mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Adding interface for editor access to table layout data
This commit is contained in:
parent
a790b9d1e2
commit
2781d6d9a2
@ -26,6 +26,7 @@ MODULE = raptor
|
||||
|
||||
EXPORTS = \
|
||||
nsITableCellLayout.h \
|
||||
nsITableLayout.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
@ -21,8 +21,9 @@ IGNORE_MANIFEST=1
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
EXPORTS = \
|
||||
nsITableCellLayout.h \
|
||||
EXPORTS = \
|
||||
nsITableCellLayout.h \
|
||||
nsITableLayout.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
@ -1008,10 +1008,11 @@ NS_METHOD nsTableCellFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsTableCellFrame, nsHTMLContainerFrame, nsITableCellLayout)
|
||||
|
||||
/* ----- global methods ----- */
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsTableCellFrame, nsHTMLContainerFrame, nsITableCellLayout)
|
||||
|
||||
nsresult
|
||||
NS_NewTableCellFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIStyleSet.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gsDebug = PR_FALSE;
|
||||
@ -271,7 +272,6 @@ nsTableFrame::GetFrameType(nsIAtom** aType) const
|
||||
|
||||
/* --------------------- nsTableFrame -------------------- */
|
||||
|
||||
|
||||
nsTableFrame::nsTableFrame()
|
||||
: nsHTMLContainerFrame(),
|
||||
mColumnWidthsValid(PR_FALSE),
|
||||
@ -292,6 +292,8 @@ nsTableFrame::nsTableFrame()
|
||||
mBorderEdges.mOutsideEdge=PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsTableFrame, nsHTMLContainerFrame, nsITableLayout)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableFrame::Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
@ -5345,6 +5347,53 @@ void nsTableFrame::GetCellInfoAt(PRInt32 aRowX,
|
||||
cellMap->GetCellInfoAt(aRowX, aColX, aCellFrame, aOriginates, aColSpan);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell, //out params
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan,
|
||||
PRBool& aIsSelected)
|
||||
{
|
||||
nsresult result;
|
||||
nsCellMap* cellMap = GetCellMap();
|
||||
// Initialize out params
|
||||
aCell = nsnull;
|
||||
aStartRowIndex = 0;
|
||||
aStartColIndex = 0;
|
||||
aRowSpan = 0;
|
||||
aColSpan = 0;
|
||||
aIsSelected = PR_FALSE;
|
||||
|
||||
if (!cellMap) { return NS_ERROR_NOT_INITIALIZED;}
|
||||
nsTableCellFrame *cellFrame = cellMap->GetCellFrameAt(aRowIndex, aColIndex);
|
||||
// This error value if a cell isn't found will pass the NS_SUCCEEDED() test
|
||||
// It's OK to attempt to get a cell out of bounds,
|
||||
// as long as caller test i aCell is not null
|
||||
// Thus we can get iterate to get all cells in a row or col
|
||||
// and stop when aCell is returned null.
|
||||
if (!cellFrame) { return NS_TABLELAYOUT_CELL_NOT_FOUND;} // row or col index out of bounds
|
||||
|
||||
result = cellFrame->GetRowIndex(aStartRowIndex);
|
||||
if (NS_FAILED(result)) return result;
|
||||
result = cellFrame->GetColIndex(aStartColIndex);
|
||||
if (NS_FAILED(result)) return result;
|
||||
aRowSpan = cellFrame->GetRowSpan();
|
||||
aColSpan = cellFrame->GetColSpan();
|
||||
result = cellFrame->GetSelected(&aIsSelected);
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// do this last, because it addrefs,
|
||||
// and we don't want the caller leaking it on error
|
||||
nsCOMPtr<nsIContent>content;
|
||||
result = cellFrame->GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(result) && content)
|
||||
{
|
||||
content->QueryInterface(nsIDOMElement::GetIID(), (void**)(&aCell));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32 nsTableFrame::GetNumCellsOriginatingIn(PRInt32 aColIndex)
|
||||
{
|
||||
nsCellMap* cellMap = GetCellMap();
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIFrameReflow.h" // for nsReflowReason enum
|
||||
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
class nsCellMap;
|
||||
class nsTableCellFrame;
|
||||
@ -62,10 +62,13 @@ struct nsStyleSpacing;
|
||||
*
|
||||
* TODO: make methods virtual so nsTableFrame can be used as a base class in the future.
|
||||
*/
|
||||
class nsTableFrame : public nsHTMLContainerFrame
|
||||
class nsTableFrame : public nsHTMLContainerFrame, public nsITableLayout
|
||||
{
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
/** nsTableOuterFrame has intimate knowledge of the inner table frame */
|
||||
friend class nsTableOuterFrame;
|
||||
|
||||
@ -802,6 +805,13 @@ public: /* ----- Cell Map public methods ----- */
|
||||
/** returns PR_TRUE if table layout requires a preliminary pass over the content */
|
||||
PRBool RequiresPass1Layout();
|
||||
|
||||
/*---------------- nsITableLayout methods ------------------------*/
|
||||
NS_IMETHOD GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell, //out params
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan,
|
||||
PRBool& aIsSelected);
|
||||
|
||||
public:
|
||||
static nsIAtom* gColGroupAtom;
|
||||
void Dump(PRBool aDumpCols, PRBool aDumpCellMap);
|
||||
|
@ -174,7 +174,7 @@ struct OuterTableReflowState {
|
||||
|
||||
/* ----------- nsTableOuterFrame ---------- */
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame, nsITableLayout)
|
||||
|
||||
NS_IMETHODIMP nsTableOuterFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
||||
nsIAtom* aListName,
|
||||
@ -1227,6 +1227,25 @@ nsTableOuterFrame::GetFrameType(nsIAtom** aType) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell, //out params
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan,
|
||||
PRBool& aIsSelected)
|
||||
{
|
||||
if (!mInnerTableFrame) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
nsITableLayout *inner;
|
||||
nsresult result = mInnerTableFrame->QueryInterface(nsITableLayout::GetIID(), (void **)&inner);
|
||||
if (NS_SUCCEEDED(result) && inner)
|
||||
{
|
||||
return (inner->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
||||
aStartRowIndex, aStartColIndex,
|
||||
aRowSpan, aColSpan, aIsSelected));
|
||||
}
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
/* ----- global methods ----- */
|
||||
|
||||
nsresult
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsHTMLContainerFrame.h"
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
struct OuterTableReflowState;
|
||||
struct nsStyleText;
|
||||
@ -38,10 +39,13 @@ struct nsStyleText;
|
||||
* are always mapped
|
||||
*
|
||||
*/
|
||||
class nsTableOuterFrame : public nsHTMLContainerFrame
|
||||
class nsTableOuterFrame : public nsHTMLContainerFrame, public nsITableLayout
|
||||
{
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
/** instantiate a new instance of nsTableOuterFrame.
|
||||
* @param aResult the new object is returned in this out-param
|
||||
*
|
||||
@ -88,6 +92,14 @@ public:
|
||||
*/
|
||||
nscoord GetMinCaptionWidth();
|
||||
|
||||
/*---------------- nsITableLayout methods ------------------------*/
|
||||
NS_IMETHOD GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell, //out params
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan,
|
||||
PRBool& aIsSelected);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
@ -1008,10 +1008,11 @@ NS_METHOD nsTableCellFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsTableCellFrame, nsHTMLContainerFrame, nsITableCellLayout)
|
||||
|
||||
/* ----- global methods ----- */
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsTableCellFrame, nsHTMLContainerFrame, nsITableCellLayout)
|
||||
|
||||
nsresult
|
||||
NS_NewTableCellFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIStyleSet.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gsDebug = PR_FALSE;
|
||||
@ -271,7 +272,6 @@ nsTableFrame::GetFrameType(nsIAtom** aType) const
|
||||
|
||||
/* --------------------- nsTableFrame -------------------- */
|
||||
|
||||
|
||||
nsTableFrame::nsTableFrame()
|
||||
: nsHTMLContainerFrame(),
|
||||
mColumnWidthsValid(PR_FALSE),
|
||||
@ -292,6 +292,8 @@ nsTableFrame::nsTableFrame()
|
||||
mBorderEdges.mOutsideEdge=PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsTableFrame, nsHTMLContainerFrame, nsITableLayout)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableFrame::Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
@ -5345,6 +5347,53 @@ void nsTableFrame::GetCellInfoAt(PRInt32 aRowX,
|
||||
cellMap->GetCellInfoAt(aRowX, aColX, aCellFrame, aOriginates, aColSpan);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell, //out params
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan,
|
||||
PRBool& aIsSelected)
|
||||
{
|
||||
nsresult result;
|
||||
nsCellMap* cellMap = GetCellMap();
|
||||
// Initialize out params
|
||||
aCell = nsnull;
|
||||
aStartRowIndex = 0;
|
||||
aStartColIndex = 0;
|
||||
aRowSpan = 0;
|
||||
aColSpan = 0;
|
||||
aIsSelected = PR_FALSE;
|
||||
|
||||
if (!cellMap) { return NS_ERROR_NOT_INITIALIZED;}
|
||||
nsTableCellFrame *cellFrame = cellMap->GetCellFrameAt(aRowIndex, aColIndex);
|
||||
// This error value if a cell isn't found will pass the NS_SUCCEEDED() test
|
||||
// It's OK to attempt to get a cell out of bounds,
|
||||
// as long as caller test i aCell is not null
|
||||
// Thus we can get iterate to get all cells in a row or col
|
||||
// and stop when aCell is returned null.
|
||||
if (!cellFrame) { return NS_TABLELAYOUT_CELL_NOT_FOUND;} // row or col index out of bounds
|
||||
|
||||
result = cellFrame->GetRowIndex(aStartRowIndex);
|
||||
if (NS_FAILED(result)) return result;
|
||||
result = cellFrame->GetColIndex(aStartColIndex);
|
||||
if (NS_FAILED(result)) return result;
|
||||
aRowSpan = cellFrame->GetRowSpan();
|
||||
aColSpan = cellFrame->GetColSpan();
|
||||
result = cellFrame->GetSelected(&aIsSelected);
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// do this last, because it addrefs,
|
||||
// and we don't want the caller leaking it on error
|
||||
nsCOMPtr<nsIContent>content;
|
||||
result = cellFrame->GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(result) && content)
|
||||
{
|
||||
content->QueryInterface(nsIDOMElement::GetIID(), (void**)(&aCell));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32 nsTableFrame::GetNumCellsOriginatingIn(PRInt32 aColIndex)
|
||||
{
|
||||
nsCellMap* cellMap = GetCellMap();
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIFrameReflow.h" // for nsReflowReason enum
|
||||
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
class nsCellMap;
|
||||
class nsTableCellFrame;
|
||||
@ -62,10 +62,13 @@ struct nsStyleSpacing;
|
||||
*
|
||||
* TODO: make methods virtual so nsTableFrame can be used as a base class in the future.
|
||||
*/
|
||||
class nsTableFrame : public nsHTMLContainerFrame
|
||||
class nsTableFrame : public nsHTMLContainerFrame, public nsITableLayout
|
||||
{
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
/** nsTableOuterFrame has intimate knowledge of the inner table frame */
|
||||
friend class nsTableOuterFrame;
|
||||
|
||||
@ -802,6 +805,13 @@ public: /* ----- Cell Map public methods ----- */
|
||||
/** returns PR_TRUE if table layout requires a preliminary pass over the content */
|
||||
PRBool RequiresPass1Layout();
|
||||
|
||||
/*---------------- nsITableLayout methods ------------------------*/
|
||||
NS_IMETHOD GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell, //out params
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan,
|
||||
PRBool& aIsSelected);
|
||||
|
||||
public:
|
||||
static nsIAtom* gColGroupAtom;
|
||||
void Dump(PRBool aDumpCols, PRBool aDumpCellMap);
|
||||
|
@ -174,7 +174,7 @@ struct OuterTableReflowState {
|
||||
|
||||
/* ----------- nsTableOuterFrame ---------- */
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame, nsITableLayout)
|
||||
|
||||
NS_IMETHODIMP nsTableOuterFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
||||
nsIAtom* aListName,
|
||||
@ -1227,6 +1227,25 @@ nsTableOuterFrame::GetFrameType(nsIAtom** aType) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell, //out params
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan,
|
||||
PRBool& aIsSelected)
|
||||
{
|
||||
if (!mInnerTableFrame) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
nsITableLayout *inner;
|
||||
nsresult result = mInnerTableFrame->QueryInterface(nsITableLayout::GetIID(), (void **)&inner);
|
||||
if (NS_SUCCEEDED(result) && inner)
|
||||
{
|
||||
return (inner->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
||||
aStartRowIndex, aStartColIndex,
|
||||
aRowSpan, aColSpan, aIsSelected));
|
||||
}
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
/* ----- global methods ----- */
|
||||
|
||||
nsresult
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsHTMLContainerFrame.h"
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
struct OuterTableReflowState;
|
||||
struct nsStyleText;
|
||||
@ -38,10 +39,13 @@ struct nsStyleText;
|
||||
* are always mapped
|
||||
*
|
||||
*/
|
||||
class nsTableOuterFrame : public nsHTMLContainerFrame
|
||||
class nsTableOuterFrame : public nsHTMLContainerFrame, public nsITableLayout
|
||||
{
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
/** instantiate a new instance of nsTableOuterFrame.
|
||||
* @param aResult the new object is returned in this out-param
|
||||
*
|
||||
@ -88,6 +92,14 @@ public:
|
||||
*/
|
||||
nscoord GetMinCaptionWidth();
|
||||
|
||||
/*---------------- nsITableLayout methods ------------------------*/
|
||||
NS_IMETHOD GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell, //out params
|
||||
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
||||
PRInt32& aRowSpan, PRInt32& aColSpan,
|
||||
PRBool& aIsSelected);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user