mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-10 21:12:01 +03:00
Interned string cleanup, phase 5: Move imagemap.c to corestring.
This commit is contained in:
parent
2363301c94
commit
5dadb1a0ec
@ -32,6 +32,7 @@
|
||||
#include "render/box.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/imagemap.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
@ -258,7 +259,7 @@ imagemap_extract(html_content *c)
|
||||
unsigned long maybe_maps, mapnr;
|
||||
|
||||
exc = dom_document_get_elements_by_tag_name(c->document,
|
||||
html_dom_string_map,
|
||||
corestring_dom_map,
|
||||
&nlist);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
return false;
|
||||
@ -277,7 +278,7 @@ imagemap_extract(html_content *c)
|
||||
goto out_nlist;
|
||||
}
|
||||
|
||||
exc = dom_element_get_attribute(node, html_dom_string_id,
|
||||
exc = dom_element_get_attribute(node, corestring_dom_id,
|
||||
&name);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
dom_node_unref(node);
|
||||
@ -286,7 +287,7 @@ imagemap_extract(html_content *c)
|
||||
|
||||
if (name == NULL) {
|
||||
exc = dom_element_get_attribute(node,
|
||||
html_dom_string_name,
|
||||
corestring_dom_name,
|
||||
&name);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
dom_node_unref(node);
|
||||
@ -391,10 +392,10 @@ bool imagemap_extract_map(dom_node *node, html_content *c,
|
||||
struct mapentry **entry)
|
||||
{
|
||||
if (imagemap_extract_map_entries(node, c, entry,
|
||||
html_dom_string_area) == false)
|
||||
corestring_dom_area) == false)
|
||||
return false;
|
||||
return imagemap_extract_map_entries(node, c, entry,
|
||||
html_dom_string_a);
|
||||
corestring_dom_a);
|
||||
}
|
||||
/**
|
||||
* Adds an imagemap entry to the list
|
||||
@ -414,39 +415,38 @@ imagemap_addtolist(dom_node *n, nsurl *base_url,
|
||||
struct mapentry *new_map, *temp;
|
||||
bool ret = true;
|
||||
|
||||
if (tagtype == html_dom_string_area) {
|
||||
if (dom_string_caseless_isequal(tagtype, corestring_dom_area)) {
|
||||
bool nohref = false;
|
||||
exc = dom_element_has_attribute(n,
|
||||
html_dom_string_nohref,
|
||||
&nohref);
|
||||
corestring_dom_nohref, &nohref);
|
||||
if ((exc != DOM_NO_ERR) || nohref)
|
||||
/* Skip <area nohref="anything" /> */
|
||||
goto ok_out;
|
||||
}
|
||||
|
||||
exc = dom_element_get_attribute(n, html_dom_string_href, &href);
|
||||
exc = dom_element_get_attribute(n, corestring_dom_href, &href);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
/* No href="" attribute, skip this element */
|
||||
goto ok_out;
|
||||
}
|
||||
|
||||
exc = dom_element_get_attribute(n, html_dom_string_target, &target);
|
||||
exc = dom_element_get_attribute(n, corestring_dom_target, &target);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
goto ok_out;
|
||||
}
|
||||
|
||||
exc = dom_element_get_attribute(n, html_dom_string_shape, &shape);
|
||||
exc = dom_element_get_attribute(n, corestring_dom_shape, &shape);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
goto ok_out;
|
||||
}
|
||||
|
||||
/* If there's no shape, we default to rectangles */
|
||||
if (shape == NULL)
|
||||
shape = dom_string_ref(html_dom_string_rect);
|
||||
shape = dom_string_ref(corestring_dom_rect);
|
||||
|
||||
if (!dom_string_caseless_isequal(shape, html_dom_string_default)) {
|
||||
if (!dom_string_caseless_lwc_isequal(shape, corestring_lwc_default)) {
|
||||
/* If not 'default' and there's no 'coords' give up */
|
||||
exc = dom_element_get_attribute(n, html_dom_string_coords,
|
||||
exc = dom_element_get_attribute(n, corestring_dom_coords,
|
||||
&coords);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
goto ok_out;
|
||||
@ -458,15 +458,15 @@ imagemap_addtolist(dom_node *n, nsurl *base_url,
|
||||
goto bad_out;
|
||||
}
|
||||
|
||||
if (dom_string_caseless_isequal(shape, html_dom_string_rect) ||
|
||||
dom_string_caseless_isequal(shape, html_dom_string_rectangle))
|
||||
if (dom_string_caseless_lwc_isequal(shape, corestring_lwc_rect) ||
|
||||
dom_string_caseless_lwc_isequal(shape, corestring_lwc_rectangle))
|
||||
new_map->type = IMAGEMAP_RECT;
|
||||
else if (dom_string_caseless_isequal(shape, html_dom_string_circle))
|
||||
else if (dom_string_caseless_lwc_isequal(shape, corestring_lwc_circle))
|
||||
new_map->type = IMAGEMAP_CIRCLE;
|
||||
else if (dom_string_caseless_isequal(shape, html_dom_string_poly) ||
|
||||
dom_string_caseless_isequal(shape, html_dom_string_polygon))
|
||||
else if (dom_string_caseless_lwc_isequal(shape, corestring_lwc_poly) ||
|
||||
dom_string_caseless_lwc_isequal(shape, corestring_lwc_polygon))
|
||||
new_map->type = IMAGEMAP_POLY;
|
||||
else if (dom_string_caseless_isequal(shape, html_dom_string_default))
|
||||
else if (dom_string_caseless_lwc_isequal(shape, corestring_lwc_default))
|
||||
new_map->type = IMAGEMAP_DEFAULT;
|
||||
else
|
||||
goto bad_out;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/* lwc_string strings */
|
||||
lwc_string *corestring_lwc_a;
|
||||
@ -36,7 +37,9 @@ lwc_string *corestring_lwc_bottom;
|
||||
lwc_string *corestring_lwc_button;
|
||||
lwc_string *corestring_lwc_caption;
|
||||
lwc_string *corestring_lwc_center;
|
||||
lwc_string *corestring_lwc_circle;
|
||||
lwc_string *corestring_lwc_col;
|
||||
lwc_string *corestring_lwc_default;
|
||||
lwc_string *corestring_lwc_div;
|
||||
lwc_string *corestring_lwc_embed;
|
||||
lwc_string *corestring_lwc_font;
|
||||
@ -56,6 +59,10 @@ lwc_string *corestring_lwc_middle;
|
||||
lwc_string *corestring_lwc_object;
|
||||
lwc_string *corestring_lwc_p;
|
||||
lwc_string *corestring_lwc_password;
|
||||
lwc_string *corestring_lwc_poly;
|
||||
lwc_string *corestring_lwc_polygon;
|
||||
lwc_string *corestring_lwc_rect;
|
||||
lwc_string *corestring_lwc_rectangle;
|
||||
lwc_string *corestring_lwc_right;
|
||||
lwc_string *corestring_lwc_table;
|
||||
lwc_string *corestring_lwc_tbody;
|
||||
@ -70,7 +77,9 @@ lwc_string *corestring_lwc_top;
|
||||
lwc_string *corestring_lwc_tr;
|
||||
|
||||
/* dom_string strings */
|
||||
dom_string *corestring_dom_a;
|
||||
dom_string *corestring_dom_align;
|
||||
dom_string *corestring_dom_area;
|
||||
dom_string *corestring_dom_background;
|
||||
dom_string *corestring_dom_bgcolor;
|
||||
dom_string *corestring_dom_border;
|
||||
@ -79,13 +88,21 @@ dom_string *corestring_dom_cellpadding;
|
||||
dom_string *corestring_dom_cellspacing;
|
||||
dom_string *corestring_dom_color;
|
||||
dom_string *corestring_dom_cols;
|
||||
dom_string *corestring_dom_coords;
|
||||
dom_string *corestring_dom_height;
|
||||
dom_string *corestring_dom_href;
|
||||
dom_string *corestring_dom_hspace;
|
||||
dom_string *corestring_dom_id;
|
||||
dom_string *corestring_dom_link;
|
||||
dom_string *corestring_dom_map;
|
||||
dom_string *corestring_dom_name;
|
||||
dom_string *corestring_dom_nohref;
|
||||
dom_string *corestring_dom_rect;
|
||||
dom_string *corestring_dom_rows;
|
||||
dom_string *corestring_dom_size;
|
||||
dom_string *corestring_dom_shape;
|
||||
dom_string *corestring_dom_src;
|
||||
dom_string *corestring_dom_target;
|
||||
dom_string *corestring_dom_text;
|
||||
dom_string *corestring_dom_text_javascript;
|
||||
dom_string *corestring_dom_type;
|
||||
@ -119,7 +136,9 @@ void corestrings_fini(void)
|
||||
CSS_LWC_STRING_UNREF(button);
|
||||
CSS_LWC_STRING_UNREF(caption);
|
||||
CSS_LWC_STRING_UNREF(center);
|
||||
CSS_LWC_STRING_UNREF(circle);
|
||||
CSS_LWC_STRING_UNREF(col);
|
||||
CSS_LWC_STRING_UNREF(default);
|
||||
CSS_LWC_STRING_UNREF(div);
|
||||
CSS_LWC_STRING_UNREF(embed);
|
||||
CSS_LWC_STRING_UNREF(font);
|
||||
@ -139,6 +158,10 @@ void corestrings_fini(void)
|
||||
CSS_LWC_STRING_UNREF(object);
|
||||
CSS_LWC_STRING_UNREF(p);
|
||||
CSS_LWC_STRING_UNREF(password);
|
||||
CSS_LWC_STRING_UNREF(poly);
|
||||
CSS_LWC_STRING_UNREF(polygon);
|
||||
CSS_LWC_STRING_UNREF(rect);
|
||||
CSS_LWC_STRING_UNREF(rectangle);
|
||||
CSS_LWC_STRING_UNREF(right);
|
||||
CSS_LWC_STRING_UNREF(table);
|
||||
CSS_LWC_STRING_UNREF(tbody);
|
||||
@ -161,7 +184,9 @@ void corestrings_fini(void)
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
CSS_DOM_STRING_UNREF(a);
|
||||
CSS_DOM_STRING_UNREF(align);
|
||||
CSS_DOM_STRING_UNREF(area);
|
||||
CSS_DOM_STRING_UNREF(background);
|
||||
CSS_DOM_STRING_UNREF(bgcolor);
|
||||
CSS_DOM_STRING_UNREF(border);
|
||||
@ -170,13 +195,21 @@ void corestrings_fini(void)
|
||||
CSS_DOM_STRING_UNREF(cellspacing);
|
||||
CSS_DOM_STRING_UNREF(color);
|
||||
CSS_DOM_STRING_UNREF(cols);
|
||||
CSS_DOM_STRING_UNREF(coords);
|
||||
CSS_DOM_STRING_UNREF(height);
|
||||
CSS_DOM_STRING_UNREF(href);
|
||||
CSS_DOM_STRING_UNREF(hspace);
|
||||
CSS_DOM_STRING_UNREF(id);
|
||||
CSS_DOM_STRING_UNREF(link);
|
||||
CSS_DOM_STRING_UNREF(map);
|
||||
CSS_DOM_STRING_UNREF(name);
|
||||
CSS_DOM_STRING_UNREF(nohref);
|
||||
CSS_DOM_STRING_UNREF(rect);
|
||||
CSS_DOM_STRING_UNREF(rows);
|
||||
CSS_DOM_STRING_UNREF(size);
|
||||
CSS_DOM_STRING_UNREF(shape);
|
||||
CSS_DOM_STRING_UNREF(src);
|
||||
CSS_DOM_STRING_UNREF(target);
|
||||
CSS_DOM_STRING_UNREF(text);
|
||||
CSS_DOM_STRING_UNREF(text_javascript);
|
||||
CSS_DOM_STRING_UNREF(type);
|
||||
@ -221,7 +254,9 @@ nserror corestrings_init(void)
|
||||
CSS_LWC_STRING_INTERN(button);
|
||||
CSS_LWC_STRING_INTERN(caption);
|
||||
CSS_LWC_STRING_INTERN(center);
|
||||
CSS_LWC_STRING_INTERN(circle);
|
||||
CSS_LWC_STRING_INTERN(col);
|
||||
CSS_LWC_STRING_INTERN(default);
|
||||
CSS_LWC_STRING_INTERN(div);
|
||||
CSS_LWC_STRING_INTERN(embed);
|
||||
CSS_LWC_STRING_INTERN(font);
|
||||
@ -241,6 +276,10 @@ nserror corestrings_init(void)
|
||||
CSS_LWC_STRING_INTERN(object);
|
||||
CSS_LWC_STRING_INTERN(p);
|
||||
CSS_LWC_STRING_INTERN(password);
|
||||
CSS_LWC_STRING_INTERN(poly);
|
||||
CSS_LWC_STRING_INTERN(polygon);
|
||||
CSS_LWC_STRING_INTERN(rect);
|
||||
CSS_LWC_STRING_INTERN(rectangle);
|
||||
CSS_LWC_STRING_INTERN(right);
|
||||
CSS_LWC_STRING_INTERN(table);
|
||||
CSS_LWC_STRING_INTERN(tbody);
|
||||
@ -268,7 +307,9 @@ nserror corestrings_init(void)
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
CSS_DOM_STRING_INTERN(a);
|
||||
CSS_DOM_STRING_INTERN(align);
|
||||
CSS_DOM_STRING_INTERN(area);
|
||||
CSS_DOM_STRING_INTERN(background);
|
||||
CSS_DOM_STRING_INTERN(bgcolor);
|
||||
CSS_DOM_STRING_INTERN(border);
|
||||
@ -277,15 +318,22 @@ nserror corestrings_init(void)
|
||||
CSS_DOM_STRING_INTERN(cellspacing);
|
||||
CSS_DOM_STRING_INTERN(color);
|
||||
CSS_DOM_STRING_INTERN(cols);
|
||||
CSS_DOM_STRING_INTERN(coords);
|
||||
CSS_DOM_STRING_INTERN(height);
|
||||
CSS_DOM_STRING_INTERN(href);
|
||||
CSS_DOM_STRING_INTERN(hspace);
|
||||
CSS_DOM_STRING_INTERN(id);
|
||||
CSS_DOM_STRING_INTERN(link);
|
||||
CSS_DOM_STRING_INTERN(map);
|
||||
CSS_DOM_STRING_INTERN(name);
|
||||
CSS_DOM_STRING_INTERN(nohref);
|
||||
CSS_DOM_STRING_INTERN(rect);
|
||||
CSS_DOM_STRING_INTERN(rows);
|
||||
CSS_DOM_STRING_INTERN(size);
|
||||
CSS_DOM_STRING_INTERN(shape);
|
||||
CSS_DOM_STRING_INTERN(src);
|
||||
CSS_DOM_STRING_INTERN(target);
|
||||
CSS_DOM_STRING_INTERN(text);
|
||||
CSS_DOM_STRING_INTERN(text_javascript);
|
||||
CSS_DOM_STRING_INTERN(type);
|
||||
CSS_DOM_STRING_INTERN(valign);
|
||||
CSS_DOM_STRING_INTERN(vlink);
|
||||
@ -293,6 +341,12 @@ nserror corestrings_init(void)
|
||||
CSS_DOM_STRING_INTERN(width);
|
||||
#undef CSS_DOM_STRING_INTERN
|
||||
|
||||
exc = dom_string_create_interned((const uint8_t *) "text/javascript",
|
||||
SLEN("text/javascript"),
|
||||
&corestring_dom_text_javascript);
|
||||
if ((exc != DOM_NO_ERR) || (corestring_dom_text_javascript == NULL))
|
||||
goto error;
|
||||
|
||||
return NSERROR_OK;
|
||||
|
||||
error:
|
||||
|
@ -41,7 +41,9 @@ extern lwc_string *corestring_lwc_bottom;
|
||||
extern lwc_string *corestring_lwc_button;
|
||||
extern lwc_string *corestring_lwc_caption;
|
||||
extern lwc_string *corestring_lwc_center;
|
||||
extern lwc_string *corestring_lwc_circle;
|
||||
extern lwc_string *corestring_lwc_col;
|
||||
extern lwc_string *corestring_lwc_default;
|
||||
extern lwc_string *corestring_lwc_div;
|
||||
extern lwc_string *corestring_lwc_embed;
|
||||
extern lwc_string *corestring_lwc_font;
|
||||
@ -61,6 +63,10 @@ extern lwc_string *corestring_lwc_middle;
|
||||
extern lwc_string *corestring_lwc_object;
|
||||
extern lwc_string *corestring_lwc_p;
|
||||
extern lwc_string *corestring_lwc_password;
|
||||
extern lwc_string *corestring_lwc_poly;
|
||||
extern lwc_string *corestring_lwc_polygon;
|
||||
extern lwc_string *corestring_lwc_rect;
|
||||
extern lwc_string *corestring_lwc_rectangle;
|
||||
extern lwc_string *corestring_lwc_right;
|
||||
extern lwc_string *corestring_lwc_table;
|
||||
extern lwc_string *corestring_lwc_tbody;
|
||||
@ -77,7 +83,9 @@ extern lwc_string *corestring_lwc_tr;
|
||||
struct dom_string;
|
||||
|
||||
/* dom_string strings */
|
||||
extern struct dom_string *corestring_dom_a;
|
||||
extern struct dom_string *corestring_dom_align;
|
||||
extern struct dom_string *corestring_dom_area;
|
||||
extern struct dom_string *corestring_dom_background;
|
||||
extern struct dom_string *corestring_dom_bgcolor;
|
||||
extern struct dom_string *corestring_dom_border;
|
||||
@ -86,13 +94,21 @@ extern struct dom_string *corestring_dom_cellpadding;
|
||||
extern struct dom_string *corestring_dom_cellspacing;
|
||||
extern struct dom_string *corestring_dom_color;
|
||||
extern struct dom_string *corestring_dom_cols;
|
||||
extern struct dom_string *corestring_dom_coords;
|
||||
extern struct dom_string *corestring_dom_height;
|
||||
extern struct dom_string *corestring_dom_href;
|
||||
extern struct dom_string *corestring_dom_hspace;
|
||||
extern struct dom_string *corestring_dom_id;
|
||||
extern struct dom_string *corestring_dom_link;
|
||||
extern struct dom_string *corestring_dom_map;
|
||||
extern struct dom_string *corestring_dom_name;
|
||||
extern struct dom_string *corestring_dom_nohref;
|
||||
extern struct dom_string *corestring_dom_rect;
|
||||
extern struct dom_string *corestring_dom_rows;
|
||||
extern struct dom_string *corestring_dom_size;
|
||||
extern struct dom_string *corestring_dom_shape;
|
||||
extern struct dom_string *corestring_dom_src;
|
||||
extern struct dom_string *corestring_dom_target;
|
||||
extern struct dom_string *corestring_dom_text;
|
||||
extern struct dom_string *corestring_dom_text_javascript;
|
||||
extern struct dom_string *corestring_dom_type;
|
||||
|
Loading…
Reference in New Issue
Block a user