Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/xul/nsBoxFrame.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
/**
8
9
  Eric D Vaughan
10
  nsBoxFrame is a frame that can lay its children out either vertically or horizontally.
11
  It lays them out according to a min max or preferred size.
12
13
**/
14
15
#ifndef nsBoxFrame_h___
16
#define nsBoxFrame_h___
17
18
#include "mozilla/Attributes.h"
19
#include "nsCOMPtr.h"
20
#include "nsContainerFrame.h"
21
#include "nsBoxLayout.h"
22
23
class nsBoxLayoutState;
24
25
namespace mozilla {
26
namespace gfx {
27
class DrawTarget;
28
} // namespace gfx
29
} // namespace mozilla
30
31
nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
32
                         mozilla::ComputedStyle* aStyle,
33
                         bool aIsRoot,
34
                         nsBoxLayout* aLayoutManager);
35
nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
36
                         mozilla::ComputedStyle* aStyle);
37
38
class nsBoxFrame : public nsContainerFrame
39
{
40
protected:
41
  typedef mozilla::gfx::DrawTarget DrawTarget;
42
43
public:
44
  NS_DECL_FRAMEARENA_HELPERS(nsBoxFrame)
45
#ifdef DEBUG
46
  NS_DECL_QUERYFRAME
47
#endif
48
49
  friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
50
                                  ComputedStyle* aStyle,
51
                                  bool aIsRoot,
52
                                  nsBoxLayout* aLayoutManager);
53
  friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
54
                                  ComputedStyle* aStyle);
55
56
  // gets the rect inside our border and debug border. If you wish to paint inside a box
57
  // call this method to get the rect so you don't draw on the debug border or outer border.
58
59
0
  virtual void SetXULLayoutManager(nsBoxLayout* aLayout) override { mLayoutManager = aLayout; }
60
0
  virtual nsBoxLayout* GetXULLayoutManager() override { return mLayoutManager; }
61
62
  virtual nsresult XULRelayoutChildAtOrdinal(nsIFrame* aChild) override;
63
64
  virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
65
  virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
66
  virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
67
  virtual nscoord GetXULFlex() override;
68
  virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
69
0
  virtual Valignment GetXULVAlign() const override { return mValign; }
70
0
  virtual Halignment GetXULHAlign() const override { return mHalign; }
71
  NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
72
73
0
  virtual bool ComputesOwnOverflowArea() override { return false; }
74
75
  // ----- child and sibling operations ---
76
77
  // ----- public methods -------
78
79
  virtual void Init(nsIContent*       aContent,
80
                    nsContainerFrame* aParent,
81
                    nsIFrame*         aPrevInFlow) override;
82
83
84
  virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
85
                                    nsAtom*        aAttribute,
86
                                    int32_t         aModType) override;
87
88
  virtual void MarkIntrinsicISizesDirty() override;
89
  virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
90
  virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
91
92
  virtual void Reflow(nsPresContext*           aPresContext,
93
                      ReflowOutput&     aDesiredSize,
94
                      const ReflowInput& aReflowInput,
95
                      nsReflowStatus&          aStatus) override;
96
97
  virtual void SetInitialChildList(ChildListID  aListID,
98
                                   nsFrameList& aChildList) override;
99
  virtual void AppendFrames(ChildListID     aListID,
100
                            nsFrameList&    aFrameList) override;
101
  virtual void InsertFrames(ChildListID     aListID,
102
                            nsIFrame*       aPrevFrame,
103
                            nsFrameList&    aFrameList) override;
104
  virtual void RemoveFrame(ChildListID     aListID,
105
                           nsIFrame*       aOldFrame) override;
106
107
  virtual nsContainerFrame* GetContentInsertionFrame() override;
108
109
  virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
110
111
  virtual bool IsFrameOfType(uint32_t aFlags) const override
112
0
  {
113
0
    // record that children that are ignorable whitespace should be excluded
114
0
    // (When content was loaded via the XUL content sink, it's already
115
0
    // been excluded, but we need this for when the XUL namespace is used
116
0
    // in other MIME types or when the XUL CSS display types are used with
117
0
    // non-XUL elements.)
118
0
119
0
    // This is bogus, but it's what we've always done.
120
0
    // (Given that we're replaced, we need to say we're a replaced element
121
0
    // that contains a block so ReflowInput doesn't tell us to be
122
0
    // NS_INTRINSICSIZE wide.)
123
0
    return nsContainerFrame::IsFrameOfType(aFlags &
124
0
      ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox |
125
0
        nsIFrame::eExcludesIgnorableWhitespace));
126
0
  }
127
128
#ifdef DEBUG_FRAME_DUMP
129
  virtual nsresult GetFrameName(nsAString& aResult) const override;
130
#endif
131
132
  virtual void DidReflow(nsPresContext*           aPresContext,
133
                         const ReflowInput* aReflowInput) override;
134
135
  virtual bool HonorPrintBackgroundSettings() override;
136
137
  // virtual so nsStackFrame, nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
138
  // can override it
139
  virtual void BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
140
                                           const nsDisplayListSet& aLists);
141
142
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
143
                                const nsDisplayListSet& aLists) override;
144
145
  static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect);
146
147
  /**
148
   * Utility method to redirect events on descendants to this frame.
149
   * Supports 'allowevents' attribute on descendant elements to allow those
150
   * elements and their descendants to receive events.
151
   */
152
  void WrapListsInRedirector(nsDisplayListBuilder*   aBuilder,
153
                             const nsDisplayListSet& aIn,
154
                             const nsDisplayListSet& aOut);
155
156
  /**
157
   * Return our wrapper block, if any.
158
   */
159
  void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
160
161
private:
162
  explicit nsBoxFrame(ComputedStyle* aStyle)
163
0
    : nsBoxFrame(aStyle, kClassID, false, nullptr) {}
164
protected:
165
  nsBoxFrame(ComputedStyle* aStyle, ClassID aID, bool aIsRoot = false,
166
             nsBoxLayout* aLayoutManager = nullptr);
167
  virtual ~nsBoxFrame();
168
169
    virtual bool GetInitialEqualSize(bool& aEqualSize);
170
    virtual void GetInitialOrientation(bool& aIsHorizontal);
171
    virtual void GetInitialDirection(bool& aIsNormal);
172
    virtual bool GetInitialHAlignment(Halignment& aHalign);
173
    virtual bool GetInitialVAlignment(Valignment& aValign);
174
    virtual bool GetInitialAutoStretch(bool& aStretch);
175
176
    virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
177
178
    nsSize mPrefSize;
179
    nsSize mMinSize;
180
    nsSize mMaxSize;
181
    nscoord mFlex;
182
    nscoord mAscent;
183
184
    nsCOMPtr<nsBoxLayout> mLayoutManager;
185
186
    // Get the point associated with this event. Returns true if a single valid
187
    // point was found. Otherwise false.
188
    bool GetEventPoint(mozilla::WidgetGUIEvent* aEvent, nsPoint& aPoint);
189
    // Gets the event coordinates relative to the widget offset associated with
190
    // this frame. Return true if a single valid point was found.
191
    bool GetEventPoint(mozilla::WidgetGUIEvent* aEvent,
192
                       mozilla::LayoutDeviceIntPoint& aPoint);
193
194
protected:
195
    void RegUnregAccessKey(bool aDoReg);
196
197
  void CheckBoxOrder();
198
199
private:
200
201
    virtual void UpdateMouseThrough();
202
203
    void CacheAttributes();
204
205
    // instance variables.
206
    Halignment mHalign;
207
    Valignment mValign;
208
209
}; // class nsBoxFrame
210
211
#endif
212