Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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 | #ifndef nsTableOuterFrame_h__ |
michael@0 | 6 | #define nsTableOuterFrame_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "mozilla/Attributes.h" |
michael@0 | 9 | #include "nscore.h" |
michael@0 | 10 | #include "nsContainerFrame.h" |
michael@0 | 11 | #include "nsCellMap.h" |
michael@0 | 12 | #include "nsBlockFrame.h" |
michael@0 | 13 | #include "nsTableFrame.h" |
michael@0 | 14 | |
michael@0 | 15 | class nsTableCaptionFrame : public nsBlockFrame |
michael@0 | 16 | { |
michael@0 | 17 | public: |
michael@0 | 18 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 19 | |
michael@0 | 20 | // nsISupports |
michael@0 | 21 | virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
michael@0 | 22 | friend nsIFrame* NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
michael@0 | 23 | |
michael@0 | 24 | virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext, |
michael@0 | 25 | nsSize aCBSize, nscoord aAvailableWidth, |
michael@0 | 26 | nsSize aMargin, nsSize aBorder, |
michael@0 | 27 | nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE; |
michael@0 | 28 | |
michael@0 | 29 | virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE; |
michael@0 | 30 | |
michael@0 | 31 | #ifdef ACCESSIBILITY |
michael@0 | 32 | virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
michael@0 | 33 | #endif |
michael@0 | 34 | |
michael@0 | 35 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 36 | virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
michael@0 | 37 | #endif |
michael@0 | 38 | |
michael@0 | 39 | protected: |
michael@0 | 40 | nsTableCaptionFrame(nsStyleContext* aContext); |
michael@0 | 41 | virtual ~nsTableCaptionFrame(); |
michael@0 | 42 | }; |
michael@0 | 43 | |
michael@0 | 44 | |
michael@0 | 45 | /* TODO |
michael@0 | 46 | 1. decide if we'll allow subclassing. If so, decide which methods really need to be virtual. |
michael@0 | 47 | */ |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * main frame for an nsTable content object, |
michael@0 | 51 | * the nsTableOuterFrame contains 0 or one caption frame, and a nsTableFrame |
michael@0 | 52 | * pseudo-frame (referred to as the "inner frame'). |
michael@0 | 53 | */ |
michael@0 | 54 | class nsTableOuterFrame : public nsContainerFrame |
michael@0 | 55 | { |
michael@0 | 56 | public: |
michael@0 | 57 | NS_DECL_QUERYFRAME |
michael@0 | 58 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 59 | |
michael@0 | 60 | NS_DECL_QUERYFRAME_TARGET(nsTableOuterFrame) |
michael@0 | 61 | |
michael@0 | 62 | /** instantiate a new instance of nsTableRowFrame. |
michael@0 | 63 | * @param aPresShell the pres shell for this frame |
michael@0 | 64 | * |
michael@0 | 65 | * @return the frame that was created |
michael@0 | 66 | */ |
michael@0 | 67 | friend nsIFrame* NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
michael@0 | 68 | |
michael@0 | 69 | // nsIFrame overrides - see there for a description |
michael@0 | 70 | |
michael@0 | 71 | virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
michael@0 | 72 | |
michael@0 | 73 | virtual nsresult SetInitialChildList(ChildListID aListID, |
michael@0 | 74 | nsFrameList& aChildList) MOZ_OVERRIDE; |
michael@0 | 75 | |
michael@0 | 76 | virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE; |
michael@0 | 77 | virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE; |
michael@0 | 78 | |
michael@0 | 79 | virtual nsresult AppendFrames(ChildListID aListID, |
michael@0 | 80 | nsFrameList& aFrameList) MOZ_OVERRIDE; |
michael@0 | 81 | |
michael@0 | 82 | virtual nsresult InsertFrames(ChildListID aListID, |
michael@0 | 83 | nsIFrame* aPrevFrame, |
michael@0 | 84 | nsFrameList& aFrameList) MOZ_OVERRIDE; |
michael@0 | 85 | |
michael@0 | 86 | virtual nsresult RemoveFrame(ChildListID aListID, |
michael@0 | 87 | nsIFrame* aOldFrame) MOZ_OVERRIDE; |
michael@0 | 88 | |
michael@0 | 89 | virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE { |
michael@0 | 90 | return GetFirstPrincipalChild()->GetContentInsertionFrame(); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | #ifdef ACCESSIBILITY |
michael@0 | 94 | virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
michael@0 | 95 | #endif |
michael@0 | 96 | |
michael@0 | 97 | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
michael@0 | 98 | const nsRect& aDirtyRect, |
michael@0 | 99 | const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
michael@0 | 100 | |
michael@0 | 101 | void BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuilder, |
michael@0 | 102 | const nsRect& aDirtyRect, |
michael@0 | 103 | const nsDisplayListSet& aLists); |
michael@0 | 104 | |
michael@0 | 105 | virtual nscoord GetBaseline() const MOZ_OVERRIDE; |
michael@0 | 106 | |
michael@0 | 107 | virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 108 | virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 109 | virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext, |
michael@0 | 110 | nsSize aCBSize, nscoord aAvailableWidth, |
michael@0 | 111 | nsSize aMargin, nsSize aBorder, |
michael@0 | 112 | nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE; |
michael@0 | 113 | |
michael@0 | 114 | /** process a reflow command for the table. |
michael@0 | 115 | * This involves reflowing the caption and the inner table. |
michael@0 | 116 | * @see nsIFrame::Reflow */ |
michael@0 | 117 | virtual nsresult Reflow(nsPresContext* aPresContext, |
michael@0 | 118 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 119 | const nsHTMLReflowState& aReflowState, |
michael@0 | 120 | nsReflowStatus& aStatus) MOZ_OVERRIDE; |
michael@0 | 121 | |
michael@0 | 122 | /** |
michael@0 | 123 | * Get the "type" of the frame |
michael@0 | 124 | * |
michael@0 | 125 | * @see nsGkAtoms::tableOuterFrame |
michael@0 | 126 | */ |
michael@0 | 127 | virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
michael@0 | 128 | |
michael@0 | 129 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 130 | virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
michael@0 | 131 | #endif |
michael@0 | 132 | |
michael@0 | 133 | virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE; |
michael@0 | 134 | |
michael@0 | 135 | /** |
michael@0 | 136 | * Return the content for the cell at the given row and column. |
michael@0 | 137 | */ |
michael@0 | 138 | nsIContent* GetCellAt(uint32_t aRowIdx, uint32_t aColIdx) const; |
michael@0 | 139 | |
michael@0 | 140 | /** |
michael@0 | 141 | * Return the number of rows in the table. |
michael@0 | 142 | */ |
michael@0 | 143 | int32_t GetRowCount() const |
michael@0 | 144 | { |
michael@0 | 145 | return InnerTableFrame()->GetRowCount(); |
michael@0 | 146 | } |
michael@0 | 147 | |
michael@0 | 148 | /** |
michael@0 | 149 | * Return the number of columns in the table. |
michael@0 | 150 | */ |
michael@0 | 151 | int32_t GetColCount() const |
michael@0 | 152 | { |
michael@0 | 153 | return InnerTableFrame()->GetColCount(); |
michael@0 | 154 | } |
michael@0 | 155 | |
michael@0 | 156 | /** |
michael@0 | 157 | * Return the index of the cell at the given row and column. |
michael@0 | 158 | */ |
michael@0 | 159 | int32_t GetIndexByRowAndColumn(int32_t aRowIdx, int32_t aColIdx) const |
michael@0 | 160 | { |
michael@0 | 161 | nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap(); |
michael@0 | 162 | if (!cellMap) |
michael@0 | 163 | return -1; |
michael@0 | 164 | |
michael@0 | 165 | return cellMap->GetIndexByRowAndColumn(aRowIdx, aColIdx); |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | /** |
michael@0 | 169 | * Get the row and column indices for the cell at the given index. |
michael@0 | 170 | */ |
michael@0 | 171 | void GetRowAndColumnByIndex(int32_t aCellIdx, int32_t* aRowIdx, |
michael@0 | 172 | int32_t* aColIdx) const |
michael@0 | 173 | { |
michael@0 | 174 | *aRowIdx = *aColIdx = 0; |
michael@0 | 175 | nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap(); |
michael@0 | 176 | if (cellMap) { |
michael@0 | 177 | cellMap->GetRowAndColumnByIndex(aCellIdx, aRowIdx, aColIdx); |
michael@0 | 178 | } |
michael@0 | 179 | } |
michael@0 | 180 | |
michael@0 | 181 | /** |
michael@0 | 182 | * return the frame for the cell at the given row and column. |
michael@0 | 183 | */ |
michael@0 | 184 | nsTableCellFrame* GetCellFrameAt(uint32_t aRowIdx, uint32_t aColIdx) const |
michael@0 | 185 | { |
michael@0 | 186 | nsTableCellMap* map = InnerTableFrame()->GetCellMap(); |
michael@0 | 187 | if (!map) { |
michael@0 | 188 | return nullptr; |
michael@0 | 189 | } |
michael@0 | 190 | |
michael@0 | 191 | return map->GetCellInfoAt(aRowIdx, aColIdx); |
michael@0 | 192 | } |
michael@0 | 193 | |
michael@0 | 194 | /** |
michael@0 | 195 | * Return the col span of the cell at the given row and column indices. |
michael@0 | 196 | */ |
michael@0 | 197 | uint32_t GetEffectiveColSpanAt(uint32_t aRowIdx, uint32_t aColIdx) const |
michael@0 | 198 | { |
michael@0 | 199 | nsTableCellMap* map = InnerTableFrame()->GetCellMap(); |
michael@0 | 200 | return map->GetEffectiveColSpan(aRowIdx, aColIdx); |
michael@0 | 201 | } |
michael@0 | 202 | |
michael@0 | 203 | /** |
michael@0 | 204 | * Return the effective row span of the cell at the given row and column. |
michael@0 | 205 | */ |
michael@0 | 206 | uint32_t GetEffectiveRowSpanAt(uint32_t aRowIdx, uint32_t aColIdx) const |
michael@0 | 207 | { |
michael@0 | 208 | nsTableCellMap* map = InnerTableFrame()->GetCellMap(); |
michael@0 | 209 | return map->GetEffectiveRowSpan(aRowIdx, aColIdx); |
michael@0 | 210 | } |
michael@0 | 211 | |
michael@0 | 212 | protected: |
michael@0 | 213 | |
michael@0 | 214 | |
michael@0 | 215 | nsTableOuterFrame(nsStyleContext* aContext); |
michael@0 | 216 | virtual ~nsTableOuterFrame(); |
michael@0 | 217 | |
michael@0 | 218 | void InitChildReflowState(nsPresContext& aPresContext, |
michael@0 | 219 | nsHTMLReflowState& aReflowState); |
michael@0 | 220 | |
michael@0 | 221 | uint8_t GetCaptionSide(); // NS_STYLE_CAPTION_SIDE_* or NO_SIDE |
michael@0 | 222 | |
michael@0 | 223 | bool HasSideCaption() { |
michael@0 | 224 | uint8_t captionSide = GetCaptionSide(); |
michael@0 | 225 | return captionSide == NS_STYLE_CAPTION_SIDE_LEFT || |
michael@0 | 226 | captionSide == NS_STYLE_CAPTION_SIDE_RIGHT; |
michael@0 | 227 | } |
michael@0 | 228 | |
michael@0 | 229 | uint8_t GetCaptionVerticalAlign(); |
michael@0 | 230 | |
michael@0 | 231 | void SetDesiredSize(uint8_t aCaptionSide, |
michael@0 | 232 | const nsMargin& aInnerMargin, |
michael@0 | 233 | const nsMargin& aCaptionMargin, |
michael@0 | 234 | nscoord& aWidth, |
michael@0 | 235 | nscoord& aHeight); |
michael@0 | 236 | |
michael@0 | 237 | nsresult GetCaptionOrigin(uint32_t aCaptionSide, |
michael@0 | 238 | const nsSize& aContainBlockSize, |
michael@0 | 239 | const nsSize& aInnerSize, |
michael@0 | 240 | const nsMargin& aInnerMargin, |
michael@0 | 241 | const nsSize& aCaptionSize, |
michael@0 | 242 | nsMargin& aCaptionMargin, |
michael@0 | 243 | nsPoint& aOrigin); |
michael@0 | 244 | |
michael@0 | 245 | nsresult GetInnerOrigin(uint32_t aCaptionSide, |
michael@0 | 246 | const nsSize& aContainBlockSize, |
michael@0 | 247 | const nsSize& aCaptionSize, |
michael@0 | 248 | const nsMargin& aCaptionMargin, |
michael@0 | 249 | const nsSize& aInnerSize, |
michael@0 | 250 | nsMargin& aInnerMargin, |
michael@0 | 251 | nsPoint& aOrigin); |
michael@0 | 252 | |
michael@0 | 253 | // reflow the child (caption or innertable frame) |
michael@0 | 254 | void OuterBeginReflowChild(nsPresContext* aPresContext, |
michael@0 | 255 | nsIFrame* aChildFrame, |
michael@0 | 256 | const nsHTMLReflowState& aOuterRS, |
michael@0 | 257 | void* aChildRSSpace, |
michael@0 | 258 | nscoord aAvailWidth); |
michael@0 | 259 | |
michael@0 | 260 | nsresult OuterDoReflowChild(nsPresContext* aPresContext, |
michael@0 | 261 | nsIFrame* aChildFrame, |
michael@0 | 262 | const nsHTMLReflowState& aChildRS, |
michael@0 | 263 | nsHTMLReflowMetrics& aMetrics, |
michael@0 | 264 | nsReflowStatus& aStatus); |
michael@0 | 265 | |
michael@0 | 266 | // Set the reflow metrics |
michael@0 | 267 | void UpdateReflowMetrics(uint8_t aCaptionSide, |
michael@0 | 268 | nsHTMLReflowMetrics& aMet, |
michael@0 | 269 | const nsMargin& aInnerMargin, |
michael@0 | 270 | const nsMargin& aCaptionMargin); |
michael@0 | 271 | |
michael@0 | 272 | // Get the margin. aMarginNoAuto is aMargin, but with auto |
michael@0 | 273 | // margins set to 0 |
michael@0 | 274 | void GetChildMargin(nsPresContext* aPresContext, |
michael@0 | 275 | const nsHTMLReflowState& aOuterRS, |
michael@0 | 276 | nsIFrame* aChildFrame, |
michael@0 | 277 | nscoord aAvailableWidth, |
michael@0 | 278 | nsMargin& aMargin); |
michael@0 | 279 | |
michael@0 | 280 | virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
michael@0 | 281 | { |
michael@0 | 282 | return nsContainerFrame::IsFrameOfType(aFlags & |
michael@0 | 283 | (~eCanContainOverflowContainers)); |
michael@0 | 284 | } |
michael@0 | 285 | |
michael@0 | 286 | nsTableFrame* InnerTableFrame() const { |
michael@0 | 287 | return static_cast<nsTableFrame*>(mFrames.FirstChild()); |
michael@0 | 288 | } |
michael@0 | 289 | |
michael@0 | 290 | private: |
michael@0 | 291 | nsFrameList mCaptionFrames; |
michael@0 | 292 | }; |
michael@0 | 293 | |
michael@0 | 294 | #endif |