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

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

Issue 714083003: Revert "Move some scroll invalidations to the paint invalidation phase" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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
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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 1337
1338 for (RenderLayer* child = layer->firstChild(); child; child = child->nextSib ling()) { 1338 for (RenderLayer* child = layer->firstChild(); child; child = child->nextSib ling()) {
1339 // Don't include paint invalidation rects for composited child layers; t hey will paint themselves and have a different origin. 1339 // Don't include paint invalidation rects for composited child layers; t hey will paint themselves and have a different origin.
1340 if (child->isPaintInvalidationContainer()) 1340 if (child->isPaintInvalidationContainer())
1341 continue; 1341 continue;
1342 1342
1343 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(child ); 1343 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(child );
1344 } 1344 }
1345 } 1345 }
1346 1346
1347 LayoutRect paintInvalidationRectIncludingNonCompositingDescendants(RenderLayer* layer)
1348 {
1349 LayoutRect paintInvalidationRect = layer->renderer()->previousPaintInvalidat ionRect();
1350 for (RenderLayer* child = layer->firstChild(); child; child = child->nextSib ling()) {
1351 // Don't include paint invalidation rects for composited child layers; t hey will paint themselves and have a different origin.
1352 if (child->compositingState() == PaintsIntoOwnBacking || child->composit ingState() == PaintsIntoGroupedBacking)
dsinclair 2014/11/11 19:51:23 Should this be isPaintInvalidationContainer()?
1353 continue;
1354
1355 paintInvalidationRect.unite(paintInvalidationRectIncludingNonCompositing Descendants(child));
1356 }
1357 return paintInvalidationRect;
1358 }
1359
1347 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) 1360 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta)
1348 { 1361 {
1349 if (!contentsInCompositedLayer() || hasSlowRepaintObjects()) 1362 if (!contentsInCompositedLayer() || hasSlowRepaintObjects())
1350 return false; 1363 return false;
1351 1364
1352 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty() ) { 1365 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty() ) {
1353 InspectorInstrumentation::didScroll(page()); 1366 InspectorInstrumentation::didScroll(page());
1354 return true; 1367 return true;
1355 } 1368 }
1356 1369
1370 Region regionToUpdate;
1357 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { 1371 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) {
1358 RenderObject* renderer = viewportConstrainedObject; 1372 RenderObject* renderer = viewportConstrainedObject;
1359 ASSERT(renderer->style()->hasViewportConstrainedPosition()); 1373 ASSERT(renderer->style()->hasViewportConstrainedPosition());
1360 ASSERT(renderer->hasLayer()); 1374 ASSERT(renderer->hasLayer());
1361 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); 1375 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
1362 1376
1363 if (layer->isPaintInvalidationContainer()) 1377 CompositingState state = layer->compositingState();
1378 if (state == PaintsIntoOwnBacking || state == PaintsIntoGroupedBacking)
dsinclair 2014/11/11 19:51:23 Should this stay as layer->isPaintInvalidationCont
Julien - ping for review 2014/11/12 18:46:01 Changed as it made more sense.
1364 continue; 1379 continue;
1365 1380
1366 if (layer->subtreeIsInvisible()) 1381 if (layer->subtreeIsInvisible())
1367 continue; 1382 continue;
1368 1383
1369 // If the fixed layer has a blur/drop-shadow filter applied on at least one of its parents, we cannot 1384 // If the fixed layer has a blur/drop-shadow filter applied on at least one of its parents, we cannot
1370 // scroll using the fast path, otherwise the outsets of the filter will be moved around the page. 1385 // scroll using the fast path, otherwise the outsets of the filter will be moved around the page.
1371 if (layer->hasAncestorWithFilterOutsets()) 1386 if (layer->hasAncestorWithFilterOutsets())
1372 return false; 1387 return false;
1373 1388
1374 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(layer ); 1389 IntRect updateRect = pixelSnappedIntRect(paintInvalidationRectIncludingN onCompositingDescendants(layer));
1390
1391 const RenderLayerModelObject* repaintContainer = layer->renderer()->cont ainerForPaintInvalidation();
1392 if (repaintContainer && !repaintContainer->isRenderView()) {
1393 // Invalidate the old and new locations of fixed position elements t hat are not drawn into the RenderView.
1394 updateRect.moveBy(scrollPosition());
1395 IntRect previousRect = updateRect;
1396 previousRect.move(scrollDelta);
1397 // FIXME: Rather than uniting the rects, we should just issue both i nvalidations.
1398 updateRect.unite(previousRect);
1399 layer->renderer()->invalidatePaintUsingContainer(repaintContainer, u pdateRect, PaintInvalidationScroll);
1400 } else {
1401 // Coalesce the paint invalidations that will be issued to the rende rView.
1402 updateRect = contentsToRootView(updateRect);
1403 if (!updateRect.isEmpty())
1404 regionToUpdate.unite(updateRect);
1405 }
1375 } 1406 }
1376 1407
1377 InspectorInstrumentation::didScroll(page()); 1408 InspectorInstrumentation::didScroll(page());
1409
1410 // Invalidate the old and new locations of fixed position elements that are drawn into the RenderView.
1411 Vector<IntRect> subRectsToUpdate = regionToUpdate.rects();
1412 size_t viewportConstrainedObjectsCount = subRectsToUpdate.size();
1413 for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) {
1414 IntRect updateRect = subRectsToUpdate[i];
1415 IntRect scrolledRect = updateRect;
1416 scrolledRect.move(-scrollDelta);
1417 updateRect.unite(scrolledRect);
1418 // FIXME: We should be able to issue these invalidations separately and before we actually scroll.
1419 renderView()->setBackingNeedsPaintInvalidationInRect(rootViewToContents( updateRect), PaintInvalidationScroll);
1420 }
1421
1378 return true; 1422 return true;
1379 } 1423 }
1380 1424
1381 void FrameView::scrollContentsSlowPath(const IntRect& updateRect) 1425 void FrameView::scrollContentsSlowPath(const IntRect& updateRect)
1382 { 1426 {
1383 if (contentsInCompositedLayer()) { 1427 if (contentsInCompositedLayer()) {
1384 IntRect updateRect = visibleContentRect(); 1428 IntRect updateRect = visibleContentRect();
1385 ASSERT(renderView()); 1429 ASSERT(renderView());
1386 renderView()->invalidatePaintRectangle(updateRect); 1430 renderView()->invalidatePaintRectangle(updateRect);
1387 } 1431 }
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 InspectorInstrumentation::willUpdateLayerTree(m_frame.get()); 2591 InspectorInstrumentation::willUpdateLayerTree(m_frame.get());
2548 2592
2549 view->compositor()->updateIfNeededRecursive(); 2593 view->compositor()->updateIfNeededRecursive();
2550 2594
2551 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) 2595 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot())
2552 m_frame->page()->scrollingCoordinator()->updateAfterCompositingChang eIfNeeded(); 2596 m_frame->page()->scrollingCoordinator()->updateAfterCompositingChang eIfNeeded();
2553 2597
2554 updateCompositedSelectionBoundsIfNeeded(); 2598 updateCompositedSelectionBoundsIfNeeded();
2555 2599
2556 InspectorInstrumentation::didUpdateLayerTree(m_frame.get()); 2600 InspectorInstrumentation::didUpdateLayerTree(m_frame.get());
2601
2602 scrollContentsIfNeededRecursive();
dsinclair 2014/11/11 19:51:23 Did you mean to move these up into the if (view) {
Julien - ping for review 2014/11/12 18:46:01 It was a bad merge, fixed.
2603
2604 if (view)
2605 invalidateTreeIfNeededRecursive();
2557 } 2606 }
2558 2607
2559 scrollContentsIfNeededRecursive();
2560
2561 if (view)
2562 invalidateTreeIfNeededRecursive();
2563
2564 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); 2608 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean);
2565 } 2609 }
2566 2610
2567 void FrameView::updateLayoutAndStyleIfNeededRecursive() 2611 void FrameView::updateLayoutAndStyleIfNeededRecursive()
2568 { 2612 {
2569 // We have to crawl our entire tree looking for any FrameViews that need 2613 // We have to crawl our entire tree looking for any FrameViews that need
2570 // layout and make sure they are up to date. 2614 // layout and make sure they are up to date.
2571 // Mac actually tests for intersection with the dirty region and tries not t o 2615 // 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 2616 // 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 2617 // pointless (since those frames will have set a zero timer to layout anyway ), but
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
3506 } 3550 }
3507 3551
3508 void FrameView::scrollContentsIfNeeded() 3552 void FrameView::scrollContentsIfNeeded()
3509 { 3553 {
3510 if (m_pendingScrollDelta.isZero()) 3554 if (m_pendingScrollDelta.isZero())
3511 return; 3555 return;
3512 DoubleSize scrollDelta = m_pendingScrollDelta; 3556 DoubleSize scrollDelta = m_pendingScrollDelta;
3513 m_pendingScrollDelta = DoubleSize(); 3557 m_pendingScrollDelta = DoubleSize();
3514 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. 3558 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283.
3515 scrollContents(flooredIntSize(scrollDelta)); 3559 scrollContents(flooredIntSize(scrollDelta));
3560 updateFixedElementPaintInvalidationRectsAfterScroll();
3561 }
3562
3563 void FrameView::updateFixedElementPaintInvalidationRectsAfterScroll()
3564 {
3565 if (!hasViewportConstrainedObjects())
3566 return;
3567 // Update the paint invalidation rects for fixed elements after scrolling an d invalidation to reflect
3568 // the new scroll position.
3569 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end();
3570 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) {
3571 RenderObject* renderer = *it;
3572 // m_viewportConstrainedObjects should not contain non-viewport constrai ned objects.
3573 ASSERT(renderer->style()->hasViewportConstrainedPosition());
3574 // Fixed items should always have layers.
3575 ASSERT(renderer->hasLayer());
3576 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
3577 // Don't need to do this for composited fixed items.
3578 if (layer->compositingState() == PaintsIntoOwnBacking)
3579 continue;
3580 forceRecomputePaintInvalidationRectsIncludingNonCompositingDescendants(l ayer->renderer());
3581 }
3516 } 3582 }
3517 3583
3518 void FrameView::scrollContents(const IntSize& scrollDelta) 3584 void FrameView::scrollContents(const IntSize& scrollDelta)
3519 { 3585 {
3520 HostWindow* window = hostWindow(); 3586 HostWindow* window = hostWindow();
3521 if (!window) 3587 if (!window)
3522 return; 3588 return;
3523 3589
3524 IntRect clipRect = windowClipRect(); 3590 IntRect clipRect = windowClipRect();
3525 IntRect updateRect = clipRect; 3591 IntRect updateRect = clipRect;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
3958 return; 4024 return;
3959 4025
3960 ScrollableArea::setScrollOrigin(origin); 4026 ScrollableArea::setScrollOrigin(origin);
3961 4027
3962 // Update if the scroll origin changes, since our position will be different if the content size did not change. 4028 // Update if the scroll origin changes, since our position will be different if the content size did not change.
3963 if (updatePositionAtAll && updatePositionSynchronously) 4029 if (updatePositionAtAll && updatePositionSynchronously)
3964 updateScrollbars(scrollOffsetDouble()); 4030 updateScrollbars(scrollOffsetDouble());
3965 } 4031 }
3966 4032
3967 } // namespace blink 4033 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698