| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 #include "GeolocationClientProxy.h" | 65 #include "GeolocationClientProxy.h" |
| 66 #include "GeolocationController.h" | 66 #include "GeolocationController.h" |
| 67 #include "GraphicsContext.h" | 67 #include "GraphicsContext.h" |
| 68 #include "GraphicsContext3D.h" | 68 #include "GraphicsContext3D.h" |
| 69 #include "GraphicsContext3DPrivate.h" | 69 #include "GraphicsContext3DPrivate.h" |
| 70 #include "GraphicsLayerFactoryChromium.h" | 70 #include "GraphicsLayerFactoryChromium.h" |
| 71 #include "HTMLInputElement.h" | 71 #include "HTMLInputElement.h" |
| 72 #include "HTMLMediaElement.h" | 72 #include "HTMLMediaElement.h" |
| 73 #include "HTMLNames.h" | 73 #include "HTMLNames.h" |
| 74 #include "HTMLTextAreaElement.h" | 74 #include "HTMLTextAreaElement.h" |
| 75 #include "HitTestResult.h" | |
| 76 #include "Image.h" | 75 #include "Image.h" |
| 77 #include "ImageBuffer.h" | 76 #include "ImageBuffer.h" |
| 78 #include "InspectorController.h" | 77 #include "InspectorController.h" |
| 79 #include "InspectorInstrumentation.h" | 78 #include "InspectorInstrumentation.h" |
| 80 #include "KeyboardCodes.h" | 79 #include "KeyboardCodes.h" |
| 81 #include "KeyboardEvent.h" | 80 #include "KeyboardEvent.h" |
| 82 #include "LayerPainterChromium.h" | 81 #include "LayerPainterChromium.h" |
| 83 #include "LinkHighlight.h" | 82 #include "LinkHighlight.h" |
| 84 #include "MIMETypeRegistry.h" | 83 #include "MIMETypeRegistry.h" |
| 85 #include "NodeRenderStyle.h" | 84 #include "NodeRenderStyle.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 111 #include "SpeechInputClientImpl.h" | 110 #include "SpeechInputClientImpl.h" |
| 112 #include "SpeechRecognitionClientProxy.h" | 111 #include "SpeechRecognitionClientProxy.h" |
| 113 #include "StyleResolver.h" | 112 #include "StyleResolver.h" |
| 114 #include "Text.h" | 113 #include "Text.h" |
| 115 #include "TextFieldDecoratorImpl.h" | 114 #include "TextFieldDecoratorImpl.h" |
| 116 #include "TextIterator.h" | 115 #include "TextIterator.h" |
| 117 #include "Timer.h" | 116 #include "Timer.h" |
| 118 #include "TouchDisambiguation.h" | 117 #include "TouchDisambiguation.h" |
| 119 #include "TraceEvent.h" | 118 #include "TraceEvent.h" |
| 120 #include "ValidationMessageClientImpl.h" | 119 #include "ValidationMessageClientImpl.h" |
| 120 #include "ViewportAnchor.h" |
| 121 #include "WebAccessibilityObject.h" | 121 #include "WebAccessibilityObject.h" |
| 122 #include "WebActiveWheelFlingParameters.h" | 122 #include "WebActiveWheelFlingParameters.h" |
| 123 #include "WebAutofillClient.h" | 123 #include "WebAutofillClient.h" |
| 124 #include "WebCompositorInputHandlerImpl.h" | 124 #include "WebCompositorInputHandlerImpl.h" |
| 125 #include "WebDevToolsAgentImpl.h" | 125 #include "WebDevToolsAgentImpl.h" |
| 126 #include "WebDevToolsAgentPrivate.h" | 126 #include "WebDevToolsAgentPrivate.h" |
| 127 #include "WebFrameImpl.h" | 127 #include "WebFrameImpl.h" |
| 128 #include "WebHelperPluginImpl.h" | 128 #include "WebHelperPluginImpl.h" |
| 129 #include "WebHitTestResult.h" | 129 #include "WebHitTestResult.h" |
| 130 #include "WebInputElement.h" | 130 #include "WebInputElement.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // (such as due to a double tap gesture or find in page etc.). These are | 189 // (such as due to a double tap gesture or find in page etc.). These are |
| 190 // experimentally determined. | 190 // experimentally determined. |
| 191 static const int touchPointPadding = 32; | 191 static const int touchPointPadding = 32; |
| 192 static const int nonUserInitiatedPointPadding = 11; | 192 static const int nonUserInitiatedPointPadding = 11; |
| 193 static const float minScaleDifference = 0.01f; | 193 static const float minScaleDifference = 0.01f; |
| 194 static const float doubleTapZoomContentDefaultMargin = 5; | 194 static const float doubleTapZoomContentDefaultMargin = 5; |
| 195 static const float doubleTapZoomContentMinimumMargin = 2; | 195 static const float doubleTapZoomContentMinimumMargin = 2; |
| 196 static const double doubleTapZoomAnimationDurationInSeconds = 0.25; | 196 static const double doubleTapZoomAnimationDurationInSeconds = 0.25; |
| 197 static const float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 197 static const float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 198 | 198 |
| 199 // Constants for viewport anchoring on resize. |
| 200 static const float viewportAnchorXCoord = 0.5f; |
| 201 static const float viewportAnchorYCoord = 0; |
| 202 |
| 199 // Constants for zooming in on a focused text field. | 203 // Constants for zooming in on a focused text field. |
| 200 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; | 204 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; |
| 201 static const int minReadableCaretHeight = 18; | 205 static const int minReadableCaretHeight = 18; |
| 202 static const float minScaleChangeToTriggerZoom = 1.05f; | 206 static const float minScaleChangeToTriggerZoom = 1.05f; |
| 203 static const float leftBoxRatio = 0.3f; | 207 static const float leftBoxRatio = 0.3f; |
| 204 static const int caretPadding = 10; | 208 static const int caretPadding = 10; |
| 205 | 209 |
| 206 namespace WebKit { | 210 namespace WebKit { |
| 207 | 211 |
| 208 // Change the text zoom level by kTextSizeMultiplierRatio each time the user | 212 // Change the text zoom level by kTextSizeMultiplierRatio each time the user |
| (...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 { | 1648 { |
| 1645 if (m_shouldAutoResize || m_size == newSize) | 1649 if (m_shouldAutoResize || m_size == newSize) |
| 1646 return; | 1650 return; |
| 1647 | 1651 |
| 1648 FrameView* view = mainFrameImpl()->frameView(); | 1652 FrameView* view = mainFrameImpl()->frameView(); |
| 1649 if (!view) | 1653 if (!view) |
| 1650 return; | 1654 return; |
| 1651 | 1655 |
| 1652 WebSize oldSize = m_size; | 1656 WebSize oldSize = m_size; |
| 1653 float oldPageScaleFactor = pageScaleFactor(); | 1657 float oldPageScaleFactor = pageScaleFactor(); |
| 1654 IntSize oldScrollOffset = view->scrollOffset(); | 1658 int oldContentsWidth = contentsSize().width(); |
| 1655 int oldFixedLayoutWidth = fixedLayoutSize().width; | |
| 1656 | 1659 |
| 1657 m_size = newSize; | 1660 m_size = newSize; |
| 1658 | 1661 |
| 1659 #if ENABLE(VIEWPORT) | 1662 #if ENABLE(VIEWPORT) |
| 1663 bool shouldAnchorAndRescaleViewport = settings()->viewportEnabled() && oldSi
ze.width && oldContentsWidth; |
| 1664 ViewportAnchor viewportAnchor(mainFrameImpl()->frame()->eventHandler()); |
| 1665 if (shouldAnchorAndRescaleViewport) { |
| 1666 viewportAnchor.setAnchor(view->visibleContentRect(), |
| 1667 FloatSize(viewportAnchorXCoord, viewportAnchorY
Coord)); |
| 1668 } |
| 1669 |
| 1660 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()->
viewportArguments(); | 1670 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()->
viewportArguments(); |
| 1661 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArgu
ments); | 1671 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArgu
ments); |
| 1662 #endif | 1672 #endif |
| 1663 | 1673 |
| 1664 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); | 1674 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); |
| 1665 if (agentPrivate) | 1675 if (agentPrivate) |
| 1666 agentPrivate->webViewResized(newSize); | 1676 agentPrivate->webViewResized(newSize); |
| 1667 if (!agentPrivate || !agentPrivate->metricsOverridden()) { | 1677 if (!agentPrivate || !agentPrivate->metricsOverridden()) { |
| 1668 WebFrameImpl* webFrame = mainFrameImpl(); | 1678 WebFrameImpl* webFrame = mainFrameImpl(); |
| 1669 if (webFrame->frameView()) | 1679 if (webFrame->frameView()) |
| 1670 webFrame->frameView()->resize(m_size); | 1680 webFrame->frameView()->resize(m_size); |
| 1671 } | 1681 } |
| 1672 | 1682 |
| 1673 #if ENABLE(VIEWPORT) | 1683 #if ENABLE(VIEWPORT) |
| 1674 if (settings()->viewportEnabled()) { | 1684 if (settings()->viewportEnabled()) { |
| 1675 // Relayout immediately to recalculate the minimum scale limit. | 1685 // Relayout immediately to recalculate the minimum scale limit. |
| 1676 if (view->needsLayout()) | 1686 if (view->needsLayout()) |
| 1677 view->layout(); | 1687 view->layout(); |
| 1678 | 1688 |
| 1679 // When the device rotates: | 1689 if (shouldAnchorAndRescaleViewport) { |
| 1680 // - If the page width is unchanged, then zoom by new width/old width | 1690 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi
ze.width; |
| 1681 // such as to keep the same content horizontally onscreen. | 1691 float contentsWidthRatio = static_cast<float>(contentsSize().width()
) / oldContentsWidth; |
| 1682 // - If the page width stretches proportionally to the change in | 1692 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio; |
| 1683 // screen width, then don't zoom at all (assuming the content has | 1693 |
| 1684 // scaled uniformly, then the same content will be horizontally | 1694 IntSize viewportSize = view->visibleContentRect().size(); |
| 1685 // onscreen). | 1695 if (scaleMultiplier != 1) { |
| 1686 // - If the page width partially stretches, then zoom partially to | 1696 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier; |
| 1687 // make up the difference. | 1697 viewportSize.scale(pageScaleFactor() / newPageScaleFactor); |
| 1688 // In all cases try to keep the same content at the top of the screen. | 1698 IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(v
iewportSize); |
| 1689 float viewportWidthRatio = !oldSize.width ? 1 : newSize.width / (float)
oldSize.width; | 1699 setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale); |
| 1690 float fixedLayoutWidthRatio = !oldFixedLayoutWidth ? 1 : fixedLayoutSize
().width / (float) oldFixedLayoutWidth; | 1700 } else { |
| 1691 float scaleMultiplier = viewportWidthRatio / fixedLayoutWidthRatio; | 1701 IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnc
hor.computeOrigin(viewportSize), pageScaleFactor()); |
| 1692 if (scaleMultiplier != 1) | 1702 updateMainFrameScrollPosition(scrollOffsetAtNewScale, false); |
| 1693 setPageScaleFactor(oldPageScaleFactor * scaleMultiplier, WebPoint(ol
dScrollOffset.width(), oldScrollOffset.height())); | 1703 } |
| 1704 } |
| 1694 } | 1705 } |
| 1695 #endif | 1706 #endif |
| 1696 | 1707 |
| 1697 sendResizeEventAndRepaint(); | 1708 sendResizeEventAndRepaint(); |
| 1698 } | 1709 } |
| 1699 | 1710 |
| 1700 void WebViewImpl::willEndLiveResize() | 1711 void WebViewImpl::willEndLiveResize() |
| 1701 { | 1712 { |
| 1702 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1713 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
| 1703 mainFrameImpl()->frameView()->willEndLiveResize(); | 1714 mainFrameImpl()->frameView()->willEndLiveResize(); |
| (...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4213 } | 4224 } |
| 4214 | 4225 |
| 4215 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4226 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 4216 { | 4227 { |
| 4217 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport
Arguments(); | 4228 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport
Arguments(); |
| 4218 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.
userZoom | 4229 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.
userZoom |
| 4219 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp
ortArguments::ValueAuto); | 4230 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp
ortArguments::ValueAuto); |
| 4220 } | 4231 } |
| 4221 | 4232 |
| 4222 } // namespace WebKit | 4233 } // namespace WebKit |
| OLD | NEW |