Bug 1708422: part 17) Rename `words` to `normalizedWords` in `mozInlineSpellChecker...
[gecko.git] / layout / xul / nsBoxFrame.h
blob8ce821470da8ae8afbc8c5791fd9ee0f6b021e71
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/. */
7 /**
9 Eric D Vaughan
10 nsBoxFrame is a frame that can lay its children out either vertically or
11 horizontally. It lays them out according to a min max or preferred size.
13 **/
15 #ifndef nsBoxFrame_h___
16 #define nsBoxFrame_h___
18 #include "mozilla/Attributes.h"
19 #include "nsCOMPtr.h"
20 #include "nsContainerFrame.h"
21 #include "nsBoxLayout.h"
23 class nsBoxLayoutState;
25 namespace mozilla {
26 class PresShell;
27 namespace gfx {
28 class DrawTarget;
29 } // namespace gfx
30 } // namespace mozilla
32 nsIFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
33 mozilla::ComputedStyle* aStyle, bool aIsRoot,
34 nsBoxLayout* aLayoutManager);
35 nsIFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
36 mozilla::ComputedStyle* aStyle);
38 class nsBoxFrame : public nsContainerFrame {
39 protected:
40 typedef mozilla::gfx::DrawTarget DrawTarget;
42 public:
43 NS_DECL_FRAMEARENA_HELPERS(nsBoxFrame)
44 #ifdef DEBUG
45 NS_DECL_QUERYFRAME
46 #endif
48 friend nsIFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
49 ComputedStyle* aStyle, bool aIsRoot,
50 nsBoxLayout* aLayoutManager);
51 friend nsIFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
52 ComputedStyle* aStyle);
54 // gets the rect inside our border and debug border. If you wish to paint
55 // inside a box call this method to get the rect so you don't draw on the
56 // debug border or outer border.
58 virtual void SetXULLayoutManager(nsBoxLayout* aLayout) override {
59 mLayoutManager = aLayout;
61 virtual nsBoxLayout* GetXULLayoutManager() override { return mLayoutManager; }
63 virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
64 virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
65 virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
66 virtual nscoord GetXULFlex() override;
67 virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
68 virtual Valignment GetXULVAlign() const override { return mValign; }
69 virtual Halignment GetXULHAlign() const override { return mHalign; }
70 NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
72 virtual bool XULComputesOwnOverflowArea() override { return false; }
74 // ----- child and sibling operations ---
76 // ----- public methods -------
78 virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
79 nsIFrame* aPrevInFlow) override;
81 virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
82 int32_t aModType) override;
84 virtual void MarkIntrinsicISizesDirty() override;
85 virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
86 virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
88 virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
89 const ReflowInput& aReflowInput,
90 nsReflowStatus& aStatus) override;
92 virtual void SetInitialChildList(ChildListID aListID,
93 nsFrameList& aChildList) override;
94 virtual void AppendFrames(ChildListID aListID,
95 nsFrameList& aFrameList) override;
96 virtual void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
97 const nsLineList::iterator* aPrevFrameLine,
98 nsFrameList& aFrameList) override;
99 virtual void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
101 virtual nsContainerFrame* GetContentInsertionFrame() override;
103 virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
105 virtual bool IsFrameOfType(uint32_t aFlags) const override {
106 // record that children that are ignorable whitespace should be excluded
107 // (When content was loaded via the XUL content sink, it's already
108 // been excluded, but we need this for when the XUL namespace is used
109 // in other MIME types or when the XUL CSS display types are used with
110 // non-XUL elements.)
112 // This is bogus, but it's what we've always done.
113 // (Given that we're replaced, we need to say we're a replaced element
114 // that contains a block so ReflowInput doesn't tell us to be
115 // NS_UNCONSTRAINEDSIZE wide.)
116 return nsContainerFrame::IsFrameOfType(
117 aFlags &
118 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox));
121 #ifdef DEBUG_FRAME_DUMP
122 virtual nsresult GetFrameName(nsAString& aResult) const override;
123 #endif
125 virtual void DidReflow(nsPresContext* aPresContext,
126 const ReflowInput* aReflowInput) override;
128 virtual bool HonorPrintBackgroundSettings() const override;
130 // virtual so nsStackFrame, nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
131 // can override it
132 virtual void BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
133 const nsDisplayListSet& aLists);
135 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
136 const nsDisplayListSet& aLists) override;
138 static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox,
139 const nsRect& aRect);
142 * Utility method to redirect events on descendants to this frame.
143 * Supports 'allowevents' attribute on descendant elements to allow those
144 * elements and their descendants to receive events.
146 void WrapListsInRedirector(nsDisplayListBuilder* aBuilder,
147 const nsDisplayListSet& aIn,
148 const nsDisplayListSet& aOut);
151 * Return our wrapper block, if any.
153 void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
155 // Gets a next / prev sibling accounting for ordinal group. Slow, please avoid
156 // usage if possible.
157 static nsIFrame* SlowOrdinalGroupAwareSibling(nsIFrame*, bool aNext);
159 private:
160 explicit nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
161 : nsBoxFrame(aStyle, aPresContext, kClassID, false, nullptr) {}
163 protected:
164 nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID,
165 bool aIsRoot = false, nsBoxLayout* aLayoutManager = nullptr);
166 virtual ~nsBoxFrame();
168 virtual bool GetInitialEqualSize(bool& aEqualSize);
169 virtual void GetInitialOrientation(bool& aIsHorizontal);
170 virtual void GetInitialDirection(bool& aIsNormal);
171 virtual bool GetInitialHAlignment(Halignment& aHalign);
172 virtual bool GetInitialVAlignment(Valignment& aValign);
173 virtual bool GetInitialAutoStretch(bool& aStretch);
175 virtual void DestroyFrom(nsIFrame* aDestructRoot,
176 PostDestroyData& aPostDestroyData) override;
178 nsSize mPrefSize;
179 nsSize mMinSize;
180 nsSize mMaxSize;
181 nscoord mFlex;
182 nscoord mAscent;
184 nsCOMPtr<nsBoxLayout> mLayoutManager;
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);
194 private:
195 void CacheAttributes();
197 // instance variables.
198 Halignment mHalign;
199 Valignment mValign;
201 }; // class nsBoxFrame
203 #endif