2011-04-28 Yael Aharon <yael.aharon@nokia.com>
authoryael.aharon@nokia.com <yael.aharon@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2011 03:36:08 +0000 (03:36 +0000)
committeryael.aharon@nokia.com <yael.aharon@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2011 03:36:08 +0000 (03:36 +0000)
        Reviewed by Beth Dakin.

        CSS sibling selector (~) does not work with :target pseudo class
        https://bugs.webkit.org/show_bug.cgi?id=26539

        * fast/css/pseudo-target-indirect-sibling-001-expected.txt: Added.
        * fast/css/pseudo-target-indirect-sibling-001.html: Added.
        * fast/css/pseudo-target-indirect-sibling-002-expected.txt: Added.
        * fast/css/pseudo-target-indirect-sibling-002.html: Added.
2011-04-28  Yael Aharon  <yael.aharon@nokia.com>

        Reviewed by Beth Dakin.

        CSS sibling selector (~) does not work with :target pseudo class
        https://bugs.webkit.org/show_bug.cgi?id=26539

        Allow style recalculation of forward siblings of elements with
        forward positional rules.

        Tests: fast/css/pseudo-target-indirect-sibling-001.html
               fast/css/pseudo-target-indirect-sibling-002.html

        * dom/Element.cpp:
        (WebCore::Element::recalcStyle):

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

LayoutTests/ChangeLog
LayoutTests/fast/css/pseudo-target-indirect-sibling-001-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/pseudo-target-indirect-sibling-001.html [new file with mode: 0644]
LayoutTests/fast/css/pseudo-target-indirect-sibling-002-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/pseudo-target-indirect-sibling-002.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp

index 9f9c3e0..06a4ca3 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-28  Yael Aharon  <yael.aharon@nokia.com>
+
+        Reviewed by Beth Dakin.
+
+        CSS sibling selector (~) does not work with :target pseudo class
+        https://bugs.webkit.org/show_bug.cgi?id=26539
+
+        * fast/css/pseudo-target-indirect-sibling-001-expected.txt: Added.
+        * fast/css/pseudo-target-indirect-sibling-001.html: Added.
+        * fast/css/pseudo-target-indirect-sibling-002-expected.txt: Added.
+        * fast/css/pseudo-target-indirect-sibling-002.html: Added.
+
 2011-04-28  Dirk Pranke  <dpranke@chromium.org>
 
         Unreviewed, expectations change. More flakiness.
diff --git a/LayoutTests/fast/css/pseudo-target-indirect-sibling-001-expected.txt b/LayoutTests/fast/css/pseudo-target-indirect-sibling-001-expected.txt
new file mode 100644 (file)
index 0000000..2d40c63
--- /dev/null
@@ -0,0 +1,13 @@
+This test passes if it finds an element whose id is "fourth" and has a sibling that comes before it and whose id matches the fragment of the url of this test.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color') is 'rgb(255, 0, 0)'
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color') is 'rgb(255, 0, 0)'
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color') is 'rgb(255, 0, 0)'
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color') is 'rgb(0, 128, 0)'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/pseudo-target-indirect-sibling-001.html b/LayoutTests/fast/css/pseudo-target-indirect-sibling-001.html
new file mode 100644 (file)
index 0000000..1411913
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+<script>
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+window.jsTestIsAsync = true;
+
+</script>
+
+<style>
+div.class { background-color: red; }
+:hover {background-color:blue; }
+:target~#fourth { background-color: green; }
+</style>
+
+</head>
+<body onhashchange="hashchange();">
+<p id="description"></p>
+<div tabindex=1" id="first" class="class"></div>
+<div tabindex=2" id="second" class="class"></div>
+<div tabindex=3" id="third" class="class"></div>
+<div tabindex=4" id="fourth" class="class"></div>
+<div id="console"></div>
+<script>
+description('This test passes if it finds an element whose id is "fourth" and has a sibling that comes before it and whose id matches the fragment of the url of this test.');
+
+
+if (window.location.hash.indexOf("second") == -1)
+    window.location.hash = "#second";
+
+function hashchange() {
+el = document.getElementById("first");
+shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color')", "'rgb(255, 0, 0)'");
+
+el = document.getElementById("second");
+shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color')", "'rgb(255, 0, 0)'");
+
+el = document.getElementById("third");
+shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color')", "'rgb(255, 0, 0)'");
+
+el = document.getElementById("fourth");
+shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color')", "'rgb(0, 128, 0)'");
+finishJSTest();
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/pseudo-target-indirect-sibling-002-expected.txt b/LayoutTests/fast/css/pseudo-target-indirect-sibling-002-expected.txt
new file mode 100644 (file)
index 0000000..831c130
--- /dev/null
@@ -0,0 +1,13 @@
+This test passes if it does not find the element whose id is "first", because even though it has a sibling whose id matches the fragment of the url of this test, that sibling comes after, not before the "first" element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color') is 'rgb(255, 0, 0)'
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color') is 'rgb(255, 0, 0)'
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color') is 'rgb(255, 0, 0)'
+PASS document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color') is 'rgb(255, 0, 0)'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/pseudo-target-indirect-sibling-002.html b/LayoutTests/fast/css/pseudo-target-indirect-sibling-002.html
new file mode 100644 (file)
index 0000000..c4c0f5a
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+<script>
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+window.jsTestIsAsync = true;
+
+</script>
+
+<style>
+div.class { background-color: red; }
+:hover {background-color:blue; }
+:target~#first { background-color: green; }
+</style>
+
+</head>
+<body onhashchange="hashchange();">
+<p id="description"></p>
+<div tabindex=1" id="first" class="class"></div>
+<div tabindex=2" id="second" class="class"></div>
+<div tabindex=3" id="third" class="class"></div>
+<div tabindex=4" id="fourth" class="class"></div>
+<div id="console"></div>
+<script>
+description('This test passes if it does not find the element whose id is "first", because even though it has a sibling whose id matches the fragment of the url of this test, that sibling comes after, not before the "first" element.');
+
+
+if (window.location.hash.indexOf("second") == -1)
+    window.location.hash = "#second";
+
+function hashchange() {
+el = document.getElementById("first");
+shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color')", "'rgb(255, 0, 0)'");
+
+el = document.getElementById("second");
+shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color')", "'rgb(255, 0, 0)'");
+
+el = document.getElementById("third");
+shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color')", "'rgb(255, 0, 0)'");
+
+el = document.getElementById("fourth");
+shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color')", "'rgb(255, 0, 0)'");
+finishJSTest();
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 8d862c8..9e3359f 100644 (file)
@@ -1,3 +1,19 @@
+2011-04-28  Yael Aharon  <yael.aharon@nokia.com>
+
+        Reviewed by Beth Dakin.
+
+        CSS sibling selector (~) does not work with :target pseudo class
+        https://bugs.webkit.org/show_bug.cgi?id=26539
+
+        Allow style recalculation of forward siblings of elements with
+        forward positional rules.
+
+        Tests: fast/css/pseudo-target-indirect-sibling-001.html
+               fast/css/pseudo-target-indirect-sibling-002.html
+
+        * dom/Element.cpp:
+        (WebCore::Element::recalcStyle):
+
 2011-04-28  Nat Duca  <nduca@chromium.org>
 
         Reviewed by Kenneth Russell.
index 5a66f04..295143a 100644 (file)
@@ -1079,6 +1079,7 @@ void Element::recalcStyle(StyleChange change)
     RefPtr<RenderStyle> currentStyle(renderStyle());
     bool hasParentStyle = parentNodeForRenderingAndStyle() ? parentNodeForRenderingAndStyle()->renderStyle() : false;
     bool hasDirectAdjacentRules = currentStyle && currentStyle->childrenAffectedByDirectAdjacentRules();
+    bool hasIndirectAdjacentRules = currentStyle && currentStyle->childrenAffectedByForwardPositionalRules();
 
     if ((change > NoChange || needsStyleRecalc())) {
         if (hasRareData())
@@ -1146,16 +1147,19 @@ void Element::recalcStyle(StyleChange change)
     // For now we will just worry about the common case, since it's a lot trickier to get the second case right
     // without doing way too much re-resolution.
     bool forceCheckOfNextElementSibling = false;
+    bool forceCheckOfAnyElementSibling = false;
     for (Node *n = firstChild(); n; n = n->nextSibling()) {
         bool childRulesChanged = n->needsStyleRecalc() && n->styleChangeType() == FullStyleChange;
-        if (forceCheckOfNextElementSibling && n->isElementNode())
+        if ((forceCheckOfNextElementSibling || forceCheckOfAnyElementSibling) && n->isElementNode())
             n->setNeedsStyleRecalc();
         if (change >= Inherit || n->isTextNode() || n->childNeedsStyleRecalc() || n->needsStyleRecalc()) {
             parentPusher.push();
             n->recalcStyle(change);
         }
-        if (n->isElementNode())
+        if (n->isElementNode()) {
             forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjacentRules;
+            forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childRulesChanged && hasIndirectAdjacentRules);
+        }
     }
     // FIXME: This does not care about sibling combinators. Will be necessary in XBL2 world.
     if (Node* shadow = shadowRoot()) {