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

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

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

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

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

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

@ -382,8 +382,11 @@ public:
nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName);
already_AddRefed<ServoComputedValues>
GetBaseComputedValuesForElement(dom::Element* aElement,
already_AddRefed<ServoStyleContext>
GetBaseContextForElement(dom::Element* aElement,
nsStyleContext* aParentContext,
nsPresContext* aPresContext,
nsIAtom* aPseudoTag,
CSSPseudoElementType aPseudoType,
ServoComputedValuesBorrowed aStyle);

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

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

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

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

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

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