Changeset 142913 in webkit
- Timestamp:
- Feb 14, 2013, 1:56:03 PM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r142911 r142913 1 2013-02-14 Alexandre Elias <aelias@chromium.org> 2 3 [chromium] Fix scaling in WebViewImpl::handleGestureEvent, second try 4 https://bugs.webkit.org/show_bug.cgi?id=109671 5 6 Reviewed by James Robinson. 7 8 My patch 142571 broke a bunch of things in handleGestureEvent that 9 assumed the event came in scaled, most notably tap highlight and 10 double-tap zoom. Switch those to PlatformGestureEvent. 11 12 142808 was an earlier version of this patch that was reverted 13 due to fling events asserting they can't be converted to 14 PlatformGestureEvent. This version moves fling earlier in the 15 function to avoid that. 16 17 * src/WebViewImpl.cpp: 18 (WebKit::WebViewImpl::handleGestureEvent): 19 (WebKit::WebViewImpl::bestTapNode): 20 (WebKit::WebViewImpl::enableTapHighlight): 21 * src/WebViewImpl.h: 22 (WebViewImpl): 23 * tests/LinkHighlightTest.cpp: 24 (WebCore::TEST): 25 1 26 2013-02-14 Dirk Pranke <dpranke@chromium.org> 2 27 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r142879 r142913 697 697 bool eventCancelled = false; // for disambiguation 698 698 699 // Special handling for slow-path fling gestures, which have no PlatformGestureEvent equivalent. 700 switch (event.type) { 701 case WebInputEvent::GestureFlingStart: { 702 if (mainFrameImpl()->frame()->eventHandler()->isScrollbarHandlingGestures()) { 703 m_client->didHandleGestureEvent(event, eventCancelled); 704 return eventSwallowed; 705 } 706 m_client->cancelScheduledContentIntents(); 707 m_positionOnFlingStart = WebPoint(event.x / pageScaleFactor(), event.y / pageScaleFactor()); 708 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); 709 m_flingModifier = event.modifiers; 710 m_flingSourceDevice = event.sourceDevice; 711 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY), WebSize())); 712 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(flingCurve.release(), this); 713 scheduleAnimation(); 714 eventSwallowed = true; 715 716 m_client->didHandleGestureEvent(event, eventCancelled); 717 return eventSwallowed; 718 } 719 case WebInputEvent::GestureFlingCancel: 720 if (m_gestureAnimation) { 721 m_gestureAnimation.clear(); 722 if (m_layerTreeView) 723 m_layerTreeView->didStopFlinging(); 724 eventSwallowed = true; 725 } 726 727 m_client->didHandleGestureEvent(event, eventCancelled); 728 return eventSwallowed; 729 default: 730 break; 731 } 732 733 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); 734 699 735 // Handle link highlighting outside the main switch to avoid getting lost in the 700 736 // complicated set of cases handled below. … … 704 740 #if OS(LINUX) 705 741 if (settingsImpl()->gestureTapHighlightEnabled()) 706 enableT ouchHighlight(event);742 enableTapHighlight(platformEvent); 707 743 #endif 708 744 break; … … 718 754 719 755 switch (event.type) { 720 case WebInputEvent::GestureFlingStart: {721 if (mainFrameImpl()->frame()->eventHandler()->isScrollbarHandlingGestures())722 break;723 m_client->cancelScheduledContentIntents();724 m_positionOnFlingStart = WebPoint(event.x, event.y);725 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);726 m_flingModifier = event.modifiers;727 m_flingSourceDevice = event.sourceDevice;728 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY), WebSize()));729 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(flingCurve.release(), this);730 scheduleAnimation();731 eventSwallowed = true;732 break;733 }734 case WebInputEvent::GestureFlingCancel:735 if (m_gestureAnimation) {736 m_gestureAnimation.clear();737 if (m_layerTreeView)738 m_layerTreeView->didStopFlinging();739 eventSwallowed = true;740 }741 break;742 756 case WebInputEvent::GestureTap: { 743 757 m_client->cancelScheduledContentIntents(); 744 if (detectContentOnTouch( WebPoint(event.x, event.y))) {758 if (detectContentOnTouch(platformEvent.position())) { 745 759 eventSwallowed = true; 746 760 break; … … 757 771 // FIXME: didTapMultipleTargets should just take a rect instead of 758 772 // an event. 759 WebGestureEvent scaledEvent ;773 WebGestureEvent scaledEvent = event; 760 774 scaledEvent.x = event.x / pageScaleFactor(); 761 775 scaledEvent.y = event.y / pageScaleFactor(); … … 774 788 } 775 789 776 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);777 790 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); 778 791 … … 796 809 m_page->contextMenuController()->clearContextMenu(); 797 810 m_contextMenuAllowed = true; 798 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);799 811 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); 800 812 m_contextMenuAllowed = false; … … 804 816 case WebInputEvent::GestureTapDown: { 805 817 m_client->cancelScheduledContentIntents(); 806 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);807 818 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); 808 819 break; … … 811 822 if (m_webSettings->doubleTapToZoomEnabled() && m_minimumPageScaleFactor != m_maximumPageScaleFactor) { 812 823 m_client->cancelScheduledContentIntents(); 813 animateZoomAroundPoint( WebPoint(event.x, event.y), DoubleTap);824 animateZoomAroundPoint(platformEvent.position(), DoubleTap); 814 825 eventSwallowed = true; 815 826 break; … … 824 835 case WebInputEvent::GesturePinchEnd: 825 836 case WebInputEvent::GesturePinchUpdate: { 826 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);827 837 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); 828 838 break; … … 1271 1281 } 1272 1282 1273 Node* WebViewImpl::bestT ouchLinkNode(const WebGestureEvent& touchEvent)1283 Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent) 1274 1284 { 1275 1285 if (!m_page || !m_page->mainFrame()) … … 1278 1288 Node* bestTouchNode = 0; 1279 1289 1280 IntSize touchEventSearchRegionSize(touchEvent.data.tapDown.width / 2, touchEvent.data.tapDown.height / 2); 1281 IntPoint touchEventLocation(touchEvent.x, touchEvent.y); 1290 IntPoint touchEventLocation(tapEvent.position()); 1282 1291 #if ENABLE(TOUCH_ADJUSTMENT) 1283 m_page->mainFrame()->eventHandler()->adjustGesturePosition( PlatformGestureEventBuilder(mainFrameImpl()->frameView(), touchEvent), touchEventLocation);1292 m_page->mainFrame()->eventHandler()->adjustGesturePosition(tapEvent, touchEventLocation); 1284 1293 #endif 1285 1294 … … 1291 1300 // Make sure our highlight candidate uses a hand cursor as a heuristic to 1292 1301 // choose appropriate targets. 1293 bool shiftKey = touchEvent.modifiers & WebGestureEvent::ShiftKey; 1294 while (bestTouchNode && !invokesHandCursor(bestTouchNode, shiftKey, m_page->mainFrame())) 1302 while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mainFrame())) 1295 1303 bestTouchNode = bestTouchNode->parentNode(); 1296 1304 1297 1305 // We should pick the largest enclosing node with hand cursor set. 1298 while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), shiftKey, m_page->mainFrame()))1306 while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), false, m_page->mainFrame())) 1299 1307 bestTouchNode = bestTouchNode->parentNode(); 1300 1308 … … 1302 1310 } 1303 1311 1304 void WebViewImpl::enableT ouchHighlight(const WebGestureEvent& touchEvent)1312 void WebViewImpl::enableTapHighlight(const PlatformGestureEvent& tapEvent) 1305 1313 { 1306 1314 // Always clear any existing highlight when this is invoked, even if we don't get a new target to highlight. 1307 1315 m_linkHighlight.clear(); 1308 1316 1309 Node* touchNode = bestT ouchLinkNode(touchEvent);1317 Node* touchNode = bestTapNode(tapEvent); 1310 1318 1311 1319 if (!touchNode || !touchNode->renderer() || !touchNode->renderer()->enclosingLayer()) -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r142872 r142913 577 577 #if ENABLE(GESTURE_EVENTS) 578 578 void computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType, float& scale, WebPoint& scroll, bool& isAnchor); 579 WebCore::Node* bestT ouchLinkNode(const WebGestureEvent& touchEvent);580 void enableT ouchHighlight(const WebGestureEvent& touchEvent);579 WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent); 580 void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent); 581 581 void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float& scale, WebCore::IntPoint& scroll, bool& needAnimation); 582 582 #endif -
trunk/Source/WebKit/chromium/tests/LinkHighlightTest.cpp
r142872 r142913 28 28 29 29 #include "FrameTestHelpers.h" 30 #include "FrameView.h" 30 31 #include "IntRect.h" 31 32 #include "Node.h" … … 33 34 #include "WebCompositorInitializer.h" 34 35 #include "WebFrame.h" 36 #include "WebFrameImpl.h" 35 37 #include "WebInputEvent.h" 38 #include "WebInputEventConversion.h" 36 39 #include "WebViewImpl.h" 37 40 #include <gtest/gtest.h> … … 67 70 touchEvent.x = 20; 68 71 touchEvent.y = 20; 69 Node* touchNode = webViewImpl->bestTouchLinkNode(touchEvent); 70 ASSERT_TRUE(touchNode); 72 73 { 74 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); 75 Node* touchNode = webViewImpl->bestTapNode(platformEvent); 76 ASSERT_TRUE(touchNode); 77 } 71 78 72 79 touchEvent.y = 40; 73 EXPECT_FALSE(webViewImpl->bestTouchLinkNode(touchEvent)); 80 { 81 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); 82 EXPECT_FALSE(webViewImpl->bestTapNode(platformEvent)); 83 } 74 84 75 85 touchEvent.y = 20; 76 86 // Shouldn't crash. 77 87 78 webViewImpl->enableTouchHighlight(touchEvent); 88 { 89 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); 90 webViewImpl->enableTapHighlight(platformEvent); 91 } 92 79 93 EXPECT_TRUE(webViewImpl->linkHighlight()); 80 94 EXPECT_TRUE(webViewImpl->linkHighlight()->contentLayer()); … … 84 98 85 99 touchEvent.y = 100; 86 webViewImpl->enableTouchHighlight(touchEvent); 100 { 101 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); 102 webViewImpl->enableTapHighlight(platformEvent); 103 } 104 87 105 ASSERT_TRUE(webViewImpl->linkHighlight()); 88 106 89 107 // Don't highlight if no "hand cursor" 90 108 touchEvent.y = 220; // An A-link with cross-hair cursor. 91 webViewImpl->enableTouchHighlight(touchEvent); 109 { 110 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); 111 webViewImpl->enableTapHighlight(platformEvent); 112 } 92 113 ASSERT_FALSE(webViewImpl->linkHighlight()); 93 114 94 115 touchEvent.y = 260; // A text input box. 95 webViewImpl->enableTouchHighlight(touchEvent); 116 { 117 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); 118 webViewImpl->enableTapHighlight(platformEvent); 119 } 96 120 ASSERT_FALSE(webViewImpl->linkHighlight()); 97 121
Note:
See TracChangeset
for help on using the changeset viewer.