Diff
Modified: trunk/LayoutTests/ChangeLog (101618 => 101619)
--- trunk/LayoutTests/ChangeLog 2011-12-01 07:16:28 UTC (rev 101618)
+++ trunk/LayoutTests/ChangeLog 2011-12-01 07:20:59 UTC (rev 101619)
@@ -1,3 +1,13 @@
+2011-11-30 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.
+
2011-11-30 Hayato Ito <[email protected]>
Unreviewed. Update chromium test expectations for plugins/form-value.html.
Property changes on: trunk/LayoutTests/ChangeLog
___________________________________________________________________
Deleted: svn:executable
Added: trunk/LayoutTests/fast/css/hover-active-drag-expected.txt (0 => 101619)
--- trunk/LayoutTests/fast/css/hover-active-drag-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/hover-active-drag-expected.txt 2011-12-01 07:20:59 UTC (rev 101619)
@@ -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 => 101619)
--- trunk/LayoutTests/fast/css/hover-active-drag.html (rev 0)
+++ trunk/LayoutTests/fast/css/hover-active-drag.html 2011-12-01 07:20:59 UTC (rev 101619)
@@ -0,0 +1,57 @@
+<!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 backgroundOf(element) {
+ return getComputedStyle(element, null).getPropertyValue("background-color")
+ }
+ 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;
+ 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)')
+
+ eventSender.mouseMoveTo(50, 150)
+ shouldHaveBackground(box, 'rgb(0, 255, 0)')
+ shouldHaveBackground(box2, 'rgb(0, 0, 0)')
+
+ 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>
Modified: trunk/Source/WebCore/ChangeLog (101618 => 101619)
--- trunk/Source/WebCore/ChangeLog 2011-12-01 07:16:28 UTC (rev 101618)
+++ trunk/Source/WebCore/ChangeLog 2011-12-01 07:20:59 UTC (rev 101619)
@@ -1,3 +1,19 @@
+2011-11-30 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-11-30 Hans Muller <[email protected]>
XHR 'progress' event code assumes wrongly that expectedLength >= 0
Property changes on: trunk/Source/WebCore/ChangeLog
___________________________________________________________________
Deleted: svn:executable
Modified: trunk/Source/WebCore/page/EventHandler.cpp (101618 => 101619)
--- trunk/Source/WebCore/page/EventHandler.cpp 2011-12-01 07:16:28 UTC (rev 101618)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2011-12-01 07:20:59 UTC (rev 101619)
@@ -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 (101618 => 101619)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2011-12-01 07:16:28 UTC (rev 101618)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2011-12-01 07:20:59 UTC (rev 101619)
@@ -3951,8 +3951,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 {
@@ -3968,6 +3970,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
@@ -4010,13 +4015,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);
}
}