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

Unified Diff: Source/core/dom/ContainerNode.cpp

Issue 135183002: Avoid unnecessary style recalc for subtree of focused element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed contenteditable shadow dom regression. Created 6 years, 11 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
« no previous file with comments | « Source/core/css/AffectedByFocusTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 5664bd9e4f684f44513e6859349ef746e444976c..4d2285f5aee00b9cd026faa5a3e150637e21b7d5 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -791,6 +791,18 @@ LayoutRect ContainerNode::boundingBox() const
return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperLeft) - upperLeft));
}
+static inline StyleChangeType focusStyleChange(const ContainerNode* node)
esprehn 2014/01/22 20:58:52 This should be a private method, you always pass |
rune 2014/01/30 23:24:36 Done. That is, the method is now gone.
+{
+ // -webkit-user-modify (from contenteditable) needs special propagation (see StyleResolver)
+ // into the shadow dom. Do SubtreeStyleChange even if children are not affected by focus to
+ // cover that.
+ if (node->isElementNode() && (toElement(node)->childrenAffectedByFocus() || toElement(node)->shadow()))
esprehn 2014/01/22 20:58:52 This shadow check doesn't seem right, why do you n
rune 2014/01/30 17:24:40 It's about the propagation of -webkit-user-modify
rune 2014/01/30 23:24:36 Done.
+ return SubtreeStyleChange;
+ if (!node->renderer() || node->renderStyle()->affectedByFocus())
+ return LocalStyleChange;
+ return NoStyleChange;
+}
+
// This is used by FrameSelection to denote when the active-state of the page has changed
// independent of the focused element changing.
void ContainerNode::focusStateChanged()
@@ -799,10 +811,10 @@ void ContainerNode::focusStateChanged()
// renderer we can just ignore the state change.
if (!renderer())
return;
- // FIXME: This could probably setNeedsStyleRecalc(LocalStyleChange) in the affectedByFocus case
- // and only setNeedsStyleRecalc(SubtreeStyleChange) in the childrenAffectedByFocus case.
- if (renderStyle()->affectedByFocus() || (isElementNode() && toElement(this)->childrenAffectedByFocus()))
- setNeedsStyleRecalc();
+
+ StyleChangeType change = focusStyleChange(this);
+ if (change != NoStyleChange)
+ setNeedsStyleRecalc(change);
if (renderer() && renderer()->style()->hasAppearance())
RenderTheme::theme().stateChanged(renderer(), FocusState);
}
@@ -816,8 +828,10 @@ void ContainerNode::setFocus(bool received)
focusStateChanged();
// If :focus sets display: none, we lose focus but still need to recalc our style.
- if (!renderer() && !received)
- setNeedsStyleRecalc();
+ if (!renderer() && !received) {
+ ASSERT(focusStyleChange(this) != NoStyleChange);
+ setNeedsStyleRecalc(focusStyleChange(this));
+ }
}
void ContainerNode::setActive(bool down)
« no previous file with comments | « Source/core/css/AffectedByFocusTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698