Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/generic/nsLeafFrame.h
Line
Count
Source (jump to first uncovered line)
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
#ifndef nsLeafFrame_h___
10
#define nsLeafFrame_h___
11
12
#include "mozilla/Attributes.h"
13
#include "nsFrame.h"
14
#include "nsDisplayList.h"
15
16
/**
17
 * Abstract class that provides simple fixed-size layout for leaf objects
18
 * (e.g. images, form elements, etc.). Deriviations provide the implementation
19
 * of the GetDesiredSize method. The rendering method knows how to render
20
 * borders and backgrounds.
21
 */
22
class nsLeafFrame : public nsFrame {
23
public:
24
  NS_DECL_ABSTRACT_FRAME(nsLeafFrame)
25
26
  // nsIFrame replacements
27
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
28
0
                                const nsDisplayListSet& aLists) override {
29
0
    DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
30
0
    DisplayBorderBackgroundOutline(aBuilder, aLists);
31
0
  }
32
33
  /**
34
   * Both GetMinISize and GetPrefISize will return whatever GetIntrinsicISize
35
   * returns.
36
   */
37
  virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
38
  virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
39
40
  /**
41
   * Our auto size is just intrinsic width and intrinsic height.
42
   */
43
  virtual mozilla::LogicalSize
44
  ComputeAutoSize(gfxContext*                 aRenderingContext,
45
                  mozilla::WritingMode        aWM,
46
                  const mozilla::LogicalSize& aCBSize,
47
                  nscoord                     aAvailableISize,
48
                  const mozilla::LogicalSize& aMargin,
49
                  const mozilla::LogicalSize& aBorder,
50
                  const mozilla::LogicalSize& aPadding,
51
                  ComputeSizeFlags            aFlags) override;
52
53
  /**
54
   * Each of our subclasses should provide its own Reflow impl:
55
   */
56
  virtual void Reflow(nsPresContext*      aPresContext,
57
                      ReflowOutput&       aDesiredSize,
58
                      const ReflowInput&  aReflowInput,
59
                      nsReflowStatus&     aStatus) override = 0;
60
61
  virtual bool IsFrameOfType(uint32_t aFlags) const override
62
0
  {
63
0
    // We don't actually contain a block, but we do always want a
64
0
    // computed width, so tell a little white lie here.
65
0
    return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
66
0
  }
67
68
protected:
69
  nsLeafFrame(ComputedStyle* aStyle, ClassID aID)
70
    : nsFrame(aStyle, aID)
71
0
  {}
72
73
  virtual ~nsLeafFrame();
74
75
  /**
76
   * Return the intrinsic isize of the frame's content area. Note that this
77
   * should not include borders or padding and should not depend on the applied
78
   * styles.
79
   */
80
  virtual nscoord GetIntrinsicISize() = 0;
81
82
  /**
83
   * Return the intrinsic bsize of the frame's content area.  This should not
84
   * include border or padding.  This will only matter if the specified bsize
85
   * is auto.  Note that subclasses must either implement this or override
86
   * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
87
   * call this method.
88
   */
89
  virtual nscoord GetIntrinsicBSize();
90
91
  /**
92
   * Set aDesiredSize to be the available size
93
   */
94
  void SizeToAvailSize(const ReflowInput& aReflowInput,
95
                       ReflowOutput& aDesiredSize);
96
};
97
98
#endif /* nsLeafFrame_h___ */