Title: [108765] trunk/Source/WebCore
Revision
108765
Author
[email protected]
Date
2012-02-24 03:21:22 -0800 (Fri, 24 Feb 2012)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108764 => 108765)


--- trunk/Source/WebCore/ChangeLog	2012-02-24 11:01:28 UTC (rev 108764)
+++ trunk/Source/WebCore/ChangeLog	2012-02-24 11:21:22 UTC (rev 108765)
@@ -1,3 +1,24 @@
+2012-02-24  Andreas Kling  <[email protected]>
+
+        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  <[email protected]>
 
         [chromium] Avoid culling work for fully-non-opaque tiles, and add tracing for draw culling

Modified: trunk/Source/WebCore/html/HTMLEmbedElement.cpp (108764 => 108765)


--- trunk/Source/WebCore/html/HTMLEmbedElement.cpp	2012-02-24 11:01:28 UTC (rev 108764)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.cpp	2012-02-24 11:21:22 UTC (rev 108765)
@@ -85,8 +85,8 @@
 {
     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);

Modified: trunk/Source/WebCore/html/HTMLHRElement.cpp (108764 => 108765)


--- trunk/Source/WebCore/html/HTMLHRElement.cpp	2012-02-24 11:01:28 UTC (rev 108764)
+++ trunk/Source/WebCore/html/HTMLHRElement.cpp	2012-02-24 11:21:22 UTC (rev 108765)
@@ -60,11 +60,11 @@
 {
     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 @@
         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 @@
         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);
 }

Modified: trunk/Source/WebCore/html/HTMLIFrameElement.cpp (108764 => 108765)


--- trunk/Source/WebCore/html/HTMLIFrameElement.cpp	2012-02-24 11:01:28 UTC (rev 108764)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.cpp	2012-02-24 11:21:22 UTC (rev 108765)
@@ -68,7 +68,7 @@
         // 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);

Modified: trunk/Source/WebCore/html/HTMLTableElement.cpp (108764 => 108765)


--- trunk/Source/WebCore/html/HTMLTableElement.cpp	2012-02-24 11:01:28 UTC (rev 108764)
+++ trunk/Source/WebCore/html/HTMLTableElement.cpp	2012-02-24 11:21:22 UTC (rev 108765)
@@ -300,8 +300,8 @@
     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());

Modified: trunk/Source/WebCore/html/HTMLTablePartElement.cpp (108764 => 108765)


--- trunk/Source/WebCore/html/HTMLTablePartElement.cpp	2012-02-24 11:01:28 UTC (rev 108764)
+++ trunk/Source/WebCore/html/HTMLTablePartElement.cpp	2012-02-24 11:21:22 UTC (rev 108765)
@@ -59,7 +59,15 @@
             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"))
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to