Chromium Code Reviews| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 #include "GeolocationClientProxy.h" | 66 #include "GeolocationClientProxy.h" |
| 67 #include "GeolocationController.h" | 67 #include "GeolocationController.h" |
| 68 #include "GraphicsContext.h" | 68 #include "GraphicsContext.h" |
| 69 #include "GraphicsContext3D.h" | 69 #include "GraphicsContext3D.h" |
| 70 #include "GraphicsContext3DPrivate.h" | 70 #include "GraphicsContext3DPrivate.h" |
| 71 #include "GraphicsLayerFactoryChromium.h" | 71 #include "GraphicsLayerFactoryChromium.h" |
| 72 #include "HTMLInputElement.h" | 72 #include "HTMLInputElement.h" |
| 73 #include "HTMLMediaElement.h" | 73 #include "HTMLMediaElement.h" |
| 74 #include "HTMLNames.h" | 74 #include "HTMLNames.h" |
| 75 #include "HTMLTextAreaElement.h" | 75 #include "HTMLTextAreaElement.h" |
| 76 #include "HitTestResult.h" | |
| 77 #include "Image.h" | 76 #include "Image.h" |
| 78 #include "ImageBuffer.h" | 77 #include "ImageBuffer.h" |
| 79 #include "InspectorController.h" | 78 #include "InspectorController.h" |
| 80 #include "InspectorInstrumentation.h" | 79 #include "InspectorInstrumentation.h" |
| 81 #include "KeyboardCodes.h" | 80 #include "KeyboardCodes.h" |
| 82 #include "KeyboardEvent.h" | 81 #include "KeyboardEvent.h" |
| 83 #include "LayerPainterChromium.h" | 82 #include "LayerPainterChromium.h" |
| 84 #include "LinkHighlight.h" | 83 #include "LinkHighlight.h" |
| 85 #include "MIMETypeRegistry.h" | 84 #include "MIMETypeRegistry.h" |
| 86 #include "NodeRenderStyle.h" | 85 #include "NodeRenderStyle.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 112 #include "SpeechInputClientImpl.h" | 111 #include "SpeechInputClientImpl.h" |
| 113 #include "SpeechRecognitionClientProxy.h" | 112 #include "SpeechRecognitionClientProxy.h" |
| 114 #include "StyleResolver.h" | 113 #include "StyleResolver.h" |
| 115 #include "Text.h" | 114 #include "Text.h" |
| 116 #include "TextFieldDecoratorImpl.h" | 115 #include "TextFieldDecoratorImpl.h" |
| 117 #include "TextIterator.h" | 116 #include "TextIterator.h" |
| 118 #include "Timer.h" | 117 #include "Timer.h" |
| 119 #include "TouchDisambiguation.h" | 118 #include "TouchDisambiguation.h" |
| 120 #include "TraceEvent.h" | 119 #include "TraceEvent.h" |
| 121 #include "ValidationMessageClientImpl.h" | 120 #include "ValidationMessageClientImpl.h" |
| 121 #include "ViewportAnchor.h" | |
| 122 #include "WebAccessibilityObject.h" | 122 #include "WebAccessibilityObject.h" |
| 123 #include "WebActiveWheelFlingParameters.h" | 123 #include "WebActiveWheelFlingParameters.h" |
| 124 #include "WebAutofillClient.h" | 124 #include "WebAutofillClient.h" |
| 125 #include "WebCompositorInputHandlerImpl.h" | 125 #include "WebCompositorInputHandlerImpl.h" |
| 126 #include "WebDevToolsAgentImpl.h" | 126 #include "WebDevToolsAgentImpl.h" |
| 127 #include "WebDevToolsAgentPrivate.h" | 127 #include "WebDevToolsAgentPrivate.h" |
| 128 #include "WebFrameImpl.h" | 128 #include "WebFrameImpl.h" |
| 129 #include "WebHelperPluginImpl.h" | 129 #include "WebHelperPluginImpl.h" |
| 130 #include "WebHitTestResult.h" | 130 #include "WebHitTestResult.h" |
| 131 #include "WebInputElement.h" | 131 #include "WebInputElement.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 // (such as due to a double tap gesture or find in page etc.). These are | 190 // (such as due to a double tap gesture or find in page etc.). These are |
| 191 // experimentally determined. | 191 // experimentally determined. |
| 192 static const int touchPointPadding = 32; | 192 static const int touchPointPadding = 32; |
| 193 static const int nonUserInitiatedPointPadding = 11; | 193 static const int nonUserInitiatedPointPadding = 11; |
| 194 static const float minScaleDifference = 0.01f; | 194 static const float minScaleDifference = 0.01f; |
| 195 static const float doubleTapZoomContentDefaultMargin = 5; | 195 static const float doubleTapZoomContentDefaultMargin = 5; |
| 196 static const float doubleTapZoomContentMinimumMargin = 2; | 196 static const float doubleTapZoomContentMinimumMargin = 2; |
| 197 static const double doubleTapZoomAnimationDurationInSeconds = 0.25; | 197 static const double doubleTapZoomAnimationDurationInSeconds = 0.25; |
| 198 static const float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 198 static const float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 199 | 199 |
| 200 // Constants for viewport anchoring on resize. | |
| 201 static const float viewportAnchorXCoord = 0.5f; | |
| 202 static const float viewportAnchorYCoord = 0; | |
| 203 | |
| 200 // Constants for zooming in on a focused text field. | 204 // Constants for zooming in on a focused text field. |
| 201 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; | 205 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; |
| 202 static const int minReadableCaretHeight = 18; | 206 static const int minReadableCaretHeight = 18; |
| 203 static const float minScaleChangeToTriggerZoom = 1.05f; | 207 static const float minScaleChangeToTriggerZoom = 1.05f; |
| 204 static const float leftBoxRatio = 0.3f; | 208 static const float leftBoxRatio = 0.3f; |
| 205 static const int caretPadding = 10; | 209 static const int caretPadding = 10; |
| 206 | 210 |
| 207 namespace WebKit { | 211 namespace WebKit { |
| 208 | 212 |
| 209 // Change the text zoom level by kTextSizeMultiplierRatio each time the user | 213 // Change the text zoom level by kTextSizeMultiplierRatio each time the user |
| (...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1647 { | 1651 { |
| 1648 if (m_shouldAutoResize || m_size == newSize) | 1652 if (m_shouldAutoResize || m_size == newSize) |
| 1649 return; | 1653 return; |
| 1650 | 1654 |
| 1651 FrameView* view = mainFrameImpl()->frameView(); | 1655 FrameView* view = mainFrameImpl()->frameView(); |
| 1652 if (!view) | 1656 if (!view) |
| 1653 return; | 1657 return; |
| 1654 | 1658 |
| 1655 WebSize oldSize = m_size; | 1659 WebSize oldSize = m_size; |
| 1656 float oldPageScaleFactor = pageScaleFactor(); | 1660 float oldPageScaleFactor = pageScaleFactor(); |
| 1657 IntSize oldScrollOffset = view->scrollOffset(); | 1661 float oldMinimumPageScaleFactor = m_minimumPageScaleFactor; |
| 1658 int oldFixedLayoutWidth = fixedLayoutSize().width; | 1662 int oldFixedLayoutWidth = fixedLayoutSize().width; |
| 1663 int oldContentsWidth = contentsSize().width(); | |
| 1659 | 1664 |
| 1660 m_size = newSize; | 1665 m_size = newSize; |
| 1661 | 1666 |
| 1662 #if ENABLE(VIEWPORT) | 1667 #if ENABLE(VIEWPORT) |
| 1668 ViewportAnchor viewportAnchor(mainFrameImpl()->frame()->eventHandler()); | |
| 1669 if (settings()->viewportEnabled()) | |
| 1670 viewportAnchor.setAnchor(view->visibleContentRect(), | |
| 1671 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); | |
| 1672 | |
| 1663 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()-> viewportArguments(); | 1673 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()-> viewportArguments(); |
| 1664 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArgu ments); | 1674 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArgu ments); |
| 1665 #endif | 1675 #endif |
| 1666 | 1676 |
| 1667 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); | 1677 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); |
| 1668 if (agentPrivate) | 1678 if (agentPrivate) |
| 1669 agentPrivate->webViewResized(newSize); | 1679 agentPrivate->webViewResized(newSize); |
| 1670 if (!agentPrivate || !agentPrivate->metricsOverridden()) { | 1680 if (!agentPrivate || !agentPrivate->metricsOverridden()) { |
| 1671 WebFrameImpl* webFrame = mainFrameImpl(); | 1681 WebFrameImpl* webFrame = mainFrameImpl(); |
| 1672 if (webFrame->frameView()) | 1682 if (webFrame->frameView()) |
| 1673 webFrame->frameView()->resize(m_size); | 1683 webFrame->frameView()->resize(m_size); |
| 1674 } | 1684 } |
| 1675 | 1685 |
| 1676 #if ENABLE(VIEWPORT) | 1686 #if ENABLE(VIEWPORT) |
| 1677 if (settings()->viewportEnabled()) { | 1687 if (settings()->viewportEnabled()) { |
| 1678 // Relayout immediately to recalculate the minimum scale limit. | 1688 // Relayout immediately to recalculate the minimum scale limit. |
| 1679 if (view->needsLayout()) | 1689 if (view->needsLayout()) |
| 1680 view->layout(); | 1690 view->layout(); |
| 1681 | 1691 |
| 1682 // When the device rotates: | 1692 // The minimum scale limit may change as a result of layout content |
| 1683 // - If the page width is unchanged, then zoom by new width/old width | 1693 // changes; in this case, scale relative to the change in content width. |
| 1684 // such as to keep the same content horizontally onscreen. | 1694 // Otherwise scale relative to the change in layout width. |
| 1685 // - If the page width stretches proportionally to the change in | 1695 // Don't do any scaling if the old width was zero (i.e., first resize). |
| 1686 // screen width, then don't zoom at all (assuming the content has | 1696 float scalingWidthRatio = 1; |
| 1687 // scaled uniformly, then the same content will be horizontally | 1697 if (oldSize.width && oldContentsWidth && m_minimumPageScaleFactor != old MinimumPageScaleFactor) |
|
aelias_OOO_until_Jul13
2013/04/15 18:25:39
Could you delete the "&& m_minimumPageScaleFactor
jdduke (slow)
2013/04/16 15:40:26
Done.
| |
| 1688 // onscreen). | 1698 scalingWidthRatio = contentsSize().width() / (float) oldContentsWidt h; |
| 1689 // - If the page width partially stretches, then zoom partially to | 1699 else if (oldFixedLayoutWidth) |
| 1690 // make up the difference. | 1700 scalingWidthRatio = fixedLayoutSize().width / (float) oldFixedLayout Width; |
|
aelias_OOO_until_Jul13
2013/04/15 18:25:39
Could you try deleting this else block and see if
jdduke (slow)
2013/04/16 15:40:26
This initially caused some problems with fixed wid
| |
| 1691 // In all cases try to keep the same content at the top of the screen. | 1701 |
| 1692 float viewportWidthRatio = !oldSize.width ? 1 : newSize.width / (float) oldSize.width; | 1702 float viewportWidthRatio = !oldSize.width ? 1 : newSize.width / (float) oldSize.width; |
| 1693 float fixedLayoutWidthRatio = !oldFixedLayoutWidth ? 1 : fixedLayoutSize ().width / (float) oldFixedLayoutWidth; | 1703 float scaleMultiplier = viewportWidthRatio / scalingWidthRatio; |
| 1694 float scaleMultiplier = viewportWidthRatio / fixedLayoutWidthRatio; | 1704 |
| 1695 if (scaleMultiplier != 1) | 1705 IntSize viewportSize = view->visibleContentRect().size(); |
| 1696 setPageScaleFactor(oldPageScaleFactor * scaleMultiplier, WebPoint(ol dScrollOffset.width(), oldScrollOffset.height())); | 1706 if (scaleMultiplier != 1) { |
| 1707 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier; | |
| 1708 viewportSize.scale(pageScaleFactor() / newPageScaleFactor); | |
| 1709 IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(viewp ortSize); | |
| 1710 setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale); | |
| 1711 } else { | |
| 1712 IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnchor. computeOrigin(viewportSize), pageScaleFactor()); | |
| 1713 updateMainFrameScrollPosition(scrollOffsetAtNewScale, false); | |
| 1714 } | |
| 1697 } | 1715 } |
| 1698 #endif | 1716 #endif |
| 1699 | 1717 |
| 1700 sendResizeEventAndRepaint(); | 1718 sendResizeEventAndRepaint(); |
| 1701 } | 1719 } |
| 1702 | 1720 |
| 1703 void WebViewImpl::willEndLiveResize() | 1721 void WebViewImpl::willEndLiveResize() |
| 1704 { | 1722 { |
| 1705 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1723 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
| 1706 mainFrameImpl()->frameView()->willEndLiveResize(); | 1724 mainFrameImpl()->frameView()->willEndLiveResize(); |
| (...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4192 } | 4210 } |
| 4193 | 4211 |
| 4194 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4212 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 4195 { | 4213 { |
| 4196 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); | 4214 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); |
| 4197 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom | 4215 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom |
| 4198 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); | 4216 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); |
| 4199 } | 4217 } |
| 4200 | 4218 |
| 4201 } // namespace WebKit | 4219 } // namespace WebKit |
| OLD | NEW |