Bug 1382077 part 1 - Have StyleSet::MediumFeaturesChanged return nsRestyleHint rather than a bool. r?heycam
MozReview-Commit-ID: 5g3mHU8pxXP
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2112,18 +2112,19 @@ nsPresContext::MediaFeatureValuesChanged
void
nsPresContext::MediaFeatureValuesChanged(nsRestyleHint aRestyleHint,
nsChangeHint aChangeHint)
{
mPendingMediaFeatureValuesChanged = false;
// MediumFeaturesChanged updates the applied rules, so it always gets called.
- if (mShell && mShell->StyleSet()->MediumFeaturesChanged()) {
- aRestyleHint |= eRestyle_Subtree;
+ if (mShell) {
+ aRestyleHint |= mShell->
+ StyleSet()->MediumFeaturesChanged(mPendingViewportChange);
}
if (mPendingViewportChange &&
(mUsesViewportUnits || mDocument->IsStyledByServo())) {
// Rebuild all style data without rerunning selector matching.
//
// FIXME(emilio, bug 1328652): We don't set mUsesViewportUnits in stylo yet,
// so assume the worst.
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -108,20 +108,23 @@ ServoStyleSet::Shutdown()
void
ServoStyleSet::InvalidateStyleForCSSRuleChanges()
{
MOZ_ASSERT(StylistNeedsUpdate());
mPresContext->RestyleManager()->AsServo()->PostRestyleEventForCSSRuleChanges();
}
-bool
-ServoStyleSet::MediumFeaturesChanged() const
+nsRestyleHint
+ServoStyleSet::MediumFeaturesChanged(bool aViewportChanged) const
{
- return Servo_StyleSet_MediumFeaturesChanged(mRawSet.get());
+ if (Servo_StyleSet_MediumFeaturesChanged(mRawSet.get())) {
+ return eRestyle_Subtree;
+ }
+ return nsRestyleHint(0);
}
size_t
ServoStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
if (mStyleRuleMap) {
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -110,17 +110,17 @@ public:
ForceAllStyleDirty();
}
bool StyleSheetsHaveChanged() const
{
return StylistNeedsUpdate();
}
- bool MediumFeaturesChanged() const;
+ nsRestyleHint MediumFeaturesChanged(bool aViewportChanged) const;
void InvalidateStyleForCSSRuleChanges();
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
const RawServoStyleSet* RawSet() const {
return mRawSet.get();
}
--- a/layout/style/StyleSetHandle.h
+++ b/layout/style/StyleSetHandle.h
@@ -155,17 +155,17 @@ public:
inline StyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
inline void AppendAllXBLStyleSheets(nsTArray<StyleSheet*>& aArray) const;
inline nsresult RemoveDocStyleSheet(StyleSheet* aSheet);
inline nsresult AddDocStyleSheet(StyleSheet* aSheet, nsIDocument* aDocument);
inline void RecordStyleSheetChange(StyleSheet* aSheet, StyleSheet::ChangeType);
inline void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot);
inline bool StyleSheetsHaveChanged() const;
inline void InvalidateStyleForCSSRuleChanges();
- inline bool MediumFeaturesChanged();
+ inline nsRestyleHint MediumFeaturesChanged(bool aViewportChanged);
inline already_AddRefed<nsStyleContext>
ProbePseudoElementStyle(dom::Element* aParentElement,
mozilla::CSSPseudoElementType aType,
nsStyleContext* aParentContext);
inline already_AddRefed<nsStyleContext>
ProbePseudoElementStyle(dom::Element* aParentElement,
mozilla::CSSPseudoElementType aType,
nsStyleContext* aParentContext,
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -251,20 +251,20 @@ StyleSetHandle::Ptr::RecordShadowStyleCh
FORWARD(RecordShadowStyleChange, (aShadowRoot));
}
bool
StyleSetHandle::Ptr::StyleSheetsHaveChanged() const
{
FORWARD(StyleSheetsHaveChanged, ());
}
-bool
-StyleSetHandle::Ptr::MediumFeaturesChanged()
+nsRestyleHint
+StyleSetHandle::Ptr::MediumFeaturesChanged(bool aViewportChanged)
{
- FORWARD(MediumFeaturesChanged, ());
+ FORWARD(MediumFeaturesChanged, (aViewportChanged));
}
void
StyleSetHandle::Ptr::InvalidateStyleForCSSRuleChanges()
{
FORWARD(InvalidateStyleForCSSRuleChanges, ());
}
// check whether there is ::before/::after style for an element
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -2669,18 +2669,18 @@ nsStyleSet::HasAttributeDependentStyle(E
if (!(data.mHint & eRestyle_Subtree)) {
// No point keeping the list of selectors around if we are going to
// restyle the whole subtree unconditionally.
aRestyleHintDataResult = Move(data.mHintData);
}
return data.mHint;
}
-bool
-nsStyleSet::MediumFeaturesChanged()
+nsRestyleHint
+nsStyleSet::MediumFeaturesChanged(bool aViewportChanged)
{
NS_ASSERTION(mBatching == 0, "rule processors out of date");
// We can't use WalkRuleProcessors without a content node.
nsPresContext* presContext = PresContext();
bool stylesChanged = false;
for (nsIStyleRuleProcessor* processor : mRuleProcessors) {
if (!processor) {
@@ -2695,17 +2695,20 @@ nsStyleSet::MediumFeaturesChanged()
}
if (mBindingManager) {
bool thisChanged = false;
mBindingManager->MediumFeaturesChanged(presContext, &thisChanged);
stylesChanged = stylesChanged || thisChanged;
}
- return stylesChanged;
+ if (stylesChanged) {
+ return eRestyle_Subtree;
+ }
+ return nsRestyleHint(0);
}
bool
nsStyleSet::EnsureUniqueInnerOnCSSSheets()
{
AutoTArray<StyleSheet*, 32> queue;
for (SheetType type : gCSSSheetTypes) {
for (StyleSheet* sheet : mSheets[type]) {
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -375,20 +375,20 @@ class nsStyleSet final
int32_t aModType,
bool aAttrHasChanged,
const nsAttrValue* aOtherValue,
mozilla::RestyleHintData&
aRestyleHintDataResult);
/*
* Do any processing that needs to happen as a result of a change in
- * the characteristics of the medium, and return whether style rules
- * may have changed as a result.
+ * the characteristics of the medium, and return restyle hint needed
+ * for the change.
*/
- bool MediumFeaturesChanged();
+ nsRestyleHint MediumFeaturesChanged(bool aViewportChanged);
// APIs to manipulate the style sheet lists. The sheets in each
// list are stored with the most significant sheet last.
nsresult AppendStyleSheet(mozilla::SheetType aType,
mozilla::CSSStyleSheet* aSheet);
nsresult PrependStyleSheet(mozilla::SheetType aType,
mozilla::CSSStyleSheet* aSheet);
nsresult RemoveStyleSheet(mozilla::SheetType aType,