Changeset 137539 in webkit
- Timestamp:
- Dec 12, 2012 5:04:35 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r137536 r137539 1 2012-12-12 Andy Estes <aestes@apple.com> 2 3 Don't dispatch fake mousemove events when we don't know where the cursor is 4 https://bugs.webkit.org/show_bug.cgi?id=104861 5 6 Reviewed by Sam Weinig. 7 8 When EventHandler is instantiated or cleared, it sets the current mouse 9 position to (0, 0), even though this is probably not where the mouse 10 cursor really is (and we won't know until the mouse moves into the WebView). 11 If a fake mousemove event fires and the page has an element at (0, 0) 12 that responds to mousemove, we might end up changing the cursor or 13 displaying a tooltip at the current mouse position, even if it is 14 outside the WebView. 15 16 Fake mousemove events are dispatched in order to update a cursor that 17 is already over the WebView. Don't dispatch the event if we don't know 18 this to be true. 19 20 * page/EventHandler.cpp: 21 (WebCore::EventHandler::EventHandler): Instantiate m_mousePositionIsUnknown to true. 22 (WebCore::EventHandler::clear): Reset m_mousePositionIsUnknown to true. 23 (WebCore::EventHandler::dispatchFakeMouseMoveEventSoon): Return early if the mouse position is unknown. 24 (WebCore::EventHandler::setLastKnownMousePosition): Set the mouse position from the PlatformMouseEvent and set m_mousePositionIsUnknown to false. 25 (WebCore::EventHandler::handleMousePressEvent): Call setLastKnownMousePosition() instead of setting the position directly. 26 (WebCore::EventHandler::handleMouseDoubleClickEvent): Ditto. 27 (WebCore::EventHandler::handleMouseMoveEvent): Ditto. 28 (WebCore::EventHandler::handleMouseReleaseEvent): Ditto. 29 (WebCore::EventHandler::updateSelectionForMouseDrag): Rename currentMouse(Global)Position to lastKnownMouse(Global)Position. 30 (WebCore::EventHandler::handleAutoscroll): Ditto. 31 (WebCore::EventHandler::updatePanScrollState): Ditto. 32 (WebCore::EventHandler::lastKnownMousePosition): Ditto. 33 (WebCore::EventHandler::dispatchFakeMouseMoveEventSoonInQuad): Ditto. 34 (WebCore::EventHandler::fakeMouseMoveEventTimerFired): Ditto. 35 (WebCore::EventHandler::hoverTimerFired): Ditto. 36 * page/FrameView.cpp: 37 (WebCore::FrameView::lastKnownMousePosition): Ditto. 38 * platform/ScrollableArea.h: 39 (WebCore::ScrollableArea::lastKnownMousePosition): Ditto. 40 * platform/mac/ScrollAnimatorMac.mm: 41 (-[WebScrollbarPainterControllerDelegate mouseLocationInContentAreaForScrollerImpPair:]): Ditto. 42 (-[WebScrollbarPainterDelegate mouseLocationInScrollerForScrollerImp:]): Ditto. 43 * rendering/RenderLayer.cpp: 44 (WebCore::RenderLayer::panScrollFromPoint): Ditto. 45 (WebCore::RenderLayer::autoscroll): Ditto. 46 (WebCore::RenderLayer::lastKnownMousePosition): Ditto. 47 * rendering/RenderListBox.cpp: 48 (WebCore::RenderListBox::panScroll): Ditto. 49 (WebCore::RenderListBox::autoscroll): Ditto. 50 (WebCore::RenderListBox::lastKnownMousePosition): Ditto. 51 1 52 2012-12-12 Martin Robinson <mrobinson@igalia.com> 2 53 -
trunk/Source/WebCore/page/EventHandler.cpp
r137295 r137539 348 348 , m_eventHandlerWillResetCapturingMouseEventsNode(0) 349 349 , m_clickCount(0) 350 , m_mousePositionIsUnknown(true) 350 351 , m_mouseDownTimestamp(0) 351 352 , m_widgetIsLatched(false) … … 399 400 m_shouldOnlyFireDragOverEvent = false; 400 401 #endif 401 m_currentMousePosition = IntPoint(); 402 m_currentMouseGlobalPosition = IntPoint(); 402 m_mousePositionIsUnknown = true; 403 m_lastKnownMousePosition = IntPoint(); 404 m_lastKnownMouseGlobalPosition = IntPoint(); 403 405 m_mousePressNode = 0; 404 406 m_mousePressed = false; … … 821 823 HitTestRequest::Active | 822 824 HitTestRequest::Move); 823 HitTestResult result(view->windowToContents(m_ currentMousePosition));825 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); 824 826 renderer->hitTest(request, result); 825 827 updateSelectionForMouseDrag(result); … … 999 1001 #if ENABLE(PAN_SCROLLING) 1000 1002 if (m_panScrollInProgress) { 1001 m_panScrollStartPos = currentMousePosition();1003 m_panScrollStartPos = lastKnownMousePosition(); 1002 1004 if (FrameView* view = m_frame->view()) 1003 1005 view->addPanScrollIcon(m_panScrollStartPos); … … 1061 1063 // At the original click location we draw a 4 arrowed icon. Over this icon there won't be any scroll 1062 1064 // So we don't want to change the cursor over this area 1063 bool east = m_panScrollStartPos.x() < (m_ currentMousePosition.x() - ScrollView::noPanScrollRadius);1064 bool west = m_panScrollStartPos.x() > (m_ currentMousePosition.x() + ScrollView::noPanScrollRadius);1065 bool north = m_panScrollStartPos.y() > (m_ currentMousePosition.y() + ScrollView::noPanScrollRadius);1066 bool south = m_panScrollStartPos.y() < (m_ currentMousePosition.y() - ScrollView::noPanScrollRadius);1065 bool east = m_panScrollStartPos.x() < (m_lastKnownMousePosition.x() - ScrollView::noPanScrollRadius); 1066 bool west = m_panScrollStartPos.x() > (m_lastKnownMousePosition.x() + ScrollView::noPanScrollRadius); 1067 bool north = m_panScrollStartPos.y() > (m_lastKnownMousePosition.y() + ScrollView::noPanScrollRadius); 1068 bool south = m_panScrollStartPos.y() < (m_lastKnownMousePosition.y() - ScrollView::noPanScrollRadius); 1067 1069 1068 1070 if ((east || west || north || south) && m_panScrollButtonPressed) … … 1338 1340 } 1339 1341 1340 IntPoint EventHandler:: currentMousePosition() const1341 { 1342 return m_ currentMousePosition;1342 IntPoint EventHandler::lastKnownMousePosition() const 1343 { 1344 return m_lastKnownMousePosition; 1343 1345 } 1344 1346 … … 1608 1610 m_mousePressed = true; 1609 1611 m_capturesDragging = true; 1610 m_currentMousePosition = mouseEvent.position(); 1611 m_currentMouseGlobalPosition = mouseEvent.globalPosition(); 1612 setLastKnownMousePosition(mouseEvent); 1612 1613 m_mouseDownTimestamp = mouseEvent.timestamp(); 1613 1614 #if ENABLE(DRAG_SUPPORT) … … 1737 1738 // We get this instead of a second mouse-up 1738 1739 m_mousePressed = false; 1739 m_currentMousePosition = mouseEvent.position(); 1740 m_currentMouseGlobalPosition = mouseEvent.globalPosition(); 1740 setLastKnownMousePosition(mouseEvent); 1741 1741 1742 1742 HitTestRequest request(HitTestRequest::Active); … … 1832 1832 1833 1833 RefPtr<FrameView> protector(m_frame->view()); 1834 m_currentMousePosition = mouseEvent.position();1835 m_currentMouseGlobalPosition = mouseEvent.globalPosition();1834 1835 setLastKnownMousePosition(mouseEvent); 1836 1836 1837 1837 if (m_hoverTimer.isActive()) … … 1842 1842 #if ENABLE(SVG) 1843 1843 if (m_svgPan) { 1844 static_cast<SVGDocument*>(m_frame->document())->updatePan(m_frame->view()->windowToContents(m_ currentMousePosition));1844 static_cast<SVGDocument*>(m_frame->document())->updatePan(m_frame->view()->windowToContents(m_lastKnownMousePosition)); 1845 1845 return true; 1846 1846 } … … 1958 1958 1959 1959 m_mousePressed = false; 1960 m_currentMousePosition = mouseEvent.position(); 1961 m_currentMouseGlobalPosition = mouseEvent.globalPosition(); 1960 setLastKnownMousePosition(mouseEvent); 1962 1961 1963 1962 #if ENABLE(SVG) 1964 1963 if (m_svgPan) { 1965 1964 m_svgPan = false; 1966 static_cast<SVGDocument*>(m_frame->document())->updatePan(m_frame->view()->windowToContents(m_ currentMousePosition));1965 static_cast<SVGDocument*>(m_frame->document())->updatePan(m_frame->view()->windowToContents(m_lastKnownMousePosition)); 1967 1966 return true; 1968 1967 } … … 2994 2993 return; 2995 2994 2995 if (m_mousePositionIsUnknown) 2996 return; 2997 2996 2998 Settings* settings = m_frame->settings(); 2997 2999 if (settings && !settings->deviceSupportsMouse()) … … 3018 3020 return; 3019 3021 3020 if (!quad.containsPoint(view->windowToContents(m_ currentMousePosition)))3022 if (!quad.containsPoint(view->windowToContents(m_lastKnownMousePosition))) 3021 3023 return; 3022 3024 … … 3050 3052 bool metaKey; 3051 3053 PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, metaKey); 3052 PlatformMouseEvent fakeMouseMoveEvent(m_ currentMousePosition, m_currentMouseGlobalPosition, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, currentTime());3054 PlatformMouseEvent fakeMouseMoveEvent(m_lastKnownMousePosition, m_lastKnownMouseGlobalPosition, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, currentTime()); 3053 3055 mouseMoved(fakeMouseMoveEvent); 3054 3056 } … … 3075 3077 if (FrameView* view = m_frame->view()) { 3076 3078 HitTestRequest request(HitTestRequest::Move); 3077 HitTestResult result(view->windowToContents(m_ currentMousePosition));3079 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); 3078 3080 renderer->hitTest(request, result); 3079 3081 m_frame->document()->updateStyleIfNeeded(); … … 4071 4073 #endif 4072 4074 4073 } 4075 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) 4076 { 4077 m_mousePositionIsUnknown = false; 4078 m_lastKnownMousePosition = event.position(); 4079 m_lastKnownMouseGlobalPosition = event.globalPosition(); 4080 } 4081 4082 } // namespace WebCore -
trunk/Source/WebCore/page/EventHandler.h
r137220 r137539 143 143 void resizeLayerDestroyed(); 144 144 145 IntPoint currentMousePosition() const;145 IntPoint lastKnownMousePosition() const; 146 146 Cursor currentMouseCursor() const { return m_currentMouseCursor; } 147 147 … … 381 381 #endif 382 382 383 void setLastKnownMousePosition(const PlatformMouseEvent&); 384 383 385 Frame* m_frame; 384 386 … … 445 447 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeLayer. 446 448 447 IntPoint m_currentMousePosition; 448 IntPoint m_currentMouseGlobalPosition; 449 bool m_mousePositionIsUnknown; 450 IntPoint m_lastKnownMousePosition; 451 IntPoint m_lastKnownMouseGlobalPosition; 449 452 IntPoint m_mouseDownPos; // In our view's coords. 450 453 double m_mouseDownTimestamp; -
trunk/Source/WebCore/page/FrameView.cpp
r137387 r137539 1505 1505 } 1506 1506 1507 IntPoint FrameView:: currentMousePosition() const1508 { 1509 return m_frame ? m_frame->eventHandler()-> currentMousePosition() : IntPoint();1507 IntPoint FrameView::lastKnownMousePosition() const 1508 { 1509 return m_frame ? m_frame->eventHandler()->lastKnownMousePosition() : IntPoint(); 1510 1510 } 1511 1511 -
trunk/Source/WebCore/page/FrameView.h
r137178 r137539 324 324 static void setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(double p); 325 325 326 virtual IntPoint currentMousePosition() const;326 virtual IntPoint lastKnownMousePosition() const; 327 327 328 328 virtual bool scrollbarsCanBeActive() const OVERRIDE; -
trunk/Source/WebCore/platform/ScrollableArea.h
r137108 r137539 144 144 virtual IntSize contentsSize() const = 0; 145 145 virtual IntSize overhangAmount() const { return IntSize(); } 146 virtual IntPoint currentMousePosition() const { return IntPoint(); }146 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } 147 147 148 148 virtual bool shouldSuspendScrollAnimations() const { return true; } -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r136303 r137539 227 227 return NSZeroPoint; 228 228 229 return _scrollableArea-> currentMousePosition();229 return _scrollableArea->lastKnownMousePosition(); 230 230 } 231 231 … … 449 449 ASSERT_UNUSED(scrollerImp, scrollerImp == scrollbarPainterForScrollbar(_scrollbar)); 450 450 451 return _scrollbar->convertFromContainingView(_scrollbar->scrollableArea()-> currentMousePosition());451 return _scrollbar->convertFromContainingView(_scrollbar->scrollableArea()->lastKnownMousePosition()); 452 452 } 453 453 -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r137492 r137539 1659 1659 return; 1660 1660 1661 IntPoint currentMousePosition = frame->eventHandler()->currentMousePosition();1662 1663 // We need to check if the currentmouse position is out of the window. When the mouse is out of the window, the position is incoherent1661 IntPoint lastKnownMousePosition = frame->eventHandler()->lastKnownMousePosition(); 1662 1663 // We need to check if the last known mouse position is out of the window. When the mouse is out of the window, the position is incoherent 1664 1664 static IntPoint previousMousePosition; 1665 if ( currentMousePosition.x() < 0 || currentMousePosition.y() < 0)1666 currentMousePosition = previousMousePosition;1665 if (lastKnownMousePosition.x() < 0 || lastKnownMousePosition.y() < 0) 1666 lastKnownMousePosition = previousMousePosition; 1667 1667 else 1668 previousMousePosition = currentMousePosition;1669 1670 IntSize delta = currentMousePosition - sourcePoint;1668 previousMousePosition = lastKnownMousePosition; 1669 1670 IntSize delta = lastKnownMousePosition - sourcePoint; 1671 1671 1672 1672 if (abs(delta.width()) <= ScrollView::noPanScrollRadius) // at the center we let the space for the icon … … 2019 2019 #endif 2020 2020 2021 IntPoint currentDocumentPosition = frameView->windowToContents(frame->eventHandler()-> currentMousePosition());2021 IntPoint currentDocumentPosition = frameView->windowToContents(frame->eventHandler()->lastKnownMousePosition()); 2022 2022 scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded); 2023 2023 } … … 2298 2298 } 2299 2299 2300 IntPoint RenderLayer:: currentMousePosition() const2301 { 2302 return renderer()->frame() ? renderer()->frame()->eventHandler()-> currentMousePosition() : IntPoint();2300 IntPoint RenderLayer::lastKnownMousePosition() const 2301 { 2302 return renderer()->frame() ? renderer()->frame()->eventHandler()->lastKnownMousePosition() : IntPoint(); 2303 2303 } 2304 2304 -
trunk/Source/WebCore/rendering/RenderLayer.h
r137108 r137539 857 857 virtual IntSize contentsSize() const; 858 858 virtual IntSize overhangAmount() const; 859 virtual IntPoint currentMousePosition() const;859 virtual IntPoint lastKnownMousePosition() const; 860 860 virtual bool shouldSuspendScrollAnimations() const; 861 861 virtual bool scrollbarsCanBeActive() const; -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r132112 r137539 500 500 FloatPoint absOffset = localToAbsolute(); 501 501 502 IntPoint currentMousePosition = frame()->eventHandler()->currentMousePosition();503 // We need to check if the currentmouse position is out of the window. When the mouse is out of the window, the position is incoherent502 IntPoint lastKnownMousePosition = frame()->eventHandler()->lastKnownMousePosition(); 503 // We need to check if the last known mouse position is out of the window. When the mouse is out of the window, the position is incoherent 504 504 static IntPoint previousMousePosition; 505 if ( currentMousePosition.y() < 0)506 currentMousePosition = previousMousePosition;505 if (lastKnownMousePosition.y() < 0) 506 lastKnownMousePosition = previousMousePosition; 507 507 else 508 previousMousePosition = currentMousePosition;509 510 int yDelta = currentMousePosition.y() - panStartMousePosition.y();508 previousMousePosition = lastKnownMousePosition; 509 510 int yDelta = lastKnownMousePosition.y() - panStartMousePosition.y(); 511 511 512 512 // If the point is too far from the center we limit the speed … … 557 557 void RenderListBox::autoscroll() 558 558 { 559 IntPoint pos = frame()->view()->windowToContents(frame()->eventHandler()-> currentMousePosition());559 IntPoint pos = frame()->view()->windowToContents(frame()->eventHandler()->lastKnownMousePosition()); 560 560 561 561 int endIndex = scrollToward(pos); … … 804 804 } 805 805 806 IntPoint RenderListBox:: currentMousePosition() const806 IntPoint RenderListBox::lastKnownMousePosition() const 807 807 { 808 808 RenderView* view = this->view(); 809 809 if (!view) 810 810 return IntPoint(); 811 return view->frameView()-> currentMousePosition();811 return view->frameView()->lastKnownMousePosition(); 812 812 } 813 813 -
trunk/Source/WebCore/rendering/RenderListBox.h
r132753 r137539 118 118 virtual int visibleHeight() const OVERRIDE; 119 119 virtual int visibleWidth() const OVERRIDE; 120 virtual IntPoint currentMousePosition() const OVERRIDE;120 virtual IntPoint lastKnownMousePosition() const OVERRIDE; 121 121 virtual bool shouldSuspendScrollAnimations() const OVERRIDE; 122 122 virtual bool scrollbarsCanBeActive() const OVERRIDE;
Note: See TracChangeset
for help on using the changeset viewer.