Title: [141019] trunk/Source/WebKit/chromium
Revision
141019
Author
[email protected]
Date
2013-01-28 15:38:14 -0800 (Mon, 28 Jan 2013)

Log Message

[Chromium, Mobile] Do not show disambiguation pop up in mobile sites
https://bugs.webkit.org/show_bug.cgi?id=107607

Patch by Dan Alcantara <[email protected]> on 2013-01-28
Reviewed by Adam Barth.

Add a check before showing the disambiguation popup to prevent it from appearing
on mobile sites.  Makes a similar test to the current disambiguation popup test
that expects the popup to never appear.

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleGestureEvent):
(WebKit):
(WebKit::WebViewImpl::isLikelyMobileSite):
* src/WebViewImpl.h:
(WebViewImpl):
* tests/WebFrameTest.cpp:
* tests/data/disambiguation_popup_mobile_site.html: Added.

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleGestureEvent):
(WebKit):
(WebKit::WebViewImpl::shouldDisableDesktopWorkarounds):
* src/WebViewImpl.h:
(WebViewImpl):
* tests/WebFrameTest.cpp:
* tests/data/disambiguation_popup_mobile_site.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (141018 => 141019)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-01-28 23:32:58 UTC (rev 141018)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-01-28 23:38:14 UTC (rev 141019)
@@ -1,3 +1,32 @@
+2013-01-28  Dan Alcantara  <[email protected]>
+
+        [Chromium, Mobile] Do not show disambiguation pop up in mobile sites
+        https://bugs.webkit.org/show_bug.cgi?id=107607
+
+        Reviewed by Adam Barth.
+
+        Add a check before showing the disambiguation popup to prevent it from appearing
+        on mobile sites.  Makes a similar test to the current disambiguation popup test
+        that expects the popup to never appear.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleGestureEvent):
+        (WebKit):
+        (WebKit::WebViewImpl::isLikelyMobileSite):
+        * src/WebViewImpl.h:
+        (WebViewImpl):
+        * tests/WebFrameTest.cpp:
+        * tests/data/disambiguation_popup_mobile_site.html: Added.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleGestureEvent):
+        (WebKit):
+        (WebKit::WebViewImpl::shouldDisableDesktopWorkarounds):
+        * src/WebViewImpl.h:
+        (WebViewImpl):
+        * tests/WebFrameTest.cpp:
+        * tests/data/disambiguation_popup_mobile_site.html: Added.
+
 2013-01-28  Stephen Chenney  <[email protected]>
 
         [Chromium] Fix the build.

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (141018 => 141019)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2013-01-28 23:32:58 UTC (rev 141018)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2013-01-28 23:38:14 UTC (rev 141019)
@@ -753,7 +753,9 @@
         hideSelectPopup();
         ASSERT(!m_selectPopup);
 
-        if (event.data.tap.width > 0) {
+        // Don't trigger a disambiguation popup on sites designed for mobile devices.
+        // Instead, assume that the page has been designed with big enough buttons and links.
+        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);
@@ -4365,4 +4367,11 @@
 }
 #endif
 
+bool WebViewImpl::shouldDisableDesktopWorkarounds()
+{
+    ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewportArguments();
+    return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.userZoom
+        || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != ViewportArguments::ValueAuto);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (141018 => 141019)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2013-01-28 23:32:58 UTC (rev 141018)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2013-01-28 23:38:14 UTC (rev 141019)
@@ -601,6 +601,10 @@
     virtual bool isPointerLocked();
 #endif
 
+    // Heuristic-based function for determining if we should disable workarounds
+    // for viewing websites that are not optimized for mobile devices.
+    bool shouldDisableDesktopWorkarounds();
+
 #if ENABLE(GESTURE_EVENTS)
     // Exposed for tests.
     LinkHighlight* linkHighlight() { return m_linkHighlight.get(); }

Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (141018 => 141019)


--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2013-01-28 23:32:58 UTC (rev 141018)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2013-01-28 23:38:14 UTC (rev 141019)
@@ -1929,6 +1929,39 @@
     EXPECT_FALSE(client.triggered());
 }
 
+TEST_F(WebFrameTest, DisambiguationPopupMobileSite)
+{
+    registerMockedHttpURLLoad("disambiguation_popup_mobile_site.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.html", true, 0, &client));
+    webViewImpl->resize(WebSize(1000, 1000));
+    webViewImpl->layout();
+
+    client.resetTriggered();
+    webViewImpl->handleInputEvent(fatTap(0, 0));
+    EXPECT_FALSE(client.triggered());
+
+    client.resetTriggered();
+    webViewImpl->handleInputEvent(fatTap(200, 115));
+    EXPECT_FALSE(client.triggered());
+
+    for (int i = 0; i <= 46; i++) {
+        client.resetTriggered();
+        webViewImpl->handleInputEvent(fatTap(120, 230 + i * 5));
+        EXPECT_FALSE(client.triggered());
+    }
+
+    for (int i = 0; i <= 46; i++) {
+        client.resetTriggered();
+        webViewImpl->handleInputEvent(fatTap(10 + i * 5, 590));
+        EXPECT_FALSE(client.triggered());
+    }
+}
+
 class TestSubstituteDataWebFrameClient : public WebFrameClient {
 public:
     TestSubstituteDataWebFrameClient()

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


--- trunk/Source/WebKit/chromium/tests/data/disambiguation_popup_mobile_site.html	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/disambiguation_popup_mobile_site.html	2013-01-28 23:38:14 UTC (rev 141019)
@@ -0,0 +1,31 @@
+<html>
+<head>
+<title>Disambiguation Popup Test</title>
+<style type="text/css">
+.horizontal-link {
+    display:block;
+    width:200px;
+    height:30px;
+    margin:20px;
+    background-color:#ccccff;
+}
+.vertical-link {
+    display:inline-block;
+    width:30px;
+    height:200px;
+    margin:10px;
+    background-color:#ccccff;
+}
+</style>
+<meta name="viewport" content="width=device-width">
+</head>
+<body style="margin:0px;">
+<a href="" class="horizontal-link" style="margin:100px">Link</a>
+<a href="" class="horizontal-link">Link 1</a>
+<a href="" class="horizontal-link">Link 2</a>
+<a href="" class="horizontal-link">Link 3</a>
+<a href="" class="horizontal-link">Link 4</a>
+<a href="" class="horizontal-link">Link 5</a>
+<a href="" class="vertical-link">Link 1</a><a href="" class="vertical-link">Link 2</a><a href="" class="vertical-link">Link 3</a><a href="" class="vertical-link">Link 4</a><a href="" class="vertical-link">Link 5</a>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to