Bug 1357583: Tidy the PostRestyleEventForCSSRuleChanges API. r?heycam
MozReview-Commit-ID: BtOWWC5knsi
--- a/layout/base/GeckoRestyleManager.h
+++ b/layout/base/GeckoRestyleManager.h
@@ -268,22 +268,16 @@ public:
* descendants.
* @param aRestyleHintData: Additional data to go with aRestyleHint.
*/
void PostRestyleEvent(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint,
const RestyleHintData* aRestyleHintData = nullptr);
- void PostRestyleEventForCSSRuleChanges(Element* aElement,
- nsRestyleHint aRestyleHint,
- nsChangeHint aMinChangeHint) {
- PostRestyleEvent(aElement, aRestyleHint, aMinChangeHint);
- }
-
public:
/**
* Asynchronously clear style data from the root frame downwards and ensure
* it will all be rebuilt. This is safe to call anytime; it will schedule
* a restyle and take effect next time style changes are flushed.
* This method is used to recompute the style data when some change happens
* outside of any style rules, like a color preference change or a change
* in a system font size, or to fix things up when an optimization in the
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -161,19 +161,16 @@ public:
// the container is null, no work is needed.
void RestyleForAppend(nsIContent* aContainer, nsIContent* aFirstNewContent);
MOZ_DECL_STYLO_METHODS(GeckoRestyleManager, ServoRestyleManager)
inline void PostRestyleEvent(dom::Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint);
- inline void PostRestyleEventForCSSRuleChanges(dom::Element* aElement,
- nsRestyleHint aRestyleHint,
- nsChangeHint aMinChangeHint);
inline void RebuildAllStyleData(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint);
inline void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint);
inline void ProcessPendingRestyles();
inline void ContentStateChanged(nsIContent* aContent,
EventStates aStateMask);
inline void AttributeWillChange(dom::Element* aElement,
--- a/layout/base/RestyleManagerInlines.h
+++ b/layout/base/RestyleManagerInlines.h
@@ -20,25 +20,16 @@ void
RestyleManager::PostRestyleEvent(dom::Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)
{
MOZ_STYLO_FORWARD(PostRestyleEvent, (aElement, aRestyleHint, aMinChangeHint));
}
void
-RestyleManager::PostRestyleEventForCSSRuleChanges(dom::Element* aElement,
- nsRestyleHint aRestyleHint,
- nsChangeHint aMinChangeHint)
-{
- MOZ_STYLO_FORWARD(PostRestyleEventForCSSRuleChanges,
- (aElement, aRestyleHint, aMinChangeHint));
-}
-
-void
RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint)
{
MOZ_STYLO_FORWARD(RebuildAllStyleData, (aExtraHint, aRestyleHint));
}
void
RestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -62,24 +62,20 @@ ServoRestyleManager::PostRestyleEvent(El
if (aRestyleHint & ~eRestyle_AllHintsWithAnimations) {
mHaveNonAnimationRestyles = true;
}
Servo_NoteExplicitHints(aElement, aRestyleHint, aMinChangeHint);
}
void
-ServoRestyleManager::PostRestyleEventForCSSRuleChanges(
- Element* aElement,
- nsRestyleHint aRestyleHint,
- nsChangeHint aMinChangeHint)
+ServoRestyleManager::PostRestyleEventForCSSRuleChanges()
{
mRestyleForCSSRuleChanges = true;
-
- PostRestyleEvent(aElement, aRestyleHint, aMinChangeHint);
+ mPresContext->PresShell()->EnsureStyleFlush();
}
/* static */ void
ServoRestyleManager::PostRestyleEventForAnimations(Element* aElement,
nsRestyleHint aRestyleHint)
{
Servo_NoteExplicitHints(aElement, aRestyleHint, nsChangeHint(0));
}
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -38,20 +38,17 @@ public:
typedef ServoElementSnapshotTable SnapshotTable;
typedef RestyleManager base_type;
explicit ServoRestyleManager(nsPresContext* aPresContext);
void PostRestyleEvent(dom::Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint);
- void PostRestyleEventForLazyConstruction();
- void PostRestyleEventForCSSRuleChanges(dom::Element* aElement,
- nsRestyleHint aRestyleHint,
- nsChangeHint aMinChangeHint);
+ void PostRestyleEventForCSSRuleChanges();
void RebuildAllStyleData(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint);
void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint);
void ProcessPendingRestyles();
void UpdateOnlyAnimationStyles();
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -126,23 +126,17 @@ ServoStyleSet::Shutdown()
ClearNonInheritingStyleContexts();
mRawSet = nullptr;
}
void
ServoStyleSet::InvalidateStyleForCSSRuleChanges()
{
MOZ_ASSERT(StylistNeedsUpdate());
- if (Element* root = mPresContext->Document()->GetDocumentElement()) {
- // FIXME(emilio): Add a nicer API for this.
- mPresContext->RestyleManager()->PostRestyleEventForCSSRuleChanges(
- root, nsRestyleHint(0), nsChangeHint(0));
- }
- // Do nothing, we've recorded the invalidation, and we'll invalidate stuff
- // async when styling something.
+ mPresContext->RestyleManager()->AsServo()->PostRestyleEventForCSSRuleChanges();
}
size_t
ServoStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
// Measurement of the following members may be added later if DMD finds it is
@@ -980,23 +974,23 @@ ServoStyleSet::RecordStyleSheetChange(
ServoStyleSheet* aSheet,
StyleSheet::ChangeType aChangeType)
{
SetStylistStyleSheetsDirty();
switch (aChangeType) {
case StyleSheet::ChangeType::RuleAdded:
case StyleSheet::ChangeType::RuleRemoved:
case StyleSheet::ChangeType::RuleChanged:
- case StyleSheet::ChangeType::ApplicableStateChanged:
// FIXME(emilio): We can presumably do better in a bunch of these.
return ForceAllStyleDirty();
+ case StyleSheet::ChangeType::ApplicableStateChanged:
case StyleSheet::ChangeType::Added:
case StyleSheet::ChangeType::Removed:
- // Do nothing, we've already recorded the change in the AppendFoo methods,
- // etc, and will act consequently.
+ // Do nothing, we've already recorded the change in the
+ // Append/Remove/Replace methods, etc, and will act consequently.
return;
}
}
#ifdef DEBUG
void
ServoStyleSet::AssertTreeIsClean()
{
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -2404,35 +2404,35 @@ nsStyleSet::InvalidateStyleForCSSRuleCha
{
MOZ_ASSERT_IF(mStylesHaveChanged, mChangedScopeStyleRoots.IsEmpty());
AutoTArray<RefPtr<mozilla::dom::Element>, 1> scopeRoots;
mChangedScopeStyleRoots.SwapElements(scopeRoots);
mStylesHaveChanged = false;
nsPresContext* presContext = PresContext();
- RestyleManager* restyleManager = presContext->RestyleManager();
+ RestyleManager* restyleManager = presContext->RestyleManager()->AsGecko();
Element* root = presContext->Document()->GetRootElement();
if (!root) {
// No content to restyle
return;
}
if (scopeRoots.IsEmpty()) {
// If scopeRoots is empty, we know that mStylesHaveChanged was true at
// the beginning of this function, and that we need to restyle the whole
// document.
- restyleManager->PostRestyleEventForCSSRuleChanges(root,
- eRestyle_Subtree,
- nsChangeHint(0));
+ restyleManager->PostRestyleEvent(root,
+ eRestyle_Subtree,
+ nsChangeHint(0));
} else {
for (Element* scopeRoot : scopeRoots) {
- restyleManager->PostRestyleEventForCSSRuleChanges(scopeRoot,
- eRestyle_Subtree,
- nsChangeHint(0));
+ restyleManager->PostRestyleEvent(scopeRoot,
+ eRestyle_Subtree,
+ nsChangeHint(0));
}
}
}
void
nsStyleSet::GCRuleTrees()
{
MOZ_ASSERT(!mInReconstruct);