LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jan 2006 20:02:37 +0000 (20:02 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jan 2006 20:02:37 +0000 (20:02 +0000)
        Reviewed by Darin.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5983
          REGRESSION: onmouseover-powered navbar at MacNN renders incorrectly

        * fast/dynamic/hovered-detach.html: Added.
        * fast/dynamic/hovered-detach-expected.txt: Added.

WebCore:

        Test: fast/dynamic/hovered-detach.html

        Reviewed by Darin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5983
          REGRESSION: onmouseover-powered navbar at MacNN renders incorrectly

        * khtml/xml/NodeImpl.cpp:
        (WebCore::NodeImpl::detach): Set m_hovered to false and set the document's
        hoverNode to an hovered ancestor that still has a renderer.
        * rendering/render_layer.cpp: Changed static method hoverAncestor() into a
        RenderObject instance method.
        (WebCore::commonAncestor):
        (WebCore::RenderLayer::updateHoverActiveState):
        * rendering/render_object.cpp: Ditto.
        (WebCore::RenderObject::hoverAncestor)
        * rendering/render_object.h: Ditto.

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

LayoutTests/ChangeLog
LayoutTests/fast/dynamic/hovered-detach-expected.txt [new file with mode: 0644]
LayoutTests/fast/dynamic/hovered-detach.html [new file with mode: 0644]
LayoutTests/fast/inspector/matchedrules-expected.checksum [new file with mode: 0644]
LayoutTests/fast/inspector/matchedrules-expected.png [new file with mode: 0644]
WebCore/ChangeLog
WebCore/khtml/xml/NodeImpl.cpp
WebCore/rendering/render_layer.cpp
WebCore/rendering/render_object.cpp
WebCore/rendering/render_object.h

index d76af70..62f1999 100644 (file)
@@ -1,3 +1,13 @@
+2006-01-21  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Reviewed by Darin.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5983
+          REGRESSION: onmouseover-powered navbar at MacNN renders incorrectly
+
+        * fast/dynamic/hovered-detach.html: Added.
+        * fast/dynamic/hovered-detach-expected.txt: Added.
+
 2006-01-20  Maciej Stachowiak  <mjs@apple.com>
 
         - added test case for a parsing bug that was fixed in different ways in KJS
diff --git a/LayoutTests/fast/dynamic/hovered-detach-expected.txt b/LayoutTests/fast/dynamic/hovered-detach-expected.txt
new file mode 100644 (file)
index 0000000..c088517
--- /dev/null
@@ -0,0 +1,8 @@
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+This should not be red.
+This tests for a regression against http://bugzilla.opendarwin.org/show_bug.cgi?id=5983 REGRESSION: onmouseover-powered navbar at MacNN renders incorrectly.
+
+Test result: PASS
+
+
diff --git a/LayoutTests/fast/dynamic/hovered-detach.html b/LayoutTests/fast/dynamic/hovered-detach.html
new file mode 100644 (file)
index 0000000..d780d4e
--- /dev/null
@@ -0,0 +1,40 @@
+<head>
+<script type="text/javascript">
+function test()
+{
+    if (!window.layoutTestController)
+        return;
+    layoutTestController.dumpAsText();
+    eventSender.mouseMoveTo(0, 0);      // outside span
+    var a = document.getElementById('a');
+    document.body.offsetTop;            // force layout
+    eventSender.mouseMoveTo(12, 12);    // inside span
+    eventSender.mouseDown();            // required to get noticed?
+    eventSender.mouseUp();
+    a.style.display = 'none';
+    document.body.offsetTop;
+    eventSender.mouseMoveTo(0, 0);
+    a.style.display = 'inline';
+    document.body.offsetTop;
+    a.style.display = 'inline';
+    var r = document.getElementById('result');
+    var col = document.defaultView.getComputedStyle(a).color;
+    r.innerText = col == "rgb(0, 0, 0)" ? "PASS" : "FAIL: "+col;
+}
+</script>
+<style>
+    #a:hover { color: red; }
+</style>
+</head>
+<body onload="test()">
+<span id="a">This should not be red.</span>
+<hr>
+<p>
+This tests for a regression against
+<i><a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=5983">http://bugzilla.opendarwin.org/show_bug.cgi?id=5983</a>
+REGRESSION: onmouseover-powered navbar at MacNN renders incorrectly</i>.
+</p>
+<p>
+Test result: <span id="result">didn't run</span>
+</p>
+</body>
diff --git a/LayoutTests/fast/inspector/matchedrules-expected.checksum b/LayoutTests/fast/inspector/matchedrules-expected.checksum
new file mode 100644 (file)
index 0000000..f193242
--- /dev/null
@@ -0,0 +1 @@
+5ede6b32a10a6338635b4453e8dd9e59
\ No newline at end of file
diff --git a/LayoutTests/fast/inspector/matchedrules-expected.png b/LayoutTests/fast/inspector/matchedrules-expected.png
new file mode 100644 (file)
index 0000000..1416647
Binary files /dev/null and b/LayoutTests/fast/inspector/matchedrules-expected.png differ
index f44f6cb..5c10ed9 100644 (file)
@@ -1,3 +1,23 @@
+2006-01-21  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Test: fast/dynamic/hovered-detach.html
+
+        Reviewed by Darin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5983
+          REGRESSION: onmouseover-powered navbar at MacNN renders incorrectly
+
+        * khtml/xml/NodeImpl.cpp:
+        (WebCore::NodeImpl::detach): Set m_hovered to false and set the document's
+        hoverNode to an hovered ancestor that still has a renderer.
+        * rendering/render_layer.cpp: Changed static method hoverAncestor() into a
+        RenderObject instance method.
+        (WebCore::commonAncestor):
+        (WebCore::RenderLayer::updateHoverActiveState):
+        * rendering/render_object.cpp: Ditto.
+        (WebCore::RenderObject::hoverAncestor)
+        * rendering/render_object.h: Ditto.
+
 2006-01-20  David Hyatt  <hyatt@apple.com>
 
         Fix for bug 6666, pseudo-element rules incorrectly displayed
index 588f2c2..c1d0347 100644 (file)
@@ -1234,13 +1234,24 @@ void NodeImpl::detach()
     m_inDetach = true;
 //    assert(m_attached);
 
-    if (m_render)
+    DocumentImpl* doc = getDocument();
+    if (m_render) {
+        if (m_hovered && doc->hoverNode() == this) {
+            NodeImpl* e = this;
+            RenderObject* o = m_render;
+            while (o && (!e || e == this)) {
+                o = o->hoverAncestor();
+                e = o ? o->element() : 0;
+            }
+            doc->setHoverNode(e);
+        }
         m_render->destroy();
+    }
     m_render = 0;
 
-    DocumentImpl *doc = getDocument();
     if (doc)
         doc->incDOMTreeVersion();
+    m_hovered = false;
     m_attached = false;
     m_inDetach = false;
 }
index 8fdc35d..d1c7126 100644 (file)
@@ -1348,20 +1348,13 @@ void RenderLayer::clearClipRect()
     }
 }
 
-// This code has been written to anticipate the addition of CSS3-::outside and ::inside generated
-// content (and perhaps XBL).  That's why it uses the render tree and not the DOM tree.
-static RenderObject* hoverAncestor(RenderObject* obj)
-{
-    return (!obj->isInline() && obj->continuation()) ? obj->continuation() : obj->parent();
-}
-
 static RenderObject* commonAncestor(RenderObject* obj1, RenderObject* obj2)
 {
     if (!obj1 || !obj2)
         return 0;
 
-    for (RenderObject* currObj1 = obj1; currObj1; currObj1 = hoverAncestor(currObj1))
-        for (RenderObject* currObj2 = obj2; currObj2; currObj2 = hoverAncestor(currObj2))
+    for (RenderObject* currObj1 = obj1; currObj1; currObj1 = currObj1->hoverAncestor())
+        for (RenderObject* currObj2 = obj2; currObj2; currObj2 = currObj2->hoverAncestor())
             if (currObj1 == currObj2)
                 return currObj1;
 
@@ -1421,7 +1414,7 @@ void RenderLayer::updateHoverActiveState(RenderObject::NodeInfo& info)
 
     if (oldHoverObj != newHoverObj) {
         // The old hover path only needs to be cleared up to (and not including) the common ancestor;
-        for (RenderObject* curr = oldHoverObj; curr && curr != ancestor; curr = hoverAncestor(curr)) {
+        for (RenderObject* curr = oldHoverObj; curr && curr != ancestor; curr = curr->hoverAncestor()) {
             if (curr->element() && !curr->isText() && (!mustBeInActiveChain || curr->element()->inActiveChain())) {
                 curr->element()->setActive(false);
                 curr->element()->setHovered(false);
@@ -1430,7 +1423,7 @@ void RenderLayer::updateHoverActiveState(RenderObject::NodeInfo& info)
     }
 
     // Now set the hover state for our new object up to the root.
-    for (RenderObject* curr = newHoverObj; curr; curr = hoverAncestor(curr)) {
+    for (RenderObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) {
         if (curr->element() && !curr->isText() && (!mustBeInActiveChain || curr->element()->inActiveChain())) {
             curr->element()->setActive(info.active());
             curr->element()->setHovered(true);
index 80b78d8..100927e 100644 (file)
@@ -2032,6 +2032,13 @@ RenderObject *RenderObject::container() const
     return o;
 }
 
+// This code has been written to anticipate the addition of CSS3-::outside and ::inside generated
+// content (and perhaps XBL).  That's why it uses the render tree and not the DOM tree.
+RenderObject* RenderObject::hoverAncestor() const
+{
+    return (!isInline() && continuation()) ? continuation() : parent();
+}
+
 bool RenderObject::isSelectionBorder() const
 {
     SelectionState st = selectionState();
index 823974e..7a924df 100644 (file)
@@ -338,6 +338,7 @@ public:
      * positioned elements
      */
     RenderObject *container() const;
+    RenderObject* hoverAncestor() const;
 
     virtual void markAllDescendantsWithFloatsForLayout(RenderObject* floatToRemove = 0);
     void markContainingBlocksForLayout();