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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 | 1633 |
1634 void WebViewImpl::resize(const WebSize& newSize) | 1634 void WebViewImpl::resize(const WebSize& newSize) |
1635 { | 1635 { |
1636 if (m_shouldAutoResize || m_size == newSize) | 1636 if (m_shouldAutoResize || m_size == newSize) |
1637 return; | 1637 return; |
1638 | 1638 |
1639 FrameView* view = localFrameRootTemporary()->frameView(); | 1639 FrameView* view = localFrameRootTemporary()->frameView(); |
1640 if (!view) | 1640 if (!view) |
1641 return; | 1641 return; |
1642 | 1642 |
1643 WebSize oldSize = m_size; | 1643 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta
tionChanges() |
| 1644 && m_size.width && contentsSize().width() && newSize.width != m_size.wid
th && !m_fullscreenController->isFullscreen(); |
1644 float oldPageScaleFactor = pageScaleFactor(); | 1645 float oldPageScaleFactor = pageScaleFactor(); |
1645 int oldContentsWidth = contentsSize().width(); | 1646 float oldMinimumPageScaleFactor = minimumPageScaleFactor(); |
1646 | 1647 |
1647 m_size = newSize; | 1648 m_size = newSize; |
1648 | 1649 |
1649 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta
tionChanges() | |
1650 && oldSize.width && oldContentsWidth && newSize.width != oldSize.width &
& !m_fullscreenController->isFullscreen(); | |
1651 | |
1652 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand
ler()); | 1650 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand
ler()); |
1653 if (shouldAnchorAndRescaleViewport) { | 1651 if (shouldAnchorAndRescaleViewport) { |
1654 viewportAnchor.setAnchor(view->visibleContentRect(), | 1652 viewportAnchor.setAnchor(view->visibleContentRect(), |
1655 FloatSize(viewportAnchorXCoord, viewportAnchorY
Coord)); | 1653 FloatSize(viewportAnchorXCoord, viewportAnchorY
Coord)); |
1656 } | 1654 } |
1657 | 1655 |
1658 // FIXME: FastTextAutosizer does not yet support out-of-process frames. | 1656 // FIXME: FastTextAutosizer does not yet support out-of-process frames. |
1659 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) | 1657 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()) |
1660 { | 1658 { |
1661 // Avoids unnecessary invalidations while various bits of state in FastT
extAutosizer are updated. | 1659 // Avoids unnecessary invalidations while various bits of state in FastT
extAutosizer are updated. |
1662 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); | 1660 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); |
1663 performResize(); | 1661 performResize(); |
1664 } else { | 1662 } else { |
1665 performResize(); | 1663 performResize(); |
1666 } | 1664 } |
1667 | 1665 |
1668 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { | 1666 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { |
1669 // Relayout immediately to recalculate the minimum scale limit. | 1667 // Relayout immediately to recalculate the minimum scale limit. |
1670 if (view->needsLayout()) | 1668 if (view->needsLayout()) |
1671 view->layout(); | 1669 view->layout(); |
1672 | 1670 |
1673 if (shouldAnchorAndRescaleViewport) { | 1671 if (shouldAnchorAndRescaleViewport) { |
1674 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi
ze.width; | 1672 float newPageScaleFactor = oldPageScaleFactor / oldMinimumPageScaleF
actor * minimumPageScaleFactor(); |
1675 float contentsWidthRatio = static_cast<float>(contentsSize().width()
) / oldContentsWidth; | 1673 IntSize scaledViewportSize = newSize; |
1676 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio; | 1674 scaledViewportSize.scale(1 / newPageScaleFactor); |
1677 | 1675 setPageScaleFactor(newPageScaleFactor, viewportAnchor.computeOrigin(
scaledViewportSize)); |
1678 IntSize viewportSize = view->visibleContentRect().size(); | |
1679 if (scaleMultiplier != 1) { | |
1680 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier; | |
1681 viewportSize.scale(pageScaleFactor() / newPageScaleFactor); | |
1682 IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(v
iewportSize); | |
1683 setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale); | |
1684 } else { | |
1685 IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnc
hor.computeOrigin(viewportSize), pageScaleFactor()); | |
1686 updateMainFrameScrollPosition(scrollOffsetAtNewScale, false); | |
1687 } | |
1688 } | 1676 } |
1689 } | 1677 } |
1690 | 1678 |
1691 sendResizeEventAndRepaint(); | 1679 sendResizeEventAndRepaint(); |
1692 } | 1680 } |
1693 | 1681 |
1694 void WebViewImpl::willEndLiveResize() | 1682 void WebViewImpl::willEndLiveResize() |
1695 { | 1683 { |
1696 if (mainFrameImpl() && mainFrameImpl()->frameView()) | 1684 if (mainFrameImpl() && mainFrameImpl()->frameView()) |
1697 mainFrameImpl()->frameView()->willEndLiveResize(); | 1685 mainFrameImpl()->frameView()->willEndLiveResize(); |
(...skipping 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4251 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4239 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4252 | 4240 |
4253 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4241 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4254 return false; | 4242 return false; |
4255 | 4243 |
4256 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4244 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4257 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4245 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4258 } | 4246 } |
4259 | 4247 |
4260 } // namespace blink | 4248 } // namespace blink |
OLD | NEW |