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

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

Issue 498773007: Move some scroll invalidations to the paint invalidation phase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased and improved Created 6 years, 3 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/RenderLayerRepainter.h » ('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 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 scrollContentsIfNeeded(); 1217 scrollContentsIfNeeded();
1218 1218
1219 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 1219 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
1220 if (!child->isLocalFrame()) 1220 if (!child->isLocalFrame())
1221 continue; 1221 continue;
1222 if (FrameView* view = toLocalFrame(child)->view()) 1222 if (FrameView* view = toLocalFrame(child)->view())
1223 view->scrollContentsIfNeededRecursive(); 1223 view->scrollContentsIfNeededRecursive();
1224 } 1224 }
1225 } 1225 }
1226 1226
1227 void FrameView::scrollContentsIfNeeded() 1227 // FIXME: If we had a flag to force invalidations in a whole subtree, we could g et rid of this function.
dsinclair 2014/09/02 18:36:47 crbug?
Julien - ping for review 2014/09/03 00:20:20 crbug.com/410097 (probably unneeded but at least i
1228 static void paintInvalidationRectIncludingNonCompositingDescendants(const Render Layer* layer)
dsinclair 2014/09/02 18:36:48 This method name doesn't seem to match up with wha
Julien - ping for review 2014/09/03 00:20:20 Fine with the alternative name.
1228 { 1229 {
1229 bool didScroll = !pendingScrollDelta().isZero(); 1230 layer->renderer()->setShouldDoFullPaintInvalidation(true);
1230 ScrollView::scrollContentsIfNeeded(); 1231
1231 if (didScroll) 1232 for (RenderLayer* child = layer->firstChild(); child; child = child->nextSib ling()) {
1232 updateFixedElementPaintInvalidationRectsAfterScroll(); 1233 // Don't include paint invalidation rects for composited child layers; t hey will paint themselves and have a different origin.
1234 if (child->isPaintInvalidationContainer())
1235 continue;
1236
1237 paintInvalidationRectIncludingNonCompositingDescendants(child);
esprehn 2014/09/02 20:23:10 Instead of walking the whole tree recursively we s
Julien - ping for review 2014/09/03 00:20:20 The FIXME above exactly what covers this case :-)
1238 }
1233 } 1239 }
1234 1240
1235 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) 1241 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta)
1236 { 1242 {
1237 if (!contentsInCompositedLayer() || hasSlowRepaintObjects()) 1243 if (!contentsInCompositedLayer() || hasSlowRepaintObjects())
1238 return false; 1244 return false;
1239 1245
1240 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty() ) { 1246 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty() ) {
1241 InspectorInstrumentation::didScroll(page()); 1247 InspectorInstrumentation::didScroll(page());
1242 return true; 1248 return true;
1243 } 1249 }
1244 1250
1245 Region regionToUpdate;
1246 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end(); 1251 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end();
1247 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) { 1252 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) {
1248 RenderObject* renderer = *it; 1253 RenderObject* renderer = *it;
1249 ASSERT(renderer->style()->hasViewportConstrainedPosition()); 1254 ASSERT(renderer->style()->hasViewportConstrainedPosition());
1250 ASSERT(renderer->hasLayer()); 1255 ASSERT(renderer->hasLayer());
1251 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); 1256 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
1252 1257
1253 CompositingState state = layer->compositingState(); 1258 if (layer->isPaintInvalidationContainer())
1254 if (state == PaintsIntoOwnBacking || state == PaintsIntoGroupedBacking)
1255 continue; 1259 continue;
1256 1260
1257 if (layer->subtreeIsInvisible()) 1261 if (layer->subtreeIsInvisible())
1258 continue; 1262 continue;
1259 1263
1260 // If the fixed layer has a blur/drop-shadow filter applied on at least one of its parents, we cannot 1264 // If the fixed layer has a blur/drop-shadow filter applied on at least one of its parents, we cannot
1261 // scroll using the fast path, otherwise the outsets of the filter will be moved around the page. 1265 // scroll using the fast path, otherwise the outsets of the filter will be moved around the page.
1262 if (layer->hasAncestorWithFilterOutsets()) 1266 if (layer->hasAncestorWithFilterOutsets())
1263 return false; 1267 return false;
1264 1268
1265 IntRect updateRect = pixelSnappedIntRect(layer->paintInvalidator().paint InvalidationRectIncludingNonCompositingDescendants()); 1269 paintInvalidationRectIncludingNonCompositingDescendants(layer);
1266
1267 const RenderLayerModelObject* repaintContainer = layer->renderer()->cont ainerForPaintInvalidation();
1268 if (repaintContainer && !repaintContainer->isRenderView()) {
1269 // Invalidate the old and new locations of fixed position elements t hat are not drawn into the RenderView.
1270 updateRect.moveBy(scrollPosition());
1271 IntRect previousRect = updateRect;
1272 previousRect.move(scrollDelta);
1273 // FIXME: Rather than uniting the rects, we should just issue both i nvalidations.
1274 updateRect.unite(previousRect);
1275 layer->renderer()->invalidatePaintUsingContainer(repaintContainer, u pdateRect, InvalidationScroll);
1276 } else {
1277 // Coalesce the paint invalidations that will be issued to the rende rView.
1278 updateRect = contentsToRootView(updateRect);
1279 if (!updateRect.isEmpty())
1280 regionToUpdate.unite(updateRect);
1281 }
1282 }
1283
1284 InspectorInstrumentation::didScroll(page());
dsinclair 2014/09/02 18:36:48 Does this still need to exist somewhere?
Julien - ping for review 2014/09/03 00:20:20 I would believe it does, it's a bad merge :(
1285
1286 // Invalidate the old and new locations of fixed position elements that are drawn into the RenderView.
1287 Vector<IntRect> subRectsToUpdate = regionToUpdate.rects();
1288 size_t viewportConstrainedObjectsCount = subRectsToUpdate.size();
1289 for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) {
1290 IntRect updateRect = subRectsToUpdate[i];
1291 IntRect scrolledRect = updateRect;
1292 scrolledRect.move(-scrollDelta);
1293 updateRect.unite(scrolledRect);
1294 // FIXME: We should be able to issue these invalidations separately and before we actually scroll.
1295 renderView()->layer()->paintInvalidator().setBackingNeedsPaintInvalidati onInRect(rootViewToContents(updateRect));
1296 } 1270 }
1297 1271
1298 return true; 1272 return true;
1299 } 1273 }
1300 1274
1301 void FrameView::scrollContentsSlowPath(const IntRect& updateRect) 1275 void FrameView::scrollContentsSlowPath(const IntRect& updateRect)
1302 { 1276 {
1303 if (contentsInCompositedLayer()) { 1277 if (contentsInCompositedLayer()) {
1304 IntRect updateRect = visibleContentRect(); 1278 IntRect updateRect = visibleContentRect();
1305 ASSERT(renderView()); 1279 ASSERT(renderView());
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 // If there fixed position elements, scrolling may cause compositing layers to change. 1491 // If there fixed position elements, scrolling may cause compositing layers to change.
1518 // Update widget and layer positions after scrolling, but only if we're not inside of 1492 // Update widget and layer positions after scrolling, but only if we're not inside of
1519 // layout. 1493 // layout.
1520 if (!m_nestedLayoutCount) { 1494 if (!m_nestedLayoutCount) {
1521 updateWidgetPositions(); 1495 updateWidgetPositions();
1522 if (RenderView* renderView = this->renderView()) 1496 if (RenderView* renderView = this->renderView())
1523 renderView->layer()->setNeedsCompositingInputsUpdate(); 1497 renderView->layer()->setNeedsCompositingInputsUpdate();
1524 } 1498 }
1525 } 1499 }
1526 1500
1527 void FrameView::updateFixedElementPaintInvalidationRectsAfterScroll()
1528 {
1529 if (!hasViewportConstrainedObjects())
1530 return;
1531
1532 // Update the paint invalidation rects for fixed elements after scrolling an d invalidation to reflect
1533 // the new scroll position.
1534 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end();
1535 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) {
1536 RenderObject* renderer = *it;
1537 // m_viewportConstrainedObjects should not contain non-viewport constrai ned objects.
1538 ASSERT(renderer->style()->hasViewportConstrainedPosition());
1539
1540 // Fixed items should always have layers.
1541 ASSERT(renderer->hasLayer());
1542
1543 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
1544
1545 // Don't need to do this for composited fixed items.
1546 if (layer->compositingState() == PaintsIntoOwnBacking)
1547 continue;
1548
1549 layer->paintInvalidator().computePaintInvalidationRectsIncludingNonCompo sitingDescendants();
1550 }
1551 }
1552
1553 void FrameView::updateCompositedSelectionBoundsIfNeeded() 1501 void FrameView::updateCompositedSelectionBoundsIfNeeded()
1554 { 1502 {
1555 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) 1503 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled())
1556 return; 1504 return;
1557 1505
1558 Page* page = frame().page(); 1506 Page* page = frame().page();
1559 ASSERT(page); 1507 ASSERT(page);
1560 1508
1561 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame( )); 1509 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame( ));
1562 if (!frame || !frame->selection().isCaretOrRange()) { 1510 if (!frame || !frame->selection().isCaretOrRange()) {
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 2484
2537 void FrameView::updateLayoutAndStyleForPainting() 2485 void FrameView::updateLayoutAndStyleForPainting()
2538 { 2486 {
2539 // Updating layout can run script, which can tear down the FrameView. 2487 // Updating layout can run script, which can tear down the FrameView.
2540 RefPtr<FrameView> protector(this); 2488 RefPtr<FrameView> protector(this);
2541 2489
2542 updateLayoutAndStyleIfNeededRecursive(); 2490 updateLayoutAndStyleIfNeededRecursive();
2543 2491
2544 updateWidgetPositionsIfNeeded(); 2492 updateWidgetPositionsIfNeeded();
2545 2493
2546 if (RenderView* view = renderView()) { 2494 RenderView* view = renderView();
2495 if (view) {
2547 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up dateLayerTree", "frame", m_frame.get()); 2496 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up dateLayerTree", "frame", m_frame.get());
2548 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 2497 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
2549 InspectorInstrumentation::willUpdateLayerTree(m_frame.get()); 2498 InspectorInstrumentation::willUpdateLayerTree(m_frame.get());
2550 2499
2551 view->compositor()->updateIfNeededRecursive(); 2500 view->compositor()->updateIfNeededRecursive();
2552 2501
2553 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) 2502 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot())
2554 m_frame->page()->scrollingCoordinator()->updateAfterCompositingChang eIfNeeded(); 2503 m_frame->page()->scrollingCoordinator()->updateAfterCompositingChang eIfNeeded();
2555 2504
2556 updateCompositedSelectionBoundsIfNeeded(); 2505 updateCompositedSelectionBoundsIfNeeded();
2557 2506
2558 InspectorInstrumentation::didUpdateLayerTree(m_frame.get()); 2507 InspectorInstrumentation::didUpdateLayerTree(m_frame.get());
2559
2560 invalidateTreeIfNeededRecursive();
2561 } 2508 }
2562 2509
2563 scrollContentsIfNeededRecursive(); 2510 scrollContentsIfNeededRecursive();
2511
2512 if (view)
2513 invalidateTreeIfNeededRecursive();
2514
2564 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); 2515 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean);
2565 } 2516 }
2566 2517
2567 void FrameView::updateLayoutAndStyleIfNeededRecursive() 2518 void FrameView::updateLayoutAndStyleIfNeededRecursive()
2568 { 2519 {
2569 // We have to crawl our entire tree looking for any FrameViews that need 2520 // We have to crawl our entire tree looking for any FrameViews that need
2570 // layout and make sure they are up to date. 2521 // layout and make sure they are up to date.
2571 // Mac actually tests for intersection with the dirty region and tries not t o 2522 // Mac actually tests for intersection with the dirty region and tries not t o
2572 // update layout for frames that are outside the dirty region. Not only doe s this seem 2523 // update layout for frames that are outside the dirty region. Not only doe s this seem
2573 // pointless (since those frames will have set a zero timer to layout anyway ), but 2524 // pointless (since those frames will have set a zero timer to layout anyway ), but
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
3000 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation) 2951 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation)
3001 { 2952 {
3002 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); 2953 ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
3003 if (AXObjectCache* cache = axObjectCache()) { 2954 if (AXObjectCache* cache = axObjectCache()) {
3004 cache->remove(scrollbar); 2955 cache->remove(scrollbar);
3005 cache->handleScrollbarUpdate(this); 2956 cache->handleScrollbarUpdate(this);
3006 } 2957 }
3007 } 2958 }
3008 2959
3009 } // namespace blink 2960 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/rendering/RenderLayerRepainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698