Bug 1648157 - Add parameter to not iterate subdocs on media change. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D92807
This commit is contained in:
Agi Sferro 2020-10-09 17:31:52 +00:00
parent b855fa6877
commit b1029e4f28
2 changed files with 17 additions and 10 deletions

View File

@ -1542,7 +1542,8 @@ void nsPresContext::PostRebuildAllStyleDataEvent(
}
void nsPresContext::MediaFeatureValuesChangedAllDocuments(
const MediaFeatureChange& aChange) {
const MediaFeatureChange& aChange,
RecurseIntoInProcessSubDocuments aRecurseSubDocuments) {
// Handle the media feature value change in this document.
MediaFeatureValuesChanged(aChange);
@ -1550,14 +1551,17 @@ void nsPresContext::MediaFeatureValuesChangedAllDocuments(
// document is using.
mDocument->ImageTracker()->MediaFeatureValuesChangedAllDocuments(aChange);
// And then into any subdocuments.
auto recurse = [&aChange](dom::Document& aSubDoc) {
if (nsPresContext* pc = aSubDoc.GetPresContext()) {
pc->MediaFeatureValuesChangedAllDocuments(aChange);
}
return CallState::Continue;
};
mDocument->EnumerateSubDocuments(recurse);
if (aRecurseSubDocuments == RecurseIntoInProcessSubDocuments::Yes) {
// And then into any subdocuments.
auto recurse = [&aChange, aRecurseSubDocuments](dom::Document& aSubDoc) {
if (nsPresContext* pc = aSubDoc.GetPresContext()) {
pc->MediaFeatureValuesChangedAllDocuments(aChange,
aRecurseSubDocuments);
}
return CallState::Continue;
};
mDocument->EnumerateSubDocuments(recurse);
}
}
void nsPresContext::FlushPendingMediaFeatureValuesChanged() {

View File

@ -283,6 +283,8 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
void ContentLanguageChanged();
enum class RecurseIntoInProcessSubDocuments : bool { No, Yes };
/**
* Handle changes in the values of media features (used in media queries).
*/
@ -296,7 +298,8 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
* features that must be updated in all subdocuments e.g. display-mode.
*/
void MediaFeatureValuesChangedAllDocuments(
const mozilla::MediaFeatureChange&);
const mozilla::MediaFeatureChange&,
RecurseIntoInProcessSubDocuments = RecurseIntoInProcessSubDocuments::Yes);
/**
* Updates the size mode on all remote children and recursively notifies this