2004-03-09 09:48:35 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
#ifndef nsTablePainter_h__
|
|
|
|
#define nsTablePainter_h__
|
|
|
|
|
2015-02-06 07:45:56 +03:00
|
|
|
#include "imgIContainer.h"
|
|
|
|
|
2005-04-07 22:04:38 +04:00
|
|
|
#include "celldata.h"
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
// 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-06 07:00:56 +04:00
|
|
|
class nsIFrame;
|
2004-03-09 09:48:35 +03:00
|
|
|
class nsTableFrame;
|
|
|
|
class nsTableRowGroupFrame;
|
|
|
|
class nsTableRowFrame;
|
|
|
|
class nsTableCellFrame;
|
|
|
|
|
|
|
|
class TableBackgroundPainter
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Helper class for painting table backgrounds
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-02-06 07:45:56 +03:00
|
|
|
typedef mozilla::image::DrawResult DrawResult;
|
|
|
|
|
2004-03-09 09:48:35 +03:00
|
|
|
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-21 04:18:30 +03: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-13 02:44:18 +04:00
|
|
|
* @param aBGPaintFlags - Flags of the nsCSSRendering::PAINTBG_* variety
|
2004-03-09 09:48:35 +03:00
|
|
|
*/
|
|
|
|
TableBackgroundPainter(nsTableFrame* aTableFrame,
|
|
|
|
Origin aOrigin,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPresContext* aPresContext,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext& aRenderingContext,
|
2008-03-21 04:18:30 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2009-09-13 02:44:18 +04:00
|
|
|
const nsPoint& aPt,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aBGPaintFlags);
|
2004-03-09 09:48:35 +03: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.
|
|
|
|
*/
|
|
|
|
|
2004-04-18 22:17:00 +04:00
|
|
|
/* ~*~ Using nsTablePainter Background Painting ~*~
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
A call to PaintTable will normally paint all of the table's
|
2009-07-22 04:44:52 +04: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
|
2004-03-09 09:48:35 +03:00
|
|
|
method (e.g. painter.PaintRow in nsTableRow::Paint)
|
|
|
|
*/
|
|
|
|
|
2009-07-22 04:44:52 +04:00
|
|
|
/** Paint background for the table frame (if requested) and its children
|
|
|
|
* down through cells.
|
2004-03-09 09:48:35 +03: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
|
2004-04-18 22:17:00 +04:00
|
|
|
* @param aDeflate - deflation needed to bring table's mRect
|
|
|
|
* to the outer grid lines in border-collapse
|
2009-07-22 04:44:52 +04:00
|
|
|
* @param aPaintTableBackground - if true, the table background
|
|
|
|
* is included, otherwise it isn't
|
2015-02-06 07:45:56 +03:00
|
|
|
* @returns DrawResult::SUCCESS if all painting was successful. If some
|
|
|
|
* painting failed or an improved result could be achieved by sync
|
|
|
|
* decoding images, returns another value.
|
2004-03-09 09:48:35 +03:00
|
|
|
*/
|
2015-02-06 07:45:56 +03:00
|
|
|
DrawResult PaintTable(nsTableFrame* aTableFrame, const nsMargin& aDeflate,
|
|
|
|
bool aPaintTableBackground);
|
2004-03-09 09:48:35 +03: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
|
2015-02-06 07:45:56 +03:00
|
|
|
* @returns DrawResult::SUCCESS if all painting was successful. If some
|
|
|
|
* painting failed or an improved result could be achieved by sync
|
|
|
|
* decoding images, returns another value.
|
2004-03-09 09:48:35 +03:00
|
|
|
*/
|
2015-02-06 07:45:56 +03:00
|
|
|
DrawResult PaintRowGroup(nsTableRowGroupFrame* aFrame);
|
2004-03-09 09:48:35 +03: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
|
2015-02-06 07:45:56 +03:00
|
|
|
* @returns DrawResult::SUCCESS if all painting was successful. If some
|
|
|
|
* painting failed or an improved result could be achieved by sync
|
|
|
|
* decoding images, returns another value.
|
2004-03-09 09:48:35 +03:00
|
|
|
*/
|
2015-02-06 07:45:56 +03:00
|
|
|
DrawResult PaintRow(nsTableRowFrame* aFrame);
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
private:
|
2015-02-08 09:35:58 +03:00
|
|
|
struct TableBackgroundData;
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
*/
|
2015-02-06 07:45:56 +03:00
|
|
|
DrawResult PaintTableFrame(nsTableFrame* aTableFrame,
|
|
|
|
nsTableRowGroupFrame* aFirstRowGroup,
|
|
|
|
nsTableRowGroupFrame* aLastRowGroup,
|
|
|
|
const nsMargin& aDeflate);
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
/* aPassThrough params indicate whether to paint the element or to just
|
2015-02-08 09:35:58 +03:00
|
|
|
* pass through and paint underlying layers only.
|
|
|
|
* aRowGroupBGData is not a const reference because the function modifies
|
|
|
|
* its copy. Same for aRowBGData in PaintRow.
|
2004-03-09 09:48:35 +03:00
|
|
|
* See Public versions for function descriptions
|
|
|
|
*/
|
2015-02-06 07:45:56 +03:00
|
|
|
DrawResult PaintRowGroup(nsTableRowGroupFrame* aFrame,
|
|
|
|
TableBackgroundData aRowGroupBGData,
|
|
|
|
bool aPassThrough);
|
2015-02-08 09:35:58 +03:00
|
|
|
|
2015-02-06 07:45:56 +03:00
|
|
|
DrawResult PaintRow(nsTableRowFrame* aFrame,
|
|
|
|
const TableBackgroundData& aRowGroupBGData,
|
|
|
|
TableBackgroundData aRowBGData,
|
|
|
|
bool aPassThrough);
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
/** Paint table background layers for this cell space
|
|
|
|
* Also paints cell's own background in border-collapse mode
|
2014-08-20 05:24:58 +04:00
|
|
|
* @param aCell - the cell
|
2015-02-08 09:35:58 +03:00
|
|
|
* @param aRowGroupBGData - background drawing info for the row group
|
|
|
|
* @param aRowBGData - background drawing info for the row
|
2014-08-20 05:24:58 +04:00
|
|
|
* @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
|
2004-03-09 09:48:35 +03:00
|
|
|
*/
|
2015-02-06 07:45:56 +03:00
|
|
|
DrawResult PaintCell(nsTableCellFrame* aCell,
|
|
|
|
const TableBackgroundData& aRowGroupBGData,
|
|
|
|
const TableBackgroundData& aRowBGData,
|
|
|
|
nsRect& aCellBGRect,
|
|
|
|
nsRect& aRowBGRect,
|
|
|
|
nsRect& aRowGroupBGRect,
|
|
|
|
nsRect& aColBGRect,
|
|
|
|
bool aPassSelf);
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2014-08-20 05:24:58 +04:00
|
|
|
/** Compute table background layer positions for this cell space
|
|
|
|
* @param aCell - the cell
|
2015-02-08 09:35:58 +03:00
|
|
|
* @param aRowGroupBGData - background drawing info for the row group
|
|
|
|
* @param aRowBGData - background drawing info for the row
|
2014-08-20 05:24:58 +04:00
|
|
|
* @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,
|
2015-02-08 09:35:58 +03:00
|
|
|
const TableBackgroundData& aRowGroupBGData,
|
|
|
|
const TableBackgroundData& aRowBGData,
|
2014-08-20 05:24:58 +04:00
|
|
|
nsRect& aCellBGRect,
|
|
|
|
nsRect& aRowBGRect,
|
|
|
|
nsRect& aRowGroupBGRect,
|
|
|
|
nsRect& aColBGRect);
|
|
|
|
|
2004-03-09 09:48:35 +03: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 {
|
2015-02-08 09:35:58 +03:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Construct an empty TableBackgroundData instance, which is invisible.
|
2004-03-09 09:48:35 +03:00
|
|
|
*/
|
2015-02-08 09:35:58 +03:00
|
|
|
TableBackgroundData();
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2015-02-08 09:35:58 +03:00
|
|
|
/**
|
|
|
|
* Construct a TableBackgroundData instance for a frame. Visibility will
|
|
|
|
* be derived from the frame and can be overridden using MakeInvisible().
|
|
|
|
*/
|
|
|
|
explicit TableBackgroundData(nsIFrame* aFrame);
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2015-02-08 09:35:58 +03:00
|
|
|
/** Destructor */
|
|
|
|
~TableBackgroundData() {}
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2015-02-08 09:35:58 +03:00
|
|
|
/** Data is valid & frame is visible */
|
|
|
|
bool IsVisible() const { return mVisible; }
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2015-02-08 09:35:58 +03:00
|
|
|
/** Override visibility of the frame, force it to be invisible */
|
|
|
|
void MakeInvisible() { mVisible = false; }
|
2004-12-01 06:51:35 +03:00
|
|
|
|
2004-03-09 09:48:35 +03:00
|
|
|
/** True if need to set border-collapse border; must call SetFull beforehand */
|
2015-02-08 09:35:58 +03:00
|
|
|
bool ShouldSetBCBorder() const;
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
/** Set border-collapse border with aBorderWidth as widths */
|
2015-02-08 09:35:58 +03:00
|
|
|
void SetBCBorder(const nsMargin& aBorderWidth);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aZeroBorder An nsStyleBorder instance that has been initialized
|
|
|
|
* for the right nsPresContext, with all border widths
|
|
|
|
* set to zero and border styles set to solid.
|
|
|
|
* @return The nsStyleBorder that should be used for rendering
|
|
|
|
* this background.
|
|
|
|
*/
|
|
|
|
nsStyleBorder StyleBorder(const nsStyleBorder& aZeroBorder) const;
|
|
|
|
|
|
|
|
nsIFrame* const mFrame;
|
|
|
|
|
|
|
|
/** mRect is the rect of mFrame in the current coordinate system */
|
|
|
|
nsRect mRect;
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2015-02-08 09:35:58 +03:00
|
|
|
private:
|
|
|
|
nsMargin mSynthBorderWidths;
|
|
|
|
bool mVisible;
|
|
|
|
bool mUsesSynthBorder;
|
2004-03-09 09:48:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ColData {
|
2015-02-08 09:35:58 +03:00
|
|
|
ColData(nsIFrame* aFrame, TableBackgroundData& aColGroupBGData);
|
|
|
|
TableBackgroundData mCol;
|
|
|
|
TableBackgroundData& mColGroup; // reference to col's parent colgroup's data, owned by TablePainter in mColGroups
|
2004-03-09 09:48:35 +03:00
|
|
|
};
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* mPresContext;
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext& mRenderingContext;
|
2008-03-21 04:18:30 +03:00
|
|
|
nsPoint mRenderPt;
|
2004-03-09 09:48:35 +03:00
|
|
|
nsRect mDirtyRect;
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsCompatibility mCompatMode;
|
|
|
|
#endif
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsBorderCollapse;
|
2004-03-09 09:48:35 +03:00
|
|
|
Origin mOrigin; //user's table frame type
|
|
|
|
|
2015-02-08 09:35:58 +03:00
|
|
|
nsTArray<TableBackgroundData> mColGroups;
|
|
|
|
nsTArray<ColData> mCols;
|
|
|
|
size_t mNumCols;
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
nsStyleBorder mZeroBorder; //cached zero-width border
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mBGPaintFlags;
|
2004-03-09 09:48:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|