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

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

Issue 169643003: Avoid unnecessary style recalc for subtree of focused element. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« 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 1f02da09fd1c53bab08ead0b8b89cd710abfab4e..c117d5f2651f171e17b02733d284f38e18fff523 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -808,10 +808,12 @@ 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()))
+
+ if (isElementNode() && toElement(this)->childrenAffectedByFocus())
setNeedsStyleRecalc(SubtreeStyleChange);
+ else if (renderStyle()->affectedByFocus())
+ setNeedsStyleRecalc(LocalStyleChange);
+
if (renderer() && renderer()->style()->hasAppearance())
RenderTheme::theme().stateChanged(renderer(), FocusState);
}
@@ -824,9 +826,15 @@ void ContainerNode::setFocus(bool received)
Node::setFocus(received);
focusStateChanged();
+
+ if (renderer() || received)
+ return;
+
// If :focus sets display: none, we lose focus but still need to recalc our style.
- if (!renderer() && !received)
+ if (isElementNode() && toElement(this)->childrenAffectedByFocus())
setNeedsStyleRecalc(SubtreeStyleChange);
+ else
+ setNeedsStyleRecalc(LocalStyleChange);
}
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