diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/MouseRelatedEvent.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/dom/MouseRelatedEvent.cpp')
-rw-r--r-- | Source/WebCore/dom/MouseRelatedEvent.cpp | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/Source/WebCore/dom/MouseRelatedEvent.cpp b/Source/WebCore/dom/MouseRelatedEvent.cpp index 88000f5f3..829126b2c 100644 --- a/Source/WebCore/dom/MouseRelatedEvent.cpp +++ b/Source/WebCore/dom/MouseRelatedEvent.cpp @@ -37,11 +37,11 @@ MouseRelatedEvent::MouseRelatedEvent() { } -static LayoutSize contentsScrollOffset(AbstractView* abstractView) +static LayoutSize contentsScrollOffset(DOMWindow* DOMWindow) { - if (!abstractView) + if (!DOMWindow) return LayoutSize(); - Frame* frame = abstractView->frame(); + Frame* frame = DOMWindow->frame(); if (!frame) return LayoutSize(); FrameView* frameView = frame->view(); @@ -55,35 +55,47 @@ static LayoutSize contentsScrollOffset(AbstractView* abstractView) #endif } -MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, double timestamp, PassRefPtr<AbstractView> abstractView, +MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, double timestamp, DOMWindow* DOMWindow, int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, #if ENABLE(POINTER_LOCK) const IntPoint& movementDelta, #endif bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated) - : UIEventWithKeyState(eventType, canBubble, cancelable, timestamp, abstractView, detail, ctrlKey, altKey, shiftKey, metaKey) + : UIEventWithKeyState(eventType, canBubble, cancelable, timestamp, DOMWindow, detail, ctrlKey, altKey, shiftKey, metaKey, false, false) , m_screenLocation(screenLocation) #if ENABLE(POINTER_LOCK) , m_movementDelta(movementDelta) #endif , m_isSimulated(isSimulated) { + init(isSimulated, windowLocation); +} + +MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, const MouseRelatedEventInit& initializer, IsTrusted isTrusted) + : UIEventWithKeyState(eventType, initializer, isTrusted) + , m_screenLocation(IntPoint(initializer.screenX, initializer.screenY)) +#if ENABLE(POINTER_LOCK) + , m_movementDelta(IntPoint(0, 0)) +#endif + , m_isSimulated(false) +{ + init(false, IntPoint(0, 0)); +} + +void MouseRelatedEvent::init(bool isSimulated, const IntPoint& windowLocation) +{ LayoutPoint adjustedPageLocation; LayoutPoint scrollPosition; - Frame* frame = view() ? view()->frame() : 0; + Frame* frame = view() ? view()->frame() : nullptr; if (frame && !isSimulated) { if (FrameView* frameView = frame->view()) { -#if !PLATFORM(IOS) - scrollPosition = frameView->scrollPosition(); -#else - scrollPosition = frameView->actualScrollPosition(); -#endif + scrollPosition = frameView->contentsScrollPosition(); adjustedPageLocation = frameView->windowToContents(windowLocation); float scaleFactor = 1 / (frame->pageZoomFactor() * frame->frameScaleFactor()); if (scaleFactor != 1.0f) { - adjustedPageLocation.scale(scaleFactor, scaleFactor); - scrollPosition.scale(scaleFactor, scaleFactor); + adjustedPageLocation.scale(scaleFactor); + scrollPosition.scale(scaleFactor); } } } @@ -144,7 +156,7 @@ static float frameScaleFactor(const UIEvent* event) void MouseRelatedEvent::computePageLocation() { float scaleFactor = pageZoomFactor(this) * frameScaleFactor(this); - setAbsoluteLocation(roundedLayoutPoint(FloatPoint(pageX() * scaleFactor, pageY() * scaleFactor))); + setAbsoluteLocation(LayoutPoint(pageX() * scaleFactor, pageY() * scaleFactor)); } void MouseRelatedEvent::receivedTarget() @@ -154,7 +166,7 @@ void MouseRelatedEvent::receivedTarget() void MouseRelatedEvent::computeRelativePosition() { - Node* targetNode = target() ? target()->toNode() : 0; + Node* targetNode = target() ? target()->toNode() : nullptr; if (!targetNode) return; @@ -167,11 +179,10 @@ void MouseRelatedEvent::computeRelativePosition() // Adjust offsetLocation to be relative to the target's position. if (RenderObject* r = targetNode->renderer()) { - FloatPoint localPos = r->absoluteToLocal(absoluteLocation(), UseTransforms); - m_offsetLocation = roundedLayoutPoint(localPos); + m_offsetLocation = LayoutPoint(r->absoluteToLocal(absoluteLocation(), UseTransforms)); float scaleFactor = 1 / (pageZoomFactor(this) * frameScaleFactor(this)); if (scaleFactor != 1.0f) - m_offsetLocation.scale(scaleFactor, scaleFactor); + m_offsetLocation.scale(scaleFactor); } // Adjust layerLocation to be relative to the layer. @@ -208,6 +219,8 @@ int MouseRelatedEvent::layerY() int MouseRelatedEvent::offsetX() { + if (isSimulated()) + return 0; if (!m_hasCachedRelativePosition) computeRelativePosition(); return roundToInt(m_offsetLocation.x()); @@ -215,6 +228,8 @@ int MouseRelatedEvent::offsetX() int MouseRelatedEvent::offsetY() { + if (isSimulated()) + return 0; if (!m_hasCachedRelativePosition) computeRelativePosition(); return roundToInt(m_offsetLocation.y()); |