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

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

Issue 134643008: Remove FrameView::DeferredRepaintScope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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/core/frame/FrameView.h ('k') | Source/core/rendering/RenderView.cpp » ('j') | 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) 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 // paged-y always corresponds to TopToBottomPaginated or BottomToTopPaginate d. If the WritingMode 149 // paged-y always corresponds to TopToBottomPaginated or BottomToTopPaginate d. If the WritingMode
150 // is horizontal, then the direction of the horizontality dictates the choic e. If the WritingMode 150 // is horizontal, then the direction of the horizontality dictates the choic e. If the WritingMode
151 // is vertical, then we use TextDirection to choose between those options. 151 // is vertical, then we use TextDirection to choose between those options.
152 if (writingMode == TopToBottomWritingMode || (!isHorizontalWritingMode && te xtDirection == RTL)) 152 if (writingMode == TopToBottomWritingMode || (!isHorizontalWritingMode && te xtDirection == RTL))
153 return Pagination::TopToBottomPaginated; 153 return Pagination::TopToBottomPaginated;
154 return Pagination::BottomToTopPaginated; 154 return Pagination::BottomToTopPaginated;
155 } 155 }
156 156
157 FrameView::DeferredRepaintScope::DeferredRepaintScope(FrameView& view)
158 : m_view(&view)
159 {
160 m_view->beginDeferredRepaints();
161 }
162
163 FrameView::DeferredRepaintScope::~DeferredRepaintScope()
164 {
165 m_view->endDeferredRepaints();
166 }
167
168 FrameView::FrameView(Frame* frame) 157 FrameView::FrameView(Frame* frame)
169 : m_frame(frame) 158 : m_frame(frame)
170 , m_canHaveScrollbars(true) 159 , m_canHaveScrollbars(true)
171 , m_slowRepaintObjectCount(0) 160 , m_slowRepaintObjectCount(0)
172 , m_layoutTimer(this, &FrameView::layoutTimerFired) 161 , m_layoutTimer(this, &FrameView::layoutTimerFired)
173 , m_layoutRoot(0) 162 , m_layoutRoot(0)
174 , m_inSynchronousPostLayout(false) 163 , m_inSynchronousPostLayout(false)
175 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) 164 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
176 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired) 165 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired)
177 , m_isTransparent(false) 166 , m_isTransparent(false)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 m_layoutCount = 0; 253 m_layoutCount = 0;
265 m_nestedLayoutCount = 0; 254 m_nestedLayoutCount = 0;
266 m_postLayoutTasksTimer.stop(); 255 m_postLayoutTasksTimer.stop();
267 m_updateWidgetsTimer.stop(); 256 m_updateWidgetsTimer.stop();
268 m_firstLayout = true; 257 m_firstLayout = true;
269 m_firstLayoutCallbackPending = false; 258 m_firstLayoutCallbackPending = false;
270 m_wasScrolledByUser = false; 259 m_wasScrolledByUser = false;
271 m_safeToPropagateScrollToParent = true; 260 m_safeToPropagateScrollToParent = true;
272 m_lastViewportSize = IntSize(); 261 m_lastViewportSize = IntSize();
273 m_lastZoomFactor = 1.0f; 262 m_lastZoomFactor = 1.0f;
274 m_deferringRepaints = 0;
275 m_repaintCount = 0; 263 m_repaintCount = 0;
276 m_repaintRects.clear(); 264 m_repaintRects.clear();
277 m_deferredRepaintDelay = s_initialDeferredRepaintDelayDuringLoading; 265 m_deferredRepaintDelay = s_initialDeferredRepaintDelayDuringLoading;
278 m_deferredRepaintTimer.stop(); 266 m_deferredRepaintTimer.stop();
279 m_isTrackingRepaints = false; 267 m_isTrackingRepaints = false;
280 m_trackedRepaintRects.clear(); 268 m_trackedRepaintRects.clear();
281 m_lastPaintTime = 0; 269 m_lastPaintTime = 0;
282 m_paintBehavior = PaintBehaviorNormal; 270 m_paintBehavior = PaintBehaviorNormal;
283 m_isPainting = false; 271 m_isPainting = false;
284 m_visuallyNonEmptyCharacterCount = 0; 272 m_visuallyNonEmptyCharacterCount = 0;
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 document->updateStyleIfNeeded(); 878 document->updateStyleIfNeeded();
891 } 879 }
892 880
893 void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay out) 881 void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay out)
894 { 882 {
895 TRACE_EVENT0("webkit", "FrameView::performLayout"); 883 TRACE_EVENT0("webkit", "FrameView::performLayout");
896 884
897 // performLayout is the actual guts of layout(). 885 // performLayout is the actual guts of layout().
898 // FIXME: The 300 other lines in layout() probably belong in other helper fu nctions 886 // FIXME: The 300 other lines in layout() probably belong in other helper fu nctions
899 // so that a single human could understand what layout() is actually doing. 887 // so that a single human could understand what layout() is actually doing.
900 FrameView::DeferredRepaintScope deferRepaints(*this);
901 888
902 { 889 {
903 bool disableLayoutState = false; 890 bool disableLayoutState = false;
904 if (inSubtreeLayout) { 891 if (inSubtreeLayout) {
905 RenderView* view = rootForThisLayout->view(); 892 RenderView* view = rootForThisLayout->view();
906 disableLayoutState = view->shouldDisableLayoutStateForSubtree(rootFo rThisLayout); 893 disableLayoutState = view->shouldDisableLayoutStateForSubtree(rootFo rThisLayout);
907 view->pushLayoutState(rootForThisLayout); 894 view->pushLayoutState(rootForThisLayout);
908 } 895 }
909 LayoutStateDisabler layoutStateDisabler(disableLayoutState ? rootForThis Layout->view() : 0); 896 LayoutStateDisabler layoutStateDisabler(disableLayoutState ? rootForThis Layout->view() : 0);
910 897
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 m_layoutRoot = 0; 1099 m_layoutRoot = 0;
1113 } // Reset m_layoutSchedulingEnabled to its previous value. 1100 } // Reset m_layoutSchedulingEnabled to its previous value.
1114 1101
1115 bool neededFullRepaint = m_doFullRepaint; 1102 bool neededFullRepaint = m_doFullRepaint;
1116 1103
1117 if (!inSubtreeLayout && !isPartialLayout && !toRenderView(rootForThisLayout) ->document().printing()) 1104 if (!inSubtreeLayout && !isPartialLayout && !toRenderView(rootForThisLayout) ->document().printing())
1118 adjustViewSize(); 1105 adjustViewSize();
1119 1106
1120 m_doFullRepaint = neededFullRepaint; 1107 m_doFullRepaint = neededFullRepaint;
1121 1108
1122 { 1109 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
1123 // FIXME: Can this scope just encompass this entire function? 1110 if (m_doFullRepaint)
1124 FrameView::DeferredRepaintScope deferRepaints(*this); 1111 renderView()->setShouldDoFullRepaintAfterLayout(true);
1125 1112
1126 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { 1113 if (m_doFullRepaint || !partialLayout().isStopping())
1127 if (m_doFullRepaint) 1114 repaintTree(rootForThisLayout);
1128 renderView()->setShouldDoFullRepaintAfterLayout(true);
1129 1115
1130 if (m_doFullRepaint || !partialLayout().isStopping()) 1116 } else if (m_doFullRepaint) {
1131 repaintTree(rootForThisLayout); 1117 // FIXME: This isn't really right, since the RenderView doesn't fully en compass
1118 // the visibleContentRect(). It just happens to work out most of the tim e,
1119 // since first layouts and printing don't have you scrolled anywhere.
1120 renderView()->repaint();
1121 }
1132 1122
1133 } else if (m_doFullRepaint) { 1123 layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPos itionFlags(layer, inSubtreeLayout, m_doFullRepaint));
1134 // FIXME: This isn't really right, since the RenderView doesn't full y encompass 1124
1135 // the visibleContentRect(). It just happens to work out most of the time,
1136 // since first layouts and printing don't have you scrolled anywhere .
1137 renderView()->repaint();
1138 }
1139 layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLaye rPositionFlags(layer, inSubtreeLayout, m_doFullRepaint));
1140 }
1141 updateCompositingLayersAfterLayout(); 1125 updateCompositingLayersAfterLayout();
1142 1126
1143 m_layoutCount++; 1127 m_layoutCount++;
1144 1128
1145 if (AXObjectCache* cache = rootForThisLayout->document().existingAXObjectCac he()) 1129 if (AXObjectCache* cache = rootForThisLayout->document().existingAXObjectCac he())
1146 cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComple te, true); 1130 cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComple te, true);
1147 updateAnnotatedRegions(); 1131 updateAnnotatedRegions();
1148 1132
1149 ASSERT(partialLayout().isStopping() || !rootForThisLayout->needsLayout()); 1133 ASSERT(partialLayout().isStopping() || !rootForThisLayout->needsLayout());
1150 1134
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 void FrameView::repaintContentRectangle(const IntRect& r) 1795 void FrameView::repaintContentRectangle(const IntRect& r)
1812 { 1796 {
1813 ASSERT(!m_frame->ownerElement()); 1797 ASSERT(!m_frame->ownerElement());
1814 1798
1815 if (m_isTrackingRepaints) { 1799 if (m_isTrackingRepaints) {
1816 IntRect repaintRect = r; 1800 IntRect repaintRect = r;
1817 repaintRect.move(-scrollOffset()); 1801 repaintRect.move(-scrollOffset());
1818 m_trackedRepaintRects.append(repaintRect); 1802 m_trackedRepaintRects.append(repaintRect);
1819 } 1803 }
1820 1804
1821 double delay = m_deferringRepaints ? 0 : adjustedDeferredRepaintDelay(); 1805 double delay = adjustedDeferredRepaintDelay();
1822 if (m_deferringRepaints || m_deferredRepaintTimer.isActive() || delay) { 1806 if (m_deferredRepaintTimer.isActive() || delay) {
1823 IntRect paintRect = r; 1807 IntRect paintRect = r;
1824 if (clipsRepaints() && !paintsEntireContents()) 1808 if (clipsRepaints() && !paintsEntireContents())
1825 paintRect.intersect(visibleContentRect()); 1809 paintRect.intersect(visibleContentRect());
1826 if (paintRect.isEmpty()) 1810 if (paintRect.isEmpty())
1827 return; 1811 return;
1828 if (m_repaintCount == cRepaintRectUnionThreshold) { 1812 if (m_repaintCount == cRepaintRectUnionThreshold) {
1829 IntRect unionedRect; 1813 IntRect unionedRect;
1830 for (unsigned i = 0; i < cRepaintRectUnionThreshold; ++i) 1814 for (unsigned i = 0; i < cRepaintRectUnionThreshold; ++i)
1831 unionedRect.unite(pixelSnappedIntRect(m_repaintRects[i])); 1815 unionedRect.unite(pixelSnappedIntRect(m_repaintRects[i]));
1832 m_repaintRects.clear(); 1816 m_repaintRects.clear();
1833 m_repaintRects.append(unionedRect); 1817 m_repaintRects.append(unionedRect);
1834 } 1818 }
1835 if (m_repaintCount < cRepaintRectUnionThreshold) 1819 if (m_repaintCount < cRepaintRectUnionThreshold)
1836 m_repaintRects.append(paintRect); 1820 m_repaintRects.append(paintRect);
1837 else 1821 else
1838 m_repaintRects[0].unite(paintRect); 1822 m_repaintRects[0].unite(paintRect);
1839 m_repaintCount++; 1823 m_repaintCount++;
1840 1824
1841 if (!m_deferringRepaints) 1825 startDeferredRepaintTimer(delay);
1842 startDeferredRepaintTimer(delay);
1843 1826
1844 return; 1827 return;
1845 } 1828 }
1846 1829
1847 if (!shouldUpdate()) 1830 if (!shouldUpdate())
1848 return; 1831 return;
1849 1832
1850 ScrollView::repaintContentRectangle(r); 1833 ScrollView::repaintContentRectangle(r);
1851 } 1834 }
1852 1835
(...skipping 23 matching lines...) Expand all
1876 layout(); 1859 layout();
1877 1860
1878 if (renderView() && renderView()->usesCompositing()) { 1861 if (renderView() && renderView()->usesCompositing()) {
1879 renderView()->compositor()->frameViewScrollbarsExistenceDidChange(); 1862 renderView()->compositor()->frameViewScrollbarsExistenceDidChange();
1880 1863
1881 if (!useOverlayScrollbars) 1864 if (!useOverlayScrollbars)
1882 renderView()->compositor()->frameViewDidChangeSize(); 1865 renderView()->compositor()->frameViewDidChangeSize();
1883 } 1866 }
1884 } 1867 }
1885 1868
1886 void FrameView::beginDeferredRepaints()
1887 {
1888 Page* page = m_frame->page();
1889 ASSERT(page);
1890
1891 if (!isMainFrame()) {
1892 page->mainFrame()->view()->beginDeferredRepaints();
1893 return;
1894 }
1895
1896 m_deferringRepaints++;
1897 }
1898
1899 void FrameView::endDeferredRepaints()
1900 {
1901 Page* page = m_frame->page();
1902 ASSERT(page);
1903
1904 if (!isMainFrame()) {
1905 page->mainFrame()->view()->endDeferredRepaints();
1906 return;
1907 }
1908
1909 ASSERT(m_deferringRepaints > 0);
1910
1911 if (--m_deferringRepaints)
1912 return;
1913
1914 if (m_deferredRepaintTimer.isActive())
1915 return;
1916
1917 if (double delay = adjustedDeferredRepaintDelay()) {
1918 startDeferredRepaintTimer(delay);
1919 return;
1920 }
1921
1922 doDeferredRepaints();
1923 }
1924
1925 void FrameView::startDeferredRepaintTimer(double delay) 1869 void FrameView::startDeferredRepaintTimer(double delay)
1926 { 1870 {
1927 if (m_deferredRepaintTimer.isActive()) 1871 if (m_deferredRepaintTimer.isActive())
1928 return; 1872 return;
1929 1873
1930 m_deferredRepaintTimer.startOneShot(delay); 1874 m_deferredRepaintTimer.startOneShot(delay);
1931 } 1875 }
1932 1876
1933 void FrameView::handleLoadCompleted() 1877 void FrameView::handleLoadCompleted()
1934 { 1878 {
1935 // Once loading has completed, allow autoSize one last opportunity to 1879 // Once loading has completed, allow autoSize one last opportunity to
1936 // reduce the size of the frame. 1880 // reduce the size of the frame.
1937 autoSizeIfEnabled(); 1881 autoSizeIfEnabled();
1938 if (shouldUseLoadTimeDeferredRepaintDelay()) 1882 if (shouldUseLoadTimeDeferredRepaintDelay())
1939 return; 1883 return;
1940 m_deferredRepaintDelay = s_normalDeferredRepaintDelay; 1884 m_deferredRepaintDelay = s_normalDeferredRepaintDelay;
1941 flushDeferredRepaints(); 1885 flushDeferredRepaints();
1942 } 1886 }
1943 1887
1944 void FrameView::flushDeferredRepaints() 1888 void FrameView::flushDeferredRepaints()
1945 { 1889 {
1946 if (!m_deferredRepaintTimer.isActive()) 1890 if (!m_deferredRepaintTimer.isActive())
1947 return; 1891 return;
1948 m_deferredRepaintTimer.stop(); 1892 m_deferredRepaintTimer.stop();
1949 doDeferredRepaints(); 1893 doDeferredRepaints();
1950 } 1894 }
1951 1895
1952 void FrameView::doDeferredRepaints() 1896 void FrameView::doDeferredRepaints()
1953 { 1897 {
1954 ASSERT(!m_deferringRepaints);
1955 if (!shouldUpdate()) { 1898 if (!shouldUpdate()) {
1956 m_repaintRects.clear(); 1899 m_repaintRects.clear();
1957 m_repaintCount = 0; 1900 m_repaintCount = 0;
1958 return; 1901 return;
1959 } 1902 }
1960 unsigned size = m_repaintRects.size(); 1903 unsigned size = m_repaintRects.size();
1961 for (unsigned i = 0; i < size; i++) { 1904 for (unsigned i = 0; i < size; i++) {
1962 ScrollView::repaintContentRectangle(pixelSnappedIntRect(m_repaintRects[i ])); 1905 ScrollView::repaintContentRectangle(pixelSnappedIntRect(m_repaintRects[i ]));
1963 } 1906 }
1964 m_repaintRects.clear(); 1907 m_repaintRects.clear();
(...skipping 25 matching lines...) Expand all
1990 } 1933 }
1991 double incrementedRepaintDelay = m_deferredRepaintDelay + s_deferredRepaintD elayIncrementDuringLoading; 1934 double incrementedRepaintDelay = m_deferredRepaintDelay + s_deferredRepaintD elayIncrementDuringLoading;
1992 m_deferredRepaintDelay = std::min(incrementedRepaintDelay, s_maxDeferredRepa intDelayDuringLoading); 1935 m_deferredRepaintDelay = std::min(incrementedRepaintDelay, s_maxDeferredRepa intDelayDuringLoading);
1993 } 1936 }
1994 1937
1995 void FrameView::resetDeferredRepaintDelay() 1938 void FrameView::resetDeferredRepaintDelay()
1996 { 1939 {
1997 m_deferredRepaintDelay = 0; 1940 m_deferredRepaintDelay = 0;
1998 if (m_deferredRepaintTimer.isActive()) { 1941 if (m_deferredRepaintTimer.isActive()) {
1999 m_deferredRepaintTimer.stop(); 1942 m_deferredRepaintTimer.stop();
2000 if (!m_deferringRepaints) 1943 doDeferredRepaints();
2001 doDeferredRepaints();
2002 } 1944 }
2003 } 1945 }
2004 1946
2005 double FrameView::adjustedDeferredRepaintDelay() const 1947 double FrameView::adjustedDeferredRepaintDelay() const
2006 { 1948 {
2007 ASSERT(!m_deferringRepaints);
2008 if (!m_deferredRepaintDelay) 1949 if (!m_deferredRepaintDelay)
2009 return 0; 1950 return 0;
2010 double timeSinceLastPaint = currentTime() - m_lastPaintTime; 1951 double timeSinceLastPaint = currentTime() - m_lastPaintTime;
2011 return max(0., m_deferredRepaintDelay - timeSinceLastPaint); 1952 return max(0., m_deferredRepaintDelay - timeSinceLastPaint);
2012 } 1953 }
2013 1954
2014 void FrameView::deferredRepaintTimerFired(Timer<FrameView>*) 1955 void FrameView::deferredRepaintTimerFired(Timer<FrameView>*)
2015 { 1956 {
2016 doDeferredRepaints(); 1957 doDeferredRepaints();
2017 } 1958 }
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
3537 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation) 3478 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation)
3538 { 3479 {
3539 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); 3480 ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
3540 if (AXObjectCache* cache = axObjectCache()) { 3481 if (AXObjectCache* cache = axObjectCache()) {
3541 cache->remove(scrollbar); 3482 cache->remove(scrollbar);
3542 cache->handleScrollbarUpdate(this); 3483 cache->handleScrollbarUpdate(this);
3543 } 3484 }
3544 } 3485 }
3545 3486
3546 } // namespace WebCore 3487 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/rendering/RenderView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698