зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625930: Fire StyleSheetApplicableStateChanged event explicitly if the stylesheet is getten from the cache. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D81305
This commit is contained in:
Родитель
090a977b95
Коммит
7ad61c2671
|
@ -6587,23 +6587,7 @@ void Document::StyleSheetApplicableStateChanged(StyleSheet& aSheet) {
|
|||
}
|
||||
}
|
||||
|
||||
if (StyleSheetChangeEventsEnabled()) {
|
||||
StyleSheetApplicableStateChangeEventInit init;
|
||||
init.mBubbles = true;
|
||||
init.mCancelable = true;
|
||||
init.mStylesheet = &aSheet;
|
||||
init.mApplicable = applicable;
|
||||
|
||||
RefPtr<StyleSheetApplicableStateChangeEvent> event =
|
||||
StyleSheetApplicableStateChangeEvent::Constructor(
|
||||
this, u"StyleSheetApplicableStateChanged"_ns, init);
|
||||
event->SetTrusted(true);
|
||||
event->SetTarget(this);
|
||||
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(this, event);
|
||||
asyncDispatcher->mOnlyChromeDispatch = ChromeOnlyDispatch::eYes;
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
PostStyleSheetApplicableStateChangeEvent(aSheet);
|
||||
|
||||
if (!mSSApplicableStateNotificationPending) {
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
@ -6615,6 +6599,28 @@ void Document::StyleSheetApplicableStateChanged(StyleSheet& aSheet) {
|
|||
}
|
||||
}
|
||||
|
||||
void Document::PostStyleSheetApplicableStateChangeEvent(StyleSheet& aSheet) {
|
||||
if (!StyleSheetChangeEventsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
StyleSheetApplicableStateChangeEventInit init;
|
||||
init.mBubbles = true;
|
||||
init.mCancelable = true;
|
||||
init.mStylesheet = &aSheet;
|
||||
init.mApplicable = aSheet.IsApplicable();
|
||||
|
||||
RefPtr<StyleSheetApplicableStateChangeEvent> event =
|
||||
StyleSheetApplicableStateChangeEvent::Constructor(
|
||||
this, u"StyleSheetApplicableStateChanged"_ns, init);
|
||||
event->SetTrusted(true);
|
||||
event->SetTarget(this);
|
||||
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(this, event);
|
||||
asyncDispatcher->mOnlyChromeDispatch = ChromeOnlyDispatch::eYes;
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
|
||||
void Document::NotifyStyleSheetApplicableStateChanged() {
|
||||
mSSApplicableStateNotificationPending = false;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
|
|
|
@ -1679,6 +1679,8 @@ class Document : public nsINode,
|
|||
*/
|
||||
void StyleSheetApplicableStateChanged(StyleSheet&);
|
||||
|
||||
void PostStyleSheetApplicableStateChangeEvent(StyleSheet&);
|
||||
|
||||
enum additionalSheetType {
|
||||
eAgentSheet,
|
||||
eUserSheet,
|
||||
|
|
|
@ -317,6 +317,12 @@ void SharedStyleSheetCache::LoadCompletedInternal(
|
|||
"should not get a forced unique inner during parsing");
|
||||
data->mSheet->SetComplete();
|
||||
data->ScheduleLoadEventIfNeeded();
|
||||
} else if (data->mSheet->IsApplicable()) {
|
||||
if (dom::Document* doc = data->mLoader->GetDocument()) {
|
||||
// We post these events for devtools, even though the applicable state
|
||||
// has not actually changed, to make the cache not observable.
|
||||
doc->PostStyleSheetApplicableStateChangeEvent(*data->mSheet);
|
||||
}
|
||||
}
|
||||
|
||||
aDatasToNotify.AppendElement(data);
|
||||
|
|
Загрузка…
Ссылка в новой задаче