Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : // vim:cindent:ts=2:et:sw=2:
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/. */
6 :
7 : /* rendering object for CSS "::backdrop" */
8 :
9 : #include "nsBackdropFrame.h"
10 :
11 : #include "nsDisplayList.h"
12 :
13 : using namespace mozilla;
14 :
15 0 : NS_IMPL_FRAMEARENA_HELPERS(nsBackdropFrame)
16 :
17 : #ifdef DEBUG_FRAME_DUMP
18 : nsresult
19 0 : nsBackdropFrame::GetFrameName(nsAString& aResult) const
20 : {
21 0 : return MakeFrameName(NS_LITERAL_STRING("Backdrop"), aResult);
22 : }
23 : #endif
24 :
25 : /* virtual */ nsStyleContext*
26 0 : nsBackdropFrame::GetParentStyleContext(nsIFrame** aProviderFrame) const
27 : {
28 : // Style context of backdrop pseudo-element does not inherit from
29 : // any element, per the Fullscreen API spec.
30 0 : *aProviderFrame = nullptr;
31 0 : return nullptr;
32 : }
33 :
34 : /* virtual */ void
35 0 : nsBackdropFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
36 : const nsRect& aDirtyRect,
37 : const nsDisplayListSet& aLists)
38 : {
39 0 : DO_GLOBAL_REFLOW_COUNT_DSP("nsBackdropFrame");
40 : // We want this frame to always be there even if its display value is
41 : // none or contents so that we can respond to style change on it. To
42 : // support those values, we skip painting ourselves in those cases.
43 0 : auto display = StyleDisplay()->mDisplay;
44 0 : if (display == mozilla::StyleDisplay::None ||
45 : display == mozilla::StyleDisplay::Contents) {
46 0 : return;
47 : }
48 :
49 0 : DisplayBorderBackgroundOutline(aBuilder, aLists);
50 : }
51 :
52 : /* virtual */ LogicalSize
53 0 : nsBackdropFrame::ComputeAutoSize(gfxContext* aRenderingContext,
54 : WritingMode aWM,
55 : const LogicalSize& aCBSize,
56 : nscoord aAvailableISize,
57 : const LogicalSize& aMargin,
58 : const LogicalSize& aBorder,
59 : const LogicalSize& aPadding,
60 : ComputeSizeFlags aFlags)
61 : {
62 : // Note that this frame is a child of the viewport frame.
63 0 : LogicalSize result(aWM, 0xdeadbeef, NS_UNCONSTRAINEDSIZE);
64 0 : if (aFlags & ComputeSizeFlags::eShrinkWrap) {
65 0 : result.ISize(aWM) = 0;
66 : } else {
67 0 : result.ISize(aWM) = aAvailableISize - aMargin.ISize(aWM) -
68 0 : aBorder.ISize(aWM) - aPadding.ISize(aWM);
69 : }
70 0 : return result;
71 : }
72 :
73 : /* virtual */ void
74 0 : nsBackdropFrame::Reflow(nsPresContext* aPresContext,
75 : ReflowOutput& aDesiredSize,
76 : const ReflowInput& aReflowInput,
77 : nsReflowStatus& aStatus)
78 : {
79 0 : MarkInReflow();
80 0 : DO_GLOBAL_REFLOW_COUNT("nsBackdropFrame");
81 0 : DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
82 :
83 : // Note that this frame is a child of the viewport frame.
84 0 : WritingMode wm = aReflowInput.GetWritingMode();
85 0 : LogicalMargin borderPadding = aReflowInput.ComputedLogicalBorderPadding();
86 0 : nscoord isize = aReflowInput.ComputedISize() + borderPadding.IStartEnd(wm);
87 0 : nscoord bsize = aReflowInput.ComputedBSize() + borderPadding.BStartEnd(wm);
88 0 : aDesiredSize.SetSize(wm, LogicalSize(wm, isize, bsize));
89 0 : aStatus.Reset();
90 0 : }
|