зеркало из https://github.com/mozilla/pjs.git
more separation between table content and frames
This commit is contained in:
Родитель
ae81da7686
Коммит
3a0505d67b
|
@ -512,14 +512,20 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext*
|
|||
nsStyleTable::nsStyleTable(void) { }
|
||||
|
||||
struct StyleTableImpl: public nsStyleTable {
|
||||
StyleTableImpl(void) { }
|
||||
StyleTableImpl(void);
|
||||
|
||||
void ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPresContext);
|
||||
};
|
||||
|
||||
StyleTableImpl::StyleTableImpl()
|
||||
{
|
||||
ResetFrom(nsnull, nsnull);
|
||||
}
|
||||
|
||||
void StyleTableImpl::ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPresContext)
|
||||
{
|
||||
// values not inherited
|
||||
mCols = NS_STYLE_TABLE_COLS_NONE;
|
||||
mFrame = NS_STYLE_TABLE_FRAME_NONE;
|
||||
mRules = NS_STYLE_TABLE_RULES_NONE;
|
||||
mCellPadding.Reset();
|
||||
|
|
|
@ -157,6 +157,7 @@ struct nsStyleTable: public nsStyleStruct {
|
|||
PRUint8 mRules; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_RULES_*
|
||||
nsStyleCoord mCellPadding; // [reset]
|
||||
nsStyleCoord mCellSpacing; // [reset]
|
||||
PRInt32 mCols; // an integer if set, or see nsStyleConsts.h NS_STYLE_TABLE_COLS_*
|
||||
|
||||
protected:
|
||||
nsStyleTable(void);
|
||||
|
|
|
@ -231,5 +231,7 @@
|
|||
#define NS_STYLE_TABLE_RULES_COLS 3
|
||||
#define NS_STYLE_TABLE_RULES_ALL 4
|
||||
|
||||
#define NS_STYLE_TABLE_COLS_NONE (-1)
|
||||
#define NS_STYLE_TABLE_COLS_ALL PRInt32(1 << 30)
|
||||
|
||||
#endif /* nsStyleConsts_h___ */
|
||||
|
|
|
@ -512,14 +512,20 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext*
|
|||
nsStyleTable::nsStyleTable(void) { }
|
||||
|
||||
struct StyleTableImpl: public nsStyleTable {
|
||||
StyleTableImpl(void) { }
|
||||
StyleTableImpl(void);
|
||||
|
||||
void ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPresContext);
|
||||
};
|
||||
|
||||
StyleTableImpl::StyleTableImpl()
|
||||
{
|
||||
ResetFrom(nsnull, nsnull);
|
||||
}
|
||||
|
||||
void StyleTableImpl::ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPresContext)
|
||||
{
|
||||
// values not inherited
|
||||
mCols = NS_STYLE_TABLE_COLS_NONE;
|
||||
mFrame = NS_STYLE_TABLE_FRAME_NONE;
|
||||
mRules = NS_STYLE_TABLE_RULES_NONE;
|
||||
mCellPadding.Reset();
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "nsIPresContext.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsIContentDelegate.h"
|
||||
#include "nsTablePart.h"
|
||||
#include "nsTableContent.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
||||
|
@ -124,31 +123,27 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// Subclass hook for style post processing
|
||||
NS_METHOD nsTableColGroupFrame::SetStyleContextForFirstPass(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsTablePart* table = ((nsTableContent*)mContent)->GetTable();
|
||||
NS_ASSERTION(table,"Table Must not be null");
|
||||
if (!table)
|
||||
return NS_OK; // TODO: error!
|
||||
|
||||
// check for the COLS attribute
|
||||
nsContentAttr result;
|
||||
nsHTMLValue value;
|
||||
result = table->GetAttribute(nsHTMLAtoms::cols, value);
|
||||
// get the table frame
|
||||
nsIFrame* tableFrame=nsnull;
|
||||
GetGeometricParent(tableFrame);
|
||||
tableFrame->GetGeometricParent(tableFrame); // get the outer frame
|
||||
|
||||
// if COLS is set, then map it into the COL frames
|
||||
if (eContentAttr_NotThere != result)
|
||||
{
|
||||
PRInt32 numCols=0;
|
||||
if (eContentAttr_NoValue == result)
|
||||
ChildCount(numCols);
|
||||
else if (eContentAttr_HasValue == result)
|
||||
{
|
||||
nsHTMLUnit unit = value.GetUnit();
|
||||
if (eHTMLUnit_Empty==unit)
|
||||
ChildCount(numCols);
|
||||
else
|
||||
numCols = value.GetIntValue();
|
||||
}
|
||||
// get the style for the table frame
|
||||
nsIStyleContextPtr tableSC;
|
||||
tableFrame->GetStyleContext(aPresContext, tableSC.AssignRef());
|
||||
nsStyleTable *tableStyle = (nsStyleTable*)tableSC->GetStyleData(eStyleStruct_Table);
|
||||
|
||||
// if COLS is set, then map it into the COL frames
|
||||
if (NS_STYLE_TABLE_COLS_NONE != tableStyle->mCols)
|
||||
{
|
||||
// set numCols to the number of columns effected by the COLS attribute
|
||||
PRInt32 numCols=0;
|
||||
if (NS_STYLE_TABLE_COLS_ALL == tableStyle->mCols)
|
||||
ChildCount(numCols);
|
||||
else
|
||||
numCols = tableStyle->mCols;
|
||||
|
||||
// for every column effected, set its width style
|
||||
PRInt32 colIndex=0;
|
||||
nsIFrame *colFrame=nsnull;
|
||||
nsIStyleContextPtr colStyleContext;
|
||||
|
|
|
@ -1168,7 +1168,7 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext,
|
|||
GetAttribute(nsHTMLAtoms::cellpadding, value);
|
||||
if (value.GetUnit() != eHTMLUnit_Null) {
|
||||
tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
|
||||
tableStyle->mCellPadding.SetCoordValue(p2t*(float)(value.GetPixelValue()));
|
||||
tableStyle->mCellPadding.SetCoordValue((nscoord)(p2t*(float)(value.GetPixelValue())));
|
||||
}
|
||||
|
||||
// cellspacing (reuses tableStyle if already resolved)
|
||||
|
@ -1176,7 +1176,18 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext,
|
|||
if (value.GetUnit() != eHTMLUnit_Null) {
|
||||
if (nsnull==tableStyle)
|
||||
tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
|
||||
tableStyle->mCellSpacing.SetCoordValue(p2t*(float)(value.GetPixelValue()));
|
||||
tableStyle->mCellSpacing.SetCoordValue((nscoord)(p2t*(float)(value.GetPixelValue())));
|
||||
}
|
||||
|
||||
// cols
|
||||
GetAttribute(nsHTMLAtoms::cols, value);
|
||||
if (value.GetUnit() != eHTMLUnit_Null) {
|
||||
if (nsnull==tableStyle)
|
||||
tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
tableStyle->mCols = value.GetIntValue();
|
||||
else // COLS had no value, so it refers to all columns
|
||||
tableStyle->mCols = NS_STYLE_TABLE_COLS_ALL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -512,14 +512,20 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext*
|
|||
nsStyleTable::nsStyleTable(void) { }
|
||||
|
||||
struct StyleTableImpl: public nsStyleTable {
|
||||
StyleTableImpl(void) { }
|
||||
StyleTableImpl(void);
|
||||
|
||||
void ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPresContext);
|
||||
};
|
||||
|
||||
StyleTableImpl::StyleTableImpl()
|
||||
{
|
||||
ResetFrom(nsnull, nsnull);
|
||||
}
|
||||
|
||||
void StyleTableImpl::ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPresContext)
|
||||
{
|
||||
// values not inherited
|
||||
mCols = NS_STYLE_TABLE_COLS_NONE;
|
||||
mFrame = NS_STYLE_TABLE_FRAME_NONE;
|
||||
mRules = NS_STYLE_TABLE_RULES_NONE;
|
||||
mCellPadding.Reset();
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "nsIPresContext.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsIContentDelegate.h"
|
||||
#include "nsTablePart.h"
|
||||
#include "nsTableContent.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
||||
|
@ -124,31 +123,27 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// Subclass hook for style post processing
|
||||
NS_METHOD nsTableColGroupFrame::SetStyleContextForFirstPass(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsTablePart* table = ((nsTableContent*)mContent)->GetTable();
|
||||
NS_ASSERTION(table,"Table Must not be null");
|
||||
if (!table)
|
||||
return NS_OK; // TODO: error!
|
||||
|
||||
// check for the COLS attribute
|
||||
nsContentAttr result;
|
||||
nsHTMLValue value;
|
||||
result = table->GetAttribute(nsHTMLAtoms::cols, value);
|
||||
// get the table frame
|
||||
nsIFrame* tableFrame=nsnull;
|
||||
GetGeometricParent(tableFrame);
|
||||
tableFrame->GetGeometricParent(tableFrame); // get the outer frame
|
||||
|
||||
// if COLS is set, then map it into the COL frames
|
||||
if (eContentAttr_NotThere != result)
|
||||
{
|
||||
PRInt32 numCols=0;
|
||||
if (eContentAttr_NoValue == result)
|
||||
ChildCount(numCols);
|
||||
else if (eContentAttr_HasValue == result)
|
||||
{
|
||||
nsHTMLUnit unit = value.GetUnit();
|
||||
if (eHTMLUnit_Empty==unit)
|
||||
ChildCount(numCols);
|
||||
else
|
||||
numCols = value.GetIntValue();
|
||||
}
|
||||
// get the style for the table frame
|
||||
nsIStyleContextPtr tableSC;
|
||||
tableFrame->GetStyleContext(aPresContext, tableSC.AssignRef());
|
||||
nsStyleTable *tableStyle = (nsStyleTable*)tableSC->GetStyleData(eStyleStruct_Table);
|
||||
|
||||
// if COLS is set, then map it into the COL frames
|
||||
if (NS_STYLE_TABLE_COLS_NONE != tableStyle->mCols)
|
||||
{
|
||||
// set numCols to the number of columns effected by the COLS attribute
|
||||
PRInt32 numCols=0;
|
||||
if (NS_STYLE_TABLE_COLS_ALL == tableStyle->mCols)
|
||||
ChildCount(numCols);
|
||||
else
|
||||
numCols = tableStyle->mCols;
|
||||
|
||||
// for every column effected, set its width style
|
||||
PRInt32 colIndex=0;
|
||||
nsIFrame *colFrame=nsnull;
|
||||
nsIStyleContextPtr colStyleContext;
|
||||
|
|
Загрузка…
Ссылка в новой задаче