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

Side by Side Diff: Source/core/layout/LayoutObject.cpp

Issue 1287413002: Fix paint invalidation rect tracking within composited scrolling layers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 } 1312 }
1313 1313
1314 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS tate& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationConta iner) 1314 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS tate& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationConta iner)
1315 { 1315 {
1316 LayoutView* v = view(); 1316 LayoutView* v = view();
1317 if (v->document().printing()) 1317 if (v->document().printing())
1318 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng. 1318 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng.
1319 1319
1320 const LayoutRect oldBounds = previousPaintInvalidationRect(); 1320 const LayoutRect oldBounds = previousPaintInvalidationRect();
1321 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking (); 1321 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking ();
1322 const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidati onContainer, &paintInvalidationState); 1322 LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidationCont ainer, &paintInvalidationState);
1323 const LayoutPoint newLocation = DeprecatedPaintLayer::positionFromPaintInval idationBacking(this, &paintInvalidationContainer, &paintInvalidationState); 1323 LayoutPoint newLocation = DeprecatedPaintLayer::positionFromPaintInvalidatio nBacking(this, &paintInvalidationContainer, &paintInvalidationState);
1324
1325 // Composited scrolling should not be included in the bounds and position tr acking, because the graphics layer backing the scroller
1326 // does not move on scroll.
1327 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) {
1328 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset());
1329 newLocation.move(inverseOffset);
1330 newBounds.move(inverseOffset);
1331 }
1332
1324 setPreviousPaintInvalidationRect(newBounds); 1333 setPreviousPaintInvalidationRect(newBounds);
1325 setPreviousPositionFromPaintInvalidationBacking(newLocation); 1334 setPreviousPositionFromPaintInvalidationBacking(newLocation);
1326 1335
1327 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn validationContainer, oldBounds, oldLocation, newBounds, newLocation); 1336 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn validationContainer, oldBounds, oldLocation, newBounds, newLocation);
1328 1337
1329 // We need to invalidate the selection before checking for whether we are do ing a full invalidation. 1338 // We need to invalidate the selection before checking for whether we are do ing a full invalidation.
1330 // This is because we need to update the old rect regardless. 1339 // This is because we need to update the old rect regardless.
1331 invalidateSelectionIfNeeded(paintInvalidationContainer, invalidationReason); 1340 invalidateSelectionIfNeeded(paintInvalidationContainer, invalidationReason);
1332 1341
1333 // If we are set to do a full paint invalidation that means the LayoutView w ill issue 1342 // If we are set to do a full paint invalidation that means the LayoutView w ill issue
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 // into the incremental invalidation we'll issue two invalidations instead 1424 // into the incremental invalidation we'll issue two invalidations instead
1416 // of one. 1425 // of one.
1417 if (oldBounds.isEmpty()) 1426 if (oldBounds.isEmpty())
1418 return PaintInvalidationBecameVisible; 1427 return PaintInvalidationBecameVisible;
1419 if (newBounds.isEmpty()) 1428 if (newBounds.isEmpty())
1420 return PaintInvalidationBecameInvisible; 1429 return PaintInvalidationBecameInvisible;
1421 1430
1422 return PaintInvalidationIncremental; 1431 return PaintInvalidationIncremental;
1423 } 1432 }
1424 1433
1434 void LayoutObject::adjustInvalidationRectForCompositedScrolling(LayoutRect& rect , const LayoutBoxModelObject& paintInvalidationContainer)
1435 {
1436 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) {
1437 LayoutSize offset(-toLayoutBox(&paintInvalidationContainer)->scrolledCon tentOffset());
1438 rect.move(offset);
1439 }
1440 }
1441
1425 void LayoutObject::incrementallyInvalidatePaint(const LayoutBoxModelObject& pain tInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds , const LayoutPoint& positionFromPaintInvalidationBacking) 1442 void LayoutObject::incrementallyInvalidatePaint(const LayoutBoxModelObject& pain tInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds , const LayoutPoint& positionFromPaintInvalidationBacking)
1426 { 1443 {
1427 ASSERT(oldBounds.location() == newBounds.location()); 1444 ASSERT(oldBounds.location() == newBounds.location());
1428 1445
1429 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); 1446 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX();
1430 if (deltaRight > 0) 1447 if (deltaRight > 0) {
1431 invalidatePaintUsingContainer(paintInvalidationContainer, LayoutRect(old Bounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), PaintInvalidation Incremental); 1448 LayoutRect invalidationRect(oldBounds.maxX(), newBounds.y(), deltaRight, newBounds.height());
1432 else if (deltaRight < 0) 1449 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva lidationContainer);
1433 invalidatePaintUsingContainer(paintInvalidationContainer, LayoutRect(new Bounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), PaintInvalidatio nIncremental); 1450 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe ct, PaintInvalidationIncremental);
1451 } else if (deltaRight < 0) {
1452 LayoutRect invalidationRect(newBounds.maxX(), oldBounds.y(), -deltaRight , oldBounds.height());
1453 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva lidationContainer);
1454 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe ct, PaintInvalidationIncremental);
1455 }
1434 1456
1435 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY(); 1457 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY();
1436 if (deltaBottom > 0) 1458 if (deltaBottom > 0) {
1437 invalidatePaintUsingContainer(paintInvalidationContainer, LayoutRect(new Bounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), PaintInvalidation Incremental); 1459 LayoutRect invalidationRect(newBounds.x(), oldBounds.maxY(), newBounds.w idth(), deltaBottom);
1438 else if (deltaBottom < 0) 1460 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva lidationContainer);
1439 invalidatePaintUsingContainer(paintInvalidationContainer, LayoutRect(old Bounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), PaintInvalidatio nIncremental); 1461 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe ct, PaintInvalidationIncremental);
1462 } else if (deltaBottom < 0) {
1463 LayoutRect invalidationRect(oldBounds.x(), newBounds.maxY(), oldBounds.w idth(), -deltaBottom);
1464 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva lidationContainer);
1465 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe ct, PaintInvalidationIncremental);
1466 }
1440 } 1467 }
1441 1468
1442 void LayoutObject::fullyInvalidatePaint(const LayoutBoxModelObject& paintInvalid ationContainer, PaintInvalidationReason invalidationReason, const LayoutRect& ol dBounds, const LayoutRect& newBounds) 1469 void LayoutObject::fullyInvalidatePaint(const LayoutBoxModelObject& paintInvalid ationContainer, PaintInvalidationReason invalidationReason, const LayoutRect& ol dBounds, const LayoutRect& newBounds)
1443 { 1470 {
1444 // Otherwise do full paint invalidation. 1471 // Otherwise do full paint invalidation.
1445 invalidatePaintUsingContainer(paintInvalidationContainer, oldBounds, invalid ationReason); 1472 LayoutRect invalidationRect = oldBounds;
1446 if (newBounds != oldBounds) 1473 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInvalida tionContainer);
1447 invalidatePaintUsingContainer(paintInvalidationContainer, newBounds, inv alidationReason); 1474 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRect, invalidationReason);
1475 if (newBounds != oldBounds) {
1476 invalidationRect = newBounds;
1477 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva lidationContainer);
1478 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe ct, invalidationReason);
1479 }
1448 } 1480 }
1449 1481
1450 void LayoutObject::invalidatePaintForOverflow() 1482 void LayoutObject::invalidatePaintForOverflow()
1451 { 1483 {
1452 } 1484 }
1453 1485
1454 void LayoutObject::invalidatePaintForOverflowIfNeeded() 1486 void LayoutObject::invalidatePaintForOverflowIfNeeded()
1455 { 1487 {
1456 if (shouldInvalidateOverflowForPaint()) 1488 if (shouldInvalidateOverflowForPaint())
1457 invalidatePaintForOverflow(); 1489 invalidatePaintForOverflow();
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after
3280 traverseNonCompositingDescendants(const_cast<LayoutObject&>(object), Functor (paintInvalidationContainer)); 3312 traverseNonCompositingDescendants(const_cast<LayoutObject&>(object), Functor (paintInvalidationContainer));
3281 } 3313 }
3282 3314
3283 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() 3315 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants()
3284 { 3316 {
3285 class Functor : public LayoutObjectTraversalFunctor { 3317 class Functor : public LayoutObjectTraversalFunctor {
3286 public: 3318 public:
3287 explicit Functor(const LayoutBoxModelObject& paintInvalidationContainer) : m_paintInvalidationContainer(paintInvalidationContainer) { } 3319 explicit Functor(const LayoutBoxModelObject& paintInvalidationContainer) : m_paintInvalidationContainer(paintInvalidationContainer) { }
3288 void operator()(LayoutObject& object) const override 3320 void operator()(LayoutObject& object) const override
3289 { 3321 {
3290 object.invalidatePaintUsingContainer(m_paintInvalidationContainer, o bject.previousPaintInvalidationRect(), PaintInvalidationLayer); 3322 LayoutRect invalidationRect = object.previousPaintInvalidationRect() ;
3323 object.adjustInvalidationRectForCompositedScrolling(invalidationRect , m_paintInvalidationContainer);
3324 object.invalidatePaintUsingContainer(m_paintInvalidationContainer, i nvalidationRect, PaintInvalidationLayer);
3291 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) 3325 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
3292 object.invalidateDisplayItemClients(m_paintInvalidationContainer ); 3326 object.invalidateDisplayItemClients(m_paintInvalidationContainer );
3293 } 3327 }
3294 private: 3328 private:
3295 const LayoutBoxModelObject& m_paintInvalidationContainer; 3329 const LayoutBoxModelObject& m_paintInvalidationContainer;
3296 }; 3330 };
3297 3331
3298 // Since we're only painting non-composited layers, we know that they all sh are the same paintInvalidationContainer. 3332 // Since we're only painting non-composited layers, we know that they all sh are the same paintInvalidationContainer.
3299 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validationOnRootedTree(); 3333 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validationOnRootedTree();
3300 traverseNonCompositingDescendants(*this, Functor(paintInvalidationContainer) ); 3334 traverseNonCompositingDescendants(*this, Functor(paintInvalidationContainer) );
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 const blink::LayoutObject* root = object1; 3393 const blink::LayoutObject* root = object1;
3360 while (root->parent()) 3394 while (root->parent())
3361 root = root->parent(); 3395 root = root->parent();
3362 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3396 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3363 } else { 3397 } else {
3364 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3398 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3365 } 3399 }
3366 } 3400 }
3367 3401
3368 #endif 3402 #endif
OLDNEW
« Source/core/layout/LayoutObject.h ('K') | « Source/core/layout/LayoutObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698