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 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1672 | 1672 |
1673 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges() | 1673 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges() |
1674 && m_size.width && contentsSize().width() && newSize.width != m_size.wid th && !m_fullscreenController->isFullscreen(); | 1674 && m_size.width && contentsSize().width() && newSize.width != m_size.wid th && !m_fullscreenController->isFullscreen(); |
1675 float oldPageScaleFactor = pageScaleFactor(); | 1675 float oldPageScaleFactor = pageScaleFactor(); |
1676 float oldMinimumPageScaleFactor = minimumPageScaleFactor(); | 1676 float oldMinimumPageScaleFactor = minimumPageScaleFactor(); |
1677 | 1677 |
1678 m_size = newSize; | 1678 m_size = newSize; |
1679 | 1679 |
1680 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand ler()); | 1680 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand ler()); |
1681 if (shouldAnchorAndRescaleViewport) { | 1681 if (shouldAnchorAndRescaleViewport) { |
1682 viewportAnchor.setAnchor(view->visibleContentRect(), | 1682 viewportAnchor.setAnchor( |
1683 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); | 1683 localFrameRootTemporary()->frameView()->visibleContentRect(), |
bokan
2014/09/12 20:53:07
Just use the local 'view' as before.
timav
2014/09/12 23:33:35
Acknowledged.
timav
2014/09/15 20:04:35
Done.
| |
1684 visibleRectInDocument(), | |
1685 FloatSize(viewportAnchorXCoord, viewportAnchorYCoord)); | |
1684 } | 1686 } |
1685 | 1687 |
1686 // FIXME: TextAutosizer does not yet support out-of-process frames. | 1688 // FIXME: TextAutosizer does not yet support out-of-process frames. |
1687 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) | 1689 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) |
1688 { | 1690 { |
1689 // Avoids unnecessary invalidations while various bits of state in TextA utosizer are updated. | 1691 // Avoids unnecessary invalidations while various bits of state in TextA utosizer are updated. |
1690 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); | 1692 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
1691 performResize(); | 1693 performResize(); |
1692 } else { | 1694 } else { |
1693 performResize(); | 1695 performResize(); |
1694 } | 1696 } |
1695 | 1697 |
1696 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { | 1698 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { |
1697 // Relayout immediately to recalculate the minimum scale limit. | 1699 // Relayout immediately to recalculate the minimum scale limit. |
1698 if (view->needsLayout()) | 1700 if (view->needsLayout()) |
1699 view->layout(); | 1701 view->layout(); |
1700 | 1702 |
1701 if (shouldAnchorAndRescaleViewport) { | 1703 if (shouldAnchorAndRescaleViewport) { |
1702 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF actor * minimumPageScaleFactor(); | 1704 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF actor * minimumPageScaleFactor(); |
1703 IntSize scaledViewportSize = newSize; | 1705 newPageScaleFactor = clampPageScaleFactorToLimits(newPageScaleFactor ); |
1704 scaledViewportSize.scale(1 / newPageScaleFactor); | 1706 |
1705 setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin( scaledViewportSize)); | 1707 IntSize pinchViewportSize = newSize; |
1708 pinchViewportSize.scale(1 / newPageScaleFactor); | |
1709 | |
1710 IntSize mainFrameSize = localFrameRootTemporary()->frameView()->visi bleContentRect().size(); | |
bokan
2014/09/12 20:53:07
ditto here, localFrameRootTemporary()->frameView()
timav
2014/09/12 23:33:35
Acknowledged.
timav
2014/09/15 20:04:35
Done.
| |
1711 | |
1712 IntPoint mainFrameOrigin; | |
1713 FloatPoint pinchViewportOrigin; | |
1714 viewportAnchor.computeOrigins(mainFrameSize, pinchViewportSize, &mai nFrameOrigin, &pinchViewportOrigin); | |
1715 scrollAndRescaleViewports(newPageScaleFactor, mainFrameOrigin, pinch ViewportOrigin); | |
1706 } | 1716 } |
1707 } | 1717 } |
1708 | 1718 |
1709 sendResizeEventAndRepaint(); | 1719 sendResizeEventAndRepaint(); |
1710 } | 1720 } |
1711 | 1721 |
1722 IntRect WebViewImpl::visibleRectInDocument() const | |
1723 { | |
1724 if (pinchVirtualViewportEnabled()) { | |
1725 // Inner viewport in the document coordinates | |
1726 return enclosedIntRect(page()->frameHost().pinchViewport().visibleRectIn Document()); | |
1727 } | |
1728 | |
1729 // Outer viewport in the document coordinates | |
1730 return localFrameRootTemporary()->frameView()->visibleContentRect(); | |
1731 } | |
1732 | |
1712 void WebViewImpl::willEndLiveResize() | 1733 void WebViewImpl::willEndLiveResize() |
1713 { | 1734 { |
1714 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1735 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
1715 mainFrameImpl()->frameView()->willEndLiveResize(); | 1736 mainFrameImpl()->frameView()->willEndLiveResize(); |
1716 | 1737 |
1717 LocalFrame* frame = mainFrameImpl()->frame(); | 1738 LocalFrame* frame = mainFrameImpl()->frame(); |
1718 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer FromFrame(frame); | 1739 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer FromFrame(frame); |
1719 if (pluginContainer) | 1740 if (pluginContainer) |
1720 pluginContainer->willEndLiveResize(); | 1741 pluginContainer->willEndLiveResize(); |
1721 } | 1742 } |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2890 WebFloatPoint WebViewImpl::pinchViewportOffset() const | 2911 WebFloatPoint WebViewImpl::pinchViewportOffset() const |
2891 { | 2912 { |
2892 ASSERT(page()); | 2913 ASSERT(page()); |
2893 | 2914 |
2894 if (!pinchVirtualViewportEnabled()) | 2915 if (!pinchVirtualViewportEnabled()) |
2895 return WebFloatPoint(); | 2916 return WebFloatPoint(); |
2896 | 2917 |
2897 return page()->frameHost().pinchViewport().visibleRect().location(); | 2918 return page()->frameHost().pinchViewport().visibleRect().location(); |
2898 } | 2919 } |
2899 | 2920 |
2921 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, | |
2922 const IntPoint & mainFrameOrigin, | |
2923 const FloatPoint & pinchViewportOrigin) | |
2924 { | |
2925 // Old way | |
2926 if (!pinchVirtualViewportEnabled()) { | |
2927 setPageScaleFactor(scaleFactor, mainFrameOrigin); | |
2928 return; | |
2929 } | |
2930 | |
2931 if (!page()) | |
2932 return; | |
2933 | |
2934 if (!mainFrameImpl()) | |
2935 return; | |
2936 | |
2937 FrameView * view = mainFrameImpl()->frameView(); | |
2938 if (!view) | |
2939 return; | |
2940 | |
2941 // Order is important: pinch viewport location is clamped based on | |
2942 // main frame scroll position and pinch viewport scale. | |
bokan
2014/09/12 20:53:07
The inner viewport is always set relative to the o
timav
2014/09/12 23:33:35
I think you are right for the outer viewport, i.e.
bokan
2014/09/15 15:36:35
You're right, I misspoke, the scale needs to be ap
timav
2014/09/15 20:04:35
Done.
| |
2943 | |
2944 // Set outer viewport position. | |
2945 view->setScrollOffset(mainFrameOrigin); | |
2946 | |
2947 // Set the scale. | |
2948 setPageScaleFactor(scaleFactor); | |
2949 | |
2950 // Set inner viewport position. | |
2951 page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin); | |
2952 } | |
2953 | |
2900 void WebViewImpl::setPageScaleFactor(float scaleFactor) | 2954 void WebViewImpl::setPageScaleFactor(float scaleFactor) |
2901 { | 2955 { |
2902 ASSERT(page()); | 2956 ASSERT(page()); |
2903 | 2957 |
2904 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); | 2958 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); |
2905 if (scaleFactor == pageScaleFactor()) | 2959 if (scaleFactor == pageScaleFactor()) |
2906 return; | 2960 return; |
2907 | 2961 |
2908 // TODO(bokan): Old-style pinch path. Remove when we're migrated to | 2962 // TODO(bokan): Old-style pinch path. Remove when we're migrated to |
2909 // virtual viewport pinch. | 2963 // virtual viewport pinch. |
(...skipping 22 matching lines...) Expand all Loading... | |
2932 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); | 2986 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); |
2933 | 2987 |
2934 if (pinchVirtualViewportEnabled()) | 2988 if (pinchVirtualViewportEnabled()) |
2935 setPageScaleFactor(scaleFactor); | 2989 setPageScaleFactor(scaleFactor); |
2936 // Note, we don't set the offset in the new path. This method is going | 2990 // Note, we don't set the offset in the new path. This method is going |
2937 // away for the new pinch model so that's ok. | 2991 // away for the new pinch model so that's ok. |
2938 else | 2992 else |
2939 page()->setPageScaleFactor(scaleFactor, newScrollOffset); | 2993 page()->setPageScaleFactor(scaleFactor, newScrollOffset); |
2940 } | 2994 } |
2941 | 2995 |
2942 | |
2943 float WebViewImpl::deviceScaleFactor() const | 2996 float WebViewImpl::deviceScaleFactor() const |
2944 { | 2997 { |
2945 if (!page()) | 2998 if (!page()) |
2946 return 1; | 2999 return 1; |
2947 | 3000 |
2948 return page()->deviceScaleFactor(); | 3001 return page()->deviceScaleFactor(); |
2949 } | 3002 } |
2950 | 3003 |
2951 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) | 3004 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) |
2952 { | 3005 { |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4273 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4326 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
4274 | 4327 |
4275 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4328 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4276 return false; | 4329 return false; |
4277 | 4330 |
4278 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4331 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4279 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4332 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
4280 } | 4333 } |
4281 | 4334 |
4282 } // namespace blink | 4335 } // namespace blink |
OLD | NEW |