Title: [102632] trunk
Revision
102632
Author
[email protected]
Date
2011-12-12 15:51:03 -0800 (Mon, 12 Dec 2011)

Log Message

When the mouse is dragged out of an :active element, it should lose :hover.
https://bugs.webkit.org/show_bug.cgi?id=57206

Patch by Jeremy Apthorp <[email protected]> on 2011-12-12
Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: fast/css/hover-active-drag.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseMoveEvent): Don't mark mouse-drag hit tests read-only, since they no longer are.
(WebCore::EventHandler::dragSourceEndedAt): Send a hit test request when the mouse goes up after a drag, so
RenderLayer has a chance to update the hover/active status.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateHoverActiveState): Only allow the :active state to change on mouse down or mouse up.

LayoutTests:

* fast/css/hover-active-drag-expected.txt: Added.
* fast/css/hover-active-drag.html: Added.
* platform/mac/fast/css/hover-active-drag-expected.txt: Removed.
* platform/chromium/fast/css/hover-active-drag-expected.txt: Removed.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (102631 => 102632)


--- trunk/LayoutTests/ChangeLog	2011-12-12 23:21:51 UTC (rev 102631)
+++ trunk/LayoutTests/ChangeLog	2011-12-12 23:51:03 UTC (rev 102632)
@@ -1,3 +1,15 @@
+2011-12-12  Jeremy Apthorp  <[email protected]>
+
+        When the mouse is dragged out of an :active element, it should lose :hover.
+        https://bugs.webkit.org/show_bug.cgi?id=57206
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/css/hover-active-drag-expected.txt: Added.
+        * fast/css/hover-active-drag.html: Added.
+        * platform/mac/fast/css/hover-active-drag-expected.txt: Removed.
+        * platform/chromium/fast/css/hover-active-drag-expected.txt: Removed.
+
 2011-12-12  Kenneth Russell  <[email protected]>
 
         Unreviewed Chromium expectations update; skip

Copied: trunk/LayoutTests/fast/css/hover-active-drag-expected.txt (from rev 102631, trunk/LayoutTests/platform/chromium/fast/css/hover-active-drag-expected.txt) (0 => 102632)


--- trunk/LayoutTests/fast/css/hover-active-drag-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/hover-active-drag-expected.txt	2011-12-12 23:51:03 UTC (rev 102632)
@@ -0,0 +1,20 @@
+Dragging out of an element should cause it to lose :hover
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS background is "rgb(255, 0, 0)"
+PASS background is "rgb(0, 0, 0)"
+PASS background is "rgb(255, 255, 0)"
+PASS background is "rgb(0, 0, 0)"
+PASS background is "rgb(0, 255, 0)"
+PASS background is "rgb(0, 0, 0)"
+PASS background is "rgb(0, 255, 0)"
+PASS background is "rgb(0, 0, 0)"
+PASS background is "rgb(0, 0, 0)"
+PASS background is "rgb(0, 0, 0)"
+
+
+
+
+
+

Added: trunk/LayoutTests/fast/css/hover-active-drag.html (0 => 102632)


--- trunk/LayoutTests/fast/css/hover-active-drag.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/hover-active-drag.html	2011-12-12 23:51:03 UTC (rev 102632)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<style>
+  div { background: rgb(0, 0, 0); }
+  div:hover { background: rgb(255, 0, 0); }
+  div:hover:active { background: rgb(255, 255, 0); }
+  div:active { background: rgb(0, 255, 0); }
+  div {
+    width: 100px;
+    height: 100px;
+    border: 2px solid rgb(0, 0, 255);
+  }
+</style>
+
+<body>
+  <div id="box"></div>
+  <div id="box2"></div>
+  <pre id="description"></div>
+  <pre id="console"></pre>
+</body>
+
+<script src=""
+<script>
+  function shouldHaveBackground(element, bg) {
+    background = "" null).getPropertyValue("background-color")
+    shouldBeEqualToString('background', bg)
+  }
+
+  if (window.layoutTestController) {
+    description("Dragging out of an element should cause it to lose :hover")
+    var box = document.getElementById('box')
+    var box2 = document.getElementById('box2')
+    layoutTestController.dumpAsText();
+
+    eventSender.dragMode = false;
+    // This mouse click seems to be required for WebKit's event handling to
+    // pick up the :hover class. See https://bugs.webkit.org/show_bug.cgi?id=74264
+    eventSender.mouseDown()
+    eventSender.mouseUp()
+
+    // Move into the first box.
+    eventSender.mouseMoveTo(50, 50)
+    shouldHaveBackground(box, 'rgb(255, 0, 0)')
+    shouldHaveBackground(box2, 'rgb(0, 0, 0)')
+
+    eventSender.mouseDown()
+    shouldHaveBackground(box, 'rgb(255, 255, 0)')
+    shouldHaveBackground(box2, 'rgb(0, 0, 0)')
+
+    // With the mouse still down, move into the second box.
+    eventSender.mouseMoveTo(50, 150)
+    shouldHaveBackground(box, 'rgb(0, 255, 0)')
+    shouldHaveBackground(box2, 'rgb(0, 0, 0)')
+
+    // Mouse still down, move outside of both boxes.
+    eventSender.mouseMoveTo(400, 50)
+    shouldHaveBackground(box, 'rgb(0, 255, 0)')
+    shouldHaveBackground(box2, 'rgb(0, 0, 0)')
+
+    eventSender.mouseUp()
+    shouldHaveBackground(box, 'rgb(0, 0, 0)')
+    shouldHaveBackground(box2, 'rgb(0, 0, 0)')
+  }
+</script>

Deleted: trunk/LayoutTests/platform/chromium/fast/css/hover-active-drag-expected.txt (102631 => 102632)


--- trunk/LayoutTests/platform/chromium/fast/css/hover-active-drag-expected.txt	2011-12-12 23:21:51 UTC (rev 102631)
+++ trunk/LayoutTests/platform/chromium/fast/css/hover-active-drag-expected.txt	2011-12-12 23:51:03 UTC (rev 102632)
@@ -1,20 +0,0 @@
-Dragging out of an element should cause it to lose :hover
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-PASS background is "rgb(255, 0, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(255, 255, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(0, 255, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(0, 255, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(0, 0, 0)"
-
-
-
-
-
-

Deleted: trunk/LayoutTests/platform/mac/fast/css/hover-active-drag-expected.txt (102631 => 102632)


--- trunk/LayoutTests/platform/mac/fast/css/hover-active-drag-expected.txt	2011-12-12 23:21:51 UTC (rev 102631)
+++ trunk/LayoutTests/platform/mac/fast/css/hover-active-drag-expected.txt	2011-12-12 23:51:03 UTC (rev 102632)
@@ -1,20 +0,0 @@
-Dragging out of an element should cause it to lose :hover
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-FAIL background should be rgb(255, 0, 0). Was rgb(0, 0, 0).
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(255, 255, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(0, 255, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(0, 255, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(0, 0, 0)"
-PASS background is "rgb(0, 0, 0)"
-
-
-
-
-
-

Modified: trunk/Source/WebCore/ChangeLog (102631 => 102632)


--- trunk/Source/WebCore/ChangeLog	2011-12-12 23:21:51 UTC (rev 102631)
+++ trunk/Source/WebCore/ChangeLog	2011-12-12 23:51:03 UTC (rev 102632)
@@ -1,3 +1,19 @@
+2011-12-12  Jeremy Apthorp  <[email protected]>
+
+        When the mouse is dragged out of an :active element, it should lose :hover.
+        https://bugs.webkit.org/show_bug.cgi?id=57206
+
+        Reviewed by Ryosuke Niwa.
+
+        Test: fast/css/hover-active-drag.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMouseMoveEvent): Don't mark mouse-drag hit tests read-only, since they no longer are.
+        (WebCore::EventHandler::dragSourceEndedAt): Send a hit test request when the mouse goes up after a drag, so
+        RenderLayer has a chance to update the hover/active status.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateHoverActiveState): Only allow the :active state to change on mouse down or mouse up.
+
 2011-12-12  Kenneth Russell  <[email protected]>
 
         Unreviewed Windows build fix after http://trac.webkit.org/changeset/102619 .

Modified: trunk/Source/WebCore/page/EventHandler.cpp (102631 => 102632)


--- trunk/Source/WebCore/page/EventHandler.cpp	2011-12-12 23:21:51 UTC (rev 102631)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2011-12-12 23:51:03 UTC (rev 102632)
@@ -1612,14 +1612,7 @@
     if (m_lastScrollbarUnderMouse && m_mousePressed)
         return m_lastScrollbarUnderMouse->mouseMoved(mouseEvent);
 
-    // Mouse events should be treated as "read-only" in prepareMouseEvent if the mouse is 
-    // pressed and we are allowed to select OR if we're updating only scrollbars. This 
-    // means that :hover and :active freeze in the state they were in, rather than updating 
-    // for nodes the mouse moves over while you hold the mouse down (in the mouse pressed case)
-    // or while the window is not key (as in the onlyUpdateScrollbars case).
     HitTestRequest::HitTestRequestType hitType = HitTestRequest::MouseMove;
-    if ((m_mousePressed && m_mouseDownMayStartSelect) || onlyUpdateScrollbars)
-        hitType |= HitTestRequest::ReadOnly;
     if (m_mousePressed)
         hitType |= HitTestRequest::Active;
 
@@ -2761,6 +2754,10 @@
 
 void EventHandler::dragSourceEndedAt(const PlatformMouseEvent& event, DragOperation operation)
 {
+    // Send a hit test request so that RenderLayer gets a chance to update the :hover and :active pseudoclasses.
+    HitTestRequest request(HitTestRequest::MouseUp);
+    prepareMouseEvent(request, event);
+
     if (dragState().m_dragSrc && dragState().shouldDispatchEvents()) {
         dragState().m_dragClipboard->setDestinationOperation(operation);
         // for now we don't care if event handler cancels default behavior, since there is none

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (102631 => 102632)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-12-12 23:21:51 UTC (rev 102631)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-12-12 23:51:03 UTC (rev 102632)
@@ -3978,8 +3978,10 @@
     if (activeNode && !request.active()) {
         // We are clearing the :active chain because the mouse has been released.
         for (RenderObject* curr = activeNode->renderer(); curr; curr = curr->parent()) {
-            if (curr->node() && !curr->isText())
+            if (curr->node() && !curr->isText()) {
+                curr->node()->setActive(false);
                 curr->node()->clearInActiveChain();
+            }
         }
         doc->setActiveNode(0);
     } else {
@@ -3995,6 +3997,9 @@
             doc->setActiveNode(newActiveNode);
         }
     }
+    // If the mouse has just been pressed, set :active on the chain. Those (and only those)
+    // nodes should remain :active until the mouse is released.
+    bool allowActiveChanges = !activeNode && doc->activeNode();
 
     // If the mouse is down and if this is a mouse move event, we want to restrict changes in 
     // :hover/:active to only apply to elements that are in the :active chain that we froze
@@ -4037,13 +4042,13 @@
 
     size_t removeCount = nodesToRemoveFromChain.size();
     for (size_t i = 0; i < removeCount; ++i) {
-        nodesToRemoveFromChain[i]->setActive(false);
         nodesToRemoveFromChain[i]->setHovered(false);
     }
 
     size_t addCount = nodesToAddToChain.size();
     for (size_t i = 0; i < addCount; ++i) {
-        nodesToAddToChain[i]->setActive(request.active());
+        if (allowActiveChanges)
+            nodesToAddToChain[i]->setActive(true);
         nodesToAddToChain[i]->setHovered(true);
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to