зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1367553: Provide the kind of change that the stylesheet suffered to RecordStyleSheetChange. r=heycam
I plan to use it for now to force a full document restyle when a standalone rule changes or something like that. In practice, we can do better sometimes, and we may just want to propagate to the StyleSet all the style change notifications in order to have access to the rule that changed and all that... But for now this seemed easier than adding other four or five functions to StyleSetHandle. MozReview-Commit-ID: 2BEIliGu4mO --HG-- extra : rebase_source : 926f8442fbd17c7ffa7f72b6b4a515a28b9aa18b
This commit is contained in:
Родитель
e2b5e966dc
Коммит
38735b0dbd
|
@ -4564,13 +4564,14 @@ nsIPresShell::RestyleForCSSRuleChanges()
|
|||
}
|
||||
|
||||
void
|
||||
PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet)
|
||||
PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet,
|
||||
StyleSheet::ChangeType aChangeType)
|
||||
{
|
||||
// too bad we can't check that the update is UPDATE_STYLE
|
||||
NS_ASSERTION(mUpdateCount != 0, "must be in an update");
|
||||
MOZ_ASSERT(aStyleSheet->IsServo() == mStyleSet->IsServo());
|
||||
|
||||
mStyleSet->RecordStyleSheetChange(aStyleSheet);
|
||||
mStyleSet->RecordStyleSheetChange(aStyleSheet, aChangeType);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4581,7 +4582,7 @@ PresShell::StyleSheetAdded(StyleSheet* aStyleSheet,
|
|||
NS_PRECONDITION(aStyleSheet, "Must have a style sheet!");
|
||||
|
||||
if (aStyleSheet->IsApplicable() && aStyleSheet->HasRules()) {
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
RecordStyleSheetChange(aStyleSheet, StyleSheet::ChangeType::Added);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4593,7 +4594,7 @@ PresShell::StyleSheetRemoved(StyleSheet* aStyleSheet,
|
|||
NS_PRECONDITION(aStyleSheet, "Must have a style sheet!");
|
||||
|
||||
if (aStyleSheet->IsApplicable() && aStyleSheet->HasRules()) {
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
RecordStyleSheetChange(aStyleSheet, StyleSheet::ChangeType::Removed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4601,26 +4602,27 @@ void
|
|||
PresShell::StyleSheetApplicableStateChanged(StyleSheet* aStyleSheet)
|
||||
{
|
||||
if (aStyleSheet->HasRules()) {
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
RecordStyleSheetChange(
|
||||
aStyleSheet, StyleSheet::ChangeType::ApplicableStateChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleChanged(StyleSheet* aStyleSheet)
|
||||
{
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
RecordStyleSheetChange(aStyleSheet, StyleSheet::ChangeType::RuleChanged);
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleAdded(StyleSheet* aStyleSheet)
|
||||
{
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
RecordStyleSheetChange(aStyleSheet, StyleSheet::ChangeType::RuleAdded);
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleRemoved(StyleSheet* aStyleSheet)
|
||||
{
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
RecordStyleSheetChange(aStyleSheet, StyleSheet::ChangeType::RuleRemoved);
|
||||
}
|
||||
|
||||
nsPlaceholderFrame*
|
||||
|
|
|
@ -523,7 +523,8 @@ protected:
|
|||
void ShowEventTargetDebug();
|
||||
#endif
|
||||
|
||||
void RecordStyleSheetChange(mozilla::StyleSheet* aStyleSheet);
|
||||
void RecordStyleSheetChange(mozilla::StyleSheet* aStyleSheet,
|
||||
StyleSheet::ChangeType);
|
||||
|
||||
void RemovePreferenceStyles();
|
||||
|
||||
|
|
|
@ -105,8 +105,11 @@ public:
|
|||
void BeginShutdown();
|
||||
void Shutdown();
|
||||
|
||||
void RecordStyleSheetChange(mozilla::ServoStyleSheet*)
|
||||
void RecordStyleSheetChange(mozilla::ServoStyleSheet*, StyleSheet::ChangeType)
|
||||
{
|
||||
// TODO(emilio): Record which kind of changes have we handled, and act
|
||||
// properly in InvalidateStyleForCSSRuleChanges instead of invalidating the
|
||||
// whole document.
|
||||
NoteStyleSheetsChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ public:
|
|||
inline StyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
|
||||
inline nsresult RemoveDocStyleSheet(StyleSheet* aSheet);
|
||||
inline nsresult AddDocStyleSheet(StyleSheet* aSheet, nsIDocument* aDocument);
|
||||
inline void RecordStyleSheetChange(StyleSheet* aSheet);
|
||||
inline void RecordStyleSheetChange(StyleSheet* aSheet, StyleSheet::ChangeType);
|
||||
inline void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot);
|
||||
inline bool StyleSheetsHaveChanged() const;
|
||||
inline void InvalidateStyleForCSSRuleChanges();
|
||||
|
|
|
@ -221,10 +221,11 @@ StyleSetHandle::Ptr::AddDocStyleSheet(StyleSheet* aSheet,
|
|||
}
|
||||
|
||||
void
|
||||
StyleSetHandle::Ptr::RecordStyleSheetChange(StyleSheet* aSheet)
|
||||
StyleSetHandle::Ptr::RecordStyleSheetChange(StyleSheet* aSheet,
|
||||
StyleSheet::ChangeType aChangeType)
|
||||
{
|
||||
FORWARD_CONCRETE(RecordStyleSheetChange, (aSheet->AsGecko()),
|
||||
(aSheet->AsServo()));
|
||||
FORWARD_CONCRETE(RecordStyleSheetChange, (aSheet->AsGecko(), aChangeType),
|
||||
(aSheet->AsServo(), aChangeType));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -63,6 +63,21 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(StyleSheet,
|
||||
nsIDOMCSSStyleSheet)
|
||||
|
||||
/**
|
||||
* The different changes that a stylesheet may go through.
|
||||
*
|
||||
* Used by the StyleSets in order to handle more efficiently some kinds of
|
||||
* changes.
|
||||
*/
|
||||
enum class ChangeType {
|
||||
Added,
|
||||
Removed,
|
||||
ApplicableStateChanged,
|
||||
RuleAdded,
|
||||
RuleRemoved,
|
||||
RuleChanged,
|
||||
};
|
||||
|
||||
void SetOwningNode(nsINode* aOwningNode)
|
||||
{
|
||||
mOwningNode = aOwningNode;
|
||||
|
|
|
@ -2369,7 +2369,8 @@ nsStyleSet::Shutdown()
|
|||
}
|
||||
|
||||
void
|
||||
nsStyleSet::RecordStyleSheetChange(CSSStyleSheet* aStyleSheet)
|
||||
nsStyleSet::RecordStyleSheetChange(CSSStyleSheet* aStyleSheet,
|
||||
StyleSheet::ChangeType)
|
||||
{
|
||||
MOZ_ASSERT(mBatching != 0, "Should be in an update");
|
||||
|
||||
|
|
|
@ -333,7 +333,8 @@ class nsStyleSet final
|
|||
void Shutdown();
|
||||
|
||||
// Notes that a style sheet has changed.
|
||||
void RecordStyleSheetChange(mozilla::CSSStyleSheet* aStyleSheet);
|
||||
void RecordStyleSheetChange(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::StyleSheet::ChangeType);
|
||||
|
||||
// Notes that style sheets have changed in a shadow root.
|
||||
void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot);
|
||||
|
|
Загрузка…
Ссылка в новой задаче