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

Side by Side Diff: Source/core/frame/FrameView.cpp

Issue 204813002: Optimize layout/repaint on FrameView resize (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Is it better to let layout fully control what to repaint? Created 6 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 renderer->setWidget(nullptr); 213 renderer->setWidget(nullptr);
214 } 214 }
215 215
216 void FrameView::reset() 216 void FrameView::reset()
217 { 217 {
218 m_cannotBlitToWindow = false; 218 m_cannotBlitToWindow = false;
219 m_isOverlapped = false; 219 m_isOverlapped = false;
220 m_contentIsOpaque = false; 220 m_contentIsOpaque = false;
221 m_hasPendingLayout = false; 221 m_hasPendingLayout = false;
222 m_layoutSubtreeRoot = 0; 222 m_layoutSubtreeRoot = 0;
223 m_doFullRepaint = false;
224 m_layoutSchedulingEnabled = true; 223 m_layoutSchedulingEnabled = true;
225 m_inPerformLayout = false; 224 m_inPerformLayout = false;
226 m_canRepaintDuringPerformLayout = false; 225 m_canRepaintDuringPerformLayout = false;
227 m_doingPreLayoutStyleUpdate = false; 226 m_doingPreLayoutStyleUpdate = false;
228 m_inSynchronousPostLayout = false; 227 m_inSynchronousPostLayout = false;
229 m_layoutCount = 0; 228 m_layoutCount = 0;
230 m_nestedLayoutCount = 0; 229 m_nestedLayoutCount = 0;
231 m_postLayoutTasksTimer.stop(); 230 m_postLayoutTasksTimer.stop();
232 m_updateWidgetsTimer.stop(); 231 m_updateWidgetsTimer.stop();
233 m_firstLayout = true; 232 m_firstLayout = true;
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 setScrollbarModes(hMode, vMode); 942 setScrollbarModes(hMode, vMode);
944 setScrollbarsSuppressed(false, true); 943 setScrollbarsSuppressed(false, true);
945 } else if (hMode != currentHMode || vMode != currentVMode) { 944 } else if (hMode != currentHMode || vMode != currentVMode) {
946 setScrollbarModes(hMode, vMode); 945 setScrollbarModes(hMode, vMode);
947 } 946 }
948 947
949 LayoutSize oldSize = m_size; 948 LayoutSize oldSize = m_size;
950 949
951 m_size = LayoutSize(layoutSize().width(), layoutSize().height()); 950 m_size = LayoutSize(layoutSize().width(), layoutSize().height());
952 951
953 if (oldSize != m_size) { 952 if (oldSize != m_size && !m_firstLayout) {
954 shouldDoFullLayout = true; 953 RenderBox* rootRenderer = document->documentElement() ? document ->documentElement()->renderBox() : 0;
955 if (!m_firstLayout) { 954 RenderBox* bodyRenderer = rootRenderer && document->body() ? doc ument->body()->renderBox() : 0;
956 RenderBox* rootRenderer = document->documentElement() ? docu ment->documentElement()->renderBox() : 0; 955 if (bodyRenderer && bodyRenderer->stretchesToViewport())
957 RenderBox* bodyRenderer = rootRenderer && document->body() ? document->body()->renderBox() : 0; 956 bodyRenderer->setChildNeedsLayout();
958 if (bodyRenderer && bodyRenderer->stretchesToViewport()) 957 else if (rootRenderer && rootRenderer->stretchesToViewport())
959 bodyRenderer->setChildNeedsLayout(); 958 rootRenderer->setChildNeedsLayout();
960 else if (rootRenderer && rootRenderer->stretchesToViewport() )
961 rootRenderer->setChildNeedsLayout();
962 }
963 } 959 }
964 } 960 }
965 961
966 layer = rootForThisLayout->enclosingLayer(); 962 layer = rootForThisLayout->enclosingLayer();
967 963
968 // We need to set m_doFullRepaint before triggering layout as RenderObje ct::checkForRepaint 964 if (shouldDoFullLayout)
969 // checks the boolean to disable local repaints. 965 setNeedsLayout(); // May override previous setNeedsResizeLayout().
dsinclair 2014/03/20 10:41:41 It seems strange to me that we're in FrameView::la
Xianzhu 2014/03/20 17:47:43 I thought if shouldDoFullLayout but only resizeLay
970 m_doFullRepaint |= shouldDoFullLayout;
971
972 performLayout(rootForThisLayout, inSubtreeLayout); 966 performLayout(rootForThisLayout, inSubtreeLayout);
973 967
974 m_layoutSubtreeRoot = 0; 968 m_layoutSubtreeRoot = 0;
975 } // Reset m_layoutSchedulingEnabled to its previous value. 969 } // Reset m_layoutSchedulingEnabled to its previous value.
976 970
977 if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->document().printin g()) 971 if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->document().printin g())
978 adjustViewSize(); 972 adjustViewSize();
979 973
980 layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPos itionFlags(layer, inSubtreeLayout, m_doFullRepaint)); 974 layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPos itionFlags(layer, inSubtreeLayout, false));
dsinclair 2014/03/20 10:41:41 I believe this is the only caller for updateLayerP
981 975
982 updateCompositingLayersAfterLayout(); 976 updateCompositingLayersAfterLayout();
983 977
984 m_layoutCount++; 978 m_layoutCount++;
985 979
986 if (AXObjectCache* cache = rootForThisLayout->document().existingAXObjectCac he()) 980 if (AXObjectCache* cache = rootForThisLayout->document().existingAXObjectCac he())
987 cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComple te, true); 981 cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComple te, true);
988 updateAnnotatedRegions(); 982 updateAnnotatedRegions();
989 983
990 ASSERT(!rootForThisLayout->needsLayout()); 984 ASSERT(!rootForThisLayout->needsLayout());
991 985
992 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER)) 986 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
993 updateOverflowStatus(layoutSize().width() < contentsWidth(), layoutSize( ).height() < contentsHeight()); 987 updateOverflowStatus(layoutSize().width() < contentsWidth(), layoutSize( ).height() < contentsHeight());
994 988
995 scheduleOrPerformPostLayoutTasks(); 989 scheduleOrPerformPostLayoutTasks();
996 990
997 InspectorInstrumentation::didLayout(cookie, rootForThisLayout); 991 InspectorInstrumentation::didLayout(cookie, rootForThisLayout);
998 992
999 m_nestedLayoutCount--; 993 m_nestedLayoutCount--;
1000 if (m_nestedLayoutCount) 994 if (m_nestedLayoutCount)
1001 return; 995 return;
1002 996
1003 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
1004 if (m_doFullRepaint)
1005 renderView()->setShouldDoFullRepaintAfterLayout(true);
1006
1007 if (m_doFullRepaint)
1008 repaintTree(rootForThisLayout);
dsinclair 2014/03/20 10:41:41 This will break repaintAfterLayout as this is the
Xianzhu 2014/03/20 17:47:43 Previously when m_doFullRepaint is not true, would
dsinclair 2014/03/21 09:39:27 No, this was actually broken with the partial layo
Xianzhu 2014/03/21 16:17:09 Thanks for explanation. So Patch Set 3 is doing th
1009
1010 } else if (m_doFullRepaint) {
1011 // FIXME: This isn't really right, since the RenderView doesn't fully en compass
1012 // the visibleContentRect(). It just happens to work out most of the tim e,
1013 // since first layouts and printing don't have you scrolled anywhere.
1014 renderView()->repaint();
1015 }
1016
1017 m_doFullRepaint = false;
1018
1019 #ifndef NDEBUG 997 #ifndef NDEBUG
1020 // Post-layout assert that nobody was re-marked as needing layout during lay out. 998 // Post-layout assert that nobody was re-marked as needing layout during lay out.
1021 document->renderer()->assertSubtreeIsLaidOut(); 999 document->renderer()->assertSubtreeIsLaidOut();
1022 #endif 1000 #endif
1023 1001
1024 // FIXME: It should be not possible to remove the FrameView from the frame/p age during layout 1002 // FIXME: It should be not possible to remove the FrameView from the frame/p age during layout
1025 // however m_inPerformLayout is not set for most of this function, so none o f our RELEASE_ASSERTS 1003 // however m_inPerformLayout is not set for most of this function, so none o f our RELEASE_ASSERTS
1026 // in LocalFrame/Page will fire. One of the post-layout tasks is disconnecti ng the LocalFrame from 1004 // in LocalFrame/Page will fire. One of the post-layout tasks is disconnecti ng the LocalFrame from
1027 // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.ht ml 1005 // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.ht ml
1028 // necessitating this check here. 1006 // necessitating this check here.
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 repaintRect.move(-scrollOffset()); 1721 repaintRect.move(-scrollOffset());
1744 m_trackedRepaintRects.append(repaintRect); 1722 m_trackedRepaintRects.append(repaintRect);
1745 } 1723 }
1746 1724
1747 ScrollView::repaintContentRectangle(r); 1725 ScrollView::repaintContentRectangle(r);
1748 } 1726 }
1749 1727
1750 void FrameView::contentsResized() 1728 void FrameView::contentsResized()
1751 { 1729 {
1752 ScrollView::contentsResized(); 1730 ScrollView::contentsResized();
1753 setNeedsLayout(); 1731 setNeedsResizeLayout();
1754 } 1732 }
1755 1733
1756 void FrameView::scrollbarExistenceDidChange() 1734 void FrameView::scrollbarExistenceDidChange()
1757 { 1735 {
1758 // We check to make sure the view is attached to a frame() as this method ca n 1736 // We check to make sure the view is attached to a frame() as this method ca n
1759 // be triggered before the view is attached by LocalFrame::createView(...) s etting 1737 // be triggered before the view is attached by LocalFrame::createView(...) s etting
1760 // various values such as setScrollBarModes(...) for example. An ASSERT is 1738 // various values such as setScrollBarModes(...) for example. An ASSERT is
1761 // triggered when a view is layout before being attached to a frame(). 1739 // triggered when a view is layout before being attached to a frame().
1762 if (!frame().view()) 1740 if (!frame().view())
1763 return; 1741 return;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 || (renderView && renderView->needsLayout()) 1863 || (renderView && renderView->needsLayout())
1886 || isSubtreeLayout(); 1864 || isSubtreeLayout();
1887 } 1865 }
1888 1866
1889 void FrameView::setNeedsLayout() 1867 void FrameView::setNeedsLayout()
1890 { 1868 {
1891 if (RenderView* renderView = this->renderView()) 1869 if (RenderView* renderView = this->renderView())
1892 renderView->setNeedsLayout(); 1870 renderView->setNeedsLayout();
1893 } 1871 }
1894 1872
1873 void FrameView::setNeedsResizeLayout()
1874 {
1875 if (RenderView* renderView = this->renderView())
1876 renderView->setNeedsResizeLayout();
1877 }
1878
1895 bool FrameView::isTransparent() const 1879 bool FrameView::isTransparent() const
1896 { 1880 {
1897 return m_isTransparent; 1881 return m_isTransparent;
1898 } 1882 }
1899 1883
1900 void FrameView::setTransparent(bool isTransparent) 1884 void FrameView::setTransparent(bool isTransparent)
1901 { 1885 {
1902 m_isTransparent = isTransparent; 1886 m_isTransparent = isTransparent;
1903 DisableCompositingQueryAsserts disabler; 1887 DisableCompositingQueryAsserts disabler;
1904 if (renderView() && renderView()->layer()->hasCompositedLayerMapping()) 1888 if (renderView() && renderView()->layer()->hasCompositedLayerMapping())
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation) 3201 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation)
3218 { 3202 {
3219 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); 3203 ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
3220 if (AXObjectCache* cache = axObjectCache()) { 3204 if (AXObjectCache* cache = axObjectCache()) {
3221 cache->remove(scrollbar); 3205 cache->remove(scrollbar);
3222 cache->handleScrollbarUpdate(this); 3206 cache->handleScrollbarUpdate(this);
3223 } 3207 }
3224 } 3208 }
3225 3209
3226 } // namespace WebCore 3210 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698