r13758 vince - /trunk/netsurf/css/select.c

netsurf at semichrome.net netsurf at semichrome.net
Wed Mar 28 16:51:28 BST 2012


Author: vince
Date: Wed Mar 28 10:51:28 2012
New Revision: 13758

URL: http://source.netsurf-browser.org?rev=13758&view=rev
Log:
convert node_presentational_hint_width


Modified:
    trunk/netsurf/css/select.c

Modified: trunk/netsurf/css/select.c
URL: http://source.netsurf-browser.org/trunk/netsurf/css/select.c?rev=13758&r1=13757&r2=13758&view=diff
==============================================================================
--- trunk/netsurf/css/select.c (original)
+++ trunk/netsurf/css/select.c Wed Mar 28 10:51:28 2012
@@ -2412,61 +2412,80 @@
 					  dom_node *node, 
 					  css_hint *hint)
 {
-#ifdef FIXME
-	xmlChar *width;
-
-	if (strcmp((const char *) n->name, "hr") == 0 ||
-	    strcmp((const char *) n->name, "iframe") == 0 ||
-	    strcmp((const char *) n->name, "img") == 0 ||
-	    strcmp((const char *) n->name, "object") == 0 ||
-	    strcmp((const char *) n->name, "table") == 0 ||
-	    strcmp((const char *) n->name, "td") == 0 ||
-	    strcmp((const char *) n->name, "th") == 0 ||
-	    strcmp((const char *) n->name, "applet") == 0)
-		width = xmlGetProp(n, (const xmlChar *) "width");
-	else if (strcmp((const char *) n->name, "textarea") == 0)
-		width = xmlGetProp(n, (const xmlChar *) "cols");
-	else if (strcmp((const char *) n->name, "input") == 0) {
-		width = xmlGetProp(n, (const xmlChar *) "size");
-	} else
-		width = NULL;
-
-	if (width == NULL)
+	dom_string *name;
+	dom_string *width = NULL;
+	dom_exception err;
+	bool textarea = false;
+	bool input = false;
+
+	err = dom_node_get_node_name(node, &name);
+	if (err != DOM_NO_ERR)
 		return CSS_PROPERTY_NOT_SET;
 
-	if (parse_dimension((const char *) width, false,
+	if (dom_string_isequal(name, nscss_dom_string_hr) ||
+	    dom_string_isequal(name, nscss_dom_string_iframe) ||
+	    dom_string_isequal(name, nscss_dom_string_img) ||
+	    dom_string_isequal(name, nscss_dom_string_object) ||
+	    dom_string_isequal(name, nscss_dom_string_table) ||
+	    dom_string_isequal(name, nscss_dom_string_td) ||
+	    dom_string_isequal(name, nscss_dom_string_th) ||
+	    dom_string_isequal(name, nscss_dom_string_applet)) {
+		err = dom_element_get_attribute(node, 
+						nscss_dom_string_width, 
+						&width);
+	} else if (dom_string_isequal(name, nscss_dom_string_textarea)) {
+		textarea = true;
+		err = dom_element_get_attribute(node, 
+						nscss_dom_string_cols, 
+						&width);
+	} else if (dom_string_isequal(name, nscss_dom_string_input)) {
+		input = true;
+		err = dom_element_get_attribute(node, 
+						nscss_dom_string_size, 
+						&width);
+	}
+
+	dom_string_unref(name);
+
+	if ((err != DOM_NO_ERR) || (width == NULL)) {
+		return CSS_PROPERTY_NOT_SET;
+	}
+
+	if (parse_dimension((const char *)dom_string_data(width), 
+			    false,
 			    &hint->data.length.value,
 			    &hint->data.length.unit)) {
 		hint->status = CSS_WIDTH_SET;
-	} else {
-		xmlFree(width);
-		return CSS_PROPERTY_NOT_SET;
-	}
-
-	xmlFree(width);
-
-	if (strcmp((const char *) n->name, "textarea") == 0)
-		hint->data.length.unit = CSS_UNIT_EX;
-	else if (strcmp((const char *) n->name, "input") == 0) {
-		xmlChar *type = xmlGetProp(n, (const xmlChar *) "type");
-
-		if (type == NULL || strcasecmp((const char *) type,
-					       "text") == 0 ||
-		    strcasecmp((const char *) type,
-			       "password") == 0)
+		dom_string_unref(width);
+
+		if (textarea) {
 			hint->data.length.unit = CSS_UNIT_EX;
-		else {
-			xmlFree(type);
-			return CSS_PROPERTY_NOT_SET;
-		}
-
-		if (type != NULL)
-			xmlFree(type);
-	}
-
-	return CSS_OK;
-#endif
+		}
+
+		if (input) {
+			err = dom_element_get_attribute(node, 
+							nscss_dom_string_type, 
+							&width);
+			if ((err != DOM_NO_ERR) || (width == NULL)) {
+				return CSS_PROPERTY_NOT_SET;
+			}
+
+			if (dom_string_isequal(name, nscss_dom_string_text) ||
+			    dom_string_isequal(name, nscss_dom_string_password)) {
+				hint->data.length.unit = CSS_UNIT_EX;
+
+			}
+			dom_string_unref(width);
+
+
+		}
+
+		return CSS_OK;
+	}
+
+	dom_string_unref(width);
 	return CSS_PROPERTY_NOT_SET;
+
 }
 
 static css_error 




More information about the netsurf-commits mailing list