Miscellaneous CSSParser dodging in presentation attribute parsing.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 11:21:22 +0000 (11:21 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 11:21:22 +0000 (11:21 +0000)
<http://webkit.org/b/79468>

Reviewed by Antti Koivisto.

- Bypass CSSParser when adding constant values to attribute styles.
- Added fast paths for the valid HTMLTablePartElement align values.

* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::collectStyleForAttribute):
* html/HTMLHRElement.cpp:
(WebCore::HTMLHRElement::collectStyleForAttribute):
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::collectStyleForAttribute):
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::collectStyleForAttribute):
* html/HTMLTablePartElement.cpp:
(WebCore::HTMLTablePartElement::collectStyleForAttribute):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108765 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLEmbedElement.cpp
Source/WebCore/html/HTMLHRElement.cpp
Source/WebCore/html/HTMLIFrameElement.cpp
Source/WebCore/html/HTMLTableElement.cpp
Source/WebCore/html/HTMLTablePartElement.cpp

index 61ecc24..df5bcfb 100644 (file)
@@ -1,3 +1,24 @@
+2012-02-24  Andreas Kling  <awesomekling@apple.com>
+
+        Miscellaneous CSSParser dodging in presentation attribute parsing.
+        <http://webkit.org/b/79468>
+
+        Reviewed by Antti Koivisto.
+
+        - Bypass CSSParser when adding constant values to attribute styles.
+        - Added fast paths for the valid HTMLTablePartElement align values.
+
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::HTMLEmbedElement::collectStyleForAttribute):
+        * html/HTMLHRElement.cpp:
+        (WebCore::HTMLHRElement::collectStyleForAttribute):
+        * html/HTMLIFrameElement.cpp:
+        (WebCore::HTMLIFrameElement::collectStyleForAttribute):
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::collectStyleForAttribute):
+        * html/HTMLTablePartElement.cpp:
+        (WebCore::HTMLTablePartElement::collectStyleForAttribute):
+
 2012-02-24  Dana Jansens  <danakj@chromium.org>
 
         [chromium] Avoid culling work for fully-non-opaque tiles, and add tracing for draw culling
index 9ad59a8..06cb9b1 100644 (file)
@@ -85,8 +85,8 @@ void HTMLEmbedElement::collectStyleForAttribute(Attribute* attr, StylePropertySe
 {
     if (attr->name() == hiddenAttr) {
         if (equalIgnoringCase(attr->value(), "yes") || equalIgnoringCase(attr->value(), "true")) {
-            addHTMLLengthToStyle(style, CSSPropertyWidth, "0"); // FIXME: Pass as integer.
-            addHTMLLengthToStyle(style, CSSPropertyHeight, "0"); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyWidth, 0, CSSPrimitiveValue::CSS_PX);
+            addPropertyToAttributeStyle(style, CSSPropertyHeight, 0, CSSPrimitiveValue::CSS_PX);
         }
     } else
         HTMLPlugInImageElement::collectStyleForAttribute(attr, style);
index 918b4b9..8f8b6e1 100644 (file)
@@ -60,11 +60,11 @@ void HTMLHRElement::collectStyleForAttribute(Attribute* attr, StylePropertySet*
 {
     if (attr->name() == alignAttr) {
         if (equalIgnoringCase(attr->value(), "left")) {
-            addPropertyToAttributeStyle(style, CSSPropertyMarginLeft, "0"); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyMarginLeft, 0, CSSPrimitiveValue::CSS_PX);
             addPropertyToAttributeStyle(style, CSSPropertyMarginRight, CSSValueAuto);
         } else if (equalIgnoringCase(attr->value(), "right")) {
             addPropertyToAttributeStyle(style, CSSPropertyMarginLeft, CSSValueAuto);
-            addPropertyToAttributeStyle(style, CSSPropertyMarginRight, "0"); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyMarginRight, 0, CSSPrimitiveValue::CSS_PX);
         } else {
             addPropertyToAttributeStyle(style, CSSPropertyMarginLeft, CSSValueAuto);
             addPropertyToAttributeStyle(style, CSSPropertyMarginRight, CSSValueAuto);
@@ -73,7 +73,7 @@ void HTMLHRElement::collectStyleForAttribute(Attribute* attr, StylePropertySet*
         bool ok;
         int v = attr->value().toInt(&ok);
         if (ok && !v)
-            addHTMLLengthToStyle(style, CSSPropertyWidth, "1"); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyWidth, 1, CSSPrimitiveValue::CSS_PX);
         else
             addHTMLLengthToStyle(style, CSSPropertyWidth, attr->value());
     } else if (attr->name() == colorAttr) {
@@ -90,9 +90,9 @@ void HTMLHRElement::collectStyleForAttribute(Attribute* attr, StylePropertySet*
         StringImpl* si = attr->value().impl();
         int size = si->toInt();
         if (size <= 1)
-            addPropertyToAttributeStyle(style, CSSPropertyBorderBottomWidth, String("0")); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyBorderBottomWidth, 0, CSSPrimitiveValue::CSS_PX);
         else
-            addHTMLLengthToStyle(style, CSSPropertyHeight, String::number(size - 2)); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyHeight, size - 2, CSSPrimitiveValue::CSS_PX);
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
 }
index 2eed685..a846fa4 100644 (file)
@@ -68,7 +68,7 @@ void HTMLIFrameElement::collectStyleForAttribute(Attribute* attr, StylePropertyS
         // a presentational hint that the border should be off if set to zero.
         if (!attr->isNull() && !attr->value().toInt()) {
             // Add a rule that nulls out our border width.
-            addHTMLLengthToStyle(style, CSSPropertyBorderWidth, "0"); // FIXME: Pass as integer.
+            addPropertyToAttributeStyle(style, CSSPropertyBorderWidth, 0, CSSPrimitiveValue::CSS_PX);
         }
     } else
         HTMLFrameElementBase::collectStyleForAttribute(attr, style);
index 1d2c80a..9420d95 100644 (file)
@@ -300,8 +300,8 @@ void HTMLTableElement::collectStyleForAttribute(Attribute* attr, StylePropertySe
     else if (attr->name() == heightAttr)
         addHTMLLengthToStyle(style, CSSPropertyHeight, attr->value());
     else if (attr->name() == borderAttr) {
-        int border = attr->isEmpty() ? 1 : attr->value().toInt();
-        addHTMLLengthToStyle(style, CSSPropertyBorderWidth, String::number(border)); // FIXME: Pass as integer.
+        int borderWidth = attr->isEmpty() ? 1 : attr->value().toInt();
+        addPropertyToAttributeStyle(style, CSSPropertyBorderWidth, borderWidth, CSSPrimitiveValue::CSS_PX);
     } else if (attr->name() == bordercolorAttr) {
         if (!attr->isEmpty())
             addHTMLColorToStyle(style, CSSPropertyBorderColor, attr->value());
index d481a47..8a39260 100644 (file)
@@ -59,7 +59,15 @@ void HTMLTablePartElement::collectStyleForAttribute(Attribute* attr, StyleProper
             addPropertyToAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
         }
     } else if (attr->name() == valignAttr) {
-        if (!attr->value().isEmpty())
+        if (equalIgnoringCase(attr->value(), "top"))
+            addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueTop);
+        else if (equalIgnoringCase(attr->value(), "middle"))
+            addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueMiddle);
+        else if (equalIgnoringCase(attr->value(), "bottom"))
+            addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueBottom);
+        else if (equalIgnoringCase(attr->value(), "baseline"))
+            addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueBaseline);
+        else
             addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, attr->value());
     } else if (attr->name() == alignAttr) {
         if (equalIgnoringCase(attr->value(), "middle") || equalIgnoringCase(attr->value(), "center"))