Changeset 127095 in webkit
- Timestamp:
- Aug 29, 2012 9:08:37 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/WebCore.gypi
r127046 r127095 3164 3164 'page/TouchAdjustment.cpp', 3165 3165 'page/TouchAdjustment.h', 3166 'page/TouchDisambiguation.cpp', 3167 'page/TouchDisambiguation.h', 3166 3168 'page/UserContentURLPattern.cpp', 3167 3169 'page/WebKitAnimation.cpp', -
trunk/Source/WebKit/chromium/ChangeLog
r127084 r127095 1 2012-08-29 Tien-Ren Chen <trchen@chromium.org> 2 3 [chromium] Implement disambiguation popup (a.k.a. Link Preview) 4 https://bugs.webkit.org/show_bug.cgi?id=94182 5 6 Reviewed by Adam Barth. 7 8 In this new implementation, we add a new WebViewClient::handleDisambiguationPopup delegate. 9 The disambiguation sequence will be initiated by the gesture event handler 10 in WebViewImpl if an ambiguous tap is detected, then 11 m_client->handleDisambiguationPopup will be called, so the embedder can 12 decide whether to swallow the touch event and show a popup. 13 14 New test: WebFrameTest.DisambiguationPopupTest 15 16 * WebKit.gyp: 17 * features.gypi: 18 * public/WebInputEvent.h: 19 (WebGestureEvent): 20 (WebKit::WebGestureEvent::WebGestureEvent): 21 * public/WebTouchCandidatesInfo.h: Removed. 22 * public/WebView.h: 23 (WebKit): 24 * public/WebViewClient.h: 25 (WebKit): 26 (WebViewClient): 27 (WebKit::WebViewClient::triggersLinkPreview): 28 * src/WebInputEvent.cpp: 29 (SameSizeAsWebGestureEvent): 30 * src/WebViewImpl.cpp: 31 (WebKit): 32 (WebKit::WebViewImpl::handleGestureEventWithLinkPreview): 33 (WebKit::WebViewImpl::handleGestureEvent): 34 * src/WebViewImpl.h: 35 (WebViewImpl): 36 1 37 2012-08-29 Dominic Mazzoni <dmazzoni@google.com> 2 38 -
trunk/Source/WebKit/chromium/public/WebViewClient.h
r126061 r127095 63 63 class WebGeolocationClient; 64 64 class WebGeolocationService; 65 class WebGestureEvent; 65 66 class WebHelperPlugin; 66 67 class WebHitTestResult; … … 72 73 class WebNotificationPresenter; 73 74 class WebRange; 75 class WebRect; 74 76 class WebSpeechInputController; 75 77 class WebSpeechInputListener; … … 286 288 virtual void didUpdateLayout() { } 287 289 290 // Return true to swallow the input event if the embedder will start a disambiguation popup 291 virtual bool handleDisambiguationPopup(const WebGestureEvent&, const WebVector<WebRect>& targetRects) { return false; } 292 288 293 // Session history ----------------------------------------------------- 289 294 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r127076 r127095 170 170 #if ENABLE(GESTURE_EVENTS) 171 171 #include "PlatformGestureEvent.h" 172 #include "TouchDisambiguation.h" 172 173 #endif 173 174 … … 708 709 return true; 709 710 710 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);711 711 RefPtr<WebCore::PopupContainer> selectPopup; 712 712 selectPopup = m_selectPopup; 713 713 hideSelectPopup(); 714 714 ASSERT(!m_selectPopup); 715 716 if (!event.boundingBox.isEmpty()) { 717 Vector<IntRect> goodTargets; 718 findGoodTouchTargets(event.boundingBox, mainFrameImpl()->frame(), pageScaleFactor(), goodTargets); 719 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1? 720 // Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101 721 if (goodTargets.size() >= 2 && m_client && m_client->handleDisambiguationPopup(event, goodTargets)) 722 return true; 723 } 724 725 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); 715 726 bool gestureHandled = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); 727 716 728 if (m_selectPopup && m_selectPopup == selectPopup) { 717 729 // That tap triggered a select popup which is the same as the one that … … 721 733 hideSelectPopup(); 722 734 } 735 723 736 return gestureHandled; 724 737 } -
trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp
r126204 r127095 1079 1079 } 1080 1080 1081 class DisambiguationPopupTestWebViewClient : public WebViewClient { 1082 public: 1083 virtual bool handleDisambiguationPopup(const WebGestureEvent&, const WebVector<WebRect>& targetRects) OVERRIDE 1084 { 1085 EXPECT_GE(targetRects.size(), 2u); 1086 m_triggered = true; 1087 return true; 1088 } 1089 1090 bool triggered() const { return m_triggered; } 1091 void resetTriggered() { m_triggered = false; } 1092 bool m_triggered; 1093 }; 1094 1095 static WebGestureEvent fatTap(int x, int y) 1096 { 1097 WebGestureEvent event; 1098 event.type = WebInputEvent::GestureTap; 1099 event.x = x; 1100 event.y = y; 1101 event.boundingBox = WebCore::IntRect(x - 25, y - 25, 50, 50); 1102 return event; 1103 } 1104 1105 TEST_F(WebFrameTest, DisambiguationPopupTest) 1106 { 1107 registerMockedHttpURLLoad("disambiguation_popup.html"); 1108 1109 DisambiguationPopupTestWebViewClient client; 1110 1111 // Make sure we initialize to minimum scale, even if the window size 1112 // only becomes available after the load begins. 1113 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "disambiguation_popup.html", true, 0, &client)); 1114 webViewImpl->resize(WebSize(1000, 1000)); 1115 webViewImpl->layout(); 1116 1117 client.resetTriggered(); 1118 webViewImpl->handleInputEvent(fatTap(0, 0)); 1119 EXPECT_FALSE(client.triggered()); 1120 1121 client.resetTriggered(); 1122 webViewImpl->handleInputEvent(fatTap(200, 115)); 1123 EXPECT_FALSE(client.triggered()); 1124 1125 for (int i = 0; i <= 46; i++) { 1126 client.resetTriggered(); 1127 webViewImpl->handleInputEvent(fatTap(120, 230 + i * 5)); 1128 1129 int j = i % 10; 1130 if (j >= 7 && j <= 9) 1131 EXPECT_TRUE(client.triggered()); 1132 else 1133 EXPECT_FALSE(client.triggered()); 1134 } 1135 1136 for (int i = 0; i <= 46; i++) { 1137 client.resetTriggered(); 1138 webViewImpl->handleInputEvent(fatTap(10 + i * 5, 590)); 1139 1140 int j = i % 10; 1141 if (j >= 7 && j <= 9) 1142 EXPECT_TRUE(client.triggered()); 1143 else 1144 EXPECT_FALSE(client.triggered()); 1145 } 1146 1147 } 1148 1081 1149 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.