summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-07-26 15:57:33 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-07-26 15:57:33 +0100
commit2f408f0ecbadcfc895c5067940d840108bbbb77f (patch)
tree1773569e0be4897988104608869011029fa74ade
parent81e079e7470c0beb1cc0f88da63c340b5ed4f631 (diff)
downloadnetsurf-2f408f0ecbadcfc895c5067940d840108bbbb77f.tar.gz
netsurf-2f408f0ecbadcfc895c5067940d840108bbbb77f.tar.bz2
More use of interns.
-rw-r--r--render/box_construct.c92
-rw-r--r--utils/corestrings.c25
-rw-r--r--utils/corestrings.h8
3 files changed, 93 insertions, 32 deletions
diff --git a/render/box_construct.c b/render/box_construct.c
index fbaa9db5e..e103d44cc 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -40,6 +40,7 @@
#include "render/box.h"
#include "render/form.h"
#include "render/html_internal.h"
+#include "utils/corestrings.h"
#include "utils/locale.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -1647,13 +1648,17 @@ bool box_a(BOX_SPECIAL_PARAMS)
/* target frame [16.3] */
err = dom_element_get_attribute(n, kstr_target, &s);
if (err == DOM_NO_ERR && s != NULL) {
- if (!strcasecmp(dom_string_data(s), "_blank"))
+ if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc__blank))
box->target = TARGET_BLANK;
- else if (!strcasecmp(dom_string_data(s), "_top"))
+ else if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc__top))
box->target = TARGET_TOP;
- else if (!strcasecmp(dom_string_data(s), "_parent"))
+ else if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc__parent))
box->target = TARGET_PARENT;
- else if (!strcasecmp(dom_string_data(s), "_self"))
+ else if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc__self))
/* the default may have been overridden by a
* <base target=...>, so this is different to 0 */
box->target = TARGET_SELF;
@@ -1941,7 +1946,8 @@ bool box_object(BOX_SPECIAL_PARAMS)
return false;
}
- if (strcasecmp(dom_string_data(name), "param") != 0) {
+ if (!dom_string_caseless_lwc_isequal(name,
+ corestring_lwc_param)) {
/* The first non-param child is the start of
* the alt html. Therefore, we should break
* out of this loop. */
@@ -2122,7 +2128,8 @@ bool box_create_frameset(struct content_html_frames *f, dom_node *n,
/* common extension: frameborder="yes|no" to control all children */
err = dom_element_get_attribute(n, kstr_frameborder, &s);
if (err == DOM_NO_ERR && s != NULL) {
- if (strcasecmp(dom_string_data(s), "no") == 0)
+ if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc_no) == 0)
default_border = false;
dom_string_unref(s);
}
@@ -2194,12 +2201,13 @@ bool box_create_frameset(struct content_html_frames *f, dom_node *n,
}
if (type != DOM_ELEMENT_NODE ||
- (strcasecmp(
- dom_string_data(name),
- "frame") != 0 &&
- strcasecmp(
- dom_string_data(name),
- "frameset") != 0)) {
+ (!dom_string_caseless_lwc_isequal(
+ name,
+ corestring_lwc_frame) &&
+ !dom_string_caseless_lwc_isequal(
+ name,
+ corestring_lwc_frameset
+ ))) {
err = dom_node_get_next_sibling(c,
&next);
if (err != DOM_NO_ERR) {
@@ -2229,7 +2237,8 @@ bool box_create_frameset(struct content_html_frames *f, dom_node *n,
return false;
}
- if (strcasecmp(dom_string_data(s), "frameset") == 0) {
+ if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc_frameset)) {
dom_string_unref(s);
frame->border = 0;
if (box_create_frameset(frame, c,
@@ -2290,10 +2299,11 @@ bool box_create_frameset(struct content_html_frames *f, dom_node *n,
err = dom_element_get_attribute(c, kstr_scrolling, &s);
if (err == DOM_NO_ERR && s != NULL) {
- if (strcasecmp(dom_string_data(s), "yes") == 0)
+ if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc_yes))
frame->scrolling = SCROLLING_YES;
- else if (strcasecmp(dom_string_data(s),
- "no") == 0)
+ else if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc_no))
frame->scrolling = SCROLLING_NO;
dom_string_unref(s);
}
@@ -2447,9 +2457,11 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
err = dom_element_get_attribute(n, kstr_scrolling, &s);
if (err == DOM_NO_ERR && s != NULL) {
- if (strcasecmp(dom_string_data(s), "yes") == 0)
+ if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc_yes))
iframe->scrolling = SCROLLING_YES;
- else if (strcasecmp(dom_string_data(s), "no") == 0)
+ else if (dom_string_caseless_lwc_isequal(s,
+ corestring_lwc_no))
iframe->scrolling = SCROLLING_NO;
dom_string_unref(s);
}
@@ -2497,21 +2509,33 @@ bool box_input(BOX_SPECIAL_PARAMS)
box->gadget = gadget;
gadget->box = box;
- if (type && strcasecmp(dom_string_data(type), "password") == 0) {
+ if (type && dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_password)) {
if (box_input_text(n, content, box, 0, true) == false)
goto no_memory;
- } else if (type && strcasecmp(dom_string_data(type), "file") == 0) {
+
+ } else if (type && dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_file)) {
box->type = BOX_INLINE_BLOCK;
- } else if (type && strcasecmp(dom_string_data(type), "hidden") == 0) {
+
+ } else if (type && dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_hidden)) {
/* no box for hidden inputs */
box->type = BOX_NONE;
+
} else if (type &&
- (strcasecmp(dom_string_data(type), "checkbox") == 0 ||
- strcasecmp(dom_string_data(type), "radio") == 0)) {
+ (dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_checkbox) ||
+ dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_radio))) {
+
} else if (type &&
- (strcasecmp(dom_string_data(type), "submit") == 0 ||
- strcasecmp(dom_string_data(type), "reset") == 0 ||
- strcasecmp(dom_string_data(type), "button") == 0)) {
+ (dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_submit) ||
+ dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_reset) ||
+ dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_button))) {
struct box *inline_container, *inline_box;
if (box_button(n, content, box, 0) == false)
@@ -2551,7 +2575,9 @@ bool box_input(BOX_SPECIAL_PARAMS)
box_add_child(inline_container, inline_box);
box_add_child(box, inline_container);
- } else if (type && strcasecmp(dom_string_data(type), "image") == 0) {
+
+ } else if (type && dom_string_caseless_lwc_isequal(type,
+ corestring_lwc_image)) {
gadget->type = GADGET_IMAGE;
if (box->style && css_computed_display(box->style,
@@ -2703,14 +2729,16 @@ bool box_select(BOX_SPECIAL_PARAMS)
return false;
}
- if (strcasecmp(dom_string_data(name), "option") == 0) {
+ if (dom_string_caseless_lwc_isequal(name,
+ corestring_lwc_option)) {
dom_string_unref(name);
if (box_select_add_option(gadget, c) == false) {
dom_node_unref(c);
goto no_memory;
}
- } else if (strcasecmp(dom_string_data(name), "optgroup") == 0) {
+ } else if (dom_string_caseless_lwc_isequal(name,
+ corestring_lwc_optgroup)) {
dom_string_unref(name);
err = dom_node_get_first_child(c, &c2);
@@ -2729,8 +2757,8 @@ bool box_select(BOX_SPECIAL_PARAMS)
return false;
}
- if (strcasecmp(dom_string_data(c2_name),
- "option") == 0) {
+ if (dom_string_caseless_lwc_isequal(c2_name,
+ corestring_lwc_option)) {
dom_string_unref(c2_name);
if (box_select_add_option(gadget,
@@ -3051,7 +3079,7 @@ bool box_embed(BOX_SPECIAL_PARAMS)
return false;
}
- if (strcasecmp(dom_string_data(name), "src") == 0) {
+ if (dom_string_caseless_lwc_isequal(name, corestring_lwc_src)) {
dom_string_unref(name);
continue;
}
diff --git a/utils/corestrings.c b/utils/corestrings.c
index 777940931..05c5ac632 100644
--- a/utils/corestrings.c
+++ b/utils/corestrings.c
@@ -46,6 +46,8 @@ lwc_string *corestring_lwc_div;
lwc_string *corestring_lwc_embed;
lwc_string *corestring_lwc_file;
lwc_string *corestring_lwc_font;
+lwc_string *corestring_lwc_frame;
+lwc_string *corestring_lwc_frameset;
lwc_string *corestring_lwc_h1;
lwc_string *corestring_lwc_h2;
lwc_string *corestring_lwc_h3;
@@ -66,9 +68,13 @@ lwc_string *corestring_lwc_link;
lwc_string *corestring_lwc_meta;
lwc_string *corestring_lwc_middle;
lwc_string *corestring_lwc_multipart_form_data;
+lwc_string *corestring_lwc_no;
lwc_string *corestring_lwc_noscript;
lwc_string *corestring_lwc_object;
+lwc_string *corestring_lwc_optgroup;
+lwc_string *corestring_lwc_option;
lwc_string *corestring_lwc_p;
+lwc_string *corestring_lwc_param;
lwc_string *corestring_lwc_password;
lwc_string *corestring_lwc_poly;
lwc_string *corestring_lwc_polygon;
@@ -79,6 +85,7 @@ lwc_string *corestring_lwc_rectangle;
lwc_string *corestring_lwc_refresh;
lwc_string *corestring_lwc_reset;
lwc_string *corestring_lwc_right;
+lwc_string *corestring_lwc_src;
lwc_string *corestring_lwc_style;
lwc_string *corestring_lwc_submit;
lwc_string *corestring_lwc_table;
@@ -95,6 +102,7 @@ lwc_string *corestring_lwc_title;
lwc_string *corestring_lwc_top;
lwc_string *corestring_lwc_tr;
lwc_string *corestring_lwc_url;
+lwc_string *corestring_lwc_yes;
lwc_string *corestring_lwc__blank;
lwc_string *corestring_lwc__parent;
lwc_string *corestring_lwc__self;
@@ -175,6 +183,8 @@ void corestrings_fini(void)
CSS_LWC_STRING_UNREF(embed);
CSS_LWC_STRING_UNREF(file);
CSS_LWC_STRING_UNREF(font);
+ CSS_LWC_STRING_UNREF(frame);
+ CSS_LWC_STRING_UNREF(frameset);
CSS_LWC_STRING_UNREF(h1);
CSS_LWC_STRING_UNREF(h2);
CSS_LWC_STRING_UNREF(h3);
@@ -195,9 +205,13 @@ void corestrings_fini(void)
CSS_LWC_STRING_UNREF(meta);
CSS_LWC_STRING_UNREF(middle);
CSS_LWC_STRING_UNREF(multipart_form_data);
+ CSS_LWC_STRING_UNREF(no);
CSS_LWC_STRING_UNREF(noscript);
CSS_LWC_STRING_UNREF(object);
+ CSS_LWC_STRING_UNREF(optgroup);
+ CSS_LWC_STRING_UNREF(option);
CSS_LWC_STRING_UNREF(p);
+ CSS_LWC_STRING_UNREF(param);
CSS_LWC_STRING_UNREF(password);
CSS_LWC_STRING_UNREF(poly);
CSS_LWC_STRING_UNREF(polygon);
@@ -208,6 +222,7 @@ void corestrings_fini(void)
CSS_LWC_STRING_UNREF(refresh);
CSS_LWC_STRING_UNREF(reset);
CSS_LWC_STRING_UNREF(right);
+ CSS_LWC_STRING_UNREF(src);
CSS_LWC_STRING_UNREF(style);
CSS_LWC_STRING_UNREF(submit);
CSS_LWC_STRING_UNREF(table);
@@ -224,6 +239,7 @@ void corestrings_fini(void)
CSS_LWC_STRING_UNREF(top);
CSS_LWC_STRING_UNREF(tr);
CSS_LWC_STRING_UNREF(url);
+ CSS_LWC_STRING_UNREF(yes);
CSS_LWC_STRING_UNREF(_blank);
CSS_LWC_STRING_UNREF(_parent);
CSS_LWC_STRING_UNREF(_self);
@@ -324,6 +340,8 @@ nserror corestrings_init(void)
CSS_LWC_STRING_INTERN(embed);
CSS_LWC_STRING_INTERN(file);
CSS_LWC_STRING_INTERN(font);
+ CSS_LWC_STRING_INTERN(frame);
+ CSS_LWC_STRING_INTERN(frameset);
CSS_LWC_STRING_INTERN(h1);
CSS_LWC_STRING_INTERN(h2);
CSS_LWC_STRING_INTERN(h3);
@@ -343,9 +361,13 @@ nserror corestrings_init(void)
CSS_LWC_STRING_INTERN(link);
CSS_LWC_STRING_INTERN(meta);
CSS_LWC_STRING_INTERN(middle);
+ CSS_LWC_STRING_INTERN(no);
CSS_LWC_STRING_INTERN(noscript);
CSS_LWC_STRING_INTERN(object);
+ CSS_LWC_STRING_INTERN(optgroup);
+ CSS_LWC_STRING_INTERN(object);
CSS_LWC_STRING_INTERN(p);
+ CSS_LWC_STRING_INTERN(param);
CSS_LWC_STRING_INTERN(password);
CSS_LWC_STRING_INTERN(poly);
CSS_LWC_STRING_INTERN(polygon);
@@ -356,6 +378,7 @@ nserror corestrings_init(void)
CSS_LWC_STRING_INTERN(refresh);
CSS_LWC_STRING_INTERN(reset);
CSS_LWC_STRING_INTERN(right);
+ CSS_LWC_STRING_INTERN(src);
CSS_LWC_STRING_INTERN(style);
CSS_LWC_STRING_INTERN(submit);
CSS_LWC_STRING_INTERN(table);
@@ -371,12 +394,14 @@ nserror corestrings_init(void)
CSS_LWC_STRING_INTERN(top);
CSS_LWC_STRING_INTERN(tr);
CSS_LWC_STRING_INTERN(url);
+ CSS_LWC_STRING_INTERN(yes);
CSS_LWC_STRING_INTERN(_blank);
CSS_LWC_STRING_INTERN(_parent);
CSS_LWC_STRING_INTERN(_self);
CSS_LWC_STRING_INTERN(_top);
#undef CSS_LWC_STRING_INTERN
+
lerror = lwc_intern_string("multipart/form-data",
SLEN("multipart/form-data"),
&corestring_lwc_multipart_form_data);
diff --git a/utils/corestrings.h b/utils/corestrings.h
index df289dfe0..a3bda1632 100644
--- a/utils/corestrings.h
+++ b/utils/corestrings.h
@@ -50,6 +50,8 @@ extern lwc_string *corestring_lwc_div;
extern lwc_string *corestring_lwc_embed;
extern lwc_string *corestring_lwc_file;
extern lwc_string *corestring_lwc_font;
+extern lwc_string *corestring_lwc_frame;
+extern lwc_string *corestring_lwc_frameset;
extern lwc_string *corestring_lwc_h1;
extern lwc_string *corestring_lwc_h2;
extern lwc_string *corestring_lwc_h3;
@@ -70,9 +72,13 @@ extern lwc_string *corestring_lwc_link;
extern lwc_string *corestring_lwc_meta;
extern lwc_string *corestring_lwc_middle;
extern lwc_string *corestring_lwc_multipart_form_data;
+extern lwc_string *corestring_lwc_no;
extern lwc_string *corestring_lwc_noscript;
extern lwc_string *corestring_lwc_object;
+extern lwc_string *corestring_lwc_optgroup;
+extern lwc_string *corestring_lwc_option;
extern lwc_string *corestring_lwc_p;
+extern lwc_string *corestring_lwc_param;
extern lwc_string *corestring_lwc_password;
extern lwc_string *corestring_lwc_poly;
extern lwc_string *corestring_lwc_polygon;
@@ -83,6 +89,7 @@ extern lwc_string *corestring_lwc_rectangle;
extern lwc_string *corestring_lwc_refresh;
extern lwc_string *corestring_lwc_reset;
extern lwc_string *corestring_lwc_right;
+extern lwc_string *corestring_lwc_src;
extern lwc_string *corestring_lwc_style;
extern lwc_string *corestring_lwc_submit;
extern lwc_string *corestring_lwc_table;
@@ -99,6 +106,7 @@ extern lwc_string *corestring_lwc_title;
extern lwc_string *corestring_lwc_top;
extern lwc_string *corestring_lwc_tr;
extern lwc_string *corestring_lwc_url;
+extern lwc_string *corestring_lwc_yes;
extern lwc_string *corestring_lwc__blank;
extern lwc_string *corestring_lwc__parent;
extern lwc_string *corestring_lwc__self;