Changeset 219571 in webkit
- Timestamp:
- Jul 17, 2017, 1:24:16 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/events/touch/ios/touches-client-coords-after-zoom-expected.txt (added)
-
LayoutTests/fast/events/touch/ios/touches-client-coords-after-zoom.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/MouseRelatedEvent.cpp (modified) (6 diffs)
-
Source/WebCore/dom/MouseRelatedEvent.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r219568 r219571 1 2017-07-17 Simon Fraser <simon.fraser@apple.com> 2 3 clientX/clientY on TouchEvent.touches are wrong 4 https://bugs.webkit.org/show_bug.cgi?id=174561 5 6 Reviewed by Tim Horton. 7 8 * fast/events/touch/ios/touches-client-coords-after-zoom-expected.txt: Added. 9 * fast/events/touch/ios/touches-client-coords-after-zoom.html: Added. 10 1 11 2017-07-17 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r219569 r219571 1 2017-07-17 Simon Fraser <simon.fraser@apple.com> 2 3 clientX/clientY on TouchEvent.touches are wrong 4 https://bugs.webkit.org/show_bug.cgi?id=174561 5 rdar://problem/33336041 6 7 Reviewed by Tim Horton. 8 9 Do some refactoring so that WebKitAdditions code that computes Touch coordinates can use 10 the same code that MouseRelatedEvent uses. 11 12 There is no behavior change in this patch, but the test exercises a behavior change in 13 WebKitAdditions code. 14 15 Test: fast/events/touch/ios/touches-client-coords-after-zoom.html 16 17 * dom/MouseRelatedEvent.cpp: 18 (WebCore::MouseRelatedEvent::init): 19 (WebCore::MouseRelatedEvent::frameViewFromDOMWindow): 20 (WebCore::MouseRelatedEvent::pagePointToClientPoint): 21 (WebCore::MouseRelatedEvent::pagePointToAbsolutePoint): 22 (WebCore::MouseRelatedEvent::initCoordinates): 23 (WebCore::MouseRelatedEvent::documentToAbsoluteScaleFactor): 24 (WebCore::MouseRelatedEvent::computePageLocation): 25 (WebCore::MouseRelatedEvent::locationInRootViewCoordinates): 26 (WebCore::MouseRelatedEvent::frameView): Deleted. 27 * dom/MouseRelatedEvent.h: 28 1 29 2017-07-17 Jeremy Jones <jeremyj@apple.com> 2 30 -
trunk/Source/WebCore/dom/MouseRelatedEvent.cpp
r219304 r219571 62 62 { 63 63 if (!isSimulated) { 64 if (auto* frameView = this->frameView()) {64 if (auto* frameView = frameViewFromDOMWindow(view())) { 65 65 FloatPoint absolutePoint = frameView->windowToContents(windowLocation); 66 66 FloatPoint documentPoint = frameView->absoluteToDocumentPoint(absolutePoint); 67 67 m_pageLocation = flooredLayoutPoint(documentPoint); 68 m_clientLocation = flooredLayoutPoint(frameView->documentToClientPoint(documentPoint));68 m_clientLocation = pagePointToClientPoint(m_pageLocation, frameView); 69 69 } 70 70 } … … 84 84 } 85 85 86 FrameView* MouseRelatedEvent::frameViewFromDOMWindow(DOMWindow* window) 87 { 88 auto* frame = window ? window->frame() : nullptr; 89 if (!frame) 90 return nullptr; 91 92 return frame->view(); 93 } 94 95 LayoutPoint MouseRelatedEvent::pagePointToClientPoint(LayoutPoint pagePoint, FrameView* frameView) 96 { 97 if (!frameView) 98 return pagePoint; 99 100 return flooredLayoutPoint(frameView->documentToClientPoint(pagePoint)); 101 } 102 103 LayoutPoint MouseRelatedEvent::pagePointToAbsolutePoint(LayoutPoint pagePoint, FrameView* frameView) 104 { 105 if (!frameView) 106 return pagePoint; 107 108 return pagePoint.scaled(frameView->documentToAbsoluteScaleFactor()); 109 } 110 86 111 void MouseRelatedEvent::initCoordinates(const LayoutPoint& clientLocation) 87 112 { … … 89 114 // Correct values are computed lazily, see computeRelativePosition. 90 115 FloatSize documentToClientOffset; 91 if (auto* frameView = this->frameView())116 if (auto* frameView = frameViewFromDOMWindow(view())) 92 117 documentToClientOffset = frameView->documentToClientOffset(); 93 118 … … 102 127 } 103 128 104 FrameView* MouseRelatedEvent::frameView() const105 {106 auto* frame = view() ? view()->frame() : nullptr;107 if (!frame)108 return nullptr;109 110 return frame->view();111 }112 113 129 float MouseRelatedEvent::documentToAbsoluteScaleFactor() const 114 130 { 115 if (auto* frameView = this->frameView())131 if (auto* frameView = frameViewFromDOMWindow(view())) 116 132 return frameView->documentToAbsoluteScaleFactor(); 117 133 … … 121 137 void MouseRelatedEvent::computePageLocation() 122 138 { 123 m_absoluteLocation = m_pageLocation.scaled(documentToAbsoluteScaleFactor());139 m_absoluteLocation = pagePointToAbsolutePoint(m_pageLocation, frameViewFromDOMWindow(view())); 124 140 } 125 141 … … 170 186 FloatPoint MouseRelatedEvent::locationInRootViewCoordinates() const 171 187 { 172 return frameView()->contentsToRootView(roundedIntPoint(m_absoluteLocation)); 188 if (auto* frameView = frameViewFromDOMWindow(view())) 189 return frameView->contentsToRootView(roundedIntPoint(m_absoluteLocation)); 190 191 return m_absoluteLocation; 173 192 } 174 193 -
trunk/Source/WebCore/dom/MouseRelatedEvent.h
r219304 r219571 66 66 // usable with RenderObject::absoluteToLocal). 67 67 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } 68 69 static FrameView* frameViewFromDOMWindow(DOMWindow*); 70 71 static LayoutPoint pagePointToClientPoint(LayoutPoint pagePoint, FrameView*); 72 static LayoutPoint pagePointToAbsolutePoint(LayoutPoint pagePoint, FrameView*); 68 73 69 74 protected: … … 85 90 86 91 float documentToAbsoluteScaleFactor() const; 87 FrameView* frameView() const;88 92 89 93 // Expose these so MouseEvent::initMouseEvent can set them.
Note:
See TracChangeset
for help on using the changeset viewer.