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

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

Issue 1456953003: Revert of Calculate paint invalidation rect for scrollbars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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) 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 3280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 return gModifyLayoutTreeStructureAnyState; 3291 return gModifyLayoutTreeStructureAnyState;
3292 } 3292 }
3293 3293
3294 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() 3294 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts()
3295 : m_disabler(gDisablePaintInvalidationStateAsserts, true) 3295 : m_disabler(gDisablePaintInvalidationStateAsserts, true)
3296 { 3296 {
3297 } 3297 }
3298 3298
3299 namespace { 3299 namespace {
3300 3300
3301 // TODO(trchen): Use std::function<void, LayoutObject&> when available. 3301 // TODO(trchen): Use std::function<void, LayoutObject&> and lambda when availabl e.
3302 template <typename LayoutObjectTraversalFunctor> 3302 class LayoutObjectTraversalFunctor {
3303 public:
3304 virtual void operator()(LayoutObject&) const = 0;
3305 };
3306
3303 void traverseNonCompositingDescendants(LayoutObject&, const LayoutObjectTraversa lFunctor&); 3307 void traverseNonCompositingDescendants(LayoutObject&, const LayoutObjectTraversa lFunctor&);
3304 3308
3305 template <typename LayoutObjectTraversalFunctor>
3306 void findNonCompositedDescendantLayerToTraverse(LayoutObject& object, const Layo utObjectTraversalFunctor& functor) 3309 void findNonCompositedDescendantLayerToTraverse(LayoutObject& object, const Layo utObjectTraversalFunctor& functor)
3307 { 3310 {
3308 LayoutObject* descendant = object.nextInPreOrder(&object); 3311 LayoutObject* descendant = object.nextInPreOrder(&object);
3309 while (descendant) { 3312 while (descendant) {
3310 // Case 1: If the descendant has no layer, keep searching until we find a layer. 3313 // Case 1: If the descendant has no layer, keep searching until we find a layer.
3311 if (!descendant->hasLayer()) { 3314 if (!descendant->hasLayer()) {
3312 descendant = descendant->nextInPreOrder(&object); 3315 descendant = descendant->nextInPreOrder(&object);
3313 continue; 3316 continue;
3314 } 3317 }
3315 // Case 2: The descendant has a layer and is not composited. 3318 // Case 2: The descendant has a layer and is not composited.
(...skipping 10 matching lines...) Expand all
3326 if (descendant->styleRef().isStackingContext()) { 3329 if (descendant->styleRef().isStackingContext()) {
3327 descendant = descendant->nextInPreOrderAfterChildren(&object); 3330 descendant = descendant->nextInPreOrderAfterChildren(&object);
3328 continue; 3331 continue;
3329 } 3332 }
3330 // Case 4: The descendant is an invalidation container but not a stackin g context. 3333 // Case 4: The descendant is an invalidation container but not a stackin g context.
3331 // This is the same situation as the root, thus keep searching. 3334 // This is the same situation as the root, thus keep searching.
3332 descendant = descendant->nextInPreOrder(&object); 3335 descendant = descendant->nextInPreOrder(&object);
3333 } 3336 }
3334 } 3337 }
3335 3338
3336 template <typename LayoutObjectTraversalFunctor>
3337 void traverseNonCompositingDescendants(LayoutObject& object, const LayoutObjectT raversalFunctor& functor) 3339 void traverseNonCompositingDescendants(LayoutObject& object, const LayoutObjectT raversalFunctor& functor)
3338 { 3340 {
3339 functor(object); 3341 functor(object);
3340 LayoutObject* descendant = object.nextInPreOrder(&object); 3342 LayoutObject* descendant = object.nextInPreOrder(&object);
3341 while (descendant) { 3343 while (descendant) {
3342 if (!descendant->isPaintInvalidationContainer()) { 3344 if (!descendant->isPaintInvalidationContainer()) {
3343 functor(*descendant); 3345 functor(*descendant);
3344 descendant = descendant->nextInPreOrder(&object); 3346 descendant = descendant->nextInPreOrder(&object);
3345 continue; 3347 continue;
3346 } 3348 }
3347 if (descendant->styleRef().isStackingContext()) { 3349 if (descendant->styleRef().isStackingContext()) {
3348 descendant = descendant->nextInPreOrderAfterChildren(&object); 3350 descendant = descendant->nextInPreOrderAfterChildren(&object);
3349 continue; 3351 continue;
3350 } 3352 }
3351 3353
3352 // If a paint invalidation container is not a stacking context, 3354 // If a paint invalidation container is not a stacking context,
3353 // some of its descendants may belong to the parent container. 3355 // some of its descendants may belong to the parent container.
3354 findNonCompositedDescendantLayerToTraverse(*descendant, functor); 3356 findNonCompositedDescendantLayerToTraverse(*descendant, functor);
3355 descendant = descendant->nextInPreOrderAfterChildren(&object); 3357 descendant = descendant->nextInPreOrderAfterChildren(&object);
3356 } 3358 }
3357 } 3359 }
3358 3360
3359 } // unnamed namespace 3361 } // unnamed namespace
3360 3362
3361 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant s(const LayoutBoxModelObject* paintInvalidationContainer, PaintInvalidationReaso n paintInvalidationReason, const LayoutRect* paintInvalidationRect) const 3363 void LayoutObject::invalidateDisplayItemClientForNonCompositingDescendantsOf(con st LayoutObject& object) const
3362 { 3364 {
3365 // Not using enclosingCompositedContainer() directly because this object may be in an orphaned subtree.
3366 PaintLayer* enclosingLayer = this->enclosingLayer();
3367 if (!enclosingLayer)
3368 return;
3369
3370 // TODO(wangxianzhu): This is a workaround for invalidation of detached cust om scrollbar parts which can't find
3371 // their own enclosing layers. May remove this when fixing crbug.com/547119 for scrollbars.
3372 enclosingLayer->setNeedsRepaint();
3373
3363 // This is valid because we want to invalidate the client in the display ite m list of the current backing. 3374 // This is valid because we want to invalidate the client in the display ite m list of the current backing.
3364 DisableCompositingQueryAsserts disabler; 3375 DisableCompositingQueryAsserts disabler;
3365 if (!paintInvalidationContainer) { 3376 const PaintLayer* paintInvalidationLayer = enclosingLayer->enclosingLayerFor PaintInvalidationCrossingFrameBoundaries();
3366 // Not using enclosingCompositedContainer() directly because this object may be in an orphaned subtree. 3377 if (!paintInvalidationLayer)
3367 PaintLayer* enclosingLayer = this->enclosingLayer(); 3378 return;
3368 if (!enclosingLayer)
3369 return;
3370 const PaintLayer* paintInvalidationLayer = enclosingLayer->enclosingLaye rForPaintInvalidationCrossingFrameBoundaries();
3371 if (!paintInvalidationLayer)
3372 return;
3373 paintInvalidationContainer = paintInvalidationLayer->layoutObject();
3374 }
3375 3379
3376 traverseNonCompositingDescendants(const_cast<LayoutObject&>(*this), [&paintI nvalidationContainer, paintInvalidationReason, paintInvalidationRect](LayoutObje ct& object) { 3380 class Functor : public LayoutObjectTraversalFunctor {
3377 object.invalidateDisplayItemClients(*paintInvalidationContainer, paintIn validationReason, paintInvalidationRect); 3381 public:
3378 }); 3382 explicit Functor(const LayoutBoxModelObject& paintInvalidationContainer) : m_paintInvalidationContainer(paintInvalidationContainer) { }
3383 void operator()(LayoutObject& object) const override
3384 {
3385 // TODO(wangxianzhu): Ensure correct bounds for the client will be o r has been passed to PaintController. crbug.com/547119.
3386 object.invalidateDisplayItemClients(m_paintInvalidationContainer, Pa intInvalidationFull, nullptr);
3387 }
3388 private:
3389 const LayoutBoxModelObject& m_paintInvalidationContainer;
3390 };
3391
3392 const LayoutBoxModelObject& paintInvalidationContainer = *paintInvalidationL ayer->layoutObject();
3393 traverseNonCompositingDescendants(const_cast<LayoutObject&>(object), Functor (paintInvalidationContainer));
3379 } 3394 }
3380 3395
3381 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo xModelObject& paintInvalidationContainer, PaintInvalidationReason reason) 3396 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo xModelObject& paintInvalidationContainer, PaintInvalidationReason reason)
3382 { 3397 {
3383 // These disablers are valid because we want to use the current compositing/ invalidation status. 3398 // These disablers are valid because we want to use the current compositing/ invalidation status.
3384 DisablePaintInvalidationStateAsserts invalidationDisabler; 3399 DisablePaintInvalidationStateAsserts invalidationDisabler;
3385 DisableCompositingQueryAsserts compositingDisabler; 3400 DisableCompositingQueryAsserts compositingDisabler;
3386 3401
3387 LayoutRect invalidationRect = previousPaintInvalidationRect(); 3402 LayoutRect invalidationRect = previousPaintInvalidationRect();
3388 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInvalida tionContainer); 3403 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInvalida tionContainer);
3389 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRect, PaintInvalidationLayer); 3404 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRect, PaintInvalidationLayer);
3390 3405
3391 // The PaintController may have changed. Pass the previous paint invalidatio n rect to the new PaintController. 3406 // The PaintController may have changed. Pass the previous paint invalidatio n rect to the new PaintController.
3392 // The rect will be updated if it changes during the next paint invalidation . 3407 // The rect will be updated if it changes during the next paint invalidation .
3393 invalidateDisplayItemClients(paintInvalidationContainer, PaintInvalidationLa yer, &invalidationRect); 3408 invalidateDisplayItemClients(paintInvalidationContainer, PaintInvalidationLa yer, &invalidationRect);
3394 3409
3395 // This method may be used to invalidate paint of an object changing paint i nvalidation container. 3410 // This method may be used to invalidate paint of an object changing paint i nvalidation container.
3396 // Clear previous paint invalidation rect on the original paint invalidation container to avoid 3411 // Clear previous paint invalidation rect on the original paint invalidation container to avoid
3397 // under-invalidation if the new paint invalidation rect on the new paint in validation container 3412 // under-invalidation if the new paint invalidation rect on the new paint in validation container
3398 // happens to be the same as the old one. 3413 // happens to be the same as the old one.
3399 setPreviousPaintInvalidationRect(LayoutRect()); 3414 setPreviousPaintInvalidationRect(LayoutRect());
3400 } 3415 }
3401 3416
3402 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() 3417 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants()
3403 { 3418 {
3419 class Functor : public LayoutObjectTraversalFunctor {
3420 public:
3421 explicit Functor(const LayoutBoxModelObject& paintInvalidationContainer) : m_paintInvalidationContainer(paintInvalidationContainer) { }
3422 void operator()(LayoutObject& object) const override
3423 {
3424 object.invalidatePaintOfPreviousPaintInvalidationRect(m_paintInvalid ationContainer, PaintInvalidationLayer);
3425 }
3426 private:
3427 const LayoutBoxModelObject& m_paintInvalidationContainer;
3428 };
3429
3404 // Since we're only painting non-composited layers, we know that they all sh are the same paintInvalidationContainer. 3430 // Since we're only painting non-composited layers, we know that they all sh are the same paintInvalidationContainer.
3405 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validationOnRootedTree(); 3431 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validationOnRootedTree();
3406 traverseNonCompositingDescendants(*this, [&paintInvalidationContainer](Layou tObject& object) { 3432 traverseNonCompositingDescendants(*this, Functor(paintInvalidationContainer) );
3407 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC ontainer, PaintInvalidationLayer);
3408 });
3409 } 3433 }
3410 3434
3411 // FIXME: If we had a flag to force invalidations in a whole subtree, we could g et rid of this function (crbug.com/410097). 3435 // FIXME: If we had a flag to force invalidations in a whole subtree, we could g et rid of this function (crbug.com/410097).
3412 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants() 3436 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants()
3413 { 3437 {
3438 class Functor : public LayoutObjectTraversalFunctor {
3439 public:
3440 void operator()(LayoutObject& object) const override
3441 {
3442 object.setShouldDoFullPaintInvalidation();
3443 }
3444 };
3445
3414 // Need to access the current compositing status. 3446 // Need to access the current compositing status.
3415 DisableCompositingQueryAsserts disabler; 3447 DisableCompositingQueryAsserts disabler;
3416 traverseNonCompositingDescendants(*this, [](LayoutObject& object) { 3448 traverseNonCompositingDescendants(*this, Functor());
3417 object.setShouldDoFullPaintInvalidation();
3418 });
3419 } 3449 }
3420 3450
3421 void LayoutObject::invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBoxModelObject& paintInvalidationContainer) 3451 void LayoutObject::invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBoxModelObject& paintInvalidationContainer)
3422 { 3452 {
3423 invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationContainer, P aintInvalidationLayer); 3453 invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationContainer, P aintInvalidationLayer);
3424 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli ng()) { 3454 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli ng()) {
3425 if (!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSel fPaintingLayer()) 3455 if (!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSel fPaintingLayer())
3426 child->invalidatePaintIncludingNonSelfPaintingLayerDescendants(paint InvalidationContainer); 3456 child->invalidatePaintIncludingNonSelfPaintingLayerDescendants(paint InvalidationContainer);
3427 } 3457 }
3428 } 3458 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3488 const blink::LayoutObject* root = object1; 3518 const blink::LayoutObject* root = object1;
3489 while (root->parent()) 3519 while (root->parent())
3490 root = root->parent(); 3520 root = root->parent();
3491 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3521 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3492 } else { 3522 } else {
3493 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3523 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3494 } 3524 }
3495 } 3525 }
3496 3526
3497 #endif 3527 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutScrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698