| 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 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 | 1732 |
| 1733 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta
tionChanges() | 1733 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta
tionChanges() |
| 1734 && m_size.width && contentsSize().width() && newSize.width != m_size.wid
th && !m_fullscreenController->isFullscreen(); | 1734 && m_size.width && contentsSize().width() && newSize.width != m_size.wid
th && !m_fullscreenController->isFullscreen(); |
| 1735 float oldPageScaleFactor = pageScaleFactor(); | 1735 float oldPageScaleFactor = pageScaleFactor(); |
| 1736 float oldMinimumPageScaleFactor = minimumPageScaleFactor(); | 1736 float oldMinimumPageScaleFactor = minimumPageScaleFactor(); |
| 1737 | 1737 |
| 1738 m_size = newSize; | 1738 m_size = newSize; |
| 1739 | 1739 |
| 1740 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand
ler()); | 1740 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand
ler()); |
| 1741 if (shouldAnchorAndRescaleViewport) { | 1741 if (shouldAnchorAndRescaleViewport) { |
| 1742 viewportAnchor.setAnchor(view->visibleContentRect(), | 1742 viewportAnchor.setAnchor( |
| 1743 FloatSize(viewportAnchorXCoord, viewportAnchorY
Coord)); | 1743 view->visibleContentRect(), |
| 1744 visibleRectInDocument(), |
| 1745 FloatSize(viewportAnchorXCoord, viewportAnchorYCoord)); |
| 1744 } | 1746 } |
| 1745 | 1747 |
| 1746 // FIXME: TextAutosizer does not yet support out-of-process frames. | 1748 // FIXME: TextAutosizer does not yet support out-of-process frames. |
| 1747 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) | 1749 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) |
| 1748 { | 1750 { |
| 1749 // Avoids unnecessary invalidations while various bits of state in TextA
utosizer are updated. | 1751 // Avoids unnecessary invalidations while various bits of state in TextA
utosizer are updated. |
| 1750 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); | 1752 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
| 1751 performResize(); | 1753 performResize(); |
| 1752 } else { | 1754 } else { |
| 1753 performResize(); | 1755 performResize(); |
| 1754 } | 1756 } |
| 1755 | 1757 |
| 1756 if (settings()->viewportEnabled()) { | 1758 if (settings()->viewportEnabled()) { |
| 1757 // Relayout immediately to recalculate the minimum scale limit. | 1759 // Relayout immediately to recalculate the minimum scale limit. |
| 1758 if (view->needsLayout()) | 1760 if (view->needsLayout()) |
| 1759 view->layout(); | 1761 view->layout(); |
| 1760 | 1762 |
| 1761 if (shouldAnchorAndRescaleViewport) { | 1763 if (shouldAnchorAndRescaleViewport) { |
| 1762 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF
actor * minimumPageScaleFactor(); | 1764 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF
actor * minimumPageScaleFactor(); |
| 1763 IntSize scaledViewportSize = newSize; | 1765 newPageScaleFactor = clampPageScaleFactorToLimits(newPageScaleFactor
); |
| 1764 scaledViewportSize.scale(1 / newPageScaleFactor); | 1766 |
| 1765 setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin(
scaledViewportSize)); | 1767 FloatSize pinchViewportSize = FloatSize(newSize); |
| 1768 pinchViewportSize.scale(1 / newPageScaleFactor); |
| 1769 |
| 1770 IntPoint mainFrameOrigin; |
| 1771 FloatPoint pinchViewportOrigin; |
| 1772 viewportAnchor.computeOrigins(*view, pinchViewportSize, |
| 1773 mainFrameOrigin, pinchViewportOrigin); |
| 1774 scrollAndRescaleViewports(newPageScaleFactor, mainFrameOrigin, pinch
ViewportOrigin); |
| 1766 } | 1775 } |
| 1767 } | 1776 } |
| 1768 | 1777 |
| 1769 sendResizeEventAndRepaint(); | 1778 sendResizeEventAndRepaint(); |
| 1770 } | 1779 } |
| 1771 | 1780 |
| 1781 IntRect WebViewImpl::visibleRectInDocument() const |
| 1782 { |
| 1783 if (pinchVirtualViewportEnabled()) { |
| 1784 // Inner viewport in the document coordinates |
| 1785 return enclosedIntRect(page()->frameHost().pinchViewport().visibleRectIn
Document()); |
| 1786 } |
| 1787 |
| 1788 // Outer viewport in the document coordinates |
| 1789 return localFrameRootTemporary()->frameView()->visibleContentRect(); |
| 1790 } |
| 1791 |
| 1772 void WebViewImpl::willEndLiveResize() | 1792 void WebViewImpl::willEndLiveResize() |
| 1773 { | 1793 { |
| 1774 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1794 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
| 1775 mainFrameImpl()->frameView()->willEndLiveResize(); | 1795 mainFrameImpl()->frameView()->willEndLiveResize(); |
| 1776 | 1796 |
| 1777 LocalFrame* frame = mainFrameImpl()->frame(); | 1797 LocalFrame* frame = mainFrameImpl()->frame(); |
| 1778 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer
FromFrame(frame); | 1798 WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainer
FromFrame(frame); |
| 1779 if (pluginContainer) | 1799 if (pluginContainer) |
| 1780 pluginContainer->willEndLiveResize(); | 1800 pluginContainer->willEndLiveResize(); |
| 1781 } | 1801 } |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2967 WebFloatPoint WebViewImpl::pinchViewportOffset() const | 2987 WebFloatPoint WebViewImpl::pinchViewportOffset() const |
| 2968 { | 2988 { |
| 2969 ASSERT(page()); | 2989 ASSERT(page()); |
| 2970 | 2990 |
| 2971 if (!pinchVirtualViewportEnabled()) | 2991 if (!pinchVirtualViewportEnabled()) |
| 2972 return WebFloatPoint(); | 2992 return WebFloatPoint(); |
| 2973 | 2993 |
| 2974 return page()->frameHost().pinchViewport().visibleRect().location(); | 2994 return page()->frameHost().pinchViewport().visibleRect().location(); |
| 2975 } | 2995 } |
| 2976 | 2996 |
| 2997 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, |
| 2998 const IntPoint& mainFrameOrigin, |
| 2999 const FloatPoint& pinchViewportOrigin) |
| 3000 { |
| 3001 // Old way |
| 3002 if (!pinchVirtualViewportEnabled()) { |
| 3003 setPageScaleFactor(scaleFactor, mainFrameOrigin); |
| 3004 return; |
| 3005 } |
| 3006 |
| 3007 if (!page()) |
| 3008 return; |
| 3009 |
| 3010 if (!mainFrameImpl()) |
| 3011 return; |
| 3012 |
| 3013 FrameView * view = mainFrameImpl()->frameView(); |
| 3014 if (!view) |
| 3015 return; |
| 3016 |
| 3017 // Order is important: pinch viewport location is clamped based on |
| 3018 // main frame scroll position and pinch viewport scale. |
| 3019 |
| 3020 view->setScrollOffset(mainFrameOrigin); |
| 3021 |
| 3022 setPageScaleFactor(scaleFactor); |
| 3023 |
| 3024 page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin); |
| 3025 } |
| 3026 |
| 2977 void WebViewImpl::setPageScaleFactor(float scaleFactor) | 3027 void WebViewImpl::setPageScaleFactor(float scaleFactor) |
| 2978 { | 3028 { |
| 2979 ASSERT(page()); | 3029 ASSERT(page()); |
| 2980 | 3030 |
| 2981 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); | 3031 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); |
| 2982 if (scaleFactor == pageScaleFactor()) | 3032 if (scaleFactor == pageScaleFactor()) |
| 2983 return; | 3033 return; |
| 2984 | 3034 |
| 2985 // TODO(bokan): Old-style pinch path. Remove when we're migrated to | 3035 // TODO(bokan): Old-style pinch path. Remove when we're migrated to |
| 2986 // virtual viewport pinch. | 3036 // virtual viewport pinch. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3009 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); | 3059 newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor); |
| 3010 | 3060 |
| 3011 if (pinchVirtualViewportEnabled()) | 3061 if (pinchVirtualViewportEnabled()) |
| 3012 setPageScaleFactor(scaleFactor); | 3062 setPageScaleFactor(scaleFactor); |
| 3013 // Note, we don't set the offset in the new path. This method is going | 3063 // Note, we don't set the offset in the new path. This method is going |
| 3014 // away for the new pinch model so that's ok. | 3064 // away for the new pinch model so that's ok. |
| 3015 else | 3065 else |
| 3016 page()->setPageScaleFactor(scaleFactor, newScrollOffset); | 3066 page()->setPageScaleFactor(scaleFactor, newScrollOffset); |
| 3017 } | 3067 } |
| 3018 | 3068 |
| 3019 | |
| 3020 float WebViewImpl::deviceScaleFactor() const | 3069 float WebViewImpl::deviceScaleFactor() const |
| 3021 { | 3070 { |
| 3022 if (!page()) | 3071 if (!page()) |
| 3023 return 1; | 3072 return 1; |
| 3024 | 3073 |
| 3025 return page()->deviceScaleFactor(); | 3074 return page()->deviceScaleFactor(); |
| 3026 } | 3075 } |
| 3027 | 3076 |
| 3028 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) | 3077 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) |
| 3029 { | 3078 { |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4363 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4412 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
| 4364 | 4413 |
| 4365 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4414 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4366 return false; | 4415 return false; |
| 4367 | 4416 |
| 4368 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4417 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4369 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4418 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
| 4370 } | 4419 } |
| 4371 | 4420 |
| 4372 } // namespace blink | 4421 } // namespace blink |
| OLD | NEW |