Title: [140436] trunk
Revision
140436
Author
[email protected]
Date
2013-01-22 10:22:01 -0800 (Tue, 22 Jan 2013)

Log Message

When we do setAttribute("border", null) on a table we should create a border like every other browser
https://bugs.webkit.org/show_bug.cgi?id=102112

Reviewed by Ryosuke Niwa.

Source/WebCore:

http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#tables says:
"If the [table's border] attribute is present but parsing the attribute's value using the rules for parsing
non-negative integers generates an error, a default value of 1px is expected to be used for that property instead."

Match the spec and bring us into line with other browsers by observing the 'parsing non-negative integers' algorithm.

Tests: fast/dom/HTMLTableElement/table-with-invalid-border.html
       fast/table/table-with-borderattr-null.html
       fast/table/table-with-borderattr-set-to-null.html

* html/HTMLElement.cpp:
(WebCore::HTMLElement::parseBorderWidthAttribute):
(WebCore::HTMLElement::applyBorderAttributeToStyle):
* html/HTMLElement.h:
(HTMLElement):
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::collectStyleForPresentationAttribute):
(WebCore::HTMLTableElement::parseAttribute):

LayoutTests:

* fast/dom/HTMLTableElement/table-with-invalid-border-expected.txt: Added.
* fast/dom/HTMLTableElement/table-with-invalid-border.html: Added.
* fast/table/table-with-borderattr-null-expected.txt: Added.
* fast/table/table-with-borderattr-null.html: Added.
* fast/table/table-with-borderattr-set-to-null-expected.txt: Added.
* fast/table/table-with-borderattr-set-to-null.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140435 => 140436)


--- trunk/LayoutTests/ChangeLog	2013-01-22 18:17:37 UTC (rev 140435)
+++ trunk/LayoutTests/ChangeLog	2013-01-22 18:22:01 UTC (rev 140436)
@@ -1,3 +1,17 @@
+2013-01-22  Robert Hogan  <[email protected]>
+
+        When we do setAttribute("border", null) on a table we should create a border like every other browser
+        https://bugs.webkit.org/show_bug.cgi?id=102112
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/dom/HTMLTableElement/table-with-invalid-border-expected.txt: Added.
+        * fast/dom/HTMLTableElement/table-with-invalid-border.html: Added.
+        * fast/table/table-with-borderattr-null-expected.txt: Added.
+        * fast/table/table-with-borderattr-null.html: Added.
+        * fast/table/table-with-borderattr-set-to-null-expected.txt: Added.
+        * fast/table/table-with-borderattr-set-to-null.html: Added.
+
 2013-01-22  Abhishek Arya  <[email protected]>
 
         Heap-use-after-free in WebCore::RenderObject::isDescendantOf

Added: trunk/LayoutTests/fast/dom/HTMLTableElement/table-with-invalid-border-expected.txt (0 => 140436)


--- trunk/LayoutTests/fast/dom/HTMLTableElement/table-with-invalid-border-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTableElement/table-with-invalid-border-expected.txt	2013-01-22 18:22:01 UTC (rev 140436)
@@ -0,0 +1,3 @@
+https://bugs.webkit.org/show_bug.cgi?id=102112: There should be a black box below. 
+PASS getComputedStyle(document.querySelector("table")).borderTopWidth is "1px"
+

Added: trunk/LayoutTests/fast/dom/HTMLTableElement/table-with-invalid-border.html (0 => 140436)


--- trunk/LayoutTests/fast/dom/HTMLTableElement/table-with-invalid-border.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTableElement/table-with-invalid-border.html	2013-01-22 18:22:01 UTC (rev 140436)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<head>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+</script>
+<script src=""
+</head>
+<body>
+    <p>https://bugs.webkit.org/show_bug.cgi?id=102112: There should be a black box below. <br> 
+
+    <table border="djska" width="100%" height="100%">
+        <tr>
+            <td height="26"></td>
+        </tr>
+    </table>
+    <div id="console"></div>
+    
+    <script>
+    shouldBeEqualToString('getComputedStyle(document.querySelector("table")).borderTopWidth', "1px");
+    </script>
+</body>

Added: trunk/LayoutTests/fast/table/table-with-borderattr-null-expected.txt (0 => 140436)


--- trunk/LayoutTests/fast/table/table-with-borderattr-null-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/table/table-with-borderattr-null-expected.txt	2013-01-22 18:22:01 UTC (rev 140436)
@@ -0,0 +1,3 @@
+There should be a black box below. 
+PASS getComputedStyle(document.querySelector("table")).borderTopWidth is "1px"
+

Added: trunk/LayoutTests/fast/table/table-with-borderattr-null.html (0 => 140436)


--- trunk/LayoutTests/fast/table/table-with-borderattr-null.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/table-with-borderattr-null.html	2013-01-22 18:22:01 UTC (rev 140436)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<head>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+</script>
+<script src=""
+</head>
+<body>
+    <p>There should be a black box below. <br> 
+
+    <table id="table" border="null" width="100%" height="100%">
+        <tr>
+            <td height="26"></td>
+        </tr>
+    </table>
+    <div id="console"></div>
+    
+    <script>
+    shouldBeEqualToString('getComputedStyle(document.querySelector("table")).borderTopWidth', "1px");
+    </script>
+</body>

Added: trunk/LayoutTests/fast/table/table-with-borderattr-set-to-null-expected.txt (0 => 140436)


--- trunk/LayoutTests/fast/table/table-with-borderattr-set-to-null-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/table/table-with-borderattr-set-to-null-expected.txt	2013-01-22 18:22:01 UTC (rev 140436)
@@ -0,0 +1,3 @@
+There should be a black box below. 
+PASS getComputedStyle(document.querySelector("table")).borderTopWidth is "1px"
+

Added: trunk/LayoutTests/fast/table/table-with-borderattr-set-to-null.html (0 => 140436)


--- trunk/LayoutTests/fast/table/table-with-borderattr-set-to-null.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/table-with-borderattr-set-to-null.html	2013-01-22 18:22:01 UTC (rev 140436)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<head>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+</script>
+<script src=""
+</head>
+<body>
+    <p>There should be a black box below. <br> 
+
+    <table id="table" width="100%" height="100%">
+        <tr>
+            <td height="26"></td>
+        </tr>
+    </table>
+
+    <div id="console"></div>
+    <script>
+        var table = document.getElementById("table");
+        table.setAttribute("border", null);
+        shouldBeEqualToString('getComputedStyle(document.querySelector("table")).borderTopWidth', "1px");
+    </script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (140435 => 140436)


--- trunk/Source/WebCore/ChangeLog	2013-01-22 18:17:37 UTC (rev 140435)
+++ trunk/Source/WebCore/ChangeLog	2013-01-22 18:22:01 UTC (rev 140436)
@@ -1,3 +1,29 @@
+2013-01-22  Robert Hogan  <[email protected]>
+
+        When we do setAttribute("border", null) on a table we should create a border like every other browser
+        https://bugs.webkit.org/show_bug.cgi?id=102112
+
+        Reviewed by Ryosuke Niwa.
+
+        http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#tables says:
+        "If the [table's border] attribute is present but parsing the attribute's value using the rules for parsing 
+        non-negative integers generates an error, a default value of 1px is expected to be used for that property instead."
+
+        Match the spec and bring us into line with other browsers by observing the 'parsing non-negative integers' algorithm.
+
+        Tests: fast/dom/HTMLTableElement/table-with-invalid-border.html
+               fast/table/table-with-borderattr-null.html
+               fast/table/table-with-borderattr-set-to-null.html
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::parseBorderWidthAttribute):
+        (WebCore::HTMLElement::applyBorderAttributeToStyle):
+        * html/HTMLElement.h:
+        (HTMLElement):
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::collectStyleForPresentationAttribute):
+        (WebCore::HTMLTableElement::parseAttribute):
+
 2013-01-22  Abhishek Arya  <[email protected]>
 
         Heap-use-after-free in WebCore::RenderObject::isDescendantOf

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (140435 => 140436)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2013-01-22 18:17:37 UTC (rev 140435)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2013-01-22 18:22:01 UTC (rev 140436)
@@ -133,18 +133,18 @@
     return CSSValueWebkitIsolate;
 }
 
-static unsigned parseBorderWidthAttribute(const Attribute& attribute)
+unsigned HTMLElement::parseBorderWidthAttribute(const QualifiedName& name, const AtomicString& value) const
 {
-    ASSERT(attribute.name() == borderAttr);
+    ASSERT_UNUSED(name, name == borderAttr);
     unsigned borderWidth = 0;
-    if (!attribute.isEmpty())
-        parseHTMLNonNegativeInteger(attribute.value(), borderWidth);
+    if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, borderWidth))
+        return hasLocalName(tableTag) ? 1 : borderWidth;
     return borderWidth;
 }
 
 void HTMLElement::applyBorderAttributeToStyle(const Attribute& attribute, StylePropertySet* style)
 {
-    addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, parseBorderWidthAttribute(attribute), CSSPrimitiveValue::CSS_PX);
+    addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, parseBorderWidthAttribute(attribute.name(), attribute.value()), CSSPrimitiveValue::CSS_PX);
     addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
 }
 

Modified: trunk/Source/WebCore/html/HTMLElement.h (140435 => 140436)


--- trunk/Source/WebCore/html/HTMLElement.h	2013-01-22 18:17:37 UTC (rev 140435)
+++ trunk/Source/WebCore/html/HTMLElement.h	2013-01-22 18:22:01 UTC (rev 140436)
@@ -120,6 +120,7 @@
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void collectStyleForPresentationAttribute(const Attribute&, StylePropertySet*) OVERRIDE;
+    unsigned parseBorderWidthAttribute(const QualifiedName&, const AtomicString& value) const;
 
     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     void calculateAndAdjustDirectionality();

Modified: trunk/Source/WebCore/html/HTMLTableElement.cpp (140435 => 140436)


--- trunk/Source/WebCore/html/HTMLTableElement.cpp	2013-01-22 18:17:37 UTC (rev 140435)
+++ trunk/Source/WebCore/html/HTMLTableElement.cpp	2013-01-22 18:22:01 UTC (rev 140436)
@@ -310,10 +310,9 @@
         addHTMLLengthToStyle(style, CSSPropertyWidth, attribute.value());
     else if (attribute.name() == heightAttr)
         addHTMLLengthToStyle(style, CSSPropertyHeight, attribute.value());
-    else if (attribute.name() == borderAttr) {
-        int borderWidth = attribute.isEmpty() ? 1 : attribute.value().toInt();
-        addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, borderWidth, CSSPrimitiveValue::CSS_PX);
-    } else if (attribute.name() == bordercolorAttr) {
+    else if (attribute.name() == borderAttr) 
+        addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, parseBorderWidthAttribute(attribute.name(), attribute.value()), CSSPrimitiveValue::CSS_PX);
+    else if (attribute.name() == bordercolorAttr) {
         if (!attribute.isEmpty())
             addHTMLColorToStyle(style, CSSPropertyBorderColor, attribute.value());
     } else if (attribute.name() == bgcolorAttr)
@@ -376,11 +375,7 @@
 
     if (name == borderAttr)  {
         // FIXME: This attribute is a mess.
-        m_borderAttr = true;
-        if (!value.isNull()) {
-            int border = value.isEmpty() ? 1 : value.toInt();
-            m_borderAttr = border;
-        }
+        m_borderAttr = parseBorderWidthAttribute(name, value);
     } else if (name == bordercolorAttr) {
         m_borderColorAttr = !value.isEmpty();
     } else if (name == frameAttr) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to