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