Bug 1336863: Flush stylesheets in RestyleForCSSRuleChanges if not under an update. r=heycam

This also moves the NoteStyleSheetsChanged to RecordStylesheetChange, which
makes more sense, and stopped special-casing author styles, since it's not
needed now.

MozReview-Commit-ID: 9WKFa0JxqlU

--HG--
extra : rebase_source : 5803620c98309bd2fbb542158e69ef3ddcee9a4b
This commit is contained in:
Emilio Cobos Álvarez 2017-04-25 21:03:18 +02:00
Родитель c4d69b8e6d
Коммит e868552184
2 изменённых файлов: 11 добавлений и 14 удалений

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

@ -4559,19 +4559,6 @@ nsIPresShell::RestyleForCSSRuleChanges()
mPresContext->RebuildCounterStyles(); mPresContext->RebuildCounterStyles();
} }
// Tell Servo that the contents of style sheets have changed.
//
// NB: It's important to do so before bailing out.
//
// Even if we have no frames, we can end up styling those when creating
// them, and it's important for Servo to know that it needs to use the
// correct styles.
// We don't do this notification if author styles are disabled, because
// the ServoStyleSet has already taken care of it.
if (mStyleSet->IsServo() && !mStyleSet->AsServo()->GetAuthorStyleDisabled()) {
mStyleSet->AsServo()->NoteStyleSheetsChanged();
}
Element* root = mDocument->GetRootElement(); Element* root = mDocument->GetRootElement();
if (!mDidInitialize) { if (!mDidInitialize) {
// Nothing to do here, since we have no frames yet // Nothing to do here, since we have no frames yet
@ -4608,6 +4595,11 @@ PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet)
if (mStylesHaveChanged) if (mStylesHaveChanged)
return; return;
// Tell Servo that the contents of style sheets have changed.
if (ServoStyleSet* set = mStyleSet->GetAsServo()) {
set->NoteStyleSheetsChanged();
}
if (aStyleSheet->IsGecko()) { if (aStyleSheet->IsGecko()) {
// XXXheycam ServoStyleSheets don't support <style scoped> yet. // XXXheycam ServoStyleSheets don't support <style scoped> yet.
Element* scopeElement = aStyleSheet->AsGecko()->GetScopeElement(); Element* scopeElement = aStyleSheet->AsGecko()->GetScopeElement();

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

@ -143,10 +143,12 @@ ServoStyleSet::SetAuthorStyleDisabled(bool aStyleDisabled)
// call flush directly, since the PresShell won't. // call flush directly, since the PresShell won't.
if (mAuthorStyleDisabled) { if (mAuthorStyleDisabled) {
NoteStyleSheetsChanged(); NoteStyleSheetsChanged();
Servo_StyleSet_FlushStyleSheets(mRawSet.get());
} }
// If we've just enabled, then PresShell will trigger the notification and // If we've just enabled, then PresShell will trigger the notification and
// later flush when the stylesheet objects are enabled in JS. // later flush when the stylesheet objects are enabled in JS.
//
// TODO(emilio): Users can have JS disabled, can't they? Will that affect that
// notification on content documents?
return NS_OK; return NS_OK;
} }
@ -838,6 +840,9 @@ void
ServoStyleSet::NoteStyleSheetsChanged() ServoStyleSet::NoteStyleSheetsChanged()
{ {
Servo_StyleSet_NoteStyleSheetsChanged(mRawSet.get(), mAuthorStyleDisabled); Servo_StyleSet_NoteStyleSheetsChanged(mRawSet.get(), mAuthorStyleDisabled);
if (!mBatching) {
Servo_StyleSet_FlushStyleSheets(mRawSet.get());
}
} }
#ifdef DEBUG #ifdef DEBUG