Bug 1296556: Recreate style contexts inside generated content. r?heycam
MozReview-Commit-ID: JvVyml8yCrO
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -143,44 +143,58 @@ ServoRestyleManager::RecreateStyleContex
f = GetNextContinuationWithSameStyle(f, oldStyleContext)) {
f->SetStyleContext(newContext);
}
// Update pseudo-elements state if appropriate.
if (aContent->IsElement()) {
Element* aElement = aContent->AsElement();
const static CSSPseudoElementType pseudosToRestyle[] = {
- CSSPseudoElementType::before, CSSPseudoElementType::after,
+ CSSPseudoElementType::before,
+ CSSPseudoElementType::after,
};
for (CSSPseudoElementType pseudoType : pseudosToRestyle) {
- nsIAtom* pseudoTag =
- nsCSSPseudoElements::GetPseudoAtom(pseudoType);
+ nsIAtom* pseudoTag = nsCSSPseudoElements::GetPseudoAtom(pseudoType);
+
if (nsIFrame* pseudoFrame =
FrameForPseudoElement(aElement, pseudoTag)) {
// TODO: we could maybe make this more performant via calling into
// Servo just once to know which pseudo-elements we've got to restyle?
RefPtr<nsStyleContext> pseudoContext =
aStyleSet->ProbePseudoElementStyle(aElement, pseudoType,
newContext);
// If pseudoContext is null here, it means the frame is going away, so
// our change hint computation should have already indicated we need
// to reframe.
MOZ_ASSERT_IF(!pseudoContext,
changeHint & nsChangeHint_ReconstructFrame);
if (pseudoContext) {
pseudoFrame->SetStyleContext(pseudoContext);
+
+ // We only care restyling text nodes, since other type of nodes
+ // (images), are still not supported. If that eventually changes, we
+ // may have to write more code here... Or not, I don't think too
+ // many inherited properties can affect those other frames.
+ StyleChildrenIterator it(pseudoFrame->GetContent());
+ for (nsIContent* n = it.GetNextChild(); n; n = it.GetNextChild()) {
+ if (n->IsNodeOfType(nsINode::eTEXT)) {
+ RefPtr<nsStyleContext> childContext =
+ aStyleSet->ResolveStyleForText(n, pseudoContext);
+ MOZ_ASSERT(n->GetPrimaryFrame(),
+ "How? This node is created at FC time!");
+ n->GetPrimaryFrame()->SetStyleContext(childContext);
+ }
+ }
}
}
}
}
- // TODO: There are other continuations we still haven't restyled, mostly
- // pseudo-elements. We have to deal with those, and with anonymous boxes.
aContent->UnsetIsDirtyForServo();
}
if (aContent->HasDirtyDescendantsForServo()) {
MOZ_ASSERT(primaryFrame,
"Frame construction should be scheduled, and it takes the "
"correct style for the children, so no need to be here.");
StyleChildrenIterator it(aContent);