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

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

Issue 2709693003: Repaint selection when element with ::selection style is recalculated. (Closed)
Patch Set: Fixed review issues Created 3 years, 10 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
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. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * Copyright (C) 2009 Google Inc. All rights reserved. 8 * Copyright (C) 2009 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 else 1705 else
1706 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); 1706 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange);
1707 } 1707 }
1708 1708
1709 if (diff.needsPaintInvalidationSubtree() || 1709 if (diff.needsPaintInvalidationSubtree() ||
1710 updatedDiff.needsPaintInvalidationSubtree()) 1710 updatedDiff.needsPaintInvalidationSubtree())
1711 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); 1711 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
1712 else if (diff.needsPaintInvalidationObject() || 1712 else if (diff.needsPaintInvalidationObject() ||
1713 updatedDiff.needsPaintInvalidationObject()) 1713 updatedDiff.needsPaintInvalidationObject())
1714 setShouldDoFullPaintInvalidation(); 1714 setShouldDoFullPaintInvalidation();
1715 else if (diff.needsPaintInvalidationSelection())
1716 invalidatePaintForSelection();
1715 1717
1716 // Text nodes share style with their parents but the paint properties don't 1718 // Text nodes share style with their parents but the paint properties don't
1717 // apply to them, hence the !isText() check. 1719 // apply to them, hence the !isText() check.
1718 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && !isText() && 1720 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && !isText() &&
1719 (diff.transformChanged() || diff.opacityChanged() || 1721 (diff.transformChanged() || diff.opacityChanged() ||
1720 diff.zIndexChanged() || diff.filterChanged() || 1722 diff.zIndexChanged() || diff.filterChanged() ||
1721 diff.backdropFilterChanged() || diff.cssClipChanged())) { 1723 diff.backdropFilterChanged() || diff.cssClipChanged())) {
1722 setNeedsPaintPropertyUpdate(); 1724 setNeedsPaintPropertyUpdate();
1723 1725
1724 // We don't need to invalidate paint of objects on SPv2 when only paint 1726 // We don't need to invalidate paint of objects on SPv2 when only paint
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
3460 3462
3461 LayoutRect LayoutObject::debugRect() const { 3463 LayoutRect LayoutObject::debugRect() const {
3462 LayoutRect rect; 3464 LayoutRect rect;
3463 LayoutBlock* block = containingBlock(); 3465 LayoutBlock* block = containingBlock();
3464 if (block) 3466 if (block)
3465 block->adjustChildDebugRect(rect); 3467 block->adjustChildDebugRect(rect);
3466 3468
3467 return rect; 3469 return rect;
3468 } 3470 }
3469 3471
3472 void LayoutObject::invalidatePaintForSelection() {
3473 // setSelectionState() propagates the state up the containing block chain to
3474 // tell if a block contains selected nodes or not. If this layout object is
3475 // not a block, we need to get the selection state from the containing block
3476 // to tell if we have any selected node children.
3477 LayoutBlock* block =
3478 isLayoutBlock() ? toLayoutBlock(this) : containingBlock();
3479 if (!block)
3480 return;
3481 if (!block->hasSelectedChildren())
3482 return;
3483
3484 // ::selection style only applies to direct selection leaf children of the
3485 // element on which the ::selection style is set. Thus, we only walk the
3486 // direct children here.
3487 for (LayoutObject* child = slowFirstChild(); child;
3488 child = child->nextSibling()) {
3489 if (!child->canBeSelectionLeaf())
3490 continue;
3491 if (child->getSelectionState() == SelectionNone)
3492 continue;
3493 child->setShouldInvalidateSelection();
3494 }
3495 }
3496
3470 } // namespace blink 3497 } // namespace blink
3471 3498
3472 #ifndef NDEBUG 3499 #ifndef NDEBUG
3473 3500
3474 void showTree(const blink::LayoutObject* object) { 3501 void showTree(const blink::LayoutObject* object) {
3475 if (object) 3502 if (object)
3476 object->showTreeForThis(); 3503 object->showTreeForThis();
3477 else 3504 else
3478 WTFLogAlways("%s", "Cannot showTree. Root is (nil)"); 3505 WTFLogAlways("%s", "Cannot showTree. Root is (nil)");
3479 } 3506 }
(...skipping 15 matching lines...) Expand all
3495 const blink::LayoutObject* root = object1; 3522 const blink::LayoutObject* root = object1;
3496 while (root->parent()) 3523 while (root->parent())
3497 root = root->parent(); 3524 root = root->parent();
3498 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3525 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3499 } else { 3526 } else {
3500 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); 3527 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)");
3501 } 3528 }
3502 } 3529 }
3503 3530
3504 #endif 3531 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698