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 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 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1646 { | 1650 { |
| 1647 if (m_shouldAutoResize || m_size == newSize) | 1651 if (m_shouldAutoResize || m_size == newSize) |
| 1648 return; | 1652 return; |
| 1649 | 1653 |
| 1650 FrameView* view = mainFrameImpl()->frameView(); | 1654 FrameView* view = mainFrameImpl()->frameView(); |
| 1651 if (!view) | 1655 if (!view) |
| 1652 return; | 1656 return; |
| 1653 | 1657 |
| 1654 WebSize oldSize = m_size; | 1658 WebSize oldSize = m_size; |
| 1655 float oldPageScaleFactor = pageScaleFactor(); | 1659 float oldPageScaleFactor = pageScaleFactor(); |
| 1656 IntSize oldScrollOffset = view->scrollOffset(); | 1660 int oldContentsWidth = contentsSize().width(); |
| 1657 int oldFixedLayoutWidth = fixedLayoutSize().width; | |
| 1658 | 1661 |
| 1659 m_size = newSize; | 1662 m_size = newSize; |
| 1660 | 1663 |
| 1661 #if ENABLE(VIEWPORT) | 1664 #if ENABLE(VIEWPORT) |
| 1665 ViewportAnchor viewportAnchor(mainFrameImpl()->frame()->eventHandler()); | |
| 1666 if (settings()->viewportEnabled()) | |
| 1667 viewportAnchor.setAnchor(view->visibleContentRect(), | |
| 1668 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); | |
| 1669 | |
| 1662 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()-> viewportArguments(); | 1670 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()-> viewportArguments(); |
| 1663 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArgu ments); | 1671 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArgu ments); |
| 1664 #endif | 1672 #endif |
| 1665 | 1673 |
| 1666 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); | 1674 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); |
| 1667 if (agentPrivate) | 1675 if (agentPrivate) |
| 1668 agentPrivate->webViewResized(newSize); | 1676 agentPrivate->webViewResized(newSize); |
| 1669 if (!agentPrivate || !agentPrivate->metricsOverridden()) { | 1677 if (!agentPrivate || !agentPrivate->metricsOverridden()) { |
| 1670 WebFrameImpl* webFrame = mainFrameImpl(); | 1678 WebFrameImpl* webFrame = mainFrameImpl(); |
| 1671 if (webFrame->frameView()) | 1679 if (webFrame->frameView()) |
| 1672 webFrame->frameView()->resize(m_size); | 1680 webFrame->frameView()->resize(m_size); |
| 1673 } | 1681 } |
| 1674 | 1682 |
| 1675 #if ENABLE(VIEWPORT) | 1683 #if ENABLE(VIEWPORT) |
| 1676 if (settings()->viewportEnabled()) { | 1684 if (settings()->viewportEnabled()) { |
|
aelias_OOO_until_Jul13
2013/04/16 16:35:42
Please change this to if (settings()->viewportEnab
jdduke (slow)
2013/04/16 18:58:26
There appear to be some assumptions that view->lay
| |
| 1677 // Relayout immediately to recalculate the minimum scale limit. | 1685 // Relayout immediately to recalculate the minimum scale limit. |
| 1678 if (view->needsLayout()) | 1686 if (view->needsLayout()) |
| 1679 view->layout(); | 1687 view->layout(); |
| 1680 | 1688 |
| 1681 // When the device rotates: | |
| 1682 // - If the page width is unchanged, then zoom by new width/old width | |
| 1683 // such as to keep the same content horizontally onscreen. | |
| 1684 // - If the page width stretches proportionally to the change in | |
| 1685 // screen width, then don't zoom at all (assuming the content has | |
| 1686 // scaled uniformly, then the same content will be horizontally | |
| 1687 // onscreen). | |
| 1688 // - If the page width partially stretches, then zoom partially to | |
| 1689 // make up the difference. | |
| 1690 // In all cases try to keep the same content at the top of the screen. | |
| 1691 float viewportWidthRatio = !oldSize.width ? 1 : newSize.width / (float) oldSize.width; | 1689 float viewportWidthRatio = !oldSize.width ? 1 : newSize.width / (float) oldSize.width; |
|
aelias_OOO_until_Jul13
2013/04/16 16:35:42
And you can then delete both of the ternary operat
jdduke (slow)
2013/04/16 18:58:26
Done.
| |
| 1692 float fixedLayoutWidthRatio = !oldFixedLayoutWidth ? 1 : fixedLayoutSize ().width / (float) oldFixedLayoutWidth; | 1690 float contentsWidthRatio = (!oldSize.width || !oldContentsWidth) ? 1 : c ontentsSize().width() / (float) oldContentsWidth; |
| 1693 float scaleMultiplier = viewportWidthRatio / fixedLayoutWidthRatio; | 1691 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio; |
| 1694 if (scaleMultiplier != 1) | 1692 |
| 1695 setPageScaleFactor(oldPageScaleFactor * scaleMultiplier, WebPoint(ol dScrollOffset.width(), oldScrollOffset.height())); | 1693 IntSize viewportSize = view->visibleContentRect().size(); |
| 1694 if (scaleMultiplier != 1) { | |
| 1695 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier; | |
| 1696 viewportSize.scale(pageScaleFactor() / newPageScaleFactor); | |
| 1697 IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(viewp ortSize); | |
| 1698 setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale); | |
| 1699 } else { | |
| 1700 IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnchor. computeOrigin(viewportSize), pageScaleFactor()); | |
| 1701 updateMainFrameScrollPosition(scrollOffsetAtNewScale, false); | |
| 1702 } | |
| 1696 } | 1703 } |
| 1697 #endif | 1704 #endif |
| 1698 | 1705 |
| 1699 sendResizeEventAndRepaint(); | 1706 sendResizeEventAndRepaint(); |
| 1700 } | 1707 } |
| 1701 | 1708 |
| 1702 void WebViewImpl::willEndLiveResize() | 1709 void WebViewImpl::willEndLiveResize() |
| 1703 { | 1710 { |
| 1704 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1711 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
| 1705 mainFrameImpl()->frameView()->willEndLiveResize(); | 1712 mainFrameImpl()->frameView()->willEndLiveResize(); |
| (...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4191 } | 4198 } |
| 4192 | 4199 |
| 4193 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4200 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 4194 { | 4201 { |
| 4195 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); | 4202 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); |
| 4196 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom | 4203 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom |
| 4197 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); | 4204 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); |
| 4198 } | 4205 } |
| 4199 | 4206 |
| 4200 } // namespace WebKit | 4207 } // namespace WebKit |
| OLD | NEW |