diff --git a/mozilla/layout/forms/nsFieldSetFrame.cpp b/mozilla/layout/forms/nsFieldSetFrame.cpp
index 54f598588ab..d73b68b82c8 100644
--- a/mozilla/layout/forms/nsFieldSetFrame.cpp
+++ b/mozilla/layout/forms/nsFieldSetFrame.cpp
@@ -122,11 +122,8 @@ nsFieldSetFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
- if (mInline) {
- NS_NewInlineFrame(mContent, this, mFirstChild);
- } else {
- NS_NewBodyFrame(mContent, this, mFirstChild, PR_FALSE);
- }
+ PRUint8 flags = (mInline) ? NS_BODY_SHRINK_WRAP : 0;
+ NS_NewBodyFrame(mContent, this, mFirstChild, flags);
mContentFrame = mFirstChild;
// Resolve style and set the style context
@@ -156,7 +153,7 @@ nsFieldSetFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
mFirstChild->SetNextSibling(frame);
mLegendFrame = frame;
mLegendFrame->SetNextSibling(nsnull);
- } else {
+ } else {
frame->SetGeometricParent(mFirstChild);
frame->SetContentParent(mFirstChild);
}
@@ -405,7 +402,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
if (nsnull != aDesiredSize.maxElementSize) {
- *aDesiredSize.maxElementSize = maxElementSize;
+ aDesiredSize.maxElementSize->width = maxElementSize.width + borderPadding.left + borderPadding.right;
+ aDesiredSize.maxElementSize->height = maxElementSize.height + borderPadding.top + borderPadding.bottom;
}
aStatus = NS_FRAME_COMPLETE;
diff --git a/mozilla/layout/forms/nsLegendFrame.cpp b/mozilla/layout/forms/nsLegendFrame.cpp
index 7cf072ab28d..71c3a75cdbf 100644
--- a/mozilla/layout/forms/nsLegendFrame.cpp
+++ b/mozilla/layout/forms/nsLegendFrame.cpp
@@ -94,11 +94,8 @@ nsLegendFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
- if (mInline) {
- NS_NewInlineFrame(mContent, this, mFirstChild);
- } else {
- NS_NewBodyFrame(mContent, this, mFirstChild, PR_FALSE);
- }
+ PRUint8 flags = (mInline) ? NS_BODY_SHRINK_WRAP : 0;
+ NS_NewBodyFrame(mContent, this, mFirstChild, flags);
// Resolve style and set the style context
nsIStyleContext* styleContext =
@@ -132,19 +129,29 @@ nsLegendFrame::Reflow(nsIPresContext& aPresContext,
{
nsSize availSize(aReflowState.maxSize);
- // Try to reflow the child into the available space. It might not fit
+ // reflow the child
nsHTMLReflowState reflowState(mFirstChild, aReflowState, availSize);
- //nsIHTMLReflow* htmlReflow = nsnull;
- //if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
- //htmlReflow->WillReflow(aPresContext);
- //mFirstChild->MoveTo(0, 0);
- ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState, aStatus);
- //}
+ ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState, aStatus);
+
+ // get border and padding
+ const nsStyleSpacing* spacing =
+ (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
+ nsMargin borderPadding;
+ spacing->CalcBorderPaddingFor(this, borderPadding);
// Place the child
- nsRect rect = nsRect(0, 0, aDesiredSize.width, aDesiredSize.height);
+ nsRect rect = nsRect(borderPadding.left, borderPadding.top, aDesiredSize.width, aDesiredSize.height);
mFirstChild->SetRect(rect);
+ // add in our border and padding to the size of the child
+ aDesiredSize.width += borderPadding.left + borderPadding.right;
+ aDesiredSize.height += borderPadding.top + borderPadding.bottom;
+
+ // adjust our max element size, if necessary
+ if (aDesiredSize.maxElementSize) {
+ aDesiredSize.maxElementSize->width += borderPadding.left + borderPadding.right;
+ aDesiredSize.maxElementSize->height += borderPadding.top + borderPadding.bottom;
+ }
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
diff --git a/mozilla/layout/html/document/src/ua.css b/mozilla/layout/html/document/src/ua.css
index cbbcb367fd8..3976b9f0732 100644
--- a/mozilla/layout/html/document/src/ua.css
+++ b/mozilla/layout/html/document/src/ua.css
@@ -291,7 +291,7 @@ NOBR {
white-space: nowrap;
}
LEGEND {
- display: block;
+ display: inline;
padding-left: 2px;
padding-right: 2px;
border: 2px solid black;
diff --git a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp
index 54f598588ab..d73b68b82c8 100644
--- a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp
@@ -122,11 +122,8 @@ nsFieldSetFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
- if (mInline) {
- NS_NewInlineFrame(mContent, this, mFirstChild);
- } else {
- NS_NewBodyFrame(mContent, this, mFirstChild, PR_FALSE);
- }
+ PRUint8 flags = (mInline) ? NS_BODY_SHRINK_WRAP : 0;
+ NS_NewBodyFrame(mContent, this, mFirstChild, flags);
mContentFrame = mFirstChild;
// Resolve style and set the style context
@@ -156,7 +153,7 @@ nsFieldSetFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
mFirstChild->SetNextSibling(frame);
mLegendFrame = frame;
mLegendFrame->SetNextSibling(nsnull);
- } else {
+ } else {
frame->SetGeometricParent(mFirstChild);
frame->SetContentParent(mFirstChild);
}
@@ -405,7 +402,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
if (nsnull != aDesiredSize.maxElementSize) {
- *aDesiredSize.maxElementSize = maxElementSize;
+ aDesiredSize.maxElementSize->width = maxElementSize.width + borderPadding.left + borderPadding.right;
+ aDesiredSize.maxElementSize->height = maxElementSize.height + borderPadding.top + borderPadding.bottom;
}
aStatus = NS_FRAME_COMPLETE;
diff --git a/mozilla/layout/html/forms/src/nsLegendFrame.cpp b/mozilla/layout/html/forms/src/nsLegendFrame.cpp
index 7cf072ab28d..71c3a75cdbf 100644
--- a/mozilla/layout/html/forms/src/nsLegendFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsLegendFrame.cpp
@@ -94,11 +94,8 @@ nsLegendFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
- if (mInline) {
- NS_NewInlineFrame(mContent, this, mFirstChild);
- } else {
- NS_NewBodyFrame(mContent, this, mFirstChild, PR_FALSE);
- }
+ PRUint8 flags = (mInline) ? NS_BODY_SHRINK_WRAP : 0;
+ NS_NewBodyFrame(mContent, this, mFirstChild, flags);
// Resolve style and set the style context
nsIStyleContext* styleContext =
@@ -132,19 +129,29 @@ nsLegendFrame::Reflow(nsIPresContext& aPresContext,
{
nsSize availSize(aReflowState.maxSize);
- // Try to reflow the child into the available space. It might not fit
+ // reflow the child
nsHTMLReflowState reflowState(mFirstChild, aReflowState, availSize);
- //nsIHTMLReflow* htmlReflow = nsnull;
- //if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
- //htmlReflow->WillReflow(aPresContext);
- //mFirstChild->MoveTo(0, 0);
- ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState, aStatus);
- //}
+ ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState, aStatus);
+
+ // get border and padding
+ const nsStyleSpacing* spacing =
+ (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
+ nsMargin borderPadding;
+ spacing->CalcBorderPaddingFor(this, borderPadding);
// Place the child
- nsRect rect = nsRect(0, 0, aDesiredSize.width, aDesiredSize.height);
+ nsRect rect = nsRect(borderPadding.left, borderPadding.top, aDesiredSize.width, aDesiredSize.height);
mFirstChild->SetRect(rect);
+ // add in our border and padding to the size of the child
+ aDesiredSize.width += borderPadding.left + borderPadding.right;
+ aDesiredSize.height += borderPadding.top + borderPadding.bottom;
+
+ // adjust our max element size, if necessary
+ if (aDesiredSize.maxElementSize) {
+ aDesiredSize.maxElementSize->width += borderPadding.left + borderPadding.right;
+ aDesiredSize.maxElementSize->height += borderPadding.top + borderPadding.bottom;
+ }
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
diff --git a/mozilla/layout/style/ua.css b/mozilla/layout/style/ua.css
index cbbcb367fd8..3976b9f0732 100644
--- a/mozilla/layout/style/ua.css
+++ b/mozilla/layout/style/ua.css
@@ -291,7 +291,7 @@ NOBR {
white-space: nowrap;
}
LEGEND {
- display: block;
+ display: inline;
padding-left: 2px;
padding-right: 2px;
border: 2px solid black;
diff --git a/mozilla/webshell/tests/viewer/samples/test8.html b/mozilla/webshell/tests/viewer/samples/test8.html
index b3eb6cfdebb..3dfaa772526 100644
--- a/mozilla/webshell/tests/viewer/samples/test8.html
+++ b/mozilla/webshell/tests/viewer/samples/test8.html
@@ -24,24 +24,23 @@ SELECT#select1 {