mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
Sort links when necessary
This commit is contained in:
parent
dacb694e33
commit
52d3a6411d
@ -188,6 +188,7 @@ struct document {
|
||||
color_T bgcolor;
|
||||
|
||||
enum cp_status cp_status;
|
||||
unsigned int links_sorted:1; /* whether links are already sorted */
|
||||
};
|
||||
|
||||
#define document_has_frames(document_) ((document_) && (document_)->frame_desc)
|
||||
|
@ -408,6 +408,7 @@ add_dom_link(struct dom_renderer *renderer, unsigned char *string, int length,
|
||||
}
|
||||
|
||||
document->nlinks++;
|
||||
document->links_sorted = 0;
|
||||
|
||||
return link;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "bfu/listmenu.h"
|
||||
#include "document/document.h"
|
||||
#include "document/forms.h"
|
||||
#include "document/renderer.h"
|
||||
#include "util/error.h"
|
||||
#include "util/lists.h"
|
||||
#include "util/memory.h"
|
||||
@ -131,6 +132,8 @@ get_form_control_link(struct document *document, struct form_control *fc)
|
||||
if (fc->type == FC_HIDDEN)
|
||||
return -1;
|
||||
|
||||
if (!document->links_sorted) sort_links(document);
|
||||
|
||||
for (link = 0; link < document->nlinks; link++)
|
||||
if (fc == get_link_form_control(&document->links[link]))
|
||||
return link;
|
||||
|
@ -1049,6 +1049,7 @@ new_link(struct html_context *html_context, unsigned char *name, int namelen)
|
||||
|
||||
init_link_event_hooks(html_context, link);
|
||||
|
||||
document->links_sorted = 0;
|
||||
return link;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ add_document_link(struct document *document, unsigned char *uri, int length,
|
||||
}
|
||||
|
||||
document->nlinks++;
|
||||
|
||||
document->links_sorted = 0;
|
||||
return link;
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,6 @@
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
|
||||
static void sort_links(struct document *document);
|
||||
|
||||
#ifdef CONFIG_ECMASCRIPT
|
||||
/* XXX: This function is de facto obsolete, since we do not need to copy
|
||||
* snippets around anymore (we process them in one go after the document is
|
||||
@ -496,7 +494,7 @@ comp_links(struct link *l1, struct link *l2)
|
||||
return (l1->number - l2->number);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
sort_links(struct document *document)
|
||||
{
|
||||
int i;
|
||||
@ -505,6 +503,7 @@ sort_links(struct document *document)
|
||||
if_assert_failed return;
|
||||
if (!document->nlinks) return;
|
||||
|
||||
if (document->links_sorted) return;
|
||||
assert(document->links);
|
||||
if_assert_failed return;
|
||||
|
||||
@ -544,6 +543,7 @@ sort_links(struct document *document)
|
||||
document->lines1[j] = &document->links[i];
|
||||
}
|
||||
}
|
||||
document->links_sorted = 1;
|
||||
}
|
||||
|
||||
struct conv_table *
|
||||
|
@ -12,6 +12,6 @@ struct view_state;
|
||||
void render_document(struct view_state *, struct document_view *, struct document_options *);
|
||||
void render_document_frames(struct session *ses, int no_cache);
|
||||
struct conv_table *get_convert_table(unsigned char *head, int to_cp, int default_cp, int *from_cp, enum cp_status *cp_status, int ignore_server_cp);
|
||||
|
||||
void sort_links(struct document *document);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user