mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-03 17:54:33 +03:00
Pass nsurls through html_fetch_object.
svn path=/trunk/netsurf/; revision=12945
This commit is contained in:
parent
170136a4e8
commit
08b42089ca
@ -399,12 +399,24 @@ static bool box_construct_marker(struct box *box, const char *title,
|
|||||||
|
|
||||||
if (css_computed_list_style_image(box->style, &image_uri) ==
|
if (css_computed_list_style_image(box->style, &image_uri) ==
|
||||||
CSS_LIST_STYLE_IMAGE_URI && image_uri != NULL) {
|
CSS_LIST_STYLE_IMAGE_URI && image_uri != NULL) {
|
||||||
if (html_fetch_object(content,
|
nsurl *url;
|
||||||
lwc_string_data(image_uri),
|
nserror error;
|
||||||
marker, image_types,
|
|
||||||
content->base.available_width,
|
/* TODO: we get a url out of libcss as a lwc string, but
|
||||||
1000, false) == false)
|
* earlier we already had it as a nsurl after we
|
||||||
|
* nsurl_joined it. Can this be improved?
|
||||||
|
* For now, just making another nsurl. */
|
||||||
|
error = nsurl_create(lwc_string_data(image_uri), &url);
|
||||||
|
if (error != NSERROR_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (html_fetch_object(content, url, marker, image_types,
|
||||||
|
content->base.available_width, 1000, false) ==
|
||||||
|
false) {
|
||||||
|
nsurl_unref(url);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
nsurl_unref(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
box->list_marker = marker;
|
box->list_marker = marker;
|
||||||
@ -685,12 +697,24 @@ bool box_construct_element(struct box_construct_ctx *ctx,
|
|||||||
/* Kick off fetch for any background image */
|
/* Kick off fetch for any background image */
|
||||||
if (css_computed_background_image(box->style, &bgimage_uri) ==
|
if (css_computed_background_image(box->style, &bgimage_uri) ==
|
||||||
CSS_BACKGROUND_IMAGE_IMAGE && bgimage_uri != NULL) {
|
CSS_BACKGROUND_IMAGE_IMAGE && bgimage_uri != NULL) {
|
||||||
if (html_fetch_object(ctx->content,
|
nsurl *url;
|
||||||
lwc_string_data(bgimage_uri),
|
nserror error;
|
||||||
box, image_types,
|
|
||||||
ctx->content->base.available_width, 1000,
|
/* TODO: we get a url out of libcss as a lwc string, but
|
||||||
true) == false)
|
* earlier we already had it as a nsurl after we
|
||||||
|
* nsurl_joined it. Can this be improved?
|
||||||
|
* For now, just making another nsurl. */
|
||||||
|
error = nsurl_create(lwc_string_data(bgimage_uri), &url);
|
||||||
|
if (error != NSERROR_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (html_fetch_object(ctx->content, url, box, image_types,
|
||||||
|
ctx->content->base.available_width, 1000,
|
||||||
|
true) == false) {
|
||||||
|
nsurl_unref(url);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
nsurl_unref(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*convert_children)
|
if (*convert_children)
|
||||||
@ -1339,7 +1363,7 @@ bool box_image(BOX_SPECIAL_PARAMS)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* start fetch */
|
/* start fetch */
|
||||||
ok = html_fetch_object(content, nsurl_access(url), box, image_types,
|
ok = html_fetch_object(content, url, box, image_types,
|
||||||
content->base.available_width, 1000, false);
|
content->base.available_width, 1000, false);
|
||||||
nsurl_unref(url);
|
nsurl_unref(url);
|
||||||
|
|
||||||
@ -1536,9 +1560,8 @@ bool box_object(BOX_SPECIAL_PARAMS)
|
|||||||
|
|
||||||
/* start fetch (MIME type is ok or not specified) */
|
/* start fetch (MIME type is ok or not specified) */
|
||||||
if (!html_fetch_object(content,
|
if (!html_fetch_object(content,
|
||||||
params->data ? nsurl_access(params->data) :
|
params->data ? params->data : params->classid,
|
||||||
nsurl_access(params->classid),
|
box, CONTENT_ANY, content->base.available_width, 1000,
|
||||||
box, CONTENT_ANY, content->base.available_width, 1000,
|
|
||||||
false))
|
false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1913,8 +1936,9 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
|
|||||||
bool box_input(BOX_SPECIAL_PARAMS)
|
bool box_input(BOX_SPECIAL_PARAMS)
|
||||||
{
|
{
|
||||||
struct form_control *gadget = NULL;
|
struct form_control *gadget = NULL;
|
||||||
char *s, *type, *url;
|
char *s, *type;
|
||||||
url_func_result res;
|
nsurl *url;
|
||||||
|
nserror error;
|
||||||
|
|
||||||
type = (char *) xmlGetProp(n, (const xmlChar *) "type");
|
type = (char *) xmlGetProp(n, (const xmlChar *) "type");
|
||||||
|
|
||||||
@ -1983,28 +2007,26 @@ bool box_input(BOX_SPECIAL_PARAMS)
|
|||||||
n->parent == NULL) != CSS_DISPLAY_NONE) {
|
n->parent == NULL) != CSS_DISPLAY_NONE) {
|
||||||
if ((s = (char *) xmlGetProp(n,
|
if ((s = (char *) xmlGetProp(n,
|
||||||
(const xmlChar*) "src"))) {
|
(const xmlChar*) "src"))) {
|
||||||
res = url_join(s,
|
error = nsurl_join(content->base_url, s, &url);
|
||||||
nsurl_access(content->base_url),
|
|
||||||
&url);
|
|
||||||
xmlFree(s);
|
xmlFree(s);
|
||||||
|
if (error != NSERROR_OK)
|
||||||
|
goto no_memory;
|
||||||
|
|
||||||
/* if url is equivalent to the parent's url,
|
/* if url is equivalent to the parent's url,
|
||||||
* we've got infinite inclusion. stop it here
|
* we've got infinite inclusion. stop it here
|
||||||
* also bail if url_join failed.
|
|
||||||
*/
|
*/
|
||||||
if (res == URL_FUNC_OK &&
|
if (nsurl_compare(url, content->base_url,
|
||||||
strcasecmp(url,
|
NSURL_COMPLETE) == false) {
|
||||||
nsurl_access(
|
|
||||||
content->base_url)) != 0) {
|
|
||||||
if (!html_fetch_object(content, url,
|
if (!html_fetch_object(content, url,
|
||||||
box, image_types,
|
box, image_types,
|
||||||
content->base.
|
content->base.
|
||||||
available_width,
|
available_width,
|
||||||
1000, false)) {
|
1000, false)) {
|
||||||
free(url);
|
nsurl_unref(url);
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(url);
|
nsurl_unref(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2421,9 +2443,8 @@ bool box_embed(BOX_SPECIAL_PARAMS)
|
|||||||
box->object_params = params;
|
box->object_params = params;
|
||||||
|
|
||||||
/* start fetch */
|
/* start fetch */
|
||||||
return html_fetch_object(content, nsurl_access(params->data), box,
|
return html_fetch_object(content, params->data, box, CONTENT_ANY,
|
||||||
CONTENT_ANY, content->base.available_width, 1000,
|
content->base.available_width, 1000, false);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1388,7 +1388,7 @@ nserror html_convert_css_callback(hlcache_handle *css,
|
|||||||
* \return true on success, false on memory exhaustion
|
* \return true on success, false on memory exhaustion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool html_fetch_object(html_content *c, const char *url, struct box *box,
|
bool html_fetch_object(html_content *c, nsurl *url, struct box *box,
|
||||||
content_type permitted_types,
|
content_type permitted_types,
|
||||||
int available_width, int available_height,
|
int available_width, int available_height,
|
||||||
bool background)
|
bool background)
|
||||||
@ -1396,7 +1396,6 @@ bool html_fetch_object(html_content *c, const char *url, struct box *box,
|
|||||||
struct content_html_object *object;
|
struct content_html_object *object;
|
||||||
hlcache_child_context child;
|
hlcache_child_context child;
|
||||||
nserror error;
|
nserror error;
|
||||||
nsurl *object_url;
|
|
||||||
|
|
||||||
/* If we've already been aborted, don't bother attempting the fetch */
|
/* If we've already been aborted, don't bother attempting the fetch */
|
||||||
if (c->aborted)
|
if (c->aborted)
|
||||||
@ -1405,15 +1404,8 @@ bool html_fetch_object(html_content *c, const char *url, struct box *box,
|
|||||||
child.charset = c->encoding;
|
child.charset = c->encoding;
|
||||||
child.quirks = c->base.quirks;
|
child.quirks = c->base.quirks;
|
||||||
|
|
||||||
error = nsurl_create(url, &object_url);
|
|
||||||
if (error != NSERROR_OK) {
|
|
||||||
LOG(("failed to normalize url '%s'", url));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
object = talloc(c, struct content_html_object);
|
object = talloc(c, struct content_html_object);
|
||||||
if (object == NULL) {
|
if (object == NULL) {
|
||||||
nsurl_unref(object_url);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1424,19 +1416,16 @@ bool html_fetch_object(html_content *c, const char *url, struct box *box,
|
|||||||
object->permitted_types = permitted_types;
|
object->permitted_types = permitted_types;
|
||||||
object->background = background;
|
object->background = background;
|
||||||
|
|
||||||
error = hlcache_handle_retrieve(object_url,
|
error = hlcache_handle_retrieve(url,
|
||||||
HLCACHE_RETRIEVE_SNIFF_TYPE,
|
HLCACHE_RETRIEVE_SNIFF_TYPE,
|
||||||
content__get_url(&c->base), NULL,
|
content__get_url(&c->base), NULL,
|
||||||
html_object_callback, object, &child,
|
html_object_callback, object, &child,
|
||||||
object->permitted_types, &object->content);
|
object->permitted_types, &object->content);
|
||||||
if (error != NSERROR_OK) {
|
if (error != NSERROR_OK) {
|
||||||
talloc_free(object);
|
talloc_free(object);
|
||||||
nsurl_unref(object_url);
|
|
||||||
return error != NSERROR_NOMEM;
|
return error != NSERROR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsurl_unref(object_url);
|
|
||||||
|
|
||||||
/* add to content object list */
|
/* add to content object list */
|
||||||
object->next = c->object_list;
|
object->next = c->object_list;
|
||||||
c->object_list = object;
|
c->object_list = object;
|
||||||
|
@ -105,7 +105,7 @@ typedef struct html_content {
|
|||||||
} html_content;
|
} html_content;
|
||||||
|
|
||||||
|
|
||||||
bool html_fetch_object(html_content *c, const char *url, struct box *box,
|
bool html_fetch_object(html_content *c, nsurl *url, struct box *box,
|
||||||
content_type permitted_types,
|
content_type permitted_types,
|
||||||
int available_width, int available_height,
|
int available_width, int available_height,
|
||||||
bool background);
|
bool background);
|
||||||
|
Loading…
Reference in New Issue
Block a user