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