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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 68baec2858e10ef18b15fd7e1892c1b891a5824f..41bf1665bbd286287da76098edf5658280295f78 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -1712,6 +1712,8 @@ void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) {
else if (diff.needsPaintInvalidationObject() ||
updatedDiff.needsPaintInvalidationObject())
setShouldDoFullPaintInvalidation();
+ else if (diff.needsPaintInvalidationSelection())
+ invalidatePaintForSelection();
// Text nodes share style with their parents but the paint properties don't
// apply to them, hence the !isText() check.
@@ -3467,6 +3469,31 @@ LayoutRect LayoutObject::debugRect() const {
return rect;
}
+void LayoutObject::invalidatePaintForSelection() {
+ // setSelectionState() propagates the state up the containing block chain to
+ // tell if a block contains selected nodes or not. If this layout object is
+ // not a block, we need to get the selection state from the containing block
+ // to tell if we have any selected node children.
+ LayoutBlock* block =
+ isLayoutBlock() ? toLayoutBlock(this) : containingBlock();
+ if (!block)
+ return;
+ if (!block->hasSelectedChildren())
+ return;
+
+ // ::selection style only applies to direct selection leaf children of the
+ // element on which the ::selection style is set. Thus, we only walk the
+ // direct children here.
+ for (LayoutObject* child = slowFirstChild(); child;
+ child = child->nextSibling()) {
+ if (!child->canBeSelectionLeaf())
+ continue;
+ if (child->getSelectionState() == SelectionNone)
+ continue;
+ child->setShouldInvalidateSelection();
+ }
+}
+
} // namespace blink
#ifndef NDEBUG
« 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