2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsTablePainter_h__
|
|
|
|
#define nsTablePainter_h__
|
|
|
|
|
|
|
|
#include "celldata.h"
|
|
|
|
|
|
|
|
// flags for Paint, PaintChild, PaintChildren are currently only used by tables.
|
|
|
|
//Table-based paint call; not a direct call as with views
|
|
|
|
#define NS_PAINT_FLAG_TABLE_BG_PAINT 0x00000001
|
|
|
|
//Cells should paint their backgrounds only, no children
|
|
|
|
#define NS_PAINT_FLAG_TABLE_CELL_BG_PASS 0x00000002
|
|
|
|
|
2012-08-05 20:00:56 -07:00
|
|
|
class nsIFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsTableFrame;
|
|
|
|
class nsTableRowGroupFrame;
|
|
|
|
class nsTableRowFrame;
|
|
|
|
class nsTableCellFrame;
|
|
|
|
|
|
|
|
class TableBackgroundPainter
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Helper class for painting table backgrounds
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum Origin { eOrigin_Table, eOrigin_TableRowGroup, eOrigin_TableRow };
|
|
|
|
|
|
|
|
/** Public constructor
|
|
|
|
* @param aTableFrame - the table's table frame
|
|
|
|
* @param aOrigin - what type of table frame is creating this instance
|
|
|
|
* @param aPresContext - the presentation context
|
|
|
|
* @param aRenderingContext - the rendering context
|
2008-03-20 18:18:30 -07:00
|
|
|
* @param aDirtyRect - the area that needs to be painted,
|
|
|
|
* relative to aRenderingContext
|
|
|
|
* @param aPt - offset of the table frame relative to
|
|
|
|
* aRenderingContext
|
2009-09-12 15:44:18 -07:00
|
|
|
* @param aBGPaintFlags - Flags of the nsCSSRendering::PAINTBG_* variety
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
TableBackgroundPainter(nsTableFrame* aTableFrame,
|
|
|
|
Origin aOrigin,
|
|
|
|
nsPresContext* aPresContext,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext& aRenderingContext,
|
2008-03-20 18:18:30 -07:00
|
|
|
const nsRect& aDirtyRect,
|
2009-09-12 15:44:18 -07:00
|
|
|
const nsPoint& aPt,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aBGPaintFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** Destructor */
|
|
|
|
~TableBackgroundPainter();
|
|
|
|
|
|
|
|
/* ~*~ The Border Collapse Painting Issue ~*~
|
|
|
|
|
|
|
|
In border-collapse, the *table* paints the cells' borders,
|
|
|
|
so we need to make sure the backgrounds get painted first
|
|
|
|
(underneath) by doing a cell-background-only painting pass.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ~*~ Using nsTablePainter Background Painting ~*~
|
|
|
|
|
|
|
|
A call to PaintTable will normally paint all of the table's
|
2009-07-21 17:44:52 -07:00
|
|
|
elements (except for the table background, if aPaintTableBackground
|
|
|
|
is false).
|
|
|
|
Elements with views however, will be skipped and must create their
|
|
|
|
own painter to call the appropriate paint function in their ::Paint
|
2007-03-22 10:30:00 -07:00
|
|
|
method (e.g. painter.PaintRow in nsTableRow::Paint)
|
|
|
|
*/
|
|
|
|
|
2009-07-21 17:44:52 -07:00
|
|
|
/** Paint background for the table frame (if requested) and its children
|
|
|
|
* down through cells.
|
2007-03-22 10:30:00 -07:00
|
|
|
* (Cells themselves will only be painted in border collapse)
|
|
|
|
* Table must do a flagged TABLE_BG_PAINT ::Paint call on its
|
|
|
|
* children afterwards
|
|
|
|
* @param aTableFrame - the table frame
|
|
|
|
* @param aDeflate - deflation needed to bring table's mRect
|
|
|
|
* to the outer grid lines in border-collapse
|
2009-07-21 17:44:52 -07:00
|
|
|
* @param aPaintTableBackground - if true, the table background
|
|
|
|
* is included, otherwise it isn't
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2009-07-21 17:44:52 -07:00
|
|
|
nsresult PaintTable(nsTableFrame* aTableFrame, const nsMargin& aDeflate,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aPaintTableBackground);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** Paint background for the row group and its children down through cells
|
|
|
|
* (Cells themselves will only be painted in border collapse)
|
|
|
|
* Standards mode only
|
|
|
|
* Table Row Group must do a flagged TABLE_BG_PAINT ::Paint call on its
|
|
|
|
* children afterwards
|
|
|
|
* @param aFrame - the table row group frame
|
|
|
|
*/
|
|
|
|
nsresult PaintRowGroup(nsTableRowGroupFrame* aFrame)
|
2011-10-17 07:59:28 -07:00
|
|
|
{ return PaintRowGroup(aFrame, false); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** Paint background for the row and its children down through cells
|
|
|
|
* (Cells themselves will only be painted in border collapse)
|
|
|
|
* Standards mode only
|
|
|
|
* Table Row must do a flagged TABLE_BG_PAINT ::Paint call on its
|
|
|
|
* children afterwards
|
|
|
|
* @param aFrame - the table row frame
|
|
|
|
*/
|
|
|
|
nsresult PaintRow(nsTableRowFrame* aFrame)
|
2011-10-17 07:59:28 -07:00
|
|
|
{ return PaintRow(aFrame, false); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/** Paint table frame's background
|
|
|
|
* @param aTableFrame - the table frame
|
|
|
|
* @param aFirstRowGroup - the first (in layout order) row group
|
|
|
|
* may be null
|
|
|
|
* @param aLastRowGroup - the last (in layout order) row group
|
|
|
|
* may be null
|
|
|
|
* @param aDeflate - adjustment to frame's rect (used for quirks BC)
|
|
|
|
* may be null
|
|
|
|
*/
|
|
|
|
nsresult PaintTableFrame(nsTableFrame* aTableFrame,
|
|
|
|
nsTableRowGroupFrame* aFirstRowGroup,
|
|
|
|
nsTableRowGroupFrame* aLastRowGroup,
|
2009-07-21 17:44:52 -07:00
|
|
|
const nsMargin& aDeflate);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* aPassThrough params indicate whether to paint the element or to just
|
|
|
|
* pass through and paint underlying layers only
|
|
|
|
* See Public versions for function descriptions
|
|
|
|
*/
|
|
|
|
nsresult PaintRowGroup(nsTableRowGroupFrame* aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aPassThrough);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult PaintRow(nsTableRowFrame* aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aPassThrough);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** Paint table background layers for this cell space
|
|
|
|
* Also paints cell's own background in border-collapse mode
|
2014-08-19 18:24:58 -07:00
|
|
|
* @param aCell - the cell
|
|
|
|
* @param aCellBGRect - background rect for the cell
|
|
|
|
* @param aRowBGRect - background rect for the row
|
|
|
|
* @param aRowGroupBGRect - background rect for the row group
|
|
|
|
* @param aColBGRect - background rect for the column and column group
|
|
|
|
* @param aPassSelf - pass this cell; i.e. paint only underlying layers
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2014-08-19 18:24:58 -07:00
|
|
|
nsresult PaintCell(nsTableCellFrame* aCell,
|
|
|
|
nsRect& aCellBGRect,
|
|
|
|
nsRect& aRowBGRect,
|
|
|
|
nsRect& aRowGroupBGRect,
|
|
|
|
nsRect& aColBGRect,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aPassSelf);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-08-19 18:24:58 -07:00
|
|
|
/** Compute table background layer positions for this cell space
|
|
|
|
* @param aCell - the cell
|
|
|
|
* @param aCellBGRectOut - outparam: background rect for the cell
|
|
|
|
* @param aRowBGRectOut - outparam: background rect for the row
|
|
|
|
* @param aRowGroupBGRectOut - outparam: background rect for the row group
|
|
|
|
* @param aColBGRectOut - outparam: background rect for the column
|
|
|
|
and column group
|
|
|
|
*/
|
|
|
|
void ComputeCellBackgrounds(nsTableCellFrame* aCell,
|
|
|
|
nsRect& aCellBGRect,
|
|
|
|
nsRect& aRowBGRect,
|
|
|
|
nsRect& aRowGroupBGRect,
|
|
|
|
nsRect& aColBGRect);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/** Translate mRenderingContext, mDirtyRect, and mCols' column and
|
|
|
|
* colgroup coords
|
|
|
|
* @param aDX - origin's x-coord change
|
|
|
|
* @param aDY - origin's y-coord change
|
|
|
|
*/
|
|
|
|
void TranslateContext(nscoord aDX,
|
|
|
|
nscoord aDY);
|
|
|
|
|
|
|
|
struct TableBackgroundData;
|
|
|
|
friend struct TableBackgroundData;
|
|
|
|
struct TableBackgroundData {
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
/** mRect is the rect of mFrame in the current coordinate system */
|
|
|
|
nsRect mRect;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mVisible;
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsStyleBorder* mBorder;
|
|
|
|
|
|
|
|
/** Data is valid & frame is visible */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsVisible() const { return mVisible; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
TableBackgroundData();
|
|
|
|
/** Destructor */
|
|
|
|
~TableBackgroundData();
|
|
|
|
/** Destroys synthesized data. MUST be called before destructor
|
|
|
|
* @param aPresContext - the pres context
|
|
|
|
*/
|
|
|
|
void Destroy(nsPresContext* aPresContext);
|
|
|
|
|
|
|
|
|
|
|
|
/** Clear background data */
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
/** Calculate and set all data values to represent aFrame */
|
|
|
|
void SetFull(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/** Set frame data (mFrame, mRect) but leave style data empty */
|
|
|
|
void SetFrame(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/** Calculate the style data for mFrame */
|
|
|
|
void SetData();
|
|
|
|
|
|
|
|
/** True if need to set border-collapse border; must call SetFull beforehand */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ShouldSetBCBorder();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** Set border-collapse border with aBorderWidth as widths */
|
|
|
|
nsresult SetBCBorder(nsMargin& aBorderWidth,
|
|
|
|
TableBackgroundPainter* aPainter);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsStyleBorder* mSynthBorder;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ColData;
|
|
|
|
friend struct ColData;
|
|
|
|
struct ColData {
|
|
|
|
TableBackgroundData mCol;
|
|
|
|
TableBackgroundData* mColGroup; //link to col's parent colgroup's data (owned by painter)
|
|
|
|
ColData() {
|
2012-07-30 07:20:58 -07:00
|
|
|
mColGroup = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
nsPresContext* mPresContext;
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext& mRenderingContext;
|
2008-03-20 18:18:30 -07:00
|
|
|
nsPoint mRenderPt;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRect mDirtyRect;
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsCompatibility mCompatMode;
|
|
|
|
#endif
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsBorderCollapse;
|
2007-03-22 10:30:00 -07:00
|
|
|
Origin mOrigin; //user's table frame type
|
|
|
|
|
|
|
|
ColData* mCols; //array of columns' ColData
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mNumCols;
|
2007-03-22 10:30:00 -07:00
|
|
|
TableBackgroundData mRowGroup; //current row group
|
|
|
|
TableBackgroundData mRow; //current row
|
|
|
|
|
|
|
|
nsStyleBorder mZeroBorder; //cached zero-width border
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mBGPaintFlags;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|