| 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( | 1692 viewportAnchor.setAnchor(view->visibleContentRect(), |
| 1693 view->visibleContentRect(), | 1693 FloatSize(viewportAnchorXCoord, viewportAnchorY
Coord)); |
| 1694 visibleRectInDocument(), | |
| 1695 FloatSize(viewportAnchorXCoord, viewportAnchorYCoord)); | |
| 1696 } | 1694 } |
| 1697 | 1695 |
| 1698 // FIXME: TextAutosizer does not yet support out-of-process frames. | 1696 // FIXME: TextAutosizer does not yet support out-of-process frames. |
| 1699 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) | 1697 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) |
| 1700 { | 1698 { |
| 1701 // Avoids unnecessary invalidations while various bits of state in TextA
utosizer are updated. | 1699 // Avoids unnecessary invalidations while various bits of state in TextA
utosizer are updated. |
| 1702 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); | 1700 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
| 1703 performResize(); | 1701 performResize(); |
| 1704 } else { | 1702 } else { |
| 1705 performResize(); | 1703 performResize(); |
| 1706 } | 1704 } |
| 1707 | 1705 |
| 1708 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { | 1706 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { |
| 1709 // Relayout immediately to recalculate the minimum scale limit. | 1707 // Relayout immediately to recalculate the minimum scale limit. |
| 1710 if (view->needsLayout()) | 1708 if (view->needsLayout()) |
| 1711 view->layout(); | 1709 view->layout(); |
| 1712 | 1710 |
| 1713 if (shouldAnchorAndRescaleViewport) { | 1711 if (shouldAnchorAndRescaleViewport) { |
| 1714 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF
actor * minimumPageScaleFactor(); | 1712 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF
actor * minimumPageScaleFactor(); |
| 1715 newPageScaleFactor = clampPageScaleFactorToLimits(newPageScaleFactor
); | 1713 IntSize scaledViewportSize = newSize; |
| 1716 | 1714 scaledViewportSize.scale(1 / newPageScaleFactor); |
| 1717 FloatSize pinchViewportSize = FloatSize(newSize); | 1715 setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin(
scaledViewportSize)); |
| 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); | |
| 1725 } | 1716 } |
| 1726 } | 1717 } |
| 1727 | 1718 |
| 1728 sendResizeEventAndRepaint(); | 1719 sendResizeEventAndRepaint(); |
| 1729 } | 1720 } |
| 1730 | 1721 |
| 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 | |
| 1742 void WebViewImpl::willEndLiveResize() | 1722 void WebViewImpl::willEndLiveResize() |
| 1743 { | 1723 { |
| 1744 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1724 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
| 1745 mainFrameImpl()->frameView()->willEndLiveResize(); | 1725 mainFrameImpl()->frameView()->willEndLiveResize(); |
| 1746 | 1726 |
| 1747 LocalFrame* frame = mainFrameImpl()->frame(); | 1727 LocalFrame* frame = mainFrameImpl()->frame(); |
| 1748 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer
FromFrame(frame); | 1728 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer
FromFrame(frame); |
| 1749 if (pluginContainer) | 1729 if (pluginContainer) |
| 1750 pluginContainer->willEndLiveResize(); | 1730 pluginContainer->willEndLiveResize(); |
| 1751 } | 1731 } |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2931 WebFloatPoint WebViewImpl::pinchViewportOffset() const | 2911 WebFloatPoint WebViewImpl::pinchViewportOffset() const |
| 2932 { | 2912 { |
| 2933 ASSERT(page()); | 2913 ASSERT(page()); |
| 2934 | 2914 |
| 2935 if (!pinchVirtualViewportEnabled()) | 2915 if (!pinchVirtualViewportEnabled()) |
| 2936 return WebFloatPoint(); | 2916 return WebFloatPoint(); |
| 2937 | 2917 |
| 2938 return page()->frameHost().pinchViewport().visibleRect().location(); | 2918 return page()->frameHost().pinchViewport().visibleRect().location(); |
| 2939 } | 2919 } |
| 2940 | 2920 |
| 2941 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, | |
| 2942 const IntPoint& mainFrameOrigin, | |
| 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 view->setScrollOffset(mainFrameOrigin); | |
| 2965 | |
| 2966 setPageScaleFactor(scaleFactor); | |
| 2967 | |
| 2968 page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin); | |
| 2969 } | |
| 2970 | |
| 2971 void WebViewImpl::setPageScaleFactor(float scaleFactor) | 2921 void WebViewImpl::setPageScaleFactor(float scaleFactor) |
| 2972 { | 2922 { |
| 2973 ASSERT(page()); | 2923 ASSERT(page()); |
| 2974 | 2924 |
| 2975 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); | 2925 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); |
| 2976 if (scaleFactor == pageScaleFactor()) | 2926 if (scaleFactor == pageScaleFactor()) |
| 2977 return; | 2927 return; |
| 2978 | 2928 |
| 2979 // TODO(bokan): Old-style pinch path. Remove when we're migrated to | 2929 // TODO(bokan): Old-style pinch path. Remove when we're migrated to |
| 2980 // virtual viewport pinch. | 2930 // virtual viewport pinch. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3003 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); | 2953 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); |
| 3004 | 2954 |
| 3005 if (pinchVirtualViewportEnabled()) | 2955 if (pinchVirtualViewportEnabled()) |
| 3006 setPageScaleFactor(scaleFactor); | 2956 setPageScaleFactor(scaleFactor); |
| 3007 // Note, we don't set the offset in the new path. This method is going | 2957 // Note, we don't set the offset in the new path. This method is going |
| 3008 // away for the new pinch model so that's ok. | 2958 // away for the new pinch model so that's ok. |
| 3009 else | 2959 else |
| 3010 page()->setPageScaleFactor(scaleFactor, newScrollOffset); | 2960 page()->setPageScaleFactor(scaleFactor, newScrollOffset); |
| 3011 } | 2961 } |
| 3012 | 2962 |
| 2963 |
| 3013 float WebViewImpl::deviceScaleFactor() const | 2964 float WebViewImpl::deviceScaleFactor() const |
| 3014 { | 2965 { |
| 3015 if (!page()) | 2966 if (!page()) |
| 3016 return 1; | 2967 return 1; |
| 3017 | 2968 |
| 3018 return page()->deviceScaleFactor(); | 2969 return page()->deviceScaleFactor(); |
| 3019 } | 2970 } |
| 3020 | 2971 |
| 3021 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) | 2972 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) |
| 3022 { | 2973 { |
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4368 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4319 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
| 4369 | 4320 |
| 4370 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4321 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4371 return false; | 4322 return false; |
| 4372 | 4323 |
| 4373 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4324 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4374 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4325 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
| 4375 } | 4326 } |
| 4376 | 4327 |
| 4377 } // namespace blink | 4328 } // namespace blink |
| OLD | NEW |