зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1339629 Part 8: Uplift ClearRuleCascades into StyleSheet. r=heycam
MozReview-Commit-ID: CCYIYjWrw86 --HG-- extra : rebase_source : c9f3e4bced29d46ab9c906e58e97465e60fda5ae
This commit is contained in:
Родитель
0d3ac0a207
Коммит
1af9f090ed
|
@ -573,9 +573,6 @@ CSSStyleSheet::EnsureUniqueInner()
|
|||
{
|
||||
StyleSheet::EnsureUniqueInner();
|
||||
|
||||
// otherwise the rule processor has pointers to the old rules
|
||||
ClearRuleCascades();
|
||||
|
||||
// let our containing style sets know that if we call
|
||||
// nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the
|
||||
// document
|
||||
|
@ -628,9 +625,9 @@ CSSStyleSheet::List(FILE* out, int32_t aIndent) const
|
|||
#endif
|
||||
|
||||
void
|
||||
CSSStyleSheet::ClearRuleCascades()
|
||||
CSSStyleSheet::ClearRuleCascadesInternal()
|
||||
{
|
||||
// We might be in ClearRuleCascades because we had a modification
|
||||
// We might be in ClearRuleCascadesInternal because we had a modification
|
||||
// to the sheet that resulted in an nsCSSSelector being destroyed.
|
||||
// Tell the RestyleManager for each document we're used in
|
||||
// so that they can drop any nsCSSSelector pointers (used for
|
||||
|
@ -654,10 +651,6 @@ CSSStyleSheet::ClearRuleCascades()
|
|||
(*iter)->ClearRuleCascades();
|
||||
}
|
||||
}
|
||||
if (mParent) {
|
||||
CSSStyleSheet* parent = (CSSStyleSheet*)mParent;
|
||||
parent->ClearRuleCascades();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -183,7 +183,7 @@ private:
|
|||
protected:
|
||||
virtual ~CSSStyleSheet();
|
||||
|
||||
void ClearRuleCascades();
|
||||
void ClearRuleCascadesInternal() override;
|
||||
|
||||
// Add the namespace mapping from this @namespace rule to our namespace map
|
||||
nsresult RegisterNamespaceRule(css::Rule* aRule);
|
||||
|
|
|
@ -280,6 +280,17 @@ public:
|
|||
*/
|
||||
void NoteStyleSheetsChanged();
|
||||
|
||||
/**
|
||||
* Helper for correctly calling RebuildStylist without paying the cost of an
|
||||
* extra function call in the common no-rebuild-needed case.
|
||||
*/
|
||||
void UpdateStylistIfNeeded()
|
||||
{
|
||||
if (StylistNeedsUpdate()) {
|
||||
UpdateStylist();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void AssertTreeIsClean();
|
||||
#else
|
||||
|
@ -469,17 +480,6 @@ private:
|
|||
*/
|
||||
void UpdateStylist();
|
||||
|
||||
/**
|
||||
* Helper for correctly calling RebuildStylist without paying the cost of an
|
||||
* extra function call in the common no-rebuild-needed case.
|
||||
*/
|
||||
void UpdateStylistIfNeeded()
|
||||
{
|
||||
if (StylistNeedsUpdate()) {
|
||||
UpdateStylist();
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<ServoComputedValues>
|
||||
ResolveStyleLazily(dom::Element* aElement, CSSPseudoElementType aPseudoType);
|
||||
|
||||
|
|
|
@ -213,6 +213,15 @@ ServoStyleSheet::Clone(StyleSheet* aCloneParent,
|
|||
return clone.forget();
|
||||
}
|
||||
|
||||
void
|
||||
ServoStyleSheet::ClearRuleCascadesInternal()
|
||||
{
|
||||
for (StyleSetHandle& setHandle : mStyleSets) {
|
||||
setHandle->AsServo()->NoteStyleSheetsChanged();
|
||||
setHandle->AsServo()->UpdateStylistIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
CSSRuleList*
|
||||
ServoStyleSheet::GetCssRulesInternal(ErrorResult& aRv)
|
||||
{
|
||||
|
|
|
@ -113,6 +113,8 @@ public:
|
|||
protected:
|
||||
virtual ~ServoStyleSheet();
|
||||
|
||||
void ClearRuleCascadesInternal() override;
|
||||
|
||||
ServoStyleSheetInner* Inner() const
|
||||
{
|
||||
return static_cast<ServoStyleSheetInner*>(mInner);
|
||||
|
|
|
@ -127,6 +127,15 @@ StyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
StyleSheet::ClearRuleCascades()
|
||||
{
|
||||
ClearRuleCascadesInternal();
|
||||
if (mParent) {
|
||||
mParent->ClearRuleCascades();
|
||||
}
|
||||
}
|
||||
|
||||
// QueryInterface implementation for StyleSheet
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheet)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
|
@ -437,6 +446,9 @@ StyleSheet::EnsureUniqueInner()
|
|||
MOZ_ASSERT(clone);
|
||||
mInner->RemoveSheet(this);
|
||||
mInner = clone;
|
||||
|
||||
// Ensure we're using the new rules.
|
||||
ClearRuleCascades();
|
||||
}
|
||||
|
||||
// WebIDL CSSStyleSheet API
|
||||
|
|
|
@ -271,6 +271,9 @@ protected:
|
|||
// Traverse our inner, if needed, for cycle collection
|
||||
virtual void TraverseInner(nsCycleCollectionTraversalCallback &);
|
||||
|
||||
void ClearRuleCascades();
|
||||
virtual void ClearRuleCascadesInternal() {}
|
||||
|
||||
StyleSheet* mParent; // weak ref
|
||||
|
||||
nsString mTitle;
|
||||
|
|
Загрузка…
Ссылка в новой задаче