Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(847)

Side by Side Diff: Source/WebKit/chromium/src/WebViewImpl.cpp

Issue 15663005: Expand tap highlight to allow multiple highlights for touch disambiguation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 686
687 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t); 687 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t);
688 688
689 // Handle link highlighting outside the main switch to avoid getting lost in the 689 // Handle link highlighting outside the main switch to avoid getting lost in the
690 // complicated set of cases handled below. 690 // complicated set of cases handled below.
691 switch (event.type) { 691 switch (event.type) {
692 case WebInputEvent::GestureTapDown: 692 case WebInputEvent::GestureTapDown:
693 // Queue a highlight animation, then hand off to regular handler. 693 // Queue a highlight animation, then hand off to regular handler.
694 #if OS(LINUX) 694 #if OS(LINUX)
695 if (settingsImpl()->gestureTapHighlightEnabled()) 695 if (settingsImpl()->gestureTapHighlightEnabled())
696 enableTapHighlight(platformEvent); 696 enableTapHighlightAtPoint(platformEvent);
697 #endif 697 #endif
698 break; 698 break;
699 case WebInputEvent::GestureTapCancel: 699 case WebInputEvent::GestureTapCancel:
700 case WebInputEvent::GestureTap: 700 case WebInputEvent::GestureTap:
701 case WebInputEvent::GestureLongPress: 701 case WebInputEvent::GestureLongPress:
702 if (m_linkHighlight) 702 for (size_t i = 0; i < m_linkHighlights.size(); i++)
703 m_linkHighlight->startHighlightAnimationIfNeeded(); 703 m_linkHighlights[i]->startHighlightAnimationIfNeeded();
704 break; 704 break;
705 default: 705 default:
706 break; 706 break;
707 } 707 }
708 708
709 switch (event.type) { 709 switch (event.type) {
710 case WebInputEvent::GestureTap: { 710 case WebInputEvent::GestureTap: {
711 m_client->cancelScheduledContentIntents(); 711 m_client->cancelScheduledContentIntents();
712 if (detectContentOnTouch(platformEvent.position())) { 712 if (detectContentOnTouch(platformEvent.position())) {
713 eventSwallowed = true; 713 eventSwallowed = true;
(...skipping 10 matching lines...) Expand all
724 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) { 724 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) {
725 // FIXME: didTapMultipleTargets should just take a rect instead of 725 // FIXME: didTapMultipleTargets should just take a rect instead of
726 // an event. 726 // an event.
727 WebGestureEvent scaledEvent = event; 727 WebGestureEvent scaledEvent = event;
728 scaledEvent.x = event.x / pageScaleFactor(); 728 scaledEvent.x = event.x / pageScaleFactor();
729 scaledEvent.y = event.y / pageScaleFactor(); 729 scaledEvent.y = event.y / pageScaleFactor();
730 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor( ); 730 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor( );
731 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto r(); 731 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto r();
732 IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2, scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, sca ledEvent.data.tap.height); 732 IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2, scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, sca ledEvent.data.tap.height);
733 Vector<IntRect> goodTargets; 733 Vector<IntRect> goodTargets;
734 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg ets); 734 Vector<Node*> highlightNodes;
735 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg ets, highlightNodes);
735 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1? 736 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
736 // Single candidate case is currently handled by: https://bugs.webki t.org/show_bug.cgi?id=85101 737 // Single candidate case is currently handled by: https://bugs.webki t.org/show_bug.cgi?id=85101
737 if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleT argets(scaledEvent, goodTargets)) { 738 if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleT argets(scaledEvent, goodTargets)) {
739 if (settingsImpl()->gestureTapHighlightEnabled())
740 enableTapHighlights(highlightNodes);
738 eventSwallowed = true; 741 eventSwallowed = true;
739 eventCancelled = true; 742 eventCancelled = true;
740 break; 743 break;
741 } 744 }
742 } 745 }
743 746
744 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture Event(platformEvent); 747 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture Event(platformEvent);
745 748
746 if (m_selectPopup && m_selectPopup == selectPopup) { 749 if (m_selectPopup && m_selectPopup == selectPopup) {
747 // That tap triggered a select popup which is the same as the one th at 750 // That tap triggered a select popup which is the same as the one th at
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mai nFrame())) 1245 while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mai nFrame()))
1243 bestTouchNode = bestTouchNode->parentNode(); 1246 bestTouchNode = bestTouchNode->parentNode();
1244 1247
1245 // We should pick the largest enclosing node with hand cursor set. 1248 // We should pick the largest enclosing node with hand cursor set.
1246 while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bes tTouchNode->parentNode(), false, m_page->mainFrame())) 1249 while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bes tTouchNode->parentNode(), false, m_page->mainFrame()))
1247 bestTouchNode = bestTouchNode->parentNode(); 1250 bestTouchNode = bestTouchNode->parentNode();
1248 1251
1249 return bestTouchNode; 1252 return bestTouchNode;
1250 } 1253 }
1251 1254
1252 void WebViewImpl::enableTapHighlight(const PlatformGestureEvent& tapEvent) 1255 void WebViewImpl::enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent )
1253 { 1256 {
1254 // Always clear any existing highlight when this is invoked, even if we don' t get a new target to highlight.
1255 m_linkHighlight.clear();
1256
1257 Node* touchNode = bestTapNode(tapEvent); 1257 Node* touchNode = bestTapNode(tapEvent);
1258 1258
1259 if (!touchNode || !touchNode->renderer() || !touchNode->renderer()->enclosin gLayer()) 1259 Vector<Node*> highlightNodes;
1260 return; 1260 highlightNodes.append(touchNode);
1261 1261
1262 Color highlightColor = touchNode->renderer()->style()->tapHighlightColor(); 1262 enableTapHighlights(highlightNodes);
1263 // Safari documentation for -webkit-tap-highlight-color says if the specifie d color has 0 alpha, 1263 }
1264 // then tap highlighting is disabled.
1265 // http://developer.apple.com/library/safari/#documentation/appleapplication s/reference/safaricssref/articles/standardcssproperties.html
1266 if (!highlightColor.alpha())
1267 return;
1268 1264
1269 m_linkHighlight = LinkHighlight::create(touchNode, this); 1265 void WebViewImpl::enableTapHighlights(Vector<Node*>& highlightNodes)
1266 {
1267 // Always clear any existing highlight when this is invoked, even if we
1268 // don't get a new target to highlight.
1269 m_linkHighlights.clear();
1270
1271 for (size_t i = 0; i < highlightNodes.size(); i++) {
1272 Node* node = highlightNodes[i];
1273
1274 if (!node || !node->renderer() || !node->renderer()->enclosingLayer())
1275 return;
1276
1277 Color highlightColor = node->renderer()->style()->tapHighlightColor();
1278 // Safari documentation for -webkit-tap-highlight-color says if the
1279 // specified color has 0 alpha, then tap highlighting is disabled.
1280 // http://developer.apple.com/library/safari/#documentation/appleapplica tions/reference/safaricssref/articles/standardcssproperties.html
1281 if (!highlightColor.alpha())
1282 continue;
1283
1284 m_linkHighlights.append(LinkHighlight::create(node, this));
1285 }
1270 } 1286 }
1271 1287
1272 void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoo mType) 1288 void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoo mType)
1273 { 1289 {
1274 if (!mainFrameImpl()) 1290 if (!mainFrameImpl())
1275 return; 1291 return;
1276 1292
1277 float scale; 1293 float scale;
1278 WebPoint scroll; 1294 WebPoint scroll;
1279 bool isAnchor; 1295 bool isAnchor;
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 } 1758 }
1743 } 1759 }
1744 1760
1745 void WebViewImpl::layout() 1761 void WebViewImpl::layout()
1746 { 1762 {
1747 TRACE_EVENT0("webkit", "WebViewImpl::layout"); 1763 TRACE_EVENT0("webkit", "WebViewImpl::layout");
1748 PageWidgetDelegate::layout(m_page.get()); 1764 PageWidgetDelegate::layout(m_page.get());
1749 if (m_layerTreeView) 1765 if (m_layerTreeView)
1750 m_layerTreeView->setBackgroundColor(backgroundColor()); 1766 m_layerTreeView->setBackgroundColor(backgroundColor());
1751 1767
1752 if (m_linkHighlight) 1768 for (size_t i = 0; i < m_linkHighlights.size(); i++)
1753 m_linkHighlight->updateGeometry(); 1769 m_linkHighlights[i]->updateGeometry();
1754 } 1770 }
1755 1771
1756 void WebViewImpl::enterForceCompositingMode(bool enter) 1772 void WebViewImpl::enterForceCompositingMode(bool enter)
1757 { 1773 {
1758 if (page()->settings()->forceCompositingMode() == enter) 1774 if (page()->settings()->forceCompositingMode() == enter)
1759 return; 1775 return;
1760 1776
1761 TRACE_EVENT1("webkit", "WebViewImpl::enterForceCompositingMode", "enter", en ter); 1777 TRACE_EVENT1("webkit", "WebViewImpl::enterForceCompositingMode", "enter", en ter);
1762 settingsImpl()->setForceCompositingMode(enter); 1778 settingsImpl()->setForceCompositingMode(enter);
1763 if (enter) { 1779 if (enter) {
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after
3591 #ifndef NDEBUG 3607 #ifndef NDEBUG
3592 ASSERT(!m_observedNewNavigation 3608 ASSERT(!m_observedNewNavigation
3593 || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoa der); 3609 || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoa der);
3594 m_newNavigationLoader = 0; 3610 m_newNavigationLoader = 0;
3595 #endif 3611 #endif
3596 m_observedNewNavigation = false; 3612 m_observedNewNavigation = false;
3597 if (*isNewNavigation && !isNavigationWithinPage) 3613 if (*isNewNavigation && !isNavigationWithinPage)
3598 m_pageScaleConstraintsSet.setNeedsReset(true); 3614 m_pageScaleConstraintsSet.setNeedsReset(true);
3599 3615
3600 // Make sure link highlight from previous page is cleared. 3616 // Make sure link highlight from previous page is cleared.
3601 m_linkHighlight.clear(); 3617 m_linkHighlights.clear();
3602 m_gestureAnimation.clear(); 3618 m_gestureAnimation.clear();
3603 if (m_layerTreeView) 3619 if (m_layerTreeView)
3604 m_layerTreeView->didStopFlinging(); 3620 m_layerTreeView->didStopFlinging();
3605 resetSavedScrollAndScaleState(); 3621 resetSavedScrollAndScaleState();
3606 } 3622 }
3607 3623
3608 void WebViewImpl::layoutUpdated(WebFrameImpl* webframe) 3624 void WebViewImpl::layoutUpdated(WebFrameImpl* webframe)
3609 { 3625 {
3610 if (!m_client || webframe != mainFrameImpl()) 3626 if (!m_client || webframe != mainFrameImpl())
3611 return; 3627 return;
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
4087 } 4103 }
4088 4104
4089 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4105 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4090 { 4106 {
4091 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4107 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4092 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4108 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4093 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4109 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4094 } 4110 }
4095 4111
4096 } // namespace WebKit 4112 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698