Bug 1430844: Add assertions that would've caught this. r=bz

MozReview-Commit-ID: 1UfhIRn2We2
This commit is contained in:
Emilio Cobos Álvarez 2018-01-16 20:48:58 +01:00
Родитель cd4b889709
Коммит 271544691d
4 изменённых файлов: 23 добавлений и 7 удалений

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

@ -562,6 +562,8 @@ GeckoRestyleManager::ProcessPendingRestyles()
NS_PRECONDITION(PresContext()->Document(), "No document? Pshaw!");
NS_PRECONDITION(!nsContentUtils::IsSafeToRunScript(),
"Missing a script blocker!");
MOZ_ASSERT(!PresContext()->HasPendingMediaQueryUpdates(),
"Someone forgot to update media queries?");
// First do any queued-up frame creation. (We should really
// merge this into the rest of the process, though; see bug 827239.)

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

@ -1093,13 +1093,18 @@ ServoRestyleManager::SnapshotFor(Element* aElement)
void
ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
{
MOZ_ASSERT(PresContext()->Document(), "No document? Pshaw!");
nsPresContext* presContext = PresContext();
MOZ_ASSERT(presContext->Document(), "No document? Pshaw!");
MOZ_ASSERT(!presContext->HasPendingMediaQueryUpdates(),
"Someone forgot to update media queries?");
MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript(), "Missing a script blocker!");
MOZ_ASSERT(!mInStyleRefresh, "Reentrant call?");
if (MOZ_UNLIKELY(!PresContext()->PresShell()->DidInitialize())) {
if (MOZ_UNLIKELY(!presContext->PresShell()->DidInitialize())) {
// PresShell::FlushPendingNotifications doesn't early-return in the case
// where the PreShell hasn't yet been initialized (and therefore we haven't
// where the PresShell hasn't yet been initialized (and therefore we haven't
// yet done the initial style traversal of the DOM tree). We should arguably
// fix up the callers and assert against this case, but we just detect and
// handle it for now.
@ -1112,11 +1117,11 @@ ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
AnimationsWithDestroyedFrame animationsWithDestroyedFrame(this);
ServoStyleSet* styleSet = StyleSet();
nsIDocument* doc = PresContext()->Document();
nsIDocument* doc = presContext->Document();
// Ensure the refresh driver is active during traversal to avoid mutating
// mActiveTimer and mMostRecentRefresh time.
PresContext()->RefreshDriver()->MostRecentRefresh();
presContext->RefreshDriver()->MostRecentRefresh();
// Perform the Servo traversal, and the post-traversal if required. We do this
@ -1140,7 +1145,7 @@ ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
// Recreate style contexts, and queue up change hints (which also handle
// lazy frame construction).
{
AutoRestyleTimelineMarker marker(mPresContext->GetDocShell(), false);
AutoRestyleTimelineMarker marker(presContext->GetDocShell(), false);
DocumentStyleRootIterator iter(doc->GetServoRestyleRoot());
while (Element* root = iter.GetNextStyleRoot()) {
nsTArray<nsIFrame*> wrappersToRestyle;
@ -1159,7 +1164,7 @@ ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
// iterate until there's nothing left.
{
AutoTimelineMarker marker(
mPresContext->GetDocShell(), "StylesApplyChanges");
presContext->GetDocShell(), "StylesApplyChanges");
ReentrantChangeList newChanges;
mReentrantChanges = &newChanges;
while (!currentChanges.IsEmpty()) {

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

@ -223,6 +223,13 @@ public:
mozilla::StyleSetHandle StyleSet() const { return GetPresShell()->StyleSet(); }
#ifdef DEBUG
bool HasPendingMediaQueryUpdates() const
{
return mPendingMediaFeatureValuesChanged;
}
#endif
nsFrameManager* FrameManager()
{ return PresShell()->FrameManager(); }

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

@ -1340,6 +1340,8 @@ ServoStyleSet::AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
nsCSSCounterStyleRule*
ServoStyleSet::CounterStyleRuleForName(nsAtom* aName)
{
// FIXME(emilio): This should probably call UpdateStylistIfNeeded, or
// otherwise assert?
return Servo_StyleSet_GetCounterStyleRule(mRawSet.get(), aName);
}