1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[iframe] Begining of iframe rewrite

This commit is contained in:
Witold Filipczyk 2021-07-19 22:12:03 +02:00
parent 0b2a1ab919
commit 221f246d4c
6 changed files with 42 additions and 0 deletions

View File

@ -271,6 +271,7 @@ reset_document(struct document *document)
/// kill_timer(&document->timeout);
/// free_document(document->dom);
#endif
free_uri_list(&document->iframes);
free_list(document->tags);
free_list(document->nodes);
@ -336,6 +337,7 @@ done_document(struct document *document)
mem_free_if(document->text);
free_document(document->dom);
#endif
free_uri_list(&document->iframes);
free_list(document->tags);
free_list(document->nodes);

View File

@ -223,6 +223,7 @@ struct document {
* Used for checking rerendering for available CSS imports. */
unsigned long css_magic;
#endif
struct uri_list iframes;
struct uri *uri;

View File

@ -468,6 +468,7 @@ html_iframe_do(char *a, char *object_src,
struct html_context *html_context)
{
char *name, *url = NULL;
struct uri *uri;
url = null_or_stracpy(object_src);
if (!url) url = get_url_val(a, "src", html_context->doc_cp);
@ -491,6 +492,16 @@ html_iframe_do(char *a, char *object_src,
html_context->options->framename, html_context);
}
char *url2 = join_urls(html_context->base_href, url);
uri = get_uri(url2, URI_BASE);
if (uri) {
/* Request the imported script as part of the document ... */
html_context->special_f(html_context, SP_IFRAME, name, uri);
done_uri(uri);
mem_free(url2);
}
mem_free(name);
mem_free(url);
}

View File

@ -2355,6 +2355,18 @@ html_special(struct html_context *html_context, enum html_special_type c, ...)
}
#endif
break;
case SP_IFRAME:
{
if (document) {
char *name = va_arg(l, char *);
struct uri *uri = va_arg(l, struct uri *);
add_to_uri_list(&document->iframes, uri);
}
break;
}
}
va_end(l);

View File

@ -34,6 +34,7 @@ enum html_special_type {
SP_STYLESHEET,
SP_COLOR_LINK_LINES,
SP_SCRIPT,
SP_IFRAME
};

View File

@ -477,6 +477,20 @@ load_ecmascript_imports(struct session *ses, struct document_view *doc_view)
#define load_ecmascript_imports(ses, doc_view)
#endif
static void
load_iframes(struct session *ses, struct document_view *doc_view)
{
struct document *document = doc_view->document;
struct uri *uri;
int index;
if (!document) return;
foreach_uri (uri, index, &document->iframes) {
open_uri_in_new_tab(ses, uri, 0, 0);
}
}
NONSTATIC_INLINE void
load_frames(struct session *ses, struct document_view *doc_view)
{
@ -514,6 +528,7 @@ display_timer(struct session *ses)
load_frames(ses, ses->doc_view);
load_css_imports(ses, ses->doc_view);
load_ecmascript_imports(ses, ses->doc_view);
load_iframes(ses, ses->doc_view);
process_file_requests(ses);
}