Diff
Modified: branches/safari-604-branch/LayoutTests/ChangeLog (219788 => 219789)
--- branches/safari-604-branch/LayoutTests/ChangeLog 2017-07-23 06:52:10 UTC (rev 219788)
+++ branches/safari-604-branch/LayoutTests/ChangeLog 2017-07-23 19:02:28 UTC (rev 219789)
@@ -1,3 +1,17 @@
+2017-07-23 Jason Marcell <[email protected]>
+
+ Cherry-pick r219571. rdar://problem/33464710
+
+ 2017-07-17 Simon Fraser <[email protected]>
+
+ clientX/clientY on TouchEvent.touches are wrong
+ https://bugs.webkit.org/show_bug.cgi?id=174561
+
+ Reviewed by Tim Horton.
+
+ * fast/events/touch/ios/touches-client-coords-after-zoom-expected.txt: Added.
+ * fast/events/touch/ios/touches-client-coords-after-zoom.html: Added.
+
2017-07-22 Jason Marcell <[email protected]>
Cherry-pick r219662. rdar://problem/33464110
Added: branches/safari-604-branch/LayoutTests/fast/events/touch/ios/touches-client-coords-after-zoom-expected.txt (0 => 219789)
--- branches/safari-604-branch/LayoutTests/fast/events/touch/ios/touches-client-coords-after-zoom-expected.txt (rev 0)
+++ branches/safari-604-branch/LayoutTests/fast/events/touch/ios/touches-client-coords-after-zoom-expected.txt 2017-07-23 19:02:28 UTC (rev 219789)
@@ -0,0 +1,6 @@
+
+These two events should have the same client coordinates:
+
+Received event touchstart with client coords 150, 160
+Received event click with client coords 150, 160
+
Added: branches/safari-604-branch/LayoutTests/fast/events/touch/ios/touches-client-coords-after-zoom.html (0 => 219789)
--- branches/safari-604-branch/LayoutTests/fast/events/touch/ios/touches-client-coords-after-zoom.html (rev 0)
+++ branches/safari-604-branch/LayoutTests/fast/events/touch/ios/touches-client-coords-after-zoom.html 2017-07-23 19:02:28 UTC (rev 219789)
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+body {
+ margin: 0;
+ height: 2000px;
+}
+
+button {
+ width: 400px;
+ height: 500px;
+ border: 1px solid black;
+ background-color: silver;
+}
+</style>
+
+<script>
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+function logString(s)
+{
+ document.getElementById('log').textContent += s + '\n';
+}
+
+function getUIScript()
+{
+ return `
+ (function() {
+ uiController.zoomToScale(1.2, function() {
+ uiController.singleTapAtPoint(150, 160, function() {
+ uiController.uiScriptComplete();
+ });
+ });
+ })();`
+}
+
+var gotTouch = false;
+var gotClick = false;
+var eventsComplete = false;
+
+function checkForCompletion()
+{
+ if (gotTouch && gotClick && eventsComplete) {
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }
+}
+
+function doTest()
+{
+ var button = document.getElementById('button');
+ button.addEventListener('touchstart', function(event) {
+ logString('Received event ' + event.type + ' with client coords ' + event.touches[0].clientX + ', ' + event.touches[0].clientY);
+ gotTouch = true;
+ checkForCompletion();
+ });
+
+ button.addEventListener('click', function(event) {
+ logString('Received event ' + event.type + ' with client coords ' + event.clientX + ', ' + event.clientY);
+ gotClick = true;
+ checkForCompletion();
+ });
+
+ if (window.testRunner && testRunner.runUIScript) {
+ testRunner.runUIScript(getUIScript(), function() {
+ eventsComplete = true;
+ checkForCompletion();
+ });
+ }
+}
+
+window.addEventListener('load', doTest, false);
+</script>
+</head>
+
+<body>
+ <button id="button"></button>
+ <p>These two events should have the same client coordinates:</p>
+<pre id="log"></pre>
+</body>
+
+</html>
Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (219788 => 219789)
--- branches/safari-604-branch/Source/WebCore/ChangeLog 2017-07-23 06:52:10 UTC (rev 219788)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog 2017-07-23 19:02:28 UTC (rev 219789)
@@ -1,3 +1,35 @@
+2017-07-23 Jason Marcell <[email protected]>
+
+ Cherry-pick r219571. rdar://problem/33464710
+
+ 2017-07-17 Simon Fraser <[email protected]>
+
+ clientX/clientY on TouchEvent.touches are wrong
+ https://bugs.webkit.org/show_bug.cgi?id=174561
+ rdar://problem/33336041
+
+ Reviewed by Tim Horton.
+
+ Do some refactoring so that WebKitAdditions code that computes Touch coordinates can use
+ the same code that MouseRelatedEvent uses.
+
+ There is no behavior change in this patch, but the test exercises a behavior change in
+ WebKitAdditions code.
+
+ Test: fast/events/touch/ios/touches-client-coords-after-zoom.html
+
+ * dom/MouseRelatedEvent.cpp:
+ (WebCore::MouseRelatedEvent::init):
+ (WebCore::MouseRelatedEvent::frameViewFromDOMWindow):
+ (WebCore::MouseRelatedEvent::pagePointToClientPoint):
+ (WebCore::MouseRelatedEvent::pagePointToAbsolutePoint):
+ (WebCore::MouseRelatedEvent::initCoordinates):
+ (WebCore::MouseRelatedEvent::documentToAbsoluteScaleFactor):
+ (WebCore::MouseRelatedEvent::computePageLocation):
+ (WebCore::MouseRelatedEvent::locationInRootViewCoordinates):
+ (WebCore::MouseRelatedEvent::frameView): Deleted.
+ * dom/MouseRelatedEvent.h:
+
2017-07-22 Jason Marcell <[email protected]>
Cherry-pick r219662. rdar://problem/33464110
Modified: branches/safari-604-branch/Source/WebCore/dom/MouseRelatedEvent.cpp (219788 => 219789)
--- branches/safari-604-branch/Source/WebCore/dom/MouseRelatedEvent.cpp 2017-07-23 06:52:10 UTC (rev 219788)
+++ branches/safari-604-branch/Source/WebCore/dom/MouseRelatedEvent.cpp 2017-07-23 19:02:28 UTC (rev 219789)
@@ -61,11 +61,11 @@
void MouseRelatedEvent::init(bool isSimulated, const IntPoint& windowLocation)
{
if (!isSimulated) {
- if (auto* frameView = this->frameView()) {
+ if (auto* frameView = frameViewFromDOMWindow(view())) {
FloatPoint absolutePoint = frameView->windowToContents(windowLocation);
FloatPoint documentPoint = frameView->absoluteToDocumentPoint(absolutePoint);
m_pageLocation = flooredLayoutPoint(documentPoint);
- m_clientLocation = flooredLayoutPoint(frameView->documentToClientPoint(documentPoint));
+ m_clientLocation = pagePointToClientPoint(m_pageLocation, frameView);
}
}
@@ -83,12 +83,37 @@
m_hasCachedRelativePosition = false;
}
+FrameView* MouseRelatedEvent::frameViewFromDOMWindow(DOMWindow* window)
+{
+ auto* frame = window ? window->frame() : nullptr;
+ if (!frame)
+ return nullptr;
+
+ return frame->view();
+}
+
+LayoutPoint MouseRelatedEvent::pagePointToClientPoint(LayoutPoint pagePoint, FrameView* frameView)
+{
+ if (!frameView)
+ return pagePoint;
+
+ return flooredLayoutPoint(frameView->documentToClientPoint(pagePoint));
+}
+
+LayoutPoint MouseRelatedEvent::pagePointToAbsolutePoint(LayoutPoint pagePoint, FrameView* frameView)
+{
+ if (!frameView)
+ return pagePoint;
+
+ return pagePoint.scaled(frameView->documentToAbsoluteScaleFactor());
+}
+
void MouseRelatedEvent::initCoordinates(const LayoutPoint& clientLocation)
{
// Set up initial values for coordinates.
// Correct values are computed lazily, see computeRelativePosition.
FloatSize documentToClientOffset;
- if (auto* frameView = this->frameView())
+ if (auto* frameView = frameViewFromDOMWindow(view()))
documentToClientOffset = frameView->documentToClientOffset();
m_clientLocation = clientLocation;
@@ -101,18 +126,9 @@
m_hasCachedRelativePosition = false;
}
-FrameView* MouseRelatedEvent::frameView() const
-{
- auto* frame = view() ? view()->frame() : nullptr;
- if (!frame)
- return nullptr;
-
- return frame->view();
-}
-
float MouseRelatedEvent::documentToAbsoluteScaleFactor() const
{
- if (auto* frameView = this->frameView())
+ if (auto* frameView = frameViewFromDOMWindow(view()))
return frameView->documentToAbsoluteScaleFactor();
return 1;
@@ -120,7 +136,7 @@
void MouseRelatedEvent::computePageLocation()
{
- m_absoluteLocation = m_pageLocation.scaled(documentToAbsoluteScaleFactor());
+ m_absoluteLocation = pagePointToAbsolutePoint(m_pageLocation, frameViewFromDOMWindow(view()));
}
void MouseRelatedEvent::receivedTarget()
@@ -169,7 +185,10 @@
FloatPoint MouseRelatedEvent::locationInRootViewCoordinates() const
{
- return frameView()->contentsToRootView(roundedIntPoint(m_absoluteLocation));
+ if (auto* frameView = frameViewFromDOMWindow(view()))
+ return frameView->contentsToRootView(roundedIntPoint(m_absoluteLocation));
+
+ return m_absoluteLocation;
}
int MouseRelatedEvent::layerX()
Modified: branches/safari-604-branch/Source/WebCore/dom/MouseRelatedEvent.h (219788 => 219789)
--- branches/safari-604-branch/Source/WebCore/dom/MouseRelatedEvent.h 2017-07-23 06:52:10 UTC (rev 219788)
+++ branches/safari-604-branch/Source/WebCore/dom/MouseRelatedEvent.h 2017-07-23 19:02:28 UTC (rev 219789)
@@ -65,7 +65,12 @@
// Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords,
// usable with RenderObject::absoluteToLocal).
const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; }
+
+ static FrameView* frameViewFromDOMWindow(DOMWindow*);
+ static LayoutPoint pagePointToClientPoint(LayoutPoint pagePoint, FrameView*);
+ static LayoutPoint pagePointToAbsolutePoint(LayoutPoint pagePoint, FrameView*);
+
protected:
MouseRelatedEvent() = default;
MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow*,
@@ -84,7 +89,6 @@
void computeRelativePosition();
float documentToAbsoluteScaleFactor() const;
- FrameView* frameView() const;
// Expose these so MouseEvent::initMouseEvent can set them.
IntPoint m_screenLocation;