diff --git a/content/base/src/nsHTMLValue.h b/content/base/src/nsHTMLValue.h
index 4bd87a0e50f7..cc5f437f9532 100644
--- a/content/base/src/nsHTMLValue.h
+++ b/content/base/src/nsHTMLValue.h
@@ -25,14 +25,15 @@
enum nsHTMLUnit {
- eHTMLUnit_Null = 0, // (n/a) null unit, value is not specified
- eHTMLUnit_Empty = 1, // (n/a) empty unit, value is not specified
- eHTMLUnit_String = 10, // (nsString) a string value
- eHTMLUnit_ISupports = 20, // (nsISupports*) a ref counted interface
- eHTMLUnit_Integer = 50, // (int) simple value
- eHTMLUnit_Enumerated = 51, // (int) value has enumerated meaning
- eHTMLUnit_Color = 80, // (color) an RGBA value
- eHTMLUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
+ eHTMLUnit_Null = 0, // (n/a) null unit, value is not specified
+ eHTMLUnit_Empty = 1, // (n/a) empty unit, value is not specified
+ eHTMLUnit_String = 10, // (nsString) a string value
+ eHTMLUnit_ISupports = 20, // (nsISupports*) a ref counted interface
+ eHTMLUnit_Integer = 50, // (int) simple value
+ eHTMLUnit_Enumerated = 51, // (int) value has enumerated meaning
+ eHTMLUnit_Proportional = 52, // (int) value is a relative proportion of some whole
+ eHTMLUnit_Color = 80, // (color) an RGBA value
+ eHTMLUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
// Screen relative measure
eHTMLUnit_Pixel = 600 // (int) screen pixels
diff --git a/content/html/content/src/nsHTMLAtoms.cpp b/content/html/content/src/nsHTMLAtoms.cpp
index d897e43ef2df..336e5e4b2c1c 100644
--- a/content/html/content/src/nsHTMLAtoms.cpp
+++ b/content/html/content/src/nsHTMLAtoms.cpp
@@ -114,6 +114,7 @@ nsIAtom* nsHTMLAtoms::scrolling;
nsIAtom* nsHTMLAtoms::selected;
nsIAtom* nsHTMLAtoms::shape;
nsIAtom* nsHTMLAtoms::size;
+nsIAtom* nsHTMLAtoms::span;
nsIAtom* nsHTMLAtoms::src;
nsIAtom* nsHTMLAtoms::start;
nsIAtom* nsHTMLAtoms::style;
@@ -241,6 +242,7 @@ void nsHTMLAtoms::AddrefAtoms()
selected = NS_NewAtom("SELECTED");
shape = NS_NewAtom("SHAPE");
size = NS_NewAtom("SIZE");
+ span = NS_NewAtom("SPAN");
src = NS_NewAtom("SRC");
start = NS_NewAtom("START");
style = NS_NewAtom("STYLE");
@@ -369,6 +371,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(selected);
NS_RELEASE(shape);
NS_RELEASE(size);
+ NS_RELEASE(span);
NS_RELEASE(src);
NS_RELEASE(start);
NS_RELEASE(style);
diff --git a/content/html/content/src/nsHTMLAtoms.h b/content/html/content/src/nsHTMLAtoms.h
index 6bbf96ff0ba6..f23e2b45dc99 100644
--- a/content/html/content/src/nsHTMLAtoms.h
+++ b/content/html/content/src/nsHTMLAtoms.h
@@ -145,6 +145,7 @@ public:
static nsIAtom* selected;
static nsIAtom* shape;
static nsIAtom* size;
+ static nsIAtom* span;
static nsIAtom* src;
static nsIAtom* start;
static nsIAtom* style;
diff --git a/content/html/style/src/nsHTMLValue.h b/content/html/style/src/nsHTMLValue.h
index 4bd87a0e50f7..cc5f437f9532 100644
--- a/content/html/style/src/nsHTMLValue.h
+++ b/content/html/style/src/nsHTMLValue.h
@@ -25,14 +25,15 @@
enum nsHTMLUnit {
- eHTMLUnit_Null = 0, // (n/a) null unit, value is not specified
- eHTMLUnit_Empty = 1, // (n/a) empty unit, value is not specified
- eHTMLUnit_String = 10, // (nsString) a string value
- eHTMLUnit_ISupports = 20, // (nsISupports*) a ref counted interface
- eHTMLUnit_Integer = 50, // (int) simple value
- eHTMLUnit_Enumerated = 51, // (int) value has enumerated meaning
- eHTMLUnit_Color = 80, // (color) an RGBA value
- eHTMLUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
+ eHTMLUnit_Null = 0, // (n/a) null unit, value is not specified
+ eHTMLUnit_Empty = 1, // (n/a) empty unit, value is not specified
+ eHTMLUnit_String = 10, // (nsString) a string value
+ eHTMLUnit_ISupports = 20, // (nsISupports*) a ref counted interface
+ eHTMLUnit_Integer = 50, // (int) simple value
+ eHTMLUnit_Enumerated = 51, // (int) value has enumerated meaning
+ eHTMLUnit_Proportional = 52, // (int) value is a relative proportion of some whole
+ eHTMLUnit_Color = 80, // (color) an RGBA value
+ eHTMLUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
// Screen relative measure
eHTMLUnit_Pixel = 600 // (int) screen pixels
diff --git a/content/shared/public/nsHTMLAtoms.h b/content/shared/public/nsHTMLAtoms.h
index 6bbf96ff0ba6..f23e2b45dc99 100644
--- a/content/shared/public/nsHTMLAtoms.h
+++ b/content/shared/public/nsHTMLAtoms.h
@@ -145,6 +145,7 @@ public:
static nsIAtom* selected;
static nsIAtom* shape;
static nsIAtom* size;
+ static nsIAtom* span;
static nsIAtom* src;
static nsIAtom* start;
static nsIAtom* style;
diff --git a/content/shared/public/nsHTMLValue.h b/content/shared/public/nsHTMLValue.h
index 4bd87a0e50f7..cc5f437f9532 100644
--- a/content/shared/public/nsHTMLValue.h
+++ b/content/shared/public/nsHTMLValue.h
@@ -25,14 +25,15 @@
enum nsHTMLUnit {
- eHTMLUnit_Null = 0, // (n/a) null unit, value is not specified
- eHTMLUnit_Empty = 1, // (n/a) empty unit, value is not specified
- eHTMLUnit_String = 10, // (nsString) a string value
- eHTMLUnit_ISupports = 20, // (nsISupports*) a ref counted interface
- eHTMLUnit_Integer = 50, // (int) simple value
- eHTMLUnit_Enumerated = 51, // (int) value has enumerated meaning
- eHTMLUnit_Color = 80, // (color) an RGBA value
- eHTMLUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
+ eHTMLUnit_Null = 0, // (n/a) null unit, value is not specified
+ eHTMLUnit_Empty = 1, // (n/a) empty unit, value is not specified
+ eHTMLUnit_String = 10, // (nsString) a string value
+ eHTMLUnit_ISupports = 20, // (nsISupports*) a ref counted interface
+ eHTMLUnit_Integer = 50, // (int) simple value
+ eHTMLUnit_Enumerated = 51, // (int) value has enumerated meaning
+ eHTMLUnit_Proportional = 52, // (int) value is a relative proportion of some whole
+ eHTMLUnit_Color = 80, // (color) an RGBA value
+ eHTMLUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
// Screen relative measure
eHTMLUnit_Pixel = 600 // (int) screen pixels
diff --git a/content/shared/src/nsHTMLAtoms.cpp b/content/shared/src/nsHTMLAtoms.cpp
index d897e43ef2df..336e5e4b2c1c 100644
--- a/content/shared/src/nsHTMLAtoms.cpp
+++ b/content/shared/src/nsHTMLAtoms.cpp
@@ -114,6 +114,7 @@ nsIAtom* nsHTMLAtoms::scrolling;
nsIAtom* nsHTMLAtoms::selected;
nsIAtom* nsHTMLAtoms::shape;
nsIAtom* nsHTMLAtoms::size;
+nsIAtom* nsHTMLAtoms::span;
nsIAtom* nsHTMLAtoms::src;
nsIAtom* nsHTMLAtoms::start;
nsIAtom* nsHTMLAtoms::style;
@@ -241,6 +242,7 @@ void nsHTMLAtoms::AddrefAtoms()
selected = NS_NewAtom("SELECTED");
shape = NS_NewAtom("SHAPE");
size = NS_NewAtom("SIZE");
+ span = NS_NewAtom("SPAN");
src = NS_NewAtom("SRC");
start = NS_NewAtom("START");
style = NS_NewAtom("STYLE");
@@ -369,6 +371,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(selected);
NS_RELEASE(shape);
NS_RELEASE(size);
+ NS_RELEASE(span);
NS_RELEASE(src);
NS_RELEASE(start);
NS_RELEASE(style);
diff --git a/layout/html/base/src/nsHTMLAtoms.cpp b/layout/html/base/src/nsHTMLAtoms.cpp
index d897e43ef2df..336e5e4b2c1c 100644
--- a/layout/html/base/src/nsHTMLAtoms.cpp
+++ b/layout/html/base/src/nsHTMLAtoms.cpp
@@ -114,6 +114,7 @@ nsIAtom* nsHTMLAtoms::scrolling;
nsIAtom* nsHTMLAtoms::selected;
nsIAtom* nsHTMLAtoms::shape;
nsIAtom* nsHTMLAtoms::size;
+nsIAtom* nsHTMLAtoms::span;
nsIAtom* nsHTMLAtoms::src;
nsIAtom* nsHTMLAtoms::start;
nsIAtom* nsHTMLAtoms::style;
@@ -241,6 +242,7 @@ void nsHTMLAtoms::AddrefAtoms()
selected = NS_NewAtom("SELECTED");
shape = NS_NewAtom("SHAPE");
size = NS_NewAtom("SIZE");
+ span = NS_NewAtom("SPAN");
src = NS_NewAtom("SRC");
start = NS_NewAtom("START");
style = NS_NewAtom("STYLE");
@@ -369,6 +371,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(selected);
NS_RELEASE(shape);
NS_RELEASE(size);
+ NS_RELEASE(span);
NS_RELEASE(src);
NS_RELEASE(start);
NS_RELEASE(style);
diff --git a/layout/html/base/src/nsHTMLAtoms.h b/layout/html/base/src/nsHTMLAtoms.h
index 6bbf96ff0ba6..f23e2b45dc99 100644
--- a/layout/html/base/src/nsHTMLAtoms.h
+++ b/layout/html/base/src/nsHTMLAtoms.h
@@ -145,6 +145,7 @@ public:
static nsIAtom* selected;
static nsIAtom* shape;
static nsIAtom* size;
+ static nsIAtom* span;
static nsIAtom* src;
static nsIAtom* start;
static nsIAtom* style;
diff --git a/layout/html/base/src/nsHTMLTagContent.cpp b/layout/html/base/src/nsHTMLTagContent.cpp
index e3a7687f6d23..418509ce7451 100644
--- a/layout/html/base/src/nsHTMLTagContent.cpp
+++ b/layout/html/base/src/nsHTMLTagContent.cpp
@@ -613,6 +613,35 @@ void nsHTMLTagContent::ParseValueOrPercent(const nsString& aString,
}
}
+/* used to parser attribute values that could be either:
+ * integer (n),
+ * percent (n%),
+ * or proportional (n*)
+ */
+void nsHTMLTagContent::ParseValueOrPercentOrProportional(const nsString& aString,
+ nsHTMLValue& aResult,
+ nsHTMLUnit aValueUnit)
+{ // XXX should have min/max values?
+ nsAutoString tmp(aString);
+ tmp.CompressWhitespace(PR_TRUE, PR_TRUE);
+ PRInt32 ec, val = tmp.ToInteger(&ec);
+ if (tmp.Last() == '%') {/* XXX not 100% compatible with ebina's code */
+ if (val < 0) val = 0;
+ if (val > 100) val = 100;
+ aResult.SetPercentValue(float(val)/100.0f);
+ } else if (tmp.Last() == '*') {
+ if (val < 0) val = 0;
+ aResult.SetIntValue(val, eHTMLUnit_Proportional); // proportional values are integers
+ } else {
+ if (eHTMLUnit_Pixel == aValueUnit) {
+ aResult.SetPixelValue(val);
+ }
+ else {
+ aResult.SetIntValue(val, aValueUnit);
+ }
+ }
+}
+
PRBool nsHTMLTagContent::ValueOrPercentToString(const nsHTMLValue& aValue,
nsString& aResult)
{
diff --git a/layout/html/base/src/nsHTMLTagContent.h b/layout/html/base/src/nsHTMLTagContent.h
index e5561ff4076b..4f10f9727e6f 100644
--- a/layout/html/base/src/nsHTMLTagContent.h
+++ b/layout/html/base/src/nsHTMLTagContent.h
@@ -131,6 +131,15 @@ public:
static void ParseValueOrPercent(const nsString& aString,
nsHTMLValue& aResult, nsHTMLUnit aValueUnit);
+ /** used to parser attribute values that could be either:
+ * integer (n),
+ * percent (n%),
+ * or proportional (n*)
+ */
+ static void nsHTMLTagContent::ParseValueOrPercentOrProportional(const nsString& aString,
+ nsHTMLValue& aResult,
+ nsHTMLUnit aValueUnit);
+
static PRBool ValueOrPercentToString(const nsHTMLValue& aValue,
nsString& aResult);
diff --git a/layout/html/style/src/nsHTMLValue.h b/layout/html/style/src/nsHTMLValue.h
index 4bd87a0e50f7..cc5f437f9532 100644
--- a/layout/html/style/src/nsHTMLValue.h
+++ b/layout/html/style/src/nsHTMLValue.h
@@ -25,14 +25,15 @@
enum nsHTMLUnit {
- eHTMLUnit_Null = 0, // (n/a) null unit, value is not specified
- eHTMLUnit_Empty = 1, // (n/a) empty unit, value is not specified
- eHTMLUnit_String = 10, // (nsString) a string value
- eHTMLUnit_ISupports = 20, // (nsISupports*) a ref counted interface
- eHTMLUnit_Integer = 50, // (int) simple value
- eHTMLUnit_Enumerated = 51, // (int) value has enumerated meaning
- eHTMLUnit_Color = 80, // (color) an RGBA value
- eHTMLUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
+ eHTMLUnit_Null = 0, // (n/a) null unit, value is not specified
+ eHTMLUnit_Empty = 1, // (n/a) empty unit, value is not specified
+ eHTMLUnit_String = 10, // (nsString) a string value
+ eHTMLUnit_ISupports = 20, // (nsISupports*) a ref counted interface
+ eHTMLUnit_Integer = 50, // (int) simple value
+ eHTMLUnit_Enumerated = 51, // (int) value has enumerated meaning
+ eHTMLUnit_Proportional = 52, // (int) value is a relative proportion of some whole
+ eHTMLUnit_Color = 80, // (color) an RGBA value
+ eHTMLUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
// Screen relative measure
eHTMLUnit_Pixel = 600 // (int) screen pixels
diff --git a/layout/html/table/src/nsTableCol.cpp b/layout/html/table/src/nsTableCol.cpp
index c3bb33a5c299..ca2fdde9a9fb 100644
--- a/layout/html/table/src/nsTableCol.cpp
+++ b/layout/html/table/src/nsTableCol.cpp
@@ -45,17 +45,10 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
- NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsReflowStatus& aStatus);
-
- NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsSize& aMaxSize,
- nsReflowCommand& aReflowCommand,
- nsReflowStatus& aStatus);
+ NS_IMETHOD Reflow(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsReflowState& aReflowState,
+ nsReflowStatus& aStatus);
protected:
@@ -72,6 +65,7 @@ nsTableColFrame::nsTableColFrame(nsIContent* aContent, nsIFrame* aParentFrame)
{
}
+
nsTableColFrame::~nsTableColFrame()
{
}
@@ -86,39 +80,23 @@ NS_METHOD nsTableColFrame::Paint(nsIPresContext& aPresContext,
}
-NS_METHOD nsTableColFrame::ResizeReflow(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsReflowStatus& aStatus)
+NS_METHOD nsTableColFrame::Reflow(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsReflowState& aReflowState,
+ nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull!=aPresContext, "bad arg");
- if (gsDebug==PR_TRUE) printf("nsTableoupFrame::ResizeReflow\n");
aDesiredSize.width=0;
aDesiredSize.height=0;
- if (nsnull!=aMaxElementSize)
+ if (nsnull!=aDesiredSize.maxElementSize)
{
- aMaxElementSize->width=0;
- aMaxElementSize->height=0;
+ aDesiredSize.maxElementSize->width=0;
+ aDesiredSize.maxElementSize->height=0;
}
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
-NS_METHOD nsTableColFrame::IncrementalReflow(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsSize& aMaxSize,
- nsReflowCommand& aReflowCommand,
- nsReflowStatus& aStatus)
-{
- NS_ASSERTION(nsnull!=aPresContext, "bad arg");
- if (gsDebug==PR_TRUE) printf("nsTableColFrame::IncrementalReflow\n");
- aDesiredSize.width=0;
- aDesiredSize.height=0;
- aStatus = NS_FRAME_COMPLETE;
- return NS_OK;
-}
-
nsresult nsTableColFrame::NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent)
@@ -184,6 +162,9 @@ nsrefcnt nsTableCol::Release(void)
return mRefCnt;
}
+// TODO: what about proportional width values (0*, 1*, etc.) down in COL tag
+// TODO: need a ::SetAttribute hook for width
+
int nsTableCol::GetType()
{
return nsITableContent::kTableColType;
@@ -229,95 +210,6 @@ void nsTableCol::ResetColumns ()
mColGroup->ResetColumns ();
}
-static const nsString kRepeatAttributeName("REPEAT");
-
-PRBool nsTableCol::SetInternalAttribute (nsString * aName, nsString * aValue)
-{
- /*
- // Assert aName and aValue
- if (aName->EqualsIgnoreCase (kRepeatAttributeName))
- {
- PRInt32 value = atoi(aValue->ToCString());
- SetRepeat (aValue);
- return true;
- }
- return super.setInternalAttribute (aName, aValue);
- */
- return PR_FALSE;
-}
-
-/** I allocated it for you, you delete it when you're done */
-// ack!!! SEC this code and HTMLContainer need to get together and decide
-nsString * nsTableCol::GetInternalAttribute (nsString * aName)
-{
- /*
- // Assert aName
- if (aName->EqualsIgnoreCase (kRepeatAttributeName))
- {
- char repeatAsCharArray[10];
- sprintf(repeatAsCharArray, "%d", GetRepeat());
- nsString * result = new nsString(repeatAsCharArray);
- }
- return nsTableContent::GetInternalAttribute (aName);
- */
- return nsnull;
-}
-
-PRBool nsTableCol::UnsetInternalAttribute (nsString * aName)
-{
- /*
- if (aName->EqualsIgnoreCase (kRepeatAttributeName))
- {
- fRepeat = 0;
- return true;
- }
- return nsTableContent::UnsetInternalAttribute (aName);
- */
- return PR_FALSE;
-}
-
-int nsTableCol::GetInternalAttributeState (nsString * aName)
-{
- /*
- if (aName->EqualsIgnoreCase (kRepeatAttributeName))
- {
- if (0 < fRepeat)
- return kAttributeSet;
- }
- return super.getInternalAttributeState (aName);
- */
- return 0;
-}
-
-PRBool nsTableCol::IsInternalAttribute (nsString * aName)
-{
- /*
- if (aName->EqualsIgnoreCase (kRepeatAttributeName))
- return true;
- return super.isInternalAttribute (aName);
- */
- return PR_FALSE;
-}
-
-
-static nsString * kInternalAttributeNames = nsnull;
-
-nsString * nsTableCol::GetAllInternalAttributeNames ()
-{
- /*
- if (null == kInternalAttributeNames)
- {
- nsString * [] superInternal = super.getAllInternalAttributeNames ();
-
- int superLen = superInternal.length;
- kInternalAttributeNames = new nsString * [superLen + 1];
- System.arraycopy (superInternal, 0, kInternalAttributeNames, 0, superLen);
- kInternalAttributeNames[superLen] = kRepeatAttributeName;
- }
- return kInternalAttributeNames;
- */
- return nsnull;
-}
nsresult
nsTableCol::CreateFrame(nsIPresContext* aPresContext,
diff --git a/layout/html/table/src/nsTableCol.h b/layout/html/table/src/nsTableCol.h
index 4a7ba2ff69d6..1109001d782e 100644
--- a/layout/html/table/src/nsTableCol.h
+++ b/layout/html/table/src/nsTableCol.h
@@ -106,26 +106,6 @@ public:
virtual void ResetColumns ();
- /* ----------- nsITableContent overrides ----------- */
-
-protected:
-
- /** obsolete */
- PRBool SetInternalAttribute (nsString *aName, nsString *aValue);
- /** obsolete */
- nsString *GetInternalAttribute (nsString *aName);
- /** obsolete */
- PRBool UnsetInternalAttribute (nsString *aName);
- /** obsolete */
- int GetInternalAttributeState (nsString *aName);
- /** obsolete */
- PRBool IsInternalAttribute (nsString *aName);
- /** obsolete */
- static nsString * kInternalAttributeNames;
- /** obsolete */
- nsString * GetAllInternalAttributeNames ();
-
-
};
#endif
diff --git a/layout/html/table/src/nsTableColGroup.cpp b/layout/html/table/src/nsTableColGroup.cpp
index a99b54c18523..1858c4fdcea3 100644
--- a/layout/html/table/src/nsTableColGroup.cpp
+++ b/layout/html/table/src/nsTableColGroup.cpp
@@ -25,6 +25,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsHTMLIIDs.h"
+#include "nsHTMLAtoms.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@@ -148,48 +149,6 @@ int nsTableColGroup::GetColumnCount ()
return mColCount;
}
-PRBool nsTableColGroup::SetInternalAttribute (nsString *aName, nsString *aValue)
-{
-// Assert aName
- PRBool result = PR_FALSE;
- return result;
-}
-
-nsString * nsTableColGroup::GetInternalAttribute (nsString *aName)
-{
-// Assert aName
- nsString * result = nsnull;
- return result;
-}
-
-PRBool nsTableColGroup::UnsetInternalAttribute (nsString *aName)
-{
-// Assert aName
- PRBool result = PR_FALSE;
- return result;
-}
-
-int nsTableColGroup::GetInternalAttributeState (nsString *aName)
-{
-// Assert aName
- int result = 0;
- return result;
-}
-
-PRBool nsTableColGroup::IsInternalAttribute (nsString *aName)
-{
-// Assert aName
- PRBool result = PR_FALSE;
- return result;
-}
-
-nsString * nsTableColGroup::GetAllInternalAttributeNames ()
-{
-// Assert aName
- nsString * result = nsnull;
- return result;
-}
-
PRBool nsTableColGroup::AppendChild (nsIContent *aContent)
{
NS_ASSERTION(nsnull!=aContent, "bad arg");
@@ -331,6 +290,80 @@ PRBool nsTableColGroup::IsCol(nsIContent * aContent) const
return result;
}
+void nsTableColGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
+{
+ nsHTMLValue val;
+
+ if (aAttribute == nsHTMLAtoms::width)
+ {
+ ParseValueOrPercentOrProportional(aValue, val, eHTMLUnit_Pixel);
+ nsHTMLTagContent::SetAttribute(aAttribute, val);
+ }
+ else if ( aAttribute == nsHTMLAtoms::span)
+ {
+ ParseValue(aValue, 0, val, eHTMLUnit_Integer);
+ nsHTMLTagContent::SetAttribute(aAttribute, val);
+ }
+ else if (aAttribute == nsHTMLAtoms::align) {
+ nsHTMLValue val;
+ if (ParseTableAlignParam(aValue, val)) {
+ nsHTMLTagContent::SetAttribute(aAttribute, val);
+ }
+ return;
+ }
+ else if (aAttribute == nsHTMLAtoms::valign) {
+ nsHTMLValue val;
+ if (ParseTableAlignParam(aValue, val)) {
+ nsHTMLTagContent::SetAttribute(aAttribute, val);
+ }
+ return;
+ }
+}
+
+void nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
+{
+ NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
+ NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
+
+ float p2t;
+ nsHTMLValue value;
+
+ // width
+ GetAttribute(nsHTMLAtoms::width, value);
+ if (value.GetUnit() != eHTMLUnit_Null) {
+ nsStylePosition* position = (nsStylePosition*)
+ aContext->GetData(eStyleStruct_Position);
+ switch (value.GetUnit()) {
+ case eHTMLUnit_Percent:
+ position->mWidth.SetPercentValue(value.GetPercentValue());
+ break;
+
+ case eHTMLUnit_Pixel:
+ p2t = aPresContext->GetPixelsToTwips();
+ position->mWidth.SetCoordValue(nscoord(p2t * (float)value.GetPixelValue()));
+ break;
+ }
+ }
+
+ // align
+ GetAttribute(nsHTMLAtoms::align, value);
+ if (value.GetUnit() != eHTMLUnit_Null) {
+ NS_ASSERTION(value.GetUnit() == eHTMLUnit_Enumerated, "unexpected unit");
+ nsStyleDisplay* display = (nsStyleDisplay*)aContext->GetData(eStyleStruct_Display);
+
+ switch (value.GetIntValue()) {
+ case NS_STYLE_TEXT_ALIGN_LEFT:
+ display->mFloats = NS_STYLE_FLOAT_LEFT;
+ break;
+
+ case NS_STYLE_TEXT_ALIGN_RIGHT:
+ display->mFloats = NS_STYLE_FLOAT_RIGHT;
+ break;
+ }
+ }
+}
+
nsresult
nsTableColGroup::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
diff --git a/layout/html/table/src/nsTableColGroup.h b/layout/html/table/src/nsTableColGroup.h
index 61d20ebaaf1a..93fa882df0c0 100644
--- a/layout/html/table/src/nsTableColGroup.h
+++ b/layout/html/table/src/nsTableColGroup.h
@@ -75,6 +75,11 @@ public:
// For debugging purposes only
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
+
+ virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
+
+ virtual void MapAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
/** @see nsIHTMLContent::CreateFrame */
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
@@ -139,19 +144,6 @@ public:
/** @see nsIContent::InsertChildAt */
virtual PRBool RemoveChildAt (int aIndex);
-protected:
- virtual PRBool SetInternalAttribute (nsString *aName, nsString *aValue);
-
- virtual nsString *GetInternalAttribute (nsString *aName);
-
- virtual PRBool UnsetInternalAttribute (nsString *aName);
-
- virtual int GetInternalAttributeState (nsString *aName);
-
- virtual PRBool IsInternalAttribute (nsString *aName);
-
- virtual nsString * GetAllInternalAttributeNames ();
-
};
diff --git a/layout/html/table/src/nsTableColGroupFrame.cpp b/layout/html/table/src/nsTableColGroupFrame.cpp
index 4e6c6ae9a83e..274f410686ee 100644
--- a/layout/html/table/src/nsTableColGroupFrame.cpp
+++ b/layout/html/table/src/nsTableColGroupFrame.cpp
@@ -20,6 +20,14 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIPtr.h"
+#include "nsIContentDelegate.h"
+#include "nsTablePart.h"
+#include "nsTableContent.h"
+#include "nsHTMLAtoms.h"
+
+NS_DEF_PTR(nsIContent);
+NS_DEF_PTR(nsIStyleContext);
static PRBool gsDebug = PR_FALSE;
@@ -43,15 +51,65 @@ NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
return NS_OK;
}
-
-NS_METHOD
-nsTableColGroupFrame::ResizeReflow(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsReflowState& aReflowState,
- nsReflowStatus& aStatus)
+// TODO: content changed notifications
+NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsReflowState& aReflowState,
+ nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull!=aPresContext, "bad arg");
- if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::Reflow\n");
+ NS_ASSERTION(nsnull!=mContent, "bad state -- null content for frame");
+
+ if (nsnull == mFirstChild)
+ { // if we don't have any children, create them
+ nsIFrame* kidFrame = nsnull;
+ nsIFrame* prevKidFrame;
+
+ LastChild(prevKidFrame); // XXX remember this...
+ PRInt32 kidIndex = 0;
+ for (;;)
+ {
+ nsIContentPtr kid = mContent->ChildAt(kidIndex); // kid: REFCNT++
+ if (kid.IsNull()) {
+ break;
+ }
+
+ // Resolve style
+ nsIStyleContextPtr kidSC =
+ aPresContext->ResolveStyleContextFor(kid, this);
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(eStyleStruct_Spacing);
+
+ // Create a child frame
+ nsIContentDelegate* kidDel = nsnull;
+ kidDel = kid->GetDelegate(aPresContext);
+ nsresult rv = kidDel->CreateFrame(aPresContext, kid, this, kidSC,
+ kidFrame);
+ NS_RELEASE(kidDel);
+
+ // give the child frame a chance to reflow, even though we know it'll have 0 size
+ nsReflowMetrics kidSize(nsnull);
+ nsReflowState kidReflowState(eReflowReason_Initial, nsSize(0,0));
+ kidFrame->WillReflow(*aPresContext);
+ nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
+ kidReflowState);
+ // note that DidReflow is called as the result of some ancestor firing off a DidReflow above me
+ kidFrame->SetRect(nsRect(0,0,0,0));
+
+ // Link child frame into the list of children
+ if (nsnull != prevKidFrame) {
+ prevKidFrame->SetNextSibling(kidFrame);
+ } else {
+ mFirstChild = kidFrame; // our first child
+ SetFirstContentOffset(kidFrame);
+ }
+ prevKidFrame = kidFrame;
+ mChildCount++;
+ kidIndex++;
+ }
+ // now that I have all my COL children, adjust their style
+ SetStyleContextForFirstPass(aPresContext);
+ }
aDesiredSize.width=0;
aDesiredSize.height=0;
if (nsnull!=aDesiredSize.maxElementSize)
@@ -63,6 +121,65 @@ nsTableColGroupFrame::ResizeReflow(nsIPresContext* aPresContext,
return NS_OK;
}
+// 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);
+
+ // if COLS is set, then map it into the COL frames
+ // chicken and egg problem here. I don't have any children yet, so I
+ // don't know how many columns there are, so I can't do this!
+ // I need to just set some state, and let the individual columns query up into me
+ // in their own hooks
+ PRInt32 numCols;
+ if (result == eContentAttr_NoValue)
+ ChildCount(numCols);
+ else if (result == eContentAttr_HasValue)
+ {
+ nsHTMLUnit unit = value.GetUnit();
+ if (eHTMLUnit_Empty==unit)
+ ChildCount(numCols);
+ else
+ numCols = value.GetIntValue();
+ }
+
+ PRInt32 colIndex=0;
+ nsIFrame *colFrame;
+ FirstChild(colFrame);
+ for (; colIndexGetStyleData(eStyleStruct_Position, (nsStyleStruct*&)colPosition);
+ nsStyleCoord width (1, eStyleUnit_Proportional);
+ colPosition->mWidth = width;
+ colFrame->GetNextSibling(colFrame);
+ }
+ // if there are more columns, there width is set to "minimum"
+ PRInt32 numChildFrames;
+ ChildCount(numChildFrames);
+ for (; colIndexGetStyleData(eStyleStruct_Position, (nsStyleStruct*&)colPosition);
+ nsStyleCoord width (0, eStyleUnit_Integer);
+ colPosition->mWidth = width;
+ colFrame->GetNextSibling(colFrame);
+ }
+
+ mStyleContext->RecalcAutomaticData(aPresContext);
+ return NS_OK;
+}
+
nsresult nsTableColGroupFrame::NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent)
diff --git a/layout/html/table/src/nsTableColGroupFrame.h b/layout/html/table/src/nsTableColGroupFrame.h
index 3c02512449ff..e95ff0dcd0b6 100644
--- a/layout/html/table/src/nsTableColGroupFrame.h
+++ b/layout/html/table/src/nsTableColGroupFrame.h
@@ -39,10 +39,16 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
- NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsReflowState& aReflowState,
- nsReflowStatus& aStatus);
+ /** reflow of a column group is a trivial matter of reflowing
+ * the col group's children (columns), and setting this frame
+ * to 0-size. Since tables are row-centric, column group frames
+ * don't play directly in the rendering game. They do however
+ * maintain important state that effects table and cell layout.
+ */
+ NS_IMETHOD Reflow(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsReflowState& aReflowState,
+ nsReflowStatus& aStatus);
protected:
@@ -50,6 +56,12 @@ protected:
~nsTableColGroupFrame();
+ /** Hook for style post processing.
+ * Since we need to know the full column structure before the COLS attribute
+ * can be interpreted, we can't just use DidSetStyleContext
+ */
+ NS_METHOD SetStyleContextForFirstPass(nsIPresContext* aPresContext);
+
};
#endif
diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp
index 0aad54753a6e..04969bb77828 100644
--- a/layout/html/table/src/nsTableFrame.cpp
+++ b/layout/html/table/src/nsTableFrame.cpp
@@ -485,8 +485,7 @@ PRBool nsTableFrame::NeedsReflow(const nsSize& aMaxSize)
shrinkWrap Cells in each row to tallest, realigning contents within the cell
*/
-/** Layout the entire inner table.
- */
+/* Layout the entire inner table. */
NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
@@ -578,9 +577,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
mChildCount = 0;
mFirstContentOffset = mLastContentOffset = 0;
- nsIContent* c = mContent;
- NS_ASSERTION(nsnull != c, "null content");
- nsTablePart* table = (nsTablePart*)c;
+ NS_ASSERTION(nsnull != mContent, "null content");
+ nsTablePart* table = (nsTablePart*)mContent;
// Ensure the cell map
table->EnsureCellMap();
@@ -594,7 +592,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
nscoord maxAscent = 0;
nscoord maxDescent = 0;
PRInt32 kidIndex = 0;
- PRInt32 lastIndex = c->ChildCount();
+ PRInt32 lastIndex = table->ChildCount();
PRInt32 contentOffset=0;
nsIFrame* prevKidFrame = nsnull;/* XXX incremental reflow! */
@@ -616,7 +614,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
* TBody, in order
*/
for (;;) {
- nsIContentPtr kid = c->ChildAt(kidIndex); // kid: REFCNT++
+ nsIContentPtr kid = table->ChildAt(kidIndex); // kid: REFCNT++
if (kid.IsNull()) {
result = NS_FRAME_COMPLETE;
break;
@@ -625,7 +623,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
mLastContentIsComplete = PR_TRUE;
const PRInt32 contentType = ((nsTableContent *)(nsIContent*)kid)->GetType();
- if (contentType==nsITableContent::kTableRowGroupType)
+ /*
+ if (contentType==nsITableContent::kTableColGroupType)
{
// Resolve style
nsIStyleContextPtr kidStyleContext =
@@ -641,7 +640,40 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
else
ChildAt(0, kidFrame);
- // if this is the first time, allocate the caption frame
+ // if this is the first time, allocate the frame
+ if (nsnull==kidFrame)
+ {
+ nsIContentDelegate* kidDel;
+ kidDel = kid->GetDelegate(aPresContext);
+ nsresult rv = kidDel->CreateFrame(aPresContext, kid,
+ this, kidStyleContext, kidFrame);
+ NS_RELEASE(kidDel);
+ }
+
+ // reflow the column group
+ nsReflowState kidReflowState(eReflowReason_Resize, availSize);
+ result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
+ kidFrame->SetRect(0,0,0,0);
+ }
+ else */
+ //if (contentType==nsITableContent::kTableRowGroupType)
+ if (contentType!=nsITableContent::kTableCaptionType)
+ {
+ // Resolve style
+ nsIStyleContextPtr kidStyleContext =
+ aPresContext->ResolveStyleContextFor(kid, this);
+ NS_ASSERTION(kidStyleContext.IsNotNull(), "null style context for kid");
+
+ // SEC: TODO: when content is appended or deleted, be sure to clear out the frame hierarchy!!!!
+
+ // get next frame, creating one if needed
+ nsIFrame* kidFrame=nsnull;
+ if (nsnull!=prevKidFrame)
+ prevKidFrame->GetNextSibling(kidFrame); // no need to check for an error, just see if it returned null...
+ else
+ ChildAt(0, kidFrame);
+
+ // if this is the first time, allocate the frame
if (nsnull==kidFrame)
{
nsIContentDelegate* kidDel;
@@ -1003,8 +1035,9 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
nsIContentPtr kid;
kidFrame->GetContent(kid.AssignRef());
- if (((nsTableContent *)(nsIContent*)kid)->GetType() == nsITableContent::kTableRowGroupType)
- { // skip children that are not row groups
+ const int contentType = ((nsTableContent *)(nsIContent*)kid)->GetType();
+ if (contentType != nsITableContent::kTableCaptionType)
+ { // for all colgroups and rowgroups...
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
@@ -1051,13 +1084,16 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
aState.y += topMargin;
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
kidRect.x += aState.leftInset + kidMargin.left;
- kidRect.y += aState.topInset + aState.y ;
- PlaceChild(aPresContext, aState, kidFrame, kidRect,
- aMaxElementSize, kidMaxElementSize);
- if (bottomMargin < 0) {
- aState.prevMaxNegBottomMargin = -bottomMargin;
- } else {
- aState.prevMaxPosBottomMargin = bottomMargin;
+ kidRect.y += aState.topInset + aState.y;
+ if (contentType == nsITableContent::kTableRowGroupType)
+ {
+ PlaceChild(aPresContext, aState, kidFrame, kidRect,
+ aMaxElementSize, kidMaxElementSize);
+ if (bottomMargin < 0) {
+ aState.prevMaxNegBottomMargin = -bottomMargin;
+ } else {
+ aState.prevMaxPosBottomMargin = bottomMargin;
+ }
}
childCount++;
@@ -1266,7 +1302,15 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
//kidRect.x += kidMol->margin.left;
kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
+ nsIContent* content=nsnull;
+ kidFrame->GetContent(content);
+ NS_ASSERTION(nsnull!=content, "bad kid");
+ const int contentType = ((nsITableContent*)content)->GetType();
+ NS_RELEASE(content);
+ if (contentType == nsITableContent::kTableRowGroupType)
+ {
+ PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
+ }
// Remove the frame from its current parent
kidFrame->GetNextSibling(nextInFlow->mFirstChild);
@@ -1473,7 +1517,15 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
//aState.y += topMargin;
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
+ nsIContent* content=nsnull;
+ kidFrame->GetContent(content);
+ NS_ASSERTION(nsnull!=content, "bad kid");
+ const int contentType = ((nsITableContent*)content)->GetType();
+ NS_RELEASE(content);
+ if (contentType == nsITableContent::kTableRowGroupType)
+ {
+ PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
+ }
// Link child frame into the list of children
if (nsnull != prevKidFrame) {
diff --git a/layout/html/table/src/nsTablePart.cpp b/layout/html/table/src/nsTablePart.cpp
index 0c0d4abaa767..3be7bce87a19 100644
--- a/layout/html/table/src/nsTablePart.cpp
+++ b/layout/html/table/src/nsTablePart.cpp
@@ -1027,11 +1027,26 @@ void nsTablePart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
{
nsHTMLValue val;
+
if (aAttribute == nsHTMLAtoms::width)
{
ParseValueOrPercent(aValue, val, eHTMLUnit_Pixel);
nsHTMLTagContent::SetAttribute(aAttribute, val);
}
+ else if ( aAttribute == nsHTMLAtoms::cols)
+ { // it'll either be empty, or have an integer value
+ nsHTMLValue val;
+ nsAutoString tmp(aValue);
+ tmp.StripWhitespace();
+ if (0 == tmp.Length()) {
+ val.SetEmptyValue();
+ }
+ else
+ {
+ ParseValue(aValue, 0, val, eHTMLUnit_Integer);
+ }
+ nsHTMLTagContent::SetAttribute(aAttribute, val);
+ }
else if ( aAttribute == nsHTMLAtoms::border)
{
nsHTMLValue val;
diff --git a/layout/tables/nsTableColGroupFrame.cpp b/layout/tables/nsTableColGroupFrame.cpp
index 4e6c6ae9a83e..274f410686ee 100644
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -20,6 +20,14 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
+#include "nsIPtr.h"
+#include "nsIContentDelegate.h"
+#include "nsTablePart.h"
+#include "nsTableContent.h"
+#include "nsHTMLAtoms.h"
+
+NS_DEF_PTR(nsIContent);
+NS_DEF_PTR(nsIStyleContext);
static PRBool gsDebug = PR_FALSE;
@@ -43,15 +51,65 @@ NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
return NS_OK;
}
-
-NS_METHOD
-nsTableColGroupFrame::ResizeReflow(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsReflowState& aReflowState,
- nsReflowStatus& aStatus)
+// TODO: content changed notifications
+NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsReflowState& aReflowState,
+ nsReflowStatus& aStatus)
{
NS_ASSERTION(nsnull!=aPresContext, "bad arg");
- if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::Reflow\n");
+ NS_ASSERTION(nsnull!=mContent, "bad state -- null content for frame");
+
+ if (nsnull == mFirstChild)
+ { // if we don't have any children, create them
+ nsIFrame* kidFrame = nsnull;
+ nsIFrame* prevKidFrame;
+
+ LastChild(prevKidFrame); // XXX remember this...
+ PRInt32 kidIndex = 0;
+ for (;;)
+ {
+ nsIContentPtr kid = mContent->ChildAt(kidIndex); // kid: REFCNT++
+ if (kid.IsNull()) {
+ break;
+ }
+
+ // Resolve style
+ nsIStyleContextPtr kidSC =
+ aPresContext->ResolveStyleContextFor(kid, this);
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(eStyleStruct_Spacing);
+
+ // Create a child frame
+ nsIContentDelegate* kidDel = nsnull;
+ kidDel = kid->GetDelegate(aPresContext);
+ nsresult rv = kidDel->CreateFrame(aPresContext, kid, this, kidSC,
+ kidFrame);
+ NS_RELEASE(kidDel);
+
+ // give the child frame a chance to reflow, even though we know it'll have 0 size
+ nsReflowMetrics kidSize(nsnull);
+ nsReflowState kidReflowState(eReflowReason_Initial, nsSize(0,0));
+ kidFrame->WillReflow(*aPresContext);
+ nsReflowStatus status = ReflowChild(kidFrame,aPresContext, kidSize,
+ kidReflowState);
+ // note that DidReflow is called as the result of some ancestor firing off a DidReflow above me
+ kidFrame->SetRect(nsRect(0,0,0,0));
+
+ // Link child frame into the list of children
+ if (nsnull != prevKidFrame) {
+ prevKidFrame->SetNextSibling(kidFrame);
+ } else {
+ mFirstChild = kidFrame; // our first child
+ SetFirstContentOffset(kidFrame);
+ }
+ prevKidFrame = kidFrame;
+ mChildCount++;
+ kidIndex++;
+ }
+ // now that I have all my COL children, adjust their style
+ SetStyleContextForFirstPass(aPresContext);
+ }
aDesiredSize.width=0;
aDesiredSize.height=0;
if (nsnull!=aDesiredSize.maxElementSize)
@@ -63,6 +121,65 @@ nsTableColGroupFrame::ResizeReflow(nsIPresContext* aPresContext,
return NS_OK;
}
+// 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);
+
+ // if COLS is set, then map it into the COL frames
+ // chicken and egg problem here. I don't have any children yet, so I
+ // don't know how many columns there are, so I can't do this!
+ // I need to just set some state, and let the individual columns query up into me
+ // in their own hooks
+ PRInt32 numCols;
+ if (result == eContentAttr_NoValue)
+ ChildCount(numCols);
+ else if (result == eContentAttr_HasValue)
+ {
+ nsHTMLUnit unit = value.GetUnit();
+ if (eHTMLUnit_Empty==unit)
+ ChildCount(numCols);
+ else
+ numCols = value.GetIntValue();
+ }
+
+ PRInt32 colIndex=0;
+ nsIFrame *colFrame;
+ FirstChild(colFrame);
+ for (; colIndexGetStyleData(eStyleStruct_Position, (nsStyleStruct*&)colPosition);
+ nsStyleCoord width (1, eStyleUnit_Proportional);
+ colPosition->mWidth = width;
+ colFrame->GetNextSibling(colFrame);
+ }
+ // if there are more columns, there width is set to "minimum"
+ PRInt32 numChildFrames;
+ ChildCount(numChildFrames);
+ for (; colIndexGetStyleData(eStyleStruct_Position, (nsStyleStruct*&)colPosition);
+ nsStyleCoord width (0, eStyleUnit_Integer);
+ colPosition->mWidth = width;
+ colFrame->GetNextSibling(colFrame);
+ }
+
+ mStyleContext->RecalcAutomaticData(aPresContext);
+ return NS_OK;
+}
+
nsresult nsTableColGroupFrame::NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent)
diff --git a/layout/tables/nsTableColGroupFrame.h b/layout/tables/nsTableColGroupFrame.h
index 3c02512449ff..e95ff0dcd0b6 100644
--- a/layout/tables/nsTableColGroupFrame.h
+++ b/layout/tables/nsTableColGroupFrame.h
@@ -39,10 +39,16 @@ public:
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
- NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsReflowState& aReflowState,
- nsReflowStatus& aStatus);
+ /** reflow of a column group is a trivial matter of reflowing
+ * the col group's children (columns), and setting this frame
+ * to 0-size. Since tables are row-centric, column group frames
+ * don't play directly in the rendering game. They do however
+ * maintain important state that effects table and cell layout.
+ */
+ NS_IMETHOD Reflow(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsReflowState& aReflowState,
+ nsReflowStatus& aStatus);
protected:
@@ -50,6 +56,12 @@ protected:
~nsTableColGroupFrame();
+ /** Hook for style post processing.
+ * Since we need to know the full column structure before the COLS attribute
+ * can be interpreted, we can't just use DidSetStyleContext
+ */
+ NS_METHOD SetStyleContextForFirstPass(nsIPresContext* aPresContext);
+
};
#endif
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
index 0aad54753a6e..04969bb77828 100644
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -485,8 +485,7 @@ PRBool nsTableFrame::NeedsReflow(const nsSize& aMaxSize)
shrinkWrap Cells in each row to tallest, realigning contents within the cell
*/
-/** Layout the entire inner table.
- */
+/* Layout the entire inner table. */
NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsReflowState& aReflowState,
@@ -578,9 +577,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
mChildCount = 0;
mFirstContentOffset = mLastContentOffset = 0;
- nsIContent* c = mContent;
- NS_ASSERTION(nsnull != c, "null content");
- nsTablePart* table = (nsTablePart*)c;
+ NS_ASSERTION(nsnull != mContent, "null content");
+ nsTablePart* table = (nsTablePart*)mContent;
// Ensure the cell map
table->EnsureCellMap();
@@ -594,7 +592,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
nscoord maxAscent = 0;
nscoord maxDescent = 0;
PRInt32 kidIndex = 0;
- PRInt32 lastIndex = c->ChildCount();
+ PRInt32 lastIndex = table->ChildCount();
PRInt32 contentOffset=0;
nsIFrame* prevKidFrame = nsnull;/* XXX incremental reflow! */
@@ -616,7 +614,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
* TBody, in order
*/
for (;;) {
- nsIContentPtr kid = c->ChildAt(kidIndex); // kid: REFCNT++
+ nsIContentPtr kid = table->ChildAt(kidIndex); // kid: REFCNT++
if (kid.IsNull()) {
result = NS_FRAME_COMPLETE;
break;
@@ -625,7 +623,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
mLastContentIsComplete = PR_TRUE;
const PRInt32 contentType = ((nsTableContent *)(nsIContent*)kid)->GetType();
- if (contentType==nsITableContent::kTableRowGroupType)
+ /*
+ if (contentType==nsITableContent::kTableColGroupType)
{
// Resolve style
nsIStyleContextPtr kidStyleContext =
@@ -641,7 +640,40 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
else
ChildAt(0, kidFrame);
- // if this is the first time, allocate the caption frame
+ // if this is the first time, allocate the frame
+ if (nsnull==kidFrame)
+ {
+ nsIContentDelegate* kidDel;
+ kidDel = kid->GetDelegate(aPresContext);
+ nsresult rv = kidDel->CreateFrame(aPresContext, kid,
+ this, kidStyleContext, kidFrame);
+ NS_RELEASE(kidDel);
+ }
+
+ // reflow the column group
+ nsReflowState kidReflowState(eReflowReason_Resize, availSize);
+ result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState);
+ kidFrame->SetRect(0,0,0,0);
+ }
+ else */
+ //if (contentType==nsITableContent::kTableRowGroupType)
+ if (contentType!=nsITableContent::kTableCaptionType)
+ {
+ // Resolve style
+ nsIStyleContextPtr kidStyleContext =
+ aPresContext->ResolveStyleContextFor(kid, this);
+ NS_ASSERTION(kidStyleContext.IsNotNull(), "null style context for kid");
+
+ // SEC: TODO: when content is appended or deleted, be sure to clear out the frame hierarchy!!!!
+
+ // get next frame, creating one if needed
+ nsIFrame* kidFrame=nsnull;
+ if (nsnull!=prevKidFrame)
+ prevKidFrame->GetNextSibling(kidFrame); // no need to check for an error, just see if it returned null...
+ else
+ ChildAt(0, kidFrame);
+
+ // if this is the first time, allocate the frame
if (nsnull==kidFrame)
{
nsIContentDelegate* kidDel;
@@ -1003,8 +1035,9 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
nsIContentPtr kid;
kidFrame->GetContent(kid.AssignRef());
- if (((nsTableContent *)(nsIContent*)kid)->GetType() == nsITableContent::kTableRowGroupType)
- { // skip children that are not row groups
+ const int contentType = ((nsTableContent *)(nsIContent*)kid)->GetType();
+ if (contentType != nsITableContent::kTableCaptionType)
+ { // for all colgroups and rowgroups...
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
@@ -1051,13 +1084,16 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
aState.y += topMargin;
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
kidRect.x += aState.leftInset + kidMargin.left;
- kidRect.y += aState.topInset + aState.y ;
- PlaceChild(aPresContext, aState, kidFrame, kidRect,
- aMaxElementSize, kidMaxElementSize);
- if (bottomMargin < 0) {
- aState.prevMaxNegBottomMargin = -bottomMargin;
- } else {
- aState.prevMaxPosBottomMargin = bottomMargin;
+ kidRect.y += aState.topInset + aState.y;
+ if (contentType == nsITableContent::kTableRowGroupType)
+ {
+ PlaceChild(aPresContext, aState, kidFrame, kidRect,
+ aMaxElementSize, kidMaxElementSize);
+ if (bottomMargin < 0) {
+ aState.prevMaxNegBottomMargin = -bottomMargin;
+ } else {
+ aState.prevMaxPosBottomMargin = bottomMargin;
+ }
}
childCount++;
@@ -1266,7 +1302,15 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
//kidRect.x += kidMol->margin.left;
kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
+ nsIContent* content=nsnull;
+ kidFrame->GetContent(content);
+ NS_ASSERTION(nsnull!=content, "bad kid");
+ const int contentType = ((nsITableContent*)content)->GetType();
+ NS_RELEASE(content);
+ if (contentType == nsITableContent::kTableRowGroupType)
+ {
+ PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
+ }
// Remove the frame from its current parent
kidFrame->GetNextSibling(nextInFlow->mFirstChild);
@@ -1473,7 +1517,15 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
//aState.y += topMargin;
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
+ nsIContent* content=nsnull;
+ kidFrame->GetContent(content);
+ NS_ASSERTION(nsnull!=content, "bad kid");
+ const int contentType = ((nsITableContent*)content)->GetType();
+ NS_RELEASE(content);
+ if (contentType == nsITableContent::kTableRowGroupType)
+ {
+ PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
+ }
// Link child frame into the list of children
if (nsnull != prevKidFrame) {