зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1290209 - Part 8: Move CSSStyleSheet::SetEnabled up to StyleSheet. r=xidorn
MozReview-Commit-ID: 7shpy5ghnVR
This commit is contained in:
Родитель
e1710ec7c9
Коммит
13ce7a2e81
|
@ -600,19 +600,9 @@ CSSStyleSheet::HasRules() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CSSStyleSheet::SetEnabled(bool aEnabled)
|
CSSStyleSheet::EnabledStateChangedInternal()
|
||||||
{
|
{
|
||||||
// Internal method, so callers must handle BeginUpdate/EndUpdate
|
ClearRuleCascades();
|
||||||
bool oldDisabled = mDisabled;
|
|
||||||
mDisabled = !aEnabled;
|
|
||||||
|
|
||||||
if (mInner->mComplete && oldDisabled != mDisabled) {
|
|
||||||
ClearRuleCascades();
|
|
||||||
|
|
||||||
if (mDocument) {
|
|
||||||
mDocument->SetStyleSheetApplicableState(this, !mDisabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSStyleSheet*
|
CSSStyleSheet*
|
||||||
|
|
|
@ -115,17 +115,6 @@ public:
|
||||||
|
|
||||||
bool HasRules() const;
|
bool HasRules() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the stylesheet to be enabled. This may or may not make it
|
|
||||||
* applicable. Note that this WILL inform the sheet's document of
|
|
||||||
* its new applicable state if the state changes but WILL NOT call
|
|
||||||
* BeginUpdate() or EndUpdate() on the document -- calling those is
|
|
||||||
* the caller's responsibility. This allows use of SetEnabled when
|
|
||||||
* batched updates are desired. If you want updates handled for
|
|
||||||
* you, see nsIDOMStyleSheet::SetDisabled().
|
|
||||||
*/
|
|
||||||
void SetEnabled(bool aEnabled);
|
|
||||||
|
|
||||||
// style sheet owner info
|
// style sheet owner info
|
||||||
CSSStyleSheet* GetParentSheet() const; // may be null
|
CSSStyleSheet* GetParentSheet() const; // may be null
|
||||||
void SetOwningDocument(nsIDocument* aDocument);
|
void SetOwningDocument(nsIDocument* aDocument);
|
||||||
|
@ -243,6 +232,8 @@ protected:
|
||||||
uint32_t aIndex, ErrorResult& aRv);
|
uint32_t aIndex, ErrorResult& aRv);
|
||||||
void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv);
|
void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv);
|
||||||
|
|
||||||
|
void EnabledStateChangedInternal();
|
||||||
|
|
||||||
RefPtr<CSSStyleSheet> mNext;
|
RefPtr<CSSStyleSheet> mNext;
|
||||||
CSSStyleSheet* mParent; // weak ref
|
CSSStyleSheet* mParent; // weak ref
|
||||||
css::ImportRule* mOwnerRule; // weak ref
|
css::ImportRule* mOwnerRule; // weak ref
|
||||||
|
|
|
@ -1307,7 +1307,7 @@ Loader::PrepareSheet(StyleSheet* aSheet,
|
||||||
aSheet->SetMedia(mediaList);
|
aSheet->SetMedia(mediaList);
|
||||||
|
|
||||||
aSheet->SetTitle(aTitle);
|
aSheet->SetTitle(aTitle);
|
||||||
sheet->SetEnabled(!aIsAlternate);
|
aSheet->SetEnabled(!aIsAlternate);
|
||||||
sheet->SetScopeElement(aScopeElement);
|
sheet->SetScopeElement(aScopeElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,8 @@ protected:
|
||||||
uint32_t aIndex, ErrorResult& aRv);
|
uint32_t aIndex, ErrorResult& aRv);
|
||||||
void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv);
|
void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv);
|
||||||
|
|
||||||
|
void EnabledStateChangedInternal() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DropSheet();
|
void DropSheet();
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,22 @@ StyleSheet::SetComplete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StyleSheet::SetEnabled(bool aEnabled)
|
||||||
|
{
|
||||||
|
// Internal method, so callers must handle BeginUpdate/EndUpdate
|
||||||
|
bool oldDisabled = mDisabled;
|
||||||
|
mDisabled = !aEnabled;
|
||||||
|
|
||||||
|
if (IsComplete() && oldDisabled != mDisabled) {
|
||||||
|
EnabledStateChanged();
|
||||||
|
|
||||||
|
if (mDocument) {
|
||||||
|
mDocument->SetStyleSheetApplicableState(this, !mDisabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StyleSheetInfo::StyleSheetInfo(CORSMode aCORSMode,
|
StyleSheetInfo::StyleSheetInfo(CORSMode aCORSMode,
|
||||||
ReferrerPolicy aReferrerPolicy,
|
ReferrerPolicy aReferrerPolicy,
|
||||||
const dom::SRIMetadata& aIntegrity)
|
const dom::SRIMetadata& aIntegrity)
|
||||||
|
@ -282,6 +298,12 @@ StyleSheet::DeleteRule(uint32_t aIndex,
|
||||||
FORWARD_INTERNAL(DeleteRuleInternal, (aIndex, aRv))
|
FORWARD_INTERNAL(DeleteRuleInternal, (aIndex, aRv))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StyleSheet::EnabledStateChanged()
|
||||||
|
{
|
||||||
|
FORWARD_INTERNAL(EnabledStateChangedInternal, ())
|
||||||
|
}
|
||||||
|
|
||||||
#undef FORWARD_INTERNAL
|
#undef FORWARD_INTERNAL
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -67,6 +67,17 @@ public:
|
||||||
bool IsComplete() const;
|
bool IsComplete() const;
|
||||||
void SetComplete();
|
void SetComplete();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the stylesheet to be enabled. This may or may not make it
|
||||||
|
* applicable. Note that this WILL inform the sheet's document of
|
||||||
|
* its new applicable state if the state changes but WILL NOT call
|
||||||
|
* BeginUpdate() or EndUpdate() on the document -- calling those is
|
||||||
|
* the caller's responsibility. This allows use of SetEnabled when
|
||||||
|
* batched updates are desired. If you want updates handled for
|
||||||
|
* you, see nsIDOMStyleSheet::SetDisabled().
|
||||||
|
*/
|
||||||
|
void SetEnabled(bool aEnabled);
|
||||||
|
|
||||||
MOZ_DECL_STYLO_METHODS(CSSStyleSheet, ServoStyleSheet)
|
MOZ_DECL_STYLO_METHODS(CSSStyleSheet, ServoStyleSheet)
|
||||||
|
|
||||||
// Whether the sheet is for an inline <style> element.
|
// Whether the sheet is for an inline <style> element.
|
||||||
|
@ -198,6 +209,9 @@ protected:
|
||||||
// Drop our reference to mMedia
|
// Drop our reference to mMedia
|
||||||
void DropMedia();
|
void DropMedia();
|
||||||
|
|
||||||
|
// Called from SetEnabled when the enabled state changed.
|
||||||
|
void EnabledStateChanged();
|
||||||
|
|
||||||
nsString mTitle;
|
nsString mTitle;
|
||||||
nsIDocument* mDocument; // weak ref; parents maintain this for their children
|
nsIDocument* mDocument; // weak ref; parents maintain this for their children
|
||||||
nsINode* mOwningNode; // weak ref
|
nsINode* mOwningNode; // weak ref
|
||||||
|
|
Загрузка…
Ссылка в новой задаче