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

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

Issue 144963002: Make pseudo element update work with LocalStyleChange. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase 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 | « no previous file | Source/core/rendering/style/RenderStyle.h » ('j') | Source/core/rendering/style/RenderStyle.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index c528b8b77d020664125a92a4a8982195bb92fcdb..f9fea35ddab901b7bd03966c8af7b2662a81f7bd 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1590,9 +1590,14 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling)
}
// If we reattached we don't need to recalc the style of our descendants anymore.
- if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc())
+ if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc()) {
recalcChildStyle(change);
- clearChildNeedsStyleRecalc();
+ clearChildNeedsStyleRecalc();
+ } else if (change == UpdatePseudoElements) {
+ updatePseudoElement(BEFORE, change);
+ updatePseudoElement(AFTER, change);
+ updatePseudoElement(BACKDROP, change);
esprehn 2014/01/24 22:53:49 Can you just merge this into recalcChildStyle? If
rune 2014/01/25 00:00:38 I've tried in patch set 6. I've changed it so that
+ }
if (hasCustomStyleCallbacks())
didRecalcStyle(change);
@@ -1651,10 +1656,13 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change)
if (styleChangeType() >= SubtreeStyleChange)
return Force;
- if (change <= Inherit)
- return localChange;
+ if (change > Inherit || localChange > Inherit)
+ return max(localChange, change);
- return max(localChange, change);
+ if (localChange < Inherit && (oldStyle->hasContentPseudoStyle() || newStyle->hasContentPseudoStyle()))
+ return UpdatePseudoElements;
+
+ return localChange;
}
void Element::recalcChildStyle(StyleRecalcChange change)
@@ -2768,8 +2776,10 @@ void Element::normalizeAttributes()
void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
{
+ ASSERT(!needsStyleRecalc());
PseudoElement* element = pseudoElement(pseudoId);
- if (element && (needsStyleRecalc() || shouldRecalcStyle(change, element))) {
+ if (element && (change == UpdatePseudoElements || shouldRecalcStyle(change, element))) {
+
// Need to clear the cached style if the PseudoElement wants a recalc so it
// computes a new style.
if (element->needsStyleRecalc())
@@ -2778,7 +2788,7 @@ void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
// PseudoElement styles hang off their parent element's style so if we needed
// a style recalc we should Force one on the pseudo.
// FIXME: We should figure out the right text sibling to pass.
- element->recalcStyle(needsStyleRecalc() ? Force : change);
+ element->recalcStyle(change == UpdatePseudoElements ? Force : change);
// Wait until our parent is not displayed or pseudoElementRendererIsNeeded
// is false, otherwise we could continously create and destroy PseudoElements
@@ -2786,8 +2796,9 @@ void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
// PseudoElement's renderer for each style recalc.
if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedPseudoStyle(pseudoId)))
elementRareData()->setPseudoElement(pseudoId, 0);
- } else if (change >= Inherit || needsStyleRecalc())
+ } else if (change >= UpdatePseudoElements) {
createPseudoElementIfNeeded(pseudoId);
+ }
}
bool Element::needsPseudoElement(PseudoId pseudoId, const RenderStyle& style) const
« no previous file with comments | « no previous file | Source/core/rendering/style/RenderStyle.h » ('j') | Source/core/rendering/style/RenderStyle.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698