Bug 1331294 - Part 1: Make nsPresContext::HasPendingRestyleOrReflow check nsIPresShell::mNeedStyleFlush instead of asking the RestyleManager for its status. r=bholley

This might delay the resolution of FontFaceSet's ready promise in cases
where we don't delay it now, when we call nsIPresShell::SetNeedRestyle for
something other than posting a restyle.  But from the Font Loading API
spec's point of view, I think this is fine.

MozReview-Commit-ID: AnItzSPnIeB
This commit is contained in:
Cameron McCormack 2017-02-10 10:42:29 +08:00
Родитель d9afbf0240
Коммит 6c3d80b9c1
2 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -77,7 +77,6 @@
#include "nsLayoutStylesheetCache.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/ServoRestyleManagerInlines.h"
#include "mozilla/Telemetry.h"
#include "mozilla/dom/Performance.h"
#include "mozilla/dom/PerformanceTiming.h"
@ -2779,8 +2778,8 @@ nsPresContext::NotifyFontFaceSetOnRefresh()
bool
nsPresContext::HasPendingRestyleOrReflow()
{
return (mRestyleManager && mRestyleManager->HasPendingRestyles()) ||
PresShell()->HasPendingReflow();
nsIPresShell* shell = PresShell();
return shell->NeedStyleFlush() || shell->HasPendingReflow();
}
void

Просмотреть файл

@ -162,6 +162,10 @@ function awaitRefresh() {
return awaitOneRefresh().then(awaitOneRefresh);
}
function flushStyles() {
getComputedStyle(document.body).color;
}
function runTest() {
// Document and window from inside the display:none iframe.
var nframe = document.getElementById("n");
@ -956,6 +960,7 @@ function runTest() {
is(document.fonts.status, "loading", "FontFaceSet.status after adding a loading FontFace (TEST 32)");
document.fonts.clear();
flushStyles();
is(document.fonts.status, "loaded", "FontFaceSet.status after clearing (TEST 32)");