diff --git a/mozilla/layout/html/table/src/nsTableCaptionFrame.h b/mozilla/layout/html/table/src/nsTableCaptionFrame.h
index b224ba3c13d..a2eb8db7e5d 100644
--- a/mozilla/layout/html/table/src/nsTableCaptionFrame.h
+++ b/mozilla/layout/html/table/src/nsTableCaptionFrame.h
@@ -20,7 +20,6 @@
#include "nscore.h"
#include "nsBodyFrame.h"
-#include "nsTableCaption.h"
/**
* nsTableCaptionFrame
diff --git a/mozilla/layout/html/table/src/nsTableCell.cpp b/mozilla/layout/html/table/src/nsTableCell.cpp
index ec7a8286350..9f2f0eb0850 100644
--- a/mozilla/layout/html/table/src/nsTableCell.cpp
+++ b/mozilla/layout/html/table/src/nsTableCell.cpp
@@ -217,96 +217,121 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
- if (nsnull != mAttributes) {
- nsHTMLValue value;
- nsStyleText* textStyle = nsnull;
- // align: enum
- GetAttribute(nsHTMLAtoms::align, value);
- if (value.GetUnit() == eHTMLUnit_Enumerated)
+ nsHTMLValue value;
+ nsStyleText* textStyle = nsnull;
+
+ // align: enum
+ GetAttribute(nsHTMLAtoms::align, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated)
+ {
+ textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
+ textStyle->mTextAlign = value.GetIntValue();
+ }
+ // otherwise check the row for align and inherit it
+ else {
+ if (nsnull!=mRow)
{
- textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
- textStyle->mTextAlign = value.GetIntValue();
- }
-
- // valign: enum
- GetAttribute(nsHTMLAtoms::valign, value);
- if (value.GetUnit() == eHTMLUnit_Enumerated)
- {
- if (nsnull==textStyle)
- textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
- textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
- }
- // otherwise check the row for valign and inherit it
- else {
- if (nsnull!=mRow)
+ // TODO: optimize by putting a flag on the row to say whether align attr is set
+ nsHTMLValue parentAlignValue;
+ mRow->GetAttribute(nsHTMLAtoms::align, parentAlignValue);
+ if (parentAlignValue.GetUnit() == eHTMLUnit_Enumerated)
{
- // TODO: optimize by putting a flag on the row to say whether valign attr is set
- nsHTMLValue parentAlignValue;
- mRow->GetAttribute(nsHTMLAtoms::valign, parentAlignValue);
- if (parentAlignValue.GetUnit() == eHTMLUnit_Enumerated)
+ PRUint8 rowAlign = parentAlignValue.GetIntValue();
+ if (nsnull==textStyle)
+ textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
+ textStyle->mTextAlign = rowAlign;
+ }
+ else
+ { // we need to check the row group as well
+ nsTableRowGroup *rowGroup = mRow->GetRowGroup();
+ if (nsnull!=rowGroup)
{
- PRUint8 rowVAlign = parentAlignValue.GetIntValue();
- if (NS_STYLE_VERTICAL_ALIGN_MIDDLE!=rowVAlign)
+ rowGroup->GetAttribute(nsHTMLAtoms::align, parentAlignValue);
+ if (parentAlignValue.GetUnit() == eHTMLUnit_Enumerated)
{
+ PRUint8 rowGroupAlign = parentAlignValue.GetIntValue();
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
- textStyle->mVerticalAlign.SetIntValue(rowVAlign, eStyleUnit_Enumerated);
- }
- }
- else
- { // we need to check the row group as well
- nsTableRowGroup *rowGroup = mRow->GetRowGroup();
- if (nsnull!=rowGroup)
- {
- rowGroup->GetAttribute(nsHTMLAtoms::valign, parentAlignValue);
- if (parentAlignValue.GetUnit() == eHTMLUnit_Enumerated)
- {
- PRUint8 rowGroupVAlign = parentAlignValue.GetIntValue();
- if (NS_STYLE_VERTICAL_ALIGN_MIDDLE!=rowGroupVAlign)
- {
- if (nsnull==textStyle)
- textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
- textStyle->mVerticalAlign.SetIntValue(rowGroupVAlign, eStyleUnit_Enumerated);
- }
- }
+ textStyle->mTextAlign = rowGroupAlign;
}
}
}
}
-
- MapBackgroundAttributesInto(aContext, aPresContext);
-
- // nowrap
- GetAttribute(nsHTMLAtoms::nowrap, value);
- if (value.GetUnit() == eHTMLUnit_Empty)
+ }
+
+ // valign: enum
+ GetAttribute(nsHTMLAtoms::valign, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated)
+ {
+ if (nsnull==textStyle)
+ textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
+ textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
+ }
+ // otherwise check the row for valign and inherit it
+ else {
+ if (nsnull!=mRow)
{
- if (nsnull==textStyle)
- textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
- textStyle->mWhiteSpace = NS_STYLE_WHITESPACE_NOWRAP;
- }
-
- // width: pixel
- float p2t = aPresContext->GetPixelsToTwips();
- nsStylePosition* pos = (nsStylePosition*)
- aContext->GetMutableStyleData(eStyleStruct_Position);
- GetAttribute(nsHTMLAtoms::width, value);
- if (value.GetUnit() == eHTMLUnit_Pixel) {
- nscoord twips = nscoord(p2t * value.GetPixelValue());
- pos->mWidth.SetCoordValue(twips);
- }
- else if (value.GetUnit() == eHTMLUnit_Percent) {
- pos->mWidth.SetPercentValue(value.GetPercentValue());
- }
-
- // height: pixel
- GetAttribute(nsHTMLAtoms::height, value);
- if (value.GetUnit() == eHTMLUnit_Pixel) {
- nscoord twips = nscoord(p2t * value.GetPixelValue());
- pos->mHeight.SetCoordValue(twips);
+ // TODO: optimize by putting a flag on the row to say whether valign attr is set
+ nsHTMLValue parentAlignValue;
+ mRow->GetAttribute(nsHTMLAtoms::valign, parentAlignValue);
+ if (parentAlignValue.GetUnit() == eHTMLUnit_Enumerated)
+ {
+ PRUint8 rowVAlign = parentAlignValue.GetIntValue();
+ if (nsnull==textStyle)
+ textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
+ textStyle->mVerticalAlign.SetIntValue(rowVAlign, eStyleUnit_Enumerated);
+ }
+ else
+ { // we need to check the row group as well
+ nsTableRowGroup *rowGroup = mRow->GetRowGroup();
+ if (nsnull!=rowGroup)
+ {
+ rowGroup->GetAttribute(nsHTMLAtoms::valign, parentAlignValue);
+ if (parentAlignValue.GetUnit() == eHTMLUnit_Enumerated)
+ {
+ PRUint8 rowGroupVAlign = parentAlignValue.GetIntValue();
+ if (nsnull==textStyle)
+ textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
+ textStyle->mVerticalAlign.SetIntValue(rowGroupVAlign, eStyleUnit_Enumerated);
+ }
+ }
+ }
}
}
+ MapBackgroundAttributesInto(aContext, aPresContext);
+
+ // nowrap
+ GetAttribute(nsHTMLAtoms::nowrap, value);
+ if (value.GetUnit() == eHTMLUnit_Empty)
+ {
+ if (nsnull==textStyle)
+ textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
+ textStyle->mWhiteSpace = NS_STYLE_WHITESPACE_NOWRAP;
+ }
+
+ // width: pixel
+ float p2t = aPresContext->GetPixelsToTwips();
+ nsStylePosition* pos = (nsStylePosition*)
+ aContext->GetMutableStyleData(eStyleStruct_Position);
+ GetAttribute(nsHTMLAtoms::width, value);
+ if (value.GetUnit() == eHTMLUnit_Pixel) {
+ nscoord twips = nscoord(p2t * value.GetPixelValue());
+ pos->mWidth.SetCoordValue(twips);
+ }
+ else if (value.GetUnit() == eHTMLUnit_Percent) {
+ pos->mWidth.SetPercentValue(value.GetPercentValue());
+ }
+
+ // height: pixel
+ GetAttribute(nsHTMLAtoms::height, value);
+ if (value.GetUnit() == eHTMLUnit_Pixel) {
+ nscoord twips = nscoord(p2t * value.GetPixelValue());
+ pos->mHeight.SetCoordValue(twips);
+ }
+
+
}
nsContentAttr
diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp
index 3b760f593b3..0663b08f1e7 100644
--- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp
@@ -31,9 +31,8 @@
#include "nsHTMLIIDs.h"
#include "nsIPtr.h"
#include "nsIView.h"
-// evil dep's to be removed ASAP
-#include "nsTablePart.h"
-#include "nsTableContent.h"
+// dependancy on content
+#include "nsHTMLTagContent.h"
NS_DEF_PTR(nsIStyleContext);
@@ -485,14 +484,6 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
// this setting overrides any specific border, margin or
// padding information in the cell. If these attributes
// are not defined, the the cells attributes are used
-
- nsHTMLValue padding_value;
- nsHTMLValue spacing_value;
- nsHTMLValue border_value;
-
- nsContentAttr padding_result;
- nsContentAttr spacing_result;
- nsContentAttr border_result;
nscoord padding = 0;
nscoord spacing = 0;
@@ -500,54 +491,41 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
float p2t = aPresContext->GetPixelsToTwips();
- nsTablePart* table = ((nsTableContent*)mContent)->GetTable();
-
- NS_ASSERTION(table,"Table Must not be null");
- if (!table)
+ nsTableFrame* tableFrame = GetTableFrame();
+ tableFrame->GetGeometricParent((nsIFrame *&)tableFrame); // get the outer frame
+ NS_ASSERTION(tableFrame,"Table Must not be null");
+ if (!tableFrame)
return;
- padding_result = table->GetAttribute(nsHTMLAtoms::cellpadding,padding_value);
- spacing_result = table->GetAttribute(nsHTMLAtoms::cellspacing,spacing_value);
- border_result = table->GetAttribute(nsHTMLAtoms::border,border_value);
-
+ // get the table frame style context, and from it get cellpadding, cellspacing, and border info
+ nsIStyleContextPtr tableSC;
+ tableFrame->GetStyleContext(aPresContext, tableSC.AssignRef());
+ nsStyleTable* tableStyle = (nsStyleTable*)tableSC->GetStyleData(eStyleStruct_Table);
+ nsStyleSpacing* tableSpacingStyle = (nsStyleSpacing*)tableSC->GetStyleData(eStyleStruct_Spacing);
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
// check to see if cellpadding or cellspacing is defined
- if (spacing_result == eContentAttr_HasValue || padding_result == eContentAttr_HasValue)
+ if (tableStyle->mCellPadding.GetUnit() != eStyleUnit_Null ||
+ tableStyle->mCellSpacing.GetUnit() != eStyleUnit_Null)
{
-
- PRInt32 value;
- nsStyleCoord padding(0);
- nsStyleCoord spacing(0);
-
- if (padding_result == eContentAttr_HasValue && ConvertToPixelValue(padding_value,0,value))
- padding.SetCoordValue((nscoord)(p2t*(float)value));
-
- if (spacing_result == eContentAttr_HasValue && ConvertToPixelValue(spacing_value,0,value))
- spacing.SetCoordValue((nscoord)(p2t*(float)value));
-
- spacingData->mMargin.SetTop(spacing);
- spacingData->mMargin.SetLeft(spacing);
- spacingData->mMargin.SetBottom(spacing);
- spacingData->mMargin.SetRight(spacing);
- spacingData->mPadding.SetTop(padding);
- spacingData->mPadding.SetLeft(padding);
- spacingData->mPadding.SetBottom(padding);
- spacingData->mPadding.SetRight(padding);
-
+ spacingData->mMargin.SetTop(tableStyle->mCellSpacing);
+ spacingData->mMargin.SetLeft(tableStyle->mCellSpacing);
+ spacingData->mMargin.SetBottom(tableStyle->mCellSpacing);
+ spacingData->mMargin.SetRight(tableStyle->mCellSpacing);
+ spacingData->mPadding.SetTop(tableStyle->mCellPadding);
+ spacingData->mPadding.SetLeft(tableStyle->mCellPadding);
+ spacingData->mPadding.SetBottom(tableStyle->mCellPadding);
+ spacingData->mPadding.SetRight(tableStyle->mCellPadding);
}
- if (border_result == eContentAttr_HasValue)
+
+ // get border information from the table
+ if (tableSpacingStyle->mBorder.GetTopUnit() != eStyleUnit_Null)
{
- PRInt32 intValue = 0;
-
- if (ConvertToPixelValue(border_value,1,intValue))
- {
- if (intValue > 0)
- intValue = 1;
- border = nscoord(p2t*(float)intValue);
- }
+ nsStyleCoord borderSize;
+ tableSpacingStyle->mBorder.GetTop(borderSize);
+ border = borderSize.GetCoordValue();
}
- MapHTMLBorderStyle(aPresContext, *spacingData,border);
+ MapHTMLBorderStyle(aPresContext, *spacingData, border);
}
void nsTableCellFrame::MapTextAttributes(nsIPresContext* aPresContext)
@@ -563,7 +541,6 @@ void nsTableCellFrame::MapTextAttributes(nsIPresContext* aPresContext)
}
-
// Subclass hook for style post processing
NS_METHOD nsTableCellFrame::DidSetStyleContext(nsIPresContext* aPresContext)
{
diff --git a/mozilla/layout/html/table/src/nsTablePart.cpp b/mozilla/layout/html/table/src/nsTablePart.cpp
index 3436ea8cfea..03613e9bf72 100644
--- a/mozilla/layout/html/table/src/nsTablePart.cpp
+++ b/mozilla/layout/html/table/src/nsTablePart.cpp
@@ -1125,7 +1125,7 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext,
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
- float p2t;
+ float p2t = aPresContext->GetPixelsToTwips();
nsHTMLValue value;
// width
@@ -1139,7 +1139,6 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext,
break;
case eHTMLUnit_Pixel:
- p2t = aPresContext->GetPixelsToTwips();
position->mWidth.SetCoordValue(nscoord(p2t * (float)value.GetPixelValue()));
break;
}
@@ -1163,6 +1162,23 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext,
break;
}
}
+
+ // cellpadding
+ nsStyleTable* tableStyle=nsnull;
+ GetAttribute(nsHTMLAtoms::cellpadding, value);
+ if (value.GetUnit() != eHTMLUnit_Null) {
+ tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
+ tableStyle->mCellPadding.SetCoordValue(p2t*(float)(value.GetPixelValue()));
+ }
+
+ // cellspacing (reuses tableStyle if already resolved)
+ GetAttribute(nsHTMLAtoms::cellspacing, value);
+ if (value.GetUnit() != eHTMLUnit_Null) {
+ if (nsnull==tableStyle)
+ tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table);
+ tableStyle->mCellSpacing.SetCoordValue(p2t*(float)(value.GetPixelValue()));
+ }
+
}
void nsTablePart::GetTableBorder(nsIHTMLContent* aContent,
diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp
index 3b760f593b3..0663b08f1e7 100644
--- a/mozilla/layout/tables/nsTableCellFrame.cpp
+++ b/mozilla/layout/tables/nsTableCellFrame.cpp
@@ -31,9 +31,8 @@
#include "nsHTMLIIDs.h"
#include "nsIPtr.h"
#include "nsIView.h"
-// evil dep's to be removed ASAP
-#include "nsTablePart.h"
-#include "nsTableContent.h"
+// dependancy on content
+#include "nsHTMLTagContent.h"
NS_DEF_PTR(nsIStyleContext);
@@ -485,14 +484,6 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
// this setting overrides any specific border, margin or
// padding information in the cell. If these attributes
// are not defined, the the cells attributes are used
-
- nsHTMLValue padding_value;
- nsHTMLValue spacing_value;
- nsHTMLValue border_value;
-
- nsContentAttr padding_result;
- nsContentAttr spacing_result;
- nsContentAttr border_result;
nscoord padding = 0;
nscoord spacing = 0;
@@ -500,54 +491,41 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
float p2t = aPresContext->GetPixelsToTwips();
- nsTablePart* table = ((nsTableContent*)mContent)->GetTable();
-
- NS_ASSERTION(table,"Table Must not be null");
- if (!table)
+ nsTableFrame* tableFrame = GetTableFrame();
+ tableFrame->GetGeometricParent((nsIFrame *&)tableFrame); // get the outer frame
+ NS_ASSERTION(tableFrame,"Table Must not be null");
+ if (!tableFrame)
return;
- padding_result = table->GetAttribute(nsHTMLAtoms::cellpadding,padding_value);
- spacing_result = table->GetAttribute(nsHTMLAtoms::cellspacing,spacing_value);
- border_result = table->GetAttribute(nsHTMLAtoms::border,border_value);
-
+ // get the table frame style context, and from it get cellpadding, cellspacing, and border info
+ nsIStyleContextPtr tableSC;
+ tableFrame->GetStyleContext(aPresContext, tableSC.AssignRef());
+ nsStyleTable* tableStyle = (nsStyleTable*)tableSC->GetStyleData(eStyleStruct_Table);
+ nsStyleSpacing* tableSpacingStyle = (nsStyleSpacing*)tableSC->GetStyleData(eStyleStruct_Spacing);
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
// check to see if cellpadding or cellspacing is defined
- if (spacing_result == eContentAttr_HasValue || padding_result == eContentAttr_HasValue)
+ if (tableStyle->mCellPadding.GetUnit() != eStyleUnit_Null ||
+ tableStyle->mCellSpacing.GetUnit() != eStyleUnit_Null)
{
-
- PRInt32 value;
- nsStyleCoord padding(0);
- nsStyleCoord spacing(0);
-
- if (padding_result == eContentAttr_HasValue && ConvertToPixelValue(padding_value,0,value))
- padding.SetCoordValue((nscoord)(p2t*(float)value));
-
- if (spacing_result == eContentAttr_HasValue && ConvertToPixelValue(spacing_value,0,value))
- spacing.SetCoordValue((nscoord)(p2t*(float)value));
-
- spacingData->mMargin.SetTop(spacing);
- spacingData->mMargin.SetLeft(spacing);
- spacingData->mMargin.SetBottom(spacing);
- spacingData->mMargin.SetRight(spacing);
- spacingData->mPadding.SetTop(padding);
- spacingData->mPadding.SetLeft(padding);
- spacingData->mPadding.SetBottom(padding);
- spacingData->mPadding.SetRight(padding);
-
+ spacingData->mMargin.SetTop(tableStyle->mCellSpacing);
+ spacingData->mMargin.SetLeft(tableStyle->mCellSpacing);
+ spacingData->mMargin.SetBottom(tableStyle->mCellSpacing);
+ spacingData->mMargin.SetRight(tableStyle->mCellSpacing);
+ spacingData->mPadding.SetTop(tableStyle->mCellPadding);
+ spacingData->mPadding.SetLeft(tableStyle->mCellPadding);
+ spacingData->mPadding.SetBottom(tableStyle->mCellPadding);
+ spacingData->mPadding.SetRight(tableStyle->mCellPadding);
}
- if (border_result == eContentAttr_HasValue)
+
+ // get border information from the table
+ if (tableSpacingStyle->mBorder.GetTopUnit() != eStyleUnit_Null)
{
- PRInt32 intValue = 0;
-
- if (ConvertToPixelValue(border_value,1,intValue))
- {
- if (intValue > 0)
- intValue = 1;
- border = nscoord(p2t*(float)intValue);
- }
+ nsStyleCoord borderSize;
+ tableSpacingStyle->mBorder.GetTop(borderSize);
+ border = borderSize.GetCoordValue();
}
- MapHTMLBorderStyle(aPresContext, *spacingData,border);
+ MapHTMLBorderStyle(aPresContext, *spacingData, border);
}
void nsTableCellFrame::MapTextAttributes(nsIPresContext* aPresContext)
@@ -563,7 +541,6 @@ void nsTableCellFrame::MapTextAttributes(nsIPresContext* aPresContext)
}
-
// Subclass hook for style post processing
NS_METHOD nsTableCellFrame::DidSetStyleContext(nsIPresContext* aPresContext)
{