Bug 1357461: Cache effective media query results. r=heycam

And implement a function that returns whether they changed, to be shared with
Servo.

MozReview-Commit-ID: 8gnAdJaEfZC
This commit is contained in:
Emilio Cobos Álvarez 2017-06-02 17:55:55 +02:00
parent 6c8bd009b6
commit f87691e784
6 changed files with 18 additions and 13 deletions

View File

@ -2070,18 +2070,8 @@ nsPresContext::MediaFeatureValuesChanged(nsRestyleHint aRestyleHint,
mPendingMediaFeatureValuesChanged = false;
// MediumFeaturesChanged updates the applied rules, so it always gets called.
if (mShell) {
// XXXheycam ServoStyleSets don't support responding to medium
// changes yet.
if (mShell->StyleSet()->IsGecko()) {
if (mShell->StyleSet()->AsGecko()->MediumFeaturesChanged()) {
aRestyleHint |= eRestyle_Subtree;
}
} else {
NS_WARNING("stylo: ServoStyleSets don't support responding to medium "
"changes yet. See bug 1290228.");
aRestyleHint |= eRestyle_Subtree;
}
if (mShell && mShell->StyleSet()->MediumFeaturesChanged()) {
aRestyleHint |= eRestyle_Subtree;
}
if (mUsesViewportUnits && mPendingViewportChange) {

View File

@ -54,6 +54,8 @@ SERVO_BINDING_FUNC(Servo_StyleSet_Clear, void,
RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_RebuildData, void,
RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_MediumFeaturesChanged, bool,
RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
RawServoStyleSetBorrowed set,

View File

@ -133,6 +133,12 @@ ServoStyleSet::InvalidateStyleForCSSRuleChanges()
mPresContext->RestyleManager()->AsServo()->PostRestyleEventForCSSRuleChanges();
}
bool
ServoStyleSet::MediumFeaturesChanged() const
{
return Servo_StyleSet_MediumFeaturesChanged(mRawSet.get());
}
size_t
ServoStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{

View File

@ -137,6 +137,8 @@ public:
return StylistNeedsUpdate();
}
bool MediumFeaturesChanged() const;
void InvalidateStyleForCSSRuleChanges();
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;

View File

@ -158,6 +158,7 @@ public:
inline void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot);
inline bool StyleSheetsHaveChanged() const;
inline void InvalidateStyleForCSSRuleChanges();
inline bool MediumFeaturesChanged();
inline already_AddRefed<nsStyleContext>
ProbePseudoElementStyle(dom::Element* aParentElement,
mozilla::CSSPseudoElementType aType,

View File

@ -239,7 +239,11 @@ StyleSetHandle::Ptr::StyleSheetsHaveChanged() const
{
FORWARD(StyleSheetsHaveChanged, ());
}
bool
StyleSetHandle::Ptr::MediumFeaturesChanged()
{
FORWARD(MediumFeaturesChanged, ());
}
void
StyleSetHandle::Ptr::InvalidateStyleForCSSRuleChanges()
{