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 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 ViewportAnchor viewportAnchor(&mainFrameImpl()->frame()->eventHandler()); | 1604 ViewportAnchor viewportAnchor(&mainFrameImpl()->frame()->eventHandler()); |
1605 if (shouldAnchorAndRescaleViewport) { | 1605 if (shouldAnchorAndRescaleViewport) { |
1606 viewportAnchor.setAnchor(view->visibleContentRect(), | 1606 viewportAnchor.setAnchor(view->visibleContentRect(), |
1607 FloatSize(viewportAnchorXCoord, viewportAnchorY
Coord)); | 1607 FloatSize(viewportAnchorXCoord, viewportAnchorY
Coord)); |
1608 } | 1608 } |
1609 | 1609 |
1610 { | 1610 { |
1611 // Avoids unnecessary invalidations while various bits of state in FastT
extAutosizer are updated. | 1611 // Avoids unnecessary invalidations while various bits of state in FastT
extAutosizer are updated. |
1612 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); | 1612 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
1613 | 1613 |
| 1614 m_pageScaleConstraintsSet.didChangeViewSize(m_size); |
| 1615 |
1614 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document(
)->viewportDescription()); | 1616 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document(
)->viewportDescription()); |
1615 updateMainFrameLayoutSize(); | 1617 updateMainFrameLayoutSize(); |
1616 | 1618 |
1617 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); | 1619 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); |
1618 if (agentPrivate) | 1620 if (agentPrivate) |
1619 agentPrivate->webViewResized(newSize); | 1621 agentPrivate->webViewResized(newSize); |
1620 | 1622 |
1621 // If the virtual viewport pinch mode is enabled, the main frame will be
resized | 1623 // If the virtual viewport pinch mode is enabled, the main frame will be
resized |
1622 // after layout so it can be sized to the contentsSize. | 1624 // after layout so it can be sized to the contentsSize. |
1623 if (!pinchVirtualViewportEnabled() && mainFrameImpl()->frameView()) | 1625 if (!pinchVirtualViewportEnabled() && mainFrameImpl()->frameView()) |
1624 mainFrameImpl()->frameView()->resize(m_size); | 1626 mainFrameImpl()->frameView()->resize(m_size); |
1625 | 1627 |
1626 if (pinchVirtualViewportEnabled()) | 1628 if (pinchVirtualViewportEnabled()) |
1627 page()->frameHost().pinchViewport().setSize(m_size); | 1629 page()->frameHost().pinchViewport().setSize(m_size); |
1628 | |
1629 } | 1630 } |
1630 | 1631 |
1631 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { | 1632 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { |
1632 // Relayout immediately to recalculate the minimum scale limit. | 1633 // Relayout immediately to recalculate the minimum scale limit. |
1633 if (view->needsLayout()) | 1634 if (view->needsLayout()) |
1634 view->layout(); | 1635 view->layout(); |
1635 | 1636 |
1636 if (shouldAnchorAndRescaleViewport) { | 1637 if (shouldAnchorAndRescaleViewport) { |
1637 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi
ze.width; | 1638 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi
ze.width; |
1638 float contentsWidthRatio = static_cast<float>(contentsSize().width()
) / oldContentsWidth; | 1639 float contentsWidthRatio = static_cast<float>(contentsSize().width()
) / oldContentsWidth; |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2899 return; | 2900 return; |
2900 FrameView* view = page()->mainFrame()->view(); | 2901 FrameView* view = page()->mainFrame()->view(); |
2901 | 2902 |
2902 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v
iewportDescription()); | 2903 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v
iewportDescription()); |
2903 m_pageScaleConstraintsSet.computeFinalConstraints(); | 2904 m_pageScaleConstraintsSet.computeFinalConstraints(); |
2904 | 2905 |
2905 if (settings()->shrinksViewportContentToFit() && settings()->viewportEnabled
() && !m_fixedLayoutSizeLock) { | 2906 if (settings()->shrinksViewportContentToFit() && settings()->viewportEnabled
() && !m_fixedLayoutSizeLock) { |
2906 int verticalScrollbarWidth = 0; | 2907 int verticalScrollbarWidth = 0; |
2907 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlaySc
rollbar()) | 2908 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlaySc
rollbar()) |
2908 verticalScrollbarWidth = view->verticalScrollbar()->width(); | 2909 verticalScrollbarWidth = view->verticalScrollbar()->width(); |
2909 m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(m_size, c
ontentsSize(), verticalScrollbarWidth); | 2910 m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(contentsS
ize(), verticalScrollbarWidth); |
2910 } | 2911 } |
2911 | 2912 |
2912 if (pinchVirtualViewportEnabled()) | 2913 if (pinchVirtualViewportEnabled()) |
2913 mainFrameImpl()->frameView()->resize(m_pageScaleConstraintsSet.mainFrame
Size(m_size, contentsSize())); | 2914 mainFrameImpl()->frameView()->resize(m_pageScaleConstraintsSet.mainFrame
Size(contentsSize())); |
2914 | 2915 |
2915 float newPageScaleFactor = pageScaleFactor(); | 2916 float newPageScaleFactor = pageScaleFactor(); |
2916 if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.fina
lConstraints().initialScale != -1) { | 2917 if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.fina
lConstraints().initialScale != -1) { |
2917 newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initia
lScale; | 2918 newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initia
lScale; |
2918 m_pageScaleConstraintsSet.setNeedsReset(false); | 2919 m_pageScaleConstraintsSet.setNeedsReset(false); |
2919 } | 2920 } |
2920 setPageScaleFactor(newPageScaleFactor); | 2921 setPageScaleFactor(newPageScaleFactor); |
2921 | 2922 |
2922 updateLayerTreeViewport(); | 2923 updateLayerTreeViewport(); |
2923 | 2924 |
(...skipping 29 matching lines...) Expand all Loading... |
2953 const int legacyWidthSnappingMagicNumber = 320; | 2954 const int legacyWidthSnappingMagicNumber = 320; |
2954 if (adjustedDescription.maxWidth.isFixed() && adjustedDescription.maxWid
th.value() <= legacyWidthSnappingMagicNumber) | 2955 if (adjustedDescription.maxWidth.isFixed() && adjustedDescription.maxWid
th.value() <= legacyWidthSnappingMagicNumber) |
2955 adjustedDescription.maxWidth = Length(DeviceWidth); | 2956 adjustedDescription.maxWidth = Length(DeviceWidth); |
2956 if (adjustedDescription.maxHeight.isFixed() && adjustedDescription.maxHe
ight.value() <= m_size.height) | 2957 if (adjustedDescription.maxHeight.isFixed() && adjustedDescription.maxHe
ight.value() <= m_size.height) |
2957 adjustedDescription.maxHeight = Length(DeviceHeight); | 2958 adjustedDescription.maxHeight = Length(DeviceHeight); |
2958 adjustedDescription.minWidth = adjustedDescription.maxWidth; | 2959 adjustedDescription.minWidth = adjustedDescription.maxWidth; |
2959 adjustedDescription.minHeight = adjustedDescription.maxHeight; | 2960 adjustedDescription.minHeight = adjustedDescription.maxHeight; |
2960 } | 2961 } |
2961 | 2962 |
2962 float oldInitialScale = m_pageScaleConstraintsSet.pageDefinedConstraints().i
nitialScale; | 2963 float oldInitialScale = m_pageScaleConstraintsSet.pageDefinedConstraints().i
nitialScale; |
2963 m_pageScaleConstraintsSet.updatePageDefinedConstraints(adjustedDescription,
m_size, defaultMinWidth); | 2964 m_pageScaleConstraintsSet.updatePageDefinedConstraints(adjustedDescription,
defaultMinWidth); |
2964 | 2965 |
2965 if (settingsImpl()->clobberUserAgentInitialScaleQuirk() | 2966 if (settingsImpl()->clobberUserAgentInitialScaleQuirk() |
2966 && m_pageScaleConstraintsSet.userAgentConstraints().initialScale != -1 | 2967 && m_pageScaleConstraintsSet.userAgentConstraints().initialScale != -1 |
2967 && m_pageScaleConstraintsSet.userAgentConstraints().initialScale * devic
eScaleFactor() <= 1) { | 2968 && m_pageScaleConstraintsSet.userAgentConstraints().initialScale * devic
eScaleFactor() <= 1) { |
2968 if (description.maxWidth == Length(DeviceWidth) | 2969 if (description.maxWidth == Length(DeviceWidth) |
2969 || (description.maxWidth.type() == Auto && m_pageScaleConstraintsSet
.pageDefinedConstraints().initialScale == 1.0f)) | 2970 || (description.maxWidth.type() == Auto && m_pageScaleConstraintsSet
.pageDefinedConstraints().initialScale == 1.0f)) |
2970 setInitialPageScaleOverride(-1); | 2971 setInitialPageScaleOverride(-1); |
2971 } | 2972 } |
2972 | 2973 |
2973 m_pageScaleConstraintsSet.adjustForAndroidWebViewQuirks(adjustedDescription,
m_size, defaultMinWidth.intValue(), deviceScaleFactor(), settingsImpl()->suppor
tDeprecatedTargetDensityDPI(), page()->settings().wideViewportQuirkEnabled(), pa
ge()->settings().useWideViewport(), page()->settings().loadWithOverviewMode(), s
ettingsImpl()->viewportMetaNonUserScalableQuirk()); | 2974 m_pageScaleConstraintsSet.adjustForAndroidWebViewQuirks(adjustedDescription,
defaultMinWidth.intValue(), deviceScaleFactor(), settingsImpl()->supportDepreca
tedTargetDensityDPI(), page()->settings().wideViewportQuirkEnabled(), page()->se
ttings().useWideViewport(), page()->settings().loadWithOverviewMode(), settingsI
mpl()->viewportMetaNonUserScalableQuirk()); |
2974 float newInitialScale = m_pageScaleConstraintsSet.pageDefinedConstraints().i
nitialScale; | 2975 float newInitialScale = m_pageScaleConstraintsSet.pageDefinedConstraints().i
nitialScale; |
2975 if (oldInitialScale != newInitialScale && newInitialScale != -1) { | 2976 if (oldInitialScale != newInitialScale && newInitialScale != -1) { |
2976 m_pageScaleConstraintsSet.setNeedsReset(true); | 2977 m_pageScaleConstraintsSet.setNeedsReset(true); |
2977 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 2978 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
2978 mainFrameImpl()->frameView()->setNeedsLayout(); | 2979 mainFrameImpl()->frameView()->setNeedsLayout(); |
2979 } | 2980 } |
2980 | 2981 |
2981 updateMainFrameLayoutSize(); | 2982 updateMainFrameLayoutSize(); |
2982 | 2983 |
2983 if (LocalFrame* frame = page()->mainFrame()) { | 2984 if (LocalFrame* frame = page()->mainFrame()) { |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3622 // If we finished a layout while in deferred commit mode, | 3623 // If we finished a layout while in deferred commit mode, |
3623 // that means it's time to start producing frames again so un-defer. | 3624 // that means it's time to start producing frames again so un-defer. |
3624 resumeTreeViewCommits(); | 3625 resumeTreeViewCommits(); |
3625 | 3626 |
3626 if (m_shouldAutoResize && mainFrameImpl()->frame() && mainFrameImpl()->frame
()->view()) { | 3627 if (m_shouldAutoResize && mainFrameImpl()->frame() && mainFrameImpl()->frame
()->view()) { |
3627 WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size()
; | 3628 WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size()
; |
3628 if (frameSize != m_size) { | 3629 if (frameSize != m_size) { |
3629 m_size = frameSize; | 3630 m_size = frameSize; |
3630 | 3631 |
3631 page()->frameHost().pinchViewport().setSize(m_size); | 3632 page()->frameHost().pinchViewport().setSize(m_size); |
| 3633 m_pageScaleConstraintsSet.didChangeViewSize(m_size); |
3632 | 3634 |
3633 m_client->didAutoResize(m_size); | 3635 m_client->didAutoResize(m_size); |
3634 sendResizeEventAndRepaint(); | 3636 sendResizeEventAndRepaint(); |
3635 } | 3637 } |
3636 } | 3638 } |
3637 | 3639 |
3638 if (m_pageScaleConstraintsSet.constraintsDirty()) | 3640 if (m_pageScaleConstraintsSet.constraintsDirty()) |
3639 refreshPageScaleFactorAfterLayout(); | 3641 refreshPageScaleFactorAfterLayout(); |
3640 | 3642 |
3641 m_client->didUpdateLayout(); | 3643 m_client->didUpdateLayout(); |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4124 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4126 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4125 | 4127 |
4126 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4128 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4127 return false; | 4129 return false; |
4128 | 4130 |
4129 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4131 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4130 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4132 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4131 } | 4133 } |
4132 | 4134 |
4133 } // namespace blink | 4135 } // namespace blink |
OLD | NEW |