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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2823 { | 2827 { |
2824 LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame
() | 2828 LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame
() |
2825 ? page()->deprecatedLocalMainFrame() : 0; | 2829 ? page()->deprecatedLocalMainFrame() : 0; |
2826 Element* element = focusedElement(); | 2830 Element* element = focusedElement(); |
2827 if (!frame || !frame->view() || !element) | 2831 if (!frame || !frame->view() || !element) |
2828 return false; | 2832 return false; |
2829 | 2833 |
2830 element->document().updateLayoutIgnorePendingStylesheets(); | 2834 element->document().updateLayoutIgnorePendingStylesheets(); |
2831 | 2835 |
2832 bool zoomInToLegibleScale = m_webSettings->autoZoomFocusedNodeToLegibleScale
() | 2836 bool zoomInToLegibleScale = m_webSettings->autoZoomFocusedNodeToLegibleScale
() |
2833 && !shouldDisableDesktopWorkarounds(); | 2837 && !page()->frameHost().visualViewport().shouldDisableDesktopWorkarounds
(); |
2834 | 2838 |
2835 if (zoomInToLegibleScale) { | 2839 if (zoomInToLegibleScale) { |
2836 // When deciding whether to zoom in on a focused text box, we should dec
ide not to | 2840 // When deciding whether to zoom in on a focused text box, we should dec
ide not to |
2837 // zoom in if the user won't be able to zoom out. e.g if the textbox is
within a | 2841 // zoom in if the user won't be able to zoom out. e.g if the textbox is
within a |
2838 // touch-action: none container the user can't zoom back out. | 2842 // touch-action: none container the user can't zoom back out. |
2839 TouchAction action = TouchActionUtil::computeEffectiveTouchAction(*eleme
nt); | 2843 TouchAction action = TouchActionUtil::computeEffectiveTouchAction(*eleme
nt); |
2840 if (action != TouchActionAuto && !(action & TouchActionPinchZoom)) | 2844 if (action != TouchActionAuto && !(action & TouchActionPinchZoom)) |
2841 zoomInToLegibleScale = false; | 2845 zoomInToLegibleScale = false; |
2842 } | 2846 } |
2843 | 2847 |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4220 FrameView* frameView = mainFrameImpl()->frameView(); | 4224 FrameView* frameView = mainFrameImpl()->frameView(); |
4221 if (!frameView) | 4225 if (!frameView) |
4222 return; | 4226 return; |
4223 | 4227 |
4224 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat
ioDelta); | 4228 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat
ioDelta); |
4225 | 4229 |
4226 FloatPoint visualViewportOffset = page()->frameHost().visualViewport().visib
leRect().location(); | 4230 FloatPoint visualViewportOffset = page()->frameHost().visualViewport().visib
leRect().location(); |
4227 visualViewportOffset.move(visualViewportDelta.width, visualViewportDelta.hei
ght); | 4231 visualViewportOffset.move(visualViewportDelta.width, visualViewportDelta.hei
ght); |
4228 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, visualView
portOffset); | 4232 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, visualView
portOffset); |
4229 | 4233 |
4230 if (pageScaleDelta != 1) | 4234 if (pageScaleDelta != 1) { |
4231 m_doubleTapZoomPending = false; | 4235 m_doubleTapZoomPending = false; |
| 4236 page()->frameHost().visualViewport().userDidChangeScale(); |
| 4237 } |
4232 | 4238 |
4233 m_elasticOverscroll += elasticOverscrollDelta; | 4239 m_elasticOverscroll += elasticOverscrollDelta; |
4234 frameView->didUpdateElasticOverscroll(); | 4240 frameView->didUpdateElasticOverscroll(); |
4235 | 4241 |
4236 ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea(); | 4242 ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea(); |
4237 | 4243 |
4238 DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble() | 4244 DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble() |
4239 + DoubleSize(layoutViewportDelta.width, layoutViewportDelta.height); | 4245 + DoubleSize(layoutViewportDelta.width, layoutViewportDelta.height); |
4240 | 4246 |
4241 if (layoutViewport->scrollPositionDouble() != layoutViewportPosition) { | 4247 if (layoutViewport->scrollPositionDouble() != layoutViewportPosition) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4388 } | 4394 } |
4389 | 4395 |
4390 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); | 4396 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); |
4391 | 4397 |
4392 if (page()) | 4398 if (page()) |
4393 page()->pointerLockController().dispatchLockedMouseEvent( | 4399 page()->pointerLockController().dispatchLockedMouseEvent( |
4394 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), | 4400 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), |
4395 eventType); | 4401 eventType); |
4396 } | 4402 } |
4397 | 4403 |
4398 bool WebViewImpl::shouldDisableDesktopWorkarounds() | |
4399 { | |
4400 if (!settings()->viewportEnabled()) | |
4401 return false; | |
4402 | |
4403 // A document is considered adapted to small screen UAs if one of these hold
s: | |
4404 // 1. The author specified viewport has a constrained width that is equal to | |
4405 // the initial viewport width. | |
4406 // 2. The author has disabled viewport zoom. | |
4407 | |
4408 const PageScaleConstraints& constraints = pageScaleConstraintsSet().pageDefi
nedConstraints(); | |
4409 | |
4410 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | |
4411 return false; | |
4412 | |
4413 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | |
4414 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | |
4415 } | |
4416 | |
4417 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4404 void WebViewImpl::forceNextWebGLContextCreationToFail() |
4418 { | 4405 { |
4419 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4406 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
4420 } | 4407 } |
4421 | 4408 |
4422 void WebViewImpl::forceNextDrawingBufferCreationToFail() | 4409 void WebViewImpl::forceNextDrawingBufferCreationToFail() |
4423 { | 4410 { |
4424 DrawingBuffer::forceNextDrawingBufferCreationToFail(); | 4411 DrawingBuffer::forceNextDrawingBufferCreationToFail(); |
4425 } | 4412 } |
4426 | 4413 |
4427 void WebViewImpl::updatePageOverlays() | 4414 void WebViewImpl::updatePageOverlays() |
4428 { | 4415 { |
4429 if (m_pageColorOverlay) | 4416 if (m_pageColorOverlay) |
4430 m_pageColorOverlay->update(); | 4417 m_pageColorOverlay->update(); |
4431 if (InspectorOverlay* overlay = inspectorOverlay()) { | 4418 if (InspectorOverlay* overlay = inspectorOverlay()) { |
4432 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); | 4419 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); |
4433 if (inspectorPageOverlay) | 4420 if (inspectorPageOverlay) |
4434 inspectorPageOverlay->update(); | 4421 inspectorPageOverlay->update(); |
4435 } | 4422 } |
4436 } | 4423 } |
4437 | 4424 |
4438 } // namespace blink | 4425 } // namespace blink |
OLD | NEW |