Title: [160719] trunk
Revision
160719
Author
[email protected]
Date
2013-12-17 12:10:12 -0800 (Tue, 17 Dec 2013)

Log Message

Invalid dir attributes should resolve to ltr
https://bugs.webkit.org/show_bug.cgi?id=125830

Source/WebCore:

Reviewed by Darin Adler.

Merge https://chromium.googlesource.com/chromium/blink/+/2d592d1c998bec9438e421e1ce1ee6caba05a884

The dir attribute should resolve to direction: ltr by default when the attribute value is
"not in a defined state": http://www.w3.org/TR/2013/WD-html51-20130528/dom.html#the-directionality

Test: fast/dom/HTMLElement/set-and-clear-dir-attribute.html

* html/HTMLElement.cpp:
(WebCore::isLTROrRTLIgnoringCase): Extracted from HTMLElement::directionality.
(WebCore::HTMLElement::collectStyleForPresentationAttribute):
(WebCore::HTMLElement::directionality):

LayoutTests:

Reviewed by Darin Adler.

* fast/dom/HTMLElement/set-and-clear-dir-attribute-expected.txt: Added.
* fast/dom/HTMLElement/set-and-clear-dir-attribute.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (160718 => 160719)


--- trunk/LayoutTests/ChangeLog	2013-12-17 19:46:32 UTC (rev 160718)
+++ trunk/LayoutTests/ChangeLog	2013-12-17 20:10:12 UTC (rev 160719)
@@ -1,3 +1,13 @@
+2013-12-17  Ryosuke Niwa  <[email protected]>
+
+        Invalid dir attributes should resolve to ltr
+        https://bugs.webkit.org/show_bug.cgi?id=125830
+
+        Reviewed by Darin Adler.
+
+        * fast/dom/HTMLElement/set-and-clear-dir-attribute-expected.txt: Added.
+        * fast/dom/HTMLElement/set-and-clear-dir-attribute.html: Added.
+
 2013-12-17  Mihnea Ovidenie  <[email protected]>
 
         [CSSRegions] Incorrect repaint of fixed element with transformed parent

Added: trunk/LayoutTests/fast/dom/HTMLElement/set-and-clear-dir-attribute-expected.txt (0 => 160719)


--- trunk/LayoutTests/fast/dom/HTMLElement/set-and-clear-dir-attribute-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLElement/set-and-clear-dir-attribute-expected.txt	2013-12-17 20:10:12 UTC (rev 160719)
@@ -0,0 +1,20 @@
+This tests that setting the dir attribute to rtl and clearing it defaults to ltr.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS getComputedStyle(document.body).direction is "ltr"
+PASS getComputedStyle(someElementInBody).direction is "ltr"
+PASS document.body.dir = "rtl"; getComputedStyle(document.body).direction is "rtl"
+PASS getComputedStyle(someElementInBody).direction is "rtl"
+PASS someElementInBody.dir = "rtl"; getComputedStyle(someElementInBody).direction is "rtl"
+PASS document.body.dir = ""; getComputedStyle(document.body).direction is "ltr"
+PASS getComputedStyle(someElementInBody).direction is "rtl"
+PASS someElementInBody.dir = ""; getComputedStyle(someElementInBody).direction is "ltr"
+PASS someElementInBody.dir = "ltr"; getComputedStyle(someElementInBody).direction is "ltr"
+PASS document.body.dir = "rtl"; getComputedStyle(document.body).direction is "rtl"
+PASS someElementInBody.dir = ""; getComputedStyle(someElementInBody).direction is "rtl"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/HTMLElement/set-and-clear-dir-attribute.html (0 => 160719)


--- trunk/LayoutTests/fast/dom/HTMLElement/set-and-clear-dir-attribute.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLElement/set-and-clear-dir-attribute.html	2013-12-17 20:10:12 UTC (rev 160719)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html dir="ltr">
+<body>
+<div id="someElementInBody"></div>
+<script src=""
+<script>
+
+description('This tests that setting the dir attribute to rtl and clearing it defaults to ltr.');
+
+var someElementInBody = document.getElementById('someElementInBody');
+
+shouldBeEqualToString('getComputedStyle(document.body).direction', 'ltr');
+shouldBeEqualToString('getComputedStyle(someElementInBody).direction', 'ltr');
+shouldBeEqualToString('document.body.dir = "rtl"; getComputedStyle(document.body).direction', 'rtl');
+shouldBeEqualToString('getComputedStyle(someElementInBody).direction', 'rtl');
+shouldBeEqualToString('someElementInBody.dir = "rtl"; getComputedStyle(someElementInBody).direction', 'rtl');
+shouldBeEqualToString('document.body.dir = ""; getComputedStyle(document.body).direction', 'ltr');
+shouldBeEqualToString('getComputedStyle(someElementInBody).direction', 'rtl');
+shouldBeEqualToString('someElementInBody.dir = ""; getComputedStyle(someElementInBody).direction', 'ltr');
+shouldBeEqualToString('someElementInBody.dir = "ltr"; getComputedStyle(someElementInBody).direction', 'ltr');
+shouldBeEqualToString('document.body.dir = "rtl"; getComputedStyle(document.body).direction', 'rtl');
+shouldBeEqualToString('someElementInBody.dir = ""; getComputedStyle(someElementInBody).direction', 'rtl');
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (160718 => 160719)


--- trunk/Source/WebCore/ChangeLog	2013-12-17 19:46:32 UTC (rev 160718)
+++ trunk/Source/WebCore/ChangeLog	2013-12-17 20:10:12 UTC (rev 160719)
@@ -1,3 +1,22 @@
+2013-12-17  Ryosuke Niwa  <[email protected]>
+
+        Invalid dir attributes should resolve to ltr
+        https://bugs.webkit.org/show_bug.cgi?id=125830
+
+        Reviewed by Darin Adler.
+        
+        Merge https://chromium.googlesource.com/chromium/blink/+/2d592d1c998bec9438e421e1ce1ee6caba05a884
+
+        The dir attribute should resolve to direction: ltr by default when the attribute value is
+        "not in a defined state": http://www.w3.org/TR/2013/WD-html51-20130528/dom.html#the-directionality
+
+        Test: fast/dom/HTMLElement/set-and-clear-dir-attribute.html
+
+        * html/HTMLElement.cpp:
+        (WebCore::isLTROrRTLIgnoringCase): Extracted from HTMLElement::directionality.
+        (WebCore::HTMLElement::collectStyleForPresentationAttribute):
+        (WebCore::HTMLElement::directionality):
+
 2013-12-17  Mihnea Ovidenie  <[email protected]>
 
         [CSSRegions] Incorrect repaint of fixed element with transformed parent

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (160718 => 160719)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2013-12-17 19:46:32 UTC (rev 160718)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2013-12-17 20:10:12 UTC (rev 160719)
@@ -162,6 +162,11 @@
     return StyledElement::isPresentationAttribute(name);
 }
 
+static bool isLTROrRTLIgnoringCase(const AtomicString& dirAttributeValue)
+{
+    return equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase(dirAttributeValue, "ltr");
+}
+
 void HTMLElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStyleProperties& style)
 {
     if (name == alignAttr) {
@@ -194,7 +199,8 @@
         if (equalIgnoringCase(value, "auto"))
             addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(*this));
         else {
-            addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, value);
+            if (isLTROrRTLIgnoringCase(value))
+                addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, value);
             if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag))
                 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, CSSValueEmbed);
         }
@@ -866,7 +872,7 @@
         // Skip elements with valid dir attribute
         if (node->isElementNode()) {
             AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(dirAttr);
-            if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase(dirAttributeValue, "ltr") || equalIgnoringCase(dirAttributeValue, "auto")) {
+            if (isLTROrRTLIgnoringCase(dirAttributeValue) || equalIgnoringCase(dirAttributeValue, "auto")) {
                 node = NodeTraversal::nextSkippingChildren(node, this);
                 continue;
             }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to