Changeset 173025 in webkit
- Timestamp:
- Aug 27, 2014, 3:25:33 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r173024 r173025 1 2014-08-27 Simon Fraser <simon.fraser@apple.com> 2 3 Some EventHandler naming cleanup 4 https://bugs.webkit.org/show_bug.cgi?id=136303 5 6 Reviewed by Beth Dakin. 7 8 Rename "mev" variables to "mouseEvent". 9 10 No behavior change. 11 12 * page/EventHandler.cpp: 13 (WebCore::EventHandler::handleMousePressEvent): 14 (WebCore::EventHandler::handleMouseDoubleClickEvent): 15 (WebCore::EventHandler::handleMouseMoveEvent): 16 (WebCore::EventHandler::handleMouseReleaseEvent): 17 (WebCore::EventHandler::updateDragAndDrop): 18 (WebCore::EventHandler::prepareMouseEvent): 19 (WebCore::EventHandler::sendContextMenuEvent): 20 (WebCore::EventHandler::passMousePressEventToScrollbar): 21 (WebCore::EventHandler::dispatchSyntheticTouchEventIfEnabled): 22 1 23 2014-08-27 Simon Fraser <simon.fraser@apple.com> 2 24 -
trunk/Source/WebCore/page/EventHandler.cpp
r173024 r173025 1688 1688 // when we dispatch the event. 1689 1689 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, plaformMouseEvent.position()); 1690 MouseEventWithHitTestResults m ev= m_frame.document()->prepareMouseEvent(request, documentPoint, plaformMouseEvent);1691 1692 if (!m ev.targetNode()) {1690 MouseEventWithHitTestResults mouseEvent = m_frame.document()->prepareMouseEvent(request, documentPoint, plaformMouseEvent); 1691 1692 if (!mouseEvent.targetNode()) { 1693 1693 invalidateClick(); 1694 1694 return false; 1695 1695 } 1696 1696 1697 m_mousePressNode = m ev.targetNode();1698 1699 RefPtr<Frame> subframe = subframeForHitTestResult(m ev);1700 if (subframe && passMousePressEventToSubframe(m ev, subframe.get())) {1697 m_mousePressNode = mouseEvent.targetNode(); 1698 1699 RefPtr<Frame> subframe = subframeForHitTestResult(mouseEvent); 1700 if (subframe && passMousePressEventToSubframe(mouseEvent, subframe.get())) { 1701 1701 // Start capturing future events for this frame. We only do this if we didn't clear 1702 1702 // the m_mousePressed flag, which may happen if an AppKit widget entered a modal event loop. … … 1724 1724 1725 1725 m_clickCount = plaformMouseEvent.clickCount(); 1726 m_clickNode = m ev.targetNode();1726 m_clickNode = mouseEvent.targetNode(); 1727 1727 1728 1728 if (!m_clickNode) { … … 1745 1745 m_frame.selection().setCaretBlinkingSuspended(true); 1746 1746 1747 bool swallowEvent = !dispatchMouseEvent(eventNames().mousedownEvent, m ev.targetNode(), true, m_clickCount, plaformMouseEvent, true);1748 m_capturesDragging = !swallowEvent || m ev.scrollbar();1747 bool swallowEvent = !dispatchMouseEvent(eventNames().mousedownEvent, mouseEvent.targetNode(), true, m_clickCount, plaformMouseEvent, true); 1748 m_capturesDragging = !swallowEvent || mouseEvent.scrollbar(); 1749 1749 1750 1750 // If the hit testing originally determined the event was in a scrollbar, refetch the MouseEventWithHitTestResults 1751 1751 // in case the scrollbar widget was destroyed when the mouse event was handled. 1752 if (m ev.scrollbar()) {1753 const bool wasLastScrollBar = m ev.scrollbar() == m_lastScrollbarUnderMouse.get();1752 if (mouseEvent.scrollbar()) { 1753 const bool wasLastScrollBar = mouseEvent.scrollbar() == m_lastScrollbarUnderMouse.get(); 1754 1754 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent); 1755 m ev= m_frame.document()->prepareMouseEvent(request, documentPoint, plaformMouseEvent);1756 if (wasLastScrollBar && m ev.scrollbar() != m_lastScrollbarUnderMouse.get())1755 mouseEvent = m_frame.document()->prepareMouseEvent(request, documentPoint, plaformMouseEvent); 1756 if (wasLastScrollBar && mouseEvent.scrollbar() != m_lastScrollbarUnderMouse.get()) 1757 1757 m_lastScrollbarUnderMouse = nullptr; 1758 1758 } … … 1760 1760 if (swallowEvent) { 1761 1761 // scrollbars should get events anyway, even disabled controls might be scrollable 1762 Scrollbar* scrollbar = m ev.scrollbar();1762 Scrollbar* scrollbar = mouseEvent.scrollbar(); 1763 1763 1764 1764 updateLastScrollbarUnderMouse(scrollbar, true); 1765 1765 1766 1766 if (scrollbar) 1767 passMousePressEventToScrollbar(m ev, scrollbar);1767 passMousePressEventToScrollbar(mouseEvent, scrollbar); 1768 1768 } else { 1769 1769 // Refetch the event target node if it currently is the shadow node inside an <input> element. … … 1771 1771 // we'd like to EventHandler::handleMousePressEvent to pass the event to the widget and thus the 1772 1772 // event target node can't still be the shadow node. 1773 if (m ev.targetNode()->isShadowRoot() && isHTMLInputElement(toShadowRoot(mev.targetNode())->hostElement())) {1773 if (mouseEvent.targetNode()->isShadowRoot() && isHTMLInputElement(toShadowRoot(mouseEvent.targetNode())->hostElement())) { 1774 1774 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent); 1775 m ev= m_frame.document()->prepareMouseEvent(request, documentPoint, plaformMouseEvent);1775 mouseEvent = m_frame.document()->prepareMouseEvent(request, documentPoint, plaformMouseEvent); 1776 1776 } 1777 1777 … … 1779 1779 Scrollbar* scrollbar = view ? view->scrollbarAtPoint(plaformMouseEvent.position()) : 0; 1780 1780 if (!scrollbar) 1781 scrollbar = m ev.scrollbar();1781 scrollbar = mouseEvent.scrollbar(); 1782 1782 1783 1783 updateLastScrollbarUnderMouse(scrollbar, true); 1784 1784 1785 if (scrollbar && passMousePressEventToScrollbar(m ev, scrollbar))1785 if (scrollbar && passMousePressEventToScrollbar(mouseEvent, scrollbar)) 1786 1786 swallowEvent = true; 1787 1787 else 1788 swallowEvent = handleMousePressEvent(m ev);1788 swallowEvent = handleMousePressEvent(mouseEvent); 1789 1789 } 1790 1790 … … 1806 1806 1807 1807 HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent); 1808 MouseEventWithHitTestResults m ev= prepareMouseEvent(request, plaformMouseEvent);1809 Frame* subframe = subframeForHitTestResult(m ev);1808 MouseEventWithHitTestResults mouseEvent = prepareMouseEvent(request, plaformMouseEvent); 1809 Frame* subframe = subframeForHitTestResult(mouseEvent); 1810 1810 if (m_eventHandlerWillResetCapturingMouseEventsElement) 1811 1811 m_capturingMouseEventsElement = nullptr; 1812 if (subframe && passMousePressEventToSubframe(m ev, subframe))1812 if (subframe && passMousePressEventToSubframe(mouseEvent, subframe)) 1813 1813 return true; 1814 1814 1815 1815 m_clickCount = plaformMouseEvent.clickCount(); 1816 bool swallowMouseUpEvent = !dispatchMouseEvent(eventNames().mouseupEvent, m ev.targetNode(), true, m_clickCount, plaformMouseEvent, false);1817 1818 bool swallowClickEvent = plaformMouseEvent.button() != RightButton && m ev.targetNode() == m_clickNode && !dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, plaformMouseEvent, true);1816 bool swallowMouseUpEvent = !dispatchMouseEvent(eventNames().mouseupEvent, mouseEvent.targetNode(), true, m_clickCount, plaformMouseEvent, false); 1817 1818 bool swallowClickEvent = plaformMouseEvent.button() != RightButton && mouseEvent.targetNode() == m_clickNode && !dispatchMouseEvent(eventNames().clickEvent, mouseEvent.targetNode(), true, m_clickCount, plaformMouseEvent, true); 1819 1819 1820 1820 if (m_lastScrollbarUnderMouse) 1821 1821 swallowMouseUpEvent = m_lastScrollbarUnderMouse->mouseUp(plaformMouseEvent); 1822 1822 1823 bool swallowMouseReleaseEvent = !swallowMouseUpEvent && handleMouseReleaseEvent(m ev);1823 bool swallowMouseReleaseEvent = !swallowMouseUpEvent && handleMouseReleaseEvent(mouseEvent); 1824 1824 1825 1825 invalidateClick(); … … 1936 1936 #endif 1937 1937 HitTestRequest request(hitType); 1938 MouseEventWithHitTestResults m ev= prepareMouseEvent(request, plaformMouseEvent);1938 MouseEventWithHitTestResults mouseEvent = prepareMouseEvent(request, plaformMouseEvent); 1939 1939 if (hoveredNode) 1940 *hoveredNode = m ev.hitTestResult();1940 *hoveredNode = mouseEvent.hitTestResult(); 1941 1941 1942 1942 if (m_resizeLayer && m_resizeLayer->inResizeMode()) 1943 1943 m_resizeLayer->resize(plaformMouseEvent, m_offsetFromResizeCorner); 1944 1944 else { 1945 Scrollbar* scrollbar = m ev.scrollbar();1945 Scrollbar* scrollbar = mouseEvent.scrollbar(); 1946 1946 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); 1947 1947 … … 1956 1956 1957 1957 bool swallowEvent = false; 1958 RefPtr<Frame> newSubframe = m_capturingMouseEventsElement.get() ? subframeForTargetNode(m_capturingMouseEventsElement.get()) : subframeForHitTestResult(m ev);1958 RefPtr<Frame> newSubframe = m_capturingMouseEventsElement.get() ? subframeForTargetNode(m_capturingMouseEventsElement.get()) : subframeForHitTestResult(mouseEvent); 1959 1959 1960 1960 // We want mouseouts to happen first, from the inside out. First send a move event to the last subframe so that it will fire mouseouts. 1961 1961 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree().isDescendantOf(&m_frame) && m_lastMouseMoveEventSubframe != newSubframe) 1962 passMouseMoveEventToSubframe(m ev, m_lastMouseMoveEventSubframe.get());1962 passMouseMoveEventToSubframe(mouseEvent, m_lastMouseMoveEventSubframe.get()); 1963 1963 1964 1964 if (newSubframe) { 1965 1965 // Update over/out state before passing the event to the subframe. 1966 updateMouseEventTargetNode(m ev.targetNode(), plaformMouseEvent, true);1966 updateMouseEventTargetNode(mouseEvent.targetNode(), plaformMouseEvent, true); 1967 1967 1968 1968 // Event dispatch in updateMouseEventTargetNode may have caused the subframe of the target 1969 1969 // node to be detached from its FrameView, in which case the event should not be passed. 1970 1970 if (newSubframe->view()) 1971 swallowEvent |= passMouseMoveEventToSubframe(m ev, newSubframe.get(), hoveredNode);1971 swallowEvent |= passMouseMoveEventToSubframe(mouseEvent, newSubframe.get(), hoveredNode); 1972 1972 #if ENABLE(CURSOR_SUPPORT) 1973 1973 } else { 1974 1974 if (FrameView* view = m_frame.view()) { 1975 OptionalCursor optionalCursor = selectCursor(m ev.hitTestResult(), plaformMouseEvent.shiftKey());1975 OptionalCursor optionalCursor = selectCursor(mouseEvent.hitTestResult(), plaformMouseEvent.shiftKey()); 1976 1976 if (optionalCursor.isCursorChange()) { 1977 1977 m_currentMouseCursor = optionalCursor.cursor(); … … 1987 1987 return true; 1988 1988 1989 swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, m ev.targetNode(), false, 0, plaformMouseEvent, true);1989 swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, mouseEvent.targetNode(), false, 0, plaformMouseEvent, true); 1990 1990 #if ENABLE(DRAG_SUPPORT) 1991 1991 if (!swallowEvent) 1992 swallowEvent = handleMouseDraggedEvent(m ev);1992 swallowEvent = handleMouseDraggedEvent(mouseEvent); 1993 1993 #endif // ENABLE(DRAG_SUPPORT) 1994 1994 … … 2065 2065 2066 2066 HitTestRequest request(HitTestRequest::Release | HitTestRequest::DisallowShadowContent); 2067 MouseEventWithHitTestResults m ev= prepareMouseEvent(request, plaformMouseEvent);2068 Frame* subframe = m_capturingMouseEventsElement.get() ? subframeForTargetNode(m_capturingMouseEventsElement.get()) : subframeForHitTestResult(m ev);2067 MouseEventWithHitTestResults mouseEvent = prepareMouseEvent(request, plaformMouseEvent); 2068 Frame* subframe = m_capturingMouseEventsElement.get() ? subframeForTargetNode(m_capturingMouseEventsElement.get()) : subframeForHitTestResult(mouseEvent); 2069 2069 if (m_eventHandlerWillResetCapturingMouseEventsElement) 2070 2070 m_capturingMouseEventsElement = nullptr; 2071 if (subframe && passMouseReleaseEventToSubframe(m ev, subframe))2071 if (subframe && passMouseReleaseEventToSubframe(mouseEvent, subframe)) 2072 2072 return true; 2073 2073 2074 bool swallowMouseUpEvent = !dispatchMouseEvent(eventNames().mouseupEvent, m ev.targetNode(), true, m_clickCount, plaformMouseEvent, false);2074 bool swallowMouseUpEvent = !dispatchMouseEvent(eventNames().mouseupEvent, mouseEvent.targetNode(), true, m_clickCount, plaformMouseEvent, false); 2075 2075 2076 2076 bool contextMenuEvent = plaformMouseEvent.button() == RightButton; 2077 2077 2078 bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && mouseIsReleasedOnPressedElement(m ev.targetNode(), m_clickNode.get()) && !dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, plaformMouseEvent, true);2078 bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && mouseIsReleasedOnPressedElement(mouseEvent.targetNode(), m_clickNode.get()) && !dispatchMouseEvent(eventNames().clickEvent, mouseEvent.targetNode(), true, m_clickCount, plaformMouseEvent, true); 2079 2079 2080 2080 if (m_resizeLayer) { … … 2085 2085 bool swallowMouseReleaseEvent = false; 2086 2086 if (!swallowMouseUpEvent) 2087 swallowMouseReleaseEvent = handleMouseReleaseEvent(m ev);2087 swallowMouseReleaseEvent = handleMouseReleaseEvent(mouseEvent); 2088 2088 2089 2089 invalidateClick(); … … 2245 2245 2246 2246 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent); 2247 MouseEventWithHitTestResults m ev= prepareMouseEvent(request, event);2247 MouseEventWithHitTestResults mouseEvent = prepareMouseEvent(request, event); 2248 2248 2249 2249 RefPtr<Element> newTarget; 2250 if (Node* targetNode = m ev.targetNode()) {2250 if (Node* targetNode = mouseEvent.targetNode()) { 2251 2251 // Drag events should never go to non-element nodes (following IE, and proper mouseover/out dispatch) 2252 2252 if (!targetNode->isElementNode()) … … 2356 2356 } 2357 2357 2358 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestRequest& request, const PlatformMouseEvent& m ev)2358 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestRequest& request, const PlatformMouseEvent& mouseEvent) 2359 2359 { 2360 2360 ASSERT(m_frame.document()); 2361 return m_frame.document()->prepareMouseEvent(request, documentPointForWindowPoint(m_frame, m ev.position()), mev);2361 return m_frame.document()->prepareMouseEvent(request, documentPointForWindowPoint(m_frame, mouseEvent.position()), mouseEvent); 2362 2362 } 2363 2363 … … 2792 2792 LayoutPoint viewportPos = v->windowToContents(event.position()); 2793 2793 HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent); 2794 MouseEventWithHitTestResults m ev= doc->prepareMouseEvent(request, viewportPos, event);2794 MouseEventWithHitTestResults mouseEvent = doc->prepareMouseEvent(request, viewportPos, event); 2795 2795 2796 2796 if (m_frame.editor().behavior().shouldSelectOnContextualMenuClick() 2797 2797 && !m_frame.selection().contains(viewportPos) 2798 && !m ev.scrollbar()2798 && !mouseEvent.scrollbar() 2799 2799 // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse. 2800 2800 // If the selection is non-editable, we do word selection to make it easier to use the contextual menu items 2801 2801 // available for text selections. But only if we're above text. 2802 && (m_frame.selection().selection().isContentEditable() || (m ev.targetNode() && mev.targetNode()->isTextNode()))) {2802 && (m_frame.selection().selection().isContentEditable() || (mouseEvent.targetNode() && mouseEvent.targetNode()->isTextNode()))) { 2803 2803 m_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection 2804 selectClosestWordOrLinkFromMouseEvent(m ev);2805 } 2806 2807 swallowEvent = !dispatchMouseEvent(eventNames().contextmenuEvent, m ev.targetNode(), true, 0, event, false);2804 selectClosestWordOrLinkFromMouseEvent(mouseEvent); 2805 } 2806 2807 swallowEvent = !dispatchMouseEvent(eventNames().contextmenuEvent, mouseEvent.targetNode(), true, 0, event, false); 2808 2808 2809 2809 return swallowEvent; … … 3717 3717 } 3718 3718 3719 bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults& m ev, Scrollbar* scrollbar)3719 bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults& mouseEvent, Scrollbar* scrollbar) 3720 3720 { 3721 3721 if (!scrollbar || !scrollbar->enabled()) 3722 3722 return false; 3723 3723 setFrameWasScrolledByUser(); 3724 return scrollbar->mouseDown(m ev.event());3724 return scrollbar->mouseDown(mouseEvent.event()); 3725 3725 } 3726 3726 … … 3995 3995 3996 3996 HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent); 3997 MouseEventWithHitTestResults m ev= prepareMouseEvent(request, plaformMouseEvent);3998 if (m ev.scrollbar() || subframeForHitTestResult(mev))3997 MouseEventWithHitTestResults mouseEvent = prepareMouseEvent(request, plaformMouseEvent); 3998 if (mouseEvent.scrollbar() || subframeForHitTestResult(mouseEvent)) 3999 3999 return false; 4000 4000
Note:
See TracChangeset
for help on using the changeset viewer.