layout/tables/nsTableColGroupFrame.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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 nsTableColGroupFrame_h__
michael@0 6 #define nsTableColGroupFrame_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 "nsTableColFrame.h"
michael@0 12
michael@0 13 class nsTableFrame;
michael@0 14 class nsTableColFrame;
michael@0 15
michael@0 16 enum nsTableColGroupType {
michael@0 17 eColGroupContent = 0, // there is real col group content associated
michael@0 18 eColGroupAnonymousCol = 1, // the result of a col
michael@0 19 eColGroupAnonymousCell = 2 // the result of a cell alone
michael@0 20 };
michael@0 21
michael@0 22 /**
michael@0 23 * nsTableColGroupFrame
michael@0 24 * data structure to maintain information about a single table cell's frame
michael@0 25 *
michael@0 26 * @author sclark
michael@0 27 */
michael@0 28 class nsTableColGroupFrame : public nsContainerFrame
michael@0 29 {
michael@0 30 public:
michael@0 31 NS_DECL_FRAMEARENA_HELPERS
michael@0 32
michael@0 33 // default constructor supplied by the compiler
michael@0 34
michael@0 35 /** instantiate a new instance of nsTableRowFrame.
michael@0 36 * @param aPresShell the pres shell for this frame
michael@0 37 *
michael@0 38 * @return the frame that was created
michael@0 39 */
michael@0 40 friend nsIFrame* NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 41
michael@0 42 /** Initialize the colgroup frame with a set of children.
michael@0 43 * @see nsIFrame::SetInitialChildList
michael@0 44 */
michael@0 45 virtual nsresult SetInitialChildList(ChildListID aListID,
michael@0 46 nsFrameList& aChildList) MOZ_OVERRIDE;
michael@0 47
michael@0 48 /**
michael@0 49 * ColGroups never paint anything, nor receive events.
michael@0 50 */
michael@0 51 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 52 const nsRect& aDirtyRect,
michael@0 53 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
michael@0 54
michael@0 55 /** A colgroup can be caused by three things:
michael@0 56 * 1) An element with table-column-group display
michael@0 57 * 2) An element with a table-column display without a
michael@0 58 * table-column-group parent
michael@0 59 * 3) Cells that are not in a column (and hence get an anonymous
michael@0 60 * column and colgroup).
michael@0 61 * @return colgroup type
michael@0 62 */
michael@0 63 nsTableColGroupType GetColType() const;
michael@0 64
michael@0 65 /** Set the colgroup type based on the creation cause
michael@0 66 * @param aType - the reason why this colgroup is needed
michael@0 67 */
michael@0 68 void SetColType(nsTableColGroupType aType);
michael@0 69
michael@0 70 /** Real in this context are colgroups that come from an element
michael@0 71 * with table-column-group display or wrap around columns that
michael@0 72 * come from an element with table-column display. Colgroups
michael@0 73 * that are the result of wrapping cells in an anonymous
michael@0 74 * column and colgroup are not considered real here.
michael@0 75 * @param aTableFrame - the table parent of the colgroups
michael@0 76 * @return the last real colgroup
michael@0 77 */
michael@0 78 static nsTableColGroupFrame* GetLastRealColGroup(nsTableFrame* aTableFrame);
michael@0 79
michael@0 80 /** @see nsIFrame::DidSetStyleContext */
michael@0 81 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
michael@0 82
michael@0 83 /** @see nsIFrame::AppendFrames, InsertFrames, RemoveFrame
michael@0 84 */
michael@0 85 virtual nsresult AppendFrames(ChildListID aListID,
michael@0 86 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 87 virtual nsresult InsertFrames(ChildListID aListID,
michael@0 88 nsIFrame* aPrevFrame,
michael@0 89 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 90 virtual nsresult RemoveFrame(ChildListID aListID,
michael@0 91 nsIFrame* aOldFrame) MOZ_OVERRIDE;
michael@0 92
michael@0 93 /** remove the column aChild from the column group, if requested renumber
michael@0 94 * the subsequent columns in this column group and all following column
michael@0 95 * groups. see also ResetColIndices for this
michael@0 96 * @param aChild - the column frame that needs to be removed
michael@0 97 * @param aResetSubsequentColIndices - if true the columns that follow
michael@0 98 * after aChild will be reenumerated
michael@0 99 */
michael@0 100 void RemoveChild(nsTableColFrame& aChild,
michael@0 101 bool aResetSubsequentColIndices);
michael@0 102
michael@0 103 /** reflow of a column group is a trivial matter of reflowing
michael@0 104 * the col group's children (columns), and setting this frame
michael@0 105 * to 0-size. Since tables are row-centric, column group frames
michael@0 106 * don't play directly in the rendering game. They do however
michael@0 107 * maintain important state that effects table and cell layout.
michael@0 108 */
michael@0 109 virtual nsresult Reflow(nsPresContext* aPresContext,
michael@0 110 nsHTMLReflowMetrics& aDesiredSize,
michael@0 111 const nsHTMLReflowState& aReflowState,
michael@0 112 nsReflowStatus& aStatus) MOZ_OVERRIDE;
michael@0 113
michael@0 114 /**
michael@0 115 * Get the "type" of the frame
michael@0 116 *
michael@0 117 * @see nsGkAtoms::tableColGroupFrame
michael@0 118 */
michael@0 119 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
michael@0 120
michael@0 121 /** Add column frames to the table storages: colframe cache and cellmap
michael@0 122 * this doesn't change the mFrames of the colgroup frame.
michael@0 123 * @param aFirstColIndex - the index at which aFirstFrame should be inserted
michael@0 124 * into the colframe cache.
michael@0 125 * @param aResetSubsequentColIndices - the indices of the col frames
michael@0 126 * after the insertion might need
michael@0 127 * an update
michael@0 128 * @param aCols - an iterator that can be used to iterate over the col
michael@0 129 * frames to be added. Once this is done, the frames on the
michael@0 130 * sbling chain of its .get() at that point will still need
michael@0 131 * their col indices updated.
michael@0 132 * @result - if there is no table frame or the table frame is not
michael@0 133 * the first in flow it will return an error
michael@0 134 */
michael@0 135 nsresult AddColsToTable(int32_t aFirstColIndex,
michael@0 136 bool aResetSubsequentColIndices,
michael@0 137 const nsFrameList::Slice& aCols);
michael@0 138
michael@0 139 #ifdef DEBUG_FRAME_DUMP
michael@0 140 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
michael@0 141 void Dump(int32_t aIndent);
michael@0 142 #endif
michael@0 143
michael@0 144 /** returns the number of columns represented by this group.
michael@0 145 * if there are col children, count them (taking into account the span of each)
michael@0 146 * else, check my own span attribute.
michael@0 147 */
michael@0 148 virtual int32_t GetColCount() const;
michael@0 149
michael@0 150 /** first column on the child list */
michael@0 151 nsTableColFrame * GetFirstColumn();
michael@0 152 /** next sibling to aChildFrame that is a column frame, first column frame
michael@0 153 * in the column group if aChildFrame is null
michael@0 154 */
michael@0 155 nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame);
michael@0 156
michael@0 157 /** @return - the position of the first column in this colgroup in the table
michael@0 158 * colframe cache.
michael@0 159 */
michael@0 160 int32_t GetStartColumnIndex();
michael@0 161
michael@0 162 /** set the position of the first column in this colgroup in the table
michael@0 163 * colframe cache.
michael@0 164 */
michael@0 165 void SetStartColumnIndex(int32_t aIndex);
michael@0 166
michael@0 167 /** helper method to get the span attribute for this colgroup */
michael@0 168 int32_t GetSpan();
michael@0 169
michael@0 170 /** provide access to the mFrames list
michael@0 171 */
michael@0 172 nsFrameList& GetWritableChildList();
michael@0 173
michael@0 174 /** set the column index for all frames starting at aStartColFrame, it
michael@0 175 * will also reset the column indices in all subsequent colgroups
michael@0 176 * @param aFirstColGroup - start the reset operation inside this colgroup
michael@0 177 * @param aFirstColIndex - first column that is reset should get this index
michael@0 178 * @param aStartColFrame - if specified the reset starts with this column
michael@0 179 * inside the colgroup; if not specified, the reset
michael@0 180 * starts with the first column
michael@0 181 */
michael@0 182 static void ResetColIndices(nsIFrame* aFirstColGroup,
michael@0 183 int32_t aFirstColIndex,
michael@0 184 nsIFrame* aStartColFrame = nullptr);
michael@0 185
michael@0 186 /**
michael@0 187 * Gets inner border widths before collapsing with cell borders
michael@0 188 * Caller must get left border from previous column
michael@0 189 * GetContinuousBCBorderWidth will not overwrite aBorder.left
michael@0 190 * see nsTablePainter about continuous borders
michael@0 191 */
michael@0 192 void GetContinuousBCBorderWidth(nsMargin& aBorder);
michael@0 193 /**
michael@0 194 * Set full border widths before collapsing with cell borders
michael@0 195 * @param aForSide - side to set; only accepts top and bottom
michael@0 196 */
michael@0 197 void SetContinuousBCBorderWidth(uint8_t aForSide,
michael@0 198 BCPixelSize aPixelValue);
michael@0 199
michael@0 200 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 201 {
michael@0 202 return nsContainerFrame::IsFrameOfType(aFlags & ~(nsIFrame::eTablePart));
michael@0 203 }
michael@0 204
michael@0 205 virtual void InvalidateFrame(uint32_t aDisplayItemKey = 0) MOZ_OVERRIDE;
michael@0 206 virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0) MOZ_OVERRIDE;
michael@0 207 virtual void InvalidateFrameForRemoval() MOZ_OVERRIDE { InvalidateFrameSubtree(); }
michael@0 208
michael@0 209 protected:
michael@0 210 nsTableColGroupFrame(nsStyleContext* aContext);
michael@0 211
michael@0 212 void InsertColsReflow(int32_t aColIndex,
michael@0 213 const nsFrameList::Slice& aCols);
michael@0 214
michael@0 215 virtual int GetLogicalSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const MOZ_OVERRIDE;
michael@0 216
michael@0 217 // data members
michael@0 218 int32_t mColCount;
michael@0 219 // the starting column index this col group represents. Must be >= 0.
michael@0 220 int32_t mStartColIndex;
michael@0 221
michael@0 222 // border width in pixels
michael@0 223 BCPixelSize mTopContBorderWidth;
michael@0 224 BCPixelSize mBottomContBorderWidth;
michael@0 225 };
michael@0 226
michael@0 227 inline nsTableColGroupFrame::nsTableColGroupFrame(nsStyleContext *aContext)
michael@0 228 : nsContainerFrame(aContext), mColCount(0), mStartColIndex(0)
michael@0 229 {
michael@0 230 SetColType(eColGroupContent);
michael@0 231 }
michael@0 232
michael@0 233 inline int32_t nsTableColGroupFrame::GetStartColumnIndex()
michael@0 234 {
michael@0 235 return mStartColIndex;
michael@0 236 }
michael@0 237
michael@0 238 inline void nsTableColGroupFrame::SetStartColumnIndex (int32_t aIndex)
michael@0 239 {
michael@0 240 mStartColIndex = aIndex;
michael@0 241 }
michael@0 242
michael@0 243 inline int32_t nsTableColGroupFrame::GetColCount() const
michael@0 244 {
michael@0 245 return mColCount;
michael@0 246 }
michael@0 247
michael@0 248 inline nsFrameList& nsTableColGroupFrame::GetWritableChildList()
michael@0 249 {
michael@0 250 return mFrames;
michael@0 251 }
michael@0 252
michael@0 253 #endif
michael@0 254

mercurial