diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index d303ef8184bc..008825a2cc95 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -126,6 +126,7 @@ GK_ATOM(autoplay, "autoplay") GK_ATOM(autorepeatbutton, "autorepeatbutton") GK_ATOM(axis, "axis") GK_ATOM(b, "b") +GK_ATOM(backdropFrame, "BackdropFrame") GK_ATOM(background, "background") GK_ATOM(base, "base") GK_ATOM(basefont, "basefont") diff --git a/layout/generic/moz.build b/layout/generic/moz.build index a0e60728db8f..f971b6600865 100644 --- a/layout/generic/moz.build +++ b/layout/generic/moz.build @@ -115,6 +115,7 @@ UNIFIED_SOURCES += [ 'FrameChildList.cpp', 'MathMLTextRunFactory.cpp', 'nsAbsoluteContainingBlock.cpp', + 'nsBackdropFrame.cpp', 'nsBlockFrame.cpp', 'nsBlockReflowContext.cpp', 'nsBlockReflowState.cpp', diff --git a/layout/generic/nsBackdropFrame.cpp b/layout/generic/nsBackdropFrame.cpp new file mode 100644 index 000000000000..135d8e3f482b --- /dev/null +++ b/layout/generic/nsBackdropFrame.cpp @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +// vim:cindent:ts=2:et:sw=2: +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* rendering object for CSS "::backdrop" */ + +#include "nsBackdropFrame.h" + +using namespace mozilla; + +NS_IMPL_FRAMEARENA_HELPERS(nsBackdropFrame) + +/* virtual */ nsIAtom* +nsBackdropFrame::GetType() const +{ + return nsGkAtoms::backdropFrame; +} + +#ifdef DEBUG_FRAME_DUMP +nsresult +nsBackdropFrame::GetFrameName(nsAString& aResult) const +{ + return MakeFrameName(NS_LITERAL_STRING("Backdrop"), aResult); +} +#endif + +/* virtual */ nsStyleContext* +nsBackdropFrame::GetParentStyleContext(nsIFrame** aProviderFrame) const +{ + // Style context of backdrop pseudo-element does not inherit from + // any element, per the Fullscreen API spec. + *aProviderFrame = nullptr; + return nullptr; +} + +/* virtual */ void +nsBackdropFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, + const nsRect& aDirtyRect, + const nsDisplayListSet& aLists) +{ + DO_GLOBAL_REFLOW_COUNT_DSP("nsBackdropFrame"); + // We want this frame to always be there even if its display value is + // none or contents so that we can respond to style change on it. To + // support those values, we skip painting ourselves in those cases. + auto display = StyleDisplay()->mDisplay; + if (display != NS_STYLE_DISPLAY_NONE && + display != NS_STYLE_DISPLAY_CONTENTS) { + DisplayBorderBackgroundOutline(aBuilder, aLists); + } +} + +/* virtual */ LogicalSize +nsBackdropFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, + WritingMode aWM, + const LogicalSize& aCBSize, + nscoord aAvailableISize, + const LogicalSize& aMargin, + const LogicalSize& aBorder, + const LogicalSize& aPadding, + bool aShrinkWrap) +{ + // Note that this frame is a child of the viewport frame. + LogicalSize result(aWM, 0xdeadbeef, NS_UNCONSTRAINEDSIZE); + if (aShrinkWrap) { + result.ISize(aWM) = 0; + } else { + result.ISize(aWM) = aAvailableISize - aMargin.ISize(aWM) - + aBorder.ISize(aWM) - aPadding.ISize(aWM); + } + return result; +} + +/* virtual */ void +nsBackdropFrame::Reflow(nsPresContext* aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) +{ + MarkInReflow(); + DO_GLOBAL_REFLOW_COUNT("nsBackdropFrame"); + DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); + + // Note that this frame is a child of the viewport frame. + WritingMode wm = aReflowState.GetWritingMode(); + LogicalMargin borderPadding = aReflowState.ComputedLogicalBorderPadding(); + nscoord isize = aReflowState.ComputedISize() + borderPadding.IStartEnd(wm); + nscoord bsize = aReflowState.ComputedBSize() + borderPadding.BStartEnd(wm); + aDesiredSize.SetSize(wm, LogicalSize(wm, isize, bsize)); + aStatus = NS_FRAME_COMPLETE; +} diff --git a/layout/generic/nsBackdropFrame.h b/layout/generic/nsBackdropFrame.h new file mode 100644 index 000000000000..1babc8dd9180 --- /dev/null +++ b/layout/generic/nsBackdropFrame.h @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +// vim:cindent:ts=2:et:sw=2: +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* rendering object for CSS "::backdrop" */ + +#ifndef nsBackdropFrame_h___ +#define nsBackdropFrame_h___ + +#include "nsFrame.h" + +class nsBackdropFrame final : public nsFrame +{ +public: + NS_DECL_FRAMEARENA_HELPERS + + explicit nsBackdropFrame(nsStyleContext* aContext) + : nsFrame(aContext) { } + + // nsIFrame overrides + virtual nsIAtom* GetType() const override; +#ifdef DEBUG_FRAME_DUMP + virtual nsresult GetFrameName(nsAString& aResult) const override; +#endif + virtual nsStyleContext* + GetParentStyleContext(nsIFrame** aProviderFrame) const override; + virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, + const nsRect& aDirtyRect, + const nsDisplayListSet& aLists) override; + virtual LogicalSize ComputeAutoSize(nsRenderingContext *aRenderingContext, + WritingMode aWM, + const LogicalSize& aCBSize, + nscoord aAvailableISize, + const LogicalSize& aMargin, + const LogicalSize& aBorder, + const LogicalSize& aPadding, + bool aShrinkWrap) override; + virtual void Reflow(nsPresContext* aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) override; +}; + +#endif // nsBackdropFrame_h___ diff --git a/layout/generic/nsFrameIdList.h b/layout/generic/nsFrameIdList.h index 10d806d976f4..955359076205 100644 --- a/layout/generic/nsFrameIdList.h +++ b/layout/generic/nsFrameIdList.h @@ -5,6 +5,7 @@ FRAME_ID(BRFrame) FRAME_ID(nsAutoRepeatBoxFrame) FRAME_ID(nsBCTableCellFrame) +FRAME_ID(nsBackdropFrame) FRAME_ID(nsBlockFrame) FRAME_ID(nsBox) FRAME_ID(nsBoxFrame)