WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 18:52:09 +0000 (18:52 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 18:52:09 +0000 (18:52 +0000)
        Reviewed by Darin Adler.

        - fix a bug where CSS rules with :hover in the ancestor chain stopped
          working after changing the inline style declaration of the ancestor

        Test: fast/css/affected-by-hover-after-style-change.html

        * dom/Element.cpp:
        (WebCore::Element::recalcStyle): If we are not forcing style
        recalculation for all descendants, preserve any "affected by
        {hover|active|drag} bits that we may have acquired from them.
        Also renamed _style to currentStyle.

WebKitSite:

        Reviewed by Darin Adler.

        - removed a workaround for the bug fixed in the WebCore part of this
          patch

        * misc/DatabaseExample.html:

LayoutTests:

        Reviewed by Darin Adler.

        - test that CSS rules with :hover in the ancestor chain continue to work
          after changing the inline style declaration of the ancestor

        * fast/css/affected-by-hover-after-style-change.html: Added.
        * platform/mac/fast/css/affected-by-hover-after-style-change-expected.checksum: Added.
        * platform/mac/fast/css/affected-by-hover-after-style-change-expected.png: Added.
        * platform/mac/fast/css/affected-by-hover-after-style-change-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/affected-by-hover-after-style-change.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Element.cpp
WebKitSite/ChangeLog
WebKitSite/misc/DatabaseExample.html

index 20bcdcc1607bc36bdf4a9ff46b852dc12822f933..391fb4e8ab8b6938af925062806193c2f8e45cd8 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-07  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - test that CSS rules with :hover in the ancestor chain continue to work
+          after changing the inline style declaration of the ancestor
+
+        * fast/css/affected-by-hover-after-style-change.html: Added.
+        * platform/mac/fast/css/affected-by-hover-after-style-change-expected.checksum: Added.
+        * platform/mac/fast/css/affected-by-hover-after-style-change-expected.png: Added.
+        * platform/mac/fast/css/affected-by-hover-after-style-change-expected.txt: Added.
+
 2007-11-06  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/css/affected-by-hover-after-style-change.html b/LayoutTests/fast/css/affected-by-hover-after-style-change.html
new file mode 100644 (file)
index 0000000..06dbb85
--- /dev/null
@@ -0,0 +1,15 @@
+<style>
+    .bar { width: 100px; height: 100px; background-color: red; }
+    .foo:hover .bar { background-color: green; }
+</style>
+<div class="foo" id="target">
+    <div class="bar"></div>
+</div>
+<script>
+    document.body.offsetLeft;
+    document.getElementById("target").style.left = "0";
+    if (window.eventSender) {
+        eventSender.mouseMoveTo(200, 50);
+        eventSender.mouseMoveTo(210, 50);
+    }
+</script>
diff --git a/LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.checksum b/LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.checksum
new file mode 100644 (file)
index 0000000..ae7a7bd
--- /dev/null
@@ -0,0 +1 @@
+18f1f64eab31dfb69467a497de9442d7
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.png b/LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.png
new file mode 100644 (file)
index 0000000..fc96c0b
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.txt b/LayoutTests/platform/mac/fast/css/affected-by-hover-after-style-change-expected.txt
new file mode 100644 (file)
index 0000000..7f22e63
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x100
+        RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
index 1461cd97d5f895f1a8e1932db188a100fc2a4813..787de3bb45f7284c04c6f50017d3a9d6442056fe 100644 (file)
@@ -1,3 +1,18 @@
+2007-11-07  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - fix a bug where CSS rules with :hover in the ancestor chain stopped
+          working after changing the inline style declaration of the ancestor
+
+        Test: fast/css/affected-by-hover-after-style-change.html
+
+        * dom/Element.cpp:
+        (WebCore::Element::recalcStyle): If we are not forcing style
+        recalculation for all descendants, preserve any "affected by
+        {hover|active|drag} bits that we may have acquired from them.
+        Also renamed _style to currentStyle.
+
 2007-11-06  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Adam.
index afaaced1f292476bace2fffc84e27880c8ff4828..5f602de21658c821792237c1438cc8425f080bae 100644 (file)
@@ -697,7 +697,7 @@ void Element::detach()
 void Element::recalcStyle(StyleChange change)
 {
     // ### should go away and be done in renderobject
-    RenderStyle* _style = renderStyle();
+    RenderStyle* currentStyle = renderStyle();
     bool hasParentStyle = parentNode() ? parentNode()->renderStyle() : false;
 
 #if ENABLE(SVG)
@@ -711,7 +711,7 @@ void Element::recalcStyle(StyleChange change)
     }
     if (hasParentStyle && (change >= Inherit || changed())) {
         RenderStyle *newStyle = document()->styleSelector()->styleForElement(this);
-        StyleChange ch = diff(_style, newStyle);
+        StyleChange ch = diff(currentStyle, newStyle);
         if (ch == Detach) {
             if (attached())
                 detach();
@@ -723,11 +723,21 @@ void Element::recalcStyle(StyleChange change)
             newStyle->deref(document()->renderArena());
             return;
         }
-        else if (ch != NoChange) {
+
+        if (newStyle && change != Force && styleChangeType() != FullStyleChange && document()->usesDescendantRules()) {
+            // Preserve "affected by" bits that were propagated to us from descendants
+            if (currentStyle->affectedByHoverRules())
+                newStyle->setAffectedByHoverRules(true);
+            if (currentStyle->affectedByActiveRules())
+                newStyle->setAffectedByActiveRules(true);
+            if (currentStyle->affectedByDragRules())
+                newStyle->setAffectedByDragRules(true);
+        }
+
+        if (ch != NoChange) {
             if (newStyle)
                 setRenderStyle(newStyle);
-        }
-        else if (changed() && newStyle && (document()->usesSiblingRules() || document()->usesDescendantRules())) {
+        } else if (changed() && newStyle && (document()->usesSiblingRules() || document()->usesDescendantRules())) {
             // Although no change occurred, we use the new style so that the cousin style sharing code won't get
             // fooled into believing this style is the same.  This is only necessary if the document actually uses
             // sibling/descendant rules, since otherwise it isn't possible for ancestor styles to affect sharing of
index 3672dae0004a5dc927a79c921c50d52a19007032..eb9c51ace96af154ddc961ea523c3bef3e72c28e 100644 (file)
@@ -1,3 +1,12 @@
+2007-11-07  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - removed a workaround for the bug fixed in the WebCore part of this
+          patch
+
+        * misc/DatabaseExample.html:
+
 2007-11-04  Timothy Hatcher  <timothy@apple.com>
 
         Land the HTML Editing Toolbar demo from WWDC 2007.
index b62ac82c957c141b39db9a1828c0e7575b05a7b5..7abefc0ca3579e8340da6be71380bef32cf78a2d 100644 (file)
@@ -16,8 +16,6 @@ body {
     -webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5);
 }
 
-/* FIXME: this empty rule works around a bug in our css handling */
-.note:hover { }
 .note:hover .closebutton {
     display: block;
 }