Bug 1367904 - Part 5: stylo: Make GetBaseComputedValuesForElement return a style context; r=bholley

MozReview-Commit-ID: K5WpWc26xNZ
This commit is contained in:
Manish Goregaokar 2017-07-17 11:41:44 -07:00
Родитель 387babf22c
Коммит c2b070c584
7 изменённых файлов: 35 добавлений и 29 удалений

Просмотреть файл

@ -513,13 +513,13 @@ KeyframeEffectReadOnly::EnsureBaseStyles(
"supposed to be called right after getting computed values with " "supposed to be called right after getting computed values with "
"a valid nsPresContext"); "a valid nsPresContext");
RefPtr<const ServoComputedValues> baseComputedValues; RefPtr<ServoStyleContext> baseStyleContext;
for (const AnimationProperty& property : aProperties) { for (const AnimationProperty& property : aProperties) {
EnsureBaseStyle(property, EnsureBaseStyle(property,
mTarget->mPseudoType, mTarget->mPseudoType,
presContext, presContext,
aComputedValues, aComputedValues,
baseComputedValues); baseStyleContext);
} }
} }
@ -529,7 +529,7 @@ KeyframeEffectReadOnly::EnsureBaseStyle(
CSSPseudoElementType aPseudoType, CSSPseudoElementType aPseudoType,
nsPresContext* aPresContext, nsPresContext* aPresContext,
const ServoComputedValues* aComputedStyle, const ServoComputedValues* aComputedStyle,
RefPtr<const ServoComputedValues>& aBaseComputedValues) RefPtr<ServoStyleContext>& aBaseStyleContext)
{ {
bool hasAdditiveValues = false; bool hasAdditiveValues = false;
@ -544,15 +544,18 @@ KeyframeEffectReadOnly::EnsureBaseStyle(
return; return;
} }
if (!aBaseComputedValues) { if (!aBaseStyleContext) {
aBaseComputedValues = aBaseStyleContext =
aPresContext->StyleSet()->AsServo()->GetBaseComputedValuesForElement( aPresContext->StyleSet()->AsServo()->GetBaseContextForElement(
mTarget->mElement, mTarget->mElement,
nullptr,
aPresContext,
nullptr,
aPseudoType, aPseudoType,
aComputedStyle); aComputedStyle);
} }
RefPtr<RawServoAnimationValue> baseValue = RefPtr<RawServoAnimationValue> baseValue =
Servo_ComputedValues_ExtractAnimationValue(aBaseComputedValues, Servo_ComputedValues_ExtractAnimationValue(aBaseStyleContext->ComputedValues(),
aProperty.mProperty).Consume(); aProperty.mProperty).Consume();
mBaseStyleValuesForServo.Put(aProperty.mProperty, baseValue); mBaseStyleValuesForServo.Put(aProperty.mProperty, baseValue);
} }

Просмотреть файл

@ -45,6 +45,7 @@ class ErrorResult;
struct AnimationRule; struct AnimationRule;
struct TimingParams; struct TimingParams;
class EffectSet; class EffectSet;
class ServoStyleContext;
namespace dom { namespace dom {
class ElementOrCSSPseudoElement; class ElementOrCSSPseudoElement;
@ -385,7 +386,7 @@ protected:
CSSPseudoElementType aPseudoType, CSSPseudoElementType aPseudoType,
nsPresContext* aPresContext, nsPresContext* aPresContext,
const ServoComputedValues* aComputedValues, const ServoComputedValues* aComputedValues,
RefPtr<const ServoComputedValues>& aBaseComputedValues); RefPtr<mozilla::ServoStyleContext>& aBaseComputedValues);
Maybe<OwningAnimationTarget> mTarget; Maybe<OwningAnimationTarget> mTarget;

Просмотреть файл

@ -1093,17 +1093,22 @@ ServoStyleSet::GetAnimationValues(
&aAnimationValues); &aAnimationValues);
} }
already_AddRefed<ServoComputedValues> already_AddRefed<ServoStyleContext>
ServoStyleSet::GetBaseComputedValuesForElement( ServoStyleSet::GetBaseContextForElement(
Element* aElement, Element* aElement,
nsStyleContext* aParentContext,
nsPresContext* aPresContext,
nsIAtom* aPseudoTag,
CSSPseudoElementType aPseudoType, CSSPseudoElementType aPseudoType,
ServoComputedValuesBorrowed aStyle) ServoComputedValuesBorrowed aStyle)
{ {
return Servo_StyleSet_GetBaseComputedValuesForElement(mRawSet.get(), RefPtr<ServoComputedValues> cv = Servo_StyleSet_GetBaseComputedValuesForElement(mRawSet.get(),
aElement, aElement,
aStyle, aStyle,
&Snapshots(), &Snapshots(),
aPseudoType).Consume(); aPseudoType).Consume();
return ServoStyleContext::Create(nullptr, aPresContext, aPseudoTag,
aPseudoType, cv.forget());
} }
already_AddRefed<RawServoAnimationValue> already_AddRefed<RawServoAnimationValue>

Просмотреть файл

@ -382,10 +382,13 @@ public:
nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName); nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName);
already_AddRefed<ServoComputedValues> already_AddRefed<ServoStyleContext>
GetBaseComputedValuesForElement(dom::Element* aElement, GetBaseContextForElement(dom::Element* aElement,
CSSPseudoElementType aPseudoType, nsStyleContext* aParentContext,
ServoComputedValuesBorrowed aStyle); nsPresContext* aPresContext,
nsIAtom* aPseudoTag,
CSSPseudoElementType aPseudoType,
ServoComputedValuesBorrowed aStyle);
/** /**
* Resolve style for a given declaration block with/without the parent style. * Resolve style for a given declaration block with/without the parent style.

Просмотреть файл

@ -640,12 +640,9 @@ nsComputedDOMStyle::DoGetStyleContextNoFlush(Element* aElement,
return styleSet->ResolveStyleByRemovingAnimation( return styleSet->ResolveStyleByRemovingAnimation(
aElement, result, eRestyle_AllHintsWithAnimations); aElement, result, eRestyle_AllHintsWithAnimations);
} else { } else {
RefPtr<ServoComputedValues> baseComputedValues = return presContext->StyleSet()->AsServo()->
presContext->StyleSet()->AsServo()-> GetBaseContextForElement(aElement, nullptr, presContext,
GetBaseComputedValuesForElement( aPseudo, pseudoType, result->ComputedValues());
aElement, pseudoType, result->ComputedValues());
return ServoStyleContext::Create(nullptr, presContext, aPseudo,
pseudoType, baseComputedValues.forget());
} }
} }
@ -677,11 +674,8 @@ nsComputedDOMStyle::DoGetStyleContextNoFlush(Element* aElement,
return result.forget(); return result.forget();
} }
RefPtr<ServoComputedValues> baseComputedValues = return servoSet->GetBaseContextForElement(aElement, nullptr, presContext,
servoSet->GetBaseComputedValuesForElement( aPseudo, pseudoType, result->ComputedValues());
aElement, pseudoType, result->ComputedValues());
return ServoStyleContext::Create(nullptr, presContext, aPseudo,
pseudoType, baseComputedValues.forget());
} }
RefPtr<nsStyleContext> parentContext; RefPtr<nsStyleContext> parentContext;

Просмотреть файл

@ -622,7 +622,7 @@ nsStyleContext::Destroy()
} }
} }
already_AddRefed<nsStyleContext> already_AddRefed<GeckoStyleContext>
NS_NewStyleContext(nsStyleContext* aParentContext, NS_NewStyleContext(nsStyleContext* aParentContext,
nsIAtom* aPseudoTag, nsIAtom* aPseudoTag,
CSSPseudoElementType aPseudoType, CSSPseudoElementType aPseudoType,
@ -630,7 +630,7 @@ NS_NewStyleContext(nsStyleContext* aParentContext,
bool aSkipParentDisplayBasedStyleFixup) bool aSkipParentDisplayBasedStyleFixup)
{ {
RefPtr<nsRuleNode> node = aRuleNode; RefPtr<nsRuleNode> node = aRuleNode;
RefPtr<nsStyleContext> context = RefPtr<GeckoStyleContext> context =
new (aRuleNode->PresContext()) new (aRuleNode->PresContext())
GeckoStyleContext(aParentContext, aPseudoTag, aPseudoType, node.forget(), GeckoStyleContext(aParentContext, aPseudoTag, aPseudoType, node.forget(),
aSkipParentDisplayBasedStyleFixup); aSkipParentDisplayBasedStyleFixup);

Просмотреть файл

@ -467,7 +467,7 @@ protected:
#endif #endif
}; };
already_AddRefed<nsStyleContext> already_AddRefed<mozilla::GeckoStyleContext>
NS_NewStyleContext(nsStyleContext* aParentContext, NS_NewStyleContext(nsStyleContext* aParentContext,
nsIAtom* aPseudoTag, nsIAtom* aPseudoTag,
mozilla::CSSPseudoElementType aPseudoType, mozilla::CSSPseudoElementType aPseudoType,