OLD | NEW |
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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 689 |
690 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even
t); | 690 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even
t); |
691 | 691 |
692 // Handle link highlighting outside the main switch to avoid getting lost in
the | 692 // Handle link highlighting outside the main switch to avoid getting lost in
the |
693 // complicated set of cases handled below. | 693 // complicated set of cases handled below. |
694 switch (event.type) { | 694 switch (event.type) { |
695 case WebInputEvent::GestureTapDown: | 695 case WebInputEvent::GestureTapDown: |
696 // Queue a highlight animation, then hand off to regular handler. | 696 // Queue a highlight animation, then hand off to regular handler. |
697 #if OS(LINUX) | 697 #if OS(LINUX) |
698 if (settingsImpl()->gestureTapHighlightEnabled()) | 698 if (settingsImpl()->gestureTapHighlightEnabled()) |
699 enableTapHighlight(platformEvent); | 699 enableTapHighlightAtPoint(platformEvent); |
700 #endif | 700 #endif |
701 break; | 701 break; |
702 case WebInputEvent::GestureTapCancel: | 702 case WebInputEvent::GestureTapCancel: |
703 case WebInputEvent::GestureTap: | 703 case WebInputEvent::GestureTap: |
704 case WebInputEvent::GestureLongPress: | 704 case WebInputEvent::GestureLongPress: |
705 if (m_linkHighlight) | 705 for (size_t i = 0; i < m_linkHighlights.size(); i++) |
706 m_linkHighlight->startHighlightAnimationIfNeeded(); | 706 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); |
707 break; | 707 break; |
708 default: | 708 default: |
709 break; | 709 break; |
710 } | 710 } |
711 | 711 |
712 switch (event.type) { | 712 switch (event.type) { |
713 case WebInputEvent::GestureTap: { | 713 case WebInputEvent::GestureTap: { |
714 m_client->cancelScheduledContentIntents(); | 714 m_client->cancelScheduledContentIntents(); |
715 if (detectContentOnTouch(platformEvent.position())) { | 715 if (detectContentOnTouch(platformEvent.position())) { |
716 eventSwallowed = true; | 716 eventSwallowed = true; |
(...skipping 10 matching lines...) Expand all Loading... |
727 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) { | 727 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) { |
728 // FIXME: didTapMultipleTargets should just take a rect instead of | 728 // FIXME: didTapMultipleTargets should just take a rect instead of |
729 // an event. | 729 // an event. |
730 WebGestureEvent scaledEvent = event; | 730 WebGestureEvent scaledEvent = event; |
731 scaledEvent.x = event.x / pageScaleFactor(); | 731 scaledEvent.x = event.x / pageScaleFactor(); |
732 scaledEvent.y = event.y / pageScaleFactor(); | 732 scaledEvent.y = event.y / pageScaleFactor(); |
733 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor(
); | 733 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor(
); |
734 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto
r(); | 734 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto
r(); |
735 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); | 735 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); |
736 Vector<IntRect> goodTargets; | 736 Vector<IntRect> goodTargets; |
737 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg
ets); | 737 Vector<Node*> highlightNodes; |
| 738 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg
ets, highlightNodes); |
738 // FIXME: replace touch adjustment code when numberOfGoodTargets ==
1? | 739 // FIXME: replace touch adjustment code when numberOfGoodTargets ==
1? |
739 // Single candidate case is currently handled by: https://bugs.webki
t.org/show_bug.cgi?id=85101 | 740 // Single candidate case is currently handled by: https://bugs.webki
t.org/show_bug.cgi?id=85101 |
740 if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleT
argets(scaledEvent, goodTargets)) { | 741 if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleT
argets(scaledEvent, goodTargets)) { |
| 742 if (settingsImpl()->gestureTapHighlightEnabled()) |
| 743 enableTapHighlights(highlightNodes); |
741 eventSwallowed = true; | 744 eventSwallowed = true; |
742 eventCancelled = true; | 745 eventCancelled = true; |
743 break; | 746 break; |
744 } | 747 } |
745 } | 748 } |
746 | 749 |
747 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture
Event(platformEvent); | 750 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture
Event(platformEvent); |
748 | 751 |
749 if (m_selectPopup && m_selectPopup == selectPopup) { | 752 if (m_selectPopup && m_selectPopup == selectPopup) { |
750 // That tap triggered a select popup which is the same as the one th
at | 753 // That tap triggered a select popup which is the same as the one th
at |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mai
nFrame())) | 1227 while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mai
nFrame())) |
1225 bestTouchNode = bestTouchNode->parentNode(); | 1228 bestTouchNode = bestTouchNode->parentNode(); |
1226 | 1229 |
1227 // We should pick the largest enclosing node with hand cursor set. | 1230 // We should pick the largest enclosing node with hand cursor set. |
1228 while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bes
tTouchNode->parentNode(), false, m_page->mainFrame())) | 1231 while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bes
tTouchNode->parentNode(), false, m_page->mainFrame())) |
1229 bestTouchNode = bestTouchNode->parentNode(); | 1232 bestTouchNode = bestTouchNode->parentNode(); |
1230 | 1233 |
1231 return bestTouchNode; | 1234 return bestTouchNode; |
1232 } | 1235 } |
1233 | 1236 |
1234 void WebViewImpl::enableTapHighlight(const PlatformGestureEvent& tapEvent) | 1237 void WebViewImpl::enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent
) |
1235 { | 1238 { |
1236 // Always clear any existing highlight when this is invoked, even if we don'
t get a new target to highlight. | |
1237 m_linkHighlight.clear(); | |
1238 | |
1239 Node* touchNode = bestTapNode(tapEvent); | 1239 Node* touchNode = bestTapNode(tapEvent); |
1240 | 1240 |
1241 if (!touchNode || !touchNode->renderer() || !touchNode->renderer()->enclosin
gLayer()) | 1241 Vector<Node*> highlightNodes; |
1242 return; | 1242 highlightNodes.append(touchNode); |
1243 | 1243 |
1244 Color highlightColor = touchNode->renderer()->style()->tapHighlightColor(); | 1244 enableTapHighlights(highlightNodes); |
1245 // Safari documentation for -webkit-tap-highlight-color says if the specifie
d color has 0 alpha, | 1245 } |
1246 // then tap highlighting is disabled. | |
1247 // http://developer.apple.com/library/safari/#documentation/appleapplication
s/reference/safaricssref/articles/standardcssproperties.html | |
1248 if (!highlightColor.alpha()) | |
1249 return; | |
1250 | 1246 |
1251 m_linkHighlight = LinkHighlight::create(touchNode, this); | 1247 void WebViewImpl::enableTapHighlights(Vector<Node*>& highlightNodes) |
| 1248 { |
| 1249 // Always clear any existing highlight when this is invoked, even if we |
| 1250 // don't get a new target to highlight. |
| 1251 m_linkHighlights.clear(); |
| 1252 |
| 1253 for (size_t i = 0; i < highlightNodes.size(); i++) { |
| 1254 Node* node = highlightNodes[i]; |
| 1255 |
| 1256 if (!node || !node->renderer() || !node->renderer()->enclosingLayer()) |
| 1257 continue; |
| 1258 |
| 1259 Color highlightColor = node->renderer()->style()->tapHighlightColor(); |
| 1260 // Safari documentation for -webkit-tap-highlight-color says if the spec
ified color has 0 alpha, |
| 1261 // then tap highlighting is disabled. |
| 1262 // http://developer.apple.com/library/safari/#documentation/appleapplica
tions/reference/safaricssref/articles/standardcssproperties.html |
| 1263 if (!highlightColor.alpha()) |
| 1264 continue; |
| 1265 |
| 1266 m_linkHighlights.append(LinkHighlight::create(node, this)); |
| 1267 } |
1252 } | 1268 } |
1253 | 1269 |
1254 void WebViewImpl::animateDoubleTapZoom(const IntPoint& point) | 1270 void WebViewImpl::animateDoubleTapZoom(const IntPoint& point) |
1255 { | 1271 { |
1256 if (!mainFrameImpl()) | 1272 if (!mainFrameImpl()) |
1257 return; | 1273 return; |
1258 | 1274 |
1259 WebRect rect(point.x(), point.y(), touchPointPadding, touchPointPadding); | 1275 WebRect rect(point.x(), point.y(), touchPointPadding, touchPointPadding); |
1260 WebRect blockBounds = computeBlockBounds(rect, false); | 1276 WebRect blockBounds = computeBlockBounds(rect, false); |
1261 | 1277 |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 } | 1781 } |
1766 } | 1782 } |
1767 | 1783 |
1768 void WebViewImpl::layout() | 1784 void WebViewImpl::layout() |
1769 { | 1785 { |
1770 TRACE_EVENT0("webkit", "WebViewImpl::layout"); | 1786 TRACE_EVENT0("webkit", "WebViewImpl::layout"); |
1771 PageWidgetDelegate::layout(m_page.get()); | 1787 PageWidgetDelegate::layout(m_page.get()); |
1772 if (m_layerTreeView) | 1788 if (m_layerTreeView) |
1773 m_layerTreeView->setBackgroundColor(backgroundColor()); | 1789 m_layerTreeView->setBackgroundColor(backgroundColor()); |
1774 | 1790 |
1775 if (m_linkHighlight) | 1791 for (size_t i = 0; i < m_linkHighlights.size(); i++) |
1776 m_linkHighlight->updateGeometry(); | 1792 m_linkHighlights[i]->updateGeometry(); |
1777 } | 1793 } |
1778 | 1794 |
1779 void WebViewImpl::enterForceCompositingMode(bool enter) | 1795 void WebViewImpl::enterForceCompositingMode(bool enter) |
1780 { | 1796 { |
1781 if (page()->settings().forceCompositingMode() == enter) | 1797 if (page()->settings().forceCompositingMode() == enter) |
1782 return; | 1798 return; |
1783 | 1799 |
1784 TRACE_EVENT1("webkit", "WebViewImpl::enterForceCompositingMode", "enter", en
ter); | 1800 TRACE_EVENT1("webkit", "WebViewImpl::enterForceCompositingMode", "enter", en
ter); |
1785 settingsImpl()->setForceCompositingMode(enter); | 1801 settingsImpl()->setForceCompositingMode(enter); |
1786 if (enter) { | 1802 if (enter) { |
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3617 #ifndef NDEBUG | 3633 #ifndef NDEBUG |
3618 ASSERT(!m_observedNewNavigation | 3634 ASSERT(!m_observedNewNavigation |
3619 || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoa
der); | 3635 || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoa
der); |
3620 m_newNavigationLoader = 0; | 3636 m_newNavigationLoader = 0; |
3621 #endif | 3637 #endif |
3622 m_observedNewNavigation = false; | 3638 m_observedNewNavigation = false; |
3623 if (*isNewNavigation && !isNavigationWithinPage) | 3639 if (*isNewNavigation && !isNavigationWithinPage) |
3624 m_pageScaleConstraintsSet.setNeedsReset(true); | 3640 m_pageScaleConstraintsSet.setNeedsReset(true); |
3625 | 3641 |
3626 // Make sure link highlight from previous page is cleared. | 3642 // Make sure link highlight from previous page is cleared. |
3627 m_linkHighlight.clear(); | 3643 m_linkHighlights.clear(); |
3628 m_gestureAnimation.clear(); | 3644 m_gestureAnimation.clear(); |
3629 if (m_layerTreeView) | 3645 if (m_layerTreeView) |
3630 m_layerTreeView->didStopFlinging(); | 3646 m_layerTreeView->didStopFlinging(); |
3631 resetSavedScrollAndScaleState(); | 3647 resetSavedScrollAndScaleState(); |
3632 } | 3648 } |
3633 | 3649 |
3634 void WebViewImpl::layoutUpdated(WebFrameImpl* webframe) | 3650 void WebViewImpl::layoutUpdated(WebFrameImpl* webframe) |
3635 { | 3651 { |
3636 if (!m_client || webframe != mainFrameImpl()) | 3652 if (!m_client || webframe != mainFrameImpl()) |
3637 return; | 3653 return; |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4113 // the initial viewport width. | 4129 // the initial viewport width. |
4114 // 2. The author has disabled viewport zoom. | 4130 // 2. The author has disabled viewport zoom. |
4115 | 4131 |
4116 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4132 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4117 | 4133 |
4118 return fixedLayoutSize().width == m_size.width | 4134 return fixedLayoutSize().width == m_size.width |
4119 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4135 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4120 } | 4136 } |
4121 | 4137 |
4122 } // namespace WebKit | 4138 } // namespace WebKit |
OLD | NEW |