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/. */
6
7 /* base class for rendering objects that do not have child lists */
8
9 #include "nsLeafFrame.h"
10
11 #include "mozilla/PresShell.h"
12 #include "nsPresContext.h"
13
14 using namespace mozilla;
15
16 nsLeafFrame::~nsLeafFrame() = default;
17
18 /* virtual */
BuildDisplayList(nsDisplayListBuilder * aBuilder,const nsDisplayListSet & aLists)19 void nsLeafFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
20 const nsDisplayListSet& aLists) {
21 DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
22 DisplayBorderBackgroundOutline(aBuilder, aLists);
23 }
24
25 /* virtual */
GetMinISize(gfxContext * aRenderingContext)26 nscoord nsLeafFrame::GetMinISize(gfxContext* aRenderingContext) {
27 nscoord result;
28 DISPLAY_MIN_INLINE_SIZE(this, result);
29 result = GetIntrinsicISize();
30 return result;
31 }
32
33 /* virtual */
GetPrefISize(gfxContext * aRenderingContext)34 nscoord nsLeafFrame::GetPrefISize(gfxContext* aRenderingContext) {
35 nscoord result;
36 DISPLAY_PREF_INLINE_SIZE(this, result);
37 result = GetIntrinsicISize();
38 return result;
39 }
40
41 /* virtual */
ComputeAutoSize(gfxContext * aRenderingContext,WritingMode aWM,const LogicalSize & aCBSize,nscoord aAvailableISize,const LogicalSize & aMargin,const LogicalSize & aBorderPadding,const StyleSizeOverrides & aSizeOverrides,ComputeSizeFlags aFlags)42 LogicalSize nsLeafFrame::ComputeAutoSize(
43 gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
44 nscoord aAvailableISize, const LogicalSize& aMargin,
45 const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
46 ComputeSizeFlags aFlags) {
47 const WritingMode wm = GetWritingMode();
48 LogicalSize result(wm, GetIntrinsicISize(), GetIntrinsicBSize());
49 return result.ConvertTo(aWM, wm);
50 }
51
GetIntrinsicBSize()52 nscoord nsLeafFrame::GetIntrinsicBSize() {
53 MOZ_ASSERT_UNREACHABLE("Someone didn't override Reflow or ComputeAutoSize");
54 return 0;
55 }
56
SizeToAvailSize(const ReflowInput & aReflowInput,ReflowOutput & aDesiredSize)57 void nsLeafFrame::SizeToAvailSize(const ReflowInput& aReflowInput,
58 ReflowOutput& aDesiredSize) {
59 aDesiredSize.SetSize(aReflowInput.GetWritingMode(),
60 aReflowInput.AvailableSize());
61 aDesiredSize.SetOverflowAreasToDesiredBounds();
62 FinishAndStoreOverflow(&aDesiredSize, aReflowInput.mStyleDisplay);
63 }
64