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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 if (detectContentOnTouch(targetedEvent)) { | 792 if (detectContentOnTouch(targetedEvent)) { |
793 eventSwallowed = true; | 793 eventSwallowed = true; |
794 break; | 794 break; |
795 } | 795 } |
796 | 796 |
797 // Don't trigger a disambiguation popup on sites designed for mobile dev
ices. | 797 // Don't trigger a disambiguation popup on sites designed for mobile dev
ices. |
798 // Instead, assume that the page has been designed with big enough butto
ns and links. | 798 // Instead, assume that the page has been designed with big enough butto
ns and links. |
799 // Don't trigger a disambiguation popup when screencasting, since it's i
mplemented outside of | 799 // Don't trigger a disambiguation popup when screencasting, since it's i
mplemented outside of |
800 // compositor pipeline and is not being screencasted itself. This leads
to bad user experience. | 800 // compositor pipeline and is not being screencasted itself. This leads
to bad user experience. |
801 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); | 801 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); |
| 802 VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
802 bool screencastEnabled = devTools && devTools->screencastEnabled(); | 803 bool screencastEnabled = devTools && devTools->screencastEnabled(); |
803 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !s
creencastEnabled) { | 804 if (event.data.tap.width > 0 && !visualViewport.shouldDisableDesktopWork
arounds() && !screencastEnabled) { |
804 IntRect boundingBox(page()->frameHost().visualViewport().viewportToR
ootFrame(IntRect( | 805 IntRect boundingBox(visualViewport.viewportToRootFrame(IntRect( |
805 event.x - event.data.tap.width / 2, | 806 event.x - event.data.tap.width / 2, |
806 event.y - event.data.tap.height / 2, | 807 event.y - event.data.tap.height / 2, |
807 event.data.tap.width, | 808 event.data.tap.width, |
808 event.data.tap.height))); | 809 event.data.tap.height))); |
809 | 810 |
810 // FIXME: We shouldn't pass details of the VisualViewport offset to
render_view_impl. | 811 // TODO(bokan): We shouldn't pass details of the VisualViewport offs
et to render_view_impl. |
811 WebSize visualViewportOffset = flooredIntSize(page()->frameHost().vi
sualViewport().location()); | 812 // crbug.com/459591 |
| 813 WebSize visualViewportOffset = flooredIntSize(visualViewport.locatio
n()); |
812 | 814 |
813 if (m_webSettings->multiTargetTapNotificationEnabled()) { | 815 if (m_webSettings->multiTargetTapNotificationEnabled()) { |
814 Vector<IntRect> goodTargets; | 816 Vector<IntRect> goodTargets; |
815 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; | 817 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; |
816 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), good
Targets, highlightNodes); | 818 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), good
Targets, highlightNodes); |
817 // FIXME: replace touch adjustment code when numberOfGoodTargets
== 1? | 819 // FIXME: replace touch adjustment code when numberOfGoodTargets
== 1? |
818 // Single candidate case is currently handled by: https://bugs.w
ebkit.org/show_bug.cgi?id=85101 | 820 // Single candidate case is currently handled by: https://bugs.w
ebkit.org/show_bug.cgi?id=85101 |
819 if (goodTargets.size() >= 2 && m_client | 821 if (goodTargets.size() >= 2 && m_client |
820 && m_client->didTapMultipleTargets(visualViewportOffset, bou
ndingBox, goodTargets)) { | 822 && m_client->didTapMultipleTargets(visualViewportOffset, bou
ndingBox, goodTargets)) { |
821 | 823 |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 // on the page. There is a single input event, GestureTap, which can both | 2067 // on the page. There is a single input event, GestureTap, which can both |
2066 // be the first event after page load, and cause a form submission. In that | 2068 // be the first event after page load, and cause a form submission. In that |
2067 // case, the form submission happens before the autofill client is told | 2069 // case, the form submission happens before the autofill client is told |
2068 // to unblock the password values, and so the password values are not | 2070 // to unblock the password values, and so the password values are not |
2069 // submitted. To avoid that, GestureTap is handled explicitly: | 2071 // submitted. To avoid that, GestureTap is handled explicitly: |
2070 if (inputEvent.type == WebInputEvent::GestureTap && autofillClient) { | 2072 if (inputEvent.type == WebInputEvent::GestureTap && autofillClient) { |
2071 m_userGestureObserved = true; | 2073 m_userGestureObserved = true; |
2072 autofillClient->firstUserGestureObserved(); | 2074 autofillClient->firstUserGestureObserved(); |
2073 } | 2075 } |
2074 | 2076 |
| 2077 page()->frameHost().visualViewport().startTrackingPinchStats(); |
| 2078 |
2075 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa
me(inputEvent.type).ascii()); | 2079 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa
me(inputEvent.type).ascii()); |
2076 // If we've started a drag and drop operation, ignore input events until | 2080 // If we've started a drag and drop operation, ignore input events until |
2077 // we're done. | 2081 // we're done. |
2078 if (m_doingDragAndDrop) | 2082 if (m_doingDragAndDrop) |
2079 return true; | 2083 return true; |
2080 | 2084 |
2081 if (m_devToolsEmulator->handleInputEvent(inputEvent)) | 2085 if (m_devToolsEmulator->handleInputEvent(inputEvent)) |
2082 return true; | 2086 return true; |
2083 | 2087 |
2084 if (InspectorOverlay* overlay = inspectorOverlay()) { | 2088 if (InspectorOverlay* overlay = inspectorOverlay()) { |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 { | 2864 { |
2861 LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame
() | 2865 LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame
() |
2862 ? page()->deprecatedLocalMainFrame() : 0; | 2866 ? page()->deprecatedLocalMainFrame() : 0; |
2863 Element* element = focusedElement(); | 2867 Element* element = focusedElement(); |
2864 if (!frame || !frame->view() || !element) | 2868 if (!frame || !frame->view() || !element) |
2865 return false; | 2869 return false; |
2866 | 2870 |
2867 element->document().updateLayoutIgnorePendingStylesheets(); | 2871 element->document().updateLayoutIgnorePendingStylesheets(); |
2868 | 2872 |
2869 bool zoomInToLegibleScale = m_webSettings->autoZoomFocusedNodeToLegibleScale
() | 2873 bool zoomInToLegibleScale = m_webSettings->autoZoomFocusedNodeToLegibleScale
() |
2870 && !shouldDisableDesktopWorkarounds(); | 2874 && !page()->frameHost().visualViewport().shouldDisableDesktopWorkarounds
(); |
2871 | 2875 |
2872 if (zoomInToLegibleScale) { | 2876 if (zoomInToLegibleScale) { |
2873 // When deciding whether to zoom in on a focused text box, we should dec
ide not to | 2877 // When deciding whether to zoom in on a focused text box, we should dec
ide not to |
2874 // zoom in if the user won't be able to zoom out. e.g if the textbox is
within a | 2878 // zoom in if the user won't be able to zoom out. e.g if the textbox is
within a |
2875 // touch-action: none container the user can't zoom back out. | 2879 // touch-action: none container the user can't zoom back out. |
2876 TouchAction action = TouchActionUtil::computeEffectiveTouchAction(*eleme
nt); | 2880 TouchAction action = TouchActionUtil::computeEffectiveTouchAction(*eleme
nt); |
2877 if (action != TouchActionAuto && !(action & TouchActionPinchZoom)) | 2881 if (action != TouchActionAuto && !(action & TouchActionPinchZoom)) |
2878 zoomInToLegibleScale = false; | 2882 zoomInToLegibleScale = false; |
2879 } | 2883 } |
2880 | 2884 |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 FrameView* frameView = mainFrameImpl()->frameView(); | 4261 FrameView* frameView = mainFrameImpl()->frameView(); |
4258 if (!frameView) | 4262 if (!frameView) |
4259 return; | 4263 return; |
4260 | 4264 |
4261 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat
ioDelta); | 4265 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat
ioDelta); |
4262 | 4266 |
4263 FloatPoint visualViewportOffset = page()->frameHost().visualViewport().visib
leRect().location(); | 4267 FloatPoint visualViewportOffset = page()->frameHost().visualViewport().visib
leRect().location(); |
4264 visualViewportOffset.move(visualViewportDelta.width, visualViewportDelta.hei
ght); | 4268 visualViewportOffset.move(visualViewportDelta.width, visualViewportDelta.hei
ght); |
4265 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, visualView
portOffset); | 4269 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, visualView
portOffset); |
4266 | 4270 |
4267 if (pageScaleDelta != 1) | 4271 if (pageScaleDelta != 1) { |
4268 m_doubleTapZoomPending = false; | 4272 m_doubleTapZoomPending = false; |
| 4273 page()->frameHost().visualViewport().userDidChangeScale(); |
| 4274 } |
4269 | 4275 |
4270 m_elasticOverscroll += elasticOverscrollDelta; | 4276 m_elasticOverscroll += elasticOverscrollDelta; |
4271 frameView->didUpdateElasticOverscroll(); | 4277 frameView->didUpdateElasticOverscroll(); |
4272 | 4278 |
4273 ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea(); | 4279 ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea(); |
4274 | 4280 |
4275 DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble() | 4281 DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble() |
4276 + DoubleSize(layoutViewportDelta.width, layoutViewportDelta.height); | 4282 + DoubleSize(layoutViewportDelta.width, layoutViewportDelta.height); |
4277 | 4283 |
4278 if (layoutViewport->scrollPositionDouble() != layoutViewportPosition) { | 4284 if (layoutViewport->scrollPositionDouble() != layoutViewportPosition) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4425 } | 4431 } |
4426 | 4432 |
4427 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); | 4433 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); |
4428 | 4434 |
4429 if (page()) | 4435 if (page()) |
4430 page()->pointerLockController().dispatchLockedMouseEvent( | 4436 page()->pointerLockController().dispatchLockedMouseEvent( |
4431 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), | 4437 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), |
4432 eventType); | 4438 eventType); |
4433 } | 4439 } |
4434 | 4440 |
4435 bool WebViewImpl::shouldDisableDesktopWorkarounds() | |
4436 { | |
4437 if (!settings()->viewportEnabled()) | |
4438 return false; | |
4439 | |
4440 // A document is considered adapted to small screen UAs if one of these hold
s: | |
4441 // 1. The author specified viewport has a constrained width that is equal to | |
4442 // the initial viewport width. | |
4443 // 2. The author has disabled viewport zoom. | |
4444 | |
4445 const PageScaleConstraints& constraints = pageScaleConstraintsSet().pageDefi
nedConstraints(); | |
4446 | |
4447 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | |
4448 return false; | |
4449 | |
4450 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | |
4451 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | |
4452 } | |
4453 | |
4454 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4441 void WebViewImpl::forceNextWebGLContextCreationToFail() |
4455 { | 4442 { |
4456 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4443 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
4457 } | 4444 } |
4458 | 4445 |
4459 void WebViewImpl::forceNextDrawingBufferCreationToFail() | 4446 void WebViewImpl::forceNextDrawingBufferCreationToFail() |
4460 { | 4447 { |
4461 DrawingBuffer::forceNextDrawingBufferCreationToFail(); | 4448 DrawingBuffer::forceNextDrawingBufferCreationToFail(); |
4462 } | 4449 } |
4463 | 4450 |
4464 void WebViewImpl::updatePageOverlays() | 4451 void WebViewImpl::updatePageOverlays() |
4465 { | 4452 { |
4466 if (m_pageColorOverlay) | 4453 if (m_pageColorOverlay) |
4467 m_pageColorOverlay->update(); | 4454 m_pageColorOverlay->update(); |
4468 if (InspectorOverlay* overlay = inspectorOverlay()) { | 4455 if (InspectorOverlay* overlay = inspectorOverlay()) { |
4469 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); | 4456 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); |
4470 if (inspectorPageOverlay) | 4457 if (inspectorPageOverlay) |
4471 inspectorPageOverlay->update(); | 4458 inspectorPageOverlay->update(); |
4472 } | 4459 } |
4473 } | 4460 } |
4474 | 4461 |
4475 } // namespace blink | 4462 } // namespace blink |
OLD | NEW |