Bug 1355349 - Get unanimated style in nsComputedDOMStyle::DoGetStyleContextNoFlush for Servo too; r?hiro
MozReview-Commit-ID: BPtpVfbQ5Kk
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -632,19 +632,21 @@ nsComputedDOMStyle::DoGetStyleContextNoF
if (aAnimationFlag == eWithoutAnimation) {
nsPresContext* presContext = presShell->GetPresContext();
MOZ_ASSERT(presContext, "Should have a prescontext if we have a frame");
if (presContext && presContext->StyleSet()->IsGecko()) {
nsStyleSet* styleSet = presContext->StyleSet()->AsGecko();
return styleSet->ResolveStyleByRemovingAnimation(
aElement, result, eRestyle_AllHintsWithAnimations);
} else {
- NS_WARNING("stylo: Getting the unanimated style context is not yet"
- " supported for Servo");
- return nullptr;
+ RefPtr<ServoComputedValues> baseComputedValues =
+ presContext->StyleSet()->AsServo()->
+ GetBaseComputedValuesForElement(aElement, pseudoType);
+ return NS_NewStyleContext(nullptr, presContext, aPseudo,
+ pseudoType, baseComputedValues.forget());
}
}
// this function returns an addrefed style context
RefPtr<nsStyleContext> ret = result;
return ret.forget();
}
}
@@ -660,17 +662,26 @@ nsComputedDOMStyle::DoGetStyleContextNoF
StyleSetHandle styleSet = presShell->StyleSet();
// For Servo, compute the result directly without recursively building up
// a throwaway style context chain.
if (ServoStyleSet* servoSet = styleSet->GetAsServo()) {
StyleRuleInclusion rules = aStyleType == eDefaultOnly
? StyleRuleInclusion::DefaultOnly
: StyleRuleInclusion::All;
- return servoSet->ResolveTransientStyle(aElement, aPseudo, pseudoType, rules);
+ RefPtr<nsStyleContext> result =
+ servoSet->ResolveTransientStyle(aElement, aPseudo, pseudoType, rules);
+ if (aAnimationFlag == eWithAnimation) {
+ return result.forget();
+ }
+
+ RefPtr<ServoComputedValues> baseComputedValues =
+ servoSet->GetBaseComputedValuesForElement(aElement, pseudoType);
+ return NS_NewStyleContext(nullptr, presContext, aPseudo,
+ pseudoType, baseComputedValues.forget());
}
RefPtr<nsStyleContext> parentContext;
nsIContent* parent = aPseudo ? aElement : aElement->GetParent();
// Don't resolve parent context for document fragments.
if (parent && parent->IsElement()) {
parentContext = GetStyleContextNoFlush(parent->AsElement(), nullptr,
aPresShell, aStyleType);