Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 380303003: Enable resize and layout for frames with RemoteFrame ancestors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed DeferUpdatePageInfo problem Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 } 1582 }
1583 1583
1584 void WebViewImpl::resizePinchViewport(const WebSize& newSize) 1584 void WebViewImpl::resizePinchViewport(const WebSize& newSize)
1585 { 1585 {
1586 if (!pinchVirtualViewportEnabled()) 1586 if (!pinchVirtualViewportEnabled())
1587 return; 1587 return;
1588 1588
1589 page()->frameHost().pinchViewport().setSize(newSize); 1589 page()->frameHost().pinchViewport().setSize(newSize);
1590 } 1590 }
1591 1591
1592 WebLocalFrameImpl* WebViewImpl::localFrameRootTemporary()
1593 {
1594 // FIXME: This is a temporary method that finds the first localFrame in a tr aversal.
1595 // This is equivalent to mainFrame() if the mainFrame is in-process. We need to create
1596 // separate WebWidgets to be created by RenderWidgets, which are associated with *all*
1597 // local frame roots, not just the first one in the tree. Until then, this l imits us
1598 // to having only one functioning connected LocalFrame subtree per process.
1599 for (WebCore::Frame* frame = page()->mainFrame(); frame; frame = frame->tree ().traverseNext()) {
1600 if (frame->isLocalRoot())
1601 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame));
1602 }
1603 return 0;
1604 }
1605
1606 void WebViewImpl::performResize()
1607 {
1608 m_pageScaleConstraintsSet.didChangeViewSize(m_size);
1609
1610 updatePageDefinedViewportConstraints(localFrameRootTemporary()->frame()->doc ument()->viewportDescription());
1611 updateMainFrameLayoutSize();
1612
1613 // If the virtual viewport pinch mode is enabled, the main frame will be res ized
1614 // after layout so it can be sized to the contentsSize.
1615 if (!pinchVirtualViewportEnabled() && localFrameRootTemporary()->frameView() )
1616 localFrameRootTemporary()->frameView()->resize(m_size);
1617
1618 if (pinchVirtualViewportEnabled())
1619 page()->frameHost().pinchViewport().setSize(m_size);
1620
1621 // When device emulation is enabled, device size values may change - they ar e
1622 // usually set equal to the view size. These values are not considered viewp ort-dependent
1623 // (see MediaQueryExp::isViewportDependent), since they are only viewport-de pendent in emulation mode,
1624 // and thus will not be invalidated in |FrameView::performPreLayoutTasks|.
1625 // Therefore we should force explicit media queries invalidation here.
1626 if (page()->inspectorController().deviceEmulationEnabled()) {
1627 if (Document* document = localFrameRootTemporary()->frame()->document())
1628 document->mediaQueryAffectingValueChanged();
1629 }
1630 }
1631
1592 void WebViewImpl::resize(const WebSize& newSize) 1632 void WebViewImpl::resize(const WebSize& newSize)
1593 { 1633 {
1594 if (m_shouldAutoResize || m_size == newSize) 1634 if (m_shouldAutoResize || m_size == newSize)
1595 return; 1635 return;
1596 1636
1597 FrameView* view = mainFrameImpl()->frameView(); 1637 FrameView* view = localFrameRootTemporary()->frameView();
1598 if (!view) 1638 if (!view)
1599 return; 1639 return;
1600 1640
1601 WebSize oldSize = m_size; 1641 WebSize oldSize = m_size;
1602 float oldPageScaleFactor = pageScaleFactor(); 1642 float oldPageScaleFactor = pageScaleFactor();
1603 int oldContentsWidth = contentsSize().width(); 1643 int oldContentsWidth = contentsSize().width();
1604 1644
1605 m_size = newSize; 1645 m_size = newSize;
1606 1646
1607 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges() 1647 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges()
1608 && oldSize.width && oldContentsWidth && newSize.width != oldSize.width & & !m_fullscreenController->isFullscreen(); 1648 && oldSize.width && oldContentsWidth && newSize.width != oldSize.width & & !m_fullscreenController->isFullscreen();
1609 1649
1610 ViewportAnchor viewportAnchor(&mainFrameImpl()->frame()->eventHandler()); 1650 ViewportAnchor viewportAnchor(&mainFrameImpl()->frame()->eventHandler());
1611 if (shouldAnchorAndRescaleViewport) { 1651 if (shouldAnchorAndRescaleViewport) {
1612 viewportAnchor.setAnchor(view->visibleContentRect(), 1652 viewportAnchor.setAnchor(view->visibleContentRect(),
1613 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); 1653 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord));
1614 } 1654 }
1615 1655
1656 // FIXME: FastTextAutosizer does not yet support out-of-process frames.
1657 if (mainFrameImpl()->frame()->isLocalFrame())
1616 { 1658 {
1617 // 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.
1618 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); 1660 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page());
1619 1661 performResize();
1620 m_pageScaleConstraintsSet.didChangeViewSize(m_size); 1662 } else {
1621 1663 performResize();
1622 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document( )->viewportDescription());
1623 updateMainFrameLayoutSize();
1624
1625 // If the virtual viewport pinch mode is enabled, the main frame will be resized
1626 // after layout so it can be sized to the contentsSize.
1627 if (!pinchVirtualViewportEnabled() && mainFrameImpl()->frameView())
1628 mainFrameImpl()->frameView()->resize(m_size);
1629
1630 if (pinchVirtualViewportEnabled())
1631 page()->frameHost().pinchViewport().setSize(m_size);
1632
1633 // When device emulation is enabled, device size values may change - the y are
1634 // usually set equal to the view size. These values are not considered v iewport-dependent
1635 // (see MediaQueryExp::isViewportDependent), since they are only viewpor t-dependent in emulation mode,
1636 // and thus will not be invalidated in |FrameView::performPreLayoutTasks |.
1637 // Therefore we should force explicit media queries invalidation here.
1638 if (page()->inspectorController().deviceEmulationEnabled()) {
1639 if (Document* document = mainFrameImpl()->frame()->document())
1640 document->mediaQueryAffectingValueChanged();
1641 }
1642 } 1664 }
1643 1665
1644 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { 1666 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) {
1645 // Relayout immediately to recalculate the minimum scale limit. 1667 // Relayout immediately to recalculate the minimum scale limit.
1646 if (view->needsLayout()) 1668 if (view->needsLayout())
1647 view->layout(); 1669 view->layout();
1648 1670
1649 if (shouldAnchorAndRescaleViewport) { 1671 if (shouldAnchorAndRescaleViewport) {
1650 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width; 1672 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width;
1651 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth; 1673 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 1750
1729 if (m_continuousPaintingEnabled) { 1751 if (m_continuousPaintingEnabled) {
1730 ContinuousPainter::setNeedsDisplayRecursive(m_rootGraphicsLayer, m_pageO verlays.get()); 1752 ContinuousPainter::setNeedsDisplayRecursive(m_rootGraphicsLayer, m_pageO verlays.get());
1731 m_client->scheduleAnimation(); 1753 m_client->scheduleAnimation();
1732 } 1754 }
1733 } 1755 }
1734 1756
1735 void WebViewImpl::layout() 1757 void WebViewImpl::layout()
1736 { 1758 {
1737 TRACE_EVENT0("blink", "WebViewImpl::layout"); 1759 TRACE_EVENT0("blink", "WebViewImpl::layout");
1738 PageWidgetDelegate::layout(m_page.get()); 1760 if (!localFrameRootTemporary())
1761 return;
1762
1763 PageWidgetDelegate::layout(m_page.get(), localFrameRootTemporary()->frame()) ;
1739 updateLayerTreeBackgroundColor(); 1764 updateLayerTreeBackgroundColor();
1740 1765
1741 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 1766 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
1742 m_linkHighlights[i]->updateGeometry(); 1767 m_linkHighlights[i]->updateGeometry();
1743 1768
1744 if (m_devToolsAgent) 1769 if (m_devToolsAgent)
1745 m_devToolsAgent->didLayout(); 1770 m_devToolsAgent->didLayout();
1746 } 1771 }
1747 1772
1748 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) 1773 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
(...skipping 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
4185 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4210 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4186 4211
4187 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4212 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4188 return false; 4213 return false;
4189 4214
4190 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4215 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4191 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4216 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4192 } 4217 }
4193 4218
4194 } // namespace blink 4219 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698