Bug 1364871: Restyle ::backdrop too. r=heycam

MozReview-Commit-ID: BGWRiaeZiD8

--HG--
extra : rebase_source : a3ebd025ca9a9d7a03a5aeec95e0d40791c9af7c
This commit is contained in:
Emilio Cobos Álvarez 2017-05-19 23:59:23 +02:00
Родитель cbebceac22
Коммит cd98f069a2
1 изменённых файлов: 43 добавлений и 4 удалений

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

@ -14,6 +14,7 @@
#include "mozilla/dom/ElementInlines.h"
#include "nsBlockFrame.h"
#include "nsBulletFrame.h"
#include "nsPlaceholderFrame.h"
#include "nsContentUtils.h"
#include "nsCSSFrameConstructor.h"
#include "nsPrintfCString.h"
@ -208,7 +209,6 @@ struct ServoRestyleManager::TextPostTraversalState
static void
UpdateBlockFramePseudoElements(nsBlockFrame* aFrame,
ServoStyleSet& aStyleSet,
nsChangeHint aChangeHintForFrame,
nsStyleChangeList& aChangeList)
{
if (nsBulletFrame* bullet = aFrame->GetBullet()) {
@ -223,18 +223,57 @@ UpdateBlockFramePseudoElements(nsBlockFrame* aFrame,
}
}
static void
UpdateBackdropIfNeeded(nsIFrame* aFrame,
ServoStyleSet& aStyleSet,
nsStyleChangeList& aChangeList)
{
const nsStyleDisplay* display = aFrame->StyleContext()->StyleDisplay();
if (display->mTopLayer != NS_STYLE_TOP_LAYER_TOP) {
return;
}
// Elements in the top layer are guaranteed to have absolute or fixed
// position per https://fullscreen.spec.whatwg.org/#new-stacking-layer.
MOZ_ASSERT(display->IsAbsolutelyPositionedStyle());
nsIFrame* backdropPlaceholder =
aFrame->GetChildList(nsIFrame::kBackdropList).FirstChild();
if (!backdropPlaceholder) {
return;
}
MOZ_ASSERT(backdropPlaceholder->IsPlaceholderFrame());
nsIFrame* backdropFrame =
nsPlaceholderFrame::GetRealFrameForPlaceholder(backdropPlaceholder);
MOZ_ASSERT(backdropFrame->IsBackdropFrame());
MOZ_ASSERT(backdropFrame->StyleContext()->GetPseudoType() ==
CSSPseudoElementType::backdrop);
RefPtr<nsStyleContext> newContext =
aStyleSet.ResolvePseudoElementStyle(
aFrame->GetContent()->AsElement(),
CSSPseudoElementType::backdrop,
aFrame->StyleContext(),
/* aPseudoElement = */ nullptr);
aFrame->UpdateStyleOfOwnedChildFrame(backdropFrame,
newContext,
aChangeList);
}
static void
UpdateFramePseudoElementStyles(nsIFrame* aFrame,
ServoStyleSet& aStyleSet,
nsChangeHint aChangeHintForFrame,
nsStyleChangeList& aChangeList)
{
if (aFrame->IsFrameOfType(nsIFrame::eBlockFrame)) {
UpdateBlockFramePseudoElements(static_cast<nsBlockFrame*>(aFrame),
aStyleSet,
aChangeHintForFrame,
aChangeList);
}
UpdateBackdropIfNeeded(aFrame, aStyleSet, aChangeList);
}
void
@ -348,7 +387,7 @@ ServoRestyleManager::ProcessPostTraversal(Element* aElement,
if (styleFrame) {
styleFrame->UpdateStyleOfOwnedAnonBoxes(*aStyleSet, aChangeList, changeHint);
UpdateFramePseudoElementStyles(styleFrame, *aStyleSet, changeHint, aChangeList);
UpdateFramePseudoElementStyles(styleFrame, *aStyleSet, aChangeList);
}
}