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 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 // TODO: should we pass FloatRects instead of IntRects? |
| 1683 viewportAnchor.setAnchor(visibleRectInDocument(), outerViewportRectInDoc ument(), | |
| 1683 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); | 1684 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); |
| 1684 } | 1685 } |
| 1685 | 1686 |
| 1686 // FIXME: TextAutosizer does not yet support out-of-process frames. | 1687 // FIXME: TextAutosizer does not yet support out-of-process frames. |
| 1687 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) | 1688 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) { |
| 1688 { | |
| 1689 // Avoids unnecessary invalidations while various bits of state in TextA utosizer are updated. | 1689 // Avoids unnecessary invalidations while various bits of state in TextA utosizer are updated. |
| 1690 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); | 1690 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
| 1691 performResize(); | |
| 1692 } else { | |
| 1693 performResize(); | |
| 1694 } | 1691 } |
| 1695 | 1692 |
| 1693 performResize(); | |
|
bokan
2014/09/10 15:03:59
Why did this get moved? TextAutosizer::DeferUpdate
timav
2014/09/10 18:22:40
Oops. Thank you, I did not catch that. Will undo.
| |
| 1694 | |
| 1696 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { | 1695 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { |
| 1697 // Relayout immediately to recalculate the minimum scale limit. | 1696 // Relayout immediately to recalculate the minimum scale limit. |
| 1698 if (view->needsLayout()) | 1697 if (view->needsLayout()) |
| 1699 view->layout(); | 1698 view->layout(); |
| 1700 | 1699 |
| 1701 if (shouldAnchorAndRescaleViewport) { | 1700 if (shouldAnchorAndRescaleViewport) { |
| 1702 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF actor * minimumPageScaleFactor(); | 1701 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF actor * minimumPageScaleFactor(); |
| 1703 IntSize scaledViewportSize = newSize; | 1702 IntSize innerViewportSize = newSize; |
| 1704 scaledViewportSize.scale(1 / newPageScaleFactor); | 1703 innerViewportSize.scale(1 / newPageScaleFactor); |
| 1705 setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin( scaledViewportSize)); | 1704 |
| 1705 // in CSS pixel relative to the document | |
| 1706 IntPoint innerOrigin = viewportAnchor.computeInnerViewportOrigin(inn erViewportSize); | |
|
bokan
2014/09/10 15:03:59
Can you please rename as follows (here and other p
| |
| 1707 | |
| 1708 // in CSS pixel relative to the document | |
| 1709 IntPoint outerOrigin = viewportAnchor.computeOuterViewportOrigin( | |
| 1710 innerOrigin, outerViewportRectInDocument().size()); | |
| 1711 | |
| 1712 scrollAndRescaleViewports(newPageScaleFactor, innerOrigin, outerOrig in); | |
| 1706 } | 1713 } |
| 1707 } | 1714 } |
| 1708 | 1715 |
| 1709 sendResizeEventAndRepaint(); | 1716 sendResizeEventAndRepaint(); |
| 1710 } | 1717 } |
| 1711 | 1718 |
| 1719 IntRect WebViewImpl::visibleRectInDocument() const | |
| 1720 { | |
| 1721 if (pinchVirtualViewportEnabled()) { | |
| 1722 // Inner viewport in the document coordinates | |
| 1723 return enclosedIntRect(page()->frameHost().pinchViewport().visibleRectIn Document()); | |
| 1724 } | |
| 1725 | |
| 1726 // Outer viewport in the document coordinates | |
| 1727 return localFrameRootTemporary()->frameView()->visibleContentRect(); | |
| 1728 } | |
| 1729 | |
| 1730 IntRect WebViewImpl::outerViewportRectInDocument() const | |
|
aelias_OOO_until_Jul13
2014/09/10 01:46:25
This method doesn't seem to save much code duplica
timav
2014/09/10 18:22:40
Acknowledged.
| |
| 1731 { | |
| 1732 // Same as the inner viewport if the virtual viewport is disabled | |
| 1733 return localFrameRootTemporary()->frameView()->visibleContentRect(); | |
| 1734 } | |
| 1735 | |
| 1712 void WebViewImpl::willEndLiveResize() | 1736 void WebViewImpl::willEndLiveResize() |
| 1713 { | 1737 { |
| 1714 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1738 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
| 1715 mainFrameImpl()->frameView()->willEndLiveResize(); | 1739 mainFrameImpl()->frameView()->willEndLiveResize(); |
| 1716 | 1740 |
| 1717 LocalFrame* frame = mainFrameImpl()->frame(); | 1741 LocalFrame* frame = mainFrameImpl()->frame(); |
| 1718 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer FromFrame(frame); | 1742 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer FromFrame(frame); |
| 1719 if (pluginContainer) | 1743 if (pluginContainer) |
| 1720 pluginContainer->willEndLiveResize(); | 1744 pluginContainer->willEndLiveResize(); |
| 1721 } | 1745 } |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2915 | 2939 |
| 2916 page()->frameHost().pinchViewport().setScale(scaleFactor); | 2940 page()->frameHost().pinchViewport().setScale(scaleFactor); |
| 2917 deviceOrPageScaleFactorChanged(); | 2941 deviceOrPageScaleFactorChanged(); |
| 2918 } | 2942 } |
| 2919 | 2943 |
| 2920 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin) | 2944 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin) |
| 2921 { | 2945 { |
| 2922 updateMainFrameScrollPosition(origin, false); | 2946 updateMainFrameScrollPosition(origin, false); |
| 2923 } | 2947 } |
| 2924 | 2948 |
| 2949 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, | |
| 2950 const IntPoint & innerViewportOrigin, | |
|
aelias_OOO_until_Jul13
2014/09/10 01:46:25
Please make these arguments:
const IntPoint& outer
timav
2014/09/10 18:22:40
Acknowledged.
| |
| 2951 const IntPoint & outerViewportOrigin) | |
| 2952 { | |
| 2953 // Old way | |
| 2954 if (!pinchVirtualViewportEnabled()) { | |
| 2955 setPageScaleFactor(scaleFactor, innerViewportOrigin); | |
| 2956 return; | |
| 2957 } | |
| 2958 | |
| 2959 if (!page()) | |
| 2960 return; | |
| 2961 | |
| 2962 if (!mainFrameImpl()) | |
| 2963 return; | |
| 2964 | |
| 2965 FrameView * view = mainFrameImpl()->frameView(); | |
| 2966 if (!view) | |
| 2967 return; | |
| 2968 | |
| 2969 // Set outer viewport position. | |
| 2970 view->scrollTo(toIntSize(outerViewportOrigin)); | |
|
bokan
2014/09/10 15:03:58
Use WebViewImpl::updateMainFrameScrollPosition(Int
timav
2014/09/10 18:22:40
Yes, I missed that comment. The ScrollView::scroll
bokan
2014/09/10 18:26:40
Yup, highly easy to misuse. If you don't mind, go
| |
| 2971 | |
| 2972 // Set inner viewport position. | |
| 2973 IntSize innerViewportInOuter = innerViewportOrigin - outerViewportOrigin; | |
| 2974 page()->frameHost().pinchViewport().setLocation(IntPoint(innerViewportInOute r)); | |
| 2975 | |
| 2976 setPageScaleFactor(scaleFactor); | |
| 2977 } | |
| 2978 | |
| 2925 void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin) | 2979 void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin) |
| 2926 { | 2980 { |
| 2927 if (!page()) | 2981 if (!page()) |
| 2928 return; | 2982 return; |
| 2929 | 2983 |
| 2930 IntPoint newScrollOffset = origin; | 2984 IntPoint newScrollOffset = origin; |
| 2931 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); | 2985 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); |
| 2932 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); | 2986 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); |
| 2933 | 2987 |
| 2934 if (pinchVirtualViewportEnabled()) | 2988 if (pinchVirtualViewportEnabled()) |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4273 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4327 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
| 4274 | 4328 |
| 4275 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4329 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4276 return false; | 4330 return false; |
| 4277 | 4331 |
| 4278 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4332 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4279 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4333 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4280 } | 4334 } |
| 4281 | 4335 |
| 4282 } // namespace blink | 4336 } // namespace blink |
| OLD | NEW |