layout/tables/nsTableRowFrame.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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 nsTableRowFrame_h__
michael@0 6 #define nsTableRowFrame_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 "nsTablePainter.h"
michael@0 12
michael@0 13 class nsTableFrame;
michael@0 14 class nsTableCellFrame;
michael@0 15 struct nsTableCellReflowState;
michael@0 16
michael@0 17 /**
michael@0 18 * nsTableRowFrame is the frame that maps table rows
michael@0 19 * (HTML tag TR). This class cannot be reused
michael@0 20 * outside of an nsTableRowGroupFrame. It assumes that its parent is an nsTableRowGroupFrame,
michael@0 21 * and its children are nsTableCellFrames.
michael@0 22 *
michael@0 23 * @see nsTableFrame
michael@0 24 * @see nsTableRowGroupFrame
michael@0 25 * @see nsTableCellFrame
michael@0 26 */
michael@0 27 class nsTableRowFrame : public nsContainerFrame
michael@0 28 {
michael@0 29 public:
michael@0 30 NS_DECL_QUERYFRAME_TARGET(nsTableRowFrame)
michael@0 31 NS_DECL_QUERYFRAME
michael@0 32 NS_DECL_FRAMEARENA_HELPERS
michael@0 33
michael@0 34 virtual ~nsTableRowFrame();
michael@0 35
michael@0 36 virtual void Init(nsIContent* aContent,
michael@0 37 nsIFrame* aParent,
michael@0 38 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
michael@0 39
michael@0 40 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
michael@0 41
michael@0 42 /** @see nsIFrame::DidSetStyleContext */
michael@0 43 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
michael@0 44
michael@0 45 virtual nsresult AppendFrames(ChildListID aListID,
michael@0 46 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 47 virtual nsresult InsertFrames(ChildListID aListID,
michael@0 48 nsIFrame* aPrevFrame,
michael@0 49 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 50 virtual nsresult RemoveFrame(ChildListID aListID,
michael@0 51 nsIFrame* aOldFrame) MOZ_OVERRIDE;
michael@0 52
michael@0 53 /** instantiate a new instance of nsTableRowFrame.
michael@0 54 * @param aPresShell the pres shell for this frame
michael@0 55 *
michael@0 56 * @return the frame that was created
michael@0 57 */
michael@0 58 friend nsIFrame* NS_NewTableRowFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 59
michael@0 60 virtual nsMargin GetUsedMargin() const MOZ_OVERRIDE;
michael@0 61 virtual nsMargin GetUsedBorder() const MOZ_OVERRIDE;
michael@0 62 virtual nsMargin GetUsedPadding() const MOZ_OVERRIDE;
michael@0 63
michael@0 64 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 65 const nsRect& aDirtyRect,
michael@0 66 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
michael@0 67
michael@0 68 nsTableCellFrame* GetFirstCell() ;
michael@0 69
michael@0 70 /** calls Reflow for all of its child cells.
michael@0 71 * Cells with rowspan=1 are all set to the same height and stacked horizontally.
michael@0 72 * <P> Cells are not split unless absolutely necessary.
michael@0 73 * <P> Cells are resized in nsTableFrame::BalanceColumnWidths
michael@0 74 * and nsTableFrame::ShrinkWrapChildren
michael@0 75 *
michael@0 76 * @param aDesiredSize width set to width of the sum of the cells, height set to
michael@0 77 * height of cells with rowspan=1.
michael@0 78 *
michael@0 79 * @see nsIFrame::Reflow
michael@0 80 * @see nsTableFrame::BalanceColumnWidths
michael@0 81 * @see nsTableFrame::ShrinkWrapChildren
michael@0 82 */
michael@0 83 virtual nsresult Reflow(nsPresContext* aPresContext,
michael@0 84 nsHTMLReflowMetrics& aDesiredSize,
michael@0 85 const nsHTMLReflowState& aReflowState,
michael@0 86 nsReflowStatus& aStatus) MOZ_OVERRIDE;
michael@0 87
michael@0 88 void DidResize();
michael@0 89
michael@0 90 /**
michael@0 91 * Get the "type" of the frame
michael@0 92 *
michael@0 93 * @see nsGkAtoms::tableRowFrame
michael@0 94 */
michael@0 95 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
michael@0 96
michael@0 97 #ifdef DEBUG_FRAME_DUMP
michael@0 98 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
michael@0 99 #endif
michael@0 100
michael@0 101 void UpdateHeight(nscoord aHeight,
michael@0 102 nscoord aAscent,
michael@0 103 nscoord aDescent,
michael@0 104 nsTableFrame* aTableFrame = nullptr,
michael@0 105 nsTableCellFrame* aCellFrame = nullptr);
michael@0 106
michael@0 107 void ResetHeight(nscoord aRowStyleHeight);
michael@0 108
michael@0 109 // calculate the height, considering content height of the
michael@0 110 // cells and the style height of the row and cells, excluding pct heights
michael@0 111 nscoord CalcHeight(const nsHTMLReflowState& aReflowState);
michael@0 112
michael@0 113 // Support for cells with 'vertical-align: baseline'.
michael@0 114
michael@0 115 /**
michael@0 116 * returns the max-ascent amongst all the cells that have
michael@0 117 * 'vertical-align: baseline', *including* cells with rowspans.
michael@0 118 * returns 0 if we don't have any cell with 'vertical-align: baseline'
michael@0 119 */
michael@0 120 nscoord GetMaxCellAscent() const;
michael@0 121
michael@0 122 /* return the row ascent
michael@0 123 */
michael@0 124 nscoord GetRowBaseline();
michael@0 125
michael@0 126 /** returns the ordinal position of this row in its table */
michael@0 127 virtual int32_t GetRowIndex() const;
michael@0 128
michael@0 129 /** set this row's starting row index */
michael@0 130 void SetRowIndex (int aRowIndex);
michael@0 131
michael@0 132 /** used by row group frame code */
michael@0 133 nscoord ReflowCellFrame(nsPresContext* aPresContext,
michael@0 134 const nsHTMLReflowState& aReflowState,
michael@0 135 bool aIsTopOfPage,
michael@0 136 nsTableCellFrame* aCellFrame,
michael@0 137 nscoord aAvailableHeight,
michael@0 138 nsReflowStatus& aStatus);
michael@0 139 /**
michael@0 140 * Collapse the row if required, apply col and colgroup visibility: collapse
michael@0 141 * info to the cells in the row.
michael@0 142 * @return he amount to shift up all following rows
michael@0 143 * @param aRowOffset - shift the row up by this amount
michael@0 144 * @param aWidth - new width of the row
michael@0 145 * @param aCollapseGroup - parent rowgroup is collapsed so this row needs
michael@0 146 * to be collapsed
michael@0 147 * @param aDidCollapse - the row has been collapsed
michael@0 148 */
michael@0 149 nscoord CollapseRowIfNecessary(nscoord aRowOffset,
michael@0 150 nscoord aWidth,
michael@0 151 bool aCollapseGroup,
michael@0 152 bool& aDidCollapse);
michael@0 153
michael@0 154 /**
michael@0 155 * Insert a cell frame after the last cell frame that has a col index
michael@0 156 * that is less than aColIndex. If no such cell frame is found the
michael@0 157 * frame to insert is prepended to the child list.
michael@0 158 * @param aFrame the cell frame to insert
michael@0 159 * @param aColIndex the col index
michael@0 160 */
michael@0 161 void InsertCellFrame(nsTableCellFrame* aFrame,
michael@0 162 int32_t aColIndex);
michael@0 163
michael@0 164 nsresult CalculateCellActualHeight(nsTableCellFrame* aCellFrame,
michael@0 165 nscoord& aDesiredHeight);
michael@0 166
michael@0 167 bool IsFirstInserted() const;
michael@0 168 void SetFirstInserted(bool aValue);
michael@0 169
michael@0 170 nscoord GetContentHeight() const;
michael@0 171 void SetContentHeight(nscoord aTwipValue);
michael@0 172
michael@0 173 bool HasStyleHeight() const;
michael@0 174
michael@0 175 bool HasFixedHeight() const;
michael@0 176 void SetHasFixedHeight(bool aValue);
michael@0 177
michael@0 178 bool HasPctHeight() const;
michael@0 179 void SetHasPctHeight(bool aValue);
michael@0 180
michael@0 181 nscoord GetFixedHeight() const;
michael@0 182 void SetFixedHeight(nscoord aValue);
michael@0 183
michael@0 184 float GetPctHeight() const;
michael@0 185 void SetPctHeight(float aPctValue,
michael@0 186 bool aForce = false);
michael@0 187
michael@0 188 nscoord GetHeight(nscoord aBasis = 0) const;
michael@0 189
michael@0 190 nsTableRowFrame* GetNextRow() const;
michael@0 191
michael@0 192 bool HasUnpaginatedHeight();
michael@0 193 void SetHasUnpaginatedHeight(bool aValue);
michael@0 194 nscoord GetUnpaginatedHeight(nsPresContext* aPresContext);
michael@0 195 void SetUnpaginatedHeight(nsPresContext* aPresContext, nscoord aValue);
michael@0 196
michael@0 197 nscoord GetTopBCBorderWidth();
michael@0 198 void SetTopBCBorderWidth(BCPixelSize aWidth);
michael@0 199 nscoord GetBottomBCBorderWidth();
michael@0 200 void SetBottomBCBorderWidth(BCPixelSize aWidth);
michael@0 201 nsMargin* GetBCBorderWidth(nsMargin& aBorder);
michael@0 202
michael@0 203 /**
michael@0 204 * Gets inner border widths before collapsing with cell borders
michael@0 205 * Caller must get bottom border from next row or from table
michael@0 206 * GetContinuousBCBorderWidth will not overwrite aBorder.bottom
michael@0 207 * see nsTablePainter about continuous borders
michael@0 208 */
michael@0 209 void GetContinuousBCBorderWidth(nsMargin& aBorder);
michael@0 210 /**
michael@0 211 * @returns outer top bc border == prev row's bottom inner
michael@0 212 */
michael@0 213 nscoord GetOuterTopContBCBorderWidth();
michael@0 214 /**
michael@0 215 * Sets full border widths before collapsing with cell borders
michael@0 216 * @param aForSide - side to set; only accepts right, left, and top
michael@0 217 */
michael@0 218 void SetContinuousBCBorderWidth(uint8_t aForSide,
michael@0 219 BCPixelSize aPixelValue);
michael@0 220
michael@0 221 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 222 {
michael@0 223 return nsContainerFrame::IsFrameOfType(aFlags & ~(nsIFrame::eTablePart));
michael@0 224 }
michael@0 225
michael@0 226 virtual void InvalidateFrame(uint32_t aDisplayItemKey = 0) MOZ_OVERRIDE;
michael@0 227 virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0) MOZ_OVERRIDE;
michael@0 228 virtual void InvalidateFrameForRemoval() MOZ_OVERRIDE { InvalidateFrameSubtree(); }
michael@0 229
michael@0 230 #ifdef ACCESSIBILITY
michael@0 231 virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
michael@0 232 #endif
michael@0 233
michael@0 234 protected:
michael@0 235
michael@0 236 /** protected constructor.
michael@0 237 * @see NewFrame
michael@0 238 */
michael@0 239 nsTableRowFrame(nsStyleContext *aContext);
michael@0 240
michael@0 241 void InitChildReflowState(nsPresContext& aPresContext,
michael@0 242 const nsSize& aAvailSize,
michael@0 243 bool aBorderCollapse,
michael@0 244 nsTableCellReflowState& aReflowState);
michael@0 245
michael@0 246 virtual int GetLogicalSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const MOZ_OVERRIDE;
michael@0 247
michael@0 248 // row-specific methods
michael@0 249
michael@0 250 nscoord ComputeCellXOffset(const nsHTMLReflowState& aState,
michael@0 251 nsIFrame* aKidFrame,
michael@0 252 const nsMargin& aKidMargin) const;
michael@0 253 /**
michael@0 254 * Called for incremental/dirty and resize reflows. If aDirtyOnly is true then
michael@0 255 * only reflow dirty cells.
michael@0 256 */
michael@0 257 nsresult ReflowChildren(nsPresContext* aPresContext,
michael@0 258 nsHTMLReflowMetrics& aDesiredSize,
michael@0 259 const nsHTMLReflowState& aReflowState,
michael@0 260 nsTableFrame& aTableFrame,
michael@0 261 nsReflowStatus& aStatus);
michael@0 262
michael@0 263 private:
michael@0 264 struct RowBits {
michael@0 265 unsigned mRowIndex:29;
michael@0 266 unsigned mHasFixedHeight:1; // set if the dominating style height on the row or any cell is pixel based
michael@0 267 unsigned mHasPctHeight:1; // set if the dominating style height on the row or any cell is pct based
michael@0 268 unsigned mFirstInserted:1; // if true, then it was the top most newly inserted row
michael@0 269 } mBits;
michael@0 270
michael@0 271 // the desired height based on the content of the tallest cell in the row
michael@0 272 nscoord mContentHeight;
michael@0 273 // the height based on a style percentage height on either the row or any cell
michael@0 274 // if mHasPctHeight is set
michael@0 275 nscoord mStylePctHeight;
michael@0 276 // the height based on a style pixel height on the row or any
michael@0 277 // cell if mHasFixedHeight is set
michael@0 278 nscoord mStyleFixedHeight;
michael@0 279
michael@0 280 // max-ascent and max-descent amongst all cells that have 'vertical-align: baseline'
michael@0 281 nscoord mMaxCellAscent; // does include cells with rowspan > 1
michael@0 282 nscoord mMaxCellDescent; // does *not* include cells with rowspan > 1
michael@0 283
michael@0 284 // border widths in pixels in the collapsing border model of the *inner*
michael@0 285 // half of the border only
michael@0 286 BCPixelSize mTopBorderWidth;
michael@0 287 BCPixelSize mBottomBorderWidth;
michael@0 288 BCPixelSize mRightContBorderWidth;
michael@0 289 BCPixelSize mTopContBorderWidth;
michael@0 290 BCPixelSize mLeftContBorderWidth;
michael@0 291
michael@0 292 /**
michael@0 293 * Sets the NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT bit to indicate whether
michael@0 294 * this row has any cells that have non-auto-height. (Row-spanning
michael@0 295 * cells are ignored.)
michael@0 296 */
michael@0 297 void InitHasCellWithStyleHeight(nsTableFrame* aTableFrame);
michael@0 298
michael@0 299 };
michael@0 300
michael@0 301 inline int32_t nsTableRowFrame::GetRowIndex() const
michael@0 302 {
michael@0 303 return int32_t(mBits.mRowIndex);
michael@0 304 }
michael@0 305
michael@0 306 inline void nsTableRowFrame::SetRowIndex (int aRowIndex)
michael@0 307 {
michael@0 308 mBits.mRowIndex = aRowIndex;
michael@0 309 }
michael@0 310
michael@0 311 inline bool nsTableRowFrame::IsFirstInserted() const
michael@0 312 {
michael@0 313 return bool(mBits.mFirstInserted);
michael@0 314 }
michael@0 315
michael@0 316 inline void nsTableRowFrame::SetFirstInserted(bool aValue)
michael@0 317 {
michael@0 318 mBits.mFirstInserted = aValue;
michael@0 319 }
michael@0 320
michael@0 321 inline bool nsTableRowFrame::HasStyleHeight() const
michael@0 322 {
michael@0 323 return (bool)mBits.mHasFixedHeight || (bool)mBits.mHasPctHeight;
michael@0 324 }
michael@0 325
michael@0 326 inline bool nsTableRowFrame::HasFixedHeight() const
michael@0 327 {
michael@0 328 return (bool)mBits.mHasFixedHeight;
michael@0 329 }
michael@0 330
michael@0 331 inline void nsTableRowFrame::SetHasFixedHeight(bool aValue)
michael@0 332 {
michael@0 333 mBits.mHasFixedHeight = aValue;
michael@0 334 }
michael@0 335
michael@0 336 inline bool nsTableRowFrame::HasPctHeight() const
michael@0 337 {
michael@0 338 return (bool)mBits.mHasPctHeight;
michael@0 339 }
michael@0 340
michael@0 341 inline void nsTableRowFrame::SetHasPctHeight(bool aValue)
michael@0 342 {
michael@0 343 mBits.mHasPctHeight = aValue;
michael@0 344 }
michael@0 345
michael@0 346 inline nscoord nsTableRowFrame::GetContentHeight() const
michael@0 347 {
michael@0 348 return mContentHeight;
michael@0 349 }
michael@0 350
michael@0 351 inline void nsTableRowFrame::SetContentHeight(nscoord aValue)
michael@0 352 {
michael@0 353 mContentHeight = aValue;
michael@0 354 }
michael@0 355
michael@0 356 inline nscoord nsTableRowFrame::GetFixedHeight() const
michael@0 357 {
michael@0 358 if (mBits.mHasFixedHeight)
michael@0 359 return mStyleFixedHeight;
michael@0 360 else
michael@0 361 return 0;
michael@0 362 }
michael@0 363
michael@0 364 inline float nsTableRowFrame::GetPctHeight() const
michael@0 365 {
michael@0 366 if (mBits.mHasPctHeight)
michael@0 367 return (float)mStylePctHeight / 100.0f;
michael@0 368 else
michael@0 369 return 0.0f;
michael@0 370 }
michael@0 371
michael@0 372 inline bool nsTableRowFrame::HasUnpaginatedHeight()
michael@0 373 {
michael@0 374 return (mState & NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT) ==
michael@0 375 NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT;
michael@0 376 }
michael@0 377
michael@0 378 inline void nsTableRowFrame::SetHasUnpaginatedHeight(bool aValue)
michael@0 379 {
michael@0 380 if (aValue) {
michael@0 381 mState |= NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT;
michael@0 382 } else {
michael@0 383 mState &= ~NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT;
michael@0 384 }
michael@0 385 }
michael@0 386
michael@0 387 inline nscoord nsTableRowFrame::GetTopBCBorderWidth()
michael@0 388 {
michael@0 389 return mTopBorderWidth;
michael@0 390 }
michael@0 391
michael@0 392 inline void nsTableRowFrame::SetTopBCBorderWidth(BCPixelSize aWidth)
michael@0 393 {
michael@0 394 mTopBorderWidth = aWidth;
michael@0 395 }
michael@0 396
michael@0 397 inline nscoord nsTableRowFrame::GetBottomBCBorderWidth()
michael@0 398 {
michael@0 399 return mBottomBorderWidth;
michael@0 400 }
michael@0 401
michael@0 402 inline void nsTableRowFrame::SetBottomBCBorderWidth(BCPixelSize aWidth)
michael@0 403 {
michael@0 404 mBottomBorderWidth = aWidth;
michael@0 405 }
michael@0 406
michael@0 407 inline nsMargin* nsTableRowFrame::GetBCBorderWidth(nsMargin& aBorder)
michael@0 408 {
michael@0 409 aBorder.left = aBorder.right = 0;
michael@0 410
michael@0 411 aBorder.top = nsPresContext::CSSPixelsToAppUnits(mTopBorderWidth);
michael@0 412 aBorder.bottom = nsPresContext::CSSPixelsToAppUnits(mBottomBorderWidth);
michael@0 413
michael@0 414 return &aBorder;
michael@0 415 }
michael@0 416
michael@0 417 inline void
michael@0 418 nsTableRowFrame::GetContinuousBCBorderWidth(nsMargin& aBorder)
michael@0 419 {
michael@0 420 int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
michael@0 421 aBorder.right = BC_BORDER_LEFT_HALF_COORD(aPixelsToTwips,
michael@0 422 mLeftContBorderWidth);
michael@0 423 aBorder.top = BC_BORDER_BOTTOM_HALF_COORD(aPixelsToTwips,
michael@0 424 mTopContBorderWidth);
michael@0 425 aBorder.left = BC_BORDER_RIGHT_HALF_COORD(aPixelsToTwips,
michael@0 426 mRightContBorderWidth);
michael@0 427 }
michael@0 428
michael@0 429 inline nscoord nsTableRowFrame::GetOuterTopContBCBorderWidth()
michael@0 430 {
michael@0 431 int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
michael@0 432 return BC_BORDER_TOP_HALF_COORD(aPixelsToTwips, mTopContBorderWidth);
michael@0 433 }
michael@0 434
michael@0 435 #endif

mercurial