1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* rendering object for CSS "::backdrop" */
9 #include "nsBackdropFrame.h"
11 #include "mozilla/PresShell.h"
12 #include "nsDisplayList.h"
14 using namespace mozilla
;
16 NS_IMPL_FRAMEARENA_HELPERS(nsBackdropFrame
)
18 #ifdef DEBUG_FRAME_DUMP
19 nsresult
nsBackdropFrame::GetFrameName(nsAString
& aResult
) const {
20 return MakeFrameName(u
"Backdrop"_ns
, aResult
);
25 ComputedStyle
* nsBackdropFrame::GetParentComputedStyle(
26 nsIFrame
** aProviderFrame
) const {
27 // Style context of backdrop pseudo-element does not inherit from
28 // any element, per the Fullscreen API spec.
29 *aProviderFrame
= nullptr;
34 void nsBackdropFrame::BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
35 const nsDisplayListSet
& aLists
) {
36 DO_GLOBAL_REFLOW_COUNT_DSP("nsBackdropFrame");
37 // We want this frame to always be there even if its display value is
38 // none or contents so that we can respond to style change on it. To
39 // support those values, we skip painting ourselves in those cases.
40 auto display
= StyleDisplay()->mDisplay
;
41 if (display
== mozilla::StyleDisplay::None
||
42 display
== mozilla::StyleDisplay::Contents
) {
46 DisplayBorderBackgroundOutline(aBuilder
, aLists
);
50 LogicalSize
nsBackdropFrame::ComputeAutoSize(
51 gfxContext
* aRenderingContext
, WritingMode aWM
, const LogicalSize
& aCBSize
,
52 nscoord aAvailableISize
, const LogicalSize
& aMargin
,
53 const LogicalSize
& aBorderPadding
, const StyleSizeOverrides
& aSizeOverrides
,
54 ComputeSizeFlags aFlags
) {
55 // Note that this frame is a child of the viewport frame.
56 LogicalSize
result(aWM
, 0xdeadbeef, NS_UNCONSTRAINEDSIZE
);
57 if (aFlags
.contains(ComputeSizeFlag::ShrinkWrap
)) {
58 result
.ISize(aWM
) = 0;
61 aAvailableISize
- aMargin
.ISize(aWM
) - aBorderPadding
.ISize(aWM
);
67 void nsBackdropFrame::Reflow(nsPresContext
* aPresContext
,
68 ReflowOutput
& aDesiredSize
,
69 const ReflowInput
& aReflowInput
,
70 nsReflowStatus
& aStatus
) {
72 DO_GLOBAL_REFLOW_COUNT("nsBackdropFrame");
73 DISPLAY_REFLOW(aPresContext
, this, aReflowInput
, aDesiredSize
, aStatus
);
74 MOZ_ASSERT(aStatus
.IsEmpty(), "Caller should pass a fresh reflow status!");
76 // Note that this frame is a child of the viewport frame.
77 WritingMode wm
= aReflowInput
.GetWritingMode();
78 aDesiredSize
.SetSize(wm
, aReflowInput
.ComputedSizeWithBorderPadding(wm
));