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 #include "nsPresContext.h"
11
12 using namespace mozilla;
13
14 nsLeafFrame::~nsLeafFrame() = default;
15
16 /* virtual */
GetMinISize(gfxContext * aRenderingContext)17 nscoord nsLeafFrame::GetMinISize(gfxContext* aRenderingContext) {
18 nscoord result;
19 DISPLAY_MIN_INLINE_SIZE(this, result);
20 result = GetIntrinsicISize();
21 return result;
22 }
23
24 /* virtual */
GetPrefISize(gfxContext * aRenderingContext)25 nscoord nsLeafFrame::GetPrefISize(gfxContext* aRenderingContext) {
26 nscoord result;
27 DISPLAY_PREF_INLINE_SIZE(this, result);
28 result = GetIntrinsicISize();
29 return result;
30 }
31
32 /* virtual */
ComputeAutoSize(gfxContext * aRenderingContext,WritingMode aWM,const LogicalSize & aCBSize,nscoord aAvailableISize,const LogicalSize & aMargin,const LogicalSize & aBorder,const LogicalSize & aPadding,ComputeSizeFlags aFlags)33 LogicalSize nsLeafFrame::ComputeAutoSize(
34 gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
35 nscoord aAvailableISize, const LogicalSize& aMargin,
36 const LogicalSize& aBorder, const LogicalSize& aPadding,
37 ComputeSizeFlags aFlags) {
38 const WritingMode wm = GetWritingMode();
39 LogicalSize result(wm, GetIntrinsicISize(), GetIntrinsicBSize());
40 return result.ConvertTo(aWM, wm);
41 }
42
GetIntrinsicBSize()43 nscoord nsLeafFrame::GetIntrinsicBSize() {
44 MOZ_ASSERT_UNREACHABLE("Someone didn't override Reflow or ComputeAutoSize");
45 return 0;
46 }
47
SizeToAvailSize(const ReflowInput & aReflowInput,ReflowOutput & aDesiredSize)48 void nsLeafFrame::SizeToAvailSize(const ReflowInput& aReflowInput,
49 ReflowOutput& aDesiredSize) {
50 aDesiredSize.SetSize(aReflowInput.GetWritingMode(),
51 aReflowInput.AvailableSize());
52 aDesiredSize.SetOverflowAreasToDesiredBounds();
53 FinishAndStoreOverflow(&aDesiredSize, aReflowInput.mStyleDisplay);
54 }
55