Title: [141062] trunk/Source
Revision
141062
Author
commit-qu...@webkit.org
Date
2013-01-28 23:29:26 -0800 (Mon, 28 Jan 2013)

Log Message

Fix disambiguation popup for new-style page scale
https://bugs.webkit.org/show_bug.cgi?id=107391

Patch by Tien-Ren Chen <trc...@chromium.org> on 2013-01-28
Reviewed by Adam Barth.

This patch corrects various coordinate conversion for disambiguation
popup for the new-style page scale mode.

Source/WebCore:

New unit test: WebFrameTest.DisambiguationPopupPageScale

* page/TouchDisambiguation.cpp:
(WebCore::findGoodTouchTargets):
* page/TouchDisambiguation.h:
(WebCore):

Source/WebKit/chromium:

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleGestureEvent):
(WebKit::WebViewImpl::handleInputEvent):
* tests/WebFrameTest.cpp:
* tests/data/disambiguation_popup_page_scale.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (141061 => 141062)


--- trunk/Source/WebCore/ChangeLog	2013-01-29 07:14:20 UTC (rev 141061)
+++ trunk/Source/WebCore/ChangeLog	2013-01-29 07:29:26 UTC (rev 141062)
@@ -1,3 +1,20 @@
+2013-01-28  Tien-Ren Chen  <trc...@chromium.org>
+
+        Fix disambiguation popup for new-style page scale
+        https://bugs.webkit.org/show_bug.cgi?id=107391
+
+        Reviewed by Adam Barth.
+
+        This patch corrects various coordinate conversion for disambiguation
+        popup for the new-style page scale mode.
+
+        New unit test: WebFrameTest.DisambiguationPopupPageScale
+
+        * page/TouchDisambiguation.cpp:
+        (WebCore::findGoodTouchTargets):
+        * page/TouchDisambiguation.h:
+        (WebCore):
+
 2013-01-28  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r141049.

Modified: trunk/Source/WebCore/page/TouchDisambiguation.cpp (141061 => 141062)


--- trunk/Source/WebCore/page/TouchDisambiguation.cpp	2013-01-29 07:14:20 UTC (rev 141061)
+++ trunk/Source/WebCore/page/TouchDisambiguation.cpp	2013-01-29 07:29:26 UTC (rev 141062)
@@ -86,14 +86,14 @@
     float score;
 };
 
-void findGoodTouchTargets(const IntRect& touchBox, Frame* mainFrame, float pageScaleFactor, Vector<IntRect>& goodTargets)
+void findGoodTouchTargets(const IntRect& touchBox, Frame* mainFrame, Vector<IntRect>& goodTargets)
 {
     goodTargets.clear();
 
     int touchPointPadding = ceil(max(touchBox.width(), touchBox.height()) * 0.5);
     // FIXME: Rect-based hit test doesn't transform the touch point size.
-    //        We have to pre-apply page scale factor here.
-    int padding = ceil(touchPointPadding / pageScaleFactor);
+    //        We have to pre-apply frame scale factor here.
+    int padding = ceil(touchPointPadding / mainFrame->frameScaleFactor());
 
     IntPoint touchPoint = touchBox.center();
     IntPoint contentsPoint = mainFrame->view()->windowToContents(touchPoint);

Modified: trunk/Source/WebCore/page/TouchDisambiguation.h (141061 => 141062)


--- trunk/Source/WebCore/page/TouchDisambiguation.h	2013-01-29 07:14:20 UTC (rev 141061)
+++ trunk/Source/WebCore/page/TouchDisambiguation.h	2013-01-29 07:29:26 UTC (rev 141062)
@@ -38,7 +38,7 @@
 class Frame;
 class IntRect;
 
-void findGoodTouchTargets(const IntRect& touchBox, Frame* mainFrame, float pageScaleFactor, Vector<IntRect>& goodTargets);
+void findGoodTouchTargets(const IntRect& touchBox, Frame* mainFrame, Vector<IntRect>& goodTargets);
 
 } // namespace WebCore
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (141061 => 141062)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-01-29 07:14:20 UTC (rev 141061)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-01-29 07:29:26 UTC (rev 141062)
@@ -1,3 +1,19 @@
+2013-01-28  Tien-Ren Chen  <trc...@chromium.org>
+
+        Fix disambiguation popup for new-style page scale
+        https://bugs.webkit.org/show_bug.cgi?id=107391
+
+        Reviewed by Adam Barth.
+
+        This patch corrects various coordinate conversion for disambiguation
+        popup for the new-style page scale mode.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleGestureEvent):
+        (WebKit::WebViewImpl::handleInputEvent):
+        * tests/WebFrameTest.cpp:
+        * tests/data/disambiguation_popup_page_scale.html: Added.
+
 2013-01-28  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r141049.

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (141061 => 141062)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2013-01-29 07:14:20 UTC (rev 141061)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2013-01-29 07:29:26 UTC (rev 141062)
@@ -758,7 +758,7 @@
         if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) {
             IntRect boundingBox(event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, event.data.tap.width, event.data.tap.height);
             Vector<IntRect> goodTargets;
-            findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), pageScaleFactor(), goodTargets);
+            findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTargets);
             // FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
             // Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101
             if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(event, goodTargets)) {
@@ -2114,6 +2114,8 @@
             gestureEvent = *static_cast<const WebGestureEvent*>(&inputEvent);
             gestureEvent.x = gestureEvent.x / pageScaleFactor();
             gestureEvent.y = gestureEvent.y / pageScaleFactor();
+            gestureEvent.data.tap.width /= pageScaleFactor();
+            gestureEvent.data.tap.height /= pageScaleFactor();
             inputEventTransformed = static_cast<const WebInputEvent*>(&gestureEvent);
         }
     }

Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (141061 => 141062)


--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2013-01-29 07:14:20 UTC (rev 141061)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2013-01-29 07:29:26 UTC (rev 141062)
@@ -2067,6 +2067,40 @@
     }
 }
 
+TEST_F(WebFrameTest, DisambiguationPopupPageScale)
+{
+    registerMockedHttpURLLoad("disambiguation_popup_page_scale.html");
+
+    DisambiguationPopupTestWebViewClient client;
+
+    // Make sure we initialize to minimum scale, even if the window size
+    // only becomes available after the load begins.
+    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "disambiguation_popup_page_scale.html", true, 0, &client));
+    webViewImpl->settings()->setApplyDeviceScaleFactorInCompositor(true);
+    webViewImpl->settings()->setApplyPageScaleFactorInCompositor(true);
+    webViewImpl->resize(WebSize(1000, 1000));
+    webViewImpl->layout();
+
+    client.resetTriggered();
+    webViewImpl->handleInputEvent(fatTap(80, 80));
+    EXPECT_TRUE(client.triggered());
+
+    client.resetTriggered();
+    webViewImpl->handleInputEvent(fatTap(230, 190));
+    EXPECT_TRUE(client.triggered());
+
+    webViewImpl->setPageScaleFactor(3.0f, WebPoint(0, 0));
+    webViewImpl->layout();
+
+    client.resetTriggered();
+    webViewImpl->handleInputEvent(fatTap(240, 240));
+    EXPECT_TRUE(client.triggered());
+
+    client.resetTriggered();
+    webViewImpl->handleInputEvent(fatTap(690, 570));
+    EXPECT_FALSE(client.triggered());
+}
+
 class TestSubstituteDataWebFrameClient : public WebFrameClient {
 public:
     TestSubstituteDataWebFrameClient()

Added: trunk/Source/WebKit/chromium/tests/data/disambiguation_popup_page_scale.html (0 => 141062)


--- trunk/Source/WebKit/chromium/tests/data/disambiguation_popup_page_scale.html	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/disambiguation_popup_page_scale.html	2013-01-29 07:29:26 UTC (rev 141062)
@@ -0,0 +1,20 @@
+<html>
+<head>
+<title>Disambiguation Popup Test</title>
+<style type="text/css">
+.link {
+    display:block;
+    position:absolute;
+    width:200px;
+    height:30px;
+    background-color:#ccccff;
+}
+</style>
+</head>
+<body>
+<a href="" class="link" style="left:50px;top:50px;">Link 1</a>
+<a href="" class="link" style="left:50px;top:80px;">Link 2</a>
+<a href="" class="link" style="left:200px;top:150px;">Link 3</a>
+<a href="" class="link" style="left:200px;top:200px;">Link 4</a>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to