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 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1682 | 1682 |
| 1683 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges() | 1683 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges() |
| 1684 && m_size.width && contentsSize().width() && newSize.width != m_size.wid th && !m_fullscreenController->isFullscreen(); | 1684 && m_size.width && contentsSize().width() && newSize.width != m_size.wid th && !m_fullscreenController->isFullscreen(); |
| 1685 float oldPageScaleFactor = pageScaleFactor(); | 1685 float oldPageScaleFactor = pageScaleFactor(); |
| 1686 float oldMinimumPageScaleFactor = minimumPageScaleFactor(); | 1686 float oldMinimumPageScaleFactor = minimumPageScaleFactor(); |
| 1687 | 1687 |
| 1688 m_size = newSize; | 1688 m_size = newSize; |
| 1689 | 1689 |
| 1690 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand ler()); | 1690 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand ler()); |
| 1691 if (shouldAnchorAndRescaleViewport) { | 1691 if (shouldAnchorAndRescaleViewport) { |
| 1692 viewportAnchor.setAnchor(view->visibleContentRect(), | 1692 viewportAnchor.setAnchor( |
| 1693 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); | 1693 view->visibleContentRect(), |
| 1694 visibleRectInDocument(), | |
| 1695 FloatSize(viewportAnchorXCoord, viewportAnchorYCoord)); | |
| 1694 } | 1696 } |
| 1695 | 1697 |
| 1696 // FIXME: TextAutosizer does not yet support out-of-process frames. | 1698 // FIXME: TextAutosizer does not yet support out-of-process frames. |
| 1697 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) | 1699 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) |
| 1698 { | 1700 { |
| 1699 // Avoids unnecessary invalidations while various bits of state in TextA utosizer are updated. | 1701 // Avoids unnecessary invalidations while various bits of state in TextA utosizer are updated. |
| 1700 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); | 1702 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
| 1701 performResize(); | 1703 performResize(); |
| 1702 } else { | 1704 } else { |
| 1703 performResize(); | 1705 performResize(); |
| 1704 } | 1706 } |
| 1705 | 1707 |
| 1706 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { | 1708 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { |
| 1707 // Relayout immediately to recalculate the minimum scale limit. | 1709 // Relayout immediately to recalculate the minimum scale limit. |
| 1708 if (view->needsLayout()) | 1710 if (view->needsLayout()) |
| 1709 view->layout(); | 1711 view->layout(); |
| 1710 | 1712 |
| 1711 if (shouldAnchorAndRescaleViewport) { | 1713 if (shouldAnchorAndRescaleViewport) { |
| 1712 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF actor * minimumPageScaleFactor(); | 1714 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF actor * minimumPageScaleFactor(); |
| 1713 IntSize scaledViewportSize = newSize; | 1715 newPageScaleFactor = clampPageScaleFactorToLimits(newPageScaleFactor ); |
| 1714 scaledViewportSize.scale(1 / newPageScaleFactor); | 1716 |
| 1715 setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin( scaledViewportSize)); | 1717 FloatSize pinchViewportSize = FloatSize(newSize); |
|
aelias_OOO_until_Jul13
2014/09/17 05:16:36
nit: second FloatSize() shouldn't be necessary, pl
timav
2014/09/17 17:54:45
The cast is required to convert WebSize -> IntSize
| |
| 1718 pinchViewportSize.scale(1 / newPageScaleFactor); | |
| 1719 | |
| 1720 IntPoint mainFrameOrigin; | |
| 1721 FloatPoint pinchViewportOrigin; | |
| 1722 viewportAnchor.computeOrigins(*view, pinchViewportSize, | |
| 1723 &mainFrameOrigin, &pinchViewportOrigin); | |
| 1724 scrollAndRescaleViewports(newPageScaleFactor, mainFrameOrigin, pinch ViewportOrigin); | |
| 1716 } | 1725 } |
| 1717 } | 1726 } |
| 1718 | 1727 |
| 1719 sendResizeEventAndRepaint(); | 1728 sendResizeEventAndRepaint(); |
| 1720 } | 1729 } |
| 1721 | 1730 |
| 1731 IntRect WebViewImpl::visibleRectInDocument() const | |
| 1732 { | |
| 1733 if (pinchVirtualViewportEnabled()) { | |
| 1734 // Inner viewport in the document coordinates | |
| 1735 return enclosedIntRect(page()->frameHost().pinchViewport().visibleRectIn Document()); | |
| 1736 } | |
| 1737 | |
| 1738 // Outer viewport in the document coordinates | |
| 1739 return localFrameRootTemporary()->frameView()->visibleContentRect(); | |
| 1740 } | |
| 1741 | |
| 1722 void WebViewImpl::willEndLiveResize() | 1742 void WebViewImpl::willEndLiveResize() |
| 1723 { | 1743 { |
| 1724 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1744 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
| 1725 mainFrameImpl()->frameView()->willEndLiveResize(); | 1745 mainFrameImpl()->frameView()->willEndLiveResize(); |
| 1726 | 1746 |
| 1727 LocalFrame* frame = mainFrameImpl()->frame(); | 1747 LocalFrame* frame = mainFrameImpl()->frame(); |
| 1728 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer FromFrame(frame); | 1748 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer FromFrame(frame); |
| 1729 if (pluginContainer) | 1749 if (pluginContainer) |
| 1730 pluginContainer->willEndLiveResize(); | 1750 pluginContainer->willEndLiveResize(); |
| 1731 } | 1751 } |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2911 WebFloatPoint WebViewImpl::pinchViewportOffset() const | 2931 WebFloatPoint WebViewImpl::pinchViewportOffset() const |
| 2912 { | 2932 { |
| 2913 ASSERT(page()); | 2933 ASSERT(page()); |
| 2914 | 2934 |
| 2915 if (!pinchVirtualViewportEnabled()) | 2935 if (!pinchVirtualViewportEnabled()) |
| 2916 return WebFloatPoint(); | 2936 return WebFloatPoint(); |
| 2917 | 2937 |
| 2918 return page()->frameHost().pinchViewport().visibleRect().location(); | 2938 return page()->frameHost().pinchViewport().visibleRect().location(); |
| 2919 } | 2939 } |
| 2920 | 2940 |
| 2941 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, | |
| 2942 const IntPoint & mainFrameOrigin, | |
|
aelias_OOO_until_Jul13
2014/09/17 05:16:36
nit: "IntPoint& mainFrameOrigin" (no space before)
timav
2014/09/17 17:54:45
Done.
| |
| 2943 const FloatPoint & pinchViewportOrigin) | |
| 2944 { | |
| 2945 // Old way | |
| 2946 if (!pinchVirtualViewportEnabled()) { | |
| 2947 setPageScaleFactor(scaleFactor, mainFrameOrigin); | |
| 2948 return; | |
| 2949 } | |
| 2950 | |
| 2951 if (!page()) | |
| 2952 return; | |
| 2953 | |
| 2954 if (!mainFrameImpl()) | |
| 2955 return; | |
| 2956 | |
| 2957 FrameView * view = mainFrameImpl()->frameView(); | |
| 2958 if (!view) | |
| 2959 return; | |
| 2960 | |
| 2961 // Order is important: pinch viewport location is clamped based on | |
| 2962 // main frame scroll position and pinch viewport scale. | |
| 2963 | |
| 2964 // Set outer viewport position. | |
|
aelias_OOO_until_Jul13
2014/09/17 05:16:36
Please delete the three comments starting here. B
timav
2014/09/17 17:54:45
Done.
| |
| 2965 view->setScrollOffset(mainFrameOrigin); | |
| 2966 | |
| 2967 // Set the scale. | |
| 2968 setPageScaleFactor(scaleFactor); | |
| 2969 | |
| 2970 // Set inner viewport position. | |
| 2971 page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin); | |
| 2972 } | |
| 2973 | |
| 2921 void WebViewImpl::setPageScaleFactor(float scaleFactor) | 2974 void WebViewImpl::setPageScaleFactor(float scaleFactor) |
| 2922 { | 2975 { |
| 2923 ASSERT(page()); | 2976 ASSERT(page()); |
| 2924 | 2977 |
| 2925 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); | 2978 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); |
| 2926 if (scaleFactor == pageScaleFactor()) | 2979 if (scaleFactor == pageScaleFactor()) |
| 2927 return; | 2980 return; |
| 2928 | 2981 |
| 2929 // TODO(bokan): Old-style pinch path. Remove when we're migrated to | 2982 // TODO(bokan): Old-style pinch path. Remove when we're migrated to |
| 2930 // virtual viewport pinch. | 2983 // virtual viewport pinch. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2953 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); | 3006 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); |
| 2954 | 3007 |
| 2955 if (pinchVirtualViewportEnabled()) | 3008 if (pinchVirtualViewportEnabled()) |
| 2956 setPageScaleFactor(scaleFactor); | 3009 setPageScaleFactor(scaleFactor); |
| 2957 // Note, we don't set the offset in the new path. This method is going | 3010 // Note, we don't set the offset in the new path. This method is going |
| 2958 // away for the new pinch model so that's ok. | 3011 // away for the new pinch model so that's ok. |
| 2959 else | 3012 else |
| 2960 page()->setPageScaleFactor(scaleFactor, newScrollOffset); | 3013 page()->setPageScaleFactor(scaleFactor, newScrollOffset); |
| 2961 } | 3014 } |
| 2962 | 3015 |
| 2963 | |
|
aelias_OOO_until_Jul13
2014/09/17 05:16:36
nit: unnecessary newline
timav
2014/09/17 17:54:45
Newline removed in the new version.
| |
| 2964 float WebViewImpl::deviceScaleFactor() const | 3016 float WebViewImpl::deviceScaleFactor() const |
| 2965 { | 3017 { |
| 2966 if (!page()) | 3018 if (!page()) |
| 2967 return 1; | 3019 return 1; |
| 2968 | 3020 |
| 2969 return page()->deviceScaleFactor(); | 3021 return page()->deviceScaleFactor(); |
| 2970 } | 3022 } |
| 2971 | 3023 |
| 2972 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) | 3024 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) |
| 2973 { | 3025 { |
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4319 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4371 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
| 4320 | 4372 |
| 4321 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4373 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4322 return false; | 4374 return false; |
| 4323 | 4375 |
| 4324 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4376 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4325 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4377 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4326 } | 4378 } |
| 4327 | 4379 |
| 4328 } // namespace blink | 4380 } // namespace blink |
| OLD | NEW |