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 nsTableOuterFrame_h__
|
|
|
|
#define nsTableOuterFrame_h__
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nscore.h"
|
2011-12-27 12:18:48 -08:00
|
|
|
#include "nsContainerFrame.h"
|
2012-08-08 06:05:17 -07:00
|
|
|
#include "nsCellMap.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBlockFrame.h"
|
2011-09-12 09:08:07 -07:00
|
|
|
#include "nsTableFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsTableCaptionFrame : public nsBlockFrame
|
|
|
|
{
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsISupports
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
friend nsIFrame* NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
2014-02-24 06:41:56 -08:00
|
|
|
nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-24 06:41:56 -08:00
|
|
|
virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE;
|
2011-09-12 09:08:07 -07:00
|
|
|
|
2007-07-05 08:39:29 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
|
2007-07-05 08:39:29 -07:00
|
|
|
#endif
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsTableCaptionFrame(nsStyleContext* aContext);
|
|
|
|
virtual ~nsTableCaptionFrame();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO
|
|
|
|
1. decide if we'll allow subclassing. If so, decide which methods really need to be virtual.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* main frame for an nsTable content object,
|
|
|
|
* the nsTableOuterFrame contains 0 or one caption frame, and a nsTableFrame
|
|
|
|
* pseudo-frame (referred to as the "inner frame').
|
|
|
|
*/
|
2012-08-08 06:05:17 -07:00
|
|
|
class nsTableOuterFrame : public nsContainerFrame
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-08 06:05:17 -07:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsTableOuterFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/** instantiate a new instance of nsTableRowFrame.
|
|
|
|
* @param aPresShell the pres shell for this frame
|
|
|
|
*
|
|
|
|
* @return the frame that was created
|
|
|
|
*/
|
|
|
|
friend nsIFrame* NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
|
|
|
// nsIFrame overrides - see there for a description
|
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult SetInitialChildList(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsFrameList& aChildList) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE;
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult AppendFrames(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult InsertFrames(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult RemoveFrame(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE {
|
2011-08-24 13:54:30 -07:00
|
|
|
return GetFirstPrincipalChild()->GetContentInsertionFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-11 17:52:55 -08:00
|
|
|
virtual nscoord GetBaseline() const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
2012-09-14 09:10:08 -07:00
|
|
|
nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** process a reflow command for the table.
|
|
|
|
* This involves reflowing the caption and the inner table.
|
|
|
|
* @see nsIFrame::Reflow */
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult Reflow(nsPresContext* aPresContext,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::tableOuterFrame
|
|
|
|
*/
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-08 06:05:17 -07:00
|
|
|
/**
|
|
|
|
* Return the content for the cell at the given row and column.
|
|
|
|
*/
|
|
|
|
nsIContent* GetCellAt(uint32_t aRowIdx, uint32_t aColIdx) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-08 06:05:17 -07:00
|
|
|
/**
|
|
|
|
* Return the number of rows in the table.
|
|
|
|
*/
|
|
|
|
int32_t GetRowCount() const
|
|
|
|
{
|
|
|
|
return InnerTableFrame()->GetRowCount();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-08 06:05:17 -07:00
|
|
|
/**
|
|
|
|
* Return the number of columns in the table.
|
|
|
|
*/
|
|
|
|
int32_t GetColCount() const
|
|
|
|
{
|
|
|
|
return InnerTableFrame()->GetColCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the index of the cell at the given row and column.
|
|
|
|
*/
|
|
|
|
int32_t GetIndexByRowAndColumn(int32_t aRowIdx, int32_t aColIdx) const
|
|
|
|
{
|
|
|
|
nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap();
|
|
|
|
if (!cellMap)
|
|
|
|
return -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-08 06:05:17 -07:00
|
|
|
return cellMap->GetIndexByRowAndColumn(aRowIdx, aColIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the row and column indices for the cell at the given index.
|
|
|
|
*/
|
|
|
|
void GetRowAndColumnByIndex(int32_t aCellIdx, int32_t* aRowIdx,
|
|
|
|
int32_t* aColIdx) const
|
|
|
|
{
|
|
|
|
*aRowIdx = *aColIdx = 0;
|
|
|
|
nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap();
|
|
|
|
if (cellMap) {
|
|
|
|
cellMap->GetRowAndColumnByIndex(aCellIdx, aRowIdx, aColIdx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* return the frame for the cell at the given row and column.
|
|
|
|
*/
|
|
|
|
nsTableCellFrame* GetCellFrameAt(uint32_t aRowIdx, uint32_t aColIdx) const
|
|
|
|
{
|
|
|
|
nsTableCellMap* map = InnerTableFrame()->GetCellMap();
|
|
|
|
if (!map) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return map->GetCellInfoAt(aRowIdx, aColIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the col span of the cell at the given row and column indices.
|
|
|
|
*/
|
|
|
|
uint32_t GetEffectiveColSpanAt(uint32_t aRowIdx, uint32_t aColIdx) const
|
|
|
|
{
|
|
|
|
nsTableCellMap* map = InnerTableFrame()->GetCellMap();
|
|
|
|
return map->GetEffectiveColSpan(aRowIdx, aColIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the effective row span of the cell at the given row and column.
|
|
|
|
*/
|
|
|
|
uint32_t GetEffectiveRowSpanAt(uint32_t aRowIdx, uint32_t aColIdx) const
|
|
|
|
{
|
|
|
|
nsTableCellMap* map = InnerTableFrame()->GetCellMap();
|
|
|
|
return map->GetEffectiveRowSpan(aRowIdx, aColIdx);
|
|
|
|
}
|
2008-02-06 23:03:26 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
nsTableOuterFrame(nsStyleContext* aContext);
|
|
|
|
virtual ~nsTableOuterFrame();
|
|
|
|
|
|
|
|
void InitChildReflowState(nsPresContext& aPresContext,
|
|
|
|
nsHTMLReflowState& aReflowState);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t GetCaptionSide(); // NS_STYLE_CAPTION_SIDE_* or NO_SIDE
|
2008-02-26 18:02:20 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasSideCaption() {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t captionSide = GetCaptionSide();
|
2008-02-26 18:02:20 -08:00
|
|
|
return captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t GetCaptionVerticalAlign();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetDesiredSize(uint8_t aCaptionSide,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
nscoord& aWidth,
|
|
|
|
nscoord& aHeight);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult GetCaptionOrigin(uint32_t aCaptionSide,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
nsMargin& aCaptionMargin,
|
|
|
|
nsPoint& aOrigin);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult GetInnerOrigin(uint32_t aCaptionSide,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
nsMargin& aInnerMargin,
|
|
|
|
nsPoint& aOrigin);
|
|
|
|
|
|
|
|
// reflow the child (caption or innertable frame)
|
2008-02-26 18:01:33 -08:00
|
|
|
void OuterBeginReflowChild(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
void* aChildRSSpace,
|
|
|
|
nscoord aAvailWidth);
|
|
|
|
|
|
|
|
nsresult OuterDoReflowChild(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aChildRS,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Set the reflow metrics
|
2012-08-22 08:56:38 -07:00
|
|
|
void UpdateReflowMetrics(uint8_t aCaptionSide,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLReflowMetrics& aMet,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin);
|
|
|
|
|
|
|
|
// Get the margin. aMarginNoAuto is aMargin, but with auto
|
|
|
|
// margins set to 0
|
2009-12-22 18:59:29 -08:00
|
|
|
void GetChildMargin(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
nscoord aAvailableWidth,
|
|
|
|
nsMargin& aMargin);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2013-03-15 11:36:30 -07:00
|
|
|
{
|
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
|
|
|
(~eCanContainOverflowContainers));
|
|
|
|
}
|
|
|
|
|
2012-02-15 01:28:21 -08:00
|
|
|
nsTableFrame* InnerTableFrame() const {
|
2011-09-12 09:08:07 -07:00
|
|
|
return static_cast<nsTableFrame*>(mFrames.FirstChild());
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsFrameList mCaptionFrames;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|