| Index: Source/core/page/EventHandler.cpp
|
| diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
|
| index 7a28dc96a1595b2563160f4a90c81bb79951cbe9..dbe6c97ceda7395c4d079761223f547dc5e210cd 100644
|
| --- a/Source/core/page/EventHandler.cpp
|
| +++ b/Source/core/page/EventHandler.cpp
|
| @@ -514,7 +514,7 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
|
| // Don't restart the selection when the mouse is pressed on an
|
| // existing selection so we can allow for text dragging.
|
| if (FrameView* view = m_frame->view()) {
|
| - LayoutPoint vPoint = view->windowToContents(event.event().position());
|
| + LayoutPoint vPoint = view->rootFrameToContents(event.event().position());
|
| if (!extendSelection && m_frame->selection().contains(vPoint)) {
|
| m_mouseDownWasSingleClickInSelection = true;
|
| return false;
|
| @@ -609,7 +609,7 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
|
| if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGExtensions().zoomAndPanEnabled()) {
|
| if (event.event().shiftKey() && singleClick) {
|
| m_svgPan = true;
|
| - m_frame->document()->accessSVGExtensions().startPan(m_frame->view()->windowToContents(event.event().position()));
|
| + m_frame->document()->accessSVGExtensions().startPan(m_frame->view()->rootFrameToContents(event.event().position()));
|
| return true;
|
| }
|
| }
|
| @@ -713,7 +713,7 @@ void EventHandler::updateSelectionForMouseDrag()
|
| return;
|
|
|
| HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Move);
|
| - HitTestResult result(view->windowToContents(m_lastKnownMousePosition));
|
| + HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosition));
|
| renderer->hitTest(request, result);
|
| updateSelectionForMouseDrag(result);
|
| }
|
| @@ -1027,7 +1027,7 @@ void EventHandler::updateCursor()
|
| m_frame->document()->updateLayout();
|
|
|
| HitTestRequest request(HitTestRequest::ReadOnly);
|
| - HitTestResult result(view->windowToContents(m_lastKnownMousePosition));
|
| + HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosition));
|
| layoutView->hitTest(request, result);
|
|
|
| OptionalCursor optionalCursor = selectCursor(result);
|
| @@ -1208,12 +1208,12 @@ OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node*
|
| return pointerCursor();
|
| }
|
|
|
| -static LayoutPoint documentPointForWindowPoint(LocalFrame* frame, const IntPoint& windowPoint)
|
| +static LayoutPoint contentPointFromRootFrame(LocalFrame* frame, const IntPoint& pointInRootFrame)
|
| {
|
| FrameView* view = frame->view();
|
| // FIXME: Is it really OK to use the wrong coordinates here when view is 0?
|
| // Historically the code would just crash; this is clearly no worse than that.
|
| - return view ? view->windowToContents(windowPoint) : windowPoint;
|
| + return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame;
|
| }
|
|
|
| bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
|
| @@ -1236,7 +1236,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
|
| m_mouseDownMayStartSelect = false;
|
| m_mouseDownMayStartAutoscroll = false;
|
| if (FrameView* view = m_frame->view())
|
| - m_mouseDownPos = view->windowToContents(mouseEvent.position());
|
| + m_mouseDownPos = view->rootFrameToContents(mouseEvent.position());
|
| else {
|
| invalidateClick();
|
| return false;
|
| @@ -1245,7 +1245,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
|
| HitTestRequest request(HitTestRequest::Active);
|
| // Save the document point we generate in case the window coordinate is invalidated by what happens
|
| // when we dispatch the event.
|
| - LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.position());
|
| + LayoutPoint documentPoint = contentPointFromRootFrame(m_frame, mouseEvent.position());
|
| MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
|
|
|
| if (!mev.innerNode()) {
|
| @@ -1286,7 +1286,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
|
|
|
| if (FrameView* view = m_frame->view()) {
|
| Layer* layer = mev.innerNode()->renderer() ? mev.innerNode()->renderer()->enclosingLayer() : nullptr;
|
| - IntPoint p = view->windowToContents(mouseEvent.position());
|
| + IntPoint p = view->rootFrameToContents(mouseEvent.position());
|
| if (layer && layer->scrollableArea() && layer->scrollableArea()->isPointInResizeControl(p, ResizerForPointer)) {
|
| m_resizeScrollableArea = layer->scrollableArea();
|
| m_resizeScrollableArea->setInResizeMode(true);
|
| @@ -1409,7 +1409,7 @@ bool EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMouseEvent& mouseEv
|
| cancelFakeMouseMoveEvent();
|
|
|
| if (m_svgPan) {
|
| - m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->windowToContents(m_lastKnownMousePosition));
|
| + m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->rootFrameToContents(m_lastKnownMousePosition));
|
| return true;
|
| }
|
|
|
| @@ -1545,7 +1545,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
|
|
|
| if (m_svgPan) {
|
| m_svgPan = false;
|
| - m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->windowToContents(m_lastKnownMousePosition));
|
| + m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->rootFrameToContents(m_lastKnownMousePosition));
|
| return true;
|
| }
|
|
|
| @@ -1831,7 +1831,7 @@ MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
|
| ASSERT(m_frame);
|
| ASSERT(m_frame->document());
|
|
|
| - return m_frame->document()->prepareMouseEvent(request, documentPointForWindowPoint(m_frame, mev.position()), mev);
|
| + return m_frame->document()->prepareMouseEvent(request, contentPointFromRootFrame(m_frame, mev.position()), mev);
|
| }
|
|
|
| void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMouseEvent& mouseEvent, bool fireMouseOverOut)
|
| @@ -1982,7 +1982,7 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event)
|
| if (!view)
|
| return false;
|
|
|
| - LayoutPoint vPoint = view->windowToContents(event.position());
|
| + LayoutPoint vPoint = view->rootFrameToContents(event.position());
|
|
|
| HitTestRequest request(HitTestRequest::ReadOnly);
|
| HitTestResult result(vPoint);
|
| @@ -2186,7 +2186,7 @@ bool EventHandler::handleGestureScrollEvent(const PlatformGestureEvent& gestureE
|
| return false;
|
|
|
| FrameView* view = m_frame->view();
|
| - LayoutPoint viewPoint = view->windowToContents(gestureEvent.position());
|
| + LayoutPoint viewPoint = view->rootFrameToContents(gestureEvent.position());
|
| HitTestRequest request(HitTestRequest::ReadOnly);
|
| HitTestResult result(viewPoint);
|
| document->layoutView()->hitTest(request, result);
|
| @@ -2252,7 +2252,7 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
|
|
|
| // We use the adjusted position so the application isn't surprised to see a event with
|
| // co-ordinates outside the target's bounds.
|
| - IntPoint adjustedPoint = frameView->windowToContents(gestureEvent.position());
|
| + IntPoint adjustedPoint = frameView->rootFrameToContents(gestureEvent.position());
|
|
|
| unsigned modifiers = gestureEvent.modifiers();
|
| PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(),
|
| @@ -2272,7 +2272,7 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
|
| LocalFrame* mainFrame = m_frame->localFrameRoot();
|
| if (mainFrame && mainFrame->view())
|
| mainFrame->view()->updateLayoutAndStyleIfNeededRecursive();
|
| - adjustedPoint = frameView->windowToContents(gestureEvent.position());
|
| + adjustedPoint = frameView->rootFrameToContents(gestureEvent.position());
|
| currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType);
|
| }
|
| m_clickNode = currentHitTest.innerNode();
|
| @@ -2299,7 +2299,7 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
|
| LocalFrame* mainFrame = m_frame->localFrameRoot();
|
| if (mainFrame && mainFrame->view())
|
| mainFrame->view()->updateLayoutAndStyleIfNeededRecursive();
|
| - adjustedPoint = frameView->windowToContents(gestureEvent.position());
|
| + adjustedPoint = frameView->rootFrameToContents(gestureEvent.position());
|
| currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType);
|
| }
|
| PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(),
|
| @@ -2330,7 +2330,8 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
|
| if (!swallowed && tappedNode) {
|
| bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()->domTreeVersion();
|
| bool styleChanged = preDispatchStyleVersion != m_frame->document()->styleVersion();
|
| - m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPosition, tappedNode.get(), domTreeChanged || styleChanged);
|
| + IntPoint tappedPositionInViewport = m_frame->page()->frameHost().pinchViewport().rootFrameToViewport(tappedPosition);
|
| + m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewport, tappedNode.get(), domTreeChanged || styleChanged);
|
| }
|
| return swallowed;
|
| }
|
| @@ -2360,7 +2361,7 @@ bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
|
| MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragEvent);
|
| m_mouseDownMayStartDrag = true;
|
| dragState().m_dragSrc = nullptr;
|
| - m_mouseDownPos = m_frame->view()->windowToContents(mouseDragEvent.position());
|
| + m_mouseDownPos = m_frame->view()->rootFrameToContents(mouseDragEvent.position());
|
| RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
|
| if (handleDrag(mev, DragInitiator::Touch)) {
|
| m_longTapShouldInvokeContextMenu = true;
|
| @@ -2373,7 +2374,7 @@ bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
|
| bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()->touchEditingEnabled();
|
| #endif
|
| if (shouldLongPressSelectWord) {
|
| - IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.position());
|
| + IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEvent.position());
|
| HitTestResult result = hitTestResultAtPoint(hitTestPoint);
|
| Node* innerNode = result.innerNode();
|
| if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable() || innerNode->isTextNode()
|
| @@ -2405,7 +2406,7 @@ bool EventHandler::handleGestureLongTap(const GestureEventWithHitTestResults& ta
|
| bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const PlatformGestureEvent& gestureEvent) {
|
| if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) {
|
| Layer* layer = eventTarget->renderer() ? eventTarget->renderer()->enclosingLayer() : nullptr;
|
| - IntPoint p = m_frame->view()->windowToContents(gestureEvent.position());
|
| + IntPoint p = m_frame->view()->rootFrameToContents(gestureEvent.position());
|
| if (layer && layer->scrollableArea() && layer->scrollableArea()->isPointInResizeControl(p, ResizerForTouch)) {
|
| m_resizeScrollableArea = layer->scrollableArea();
|
| m_resizeScrollableArea->setInResizeMode(true);
|
| @@ -2600,8 +2601,8 @@ bool EventHandler::bestClickableNodeForHitTestResult(const HitTestResult& result
|
| return false;
|
| }
|
|
|
| - IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPointInMainFrame());
|
| - IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation().boundingBox());
|
| + IntPoint touchCenter = m_frame->view()->contentsToRootFrame(result.roundedPointInMainFrame());
|
| + IntRect touchRect = m_frame->view()->contentsToRootFrame(result.hitTestLocation().boundingBox());
|
|
|
| WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes;
|
| copyToVector(result.listBasedTestResult(), nodes);
|
| @@ -2613,8 +2614,8 @@ bool EventHandler::bestClickableNodeForHitTestResult(const HitTestResult& result
|
| bool EventHandler::bestContextMenuNodeForHitTestResult(const HitTestResult& result, IntPoint& targetPoint, Node*& targetNode)
|
| {
|
| ASSERT(result.isRectBasedTest());
|
| - IntPoint touchCenter = m_frame->view()->contentsToWindow(result.roundedPointInMainFrame());
|
| - IntRect touchRect = m_frame->view()->contentsToWindow(result.hitTestLocation().boundingBox());
|
| + IntPoint touchCenter = m_frame->view()->contentsToRootFrame(result.roundedPointInMainFrame());
|
| + IntRect touchRect = m_frame->view()->contentsToRootFrame(result.hitTestLocation().boundingBox());
|
| WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes;
|
| copyToVector(result.listBasedTestResult(), nodes);
|
|
|
| @@ -2627,7 +2628,7 @@ bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, co
|
| if (touchRadius.isEmpty())
|
| return false;
|
|
|
| - IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter);
|
| + IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(touchCenter);
|
|
|
| HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased;
|
| HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType, LayoutSize(touchRadius));
|
| @@ -2684,7 +2685,7 @@ GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
|
| // Perform the rect-based hit-test (or point-based if adjustment is disabled). Note that
|
| // we don't yet apply hover/active state here because we need to resolve touch adjustment
|
| // first so that we apply hover/active it to the final adjusted node.
|
| - IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.position());
|
| + IntPoint hitTestPoint = m_frame->view()->rootFrameToContents(gestureEvent.position());
|
| LayoutSize padding;
|
| if (shouldApplyTouchAdjustment(gestureEvent)) {
|
| padding = LayoutSize(gestureEvent.area());
|
| @@ -2708,7 +2709,7 @@ GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(const
|
| LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
|
| if (!hitFrame)
|
| hitFrame = m_frame;
|
| - hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased);
|
| + hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFrameToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~HitTestRequest::ListBased);
|
| }
|
|
|
| // If we did a rect-based hit test it must be resolved to the best single node by now to
|
| @@ -2773,7 +2774,7 @@ void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, HitT
|
| // Update the hit-test result to be a point-based result instead of a rect-based result.
|
| // FIXME: We should do this even when no candidate matches the node filter. crbug.com/398914
|
| if (adjusted) {
|
| - hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->windowToContents(adjustedPoint));
|
| + hitTestResult->resolveRectBasedTest(adjustedNode, m_frame->view()->rootFrameToContents(adjustedPoint));
|
| gestureEvent->applyTouchAdjustment(adjustedPoint);
|
| }
|
| }
|
| @@ -2787,7 +2788,7 @@ bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
|
|
|
| // Clear mouse press state to avoid initiating a drag while context menu is up.
|
| m_mousePressed = false;
|
| - LayoutPoint viewportPos = v->windowToContents(event.position());
|
| + LayoutPoint viewportPos = v->rootFrameToContents(event.position());
|
| HitTestRequest request(HitTestRequest::Active);
|
| MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportPos, event);
|
|
|
| @@ -2840,12 +2841,12 @@ bool EventHandler::sendContextMenuEventForKey()
|
| int x = rightAligned ? firstRect.maxX() : firstRect.x();
|
| // In a multiline edit, firstRect.maxY() would endup on the next line, so -1.
|
| int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0;
|
| - locationInViewport = view->contentsToWindow(IntPoint(x, y));
|
| + locationInViewport = view->contentsToViewport(IntPoint(x, y));
|
| } else if (focusedElement) {
|
| IntRect clippedRect = focusedElement->boundsInViewportSpace();
|
| locationInViewport = IntPoint(clippedRect.center());
|
| } else {
|
| - // FIXME - Almost certainly wrong, this is not in viewport space. crbug.com/458682.
|
| + // FIXME - Almost certainly wrong, this is not in viewport space. crbug.com/458602.
|
| locationInViewport = IntPoint(
|
| rightAligned ? view->contentsWidth() - kContextMenuMargin : kContextMenuMargin,
|
| kContextMenuMargin);
|
| @@ -2941,7 +2942,7 @@ void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad)
|
| if (!view)
|
| return;
|
|
|
| - if (!quad.containsPoint(view->windowToContents(m_lastKnownMousePosition)))
|
| + if (!quad.containsPoint(view->rootFrameToContents(m_lastKnownMousePosition)))
|
| return;
|
|
|
| dispatchFakeMouseMoveEventSoon();
|
| @@ -3007,7 +3008,7 @@ void EventHandler::hoverTimerFired(Timer<EventHandler>*)
|
| if (LayoutView* renderer = m_frame->contentRenderer()) {
|
| if (FrameView* view = m_frame->view()) {
|
| HitTestRequest request(HitTestRequest::Move);
|
| - HitTestResult result(view->windowToContents(m_lastKnownMousePosition));
|
| + HitTestResult result(view->rootFrameToContents(m_lastKnownMousePosition));
|
| renderer->hitTest(request, result);
|
| m_frame->document()->updateHoverActiveState(request, result.innerElement());
|
| }
|
| @@ -3187,12 +3188,12 @@ void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event)
|
| }
|
| }
|
|
|
| -bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation) const
|
| +bool EventHandler::dragHysteresisExceeded(const IntPoint& dragLocationInRootFrame) const
|
| {
|
| FrameView* view = m_frame->view();
|
| if (!view)
|
| return false;
|
| - IntPoint dragLocation = view->windowToContents(dragViewportLocation);
|
| + IntPoint dragLocation = view->rootFrameToContents(dragLocationInRootFrame);
|
| IntSize delta = dragLocation - m_mouseDownPos;
|
|
|
| int threshold = GeneralDragHysteresis;
|
| @@ -3611,12 +3612,12 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
|
| // to hit-test on touchstart, and it can be read-only.
|
| if (point.state() == PlatformTouchPoint::TouchPressed) {
|
| HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent | HitTestRequest::ReadOnly | HitTestRequest::Active;
|
| - LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->windowToContents(point.pos()));
|
| + LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFrameToContents(point.pos()));
|
| HitTestResult result;
|
| if (!m_touchSequenceDocument) {
|
| result = hitTestResultAtPoint(pagePoint, hitType);
|
| } else if (m_touchSequenceDocument->frame()) {
|
| - LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocument->frame()->view()->windowToContents(point.pos()));
|
| + LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocument->frame()->view()->rootFrameToContents(point.pos()));
|
| result = hitTestResultInFrame(m_touchSequenceDocument->frame(), framePoint, hitType);
|
| } else
|
| continue;
|
| @@ -3734,9 +3735,8 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
|
| }
|
| ASSERT(targetFrame);
|
|
|
| - // pagePoint should always be relative to the target elements
|
| - // containing frame.
|
| - FloatPoint pagePoint = targetFrame->view()->windowToContents(point.pos());
|
| + // pagePoint should always be in the target element's document coordinates.
|
| + FloatPoint pagePoint = targetFrame->view()->rootFrameToContents(point.pos());
|
|
|
| float scaleFactor = 1.0f / targetFrame->pageZoomFactor();
|
|
|
| @@ -3853,7 +3853,7 @@ bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
|
| // greyed out even though we're clicking on the selection. This looks
|
| // really strange (having the whole frame be greyed out), so we deselect the
|
| // selection.
|
| - IntPoint p = m_frame->view()->windowToContents(mev.event().position());
|
| + IntPoint p = m_frame->view()->rootFrameToContents(mev.event().position());
|
| if (m_frame->selection().contains(p)) {
|
| VisiblePosition visiblePos(
|
| mev.innerNode()->renderer()->positionForPoint(mev.localPoint()));
|
|
|