Bug 1435939: Make media feature changes always async. r=bz

Much in the spirit of bug 1434474.

We right now call MediaFeatureChanges sync or async pretty randomly. This has
caused bugs in the past like bug 1413143.

Unify media feature changes, and only post them async, and flush them from
FlushPendingNotifications.

This also fixes a pre-existing problem where style wasn't flushed correctly from
getComputedStyle when there were pending media feature values.

MozReview-Commit-ID: H9S1M8fk5H4
This commit is contained in:
Emilio Cobos Álvarez
2018-02-06 12:51:32 +01:00
parent 0344085e3c
commit 8fef759837
6 changed files with 197 additions and 103 deletions

View File

@@ -25,6 +25,7 @@
#include "mozilla/HTMLEditor.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/Logging.h"
#include "mozilla/MediaFeatureChange.h"
#include "mozilla/Preferences.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/Services.h"
@@ -4179,7 +4180,8 @@ nsDocShell::SetDeviceSizeIsPageSize(bool aValue)
RefPtr<nsPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
if (presContext) {
presContext->MediaFeatureValuesChanged(nsRestyleHint(0));
presContext->MediaFeatureValuesChanged({
MediaFeatureChangeReason::DeviceSizeIsPageSizeChange });
}
}
return NS_OK;
@@ -14423,7 +14425,8 @@ nsDocShell::SetDisplayMode(uint32_t aDisplayMode)
RefPtr<nsPresContext> presContext;
if (NS_SUCCEEDED(GetPresContext(getter_AddRefs(presContext)))) {
presContext->MediaFeatureValuesChangedAllDocuments(nsRestyleHint(0));
presContext->MediaFeatureValuesChangedAllDocuments({
MediaFeatureChangeReason::DisplayModeChange });
}
}