layout/xul/nsBoxFrame.h

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /**
michael@0 7
michael@0 8 Eric D Vaughan
michael@0 9 nsBoxFrame is a frame that can lay its children out either vertically or horizontally.
michael@0 10 It lays them out according to a min max or preferred size.
michael@0 11
michael@0 12 **/
michael@0 13
michael@0 14 #ifndef nsBoxFrame_h___
michael@0 15 #define nsBoxFrame_h___
michael@0 16
michael@0 17 #include "mozilla/Attributes.h"
michael@0 18 #include "nsCOMPtr.h"
michael@0 19 #include "nsContainerFrame.h"
michael@0 20 #include "nsBoxLayout.h"
michael@0 21
michael@0 22 class nsBoxLayoutState;
michael@0 23
michael@0 24 nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
michael@0 25 nsStyleContext* aContext,
michael@0 26 bool aIsRoot,
michael@0 27 nsBoxLayout* aLayoutManager);
michael@0 28 nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
michael@0 29 nsStyleContext* aContext);
michael@0 30
michael@0 31 class nsBoxFrame : public nsContainerFrame
michael@0 32 {
michael@0 33 public:
michael@0 34 NS_DECL_FRAMEARENA_HELPERS
michael@0 35 #ifdef DEBUG
michael@0 36 NS_DECL_QUERYFRAME_TARGET(nsBoxFrame)
michael@0 37 NS_DECL_QUERYFRAME
michael@0 38 #endif
michael@0 39
michael@0 40 friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
michael@0 41 nsStyleContext* aContext,
michael@0 42 bool aIsRoot,
michael@0 43 nsBoxLayout* aLayoutManager);
michael@0 44 friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
michael@0 45 nsStyleContext* aContext);
michael@0 46
michael@0 47 // gets the rect inside our border and debug border. If you wish to paint inside a box
michael@0 48 // call this method to get the rect so you don't draw on the debug border or outer border.
michael@0 49
michael@0 50 virtual void SetLayoutManager(nsBoxLayout* aLayout) MOZ_OVERRIDE { mLayoutManager = aLayout; }
michael@0 51 virtual nsBoxLayout* GetLayoutManager() MOZ_OVERRIDE { return mLayoutManager; }
michael@0 52
michael@0 53 virtual nsresult RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild) MOZ_OVERRIDE;
michael@0 54
michael@0 55 virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 56 virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 57 virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 58 virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 59 virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 60 #ifdef DEBUG_LAYOUT
michael@0 61 virtual nsresult SetDebug(nsBoxLayoutState& aBoxLayoutState, bool aDebug) MOZ_OVERRIDE;
michael@0 62 virtual nsresult GetDebug(bool& aDebug) MOZ_OVERRIDE;
michael@0 63 #endif
michael@0 64 virtual Valignment GetVAlign() const MOZ_OVERRIDE { return mValign; }
michael@0 65 virtual Halignment GetHAlign() const MOZ_OVERRIDE { return mHalign; }
michael@0 66 NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 67
michael@0 68 virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE { return false; }
michael@0 69
michael@0 70 // ----- child and sibling operations ---
michael@0 71
michael@0 72 // ----- public methods -------
michael@0 73
michael@0 74 virtual void Init(nsIContent* aContent,
michael@0 75 nsIFrame* aParent,
michael@0 76 nsIFrame* asPrevInFlow) MOZ_OVERRIDE;
michael@0 77
michael@0 78
michael@0 79 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
michael@0 80 nsIAtom* aAttribute,
michael@0 81 int32_t aModType) MOZ_OVERRIDE;
michael@0 82
michael@0 83 virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
michael@0 84 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
michael@0 85 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
michael@0 86
michael@0 87 virtual nsresult Reflow(nsPresContext* aPresContext,
michael@0 88 nsHTMLReflowMetrics& aDesiredSize,
michael@0 89 const nsHTMLReflowState& aReflowState,
michael@0 90 nsReflowStatus& aStatus) MOZ_OVERRIDE;
michael@0 91
michael@0 92 virtual nsresult AppendFrames(ChildListID aListID,
michael@0 93 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 94
michael@0 95 virtual nsresult InsertFrames(ChildListID aListID,
michael@0 96 nsIFrame* aPrevFrame,
michael@0 97 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 98
michael@0 99 virtual nsresult RemoveFrame(ChildListID aListID,
michael@0 100 nsIFrame* aOldFrame) MOZ_OVERRIDE;
michael@0 101
michael@0 102 virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE;
michael@0 103
michael@0 104 virtual nsresult SetInitialChildList(ChildListID aListID,
michael@0 105 nsFrameList& aChildList) MOZ_OVERRIDE;
michael@0 106
michael@0 107 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
michael@0 108
michael@0 109 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
michael@0 110
michael@0 111 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 112 {
michael@0 113 // record that children that are ignorable whitespace should be excluded
michael@0 114 // (When content was loaded via the XUL content sink, it's already
michael@0 115 // been excluded, but we need this for when the XUL namespace is used
michael@0 116 // in other MIME types or when the XUL CSS display types are used with
michael@0 117 // non-XUL elements.)
michael@0 118
michael@0 119 // This is bogus, but it's what we've always done.
michael@0 120 // (Given that we're replaced, we need to say we're a replaced element
michael@0 121 // that contains a block so nsHTMLReflowState doesn't tell us to be
michael@0 122 // NS_INTRINSICSIZE wide.)
michael@0 123 return nsContainerFrame::IsFrameOfType(aFlags &
michael@0 124 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox |
michael@0 125 nsIFrame::eExcludesIgnorableWhitespace));
michael@0 126 }
michael@0 127
michael@0 128 #ifdef DEBUG_FRAME_DUMP
michael@0 129 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
michael@0 130 #endif
michael@0 131
michael@0 132 virtual nsresult DidReflow(nsPresContext* aPresContext,
michael@0 133 const nsHTMLReflowState* aReflowState,
michael@0 134 nsDidReflowStatus aStatus) MOZ_OVERRIDE;
michael@0 135
michael@0 136 virtual bool HonorPrintBackgroundSettings() MOZ_OVERRIDE;
michael@0 137
michael@0 138 virtual ~nsBoxFrame();
michael@0 139
michael@0 140 nsBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot = false, nsBoxLayout* aLayoutManager = nullptr);
michael@0 141
michael@0 142 // virtual so nsStackFrame, nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
michael@0 143 // can override it
michael@0 144 virtual void BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
michael@0 145 const nsRect& aDirtyRect,
michael@0 146 const nsDisplayListSet& aLists);
michael@0 147
michael@0 148 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 149 const nsRect& aDirtyRect,
michael@0 150 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
michael@0 151
michael@0 152 #ifdef DEBUG_LAYOUT
michael@0 153 virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug);
michael@0 154 nsresult DisplayDebugInfoFor(nsIFrame* aBox,
michael@0 155 nsPoint& aPoint);
michael@0 156 #endif
michael@0 157
michael@0 158 static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect);
michael@0 159
michael@0 160 /**
michael@0 161 * Utility method to redirect events on descendants to this frame.
michael@0 162 * Supports 'allowevents' attribute on descendant elements to allow those
michael@0 163 * elements and their descendants to receive events.
michael@0 164 */
michael@0 165 void WrapListsInRedirector(nsDisplayListBuilder* aBuilder,
michael@0 166 const nsDisplayListSet& aIn,
michael@0 167 const nsDisplayListSet& aOut);
michael@0 168
michael@0 169 /**
michael@0 170 * This defaults to true, but some box frames (nsListBoxBodyFrame for
michael@0 171 * example) don't support ordinals in their children.
michael@0 172 */
michael@0 173 virtual bool SupportsOrdinalsInChildren();
michael@0 174
michael@0 175 protected:
michael@0 176 #ifdef DEBUG_LAYOUT
michael@0 177 virtual void GetBoxName(nsAutoString& aName) MOZ_OVERRIDE;
michael@0 178 void PaintXULDebugBackground(nsRenderingContext& aRenderingContext,
michael@0 179 nsPoint aPt);
michael@0 180 void PaintXULDebugOverlay(nsRenderingContext& aRenderingContext,
michael@0 181 nsPoint aPt);
michael@0 182 #endif
michael@0 183
michael@0 184 virtual bool GetInitialEqualSize(bool& aEqualSize);
michael@0 185 virtual void GetInitialOrientation(bool& aIsHorizontal);
michael@0 186 virtual void GetInitialDirection(bool& aIsNormal);
michael@0 187 virtual bool GetInitialHAlignment(Halignment& aHalign);
michael@0 188 virtual bool GetInitialVAlignment(Valignment& aValign);
michael@0 189 virtual bool GetInitialAutoStretch(bool& aStretch);
michael@0 190
michael@0 191 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
michael@0 192
michael@0 193 nsSize mPrefSize;
michael@0 194 nsSize mMinSize;
michael@0 195 nsSize mMaxSize;
michael@0 196 nscoord mFlex;
michael@0 197 nscoord mAscent;
michael@0 198
michael@0 199 nsCOMPtr<nsBoxLayout> mLayoutManager;
michael@0 200
michael@0 201 // Get the point associated with this event. Returns true if a single valid
michael@0 202 // point was found. Otherwise false.
michael@0 203 bool GetEventPoint(mozilla::WidgetGUIEvent* aEvent, nsPoint& aPoint);
michael@0 204 // Gets the event coordinates relative to the widget offset associated with
michael@0 205 // this frame. Return true if a single valid point was found.
michael@0 206 bool GetEventPoint(mozilla::WidgetGUIEvent* aEvent, nsIntPoint& aPoint);
michael@0 207
michael@0 208 protected:
michael@0 209 void RegUnregAccessKey(bool aDoReg);
michael@0 210
michael@0 211 NS_HIDDEN_(void) CheckBoxOrder();
michael@0 212
michael@0 213 private:
michael@0 214
michael@0 215 #ifdef DEBUG_LAYOUT
michael@0 216 nsresult SetDebug(nsPresContext* aPresContext, bool aDebug);
michael@0 217 bool GetInitialDebug(bool& aDebug);
michael@0 218 void GetDebugPref(nsPresContext* aPresContext);
michael@0 219
michael@0 220 void GetDebugBorder(nsMargin& aInset);
michael@0 221 void GetDebugPadding(nsMargin& aInset);
michael@0 222 void GetDebugMargin(nsMargin& aInset);
michael@0 223
michael@0 224 nsresult GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize);
michael@0 225
michael@0 226 void PixelMarginToTwips(nsPresContext* aPresContext, nsMargin& aMarginPixels);
michael@0 227
michael@0 228 void GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* value);
michael@0 229 void GetValue(nsPresContext* aPresContext, int32_t a, int32_t b, char* value);
michael@0 230 void DrawSpacer(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext, bool aHorizontal, int32_t flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize);
michael@0 231 void DrawLine(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
michael@0 232 void FillRect(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height);
michael@0 233 #endif
michael@0 234 virtual void UpdateMouseThrough();
michael@0 235
michael@0 236 void CacheAttributes();
michael@0 237
michael@0 238 // instance variables.
michael@0 239 Halignment mHalign;
michael@0 240 Valignment mValign;
michael@0 241
michael@0 242 #ifdef DEBUG_LAYOUT
michael@0 243 static bool gDebug;
michael@0 244 static nsIFrame* mDebugChild;
michael@0 245 #endif
michael@0 246
michael@0 247 }; // class nsBoxFrame
michael@0 248
michael@0 249 #endif
michael@0 250

mercurial