diff --git a/mozilla/content/html/style/src/nsCSSLayout.cpp b/mozilla/content/html/style/src/nsCSSLayout.cpp
index 851cb7aa850..19236ff8cb5 100644
--- a/mozilla/content/html/style/src/nsCSSLayout.cpp
+++ b/mozilla/content/html/style/src/nsCSSLayout.cpp
@@ -25,7 +25,7 @@
#include "nsRect.h"
#include "nsIPtr.h"
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
NS_DEF_PTR(nsIStyleContext);
@@ -64,10 +64,8 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
kid->GetStyleContext(aCX, kidSC.AssignRef());
kid->GetContent(kidContent.AssignRef());
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- PRIntn verticalAlign = kidMol->verticalAlign;
- float verticalAlignPct = kidMol->verticalAlignPct;
+ nsStyleText* textStyle = (nsStyleText*)kidSC->GetData(kStyleTextSID);
+ PRIntn verticalAlign = textStyle->mVerticalAlign;
kid->GetRect(kidRect);
@@ -146,9 +144,8 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
kid->GetStyleContext(aCX, kidSC.AssignRef());
kid->GetContent(kidContent.AssignRef());
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- PRIntn verticalAlign = kidMol->verticalAlign;
+ nsStyleText* textStyle = (nsStyleText*)kidSC->GetData(kStyleTextSID);
+ PRIntn verticalAlign = textStyle->mVerticalAlign;
// Vertically align the child
if (verticalAlign == NS_STYLE_VERTICAL_ALIGN_BOTTOM) {
@@ -174,14 +171,13 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
*/
void nsCSSLayout::HorizontallyPlaceChildren(nsIPresContext* aCX,
nsIFrame* aContainer,
- nsStyleMolecule* aContainerStyle,
+ nsStyleText* aContainerStyle,
nsIFrame* aFirstChild,
PRInt32 aChildCount,
nscoord aLineWidth,
nscoord aMaxWidth)
{
- PRIntn textAlign = aContainerStyle->textAlign;
-
+ PRIntn textAlign = aContainerStyle->mTextAlign;
nscoord dx = 0;
switch (textAlign) {
case NS_STYLE_TEXT_ALIGN_LEFT:
@@ -213,7 +209,6 @@ void nsCSSLayout::HorizontallyPlaceChildren(nsIPresContext* aCX,
*/
void nsCSSLayout::RelativePositionChildren(nsIPresContext* aCX,
nsIFrame* aContainer,
- nsStyleMolecule* aContainerStyle,
nsIFrame* aFirstChild,
PRInt32 aChildCount)
{
@@ -225,7 +220,8 @@ void nsCSSLayout::RelativePositionChildren(nsIPresContext* aCX,
kid->GetContent(kidContent.AssignRef());
kid->GetStyleContext(aCX, kidSC.AssignRef());
- nsStylePosition* kidPosition = (nsStylePosition*)kidSC->GetData(kStylePositionSID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidSC->GetData(kStylePositionSID);
if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
kid->GetOrigin(origin);
// XXX Check the flags: could be auto or percent (not just length)
diff --git a/mozilla/layout/base/src/nsContainerFrame.cpp b/mozilla/layout/base/src/nsContainerFrame.cpp
index 44d340f6dc1..df12feb1dc2 100644
--- a/mozilla/layout/base/src/nsContainerFrame.cpp
+++ b/mozilla/layout/base/src/nsContainerFrame.cpp
@@ -35,6 +35,7 @@
#undef NOISY
#endif
+static NS_DEFINE_IID(kIStyleSpacingSID, NS_STYLESPACING_SID);
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
nsContainerFrame::nsContainerFrame(nsIContent* aContent,
@@ -435,7 +436,6 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsIFrame::ReflowStatus
nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
- nsStyleMolecule* aKidMol,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
@@ -487,6 +487,9 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
// Get the bounding rect of the available trapezoid
nsRect rect;
+ nsIStyleContext* kidSC;
+ aKidFrame->GetStyleContext(aPresContext, kidSC);
+ nsStyleSpacing* spacing = (nsStyleSpacing*)kidSC->GetData(kIStyleSpacingSID);
availSpace->GetRect(rect);
if (aMaxSize.width != NS_UNCONSTRAINEDSIZE) {
@@ -496,13 +499,13 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
}
// Reduce the available width by the kid's left/right margin
- availSize.width -= aKidMol->margin.left + aKidMol->margin.right;
+ availSize.width -= spacing->mMargin.left + spacing->mMargin.right;
}
// Does the child frame support interface nsIRunaround?
if (NS_OK == aKidFrame->QueryInterface(kIRunaroundIID, (void**)&reflowRunaround)) {
// Yes, the child frame wants to interact directly with the space manager.
- nscoord tx = rect.x + aKidMol->margin.left;
+ nscoord tx = rect.x + spacing->mMargin.left;
// Translate the local coordinate space to the current left edge plus any
// left margin the child wants
@@ -543,6 +546,8 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
((nsContainerFrame*)parent)->DeleteChildsNextInFlow(aKidFrame);
}
}
+
+ NS_RELEASE(kidSC);
return status;
}
diff --git a/mozilla/layout/base/src/nsContainerFrame.h b/mozilla/layout/base/src/nsContainerFrame.h
index d5ca5d2e775..9188465737a 100644
--- a/mozilla/layout/base/src/nsContainerFrame.h
+++ b/mozilla/layout/base/src/nsContainerFrame.h
@@ -20,8 +20,6 @@
#include "nsSplittableFrame.h"
-struct nsStyleMolecule;
-
/**
* Implementation of a container frame. Supports being used a pseudo-
* frame (a frame that maps the same content as its parent).
@@ -239,7 +237,6 @@ protected:
*/
ReflowStatus ReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
- nsStyleMolecule* aKidMol,
nsISpaceManager* aSpaceManager,
const nsSize& aMaxSize,
nsRect& aDesiredRect,
diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp
index 8697f2d49a7..84fd53b081b 100644
--- a/mozilla/layout/generic/nsBlockFrame.cpp
+++ b/mozilla/layout/generic/nsBlockFrame.cpp
@@ -48,9 +48,12 @@
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
static NS_DEFINE_IID(kIFloaterContainerIID, NS_IFLOATERCONTAINER_IID);
static NS_DEFINE_IID(kIAnchoredItemsIID, NS_IANCHOREDITEMS_IID);
-static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -100,8 +103,7 @@ nsBlockReflowState::nsBlockReflowState()
void nsBlockReflowState::Init(const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleFont* aFont,
- nsStyleMolecule* aMol,
+ nsIStyleContext* aBlockSC,
nsISpaceManager* aSpaceManager)
{
firstLine = PR_TRUE;
@@ -114,8 +116,15 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
spaceManager = aSpaceManager;
currentBand = new BlockBandData;
- font = aFont;
- mol = aMol;
+
+ styleContext = aBlockSC;
+ styleText = (nsStyleText*) aBlockSC->GetData(kStyleTextSID);
+ styleFont = (nsStyleFont*) aBlockSC->GetData(kStyleFontSID);
+ styleDisplay = (nsStyleDisplay*) aBlockSC->GetData(kStyleDisplaySID);
+
+ justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign) &&
+ (NS_STYLE_WHITESPACE_PRE != styleText->mWhiteSpace);
+
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
maxElementSize = aMaxElementSize;
@@ -155,8 +164,6 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
- justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mol->textAlign) &&
- (NS_STYLE_WHITESPACE_PRE != mol->whiteSpace);
reflowStatus = nsIFrame::frNotComplete;
}
@@ -300,11 +307,11 @@ nsBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
// type and the display type of the previous child frame.
//
// Adjacent vertical margins between block-level elements are collapsed.
-nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
+nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
nsBlockReflowState& aState,
- nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol,
- PRBool aIsInline)
+ nsIFrame* aKidFrame,
+ nsIStyleContext* aKidSC,
+ PRBool aIsInline)
{
if (aIsInline) {
// Just use whatever the previous bottom margin was
@@ -318,10 +325,11 @@ nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
if (nsnull == kidPrevInFlow) {
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if (aKidMol->margin.top < 0) {
- maxNegTopMargin = -aKidMol->margin.top;
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ if (ss->mMargin.top < 0) {
+ maxNegTopMargin = -ss->mMargin.top;
} else {
- maxPosTopMargin = aKidMol->margin.top;
+ maxPosTopMargin = ss->mMargin.top;
}
nscoord maxPos = PR_MAX(aState.prevMaxPosBottomMargin, maxPosTopMargin);
@@ -354,20 +362,22 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
floater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* sd = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
floater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == sd->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == sd->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
// XXX Don't forget the floater's margins...
- mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left, 0);
+ mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left,
+ 0);
mCurrentState->spaceManager->AddRectRegion(region, floater);
// Set the origin of the floater in world coordinates
@@ -398,9 +408,13 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
if (aState.isInline) {
// Vertically align the children on this line, returning the height of
// the line upon completion.
- lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this, aState.font, y,
- aState.lineStart, aState.lineLength,
- aState.ascents, aState.maxAscent);
+ lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this,
+ aState.styleFont,
+ y,
+ aState.lineStart,
+ aState.lineLength,
+ aState.ascents,
+ aState.maxAscent);
// Any below current line floaters to place?
if (aState.floaterToDo.Count() > 0) {
@@ -445,7 +459,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// doing an unconstrained (in x) reflow. There's no point in doing
// the work if we *know* we are going to reflowed again.
if (!aState.unconstrainedWidth) {
- nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.mol,
+ nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.styleText,
aState.lineStart, aState.lineLength,
aState.lineWidth,
aState.availSize.width);
@@ -453,7 +467,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
if (!aState.justifying) {
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
+ nsCSSLayout::RelativePositionChildren(aCX, this,
aState.lineStart,
aState.lineLength);
}
@@ -499,17 +513,15 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsReflowMetrics& aKidSize,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
- PRIntn direction = aState.mol->direction;
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
@@ -519,15 +531,16 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
r.y = aState.y;
r.width = aKidSize.width;
r.height = aKidSize.height;
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
// Left to right positioning.
- r.x = aState.borderPadding.left + aState.x + aKidMol->margin.left;
- aState.x += aKidSize.width + aKidMol->margin.left + aKidMol->margin.right;
+ r.x = aState.borderPadding.left + aState.x + ss->mMargin.left;
+ aState.x += aKidSize.width + ss->mMargin.left + ss->mMargin.right;
} else {
// Right to left positioning
// XXX what should we do when aState.x goes negative???
- r.x = aState.x - aState.borderPadding.right - aKidMol->margin.right - aKidSize.width;
- aState.x -= aKidSize.width + aKidMol->margin.right + aKidMol->margin.left;
+ r.x = aState.x - aState.borderPadding.right - ss->mMargin.right -
+ aKidSize.width;
+ aState.x -= aKidSize.width + ss->mMargin.right + ss->mMargin.left;
}
aKidFrame->SetRect(r);
aState.AddAscent(aKidSize.ascent);
@@ -551,7 +564,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
#if 0
// XXX CSS2 spec says that top/bottom margin don't affect line height
// calculation. We're waiting for clarification on this issue...
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = ss->mMargin.top) < 0) {
margin = -margin;
if (margin > aState.maxNegTopMargin) {
aState.maxNegTopMargin = margin;
@@ -562,7 +575,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
}
}
#endif
- if ((margin = aKidMol->margin.bottom) < 0) {
+ if ((margin = ss->mMargin.bottom) < 0) {
margin = -margin;
if (margin > aState.maxNegBottomMargin) {
aState.maxNegBottomMargin = margin;
@@ -593,20 +606,20 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsRect& aKidRect,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
+
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
// Translate from the kid's coordinate space to our coordinate space
- aKidRect.x += aState.borderPadding.left + aKidMol->margin.left;
+ aKidRect.x += aState.borderPadding.left + ss->mMargin.left;
aKidRect.y += aState.y + aState.topMargin;
// Place and size the child
@@ -616,7 +629,7 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
aState.lineLength++;
// Is this the widest child frame?
- nscoord xMost = aKidRect.XMost() + aKidMol->margin.right;
+ nscoord xMost = aKidRect.XMost() + ss->mMargin.right;
if (xMost > aState.kidXMost) {
aState.kidXMost = xMost;
}
@@ -633,17 +646,17 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
// and the bottom line margin information which we'll use when placing
// the next child
- if (aKidMol->margin.bottom < 0) {
- aState.maxNegBottomMargin = -aKidMol->margin.bottom;
+ if (ss->mMargin.bottom < 0) {
+ aState.maxNegBottomMargin = -ss->mMargin.bottom;
} else {
- aState.maxPosBottomMargin = aKidMol->margin.bottom;
+ aState.maxPosBottomMargin = ss->mMargin.bottom;
}
// Update the running y-offset
aState.y += aKidRect.height + aState.topMargin;
// Apply relative positioning if necessary
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol, aKidFrame, 1);
+ nsCSSLayout::RelativePositionChildren(aCX, this, aKidFrame, 1);
// Advance to the next line
aState.AdvanceToNextLine(aKidFrame, aKidRect.height);
@@ -656,19 +669,19 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
*/
void nsBlockFrame::GetAvailSize(nsSize& aResult,
nsBlockReflowState& aState,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline)
{
// Determine the maximum available reflow height for the child
nscoord yb = aState.borderPadding.top + aState.availSize.height;
aResult.height = aState.unconstrainedHeight ? NS_UNCONSTRAINEDSIZE :
- yb - aState.y - aState.topMargin;
+ yb - aState.y - aState.topMargin;
// Determine the maximum available reflow width for the child
if (aState.unconstrainedWidth) {
aResult.width = NS_UNCONSTRAINEDSIZE;
} else if (aIsInline) {
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
} else {
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
@@ -830,13 +843,15 @@ getBand:
}
if (isLeftFloater) {
- if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_LEFT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
}
if (isRightFloater) {
- if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_RIGHT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
@@ -853,7 +868,7 @@ PRIntn
nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
nsSize kidMaxElementSize;
nsSize* pKidMaxElementSize =
@@ -866,17 +881,12 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Get kid and its style
- // XXX How is this any different than what was passed in to us as aKidMol?
- nsIContentPtr kid;
- nsIStyleContextPtr kidSC;
-
- aKidFrame->GetContent(kid.AssignRef());
- aKidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
// Figure out if kid is a block element or not
PRBool isInline = PR_TRUE;
- PRIntn display = kidMol->display;
+ PRIntn display = styleDisplay->mDisplay;
if (aState.firstChildIsInsideBullet && (mFirstChild == aKidFrame)) {
// XXX Special hack for properly reflowing bullets that have the
// inside value for list-style-position.
@@ -909,15 +919,20 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
aState.lineStart = aKidFrame;
- // Get the style for the last child, and see if it wanted to clear floaters.
- // This handles the BR tag, which is the only inline element for which clear
- // applies
+ // Get the style for the last child, and see if it wanted to clear
+ // floaters. This handles the BR tag, which is the only inline
+ // element for which clear applies
nsIStyleContextPtr lastChildSC;
lastFrame->GetStyleContext(aCX, lastChildSC.AssignRef());
- nsStyleMolecule* lastChildMol = (nsStyleMolecule*)lastChildSC->GetData(kStyleMoleculeSID);
- if (lastChildMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, lastChildMol->clear);
+ nsStyleDisplay* lastChildDisplay = (nsStyleDisplay*)
+ lastChildSC->GetData(kStyleDisplaySID);
+ switch (lastChildDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, lastChildDisplay->mBreakType);
+ break;
}
}
@@ -929,7 +944,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// should use
if (aState.lineStart == aKidFrame) {
// Compute the top margin to use for this line
- aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, kidMol, aState.isInline);
+ aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, aKidSC,
+ aState.isInline);
// If it's an inline element then get a band of available space
//
@@ -943,7 +959,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// Compute the available space to reflow the child into and then
// reflow it into that space.
nsSize kidAvailSize;
- GetAvailSize(kidAvailSize, aState, kidMol, aState.isInline);
+ GetAvailSize(kidAvailSize, aState, aKidSC, aState.isInline);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
@@ -990,7 +1006,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
GetAvailableSpaceBand(aState, aState.y + aState.topMargin);
// Reflow child now that it has the line to itself
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
}
@@ -1017,7 +1033,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
if (isSplittable != frNotSplittable) {
// Update size info now that we are on the next line. Then
// reflow the child into the new available space.
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
@@ -1044,21 +1060,27 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Add child to the line
- AddInlineChildToLine(aCX, aState, aKidFrame, kidSize, pKidMaxElementSize, kidMol);
-
+ AddInlineChildToLine(aCX, aState, aKidFrame, kidSize,
+ pKidMaxElementSize, aKidSC);
} else {
nsRect kidRect;
// Does the block-level element want to clear any floaters that impact
// it? Note that the clear property only applies to block-level elements
// and the BR tag
- if (aKidMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, aKidMol->clear);
- GetAvailSize(kidAvailSize, aState, kidMol, PR_FALSE);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
+ switch (styleDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, styleDisplay->mBreakType);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_FALSE);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
}
+ break;
}
// Give the block its own local coordinate space.. Note: ReflowChild()
@@ -1066,8 +1088,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// current left/right edge
aState.spaceManager->Translate(aState.borderPadding.left, 0);
// Give the block-level element the opportunity to use the space manager
- status = ReflowChild(aKidFrame, aCX, kidMol, aState.spaceManager, kidAvailSize,
- kidRect, pKidMaxElementSize);
+ status = ReflowChild(aKidFrame, aCX, aState.spaceManager,
+ kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
// For first children, we skip all the fit checks because we must
@@ -1087,7 +1109,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// calls AdvaneceToNextLine(). We need to restructure the flow of control,
// and use a state machine...
aState.lastContentIsComplete = PRBool(status == frComplete);
- AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, kidMol);
+ AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, aKidSC);
}
// If we just reflowed our last child then update the
@@ -1147,7 +1169,6 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
// Attempt to place and reflow the child
@@ -1155,7 +1176,7 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
// it is, otherwise advance to the next line and place it there if
// possible
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
ReflowStatus status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// The child doesn't fit. Push it and any remaining children.
@@ -1237,8 +1258,9 @@ PRBool nsBlockFrame::MoreToReflow(nsIPresContext* aCX)
if (nsnull != kid) {
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- switch (kidMol->display) {
+ nsStyleDisplay* kidStyleDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
+ switch (kidStyleDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Block pseudo-frames do not contain other block elements
@@ -1303,21 +1325,23 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStylePosition* kidPosition = (nsStylePosition*)kidSC->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidSC->GetData(kStylePositionSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Check whether it wants to floated or absolutely positioned
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
- } else if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
} else if (nsnull == kidPrevInFlow) {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -1378,7 +1402,7 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// complete.
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// We ran out of room.
@@ -1411,7 +1435,6 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
}
#ifdef NS_DEBUG
nsIFrame* kidNextInFlow;
@@ -1493,11 +1516,10 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// Push the kids that didn't fit back down to the next-in-flow
@@ -1534,7 +1556,6 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
} else {
// The child has a next-in-flow, but it's not one of ours.
// It *must* be in one of our next-in-flows. Collect it
@@ -1597,20 +1618,19 @@ void nsBlockFrame::SetupState(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager)
{
// Setup reflow state
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- nsStyleFont* font =
- (nsStyleFont*)mStyleContext->GetData(kStyleFontSID);
- aState.Init(aMaxSize, aMaxElementSize, font, mol, aSpaceManager);
+ aState.Init(aMaxSize, aMaxElementSize, mStyleContext, aSpaceManager);
+
+ nsStyleSpacing* mySpacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
// Apply border and padding adjustments for regular frames only
if (PR_FALSE == IsPseudoFrame()) {
- aState.borderPadding = mol->borderPadding;
- aState.y = mol->borderPadding.top;
+ aState.borderPadding = mySpacing->mBorderPadding;
+ aState.y = mySpacing->mBorderPadding.top;
aState.availSize.width -=
- (mol->borderPadding.left + mol->borderPadding.right);
+ (mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right);
aState.availSize.height -=
- (mol->borderPadding.top + mol->borderPadding.bottom);
+ (mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom);
} else {
aState.borderPadding.SizeTo(0, 0, 0, 0);
}
@@ -1830,8 +1850,7 @@ void nsBlockFrame::JustifyLines(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
- lineStart, mLines[i]);
+ nsCSSLayout::RelativePositionChildren(aCX, this, lineStart, mLines[i]);
}
}
@@ -1952,7 +1971,8 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
aFloater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* floaterDisplay = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
if (!mCurrentState->isInline) {
// Get the current band for this line
@@ -1965,10 +1985,10 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
aFloater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
@@ -1997,9 +2017,10 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
{
// Get the last-in-flow
nsBlockFrame* flow = (nsBlockFrame*)GetLastInFlow();
-
PRInt32 kidIndex = flow->NextChildOffset();
PRInt32 startIndex = kidIndex;
+
+#if 0
nsIFrame* kidFrame = nsnull;
nsIFrame* prevKidFrame;
@@ -2013,16 +2034,17 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aPresContext->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Is it a floater?
- if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
} else {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -2073,6 +2095,7 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
mChildCount++;
}
SetLastContentOffset(prevKidFrame);
+#endif
// If this is a pseudo-frame then our parent will generate the
// reflow command. Otherwise, if the container is us then we should
@@ -2106,7 +2129,14 @@ nsHTMLFrameType nsBlockFrame::GetFrameType() const
NS_METHOD nsBlockFrame::ListTag(FILE* out) const
{
if ((nsnull != mGeometricParent) && IsPseudoFrame()) {
- fprintf(out, "*block(%d)@%p", mIndexInParent, this);
+ fprintf(out, "*block<");
+ nsIAtom* atom = mContent->GetTag();
+ if (nsnull != atom) {
+ nsAutoString tmp;
+ atom->ToString(tmp);
+ fputs(tmp, out);
+ }
+ fprintf(out, ">(%d)@%p", mIndexInParent, this);
} else {
nsHTMLContainerFrame::ListTag(out);
}
diff --git a/mozilla/layout/generic/nsBlockFrame.h b/mozilla/layout/generic/nsBlockFrame.h
index cb8a2b18f88..f11bba52ca1 100644
--- a/mozilla/layout/generic/nsBlockFrame.h
+++ b/mozilla/layout/generic/nsBlockFrame.h
@@ -25,7 +25,9 @@
#include "nsVoidArray.h"
struct BlockBandData;
struct nsMargin;
+struct nsStyleDisplay;
struct nsStyleFont;
+struct nsStyleText;
/**
* Block frames have some state which needs to be made
@@ -65,9 +67,11 @@ struct nsBlockReflowState {
// Space manager to use
nsISpaceManager* spaceManager;
- // Block's style data
- nsStyleFont* font;
- nsStyleMolecule* mol;
+ // Block's style context
+ nsIStyleContext* styleContext;
+ nsStyleText* styleText;
+ nsStyleFont* styleFont;
+ nsStyleDisplay* styleDisplay;
// Block's available size (computed from the block's parent)
nsSize availSize;
@@ -139,7 +143,7 @@ struct nsBlockReflowState {
~nsBlockReflowState();
void Init(const nsSize& aMaxSize, nsSize* aMaxElementSize,
- nsStyleFont* aFont, nsStyleMolecule* aMol, nsISpaceManager* aSpaceManager);
+ nsIStyleContext* aStyleContext, nsISpaceManager* aSpaceManager);
void AddAscent(nscoord aAscent);
void AdvanceToNextLine(nsIFrame* aPrevLineLastFrame, nscoord aPrevLineHeight);
@@ -247,7 +251,7 @@ protected:
nscoord GetTopMarginFor(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline);
PRBool AdvanceToNextLine(nsIPresContext* aPresContext,
@@ -258,24 +262,24 @@ protected:
nsIFrame* aKidFrame,
nsReflowMetrics& aKidSize,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol);
+ nsIStyleContext* aKidSC);
void AddBlockChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
nsRect& aKidRect,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol);
+ nsIStyleContext* aKidSC);
void GetAvailSize(nsSize& aResult,
nsBlockReflowState& aState,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline);
PRIntn PlaceAndReflowChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* kidFrame,
- nsStyleMolecule* aKidMol);
+ nsIStyleContext* aKidSC);
void PushKids(nsBlockReflowState& aState);
diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp
index 8697f2d49a7..84fd53b081b 100644
--- a/mozilla/layout/generic/nsBlockReflowState.cpp
+++ b/mozilla/layout/generic/nsBlockReflowState.cpp
@@ -48,9 +48,12 @@
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
static NS_DEFINE_IID(kIFloaterContainerIID, NS_IFLOATERCONTAINER_IID);
static NS_DEFINE_IID(kIAnchoredItemsIID, NS_IANCHOREDITEMS_IID);
-static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -100,8 +103,7 @@ nsBlockReflowState::nsBlockReflowState()
void nsBlockReflowState::Init(const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleFont* aFont,
- nsStyleMolecule* aMol,
+ nsIStyleContext* aBlockSC,
nsISpaceManager* aSpaceManager)
{
firstLine = PR_TRUE;
@@ -114,8 +116,15 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
spaceManager = aSpaceManager;
currentBand = new BlockBandData;
- font = aFont;
- mol = aMol;
+
+ styleContext = aBlockSC;
+ styleText = (nsStyleText*) aBlockSC->GetData(kStyleTextSID);
+ styleFont = (nsStyleFont*) aBlockSC->GetData(kStyleFontSID);
+ styleDisplay = (nsStyleDisplay*) aBlockSC->GetData(kStyleDisplaySID);
+
+ justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign) &&
+ (NS_STYLE_WHITESPACE_PRE != styleText->mWhiteSpace);
+
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
maxElementSize = aMaxElementSize;
@@ -155,8 +164,6 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
- justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mol->textAlign) &&
- (NS_STYLE_WHITESPACE_PRE != mol->whiteSpace);
reflowStatus = nsIFrame::frNotComplete;
}
@@ -300,11 +307,11 @@ nsBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
// type and the display type of the previous child frame.
//
// Adjacent vertical margins between block-level elements are collapsed.
-nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
+nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
nsBlockReflowState& aState,
- nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol,
- PRBool aIsInline)
+ nsIFrame* aKidFrame,
+ nsIStyleContext* aKidSC,
+ PRBool aIsInline)
{
if (aIsInline) {
// Just use whatever the previous bottom margin was
@@ -318,10 +325,11 @@ nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
if (nsnull == kidPrevInFlow) {
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if (aKidMol->margin.top < 0) {
- maxNegTopMargin = -aKidMol->margin.top;
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ if (ss->mMargin.top < 0) {
+ maxNegTopMargin = -ss->mMargin.top;
} else {
- maxPosTopMargin = aKidMol->margin.top;
+ maxPosTopMargin = ss->mMargin.top;
}
nscoord maxPos = PR_MAX(aState.prevMaxPosBottomMargin, maxPosTopMargin);
@@ -354,20 +362,22 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
floater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* sd = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
floater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == sd->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == sd->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
// XXX Don't forget the floater's margins...
- mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left, 0);
+ mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left,
+ 0);
mCurrentState->spaceManager->AddRectRegion(region, floater);
// Set the origin of the floater in world coordinates
@@ -398,9 +408,13 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
if (aState.isInline) {
// Vertically align the children on this line, returning the height of
// the line upon completion.
- lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this, aState.font, y,
- aState.lineStart, aState.lineLength,
- aState.ascents, aState.maxAscent);
+ lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this,
+ aState.styleFont,
+ y,
+ aState.lineStart,
+ aState.lineLength,
+ aState.ascents,
+ aState.maxAscent);
// Any below current line floaters to place?
if (aState.floaterToDo.Count() > 0) {
@@ -445,7 +459,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// doing an unconstrained (in x) reflow. There's no point in doing
// the work if we *know* we are going to reflowed again.
if (!aState.unconstrainedWidth) {
- nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.mol,
+ nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.styleText,
aState.lineStart, aState.lineLength,
aState.lineWidth,
aState.availSize.width);
@@ -453,7 +467,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
if (!aState.justifying) {
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
+ nsCSSLayout::RelativePositionChildren(aCX, this,
aState.lineStart,
aState.lineLength);
}
@@ -499,17 +513,15 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsReflowMetrics& aKidSize,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
- PRIntn direction = aState.mol->direction;
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
@@ -519,15 +531,16 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
r.y = aState.y;
r.width = aKidSize.width;
r.height = aKidSize.height;
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
// Left to right positioning.
- r.x = aState.borderPadding.left + aState.x + aKidMol->margin.left;
- aState.x += aKidSize.width + aKidMol->margin.left + aKidMol->margin.right;
+ r.x = aState.borderPadding.left + aState.x + ss->mMargin.left;
+ aState.x += aKidSize.width + ss->mMargin.left + ss->mMargin.right;
} else {
// Right to left positioning
// XXX what should we do when aState.x goes negative???
- r.x = aState.x - aState.borderPadding.right - aKidMol->margin.right - aKidSize.width;
- aState.x -= aKidSize.width + aKidMol->margin.right + aKidMol->margin.left;
+ r.x = aState.x - aState.borderPadding.right - ss->mMargin.right -
+ aKidSize.width;
+ aState.x -= aKidSize.width + ss->mMargin.right + ss->mMargin.left;
}
aKidFrame->SetRect(r);
aState.AddAscent(aKidSize.ascent);
@@ -551,7 +564,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
#if 0
// XXX CSS2 spec says that top/bottom margin don't affect line height
// calculation. We're waiting for clarification on this issue...
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = ss->mMargin.top) < 0) {
margin = -margin;
if (margin > aState.maxNegTopMargin) {
aState.maxNegTopMargin = margin;
@@ -562,7 +575,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
}
}
#endif
- if ((margin = aKidMol->margin.bottom) < 0) {
+ if ((margin = ss->mMargin.bottom) < 0) {
margin = -margin;
if (margin > aState.maxNegBottomMargin) {
aState.maxNegBottomMargin = margin;
@@ -593,20 +606,20 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsRect& aKidRect,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
+
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
// Translate from the kid's coordinate space to our coordinate space
- aKidRect.x += aState.borderPadding.left + aKidMol->margin.left;
+ aKidRect.x += aState.borderPadding.left + ss->mMargin.left;
aKidRect.y += aState.y + aState.topMargin;
// Place and size the child
@@ -616,7 +629,7 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
aState.lineLength++;
// Is this the widest child frame?
- nscoord xMost = aKidRect.XMost() + aKidMol->margin.right;
+ nscoord xMost = aKidRect.XMost() + ss->mMargin.right;
if (xMost > aState.kidXMost) {
aState.kidXMost = xMost;
}
@@ -633,17 +646,17 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
// and the bottom line margin information which we'll use when placing
// the next child
- if (aKidMol->margin.bottom < 0) {
- aState.maxNegBottomMargin = -aKidMol->margin.bottom;
+ if (ss->mMargin.bottom < 0) {
+ aState.maxNegBottomMargin = -ss->mMargin.bottom;
} else {
- aState.maxPosBottomMargin = aKidMol->margin.bottom;
+ aState.maxPosBottomMargin = ss->mMargin.bottom;
}
// Update the running y-offset
aState.y += aKidRect.height + aState.topMargin;
// Apply relative positioning if necessary
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol, aKidFrame, 1);
+ nsCSSLayout::RelativePositionChildren(aCX, this, aKidFrame, 1);
// Advance to the next line
aState.AdvanceToNextLine(aKidFrame, aKidRect.height);
@@ -656,19 +669,19 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
*/
void nsBlockFrame::GetAvailSize(nsSize& aResult,
nsBlockReflowState& aState,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline)
{
// Determine the maximum available reflow height for the child
nscoord yb = aState.borderPadding.top + aState.availSize.height;
aResult.height = aState.unconstrainedHeight ? NS_UNCONSTRAINEDSIZE :
- yb - aState.y - aState.topMargin;
+ yb - aState.y - aState.topMargin;
// Determine the maximum available reflow width for the child
if (aState.unconstrainedWidth) {
aResult.width = NS_UNCONSTRAINEDSIZE;
} else if (aIsInline) {
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
} else {
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
@@ -830,13 +843,15 @@ getBand:
}
if (isLeftFloater) {
- if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_LEFT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
}
if (isRightFloater) {
- if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_RIGHT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
@@ -853,7 +868,7 @@ PRIntn
nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
nsSize kidMaxElementSize;
nsSize* pKidMaxElementSize =
@@ -866,17 +881,12 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Get kid and its style
- // XXX How is this any different than what was passed in to us as aKidMol?
- nsIContentPtr kid;
- nsIStyleContextPtr kidSC;
-
- aKidFrame->GetContent(kid.AssignRef());
- aKidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
// Figure out if kid is a block element or not
PRBool isInline = PR_TRUE;
- PRIntn display = kidMol->display;
+ PRIntn display = styleDisplay->mDisplay;
if (aState.firstChildIsInsideBullet && (mFirstChild == aKidFrame)) {
// XXX Special hack for properly reflowing bullets that have the
// inside value for list-style-position.
@@ -909,15 +919,20 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
aState.lineStart = aKidFrame;
- // Get the style for the last child, and see if it wanted to clear floaters.
- // This handles the BR tag, which is the only inline element for which clear
- // applies
+ // Get the style for the last child, and see if it wanted to clear
+ // floaters. This handles the BR tag, which is the only inline
+ // element for which clear applies
nsIStyleContextPtr lastChildSC;
lastFrame->GetStyleContext(aCX, lastChildSC.AssignRef());
- nsStyleMolecule* lastChildMol = (nsStyleMolecule*)lastChildSC->GetData(kStyleMoleculeSID);
- if (lastChildMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, lastChildMol->clear);
+ nsStyleDisplay* lastChildDisplay = (nsStyleDisplay*)
+ lastChildSC->GetData(kStyleDisplaySID);
+ switch (lastChildDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, lastChildDisplay->mBreakType);
+ break;
}
}
@@ -929,7 +944,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// should use
if (aState.lineStart == aKidFrame) {
// Compute the top margin to use for this line
- aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, kidMol, aState.isInline);
+ aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, aKidSC,
+ aState.isInline);
// If it's an inline element then get a band of available space
//
@@ -943,7 +959,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// Compute the available space to reflow the child into and then
// reflow it into that space.
nsSize kidAvailSize;
- GetAvailSize(kidAvailSize, aState, kidMol, aState.isInline);
+ GetAvailSize(kidAvailSize, aState, aKidSC, aState.isInline);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
@@ -990,7 +1006,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
GetAvailableSpaceBand(aState, aState.y + aState.topMargin);
// Reflow child now that it has the line to itself
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
}
@@ -1017,7 +1033,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
if (isSplittable != frNotSplittable) {
// Update size info now that we are on the next line. Then
// reflow the child into the new available space.
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
@@ -1044,21 +1060,27 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Add child to the line
- AddInlineChildToLine(aCX, aState, aKidFrame, kidSize, pKidMaxElementSize, kidMol);
-
+ AddInlineChildToLine(aCX, aState, aKidFrame, kidSize,
+ pKidMaxElementSize, aKidSC);
} else {
nsRect kidRect;
// Does the block-level element want to clear any floaters that impact
// it? Note that the clear property only applies to block-level elements
// and the BR tag
- if (aKidMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, aKidMol->clear);
- GetAvailSize(kidAvailSize, aState, kidMol, PR_FALSE);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
+ switch (styleDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, styleDisplay->mBreakType);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_FALSE);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
}
+ break;
}
// Give the block its own local coordinate space.. Note: ReflowChild()
@@ -1066,8 +1088,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// current left/right edge
aState.spaceManager->Translate(aState.borderPadding.left, 0);
// Give the block-level element the opportunity to use the space manager
- status = ReflowChild(aKidFrame, aCX, kidMol, aState.spaceManager, kidAvailSize,
- kidRect, pKidMaxElementSize);
+ status = ReflowChild(aKidFrame, aCX, aState.spaceManager,
+ kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
// For first children, we skip all the fit checks because we must
@@ -1087,7 +1109,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// calls AdvaneceToNextLine(). We need to restructure the flow of control,
// and use a state machine...
aState.lastContentIsComplete = PRBool(status == frComplete);
- AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, kidMol);
+ AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, aKidSC);
}
// If we just reflowed our last child then update the
@@ -1147,7 +1169,6 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
// Attempt to place and reflow the child
@@ -1155,7 +1176,7 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
// it is, otherwise advance to the next line and place it there if
// possible
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
ReflowStatus status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// The child doesn't fit. Push it and any remaining children.
@@ -1237,8 +1258,9 @@ PRBool nsBlockFrame::MoreToReflow(nsIPresContext* aCX)
if (nsnull != kid) {
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- switch (kidMol->display) {
+ nsStyleDisplay* kidStyleDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
+ switch (kidStyleDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Block pseudo-frames do not contain other block elements
@@ -1303,21 +1325,23 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStylePosition* kidPosition = (nsStylePosition*)kidSC->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidSC->GetData(kStylePositionSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Check whether it wants to floated or absolutely positioned
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
- } else if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
} else if (nsnull == kidPrevInFlow) {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -1378,7 +1402,7 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// complete.
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// We ran out of room.
@@ -1411,7 +1435,6 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
}
#ifdef NS_DEBUG
nsIFrame* kidNextInFlow;
@@ -1493,11 +1516,10 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// Push the kids that didn't fit back down to the next-in-flow
@@ -1534,7 +1556,6 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
} else {
// The child has a next-in-flow, but it's not one of ours.
// It *must* be in one of our next-in-flows. Collect it
@@ -1597,20 +1618,19 @@ void nsBlockFrame::SetupState(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager)
{
// Setup reflow state
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- nsStyleFont* font =
- (nsStyleFont*)mStyleContext->GetData(kStyleFontSID);
- aState.Init(aMaxSize, aMaxElementSize, font, mol, aSpaceManager);
+ aState.Init(aMaxSize, aMaxElementSize, mStyleContext, aSpaceManager);
+
+ nsStyleSpacing* mySpacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
// Apply border and padding adjustments for regular frames only
if (PR_FALSE == IsPseudoFrame()) {
- aState.borderPadding = mol->borderPadding;
- aState.y = mol->borderPadding.top;
+ aState.borderPadding = mySpacing->mBorderPadding;
+ aState.y = mySpacing->mBorderPadding.top;
aState.availSize.width -=
- (mol->borderPadding.left + mol->borderPadding.right);
+ (mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right);
aState.availSize.height -=
- (mol->borderPadding.top + mol->borderPadding.bottom);
+ (mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom);
} else {
aState.borderPadding.SizeTo(0, 0, 0, 0);
}
@@ -1830,8 +1850,7 @@ void nsBlockFrame::JustifyLines(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
- lineStart, mLines[i]);
+ nsCSSLayout::RelativePositionChildren(aCX, this, lineStart, mLines[i]);
}
}
@@ -1952,7 +1971,8 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
aFloater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* floaterDisplay = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
if (!mCurrentState->isInline) {
// Get the current band for this line
@@ -1965,10 +1985,10 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
aFloater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
@@ -1997,9 +2017,10 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
{
// Get the last-in-flow
nsBlockFrame* flow = (nsBlockFrame*)GetLastInFlow();
-
PRInt32 kidIndex = flow->NextChildOffset();
PRInt32 startIndex = kidIndex;
+
+#if 0
nsIFrame* kidFrame = nsnull;
nsIFrame* prevKidFrame;
@@ -2013,16 +2034,17 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aPresContext->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Is it a floater?
- if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
} else {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -2073,6 +2095,7 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
mChildCount++;
}
SetLastContentOffset(prevKidFrame);
+#endif
// If this is a pseudo-frame then our parent will generate the
// reflow command. Otherwise, if the container is us then we should
@@ -2106,7 +2129,14 @@ nsHTMLFrameType nsBlockFrame::GetFrameType() const
NS_METHOD nsBlockFrame::ListTag(FILE* out) const
{
if ((nsnull != mGeometricParent) && IsPseudoFrame()) {
- fprintf(out, "*block(%d)@%p", mIndexInParent, this);
+ fprintf(out, "*block<");
+ nsIAtom* atom = mContent->GetTag();
+ if (nsnull != atom) {
+ nsAutoString tmp;
+ atom->ToString(tmp);
+ fputs(tmp, out);
+ }
+ fprintf(out, ">(%d)@%p", mIndexInParent, this);
} else {
nsHTMLContainerFrame::ListTag(out);
}
diff --git a/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h
index 8697f2d49a7..84fd53b081b 100644
--- a/mozilla/layout/generic/nsBlockReflowState.h
+++ b/mozilla/layout/generic/nsBlockReflowState.h
@@ -48,9 +48,12 @@
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
static NS_DEFINE_IID(kIFloaterContainerIID, NS_IFLOATERCONTAINER_IID);
static NS_DEFINE_IID(kIAnchoredItemsIID, NS_IANCHOREDITEMS_IID);
-static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -100,8 +103,7 @@ nsBlockReflowState::nsBlockReflowState()
void nsBlockReflowState::Init(const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleFont* aFont,
- nsStyleMolecule* aMol,
+ nsIStyleContext* aBlockSC,
nsISpaceManager* aSpaceManager)
{
firstLine = PR_TRUE;
@@ -114,8 +116,15 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
spaceManager = aSpaceManager;
currentBand = new BlockBandData;
- font = aFont;
- mol = aMol;
+
+ styleContext = aBlockSC;
+ styleText = (nsStyleText*) aBlockSC->GetData(kStyleTextSID);
+ styleFont = (nsStyleFont*) aBlockSC->GetData(kStyleFontSID);
+ styleDisplay = (nsStyleDisplay*) aBlockSC->GetData(kStyleDisplaySID);
+
+ justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign) &&
+ (NS_STYLE_WHITESPACE_PRE != styleText->mWhiteSpace);
+
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
maxElementSize = aMaxElementSize;
@@ -155,8 +164,6 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
- justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mol->textAlign) &&
- (NS_STYLE_WHITESPACE_PRE != mol->whiteSpace);
reflowStatus = nsIFrame::frNotComplete;
}
@@ -300,11 +307,11 @@ nsBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
// type and the display type of the previous child frame.
//
// Adjacent vertical margins between block-level elements are collapsed.
-nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
+nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
nsBlockReflowState& aState,
- nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol,
- PRBool aIsInline)
+ nsIFrame* aKidFrame,
+ nsIStyleContext* aKidSC,
+ PRBool aIsInline)
{
if (aIsInline) {
// Just use whatever the previous bottom margin was
@@ -318,10 +325,11 @@ nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
if (nsnull == kidPrevInFlow) {
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if (aKidMol->margin.top < 0) {
- maxNegTopMargin = -aKidMol->margin.top;
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ if (ss->mMargin.top < 0) {
+ maxNegTopMargin = -ss->mMargin.top;
} else {
- maxPosTopMargin = aKidMol->margin.top;
+ maxPosTopMargin = ss->mMargin.top;
}
nscoord maxPos = PR_MAX(aState.prevMaxPosBottomMargin, maxPosTopMargin);
@@ -354,20 +362,22 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
floater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* sd = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
floater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == sd->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == sd->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
// XXX Don't forget the floater's margins...
- mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left, 0);
+ mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left,
+ 0);
mCurrentState->spaceManager->AddRectRegion(region, floater);
// Set the origin of the floater in world coordinates
@@ -398,9 +408,13 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
if (aState.isInline) {
// Vertically align the children on this line, returning the height of
// the line upon completion.
- lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this, aState.font, y,
- aState.lineStart, aState.lineLength,
- aState.ascents, aState.maxAscent);
+ lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this,
+ aState.styleFont,
+ y,
+ aState.lineStart,
+ aState.lineLength,
+ aState.ascents,
+ aState.maxAscent);
// Any below current line floaters to place?
if (aState.floaterToDo.Count() > 0) {
@@ -445,7 +459,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// doing an unconstrained (in x) reflow. There's no point in doing
// the work if we *know* we are going to reflowed again.
if (!aState.unconstrainedWidth) {
- nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.mol,
+ nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.styleText,
aState.lineStart, aState.lineLength,
aState.lineWidth,
aState.availSize.width);
@@ -453,7 +467,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
if (!aState.justifying) {
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
+ nsCSSLayout::RelativePositionChildren(aCX, this,
aState.lineStart,
aState.lineLength);
}
@@ -499,17 +513,15 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsReflowMetrics& aKidSize,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
- PRIntn direction = aState.mol->direction;
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
@@ -519,15 +531,16 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
r.y = aState.y;
r.width = aKidSize.width;
r.height = aKidSize.height;
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
// Left to right positioning.
- r.x = aState.borderPadding.left + aState.x + aKidMol->margin.left;
- aState.x += aKidSize.width + aKidMol->margin.left + aKidMol->margin.right;
+ r.x = aState.borderPadding.left + aState.x + ss->mMargin.left;
+ aState.x += aKidSize.width + ss->mMargin.left + ss->mMargin.right;
} else {
// Right to left positioning
// XXX what should we do when aState.x goes negative???
- r.x = aState.x - aState.borderPadding.right - aKidMol->margin.right - aKidSize.width;
- aState.x -= aKidSize.width + aKidMol->margin.right + aKidMol->margin.left;
+ r.x = aState.x - aState.borderPadding.right - ss->mMargin.right -
+ aKidSize.width;
+ aState.x -= aKidSize.width + ss->mMargin.right + ss->mMargin.left;
}
aKidFrame->SetRect(r);
aState.AddAscent(aKidSize.ascent);
@@ -551,7 +564,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
#if 0
// XXX CSS2 spec says that top/bottom margin don't affect line height
// calculation. We're waiting for clarification on this issue...
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = ss->mMargin.top) < 0) {
margin = -margin;
if (margin > aState.maxNegTopMargin) {
aState.maxNegTopMargin = margin;
@@ -562,7 +575,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
}
}
#endif
- if ((margin = aKidMol->margin.bottom) < 0) {
+ if ((margin = ss->mMargin.bottom) < 0) {
margin = -margin;
if (margin > aState.maxNegBottomMargin) {
aState.maxNegBottomMargin = margin;
@@ -593,20 +606,20 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsRect& aKidRect,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
+
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
// Translate from the kid's coordinate space to our coordinate space
- aKidRect.x += aState.borderPadding.left + aKidMol->margin.left;
+ aKidRect.x += aState.borderPadding.left + ss->mMargin.left;
aKidRect.y += aState.y + aState.topMargin;
// Place and size the child
@@ -616,7 +629,7 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
aState.lineLength++;
// Is this the widest child frame?
- nscoord xMost = aKidRect.XMost() + aKidMol->margin.right;
+ nscoord xMost = aKidRect.XMost() + ss->mMargin.right;
if (xMost > aState.kidXMost) {
aState.kidXMost = xMost;
}
@@ -633,17 +646,17 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
// and the bottom line margin information which we'll use when placing
// the next child
- if (aKidMol->margin.bottom < 0) {
- aState.maxNegBottomMargin = -aKidMol->margin.bottom;
+ if (ss->mMargin.bottom < 0) {
+ aState.maxNegBottomMargin = -ss->mMargin.bottom;
} else {
- aState.maxPosBottomMargin = aKidMol->margin.bottom;
+ aState.maxPosBottomMargin = ss->mMargin.bottom;
}
// Update the running y-offset
aState.y += aKidRect.height + aState.topMargin;
// Apply relative positioning if necessary
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol, aKidFrame, 1);
+ nsCSSLayout::RelativePositionChildren(aCX, this, aKidFrame, 1);
// Advance to the next line
aState.AdvanceToNextLine(aKidFrame, aKidRect.height);
@@ -656,19 +669,19 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
*/
void nsBlockFrame::GetAvailSize(nsSize& aResult,
nsBlockReflowState& aState,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline)
{
// Determine the maximum available reflow height for the child
nscoord yb = aState.borderPadding.top + aState.availSize.height;
aResult.height = aState.unconstrainedHeight ? NS_UNCONSTRAINEDSIZE :
- yb - aState.y - aState.topMargin;
+ yb - aState.y - aState.topMargin;
// Determine the maximum available reflow width for the child
if (aState.unconstrainedWidth) {
aResult.width = NS_UNCONSTRAINEDSIZE;
} else if (aIsInline) {
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
} else {
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
@@ -830,13 +843,15 @@ getBand:
}
if (isLeftFloater) {
- if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_LEFT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
}
if (isRightFloater) {
- if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_RIGHT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
@@ -853,7 +868,7 @@ PRIntn
nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
nsSize kidMaxElementSize;
nsSize* pKidMaxElementSize =
@@ -866,17 +881,12 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Get kid and its style
- // XXX How is this any different than what was passed in to us as aKidMol?
- nsIContentPtr kid;
- nsIStyleContextPtr kidSC;
-
- aKidFrame->GetContent(kid.AssignRef());
- aKidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
// Figure out if kid is a block element or not
PRBool isInline = PR_TRUE;
- PRIntn display = kidMol->display;
+ PRIntn display = styleDisplay->mDisplay;
if (aState.firstChildIsInsideBullet && (mFirstChild == aKidFrame)) {
// XXX Special hack for properly reflowing bullets that have the
// inside value for list-style-position.
@@ -909,15 +919,20 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
aState.lineStart = aKidFrame;
- // Get the style for the last child, and see if it wanted to clear floaters.
- // This handles the BR tag, which is the only inline element for which clear
- // applies
+ // Get the style for the last child, and see if it wanted to clear
+ // floaters. This handles the BR tag, which is the only inline
+ // element for which clear applies
nsIStyleContextPtr lastChildSC;
lastFrame->GetStyleContext(aCX, lastChildSC.AssignRef());
- nsStyleMolecule* lastChildMol = (nsStyleMolecule*)lastChildSC->GetData(kStyleMoleculeSID);
- if (lastChildMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, lastChildMol->clear);
+ nsStyleDisplay* lastChildDisplay = (nsStyleDisplay*)
+ lastChildSC->GetData(kStyleDisplaySID);
+ switch (lastChildDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, lastChildDisplay->mBreakType);
+ break;
}
}
@@ -929,7 +944,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// should use
if (aState.lineStart == aKidFrame) {
// Compute the top margin to use for this line
- aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, kidMol, aState.isInline);
+ aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, aKidSC,
+ aState.isInline);
// If it's an inline element then get a band of available space
//
@@ -943,7 +959,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// Compute the available space to reflow the child into and then
// reflow it into that space.
nsSize kidAvailSize;
- GetAvailSize(kidAvailSize, aState, kidMol, aState.isInline);
+ GetAvailSize(kidAvailSize, aState, aKidSC, aState.isInline);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
@@ -990,7 +1006,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
GetAvailableSpaceBand(aState, aState.y + aState.topMargin);
// Reflow child now that it has the line to itself
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
}
@@ -1017,7 +1033,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
if (isSplittable != frNotSplittable) {
// Update size info now that we are on the next line. Then
// reflow the child into the new available space.
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
@@ -1044,21 +1060,27 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Add child to the line
- AddInlineChildToLine(aCX, aState, aKidFrame, kidSize, pKidMaxElementSize, kidMol);
-
+ AddInlineChildToLine(aCX, aState, aKidFrame, kidSize,
+ pKidMaxElementSize, aKidSC);
} else {
nsRect kidRect;
// Does the block-level element want to clear any floaters that impact
// it? Note that the clear property only applies to block-level elements
// and the BR tag
- if (aKidMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, aKidMol->clear);
- GetAvailSize(kidAvailSize, aState, kidMol, PR_FALSE);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
+ switch (styleDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, styleDisplay->mBreakType);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_FALSE);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
}
+ break;
}
// Give the block its own local coordinate space.. Note: ReflowChild()
@@ -1066,8 +1088,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// current left/right edge
aState.spaceManager->Translate(aState.borderPadding.left, 0);
// Give the block-level element the opportunity to use the space manager
- status = ReflowChild(aKidFrame, aCX, kidMol, aState.spaceManager, kidAvailSize,
- kidRect, pKidMaxElementSize);
+ status = ReflowChild(aKidFrame, aCX, aState.spaceManager,
+ kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
// For first children, we skip all the fit checks because we must
@@ -1087,7 +1109,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// calls AdvaneceToNextLine(). We need to restructure the flow of control,
// and use a state machine...
aState.lastContentIsComplete = PRBool(status == frComplete);
- AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, kidMol);
+ AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, aKidSC);
}
// If we just reflowed our last child then update the
@@ -1147,7 +1169,6 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
// Attempt to place and reflow the child
@@ -1155,7 +1176,7 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
// it is, otherwise advance to the next line and place it there if
// possible
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
ReflowStatus status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// The child doesn't fit. Push it and any remaining children.
@@ -1237,8 +1258,9 @@ PRBool nsBlockFrame::MoreToReflow(nsIPresContext* aCX)
if (nsnull != kid) {
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- switch (kidMol->display) {
+ nsStyleDisplay* kidStyleDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
+ switch (kidStyleDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Block pseudo-frames do not contain other block elements
@@ -1303,21 +1325,23 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStylePosition* kidPosition = (nsStylePosition*)kidSC->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidSC->GetData(kStylePositionSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Check whether it wants to floated or absolutely positioned
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
- } else if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
} else if (nsnull == kidPrevInFlow) {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -1378,7 +1402,7 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// complete.
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// We ran out of room.
@@ -1411,7 +1435,6 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
}
#ifdef NS_DEBUG
nsIFrame* kidNextInFlow;
@@ -1493,11 +1516,10 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// Push the kids that didn't fit back down to the next-in-flow
@@ -1534,7 +1556,6 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
} else {
// The child has a next-in-flow, but it's not one of ours.
// It *must* be in one of our next-in-flows. Collect it
@@ -1597,20 +1618,19 @@ void nsBlockFrame::SetupState(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager)
{
// Setup reflow state
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- nsStyleFont* font =
- (nsStyleFont*)mStyleContext->GetData(kStyleFontSID);
- aState.Init(aMaxSize, aMaxElementSize, font, mol, aSpaceManager);
+ aState.Init(aMaxSize, aMaxElementSize, mStyleContext, aSpaceManager);
+
+ nsStyleSpacing* mySpacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
// Apply border and padding adjustments for regular frames only
if (PR_FALSE == IsPseudoFrame()) {
- aState.borderPadding = mol->borderPadding;
- aState.y = mol->borderPadding.top;
+ aState.borderPadding = mySpacing->mBorderPadding;
+ aState.y = mySpacing->mBorderPadding.top;
aState.availSize.width -=
- (mol->borderPadding.left + mol->borderPadding.right);
+ (mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right);
aState.availSize.height -=
- (mol->borderPadding.top + mol->borderPadding.bottom);
+ (mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom);
} else {
aState.borderPadding.SizeTo(0, 0, 0, 0);
}
@@ -1830,8 +1850,7 @@ void nsBlockFrame::JustifyLines(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
- lineStart, mLines[i]);
+ nsCSSLayout::RelativePositionChildren(aCX, this, lineStart, mLines[i]);
}
}
@@ -1952,7 +1971,8 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
aFloater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* floaterDisplay = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
if (!mCurrentState->isInline) {
// Get the current band for this line
@@ -1965,10 +1985,10 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
aFloater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
@@ -1997,9 +2017,10 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
{
// Get the last-in-flow
nsBlockFrame* flow = (nsBlockFrame*)GetLastInFlow();
-
PRInt32 kidIndex = flow->NextChildOffset();
PRInt32 startIndex = kidIndex;
+
+#if 0
nsIFrame* kidFrame = nsnull;
nsIFrame* prevKidFrame;
@@ -2013,16 +2034,17 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aPresContext->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Is it a floater?
- if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
} else {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -2073,6 +2095,7 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
mChildCount++;
}
SetLastContentOffset(prevKidFrame);
+#endif
// If this is a pseudo-frame then our parent will generate the
// reflow command. Otherwise, if the container is us then we should
@@ -2106,7 +2129,14 @@ nsHTMLFrameType nsBlockFrame::GetFrameType() const
NS_METHOD nsBlockFrame::ListTag(FILE* out) const
{
if ((nsnull != mGeometricParent) && IsPseudoFrame()) {
- fprintf(out, "*block(%d)@%p", mIndexInParent, this);
+ fprintf(out, "*block<");
+ nsIAtom* atom = mContent->GetTag();
+ if (nsnull != atom) {
+ nsAutoString tmp;
+ atom->ToString(tmp);
+ fputs(tmp, out);
+ }
+ fprintf(out, ">(%d)@%p", mIndexInParent, this);
} else {
nsHTMLContainerFrame::ListTag(out);
}
diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp
index 44075326666..27734eb6e3f 100644
--- a/mozilla/layout/generic/nsInlineFrame.cpp
+++ b/mozilla/layout/generic/nsInlineFrame.cpp
@@ -26,6 +26,7 @@
#include "nsCSSLayout.h"
#include "nsPlaceholderFrame.h"
#include "nsReflowCommand.h"
+#include "nsHTMLAtoms.h"
#include "nsAbsoluteFrame.h"
// XXX To Do:
@@ -36,16 +37,22 @@
// 6. direction support
// 7. CSS line-height property
+/* XXX */
+#include "nsHTMLIIDs.h"
+#include "nsBlockFrame.h"
+
#define DEFAULT_ASCENT_LEN 10
+
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
class nsInlineState
{
public:
nsStyleFont* font; // style font
- nsStyleMolecule* mol; // style molecule
+ nsStyleSpacing* spacing; // style spacing
nsSize availSize; // available space in which to reflow (starts as max size minus insets)
nsSize* maxElementSize; // maximum element size (may be null)
nscoord x; // running x-offset (starts at left inner edge)
@@ -58,14 +65,14 @@ public:
// Constructor
nsInlineState(nsStyleFont* aStyleFont,
- nsStyleMolecule* aStyleMolecule,
+ nsStyleSpacing* aSpacing,
const nsSize& aMaxSize,
nsSize* aMaxElementSize)
- : x(aStyleMolecule->borderPadding.left), // determined by inner edge
- y(aStyleMolecule->borderPadding.top) // determined by inner edge
+ : x(aSpacing->mBorderPadding.left), // determined by inner edge
+ y(aSpacing->mBorderPadding.top) // determined by inner edge
{
font = aStyleFont;
- mol = aStyleMolecule;
+ spacing = aSpacing;
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
@@ -74,11 +81,11 @@ public:
// needed for border/padding
availSize.width = aMaxSize.width;
if (PR_FALSE == unconstrainedWidth) {
- availSize.width -= mol->borderPadding.left + mol->borderPadding.right;
+ availSize.width -= aSpacing->mBorderPadding.left + aSpacing->mBorderPadding.right;
}
availSize.height = aMaxSize.height;
if (PR_FALSE == unconstrainedHeight) {
- availSize.height -= mol->borderPadding.top + mol->borderPadding.bottom;
+ availSize.height -= aSpacing->mBorderPadding.top + aSpacing->mBorderPadding.bottom;
}
// Initialize max element size
@@ -360,6 +367,10 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
}
}
+ // XXX if the frame being pulled up is not appropriate (e.g. a block
+ // frame) then we should stop! If we have an inline BR tag we should
+ // stop too!
+
// See if the child fits in the available space. If it fits or
// it's splittable then reflow it. The reason we can't just move
// it is that we still need ascent/descent information
@@ -531,6 +542,7 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
PRInt32 kidIndex = NextChildOffset();
nsIFrame* prevKidFrame;
+ PRBool breakAfter = PR_FALSE;
LastChild(prevKidFrame);
for (;;) {
// Get the next content object
@@ -553,19 +565,21 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Figure out how we should treat the child
nsIFrame* kidFrame;
- nsStylePosition* kidPosition = (nsStylePosition*)kidStyleContext->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay =
+ (nsStyleDisplay*)kidStyleContext->GetData(kStyleDisplaySID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidStyleContext->GetData(kStylePositionSID);
// Check whether it wants to floated or absolutely positioned
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidStyleContext);
- } else if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidStyleContext);
} else if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
if (kidIndex != mFirstContentOffset) {
@@ -578,6 +592,42 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// FALLTHROUGH
case NS_STYLE_DISPLAY_INLINE:
+ // XXX temporary hack to make plain BR's in inlines "work"
+ // get style for break-before-after; get break-type (line, page, etc.)
+ {
+ nsIAtom* tag = kid->GetTag();
+ if (nsHTMLAtoms::br == tag) {
+ // Set break-after flag so we stop mapping children (we
+ // will end up being continued if there are more children)
+ breakAfter = PR_TRUE;
+
+ // Get cached state for containing block frame
+ // XXX how about QueryInterface(kIHTMLBlockFrameIID)? DOH!
+ nsBlockReflowState* state = nsnull;
+ nsIFrame* parent = mGeometricParent;
+ while (nsnull != parent) {
+ nsIHTMLFrameType* ft;
+ nsresult status =
+ parent->QueryInterface(kIHTMLFrameTypeIID, (void**) &ft);
+ if (NS_OK == status) {
+ nsHTMLFrameType type = ft->GetFrameType();
+ if (eHTMLFrame_Block == type) {
+ break;
+ }
+ }
+ parent->GetGeometricParent(parent);
+ }
+ if (nsnull != parent) {
+ nsIPresShell* shell = aPresContext->GetShell();
+ state = (nsBlockReflowState*) shell->GetCachedData(parent);
+ // XXX Of course this won't work if the inline span is nested
+ // in another inline span!
+ state->breakAfterChild = PR_TRUE;
+ NS_RELEASE(shell);
+ }
+ }
+ NS_IF_RELEASE(tag);
+ }
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, kidIndex, this);
NS_RELEASE(kidDel);
@@ -634,6 +684,11 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
break;
}
kidPrevInFlow = nsnull;
+
+ // If we need to break after the kidFrame, then do so now
+ if (breakAfter) {
+ break;
+ }
}
done:;
@@ -668,15 +723,15 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
// Get the style molecule
nsStyleFont* styleFont =
(nsStyleFont*)mStyleContext->GetData(kStyleFontSID);
- nsStyleMolecule* styleMolecule =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleSpacing* styleSpacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
// Check for an overflow list
MoveOverflowToChildList();
// Initialize our reflow state. We must wait until after we've processed
// the overflow list, because our first content offset might change
- nsInlineState state(styleFont, styleMolecule, aMaxSize, aMaxElementSize);
+ nsInlineState state(styleFont, styleSpacing, aMaxSize, aMaxElementSize);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
// Reflow any existing frames
@@ -710,7 +765,7 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
}
}
- const nsMargin& insets = styleMolecule->borderPadding;
+ const nsMargin& insets = styleSpacing->mBorderPadding;
// Vertically align the children
nscoord lineHeight =
@@ -895,9 +950,7 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
// Recover the reflow state as if we had reflowed our children up
// to but not including the child that is next in the reflow chain
- nsStyleMolecule* styleMolecule =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- nsInlineState state(styleMolecule, aMaxSize, nsnull);
+ nsInlineState state(aMaxSize, nsnull);
state.SetNumAscents(mChildCount);
PRIntn nextIndex = RecoverState(aPresContext, state, nextInChain);
@@ -981,8 +1034,8 @@ nsInlineFrame::AdjustChildren(nsIPresContext* aPresContext,
nsReflowMetrics& aKidMetrics,
ReflowStatus aKidReflowStatus)
{
- nsStyleMolecule* mol = aState.mol;
- nscoord xr = aState.availSize.width + mol->borderPadding.left;
+ nsStyleSpacing* spacing = aState.spacing;
+ nscoord xr = aState.availSize.width + spacing->mBorderPadding.left;
nscoord remainingSpace = xr - aState.x;
nscoord x = aState.x;
@@ -1000,7 +1053,7 @@ nsInlineFrame::AdjustChildren(nsIPresContext* aPresContext,
}
// Vertically align the children
- const nsMargin& insets = mol->borderPadding;
+ const nsMargin& insets = spacing->mBorderPadding;
nsCSSLayout::VerticallyAlignChildren(aPresContext, this, aState.font,
insets.top, mFirstChild, mChildCount,
aState.ascents, aState.maxAscent);
diff --git a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp
index da6acb2e9c0..9510d1e4c9a 100644
--- a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp
+++ b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp
@@ -29,7 +29,6 @@
#include "nsViewsCID.h"
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
NS_DEF_PTR(nsIStyleContext);
diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp
index 8697f2d49a7..84fd53b081b 100644
--- a/mozilla/layout/html/base/src/nsBlockFrame.cpp
+++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp
@@ -48,9 +48,12 @@
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
static NS_DEFINE_IID(kIFloaterContainerIID, NS_IFLOATERCONTAINER_IID);
static NS_DEFINE_IID(kIAnchoredItemsIID, NS_IANCHOREDITEMS_IID);
-static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -100,8 +103,7 @@ nsBlockReflowState::nsBlockReflowState()
void nsBlockReflowState::Init(const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleFont* aFont,
- nsStyleMolecule* aMol,
+ nsIStyleContext* aBlockSC,
nsISpaceManager* aSpaceManager)
{
firstLine = PR_TRUE;
@@ -114,8 +116,15 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
spaceManager = aSpaceManager;
currentBand = new BlockBandData;
- font = aFont;
- mol = aMol;
+
+ styleContext = aBlockSC;
+ styleText = (nsStyleText*) aBlockSC->GetData(kStyleTextSID);
+ styleFont = (nsStyleFont*) aBlockSC->GetData(kStyleFontSID);
+ styleDisplay = (nsStyleDisplay*) aBlockSC->GetData(kStyleDisplaySID);
+
+ justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign) &&
+ (NS_STYLE_WHITESPACE_PRE != styleText->mWhiteSpace);
+
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
maxElementSize = aMaxElementSize;
@@ -155,8 +164,6 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
- justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mol->textAlign) &&
- (NS_STYLE_WHITESPACE_PRE != mol->whiteSpace);
reflowStatus = nsIFrame::frNotComplete;
}
@@ -300,11 +307,11 @@ nsBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
// type and the display type of the previous child frame.
//
// Adjacent vertical margins between block-level elements are collapsed.
-nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
+nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
nsBlockReflowState& aState,
- nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol,
- PRBool aIsInline)
+ nsIFrame* aKidFrame,
+ nsIStyleContext* aKidSC,
+ PRBool aIsInline)
{
if (aIsInline) {
// Just use whatever the previous bottom margin was
@@ -318,10 +325,11 @@ nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
if (nsnull == kidPrevInFlow) {
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if (aKidMol->margin.top < 0) {
- maxNegTopMargin = -aKidMol->margin.top;
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ if (ss->mMargin.top < 0) {
+ maxNegTopMargin = -ss->mMargin.top;
} else {
- maxPosTopMargin = aKidMol->margin.top;
+ maxPosTopMargin = ss->mMargin.top;
}
nscoord maxPos = PR_MAX(aState.prevMaxPosBottomMargin, maxPosTopMargin);
@@ -354,20 +362,22 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
floater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* sd = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
floater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == sd->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == sd->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
// XXX Don't forget the floater's margins...
- mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left, 0);
+ mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left,
+ 0);
mCurrentState->spaceManager->AddRectRegion(region, floater);
// Set the origin of the floater in world coordinates
@@ -398,9 +408,13 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
if (aState.isInline) {
// Vertically align the children on this line, returning the height of
// the line upon completion.
- lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this, aState.font, y,
- aState.lineStart, aState.lineLength,
- aState.ascents, aState.maxAscent);
+ lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this,
+ aState.styleFont,
+ y,
+ aState.lineStart,
+ aState.lineLength,
+ aState.ascents,
+ aState.maxAscent);
// Any below current line floaters to place?
if (aState.floaterToDo.Count() > 0) {
@@ -445,7 +459,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// doing an unconstrained (in x) reflow. There's no point in doing
// the work if we *know* we are going to reflowed again.
if (!aState.unconstrainedWidth) {
- nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.mol,
+ nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.styleText,
aState.lineStart, aState.lineLength,
aState.lineWidth,
aState.availSize.width);
@@ -453,7 +467,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
if (!aState.justifying) {
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
+ nsCSSLayout::RelativePositionChildren(aCX, this,
aState.lineStart,
aState.lineLength);
}
@@ -499,17 +513,15 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsReflowMetrics& aKidSize,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
- PRIntn direction = aState.mol->direction;
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
@@ -519,15 +531,16 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
r.y = aState.y;
r.width = aKidSize.width;
r.height = aKidSize.height;
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
// Left to right positioning.
- r.x = aState.borderPadding.left + aState.x + aKidMol->margin.left;
- aState.x += aKidSize.width + aKidMol->margin.left + aKidMol->margin.right;
+ r.x = aState.borderPadding.left + aState.x + ss->mMargin.left;
+ aState.x += aKidSize.width + ss->mMargin.left + ss->mMargin.right;
} else {
// Right to left positioning
// XXX what should we do when aState.x goes negative???
- r.x = aState.x - aState.borderPadding.right - aKidMol->margin.right - aKidSize.width;
- aState.x -= aKidSize.width + aKidMol->margin.right + aKidMol->margin.left;
+ r.x = aState.x - aState.borderPadding.right - ss->mMargin.right -
+ aKidSize.width;
+ aState.x -= aKidSize.width + ss->mMargin.right + ss->mMargin.left;
}
aKidFrame->SetRect(r);
aState.AddAscent(aKidSize.ascent);
@@ -551,7 +564,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
#if 0
// XXX CSS2 spec says that top/bottom margin don't affect line height
// calculation. We're waiting for clarification on this issue...
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = ss->mMargin.top) < 0) {
margin = -margin;
if (margin > aState.maxNegTopMargin) {
aState.maxNegTopMargin = margin;
@@ -562,7 +575,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
}
}
#endif
- if ((margin = aKidMol->margin.bottom) < 0) {
+ if ((margin = ss->mMargin.bottom) < 0) {
margin = -margin;
if (margin > aState.maxNegBottomMargin) {
aState.maxNegBottomMargin = margin;
@@ -593,20 +606,20 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsRect& aKidRect,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
+
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
// Translate from the kid's coordinate space to our coordinate space
- aKidRect.x += aState.borderPadding.left + aKidMol->margin.left;
+ aKidRect.x += aState.borderPadding.left + ss->mMargin.left;
aKidRect.y += aState.y + aState.topMargin;
// Place and size the child
@@ -616,7 +629,7 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
aState.lineLength++;
// Is this the widest child frame?
- nscoord xMost = aKidRect.XMost() + aKidMol->margin.right;
+ nscoord xMost = aKidRect.XMost() + ss->mMargin.right;
if (xMost > aState.kidXMost) {
aState.kidXMost = xMost;
}
@@ -633,17 +646,17 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
// and the bottom line margin information which we'll use when placing
// the next child
- if (aKidMol->margin.bottom < 0) {
- aState.maxNegBottomMargin = -aKidMol->margin.bottom;
+ if (ss->mMargin.bottom < 0) {
+ aState.maxNegBottomMargin = -ss->mMargin.bottom;
} else {
- aState.maxPosBottomMargin = aKidMol->margin.bottom;
+ aState.maxPosBottomMargin = ss->mMargin.bottom;
}
// Update the running y-offset
aState.y += aKidRect.height + aState.topMargin;
// Apply relative positioning if necessary
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol, aKidFrame, 1);
+ nsCSSLayout::RelativePositionChildren(aCX, this, aKidFrame, 1);
// Advance to the next line
aState.AdvanceToNextLine(aKidFrame, aKidRect.height);
@@ -656,19 +669,19 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
*/
void nsBlockFrame::GetAvailSize(nsSize& aResult,
nsBlockReflowState& aState,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline)
{
// Determine the maximum available reflow height for the child
nscoord yb = aState.borderPadding.top + aState.availSize.height;
aResult.height = aState.unconstrainedHeight ? NS_UNCONSTRAINEDSIZE :
- yb - aState.y - aState.topMargin;
+ yb - aState.y - aState.topMargin;
// Determine the maximum available reflow width for the child
if (aState.unconstrainedWidth) {
aResult.width = NS_UNCONSTRAINEDSIZE;
} else if (aIsInline) {
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
} else {
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
@@ -830,13 +843,15 @@ getBand:
}
if (isLeftFloater) {
- if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_LEFT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
}
if (isRightFloater) {
- if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_RIGHT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
@@ -853,7 +868,7 @@ PRIntn
nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
nsSize kidMaxElementSize;
nsSize* pKidMaxElementSize =
@@ -866,17 +881,12 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Get kid and its style
- // XXX How is this any different than what was passed in to us as aKidMol?
- nsIContentPtr kid;
- nsIStyleContextPtr kidSC;
-
- aKidFrame->GetContent(kid.AssignRef());
- aKidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
// Figure out if kid is a block element or not
PRBool isInline = PR_TRUE;
- PRIntn display = kidMol->display;
+ PRIntn display = styleDisplay->mDisplay;
if (aState.firstChildIsInsideBullet && (mFirstChild == aKidFrame)) {
// XXX Special hack for properly reflowing bullets that have the
// inside value for list-style-position.
@@ -909,15 +919,20 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
aState.lineStart = aKidFrame;
- // Get the style for the last child, and see if it wanted to clear floaters.
- // This handles the BR tag, which is the only inline element for which clear
- // applies
+ // Get the style for the last child, and see if it wanted to clear
+ // floaters. This handles the BR tag, which is the only inline
+ // element for which clear applies
nsIStyleContextPtr lastChildSC;
lastFrame->GetStyleContext(aCX, lastChildSC.AssignRef());
- nsStyleMolecule* lastChildMol = (nsStyleMolecule*)lastChildSC->GetData(kStyleMoleculeSID);
- if (lastChildMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, lastChildMol->clear);
+ nsStyleDisplay* lastChildDisplay = (nsStyleDisplay*)
+ lastChildSC->GetData(kStyleDisplaySID);
+ switch (lastChildDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, lastChildDisplay->mBreakType);
+ break;
}
}
@@ -929,7 +944,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// should use
if (aState.lineStart == aKidFrame) {
// Compute the top margin to use for this line
- aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, kidMol, aState.isInline);
+ aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, aKidSC,
+ aState.isInline);
// If it's an inline element then get a band of available space
//
@@ -943,7 +959,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// Compute the available space to reflow the child into and then
// reflow it into that space.
nsSize kidAvailSize;
- GetAvailSize(kidAvailSize, aState, kidMol, aState.isInline);
+ GetAvailSize(kidAvailSize, aState, aKidSC, aState.isInline);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
@@ -990,7 +1006,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
GetAvailableSpaceBand(aState, aState.y + aState.topMargin);
// Reflow child now that it has the line to itself
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
}
@@ -1017,7 +1033,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
if (isSplittable != frNotSplittable) {
// Update size info now that we are on the next line. Then
// reflow the child into the new available space.
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
@@ -1044,21 +1060,27 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Add child to the line
- AddInlineChildToLine(aCX, aState, aKidFrame, kidSize, pKidMaxElementSize, kidMol);
-
+ AddInlineChildToLine(aCX, aState, aKidFrame, kidSize,
+ pKidMaxElementSize, aKidSC);
} else {
nsRect kidRect;
// Does the block-level element want to clear any floaters that impact
// it? Note that the clear property only applies to block-level elements
// and the BR tag
- if (aKidMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, aKidMol->clear);
- GetAvailSize(kidAvailSize, aState, kidMol, PR_FALSE);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
+ switch (styleDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, styleDisplay->mBreakType);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_FALSE);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
}
+ break;
}
// Give the block its own local coordinate space.. Note: ReflowChild()
@@ -1066,8 +1088,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// current left/right edge
aState.spaceManager->Translate(aState.borderPadding.left, 0);
// Give the block-level element the opportunity to use the space manager
- status = ReflowChild(aKidFrame, aCX, kidMol, aState.spaceManager, kidAvailSize,
- kidRect, pKidMaxElementSize);
+ status = ReflowChild(aKidFrame, aCX, aState.spaceManager,
+ kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
// For first children, we skip all the fit checks because we must
@@ -1087,7 +1109,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// calls AdvaneceToNextLine(). We need to restructure the flow of control,
// and use a state machine...
aState.lastContentIsComplete = PRBool(status == frComplete);
- AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, kidMol);
+ AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, aKidSC);
}
// If we just reflowed our last child then update the
@@ -1147,7 +1169,6 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
// Attempt to place and reflow the child
@@ -1155,7 +1176,7 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
// it is, otherwise advance to the next line and place it there if
// possible
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
ReflowStatus status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// The child doesn't fit. Push it and any remaining children.
@@ -1237,8 +1258,9 @@ PRBool nsBlockFrame::MoreToReflow(nsIPresContext* aCX)
if (nsnull != kid) {
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- switch (kidMol->display) {
+ nsStyleDisplay* kidStyleDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
+ switch (kidStyleDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Block pseudo-frames do not contain other block elements
@@ -1303,21 +1325,23 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStylePosition* kidPosition = (nsStylePosition*)kidSC->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidSC->GetData(kStylePositionSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Check whether it wants to floated or absolutely positioned
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
- } else if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
} else if (nsnull == kidPrevInFlow) {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -1378,7 +1402,7 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// complete.
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// We ran out of room.
@@ -1411,7 +1435,6 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
}
#ifdef NS_DEBUG
nsIFrame* kidNextInFlow;
@@ -1493,11 +1516,10 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// Push the kids that didn't fit back down to the next-in-flow
@@ -1534,7 +1556,6 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
} else {
// The child has a next-in-flow, but it's not one of ours.
// It *must* be in one of our next-in-flows. Collect it
@@ -1597,20 +1618,19 @@ void nsBlockFrame::SetupState(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager)
{
// Setup reflow state
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- nsStyleFont* font =
- (nsStyleFont*)mStyleContext->GetData(kStyleFontSID);
- aState.Init(aMaxSize, aMaxElementSize, font, mol, aSpaceManager);
+ aState.Init(aMaxSize, aMaxElementSize, mStyleContext, aSpaceManager);
+
+ nsStyleSpacing* mySpacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
// Apply border and padding adjustments for regular frames only
if (PR_FALSE == IsPseudoFrame()) {
- aState.borderPadding = mol->borderPadding;
- aState.y = mol->borderPadding.top;
+ aState.borderPadding = mySpacing->mBorderPadding;
+ aState.y = mySpacing->mBorderPadding.top;
aState.availSize.width -=
- (mol->borderPadding.left + mol->borderPadding.right);
+ (mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right);
aState.availSize.height -=
- (mol->borderPadding.top + mol->borderPadding.bottom);
+ (mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom);
} else {
aState.borderPadding.SizeTo(0, 0, 0, 0);
}
@@ -1830,8 +1850,7 @@ void nsBlockFrame::JustifyLines(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
- lineStart, mLines[i]);
+ nsCSSLayout::RelativePositionChildren(aCX, this, lineStart, mLines[i]);
}
}
@@ -1952,7 +1971,8 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
aFloater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* floaterDisplay = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
if (!mCurrentState->isInline) {
// Get the current band for this line
@@ -1965,10 +1985,10 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
aFloater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
@@ -1997,9 +2017,10 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
{
// Get the last-in-flow
nsBlockFrame* flow = (nsBlockFrame*)GetLastInFlow();
-
PRInt32 kidIndex = flow->NextChildOffset();
PRInt32 startIndex = kidIndex;
+
+#if 0
nsIFrame* kidFrame = nsnull;
nsIFrame* prevKidFrame;
@@ -2013,16 +2034,17 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aPresContext->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Is it a floater?
- if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
} else {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -2073,6 +2095,7 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
mChildCount++;
}
SetLastContentOffset(prevKidFrame);
+#endif
// If this is a pseudo-frame then our parent will generate the
// reflow command. Otherwise, if the container is us then we should
@@ -2106,7 +2129,14 @@ nsHTMLFrameType nsBlockFrame::GetFrameType() const
NS_METHOD nsBlockFrame::ListTag(FILE* out) const
{
if ((nsnull != mGeometricParent) && IsPseudoFrame()) {
- fprintf(out, "*block(%d)@%p", mIndexInParent, this);
+ fprintf(out, "*block<");
+ nsIAtom* atom = mContent->GetTag();
+ if (nsnull != atom) {
+ nsAutoString tmp;
+ atom->ToString(tmp);
+ fputs(tmp, out);
+ }
+ fprintf(out, ">(%d)@%p", mIndexInParent, this);
} else {
nsHTMLContainerFrame::ListTag(out);
}
diff --git a/mozilla/layout/html/base/src/nsBlockFrame.h b/mozilla/layout/html/base/src/nsBlockFrame.h
index cb8a2b18f88..f11bba52ca1 100644
--- a/mozilla/layout/html/base/src/nsBlockFrame.h
+++ b/mozilla/layout/html/base/src/nsBlockFrame.h
@@ -25,7 +25,9 @@
#include "nsVoidArray.h"
struct BlockBandData;
struct nsMargin;
+struct nsStyleDisplay;
struct nsStyleFont;
+struct nsStyleText;
/**
* Block frames have some state which needs to be made
@@ -65,9 +67,11 @@ struct nsBlockReflowState {
// Space manager to use
nsISpaceManager* spaceManager;
- // Block's style data
- nsStyleFont* font;
- nsStyleMolecule* mol;
+ // Block's style context
+ nsIStyleContext* styleContext;
+ nsStyleText* styleText;
+ nsStyleFont* styleFont;
+ nsStyleDisplay* styleDisplay;
// Block's available size (computed from the block's parent)
nsSize availSize;
@@ -139,7 +143,7 @@ struct nsBlockReflowState {
~nsBlockReflowState();
void Init(const nsSize& aMaxSize, nsSize* aMaxElementSize,
- nsStyleFont* aFont, nsStyleMolecule* aMol, nsISpaceManager* aSpaceManager);
+ nsIStyleContext* aStyleContext, nsISpaceManager* aSpaceManager);
void AddAscent(nscoord aAscent);
void AdvanceToNextLine(nsIFrame* aPrevLineLastFrame, nscoord aPrevLineHeight);
@@ -247,7 +251,7 @@ protected:
nscoord GetTopMarginFor(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline);
PRBool AdvanceToNextLine(nsIPresContext* aPresContext,
@@ -258,24 +262,24 @@ protected:
nsIFrame* aKidFrame,
nsReflowMetrics& aKidSize,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol);
+ nsIStyleContext* aKidSC);
void AddBlockChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
nsRect& aKidRect,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol);
+ nsIStyleContext* aKidSC);
void GetAvailSize(nsSize& aResult,
nsBlockReflowState& aState,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline);
PRIntn PlaceAndReflowChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* kidFrame,
- nsStyleMolecule* aKidMol);
+ nsIStyleContext* aKidSC);
void PushKids(nsBlockReflowState& aState);
diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp
index 8697f2d49a7..84fd53b081b 100644
--- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp
+++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp
@@ -48,9 +48,12 @@
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
static NS_DEFINE_IID(kIFloaterContainerIID, NS_IFLOATERCONTAINER_IID);
static NS_DEFINE_IID(kIAnchoredItemsIID, NS_IANCHOREDITEMS_IID);
-static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -100,8 +103,7 @@ nsBlockReflowState::nsBlockReflowState()
void nsBlockReflowState::Init(const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleFont* aFont,
- nsStyleMolecule* aMol,
+ nsIStyleContext* aBlockSC,
nsISpaceManager* aSpaceManager)
{
firstLine = PR_TRUE;
@@ -114,8 +116,15 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
spaceManager = aSpaceManager;
currentBand = new BlockBandData;
- font = aFont;
- mol = aMol;
+
+ styleContext = aBlockSC;
+ styleText = (nsStyleText*) aBlockSC->GetData(kStyleTextSID);
+ styleFont = (nsStyleFont*) aBlockSC->GetData(kStyleFontSID);
+ styleDisplay = (nsStyleDisplay*) aBlockSC->GetData(kStyleDisplaySID);
+
+ justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign) &&
+ (NS_STYLE_WHITESPACE_PRE != styleText->mWhiteSpace);
+
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
maxElementSize = aMaxElementSize;
@@ -155,8 +164,6 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
- justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mol->textAlign) &&
- (NS_STYLE_WHITESPACE_PRE != mol->whiteSpace);
reflowStatus = nsIFrame::frNotComplete;
}
@@ -300,11 +307,11 @@ nsBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
// type and the display type of the previous child frame.
//
// Adjacent vertical margins between block-level elements are collapsed.
-nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
+nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
nsBlockReflowState& aState,
- nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol,
- PRBool aIsInline)
+ nsIFrame* aKidFrame,
+ nsIStyleContext* aKidSC,
+ PRBool aIsInline)
{
if (aIsInline) {
// Just use whatever the previous bottom margin was
@@ -318,10 +325,11 @@ nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
if (nsnull == kidPrevInFlow) {
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if (aKidMol->margin.top < 0) {
- maxNegTopMargin = -aKidMol->margin.top;
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ if (ss->mMargin.top < 0) {
+ maxNegTopMargin = -ss->mMargin.top;
} else {
- maxPosTopMargin = aKidMol->margin.top;
+ maxPosTopMargin = ss->mMargin.top;
}
nscoord maxPos = PR_MAX(aState.prevMaxPosBottomMargin, maxPosTopMargin);
@@ -354,20 +362,22 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
floater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* sd = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
floater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == sd->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == sd->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
// XXX Don't forget the floater's margins...
- mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left, 0);
+ mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left,
+ 0);
mCurrentState->spaceManager->AddRectRegion(region, floater);
// Set the origin of the floater in world coordinates
@@ -398,9 +408,13 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
if (aState.isInline) {
// Vertically align the children on this line, returning the height of
// the line upon completion.
- lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this, aState.font, y,
- aState.lineStart, aState.lineLength,
- aState.ascents, aState.maxAscent);
+ lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this,
+ aState.styleFont,
+ y,
+ aState.lineStart,
+ aState.lineLength,
+ aState.ascents,
+ aState.maxAscent);
// Any below current line floaters to place?
if (aState.floaterToDo.Count() > 0) {
@@ -445,7 +459,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// doing an unconstrained (in x) reflow. There's no point in doing
// the work if we *know* we are going to reflowed again.
if (!aState.unconstrainedWidth) {
- nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.mol,
+ nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.styleText,
aState.lineStart, aState.lineLength,
aState.lineWidth,
aState.availSize.width);
@@ -453,7 +467,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
if (!aState.justifying) {
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
+ nsCSSLayout::RelativePositionChildren(aCX, this,
aState.lineStart,
aState.lineLength);
}
@@ -499,17 +513,15 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsReflowMetrics& aKidSize,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
- PRIntn direction = aState.mol->direction;
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
@@ -519,15 +531,16 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
r.y = aState.y;
r.width = aKidSize.width;
r.height = aKidSize.height;
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
// Left to right positioning.
- r.x = aState.borderPadding.left + aState.x + aKidMol->margin.left;
- aState.x += aKidSize.width + aKidMol->margin.left + aKidMol->margin.right;
+ r.x = aState.borderPadding.left + aState.x + ss->mMargin.left;
+ aState.x += aKidSize.width + ss->mMargin.left + ss->mMargin.right;
} else {
// Right to left positioning
// XXX what should we do when aState.x goes negative???
- r.x = aState.x - aState.borderPadding.right - aKidMol->margin.right - aKidSize.width;
- aState.x -= aKidSize.width + aKidMol->margin.right + aKidMol->margin.left;
+ r.x = aState.x - aState.borderPadding.right - ss->mMargin.right -
+ aKidSize.width;
+ aState.x -= aKidSize.width + ss->mMargin.right + ss->mMargin.left;
}
aKidFrame->SetRect(r);
aState.AddAscent(aKidSize.ascent);
@@ -551,7 +564,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
#if 0
// XXX CSS2 spec says that top/bottom margin don't affect line height
// calculation. We're waiting for clarification on this issue...
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = ss->mMargin.top) < 0) {
margin = -margin;
if (margin > aState.maxNegTopMargin) {
aState.maxNegTopMargin = margin;
@@ -562,7 +575,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
}
}
#endif
- if ((margin = aKidMol->margin.bottom) < 0) {
+ if ((margin = ss->mMargin.bottom) < 0) {
margin = -margin;
if (margin > aState.maxNegBottomMargin) {
aState.maxNegBottomMargin = margin;
@@ -593,20 +606,20 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsRect& aKidRect,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
+
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
// Translate from the kid's coordinate space to our coordinate space
- aKidRect.x += aState.borderPadding.left + aKidMol->margin.left;
+ aKidRect.x += aState.borderPadding.left + ss->mMargin.left;
aKidRect.y += aState.y + aState.topMargin;
// Place and size the child
@@ -616,7 +629,7 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
aState.lineLength++;
// Is this the widest child frame?
- nscoord xMost = aKidRect.XMost() + aKidMol->margin.right;
+ nscoord xMost = aKidRect.XMost() + ss->mMargin.right;
if (xMost > aState.kidXMost) {
aState.kidXMost = xMost;
}
@@ -633,17 +646,17 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
// and the bottom line margin information which we'll use when placing
// the next child
- if (aKidMol->margin.bottom < 0) {
- aState.maxNegBottomMargin = -aKidMol->margin.bottom;
+ if (ss->mMargin.bottom < 0) {
+ aState.maxNegBottomMargin = -ss->mMargin.bottom;
} else {
- aState.maxPosBottomMargin = aKidMol->margin.bottom;
+ aState.maxPosBottomMargin = ss->mMargin.bottom;
}
// Update the running y-offset
aState.y += aKidRect.height + aState.topMargin;
// Apply relative positioning if necessary
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol, aKidFrame, 1);
+ nsCSSLayout::RelativePositionChildren(aCX, this, aKidFrame, 1);
// Advance to the next line
aState.AdvanceToNextLine(aKidFrame, aKidRect.height);
@@ -656,19 +669,19 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
*/
void nsBlockFrame::GetAvailSize(nsSize& aResult,
nsBlockReflowState& aState,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline)
{
// Determine the maximum available reflow height for the child
nscoord yb = aState.borderPadding.top + aState.availSize.height;
aResult.height = aState.unconstrainedHeight ? NS_UNCONSTRAINEDSIZE :
- yb - aState.y - aState.topMargin;
+ yb - aState.y - aState.topMargin;
// Determine the maximum available reflow width for the child
if (aState.unconstrainedWidth) {
aResult.width = NS_UNCONSTRAINEDSIZE;
} else if (aIsInline) {
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
} else {
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
@@ -830,13 +843,15 @@ getBand:
}
if (isLeftFloater) {
- if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_LEFT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
}
if (isRightFloater) {
- if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_RIGHT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
@@ -853,7 +868,7 @@ PRIntn
nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
nsSize kidMaxElementSize;
nsSize* pKidMaxElementSize =
@@ -866,17 +881,12 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Get kid and its style
- // XXX How is this any different than what was passed in to us as aKidMol?
- nsIContentPtr kid;
- nsIStyleContextPtr kidSC;
-
- aKidFrame->GetContent(kid.AssignRef());
- aKidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
// Figure out if kid is a block element or not
PRBool isInline = PR_TRUE;
- PRIntn display = kidMol->display;
+ PRIntn display = styleDisplay->mDisplay;
if (aState.firstChildIsInsideBullet && (mFirstChild == aKidFrame)) {
// XXX Special hack for properly reflowing bullets that have the
// inside value for list-style-position.
@@ -909,15 +919,20 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
aState.lineStart = aKidFrame;
- // Get the style for the last child, and see if it wanted to clear floaters.
- // This handles the BR tag, which is the only inline element for which clear
- // applies
+ // Get the style for the last child, and see if it wanted to clear
+ // floaters. This handles the BR tag, which is the only inline
+ // element for which clear applies
nsIStyleContextPtr lastChildSC;
lastFrame->GetStyleContext(aCX, lastChildSC.AssignRef());
- nsStyleMolecule* lastChildMol = (nsStyleMolecule*)lastChildSC->GetData(kStyleMoleculeSID);
- if (lastChildMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, lastChildMol->clear);
+ nsStyleDisplay* lastChildDisplay = (nsStyleDisplay*)
+ lastChildSC->GetData(kStyleDisplaySID);
+ switch (lastChildDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, lastChildDisplay->mBreakType);
+ break;
}
}
@@ -929,7 +944,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// should use
if (aState.lineStart == aKidFrame) {
// Compute the top margin to use for this line
- aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, kidMol, aState.isInline);
+ aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, aKidSC,
+ aState.isInline);
// If it's an inline element then get a band of available space
//
@@ -943,7 +959,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// Compute the available space to reflow the child into and then
// reflow it into that space.
nsSize kidAvailSize;
- GetAvailSize(kidAvailSize, aState, kidMol, aState.isInline);
+ GetAvailSize(kidAvailSize, aState, aKidSC, aState.isInline);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
@@ -990,7 +1006,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
GetAvailableSpaceBand(aState, aState.y + aState.topMargin);
// Reflow child now that it has the line to itself
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
}
@@ -1017,7 +1033,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
if (isSplittable != frNotSplittable) {
// Update size info now that we are on the next line. Then
// reflow the child into the new available space.
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
@@ -1044,21 +1060,27 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Add child to the line
- AddInlineChildToLine(aCX, aState, aKidFrame, kidSize, pKidMaxElementSize, kidMol);
-
+ AddInlineChildToLine(aCX, aState, aKidFrame, kidSize,
+ pKidMaxElementSize, aKidSC);
} else {
nsRect kidRect;
// Does the block-level element want to clear any floaters that impact
// it? Note that the clear property only applies to block-level elements
// and the BR tag
- if (aKidMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, aKidMol->clear);
- GetAvailSize(kidAvailSize, aState, kidMol, PR_FALSE);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
+ switch (styleDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, styleDisplay->mBreakType);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_FALSE);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
}
+ break;
}
// Give the block its own local coordinate space.. Note: ReflowChild()
@@ -1066,8 +1088,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// current left/right edge
aState.spaceManager->Translate(aState.borderPadding.left, 0);
// Give the block-level element the opportunity to use the space manager
- status = ReflowChild(aKidFrame, aCX, kidMol, aState.spaceManager, kidAvailSize,
- kidRect, pKidMaxElementSize);
+ status = ReflowChild(aKidFrame, aCX, aState.spaceManager,
+ kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
// For first children, we skip all the fit checks because we must
@@ -1087,7 +1109,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// calls AdvaneceToNextLine(). We need to restructure the flow of control,
// and use a state machine...
aState.lastContentIsComplete = PRBool(status == frComplete);
- AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, kidMol);
+ AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, aKidSC);
}
// If we just reflowed our last child then update the
@@ -1147,7 +1169,6 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
// Attempt to place and reflow the child
@@ -1155,7 +1176,7 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
// it is, otherwise advance to the next line and place it there if
// possible
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
ReflowStatus status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// The child doesn't fit. Push it and any remaining children.
@@ -1237,8 +1258,9 @@ PRBool nsBlockFrame::MoreToReflow(nsIPresContext* aCX)
if (nsnull != kid) {
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- switch (kidMol->display) {
+ nsStyleDisplay* kidStyleDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
+ switch (kidStyleDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Block pseudo-frames do not contain other block elements
@@ -1303,21 +1325,23 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStylePosition* kidPosition = (nsStylePosition*)kidSC->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidSC->GetData(kStylePositionSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Check whether it wants to floated or absolutely positioned
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
- } else if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
} else if (nsnull == kidPrevInFlow) {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -1378,7 +1402,7 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// complete.
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// We ran out of room.
@@ -1411,7 +1435,6 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
}
#ifdef NS_DEBUG
nsIFrame* kidNextInFlow;
@@ -1493,11 +1516,10 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// Push the kids that didn't fit back down to the next-in-flow
@@ -1534,7 +1556,6 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
} else {
// The child has a next-in-flow, but it's not one of ours.
// It *must* be in one of our next-in-flows. Collect it
@@ -1597,20 +1618,19 @@ void nsBlockFrame::SetupState(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager)
{
// Setup reflow state
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- nsStyleFont* font =
- (nsStyleFont*)mStyleContext->GetData(kStyleFontSID);
- aState.Init(aMaxSize, aMaxElementSize, font, mol, aSpaceManager);
+ aState.Init(aMaxSize, aMaxElementSize, mStyleContext, aSpaceManager);
+
+ nsStyleSpacing* mySpacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
// Apply border and padding adjustments for regular frames only
if (PR_FALSE == IsPseudoFrame()) {
- aState.borderPadding = mol->borderPadding;
- aState.y = mol->borderPadding.top;
+ aState.borderPadding = mySpacing->mBorderPadding;
+ aState.y = mySpacing->mBorderPadding.top;
aState.availSize.width -=
- (mol->borderPadding.left + mol->borderPadding.right);
+ (mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right);
aState.availSize.height -=
- (mol->borderPadding.top + mol->borderPadding.bottom);
+ (mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom);
} else {
aState.borderPadding.SizeTo(0, 0, 0, 0);
}
@@ -1830,8 +1850,7 @@ void nsBlockFrame::JustifyLines(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
- lineStart, mLines[i]);
+ nsCSSLayout::RelativePositionChildren(aCX, this, lineStart, mLines[i]);
}
}
@@ -1952,7 +1971,8 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
aFloater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* floaterDisplay = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
if (!mCurrentState->isInline) {
// Get the current band for this line
@@ -1965,10 +1985,10 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
aFloater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
@@ -1997,9 +2017,10 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
{
// Get the last-in-flow
nsBlockFrame* flow = (nsBlockFrame*)GetLastInFlow();
-
PRInt32 kidIndex = flow->NextChildOffset();
PRInt32 startIndex = kidIndex;
+
+#if 0
nsIFrame* kidFrame = nsnull;
nsIFrame* prevKidFrame;
@@ -2013,16 +2034,17 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aPresContext->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Is it a floater?
- if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
} else {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -2073,6 +2095,7 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
mChildCount++;
}
SetLastContentOffset(prevKidFrame);
+#endif
// If this is a pseudo-frame then our parent will generate the
// reflow command. Otherwise, if the container is us then we should
@@ -2106,7 +2129,14 @@ nsHTMLFrameType nsBlockFrame::GetFrameType() const
NS_METHOD nsBlockFrame::ListTag(FILE* out) const
{
if ((nsnull != mGeometricParent) && IsPseudoFrame()) {
- fprintf(out, "*block(%d)@%p", mIndexInParent, this);
+ fprintf(out, "*block<");
+ nsIAtom* atom = mContent->GetTag();
+ if (nsnull != atom) {
+ nsAutoString tmp;
+ atom->ToString(tmp);
+ fputs(tmp, out);
+ }
+ fprintf(out, ">(%d)@%p", mIndexInParent, this);
} else {
nsHTMLContainerFrame::ListTag(out);
}
diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h
index 8697f2d49a7..84fd53b081b 100644
--- a/mozilla/layout/html/base/src/nsBlockReflowState.h
+++ b/mozilla/layout/html/base/src/nsBlockReflowState.h
@@ -48,9 +48,12 @@
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
static NS_DEFINE_IID(kIFloaterContainerIID, NS_IFLOATERCONTAINER_IID);
static NS_DEFINE_IID(kIAnchoredItemsIID, NS_IANCHOREDITEMS_IID);
-static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -100,8 +103,7 @@ nsBlockReflowState::nsBlockReflowState()
void nsBlockReflowState::Init(const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleFont* aFont,
- nsStyleMolecule* aMol,
+ nsIStyleContext* aBlockSC,
nsISpaceManager* aSpaceManager)
{
firstLine = PR_TRUE;
@@ -114,8 +116,15 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
spaceManager = aSpaceManager;
currentBand = new BlockBandData;
- font = aFont;
- mol = aMol;
+
+ styleContext = aBlockSC;
+ styleText = (nsStyleText*) aBlockSC->GetData(kStyleTextSID);
+ styleFont = (nsStyleFont*) aBlockSC->GetData(kStyleFontSID);
+ styleDisplay = (nsStyleDisplay*) aBlockSC->GetData(kStyleDisplaySID);
+
+ justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign) &&
+ (NS_STYLE_WHITESPACE_PRE != styleText->mWhiteSpace);
+
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
maxElementSize = aMaxElementSize;
@@ -155,8 +164,6 @@ void nsBlockReflowState::Init(const nsSize& aMaxSize,
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
- justifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mol->textAlign) &&
- (NS_STYLE_WHITESPACE_PRE != mol->whiteSpace);
reflowStatus = nsIFrame::frNotComplete;
}
@@ -300,11 +307,11 @@ nsBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
// type and the display type of the previous child frame.
//
// Adjacent vertical margins between block-level elements are collapsed.
-nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
+nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
nsBlockReflowState& aState,
- nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol,
- PRBool aIsInline)
+ nsIFrame* aKidFrame,
+ nsIStyleContext* aKidSC,
+ PRBool aIsInline)
{
if (aIsInline) {
// Just use whatever the previous bottom margin was
@@ -318,10 +325,11 @@ nscoord nsBlockFrame::GetTopMarginFor(nsIPresContext* aCX,
if (nsnull == kidPrevInFlow) {
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if (aKidMol->margin.top < 0) {
- maxNegTopMargin = -aKidMol->margin.top;
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ if (ss->mMargin.top < 0) {
+ maxNegTopMargin = -ss->mMargin.top;
} else {
- maxPosTopMargin = aKidMol->margin.top;
+ maxPosTopMargin = ss->mMargin.top;
}
nscoord maxPos = PR_MAX(aState.prevMaxPosBottomMargin, maxPosTopMargin);
@@ -354,20 +362,22 @@ void nsBlockFrame::PlaceBelowCurrentLineFloaters(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
floater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* sd = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
floater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == sd->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == sd->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
// XXX Don't forget the floater's margins...
- mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left, 0);
+ mCurrentState->spaceManager->Translate(mCurrentState->borderPadding.left,
+ 0);
mCurrentState->spaceManager->AddRectRegion(region, floater);
// Set the origin of the floater in world coordinates
@@ -398,9 +408,13 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
if (aState.isInline) {
// Vertically align the children on this line, returning the height of
// the line upon completion.
- lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this, aState.font, y,
- aState.lineStart, aState.lineLength,
- aState.ascents, aState.maxAscent);
+ lineHeight = nsCSSLayout::VerticallyAlignChildren(aCX, this,
+ aState.styleFont,
+ y,
+ aState.lineStart,
+ aState.lineLength,
+ aState.ascents,
+ aState.maxAscent);
// Any below current line floaters to place?
if (aState.floaterToDo.Count() > 0) {
@@ -445,7 +459,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// doing an unconstrained (in x) reflow. There's no point in doing
// the work if we *know* we are going to reflowed again.
if (!aState.unconstrainedWidth) {
- nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.mol,
+ nsCSSLayout::HorizontallyPlaceChildren(aCX, this, aState.styleText,
aState.lineStart, aState.lineLength,
aState.lineWidth,
aState.availSize.width);
@@ -453,7 +467,7 @@ PRBool nsBlockFrame::AdvanceToNextLine(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
if (!aState.justifying) {
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
+ nsCSSLayout::RelativePositionChildren(aCX, this,
aState.lineStart,
aState.lineLength);
}
@@ -499,17 +513,15 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsReflowMetrics& aKidSize,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
- PRIntn direction = aState.mol->direction;
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
@@ -519,15 +531,16 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
r.y = aState.y;
r.width = aKidSize.width;
r.height = aKidSize.height;
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
// Left to right positioning.
- r.x = aState.borderPadding.left + aState.x + aKidMol->margin.left;
- aState.x += aKidSize.width + aKidMol->margin.left + aKidMol->margin.right;
+ r.x = aState.borderPadding.left + aState.x + ss->mMargin.left;
+ aState.x += aKidSize.width + ss->mMargin.left + ss->mMargin.right;
} else {
// Right to left positioning
// XXX what should we do when aState.x goes negative???
- r.x = aState.x - aState.borderPadding.right - aKidMol->margin.right - aKidSize.width;
- aState.x -= aKidSize.width + aKidMol->margin.right + aKidMol->margin.left;
+ r.x = aState.x - aState.borderPadding.right - ss->mMargin.right -
+ aKidSize.width;
+ aState.x -= aKidSize.width + ss->mMargin.right + ss->mMargin.left;
}
aKidFrame->SetRect(r);
aState.AddAscent(aKidSize.ascent);
@@ -551,7 +564,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
#if 0
// XXX CSS2 spec says that top/bottom margin don't affect line height
// calculation. We're waiting for clarification on this issue...
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = ss->mMargin.top) < 0) {
margin = -margin;
if (margin > aState.maxNegTopMargin) {
aState.maxNegTopMargin = margin;
@@ -562,7 +575,7 @@ void nsBlockFrame::AddInlineChildToLine(nsIPresContext* aCX,
}
}
#endif
- if ((margin = aKidMol->margin.bottom) < 0) {
+ if ((margin = ss->mMargin.bottom) < 0) {
margin = -margin;
if (margin > aState.maxNegBottomMargin) {
aState.maxNegBottomMargin = margin;
@@ -593,20 +606,20 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
nsIFrame* aKidFrame,
nsRect& aKidRect,
nsSize* aKidMaxElementSize,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
NS_PRECONDITION(nsnull != aState.lineStart, "bad line");
- nsStylePosition* kidPosition;
-
- // Get the position style data
- aKidFrame->GetStyleData(kStylePositionSID, (nsStyleStruct*&)kidPosition);
- if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
+ nsStyleDisplay* ds = (nsStyleDisplay*) aKidSC->GetData(kStyleDisplaySID);
+ nsStyleSpacing* ss = (nsStyleSpacing*) aKidSC->GetData(kStyleSpacingSID);
+ nsStylePosition* sp = (nsStylePosition*) aKidSC->GetData(kStylePositionSID);
+
+ if (NS_STYLE_POSITION_RELATIVE == sp->mPosition) {
aState.needRelativePos = PR_TRUE;
}
// Translate from the kid's coordinate space to our coordinate space
- aKidRect.x += aState.borderPadding.left + aKidMol->margin.left;
+ aKidRect.x += aState.borderPadding.left + ss->mMargin.left;
aKidRect.y += aState.y + aState.topMargin;
// Place and size the child
@@ -616,7 +629,7 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
aState.lineLength++;
// Is this the widest child frame?
- nscoord xMost = aKidRect.XMost() + aKidMol->margin.right;
+ nscoord xMost = aKidRect.XMost() + ss->mMargin.right;
if (xMost > aState.kidXMost) {
aState.kidXMost = xMost;
}
@@ -633,17 +646,17 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
// and the bottom line margin information which we'll use when placing
// the next child
- if (aKidMol->margin.bottom < 0) {
- aState.maxNegBottomMargin = -aKidMol->margin.bottom;
+ if (ss->mMargin.bottom < 0) {
+ aState.maxNegBottomMargin = -ss->mMargin.bottom;
} else {
- aState.maxPosBottomMargin = aKidMol->margin.bottom;
+ aState.maxPosBottomMargin = ss->mMargin.bottom;
}
// Update the running y-offset
aState.y += aKidRect.height + aState.topMargin;
// Apply relative positioning if necessary
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol, aKidFrame, 1);
+ nsCSSLayout::RelativePositionChildren(aCX, this, aKidFrame, 1);
// Advance to the next line
aState.AdvanceToNextLine(aKidFrame, aKidRect.height);
@@ -656,19 +669,19 @@ void nsBlockFrame::AddBlockChild(nsIPresContext* aCX,
*/
void nsBlockFrame::GetAvailSize(nsSize& aResult,
nsBlockReflowState& aState,
- nsStyleMolecule* aKidMol,
+ nsIStyleContext* aKidSC,
PRBool aIsInline)
{
// Determine the maximum available reflow height for the child
nscoord yb = aState.borderPadding.top + aState.availSize.height;
aResult.height = aState.unconstrainedHeight ? NS_UNCONSTRAINEDSIZE :
- yb - aState.y - aState.topMargin;
+ yb - aState.y - aState.topMargin;
// Determine the maximum available reflow width for the child
if (aState.unconstrainedWidth) {
aResult.width = NS_UNCONSTRAINEDSIZE;
} else if (aIsInline) {
- if (NS_STYLE_DIRECTION_LTR == aState.mol->direction) {
+ if (NS_STYLE_DIRECTION_LTR == aState.styleDisplay->mDirection) {
aResult.width = aState.currentBand->trapezoids[0].xTopRight - aState.x;
} else {
aResult.width = aState.x - aState.currentBand->trapezoids[0].xTopLeft;
@@ -830,13 +843,15 @@ getBand:
}
if (isLeftFloater) {
- if ((aClear == NS_STYLE_CLEAR_LEFT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_LEFT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
}
if (isRightFloater) {
- if ((aClear == NS_STYLE_CLEAR_RIGHT) || (aClear == NS_STYLE_CLEAR_BOTH)) {
+ if ((aClear == NS_STYLE_CLEAR_RIGHT) ||
+ (aClear == NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
aState.y += aState.currentBand->trapezoids[0].GetHeight();
goto getBand;
}
@@ -853,7 +868,7 @@ PRIntn
nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
nsBlockReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol)
+ nsIStyleContext* aKidSC)
{
nsSize kidMaxElementSize;
nsSize* pKidMaxElementSize =
@@ -866,17 +881,12 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Get kid and its style
- // XXX How is this any different than what was passed in to us as aKidMol?
- nsIContentPtr kid;
- nsIStyleContextPtr kidSC;
-
- aKidFrame->GetContent(kid.AssignRef());
- aKidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
// Figure out if kid is a block element or not
PRBool isInline = PR_TRUE;
- PRIntn display = kidMol->display;
+ PRIntn display = styleDisplay->mDisplay;
if (aState.firstChildIsInsideBullet && (mFirstChild == aKidFrame)) {
// XXX Special hack for properly reflowing bullets that have the
// inside value for list-style-position.
@@ -909,15 +919,20 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
aState.lineStart = aKidFrame;
- // Get the style for the last child, and see if it wanted to clear floaters.
- // This handles the BR tag, which is the only inline element for which clear
- // applies
+ // Get the style for the last child, and see if it wanted to clear
+ // floaters. This handles the BR tag, which is the only inline
+ // element for which clear applies
nsIStyleContextPtr lastChildSC;
lastFrame->GetStyleContext(aCX, lastChildSC.AssignRef());
- nsStyleMolecule* lastChildMol = (nsStyleMolecule*)lastChildSC->GetData(kStyleMoleculeSID);
- if (lastChildMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, lastChildMol->clear);
+ nsStyleDisplay* lastChildDisplay = (nsStyleDisplay*)
+ lastChildSC->GetData(kStyleDisplaySID);
+ switch (lastChildDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, lastChildDisplay->mBreakType);
+ break;
}
}
@@ -929,7 +944,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// should use
if (aState.lineStart == aKidFrame) {
// Compute the top margin to use for this line
- aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, kidMol, aState.isInline);
+ aState.topMargin = GetTopMarginFor(aCX, aState, aKidFrame, aKidSC,
+ aState.isInline);
// If it's an inline element then get a band of available space
//
@@ -943,7 +959,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// Compute the available space to reflow the child into and then
// reflow it into that space.
nsSize kidAvailSize;
- GetAvailSize(kidAvailSize, aState, kidMol, aState.isInline);
+ GetAvailSize(kidAvailSize, aState, aKidSC, aState.isInline);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
@@ -990,7 +1006,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
GetAvailableSpaceBand(aState, aState.y + aState.topMargin);
// Reflow child now that it has the line to itself
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
}
@@ -1017,7 +1033,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
if (isSplittable != frNotSplittable) {
// Update size info now that we are on the next line. Then
// reflow the child into the new available space.
- GetAvailSize(kidAvailSize, aState, kidMol, PR_TRUE);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_TRUE);
status = ReflowChild(aKidFrame, aCX, kidSize, kidAvailSize,
pKidMaxElementSize);
@@ -1044,21 +1060,27 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
}
// Add child to the line
- AddInlineChildToLine(aCX, aState, aKidFrame, kidSize, pKidMaxElementSize, kidMol);
-
+ AddInlineChildToLine(aCX, aState, aKidFrame, kidSize,
+ pKidMaxElementSize, aKidSC);
} else {
nsRect kidRect;
// Does the block-level element want to clear any floaters that impact
// it? Note that the clear property only applies to block-level elements
// and the BR tag
- if (aKidMol->clear != NS_STYLE_CLEAR_NONE) {
- ClearFloaters(aState, aKidMol->clear);
- GetAvailSize(kidAvailSize, aState, kidMol, PR_FALSE);
+ nsStyleDisplay* styleDisplay = (nsStyleDisplay*)
+ aKidSC->GetData(kStyleDisplaySID);
+ switch (styleDisplay->mBreakType) {
+ case NS_STYLE_CLEAR_LEFT:
+ case NS_STYLE_CLEAR_RIGHT:
+ case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
+ ClearFloaters(aState, styleDisplay->mBreakType);
+ GetAvailSize(kidAvailSize, aState, aKidSC, PR_FALSE);
if ((aState.currentLineNumber > 0) && (kidAvailSize.height <= 0)) {
// No more room
return 0;
}
+ break;
}
// Give the block its own local coordinate space.. Note: ReflowChild()
@@ -1066,8 +1088,8 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// current left/right edge
aState.spaceManager->Translate(aState.borderPadding.left, 0);
// Give the block-level element the opportunity to use the space manager
- status = ReflowChild(aKidFrame, aCX, kidMol, aState.spaceManager, kidAvailSize,
- kidRect, pKidMaxElementSize);
+ status = ReflowChild(aKidFrame, aCX, aState.spaceManager,
+ kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(-aState.borderPadding.left, 0);
// For first children, we skip all the fit checks because we must
@@ -1087,7 +1109,7 @@ nsBlockFrame::PlaceAndReflowChild(nsIPresContext* aCX,
// calls AdvaneceToNextLine(). We need to restructure the flow of control,
// and use a state machine...
aState.lastContentIsComplete = PRBool(status == frComplete);
- AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, kidMol);
+ AddBlockChild(aCX, aState, aKidFrame, kidRect, pKidMaxElementSize, aKidSC);
}
// If we just reflowed our last child then update the
@@ -1147,7 +1169,6 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
// Attempt to place and reflow the child
@@ -1155,7 +1176,7 @@ nsBlockFrame::ReflowMappedChildren(nsIPresContext* aCX,
// it is, otherwise advance to the next line and place it there if
// possible
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
ReflowStatus status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// The child doesn't fit. Push it and any remaining children.
@@ -1237,8 +1258,9 @@ PRBool nsBlockFrame::MoreToReflow(nsIPresContext* aCX)
if (nsnull != kid) {
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- switch (kidMol->display) {
+ nsStyleDisplay* kidStyleDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
+ switch (kidStyleDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Block pseudo-frames do not contain other block elements
@@ -1303,21 +1325,23 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStylePosition* kidPosition = (nsStylePosition*)kidSC->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidSC->GetData(kStylePositionSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Check whether it wants to floated or absolutely positioned
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
- } else if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidSC);
} else if (nsnull == kidPrevInFlow) {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -1378,7 +1402,7 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// complete.
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// We ran out of room.
@@ -1411,7 +1435,6 @@ nsBlockFrame::ReflowAppendedChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
}
#ifdef NS_DEBUG
nsIFrame* kidNextInFlow;
@@ -1493,11 +1516,10 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
kidFrame->GetContent(kid.AssignRef());
nsIStyleContextPtr kidSC = aCX->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
ReflowStatus status;
do {
- PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidMol);
+ PRIntn placeStatus = PlaceAndReflowChild(aCX, aState, kidFrame, kidSC);
status = aState.reflowStatus;
if (0 == (placeStatus & PLACE_FIT)) {
// Push the kids that didn't fit back down to the next-in-flow
@@ -1534,7 +1556,6 @@ nsBlockFrame::PullUpChildren(nsIPresContext* aCX,
// Switch to new kid style
kidFrame->GetStyleContext(aCX, kidSC.AssignRef());
- kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
} else {
// The child has a next-in-flow, but it's not one of ours.
// It *must* be in one of our next-in-flows. Collect it
@@ -1597,20 +1618,19 @@ void nsBlockFrame::SetupState(nsIPresContext* aCX,
nsISpaceManager* aSpaceManager)
{
// Setup reflow state
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- nsStyleFont* font =
- (nsStyleFont*)mStyleContext->GetData(kStyleFontSID);
- aState.Init(aMaxSize, aMaxElementSize, font, mol, aSpaceManager);
+ aState.Init(aMaxSize, aMaxElementSize, mStyleContext, aSpaceManager);
+
+ nsStyleSpacing* mySpacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
// Apply border and padding adjustments for regular frames only
if (PR_FALSE == IsPseudoFrame()) {
- aState.borderPadding = mol->borderPadding;
- aState.y = mol->borderPadding.top;
+ aState.borderPadding = mySpacing->mBorderPadding;
+ aState.y = mySpacing->mBorderPadding.top;
aState.availSize.width -=
- (mol->borderPadding.left + mol->borderPadding.right);
+ (mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right);
aState.availSize.height -=
- (mol->borderPadding.top + mol->borderPadding.bottom);
+ (mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom);
} else {
aState.borderPadding.SizeTo(0, 0, 0, 0);
}
@@ -1830,8 +1850,7 @@ void nsBlockFrame::JustifyLines(nsIPresContext* aCX,
// Finally, now that the in-flow positions of the line's frames are
// known we can apply relative positioning if any of them need it.
- nsCSSLayout::RelativePositionChildren(aCX, this, aState.mol,
- lineStart, mLines[i]);
+ nsCSSLayout::RelativePositionChildren(aCX, this, lineStart, mLines[i]);
}
}
@@ -1952,7 +1971,8 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
nsIStyleContextPtr styleContext;
aFloater->GetStyleContext(aCX, styleContext.AssignRef());
- nsStyleMolecule* mol = (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* floaterDisplay = (nsStyleDisplay*)
+ styleContext->GetData(kStyleDisplaySID);
if (!mCurrentState->isInline) {
// Get the current band for this line
@@ -1965,10 +1985,10 @@ void nsBlockFrame::PlaceFloater(nsIPresContext* aCX,
aFloater->GetRect(region);
region.y = mCurrentState->currentBand->trapezoids[0].yTop;
- if (NS_STYLE_FLOAT_LEFT == mol->floats) {
+ if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {
region.x = mCurrentState->currentBand->trapezoids[0].xTopLeft;
} else {
- NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == mol->floats, "bad float type");
+ NS_ASSERTION(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats, "bad float type");
region.x = mCurrentState->currentBand->trapezoids[0].xTopRight - region.width;
}
@@ -1997,9 +2017,10 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
{
// Get the last-in-flow
nsBlockFrame* flow = (nsBlockFrame*)GetLastInFlow();
-
PRInt32 kidIndex = flow->NextChildOffset();
PRInt32 startIndex = kidIndex;
+
+#if 0
nsIFrame* kidFrame = nsnull;
nsIFrame* prevKidFrame;
@@ -2013,16 +2034,17 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
// Resolve style for the kid
nsIStyleContextPtr kidSC = aPresContext->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidSC->GetData(kStyleDisplaySID);
// Is it a floater?
- if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
} else {
// Create initial frame for the child
nsIContentDelegate* kidDel;
nsresult fr;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
// Pseudo block frames do not contain other block elements
@@ -2073,6 +2095,7 @@ NS_METHOD nsBlockFrame::ContentAppended(nsIPresShell* aShell,
mChildCount++;
}
SetLastContentOffset(prevKidFrame);
+#endif
// If this is a pseudo-frame then our parent will generate the
// reflow command. Otherwise, if the container is us then we should
@@ -2106,7 +2129,14 @@ nsHTMLFrameType nsBlockFrame::GetFrameType() const
NS_METHOD nsBlockFrame::ListTag(FILE* out) const
{
if ((nsnull != mGeometricParent) && IsPseudoFrame()) {
- fprintf(out, "*block(%d)@%p", mIndexInParent, this);
+ fprintf(out, "*block<");
+ nsIAtom* atom = mContent->GetTag();
+ if (nsnull != atom) {
+ nsAutoString tmp;
+ atom->ToString(tmp);
+ fputs(tmp, out);
+ }
+ fprintf(out, ">(%d)@%p", mIndexInParent, this);
} else {
nsHTMLContainerFrame::ListTag(out);
}
diff --git a/mozilla/layout/html/base/src/nsBodyFrame.cpp b/mozilla/layout/html/base/src/nsBodyFrame.cpp
index 620ca3fc939..4dea2553c1f 100644
--- a/mozilla/layout/html/base/src/nsBodyFrame.cpp
+++ b/mozilla/layout/html/base/src/nsBodyFrame.cpp
@@ -31,7 +31,8 @@
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
static NS_DEFINE_IID(kIAnchoredItemsIID, NS_IANCHOREDITEMS_IID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
nsresult nsBodyFrame::NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
@@ -104,7 +105,7 @@ void nsBodyFrame::CreateColumnFrame(nsIPresContext* aPresContext)
}
nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext,
- nsStyleMolecule* aMol,
+ nsStyleSpacing* aSpacing,
const nsSize& aMaxSize)
{
nsSize result(aMaxSize);
@@ -114,7 +115,8 @@ nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext,
if (!IsPseudoFrame()) {
// If our width is constrained then subtract for the border/padding
if (aMaxSize.width != NS_UNCONSTRAINEDSIZE) {
- result.width -= aMol->borderPadding.left + aMol->borderPadding.right;
+ result.width -= aSpacing->mBorderPadding.left +
+ aSpacing->mBorderPadding.right;
if (! aPresContext->IsPaginated()) {
nsIDeviceContext* dc = aPresContext->GetDeviceContext();
result.width -= NS_TO_INT_ROUND(dc->GetScrollBarWidth());
@@ -123,7 +125,8 @@ nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext,
}
// If our height is constrained then subtract for the border/padding
if (aMaxSize.height != NS_UNCONSTRAINEDSIZE) {
- result.height -= aMol->borderPadding.top + aMol->borderPadding.bottom;
+ result.height -= aSpacing->mBorderPadding.top +
+ aSpacing->mBorderPadding.bottom;
}
}
@@ -150,18 +153,19 @@ NS_METHOD nsBodyFrame::ResizeReflow(nsIPresContext* aPresContext,
mSpaceManager->ClearRegions();
// Get our border/padding info
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleSpacing* mySpacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
// Compute the column's max size
- nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, myMol, aMaxSize);
+ nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, mySpacing,
+ aMaxSize);
// XXX Style code should be dealing with this...
PRBool isPseudoFrame = IsPseudoFrame();
nscoord leftInset = 0, topInset = 0;
if (!isPseudoFrame) {
- leftInset = myMol->borderPadding.left;
- topInset = myMol->borderPadding.top;
+ leftInset = mySpacing->mBorderPadding.left;
+ topInset = mySpacing->mBorderPadding.top;
}
// Get the column's desired rect
@@ -188,8 +192,8 @@ NS_METHOD nsBodyFrame::ResizeReflow(nsIPresContext* aPresContext,
aDesiredSize.height = PR_MAX(desiredRect.YMost(), mSpaceManager->YMost());
if (!isPseudoFrame) {
- aDesiredSize.width += myMol->borderPadding.left + myMol->borderPadding.right;
- aDesiredSize.height += myMol->borderPadding.top + myMol->borderPadding.bottom;
+ aDesiredSize.width += mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right;
+ aDesiredSize.height += mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom;
}
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
@@ -247,15 +251,15 @@ NS_METHOD nsBodyFrame::IncrementalReflow(nsIPresContext* aPresContext,
ReflowStatus& aStatus)
{
// Get our border/padding info
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleSpacing* mySpacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
// XXX Style code should be dealing with this...
PRBool isPseudoFrame = IsPseudoFrame();
nscoord leftInset = 0, topInset = 0;
if (!isPseudoFrame) {
- leftInset = myMol->borderPadding.left;
- topInset = myMol->borderPadding.top;
+ leftInset = mySpacing->mBorderPadding.left;
+ topInset = mySpacing->mBorderPadding.top;
}
// XXX Clear the list of regions. This fixes a problem with the way reflow
@@ -271,7 +275,8 @@ NS_METHOD nsBodyFrame::IncrementalReflow(nsIPresContext* aPresContext,
}
// Compute the column's max size
- nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, myMol, aMaxSize);
+ nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, mySpacing,
+ aMaxSize);
// Pass the command along to our column pseudo frame
nsIRunaround* reflowRunaround;
@@ -295,8 +300,8 @@ NS_METHOD nsBodyFrame::IncrementalReflow(nsIPresContext* aPresContext,
aDesiredSize.width = aDesiredRect.XMost();
aDesiredSize.height = aDesiredRect.YMost();
if (!isPseudoFrame) {
- aDesiredSize.width += myMol->borderPadding.left + myMol->borderPadding.right;
- aDesiredSize.height += myMol->borderPadding.top + myMol->borderPadding.bottom;
+ aDesiredSize.width += mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right;
+ aDesiredSize.height += mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom;
}
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
diff --git a/mozilla/layout/html/base/src/nsBodyFrame.h b/mozilla/layout/html/base/src/nsBodyFrame.h
index 38d54672ff5..87380909df2 100644
--- a/mozilla/layout/html/base/src/nsBodyFrame.h
+++ b/mozilla/layout/html/base/src/nsBodyFrame.h
@@ -23,6 +23,7 @@
struct nsBodyReflowState;
class SpaceManager;
+struct nsStyleSpacing;
class nsBodyFrame : public nsHTMLContainerFrame, public nsIAnchoredItems {
public:
@@ -74,9 +75,9 @@ private:
SpaceManager* mSpaceManager;
void CreateColumnFrame(nsIPresContext* aPresContext);
- nsSize GetColumnAvailSpace(nsIPresContext* aPresContext,
- nsStyleMolecule* aStyleMolecule,
- const nsSize& aMaxSize);
+ nsSize GetColumnAvailSpace(nsIPresContext* aPresContext,
+ nsStyleSpacing* aSpacing,
+ const nsSize& aMaxSize);
};
#endif /* nsBodyFrame_h___ */
diff --git a/mozilla/layout/html/base/src/nsColumnFrame.cpp b/mozilla/layout/html/base/src/nsColumnFrame.cpp
index a650cc562d6..c3ed081ea43 100644
--- a/mozilla/layout/html/base/src/nsColumnFrame.cpp
+++ b/mozilla/layout/html/base/src/nsColumnFrame.cpp
@@ -39,7 +39,8 @@
#endif
static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
NS_DEF_PTR(nsIStyleContext);
@@ -49,9 +50,6 @@ struct ColumnReflowState {
// The space manager to use
nsISpaceManager* spaceManager;
- // The body's style molecule
- nsStyleMolecule* mol;
-
// The body's available size (computed from the body's parent)
nsSize availSize;
@@ -72,11 +70,9 @@ struct ColumnReflowState {
ColumnReflowState(nsIPresContext* aPresContext,
nsISpaceManager* aSpaceManager,
- const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ const nsSize& aMaxSize)
{
spaceManager = aSpaceManager;
- mol = aMol;
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
kidXMost = 0;
@@ -122,7 +118,7 @@ nsresult ColumnFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
nscoord ColumnFrame::GetTopMarginFor(nsIPresContext* aCX,
ColumnReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
// Does the frame have a prev-in-flow?
nsIFrame* kidPrevInFlow;
@@ -136,7 +132,7 @@ nscoord ColumnFrame::GetTopMarginFor(nsIPresContext* aCX,
// XXX Style system should be zero'ing out margins for pseudo frames...
if (!ChildIsPseudoFrame(aKidFrame)) {
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -159,8 +155,8 @@ nscoord ColumnFrame::GetTopMarginFor(nsIPresContext* aCX,
void ColumnFrame::PlaceChild(nsIPresContext* aPresContext,
ColumnReflowState& aState,
nsIFrame* aKidFrame,
+ nsStyleSpacing* aKidSpacing,
const nsRect& aKidRect,
- nsStyleMolecule* aKidMol,
nsSize* aMaxElementSize,
nsSize& aKidMaxElementSize)
{
@@ -172,7 +168,7 @@ void ColumnFrame::PlaceChild(nsIPresContext* aPresContext,
aState.spaceManager->Translate(0, aKidRect.height);
// Update the x-most
- nscoord xMost = aKidRect.XMost() + aKidMol->margin.right;
+ nscoord xMost = aKidRect.XMost() + aKidSpacing->mMargin.right;
if (xMost > aState.kidXMost) {
aState.kidXMost = xMost;
}
@@ -249,10 +245,15 @@ PRBool ColumnFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidFrame, kidMol);
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState,
+ kidFrame, kidSpacing);
+
// XXX Style system should do this...
- nscoord bottomMargin = ChildIsPseudoFrame(kidFrame) ? 0 : kidMol->margin.bottom;
+ nscoord bottomMargin = ChildIsPseudoFrame(kidFrame)
+ ? 0
+ : kidSpacing->mMargin.bottom;
// Figure out the amount of available size for the child (subtract
// off the top margin we are going to apply to it)
@@ -268,7 +269,7 @@ PRBool ColumnFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
if ((kidFrame == mFirstChild) || (kidAvailSize.height > 0)) {
// Reflow the child into the available space
aState.spaceManager->Translate(0, topMargin);
- status = ReflowChild(kidFrame, aPresContext, kidMol, aState.spaceManager,
+ status = ReflowChild(kidFrame, aPresContext, aState.spaceManager,
kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(0, -topMargin);
}
@@ -298,10 +299,10 @@ PRBool ColumnFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// Place the child after taking into account it's margin
aState.y += topMargin;
aState.spaceManager->Translate(0, topMargin);
- kidRect.x += kidMol->margin.left;
+ kidRect.x += kidSpacing->mMargin.left;
kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, kidMol, aMaxElementSize,
- kidMaxElementSize);
+ PlaceChild(aPresContext, aState, kidFrame, kidSpacing,
+ kidRect, aMaxElementSize, kidMaxElementSize);
if (bottomMargin < 0) {
aState.prevMaxNegBottomMargin = -bottomMargin;
} else {
@@ -448,10 +449,15 @@ PRBool ColumnFrame::PullUpChildren(nsIPresContext* aPresContext,
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidFrame, kidMol);
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState,
+ kidFrame, kidSpacing);
+
// XXX Style system should do this...
- nscoord bottomMargin = ChildIsPseudoFrame(kidFrame) ? 0 : kidMol->margin.bottom;
+ nscoord bottomMargin = ChildIsPseudoFrame(kidFrame)
+ ? 0
+ : kidSpacing->mMargin.bottom;
// Figure out the amount of available size for the child (subtract
// off the top margin we are going to apply to it)
@@ -468,7 +474,7 @@ PRBool ColumnFrame::PullUpChildren(nsIPresContext* aPresContext,
// out of space.
if ((kidFrame == mFirstChild) || (kidAvailSize.height > 0)) {
aState.spaceManager->Translate(0, topMargin);
- status = ReflowChild(kidFrame, aPresContext, kidMol, aState.spaceManager,
+ status = ReflowChild(kidFrame, aPresContext, aState.spaceManager,
kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(0, -topMargin);
}
@@ -497,10 +503,10 @@ PRBool ColumnFrame::PullUpChildren(nsIPresContext* aPresContext,
// Place the child
aState.y += topMargin;
aState.spaceManager->Translate(0, topMargin);
- kidRect.x += kidMol->margin.left;
+ kidRect.x += kidSpacing->mMargin.left;
kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, kidMol, aMaxElementSize,
- kidMaxElementSize);
+ PlaceChild(aPresContext, aState, kidFrame, kidSpacing,
+ kidRect, aMaxElementSize, kidMaxElementSize);
if (bottomMargin < 0) {
aState.prevMaxNegBottomMargin = -bottomMargin;
} else {
@@ -669,9 +675,12 @@ ColumnFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Resolve style
nsIStyleContextPtr kidStyleContext =
aPresContext->ResolveStyleContextFor(kid, this);
- nsStylePosition* kidPosition = (nsStylePosition*)kidStyleContext->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidStyleContext->GetData(kStyleSpacingSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidStyleContext->GetData(kStyleDisplaySID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidStyleContext->GetData(kStylePositionSID);
nsBlockFrame* pseudoFrame = nsnull;
nsIFrame* kidFrame;
@@ -685,7 +694,7 @@ ColumnFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
} else if (nsnull == kidPrevInFlow) {
// Figure out how to treat the content
nsIContentDelegate* kidDel = nsnull;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_NONE:
// Create a placeholder frame that takes up no space
NS_ASSERTION(nsnull == kidPrevInFlow, "bad prev in flow");
@@ -720,9 +729,13 @@ ColumnFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
}
// Get the child's margins
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidFrame, kidMol);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState,
+ kidFrame, kidSpacing);
+
// XXX Style system should do this...
- nscoord bottomMargin = ChildIsPseudoFrame(kidFrame) ? 0 : kidMol->margin.bottom;
+ nscoord bottomMargin = ChildIsPseudoFrame(kidFrame)
+ ? 0
+ : kidSpacing->mMargin.bottom;
// Link the child frame into the list of children and update the
// child count
@@ -757,7 +770,7 @@ ColumnFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// fit or might need continuing
if (kidAvailSize.height > 0) {
aState.spaceManager->Translate(0, topMargin);
- status = ReflowChild(kidFrame, aPresContext, kidMol, aState.spaceManager,
+ status = ReflowChild(kidFrame, aPresContext, aState.spaceManager,
kidAvailSize, kidRect, pKidMaxElementSize);
aState.spaceManager->Translate(0, -topMargin);
}
@@ -803,10 +816,10 @@ ColumnFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// finish).
aState.y += topMargin;
aState.spaceManager->Translate(0, topMargin);
- kidRect.x += kidMol->margin.left;
+ kidRect.x += kidSpacing->mMargin.left;
kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, kidMol, aMaxElementSize,
- kidMaxElementSize);
+ PlaceChild(aPresContext, aState, kidFrame, kidSpacing,
+ kidRect, aMaxElementSize, kidMaxElementSize);
if (bottomMargin < 0) {
aState.prevMaxNegBottomMargin = -bottomMargin;
} else {
@@ -891,9 +904,7 @@ NS_METHOD ColumnFrame::ResizeReflow(nsIPresContext* aPresContext,
}
// Initialize body reflow state
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- ColumnReflowState state(aPresContext, aSpaceManager, aMaxSize, myMol);
+ ColumnReflowState state(aPresContext, aSpaceManager, aMaxSize);
// Check for an overflow list
MoveOverflowToChildList();
@@ -992,10 +1003,9 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
NS_NOTYETIMPLEMENTED("unexpected reflow command");
}
+#if 0
// Initialize body reflow state
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- ColumnReflowState state(aPresContext, aSpaceManager, aMaxSize, myMol);
+ ColumnReflowState state(aPresContext, aSpaceManager, aMaxSize);
// Get to the frame that we should begin reflowing (where the
// append occured).
@@ -1037,10 +1047,12 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsIStyleContextPtr kidSC;
prevKidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
// XXX Style system should do this...
- nscoord bottomMargin = ChildIsPseudoFrame(prevKidFrame) ? 0 : kidMol->margin.bottom;
+ nscoord bottomMargin = ChildIsPseudoFrame(prevKidFrame)
+ ? 0
+ : kidSpacing->mMargin.bottom;
state.y = startKidRect.YMost();
if (bottomMargin < 0) {
@@ -1070,9 +1082,10 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, state, kidFrame, kidMol);
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, state,
+ kidFrame, kidSpacing);
nsRect kidRect;
nsSize kidAvailSize(state.availSize);
@@ -1083,7 +1096,7 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
// Reflow the child
state.spaceManager->Translate(0, topMargin);
- aStatus = ReflowChild(kidFrame, aPresContext, kidMol, state.spaceManager,
+ aStatus = ReflowChild(kidFrame, aPresContext, state.spaceManager,
kidAvailSize, kidRect, nsnull);
state.spaceManager->Translate(0, -topMargin);
@@ -1103,12 +1116,15 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
state.y += topMargin;
state.spaceManager->Translate(0, topMargin);
nsSize kidMaxElementSize; // XXX unused
- kidRect.x += kidMol->margin.left;
+ kidRect.x += kidSpacing->mMargin.left;
kidRect.y += state.y;
- PlaceChild(aPresContext, state, kidFrame, kidRect, kidMol, nsnull,
- kidMaxElementSize);
+ PlaceChild(aPresContext, state, kidFrame, kidSpacing,
+ kidRect, nsnull, kidMaxElementSize);
+
// XXX Style system should do this...
- nscoord bottomMargin = ChildIsPseudoFrame(kidFrame) ? 0 : kidMol->margin.bottom;
+ nscoord bottomMargin = ChildIsPseudoFrame(kidFrame)
+ ? 0
+ : kidSpacing->mMargin.bottom;
if (bottomMargin < 0) {
state.prevMaxNegBottomMargin = -bottomMargin;
} else {
@@ -1147,7 +1163,9 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
aDesiredRect.y = 0;
aDesiredRect.width = state.kidXMost;/* XXX */
aDesiredRect.height = state.y;
-
+#endif
+ return ResizeReflow(aPresContext, aSpaceManager, aMaxSize, aDesiredRect,
+ nsnull, aStatus);
} else if (aReflowCommand.GetTarget() == this) {
// The reflow command is targeted for us. This could be a deleted or
// changed reflow command
@@ -1171,6 +1189,7 @@ NS_METHOD ColumnFrame::ContentAppended(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aContainer)
{
+#if 0
// We must only be called by the body frame since we are a
// pseudo-frame; the body frame makes sure that it's dealing with
// it's last-in-flow therefore we must also be a last-in-flow
@@ -1200,32 +1219,18 @@ NS_METHOD ColumnFrame::ContentAppended(nsIPresShell* aShell,
// Get style context for the kid
nsIStyleContextPtr kidStyleContext =
aPresContext->ResolveStyleContextFor(kid, this);
- nsStylePosition* kidPosition = (nsStylePosition*)kidStyleContext->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay = (nsStyleDisplay*)
+ kidStyleContext->GetData(kStyleDisplaySID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidStyleContext->GetData(kStylePositionSID);
// See what display mode it has
nsIFrame* kidFrame;
nsIContentDelegate* del;
-
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
- kidFrame->SetStyleContext(kidStyleContext);
-
- // Append it to the child list
- if (nsnull == prevKidFrame) {
- mFirstChild = kidFrame;
- mFirstContentOffset = kidIndex;
- } else {
- prevKidFrame->SetNextSibling(kidFrame);
- }
- mChildCount++;
- prevKidFrame = kidFrame;
- pseudoFrame = nsnull;
- kidIndex++;
- mLastContentOffset = kidIndex;
} else {
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_NONE:
// Create place holder frame
nsFrame::NewFrame(&kidFrame, kid, kidIndex, this);
@@ -1320,6 +1325,7 @@ NS_METHOD ColumnFrame::ContentAppended(nsIPresShell* aShell,
SetLastContentOffset(prevKidFrame);
// Note: Column frames *never* directly generate reflow commands
// because they are always pseudo-frames for bodies.
+#endif
return NS_OK;
}
diff --git a/mozilla/layout/html/base/src/nsColumnFrame.h b/mozilla/layout/html/base/src/nsColumnFrame.h
index 77c5c770581..148abb9e67a 100644
--- a/mozilla/layout/html/base/src/nsColumnFrame.h
+++ b/mozilla/layout/html/base/src/nsColumnFrame.h
@@ -21,6 +21,8 @@
#include "nsHTMLContainerFrame.h"
#include "nsIRunaround.h"
+struct nsStyleSpacing;
+
struct ColumnReflowState;
class ColumnFrame : public nsHTMLContainerFrame, public nsIRunaround {
@@ -64,13 +66,13 @@ protected:
nscoord GetTopMarginFor(nsIPresContext* aCX,
ColumnReflowState& aState,
nsIFrame* aKidFrame,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild(nsIPresContext* aPresContext,
ColumnReflowState& aState,
nsIFrame* aKidFrame,
+ nsStyleSpacing* aKidSpacing,
const nsRect& aKidRect,
- nsStyleMolecule* aKidMol,
nsSize* aMaxElementSize,
nsSize& aKidMaxElementSize);
diff --git a/mozilla/layout/html/base/src/nsHRPart.cpp b/mozilla/layout/html/base/src/nsHRPart.cpp
index e5bc102e93d..dac2cb82754 100644
--- a/mozilla/layout/html/base/src/nsHRPart.cpp
+++ b/mozilla/layout/html/base/src/nsHRPart.cpp
@@ -32,9 +32,9 @@
#undef DEBUG_HR_REFCNT
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
// Default alignment value (so we can tell an unset value from a set value)
#define ALIGN_UNSET PRUint8(-1)
@@ -117,16 +117,16 @@ NS_METHOD HRuleFrame::Paint(nsIPresContext& aPresContext,
nscoord thickness = nscoord(p2t * ((HRulePart*)mContent)->mThickness);
// Get style data
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
nsStyleColor* color =
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
- nscoord x0 = mol->borderPadding.left;
- nscoord y0 = mol->borderPadding.top;
+ nscoord x0 = spacing->mBorderPadding.left;
+ nscoord y0 = spacing->mBorderPadding.top;
nscoord width = mRect.width -
- (mol->borderPadding.left + mol->borderPadding.right);
+ (spacing->mBorderPadding.left + spacing->mBorderPadding.right);
nscoord height = mRect.height -
- (mol->borderPadding.top + mol->borderPadding.bottom);
+ (spacing->mBorderPadding.top + spacing->mBorderPadding.bottom);
// Center hrule vertically within the available space
y0 += (height - thickness) / 2;
diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.cpp b/mozilla/layout/html/base/src/nsHTMLContainer.cpp
index eb2ac7904c6..ab3c0772af0 100644
--- a/mozilla/layout/html/base/src/nsHTMLContainer.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLContainer.cpp
@@ -34,11 +34,11 @@
#include "nsIURL.h"
#include "prprf.h"
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
static NS_DEFINE_IID(kStyleListSID, NS_STYLELIST_SID);
-
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
nsresult
NS_NewHTMLContainer(nsIHTMLContent** aInstancePtrResult,
@@ -189,13 +189,13 @@ nsIFrame* nsHTMLContainer::CreateFrame(nsIPresContext* aPresContext,
// Resolve style for the piece of content
nsIStyleContext* styleContext =
aPresContext->ResolveStyleContextFor(this, aParentFrame);
- nsStyleMolecule* mol =
- (nsStyleMolecule*)styleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* styleDisplay =
+ (nsStyleDisplay*)styleContext->GetData(kStyleDisplaySID);
// Use style to choose what kind of frame to create
nsIFrame* rv;
nsresult fr;
- switch (mol->display) {
+ switch (styleDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
fr = nsBlockFrame::NewFrame(&rv, this, aIndexInParent, aParentFrame);
break;
@@ -459,7 +459,8 @@ void nsHTMLContainer::MapAttributesInto(nsIStyleContext* aContext,
// align: enum
GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
- // XXX set align from enum
+ nsStyleText* text = (nsStyleText*)aContext->GetData(kStyleTextSID);
+ text->mTextAlign = value.GetIntValue();
}
}
else if (mTag == nsHTMLAtoms::a) {
diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp
index 44075326666..27734eb6e3f 100644
--- a/mozilla/layout/html/base/src/nsInlineFrame.cpp
+++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp
@@ -26,6 +26,7 @@
#include "nsCSSLayout.h"
#include "nsPlaceholderFrame.h"
#include "nsReflowCommand.h"
+#include "nsHTMLAtoms.h"
#include "nsAbsoluteFrame.h"
// XXX To Do:
@@ -36,16 +37,22 @@
// 6. direction support
// 7. CSS line-height property
+/* XXX */
+#include "nsHTMLIIDs.h"
+#include "nsBlockFrame.h"
+
#define DEFAULT_ASCENT_LEN 10
+
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
+static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
class nsInlineState
{
public:
nsStyleFont* font; // style font
- nsStyleMolecule* mol; // style molecule
+ nsStyleSpacing* spacing; // style spacing
nsSize availSize; // available space in which to reflow (starts as max size minus insets)
nsSize* maxElementSize; // maximum element size (may be null)
nscoord x; // running x-offset (starts at left inner edge)
@@ -58,14 +65,14 @@ public:
// Constructor
nsInlineState(nsStyleFont* aStyleFont,
- nsStyleMolecule* aStyleMolecule,
+ nsStyleSpacing* aSpacing,
const nsSize& aMaxSize,
nsSize* aMaxElementSize)
- : x(aStyleMolecule->borderPadding.left), // determined by inner edge
- y(aStyleMolecule->borderPadding.top) // determined by inner edge
+ : x(aSpacing->mBorderPadding.left), // determined by inner edge
+ y(aSpacing->mBorderPadding.top) // determined by inner edge
{
font = aStyleFont;
- mol = aStyleMolecule;
+ spacing = aSpacing;
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
@@ -74,11 +81,11 @@ public:
// needed for border/padding
availSize.width = aMaxSize.width;
if (PR_FALSE == unconstrainedWidth) {
- availSize.width -= mol->borderPadding.left + mol->borderPadding.right;
+ availSize.width -= aSpacing->mBorderPadding.left + aSpacing->mBorderPadding.right;
}
availSize.height = aMaxSize.height;
if (PR_FALSE == unconstrainedHeight) {
- availSize.height -= mol->borderPadding.top + mol->borderPadding.bottom;
+ availSize.height -= aSpacing->mBorderPadding.top + aSpacing->mBorderPadding.bottom;
}
// Initialize max element size
@@ -360,6 +367,10 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext,
}
}
+ // XXX if the frame being pulled up is not appropriate (e.g. a block
+ // frame) then we should stop! If we have an inline BR tag we should
+ // stop too!
+
// See if the child fits in the available space. If it fits or
// it's splittable then reflow it. The reason we can't just move
// it is that we still need ascent/descent information
@@ -531,6 +542,7 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
PRInt32 kidIndex = NextChildOffset();
nsIFrame* prevKidFrame;
+ PRBool breakAfter = PR_FALSE;
LastChild(prevKidFrame);
for (;;) {
// Get the next content object
@@ -553,19 +565,21 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Figure out how we should treat the child
nsIFrame* kidFrame;
- nsStylePosition* kidPosition = (nsStylePosition*)kidStyleContext->GetData(kStylePositionSID);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleDisplay* kidDisplay =
+ (nsStyleDisplay*)kidStyleContext->GetData(kStyleDisplaySID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidStyleContext->GetData(kStylePositionSID);
// Check whether it wants to floated or absolutely positioned
if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) {
AbsoluteFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidStyleContext);
- } else if (kidMol->floats != NS_STYLE_FLOAT_NONE) {
+ } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) {
PlaceholderFrame::NewFrame(&kidFrame, kid, kidIndex, this);
kidFrame->SetStyleContext(kidStyleContext);
} else if (nsnull == kidPrevInFlow) {
nsIContentDelegate* kidDel;
- switch (kidMol->display) {
+ switch (kidDisplay->mDisplay) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
if (kidIndex != mFirstContentOffset) {
@@ -578,6 +592,42 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// FALLTHROUGH
case NS_STYLE_DISPLAY_INLINE:
+ // XXX temporary hack to make plain BR's in inlines "work"
+ // get style for break-before-after; get break-type (line, page, etc.)
+ {
+ nsIAtom* tag = kid->GetTag();
+ if (nsHTMLAtoms::br == tag) {
+ // Set break-after flag so we stop mapping children (we
+ // will end up being continued if there are more children)
+ breakAfter = PR_TRUE;
+
+ // Get cached state for containing block frame
+ // XXX how about QueryInterface(kIHTMLBlockFrameIID)? DOH!
+ nsBlockReflowState* state = nsnull;
+ nsIFrame* parent = mGeometricParent;
+ while (nsnull != parent) {
+ nsIHTMLFrameType* ft;
+ nsresult status =
+ parent->QueryInterface(kIHTMLFrameTypeIID, (void**) &ft);
+ if (NS_OK == status) {
+ nsHTMLFrameType type = ft->GetFrameType();
+ if (eHTMLFrame_Block == type) {
+ break;
+ }
+ }
+ parent->GetGeometricParent(parent);
+ }
+ if (nsnull != parent) {
+ nsIPresShell* shell = aPresContext->GetShell();
+ state = (nsBlockReflowState*) shell->GetCachedData(parent);
+ // XXX Of course this won't work if the inline span is nested
+ // in another inline span!
+ state->breakAfterChild = PR_TRUE;
+ NS_RELEASE(shell);
+ }
+ }
+ NS_IF_RELEASE(tag);
+ }
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, kidIndex, this);
NS_RELEASE(kidDel);
@@ -634,6 +684,11 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
break;
}
kidPrevInFlow = nsnull;
+
+ // If we need to break after the kidFrame, then do so now
+ if (breakAfter) {
+ break;
+ }
}
done:;
@@ -668,15 +723,15 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
// Get the style molecule
nsStyleFont* styleFont =
(nsStyleFont*)mStyleContext->GetData(kStyleFontSID);
- nsStyleMolecule* styleMolecule =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleSpacing* styleSpacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
// Check for an overflow list
MoveOverflowToChildList();
// Initialize our reflow state. We must wait until after we've processed
// the overflow list, because our first content offset might change
- nsInlineState state(styleFont, styleMolecule, aMaxSize, aMaxElementSize);
+ nsInlineState state(styleFont, styleSpacing, aMaxSize, aMaxElementSize);
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
// Reflow any existing frames
@@ -710,7 +765,7 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
}
}
- const nsMargin& insets = styleMolecule->borderPadding;
+ const nsMargin& insets = styleSpacing->mBorderPadding;
// Vertically align the children
nscoord lineHeight =
@@ -895,9 +950,7 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
// Recover the reflow state as if we had reflowed our children up
// to but not including the child that is next in the reflow chain
- nsStyleMolecule* styleMolecule =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- nsInlineState state(styleMolecule, aMaxSize, nsnull);
+ nsInlineState state(aMaxSize, nsnull);
state.SetNumAscents(mChildCount);
PRIntn nextIndex = RecoverState(aPresContext, state, nextInChain);
@@ -981,8 +1034,8 @@ nsInlineFrame::AdjustChildren(nsIPresContext* aPresContext,
nsReflowMetrics& aKidMetrics,
ReflowStatus aKidReflowStatus)
{
- nsStyleMolecule* mol = aState.mol;
- nscoord xr = aState.availSize.width + mol->borderPadding.left;
+ nsStyleSpacing* spacing = aState.spacing;
+ nscoord xr = aState.availSize.width + spacing->mBorderPadding.left;
nscoord remainingSpace = xr - aState.x;
nscoord x = aState.x;
@@ -1000,7 +1053,7 @@ nsInlineFrame::AdjustChildren(nsIPresContext* aPresContext,
}
// Vertically align the children
- const nsMargin& insets = mol->borderPadding;
+ const nsMargin& insets = spacing->mBorderPadding;
nsCSSLayout::VerticallyAlignChildren(aPresContext, this, aState.font,
insets.top, mFirstChild, mChildCount,
aState.ascents, aState.maxAscent);
diff --git a/mozilla/layout/html/forms/src/nsInputFrame.cpp b/mozilla/layout/html/forms/src/nsInputFrame.cpp
index 265cc2ae4e9..0344883f899 100644
--- a/mozilla/layout/html/forms/src/nsInputFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsInputFrame.cpp
@@ -46,7 +46,7 @@
#include "nsHTMLForms.h"
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
struct nsInputCallbackData
{
@@ -353,14 +353,17 @@ NS_METHOD nsInputFrame::HandleEvent(nsIPresContext& aPresContext,
return nsEventStatus_eConsumeDoDefault;
}
-void nsInputFrame::GetStyleSize(nsIPresContext& aPresContext, const nsSize& aMaxSize, nsSize& aSize)
+void nsInputFrame::GetStyleSize(nsIPresContext& aPresContext,
+ const nsSize& aMaxSize, nsSize& aSize)
{
nsInput* input;
GetContent((nsIContent *&) input); // this must be an nsInput
- nsStyleMolecule* mol = (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
+ nsStylePosition* position = (nsStylePosition*)
+ mStyleContext->GetData(kStylePositionSID);
//printf("\n ** %d %d", mol->fixedWidth, mol->proportionalWidth);
// set the width, height
+#if 0
aSize.width = mol->fixedWidth;
if ((CSS_NOTSET == aSize.width) && (CSS_NOTSET != mol->proportionalWidth)) {
aSize.width = (aMaxSize.width * mol->proportionalWidth) / 100;
@@ -369,6 +372,10 @@ void nsInputFrame::GetStyleSize(nsIPresContext& aPresContext, const nsSize& aMax
if ((CSS_NOTSET == aSize.height) && (CSS_NOTSET != mol->proportionalHeight)) {
aSize.height = (aMaxSize.height * mol->proportionalHeight) / 100;
}
+#else
+ aSize.width = -1;
+ aSize.height = -1;
+#endif
NS_RELEASE(input);
}
diff --git a/mozilla/layout/html/style/src/nsCSSLayout.cpp b/mozilla/layout/html/style/src/nsCSSLayout.cpp
index 851cb7aa850..19236ff8cb5 100644
--- a/mozilla/layout/html/style/src/nsCSSLayout.cpp
+++ b/mozilla/layout/html/style/src/nsCSSLayout.cpp
@@ -25,7 +25,7 @@
#include "nsRect.h"
#include "nsIPtr.h"
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
NS_DEF_PTR(nsIStyleContext);
@@ -64,10 +64,8 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
kid->GetStyleContext(aCX, kidSC.AssignRef());
kid->GetContent(kidContent.AssignRef());
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- PRIntn verticalAlign = kidMol->verticalAlign;
- float verticalAlignPct = kidMol->verticalAlignPct;
+ nsStyleText* textStyle = (nsStyleText*)kidSC->GetData(kStyleTextSID);
+ PRIntn verticalAlign = textStyle->mVerticalAlign;
kid->GetRect(kidRect);
@@ -146,9 +144,8 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
kid->GetStyleContext(aCX, kidSC.AssignRef());
kid->GetContent(kidContent.AssignRef());
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- PRIntn verticalAlign = kidMol->verticalAlign;
+ nsStyleText* textStyle = (nsStyleText*)kidSC->GetData(kStyleTextSID);
+ PRIntn verticalAlign = textStyle->mVerticalAlign;
// Vertically align the child
if (verticalAlign == NS_STYLE_VERTICAL_ALIGN_BOTTOM) {
@@ -174,14 +171,13 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
*/
void nsCSSLayout::HorizontallyPlaceChildren(nsIPresContext* aCX,
nsIFrame* aContainer,
- nsStyleMolecule* aContainerStyle,
+ nsStyleText* aContainerStyle,
nsIFrame* aFirstChild,
PRInt32 aChildCount,
nscoord aLineWidth,
nscoord aMaxWidth)
{
- PRIntn textAlign = aContainerStyle->textAlign;
-
+ PRIntn textAlign = aContainerStyle->mTextAlign;
nscoord dx = 0;
switch (textAlign) {
case NS_STYLE_TEXT_ALIGN_LEFT:
@@ -213,7 +209,6 @@ void nsCSSLayout::HorizontallyPlaceChildren(nsIPresContext* aCX,
*/
void nsCSSLayout::RelativePositionChildren(nsIPresContext* aCX,
nsIFrame* aContainer,
- nsStyleMolecule* aContainerStyle,
nsIFrame* aFirstChild,
PRInt32 aChildCount)
{
@@ -225,7 +220,8 @@ void nsCSSLayout::RelativePositionChildren(nsIPresContext* aCX,
kid->GetContent(kidContent.AssignRef());
kid->GetStyleContext(aCX, kidSC.AssignRef());
- nsStylePosition* kidPosition = (nsStylePosition*)kidSC->GetData(kStylePositionSID);
+ nsStylePosition* kidPosition = (nsStylePosition*)
+ kidSC->GetData(kStylePositionSID);
if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
kid->GetOrigin(origin);
// XXX Check the flags: could be auto or percent (not just length)
diff --git a/mozilla/layout/html/style/src/nsCSSLayout.h b/mozilla/layout/html/style/src/nsCSSLayout.h
index 2b6e8ff2f6d..d59fc94acd5 100644
--- a/mozilla/layout/html/style/src/nsCSSLayout.h
+++ b/mozilla/layout/html/style/src/nsCSSLayout.h
@@ -21,7 +21,7 @@
#include "nsCoord.h"
class nsIPresContext;
struct nsStyleFont;
-struct nsStyleMolecule;
+struct nsStyleText;
class nsIFrame;
class nsCSSLayout {
@@ -44,7 +44,7 @@ public:
*/
static void HorizontallyPlaceChildren(nsIPresContext* aPresContext,
nsIFrame* aContainer,
- nsStyleMolecule* aContainerStyle,
+ nsStyleText* aContainerStyle,
nsIFrame* aFirstChild,
PRInt32 aChildCount,
nscoord aLineWidth,
@@ -55,7 +55,6 @@ public:
*/
static void RelativePositionChildren(nsIPresContext* aPresContext,
nsIFrame* aContainer,
- nsStyleMolecule* aContainerStyle,
nsIFrame* aFirstChild,
PRInt32 aChildCount);
};
diff --git a/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp b/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp
index e0e8de8c922..fa16c310221 100644
--- a/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp
@@ -33,9 +33,10 @@ static PRBool gsDebug = PR_FALSE;
static const PRBool gsDebug = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
/**
*/
@@ -124,26 +125,20 @@ NS_METHOD nsTableCaptionFrame::Paint(nsIPresContext& aPresContext,
}
/**
-*
-* Align the frame's child frame within the caption
-*
-**/
-
+ * Align the frame's child frame within the caption
+ */
void nsTableCaptionFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
- {
+{
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull!=mol, "bad style molecule");
- nscoord topInset=0, bottomInset=0;
- PRInt32 verticalAlign = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
+ nsStyleText* textStyle =
+ (nsStyleText*)mStyleContext->GetData(kStyleTextSID);
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
- if (nsnull!=mol)
- {
- topInset = mol->borderPadding.top;
- bottomInset =mol->borderPadding.bottom;
- verticalAlign = mol->verticalAlign;
- }
+ nscoord topInset = spacing->mBorderPadding.top;
+ nscoord bottomInset = spacing->mBorderPadding.bottom;
+ PRUint8 verticalAlign = textStyle->mVerticalAlign;
+
nscoord height = mRect.height;
nsRect kidRect;
@@ -208,17 +203,12 @@ NS_METHOD nsTableCaptionFrame::ResizeReflow(nsIPresContext* aPresContext,
// SEC: what about ascent and decent???
// Compute the insets (sum of border and padding)
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull!=myMol, "bad style molecule");
- nscoord topInset=0,rightInset=0, bottomInset=0, leftInset=0;
- if (nsnull!=myMol)
- {
- topInset = myMol->borderPadding.top;
- rightInset = myMol->borderPadding.right;
- bottomInset =myMol->borderPadding.bottom;
- leftInset = myMol->borderPadding.left;
- }
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nscoord topInset = spacing->mBorderPadding.top;
+ nscoord rightInset = spacing->mBorderPadding.right;
+ nscoord bottomInset = spacing->mBorderPadding.bottom;
+ nscoord leftInset = spacing->mBorderPadding.left;
// reduce available space by insets
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
diff --git a/mozilla/layout/html/table/src/nsTableCaptionFrame.h b/mozilla/layout/html/table/src/nsTableCaptionFrame.h
index cfef6ae63b7..b40c4182d42 100644
--- a/mozilla/layout/html/table/src/nsTableCaptionFrame.h
+++ b/mozilla/layout/html/table/src/nsTableCaptionFrame.h
@@ -22,8 +22,6 @@
#include "nsContainerFrame.h"
#include "nsTableCaption.h"
-struct nsStyleMolecule;
-
/**
* nsTableCaptionFrame
* data structure to maintain information about a single table caption geometry
diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp
index 736326dbbc3..51b8221f594 100644
--- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp
@@ -35,9 +35,10 @@ static PRBool gsDebug = PR_FALSE;
static const PRBool gsDebug = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
/**
*/
@@ -86,20 +87,15 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
**/
void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
- {
+{
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nsStyleText* textStyle =
+ (nsStyleText*)mStyleContext->GetData(kStyleTextSID);
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull!=mol, "bad style molecule");
- nscoord topInset=0, bottomInset=0;
- PRInt32 verticalAlign = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
-
- if (nsnull!=mol)
- {
- topInset = mol->borderPadding.top;
- bottomInset =mol->borderPadding.bottom;
- verticalAlign = mol->verticalAlign;
- }
+ nscoord topInset = spacing->mBorderPadding.top;
+ nscoord bottomInset = spacing->mBorderPadding.bottom;
+ PRUint8 verticalAlign = textStyle->mVerticalAlign;
nscoord height = mRect.height;
nsRect kidRect;
@@ -225,17 +221,12 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
// SEC: what about ascent and decent???
// Compute the insets (sum of border and padding)
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull!=myMol, "bad style molecule");
- nscoord topInset=0,rightInset=0, bottomInset=0, leftInset=0;
- if (nsnull!=myMol)
- {
- topInset = myMol->borderPadding.top;
- rightInset = myMol->borderPadding.right;
- bottomInset =myMol->borderPadding.bottom;
- leftInset = myMol->borderPadding.left;
- }
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nscoord topInset = spacing->mBorderPadding.top;
+ nscoord rightInset = spacing->mBorderPadding.right;
+ nscoord bottomInset = spacing->mBorderPadding.bottom;
+ nscoord leftInset = spacing->mBorderPadding.left;
// reduce available space by insets
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.h b/mozilla/layout/html/table/src/nsTableCellFrame.h
index 65daa2c299a..c41849660b4 100644
--- a/mozilla/layout/html/table/src/nsTableCellFrame.h
+++ b/mozilla/layout/html/table/src/nsTableCellFrame.h
@@ -22,8 +22,6 @@
#include "nsContainerFrame.h"
#include "nsTableCell.h"
-struct nsStyleMolecule;
-
/**
* nsTableCellFrame
* data structure to maintain information about a single table cell's frame
diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp
index 8ad39a98188..9fc8d6a88ba 100644
--- a/mozilla/layout/html/table/src/nsTableFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableFrame.cpp
@@ -56,9 +56,10 @@ static const PRBool gsDebugMBP = PR_FALSE;
#define max(x, y) ((x) > (y) ? (x) : (y))
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -71,11 +72,12 @@ NS_DEF_PTR(nsTableCell);
struct InnerTableReflowState {
// The body's style molecule
- nsStyleMolecule* mol;
// The body's available size (computed from the body's parent)
nsSize availSize;
+ nscoord leftInset, topInset;
+
// Margin tracking information
nscoord prevMaxPosBottomMargin;
nscoord prevMaxNegBottomMargin;
@@ -98,16 +100,28 @@ struct InnerTableReflowState {
InnerTableReflowState(nsIPresContext* aPresContext,
const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ nsStyleSpacing* aStyleSpacing)
{
- mol = aMol;
- availSize.width = aMaxSize.width;
- availSize.height = aMaxSize.height;
prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0;
y=0; // border/padding/margin???
+
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
+ availSize.width = aMaxSize.width;
+ if (!unconstrainedWidth) {
+ availSize.width -= aStyleSpacing->mBorderPadding.left +
+ aStyleSpacing->mBorderPadding.right;
+ }
+ leftInset = aStyleSpacing->mBorderPadding.left;
+
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
+ availSize.height = aMaxSize.height;
+ if (!unconstrainedHeight) {
+ availSize.height -= aStyleSpacing->mBorderPadding.top +
+ aStyleSpacing->mBorderPadding.bottom;
+ }
+ topInset = aStyleSpacing->mBorderPadding.top;
+
firstRowGroup = PR_TRUE;
footerHeight = 0;
footerList = nsnull;
@@ -483,37 +497,39 @@ NS_METHOD nsTableFrame::ResizeReflow(nsIPresContext* aPresContext,
aStatus = frComplete;
- PRIntervalTime startTime = PR_IntervalNow();
+ PRIntervalTime startTime;
+ if (gsTiming) {
+ startTime = PR_IntervalNow();
+ }
if (PR_TRUE==gsDebug)
printf ("*** tableframe reflow\t\t%p\n", this);
if (PR_TRUE==NeedsReflow(aMaxSize))
{
- nsStyleMolecule* tableStyleMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull != tableStyleMol, "null style molecule");
- if (nsnull==tableStyleMol)
- return frComplete; // SEC: this is an error!
-
if (PR_FALSE==IsFirstPassValid())
{ // we treat the table as if we've never seen the layout data before
mPass = kPASS_FIRST;
- aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, tableStyleMol);
+ aStatus = ResizeReflowPass1(aPresContext, aDesiredSize,
+ aMaxSize, aMaxElementSize);
// check result
}
mPass = kPASS_SECOND;
// assign column widths, and assign aMaxElementSize->width
- BalanceColumnWidths(aPresContext, tableStyleMol, aMaxSize, aMaxElementSize);
+ BalanceColumnWidths(aPresContext, aMaxSize, aMaxElementSize);
// assign table width
- SetTableWidth(aPresContext, tableStyleMol);
+ SetTableWidth(aPresContext);
- aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, tableStyleMol, 0, 0);
+ aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aMaxSize,
+ aMaxElementSize, 0, 0);
- PRIntervalTime endTime = PR_IntervalNow();
- if (gsTiming) printf("Table reflow took %ld ticks for frame %d\n", endTime-startTime, this);
+ if (gsTiming) {
+ PRIntervalTime endTime = PR_IntervalNow();
+ printf("Table reflow took %ld ticks for frame %d\n",
+ endTime-startTime, this);/* XXX need to use LL_* macros! */
+ }
mPass = kPASS_UNDEFINED;
}
@@ -540,11 +556,9 @@ NS_METHOD nsTableFrame::ResizeReflow(nsIPresContext* aPresContext,
nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle)
+ nsSize* aMaxElementSize)
{
NS_ASSERTION(nsnull!=aPresContext, "bad pres context param");
- NS_ASSERTION(nsnull!=aTableStyle, "bad style param");
NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame.");
if (gsDebug==PR_TRUE) printf("nsTableFrame::ResizeReflow Pass1: maxSize=%d,%d\n",
@@ -573,10 +587,12 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresCont
nsIFrame* prevKidFrame = nsnull;/* XXX incremental reflow! */
// Compute the insets (sum of border and padding)
- nscoord topInset = aTableStyle->borderPadding.top;
- nscoord rightInset = aTableStyle->borderPadding.right;
- nscoord bottomInset =aTableStyle->borderPadding.bottom;
- nscoord leftInset = aTableStyle->borderPadding.left;
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nscoord topInset = spacing->mBorderPadding.top;
+ nscoord rightInset = spacing->mBorderPadding.right;
+ nscoord bottomInset =spacing->mBorderPadding.bottom;
+ nscoord leftInset = spacing->mBorderPadding.left;
/* assumes that Table's children are in the following order:
* Captions
@@ -601,9 +617,6 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresCont
nsIStyleContextPtr kidStyleContext =
aPresContext->ResolveStyleContextFor(kid, this);
NS_ASSERTION(nsnull != kidStyleContext, "null style context for kid");
- nsStyleMolecule* kidStyle =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull != kidStyle, "null style molecule for kid");
// SEC: TODO: when content is appended or deleted, be sure to clear out the frame hierarchy!!!!
@@ -701,7 +714,6 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle,
PRInt32 aMinCaptionWidth,
PRInt32 mMaxCaptionWidth)
{
@@ -737,9 +749,9 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
// Check for an overflow list
MoveOverflowToChildList();
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- InnerTableReflowState state(aPresContext, aMaxSize, myMol);
+ nsStyleSpacing* mySpacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
+ InnerTableReflowState state(aPresContext, aMaxSize, mySpacing);
// Reflow the existing frames
if (nsnull != mFirstChild) {
@@ -795,13 +807,11 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
if (gsDebug==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
- printf("Reflow complete, returning %s with aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
- status==frComplete ? "Complete" : "Not Complete",
+ printf("Reflow complete, returning aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
else
- printf("Reflow complete, returning %s with aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
- status==frComplete ? "Complete" : "Not Complete",
+ printf("Reflow complete, returning aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
aDesiredSize.width, aDesiredSize.height);
}
@@ -820,12 +830,12 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
// Collapse child's top margin with previous bottom margin
nscoord nsTableFrame::GetTopMarginFor(nsIPresContext* aCX,
InnerTableReflowState& aState,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
nscoord margin;
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -976,9 +986,10 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
// Figure out the amount of available size for the child (subtract
// off the top margin we are going to apply to it)
@@ -987,7 +998,8 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
}
// Subtract off for left and right margin
if (PR_FALSE == aState.unconstrainedWidth) {
- kidAvailSize.width -= kidMol->margin.left + kidMol->margin.right;
+ kidAvailSize.width -= kidSpacing->mMargin.left +
+ kidSpacing->mMargin.right;
}
// Reflow the child into the available space
@@ -1013,9 +1025,10 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
// Place the child after taking into account it's margin
aState.y += topMargin;
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
- kidRect.x += kidMol->margin.left;
- kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, kidMaxElementSize);
+ kidRect.x += aState.leftInset + kidSpacing->mMargin.left;
+ kidRect.y += aState.topInset + aState.y ;
+ PlaceChild(aPresContext, aState, kidFrame, kidRect,
+ aMaxElementSize, kidMaxElementSize);
if (bottomMargin < 0) {
aState.prevMaxNegBottomMargin = -bottomMargin;
} else {
@@ -1389,8 +1402,6 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Figure out how we should treat the child
nsIFrame* kidFrame;
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
// Create a child frame
if (nsnull == kidPrevInFlow) {
@@ -1427,7 +1438,6 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// finish).
//aState.y += topMargin;
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
- //kidRect.x += kidMol->margin.left;
kidRect.y += aState.y;
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
@@ -1474,7 +1484,6 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
*/
// use the cell map to determine which cell is in which column.
void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyle,
const nsSize& aMaxSize,
nsSize* aMaxElementSize)
{
@@ -1498,21 +1507,34 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
PRInt32 maxTableWidth = 0;
PRInt32 totalFixedWidth = 0;
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+
// need to figure out the overall table width constraint
- PRInt32 maxWidth = aMaxSize.width; // default case, get 100% of available space
- if (-1!=aTableStyle->fixedWidth) // if there is a fixed width attribute, use it
- {
- maxWidth = aTableStyle->fixedWidth;
+ // default case, get 100% of available space
+ PRInt32 maxWidth;
+ nsStylePosition* position =
+ (nsStylePosition*)mStyleContext->GetData(kStylePositionSID);
+ switch (position->mWidthFlags) {
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ maxWidth = position->mWidth;
+ break;
+ case NS_STYLE_POSITION_VALUE_PCT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ // XXX for now these fall through
+
+ default:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ maxWidth = aMaxSize.width;
+ break;
}
- else if ((NS_UNCONSTRAINEDSIZE!=maxWidth) &&
- (-1!=aTableStyle->proportionalWidth && 0!=aTableStyle->proportionalWidth))
- {
- maxWidth = (maxWidth*aTableStyle->proportionalWidth)/100;
- }
- // now, if maxWidth is not NS_UNCONSTRAINED, subtract out my border and padding
+
+ // now, if maxWidth is not NS_UNCONSTRAINED, subtract out my border
+ // and padding
if (NS_UNCONSTRAINEDSIZE!=maxWidth)
{
- maxWidth -= aTableStyle->borderPadding.left + aTableStyle->borderPadding.right;
+ maxWidth -= spacing->mBorderPadding.left + spacing->mBorderPadding.right;
if (0>maxWidth) // nonsense style specification
maxWidth = 0;
}
@@ -1520,7 +1542,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
if (gsDebug) printf (" maxWidth=%d from aMaxSize=%d,%d\n", maxWidth, aMaxSize.width, aMaxSize.height);
// Step 1 - assign the width of all fixed-width columns
- AssignFixedColumnWidths(aPresContext, maxWidth, numCols, aTableStyle,
+ AssignFixedColumnWidths(aPresContext, maxWidth, numCols,
totalFixedWidth, minTableWidth, maxTableWidth);
if (nsnull!=aMaxElementSize)
@@ -1539,14 +1561,14 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
if (TableIsAutoWidth())
{
if (gsDebug==PR_TRUE) printf (" calling BalanceProportionalColumnsForAutoWidthTable\n");
- BalanceProportionalColumnsForAutoWidthTable(aPresContext, aTableStyle,
+ BalanceProportionalColumnsForAutoWidthTable(aPresContext,
availWidth, maxWidth,
minTableWidth, maxTableWidth);
}
else
{
if (gsDebug==PR_TRUE) printf (" calling BalanceProportionalColumnsForSpecifiedWidthTable\n");
- BalanceProportionalColumnsForSpecifiedWidthTable(aPresContext, aTableStyle,
+ BalanceProportionalColumnsForSpecifiedWidthTable(aPresContext,
availWidth, maxWidth,
minTableWidth, maxTableWidth);
}
@@ -1590,11 +1612,13 @@ if there is space left over
}
// Step 1 - assign the width of all fixed-width columns,
- // and calculate min/max table width
-PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt32 maxWidth,
- PRInt32 aNumCols, nsStyleMolecule* aTableStyleMol,
+// and calculate min/max table width
+PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext,
+ PRInt32 maxWidth,
+ PRInt32 aNumCols,
PRInt32 &aTotalFixedWidth,
- PRInt32 &aMinTableWidth, PRInt32 &aMaxTableWidth)
+ PRInt32 &aMinTableWidth,
+ PRInt32 &aMaxTableWidth)
{
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
@@ -1606,15 +1630,44 @@ PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt
NS_ASSERTION(nsnull != colData, "bad column data");
nsTableColPtr col = colData->GetCol(); // col: ADDREF++
NS_ASSERTION(nsnull != col, "bad col");
- nsStyleMolecule* colStyle =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull != colStyle, "bad style for col.");
+
// need to track min/max column width for setting min/max table widths
PRInt32 minColWidth = 0;
PRInt32 maxColWidth = 0;
nsVoidArray *cells = colData->GetCells();
PRInt32 numCells = cells->Count();
if (gsDebug==PR_TRUE) printf (" for column %d numCells = %d\n", colIndex, numCells);
+
+#if XXX_need_access_to_column_frame_help
+ // Get the columns's style
+ nsIStyleContextPtr colSC;
+ colFrame->GetStyleContext(aPresContext, colSC.AssignRef());
+ nsStylePosition* colPosition = (nsStylePosition*)
+ colSC->GetData(kStylePositionSID);
+
+ // Get column width if it has one
+ PRBool haveColWidth = PR_FALSE;
+ nscoord colWidth;
+ switch (colPosition->mWidthFlags) {
+ default:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ break;
+
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ haveColWidth = PR_TRUE;
+ colWidth = colPosition->mWidth;
+ break;
+
+ case NS_STYLE_POSITION_VALUE_PCT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ //XXX haveColWidth = PR_TRUE;
+ //XXX colWidth = colPosition->mWidthPCT * something;
+ break;
+ }
+#endif
+
+ // Scan the column
for (PRInt32 cellIndex = 0; cellIndexElementAt(cellIndex));
@@ -1625,62 +1678,112 @@ PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt
if (gsDebug==PR_TRUE)
printf (" for cell %d min = %d,%d and des = %d,%d\n", cellIndex, cellMinSize->width, cellMinSize->height,
cellDesiredSize->width, cellDesiredSize->height);
- /* the first cell in a column (in row 0) has special standing.
- * if the first cell has a width specification, it overrides the COL width
+
+ PRBool haveCellWidth = PR_FALSE;
+ nscoord cellWidth;
+
+ /*
+ * The first cell in a column (in row 0) has special standing.
+ * if the first cell has a width specification, it overrides the
+ * COL width
*/
if (0==cellIndex)
{
- // SEC: TODO -- when we have a style system, set the mol for the col
nsCellLayoutData * data = (nsCellLayoutData *)(cells->ElementAt(0));
nsTableCellFrame *cellFrame = data->GetCellFrame();
nsTableCellPtr cell;
cellFrame->GetContent((nsIContent*&)(cell.AssignRef())); // cell: REFCNT++
- nsStyleMolecule* cellStyle = (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull != cellStyle, "bad style for cell.");
- // SEC: this is the code to replace
- if (-1!=cellStyle->fixedWidth)
- colStyle->proportionalWidth = cellStyle->proportionalWidth;
- if (-1!=cellStyle->proportionalWidth)
- colStyle->proportionalWidth = cellStyle->proportionalWidth;
- // SEC: end code to replace
- }
- if (-1!=colStyle->fixedWidth)
- { // this col has fixed width, so set the cell's width
- // to the larger of (specified width, largest max_element_size of the cells in the column)
- PRInt32 widthForThisCell = max(cellMinSize->width, colStyle->fixedWidth);
- if (mColumnWidths[colIndex] < widthForThisCell)
- {
- if (gsDebug) printf (" setting fixed width to %d\n",widthForThisCell);
- mColumnWidths[colIndex] = widthForThisCell;
- maxColWidth = widthForThisCell;
+
+ // Get the cell's style
+ nsIStyleContextPtr cellSC;
+ cellFrame->GetStyleContext(aPresContext, cellSC.AssignRef());
+ nsStylePosition* cellPosition = (nsStylePosition*)
+ cellSC->GetData(kStylePositionSID);
+ switch (cellPosition->mWidthFlags) {
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ haveCellWidth = PR_TRUE;
+ cellWidth = cellPosition->mWidth;
+ break;
+
+ case NS_STYLE_POSITION_VALUE_PCT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ // XXX write me when pct/proportional are supported
+ // XXX haveCellWidth = PR_TRUE;
+ // XXX cellWidth = cellPosition->mWidth;
+ break;
+
+ default:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ break;
}
}
- // regardless of the width specification, keep track of the min/max column widths
- /* TODO: must distribute COLSPAN'd cell widths between columns, either here
- * or in the subsequent Balance***ColumnWidth routines
+
+#if XXX_need_access_to_column_frame_help
+ switch (colPosition->mWidthFlags) {
+ default:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ break;
+
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ {
+ // This col has a fixed width, so set the cell's width to the
+ // larger of (specified width, largest max_element_size of the
+ // cells in the column)
+ PRInt32 widthForThisCell = max(cellMinSize->width, colPosition->mWidth);
+ if (mColumnWidths[colIndex] < widthForThisCell)
+ {
+ if (gsDebug) printf (" setting fixed width to %d\n",widthForThisCell);
+ mColumnWidths[colIndex] = widthForThisCell;
+ maxColWidth = widthForThisCell;
+ }
+ }
+ break;
+
+ case NS_STYLE_POSITION_VALUE_PCT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ // XXX write me when pct/proportional are supported
+ break;
+ }
+#endif
+
+ // regardless of the width specification, keep track of the
+ // min/max column widths
+ /* TODO: must distribute COLSPAN'd cell widths between columns,
+ * either here or in the subsequent Balance***ColumnWidth
+ * routines
*/
if (minColWidth < cellMinSize->width)
minColWidth = cellMinSize->width;
if (maxColWidth < cellDesiredSize->width)
maxColWidth = cellDesiredSize->width;
- if (gsDebug==PR_TRUE)
- printf (" after cell %d, minColWidth = %d and maxColWidth = %d\n", cellIndex, minColWidth, maxColWidth);
+ if (gsDebug) {
+ printf (" after cell %d, minColWidth = %d and maxColWidth = %d\n",
+ cellIndex, minColWidth, maxColWidth);
+ }
/* take colspan into account? */
/*
PRInt32 colSpan = col->GetColSpan();
cellIndex += colSpan-1;
*/
}
- if (-1!=colStyle->fixedWidth)
- {
- // if the col is fixed-width, expand the col to the specified fixed width if necessary
- if (colStyle->fixedWidth > mColumnWidths[colIndex])
- mColumnWidths[colIndex] = colStyle->fixedWidth;
- // keep a running total of the amount of space taken up by all fixed-width columns
- aTotalFixedWidth += mColumnWidths[colIndex];
- if (gsDebug)
- printf (" after col %d, aTotalFixedWidth = %d\n", colIndex, aTotalFixedWidth);
+
+#if 0
+ // if the col is fixed-width, expand the col to the specified
+ // fixed width if necessary
+ if (colStyle->fixedWidth > mColumnWidths[colIndex])
+ mColumnWidths[colIndex] = colStyle->fixedWidth;
+
+ // keep a running total of the amount of space taken up by all
+ // fixed-width columns
+ aTotalFixedWidth += mColumnWidths[colIndex];
+ if (gsDebug) {
+ printf (" after col %d, aTotalFixedWidth = %d\n",
+ colIndex, aTotalFixedWidth);
}
+#endif
+
// add col[i] metrics to the running totals for the table min/max width
if (NS_UNCONSTRAINEDSIZE!=aMinTableWidth)
aMinTableWidth += minColWidth; // SEC: insets!
@@ -1698,7 +1801,6 @@ PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt
}
PRBool nsTableFrame::BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -1711,7 +1813,7 @@ PRBool nsTableFrame::BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresCon
if (NS_UNCONSTRAINEDSIZE==aMaxWidth)
{ // the max width of the table fits comfortably in the available space
if (gsDebug) printf (" * table laying out in NS_UNCONSTRAINEDSIZE, calling BalanceColumnsTableFits\n");
- result = BalanceColumnsTableFits(aPresContext, aTableStyleMol, aAvailWidth);
+ result = BalanceColumnsTableFits(aPresContext, aAvailWidth);
}
else if (aMinTableWidth > aMaxWidth)
{ // the table doesn't fit in the available space
@@ -1721,19 +1823,18 @@ PRBool nsTableFrame::BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresCon
else if (aMaxTableWidth <= aMaxWidth)
{ // the max width of the table fits comfortably in the available space
if (gsDebug) printf (" * table desired size fits, calling BalanceColumnsTableFits\n");
- result = BalanceColumnsTableFits(aPresContext, aTableStyleMol, aAvailWidth);
+ result = BalanceColumnsTableFits(aPresContext, aAvailWidth);
}
else
{ // the table fits somewhere between its min and desired size
if (gsDebug) printf (" * table desired size does not fit, calling BalanceColumnsHTML4Constrained\n");
- result = BalanceColumnsHTML4Constrained(aPresContext, aTableStyleMol, aAvailWidth,
+ result = BalanceColumnsHTML4Constrained(aPresContext, aAvailWidth,
aMaxWidth, aMinTableWidth, aMaxTableWidth);
}
return result;
}
PRBool nsTableFrame::BalanceProportionalColumnsForAutoWidthTable( nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -1744,7 +1845,7 @@ PRBool nsTableFrame::BalanceProportionalColumnsForAutoWidthTable( nsIPresContext
if (NS_UNCONSTRAINEDSIZE==aMaxWidth)
{ // the max width of the table fits comfortably in the available space
if (gsDebug) printf (" * table laying out in NS_UNCONSTRAINEDSIZE, calling BalanceColumnsTableFits\n");
- result = BalanceColumnsTableFits(aPresContext, aTableStyleMol, aAvailWidth);
+ result = BalanceColumnsTableFits(aPresContext, aAvailWidth);
}
else if (aMinTableWidth > aMaxWidth)
{ // the table doesn't fit in the available space
@@ -1754,12 +1855,12 @@ PRBool nsTableFrame::BalanceProportionalColumnsForAutoWidthTable( nsIPresContext
else if (aMaxTableWidth <= aMaxWidth)
{ // the max width of the table fits comfortably in the available space
if (gsDebug) printf (" * table desired size fits, calling BalanceColumnsTableFits\n");
- result = BalanceColumnsTableFits(aPresContext, aTableStyleMol, aAvailWidth);
+ result = BalanceColumnsTableFits(aPresContext, aAvailWidth);
}
else
{ // the table fits somewhere between its min and desired size
if (gsDebug) printf (" * table desired size does not fit, calling BalanceColumnsHTML4Constrained\n");
- result = BalanceColumnsHTML4Constrained(aPresContext, aTableStyleMol, aAvailWidth,
+ result = BalanceColumnsHTML4Constrained(aPresContext, aAvailWidth,
aMaxWidth, aMinTableWidth, aMaxTableWidth);
}
return result;
@@ -1774,14 +1875,16 @@ PRBool nsTableFrame::SetColumnsToMinWidth(nsIPresContext* aPresContext)
{
nsColLayoutData * colData = (nsColLayoutData *)(columnLayoutData->ElementAt(colIndex));
nsTableColPtr col = colData->GetCol(); // col: ADDREF++
- nsStyleMolecule* colStyle =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
nsVoidArray *cells = colData->GetCells();
PRInt32 minColWidth = 0;
PRInt32 maxColWidth = 0;
PRInt32 numCells = cells->Count();
if (gsDebug==PR_TRUE) printf (" for col %d\n", colIndex);
- if (PR_TRUE==IsProportionalWidth(colStyle))
+
+ // XXX need column frame to ask this question
+ nsStylePosition* colPosition = nsnull;
+
+ if (PR_TRUE==IsProportionalWidth(colPosition))
{
for (PRInt32 cellIndex = 0; cellIndexElementAt(colIndex));
nsTableColPtr col = colData->GetCol(); // col: ADDREF++
- nsStyleMolecule* colStyle =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
nsVoidArray *cells = colData->GetCells();
PRInt32 minColWidth = 0;
PRInt32 maxColWidth = 0;
@@ -1841,7 +1944,11 @@ PRBool nsTableFrame::BalanceColumnsTableFits(nsIPresContext* aPresContext,
/* TODO: must distribute COLSPAN'd cell widths between columns, either here
* or in the prior Balance***ColumnWidth routines
*/
- if (PR_TRUE==IsProportionalWidth(colStyle))
+
+ // XXX Need columnFrame to ask the style question
+ nsStylePosition* colPosition = nsnull;
+
+ if (PR_TRUE==IsProportionalWidth(colPosition))
{
for (PRInt32 cellIndex = 0; cellIndexproportionalWidth)
{ // col width is specified to be the minimum
mColumnWidths[colIndex] = minColWidth;
@@ -1875,7 +1986,9 @@ PRBool nsTableFrame::BalanceColumnsTableFits(nsIPresContext* aPresContext,
printf (" 3 (0): col %d set to min width = %d because style set proportionalWidth=0\n",
colIndex, mColumnWidths[colIndex]);
}
- if (PR_TRUE==AutoColumnWidths(aTableStyleMol))
+ else // BUG? else? other code below has the else
+#endif
+ if (PR_TRUE==AutoColumnWidths())
{ // give each remaining column it's desired width
// if there is width left over, we'll factor that in after this loop is complete
mColumnWidths[colIndex] = maxColWidth;
@@ -1892,8 +2005,10 @@ PRBool nsTableFrame::BalanceColumnsTableFits(nsIPresContext* aPresContext,
}
else
{
+#if XXX_bug_kipp_about_this
percentage = colStyle->proportionalWidth;
if (-1==percentage)
+#endif
percentage = 100/numCols;
mColumnWidths[colIndex] = (percentage*aAvailWidth)/100;
// if the column was computed to be too small, enlarge the column
@@ -1911,7 +2026,6 @@ PRBool nsTableFrame::BalanceColumnsTableFits(nsIPresContext* aPresContext,
}
PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -1927,14 +2041,22 @@ PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext
{
nsColLayoutData * colData = (nsColLayoutData *)(columnLayoutData->ElementAt(colIndex));
nsTableColPtr col = colData->GetCol(); // col: ADDREF++
+
+#if XXX_bug_kipp_about_this
+ // XXX BUG: mStyleContext is for the table frame not for the column.
nsStyleMolecule* colStyle =
(nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
+#else
+ nsStylePosition* colPosition = nsnull;
+#endif
+
nsVoidArray *cells = colData->GetCells();
PRInt32 minColWidth = 0;
PRInt32 maxColWidth = 0;
PRInt32 numCells = cells->Count();
if (gsDebug==PR_TRUE) printf (" for col %d\n", colIndex);
- if (PR_TRUE==IsProportionalWidth(colStyle))
+
+ if (PR_TRUE==IsProportionalWidth(colPosition))
{
for (PRInt32 cellIndex = 0; cellIndexproportionalWidth)
{ // col width is specified to be the minimum
mColumnWidths[colIndex] = minColWidth;
@@ -1973,7 +2099,9 @@ PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext
printf (" 4 (0): col %d set to min width = %d because style set proportionalWidth=0\n",
colIndex, mColumnWidths[colIndex]);
}
- else if (AutoColumnWidths(aTableStyleMol))
+ else
+#endif
+ if (AutoColumnWidths())
{
PRInt32 W = aMaxWidth - aMinTableWidth;
PRInt32 D = aMaxTableWidth - aMinTableWidth;
@@ -1985,9 +2113,11 @@ PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext
}
else
{ // give each remaining column an equal percentage of the remaining space
+#if XXX_bug_kipp_about_this
PRInt32 percentage = colStyle->proportionalWidth;
if (-1==percentage)
- percentage = 100/numCols;
+#endif
+ PRInt32 percentage = 100/numCols;
mColumnWidths[colIndex] = (percentage*aAvailWidth)/100;
// if the column was computed to be too small, enlarge the column
if (mColumnWidths[colIndex] <= minColWidth)
@@ -2012,7 +2142,7 @@ PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext
// if columns have equal width, and some column's content couldn't squeeze into the computed size,
// then expand every column to the min size of the column with the largest min size
- if (!AutoColumnWidths(aTableStyleMol) && 0!=maxOfAllMinColWidths)
+ if (!AutoColumnWidths() && 0!=maxOfAllMinColWidths)
{
if (gsDebug==PR_TRUE) printf(" EqualColWidths specified, so setting all col widths to %d\n", maxOfAllMinColWidths);
for (PRInt32 colIndex = 0; colIndexborderPadding.right;
- nscoord leftInset = aTableStyle->borderPadding.left;
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nscoord rightInset = spacing->mBorderPadding.right;
+ nscoord leftInset = spacing->mBorderPadding.left;
tableWidth += (leftInset + rightInset);
nsRect tableSize = mRect;
tableSize.width = tableWidth;
@@ -2069,7 +2200,14 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
#endif
// iterate children, tell all row groups to ShrinkWrap
PRBool atLeastOneRowSpanningCell = PR_FALSE;
+
PRInt32 tableHeight = 0;
+
+ nsStyleSpacing* spacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
+ tableHeight +=
+ spacing->mBorderPadding.top + spacing->mBorderPadding.bottom;
+
PRInt32 childCount = mChildCount;
nsIFrame * kidFrame;
for (PRInt32 i = 0; i < childCount; i++)
@@ -2277,12 +2415,31 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
#endif
}
-PRBool nsTableFrame::IsProportionalWidth(nsStyleMolecule* aMol)
+// XXX Kipp wonders: what does this really mean? Are you really asking
+// "Is it fixed width"? If so, then VALUE_PCT may be wrong and the
+// name of the method should be changed.
+
+PRBool nsTableFrame::IsProportionalWidth(nsStylePosition* aStylePosition)
{
PRBool result = PR_FALSE;
- if ((-1!=aMol->proportionalWidth) ||
- ((-1==aMol->proportionalWidth) && (-1==aMol->fixedWidth)))
+ if (nsnull == aStylePosition) {
+ // Assume NS_STYLE_POSITION_VALUE_AUTO when no style is available
result = PR_TRUE;
+ }
+ else {
+ switch (aStylePosition->mWidthFlags) {
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ case NS_STYLE_POSITION_VALUE_PCT:
+ break;
+
+ default:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ result = PR_TRUE;
+ break;
+ }
+ }
return result;
}
@@ -2487,7 +2644,7 @@ PRBool nsTableFrame::TableIsAutoWidth()
return isTableAutoWidth;
}
-PRBool nsTableFrame::AutoColumnWidths(nsStyleMolecule* aTableStyleMol)
+PRBool nsTableFrame::AutoColumnWidths()
{ // ZZZ: TOTAL HACK
return isAutoColumnWidths;
}
@@ -2525,8 +2682,6 @@ NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
// Resolve style for the child
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(content, cf); // kidStyleContext: REFCNT++
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
nsIContentDelegate* kidDel = nsnull;
kidDel = content->GetDelegate(aPresContext); // kidDel: REFCNT++
nsIFrame * duplicateFrame = kidDel->CreateFrame(aPresContext, content, index, cf);
@@ -2577,6 +2732,12 @@ PRInt32 nsTableFrame::GetColumnWidth(PRInt32 aColIndex)
//printf("GET_COL_WIDTH: %p, FIF=%p getting col %d and returning %d\n", this, firstInFlow, aColIndex, result);
+ // XXX hack
+#if 0
+ if (result <= 0) {
+ result = 100;
+ }
+#endif
return result;
}
diff --git a/mozilla/layout/html/table/src/nsTableFrame.h b/mozilla/layout/html/table/src/nsTableFrame.h
index 23ace38b50d..2683b86066c 100644
--- a/mozilla/layout/html/table/src/nsTableFrame.h
+++ b/mozilla/layout/html/table/src/nsTableFrame.h
@@ -26,8 +26,9 @@ class nsTableCell;
class nsVoidArray;
class nsTableCellFrame;
class CellData;
-struct nsStyleMolecule;
struct InnerTableReflowState;
+struct nsStylePosition;
+struct nsStyleSpacing;
/** nsTableFrame maps the inner portion of a table (everything except captions.)
* Used as a pseudo-frame within nsTableOuterFrame,
@@ -133,7 +134,7 @@ public:
/** returns PR_TRUE if this table has proportional width
*/
- PRBool IsProportionalWidth(nsStyleMolecule* aMol);
+ PRBool IsProportionalWidth(nsStylePosition* aStylePosition);
@@ -193,11 +194,10 @@ protected:
*
* @see ResizeReflow
*/
- virtual nsIFrame::ReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle);
+ virtual ReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsSize& aMaxSize,
+ nsSize* aMaxElementSize);
/** second pass of ResizeReflow.
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
@@ -210,17 +210,16 @@ protected:
* @see ResizeReflow
* @see NeedsReflow
*/
- virtual nsIFrame::ReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle,
- PRInt32 aMinCaptionWidth,
- PRInt32 mMaxCaptionWidth);
+ virtual ReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsSize& aMaxSize,
+ nsSize* aMaxElementSize,
+ PRInt32 aMinCaptionWidth,
+ PRInt32 mMaxCaptionWidth);
nscoord GetTopMarginFor(nsIPresContext* aCX,
InnerTableReflowState& aState,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild(nsIPresContext* aPresContext,
InnerTableReflowState& aState,
@@ -273,7 +272,6 @@ protected:
* @param aMaxElementSize the min size of the largest indivisible object
*/
virtual void BalanceColumnWidths(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyle,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
@@ -296,7 +294,6 @@ protected:
virtual PRBool AssignFixedColumnWidths(nsIPresContext* aPresContext,
PRInt32 aMaxWidth,
PRInt32 aNumCols,
- nsStyleMolecule* aTableStyleMol,
PRInt32 & aTotalFixedWidth,
PRInt32 & aMinTableWidth,
PRInt32 & aMaxTableWidth);
@@ -317,7 +314,6 @@ protected:
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -339,7 +335,6 @@ protected:
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceProportionalColumnsForAutoWidthTable(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -366,7 +361,6 @@ protected:
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*/
virtual PRBool BalanceColumnsTableFits(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth);
/** assign widths for each column that has proportional width inside a table that
@@ -386,15 +380,13 @@ protected:
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
PRInt32 aMaxTableWidth);
/** sets the width of the table according to the computed widths of each column. */
- virtual void SetTableWidth(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyle);
+ virtual void SetTableWidth(nsIPresContext* aPresContext);
/**
*/
@@ -413,7 +405,7 @@ protected:
* according to its content.
* In NAV4, this is when there is a COLS attribute on the table.
*/
- virtual PRBool AutoColumnWidths(nsStyleMolecule* aTableStyleMol);
+ virtual PRBool AutoColumnWidths();
/** given the new parent size, do I really need to do a reflow? */
virtual PRBool NeedsReflow(const nsSize& aMaxSize);
diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp
index 704257e1516..60acd628377 100644
--- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp
@@ -43,7 +43,8 @@ static PRBool gsDebug = PR_FALSE;
static const PRBool gsDebug = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
static NS_DEFINE_IID(kITableContentIID, NS_ITABLECONTENT_IID);
NS_DEF_PTR(nsIStyleContext);
@@ -54,9 +55,6 @@ struct OuterTableReflowState {
// The presentation context
nsIPresContext *pc;
- // The body's style molecule
- nsStyleMolecule* mol;
-
// The total available size (computed from the parent)
nsSize availSize;
// The available size for the inner table frame
@@ -78,11 +76,9 @@ struct OuterTableReflowState {
PRBool processingCaption;
OuterTableReflowState(nsIPresContext* aPresContext,
- const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ const nsSize& aMaxSize)
{
pc = aPresContext;
- mol = aMol;
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
prevMaxPosBottomMargin = 0;
@@ -213,17 +209,14 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
aStatus = frComplete;
return NS_OK;
}
-
- nsStyleMolecule* tableStyleMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- OuterTableReflowState state(aPresContext, aMaxSize, tableStyleMol);
+ OuterTableReflowState state(aPresContext, aMaxSize);
// lay out captions pass 1, if necessary
if (PR_FALSE==IsFirstPassValid())
{
mFirstPassValid = PR_TRUE;
- aStatus = ResizeReflowCaptionsPass1(aPresContext, tableStyleMol);
+ aStatus = ResizeReflowCaptionsPass1(aPresContext);
}
@@ -232,7 +225,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
{ // we treat the table as if we've never seen the layout data before
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST);
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize, aMaxSize,
- &innerTableMaxElementSize, tableStyleMol);
+ &innerTableMaxElementSize);
#ifdef NOISY_MARGINS
nsIContentPtr content = mInnerTableFrame->GetContent();
@@ -252,9 +245,9 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
if (nsnull==prevInFlow)
{
// assign column widths, and assign aMaxElementSize->width
- mInnerTableFrame->BalanceColumnWidths(aPresContext, tableStyleMol, aMaxSize, aMaxElementSize);
+ mInnerTableFrame->BalanceColumnWidths(aPresContext, aMaxSize, aMaxElementSize);
// assign table width
- mInnerTableFrame->SetTableWidth(aPresContext, tableStyleMol);
+ mInnerTableFrame->SetTableWidth(aPresContext);
}
// inner table max is now the computed width and assigned height
nsSize innerTableSize;
@@ -350,12 +343,12 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
// Collapse child's top margin with previous bottom margin
nscoord nsTableOuterFrame::GetTopMarginFor(nsIPresContext* aCX,
OuterTableReflowState& aState,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
nscoord margin;
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -468,9 +461,10 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing =
+ (nsStyleSpacing*)kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
// Figure out the amount of available size for the child (subtract
// off the top margin we are going to apply to it)
@@ -479,7 +473,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
}
// Subtract off for left and right margin
if (PR_FALSE == aState.unconstrainedWidth) {
- aState.availSize.width -= kidMol->margin.left + kidMol->margin.right;
+ aState.availSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
// Only skip the reflow if this is not our first child and we are
@@ -509,7 +503,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
// Place the child after taking into account it's margin
aState.y += topMargin;
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
- kidRect.x += kidMol->margin.left;
+ kidRect.x += kidSpacing->mMargin.left;
kidRect.y += aState.y;
PlaceChild(aState, kidFrame, kidRect, aMaxElementSize, kidMaxElementSize);
if (bottomMargin < 0) {
@@ -894,29 +888,28 @@ nsTableOuterFrame::ReflowChild( nsIFrame* aKidFrame,
aKidFrame->GetStyleContext(aPresContext, captionStyleContext.AssignRef());
NS_ASSERTION(nsnull != captionStyleContext, "null style context for caption");
- nsStyleMolecule* captionStyle =
- (nsStyleMolecule*)captionStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleText* captionStyle =
+ (nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->verticalAlign)
+ if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign)
{
if (PR_TRUE==gsDebug) printf("reflowChild called with a bottom caption\n");
status = ResizeReflowBottomCaptionsPass2(aPresContext, aDesiredSize,
aMaxSize, aMaxElementSize,
- aState.mol, aState.y);
+ aState.y);
}
else
{
if (PR_TRUE==gsDebug) printf("reflowChild called with a top caption\n");
status = ResizeReflowTopCaptionsPass2(aPresContext, aDesiredSize,
- aMaxSize, aMaxElementSize,
- aState.mol);
+ aMaxSize, aMaxElementSize);
}
}
else
{
if (PR_TRUE==gsDebug) printf("reflowChild called with a table body\n");
- status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize, aState.availSize,
- aMaxElementSize, aState.mol,
+ status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize, aState.innerTableMaxSize,
+ aMaxElementSize,
mMinCaptionWidth, mMaxCaptionWidth);
}
if (PR_TRUE==gsDebug)
@@ -977,12 +970,12 @@ void nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext)
nsIStyleContextPtr captionStyleContext =
aPresContext->ResolveStyleContextFor(caption, this);
NS_ASSERTION(nsnull!=captionStyleContext, "bad style context for caption.");
- nsStyleMolecule* captionStyle =
- (nsStyleMolecule*)captionStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleText* captionStyle =
+ (nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
captionFrame->SetStyleContext(captionStyleContext);
mChildCount++;
// Link child frame into the list of children
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->verticalAlign)
+ if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign)
{ // bottom captions get added to the end of the outer frame child list
prevKidFrame->SetNextSibling(captionFrame);
prevKidFrame = captionFrame;
@@ -1018,7 +1011,7 @@ void nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext)
nsIFrame::ReflowStatus
-nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext, nsStyleMolecule* aTableStyle)
+nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext)
{
if (nsnull!=mCaptionFrames)
{
@@ -1046,8 +1039,7 @@ nsIFrame::ReflowStatus
nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle)
+ nsSize* aMaxElementSize)
{
ReflowStatus result = frComplete;
nscoord topCaptionY = 0;
@@ -1064,11 +1056,11 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
captionFrame->GetStyleContext(aPresContext, captionStyleContext.AssignRef());
NS_ASSERTION(nsnull != captionStyleContext, "null style context for caption");
- nsStyleMolecule* captionStyle =
- (nsStyleMolecule*)captionStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleText* captionStyle =
+ (nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->verticalAlign)
+ if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign)
{
}
else
@@ -1113,7 +1105,6 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle,
nscoord aYOffset)
{
ReflowStatus result = frComplete;
diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.h b/mozilla/layout/html/table/src/nsTableOuterFrame.h
index 041f43c25fa..b53523daabc 100644
--- a/mozilla/layout/html/table/src/nsTableOuterFrame.h
+++ b/mozilla/layout/html/table/src/nsTableOuterFrame.h
@@ -23,9 +23,9 @@
class nsTableFrame;
class nsVoidArray;
-struct nsStyleMolecule;
class nsTableCaptionFrame;
struct OuterTableReflowState;
+struct nsStyleSpacing;
/**
* main frame for an nsTable content object,
@@ -137,8 +137,7 @@ protected:
/** reflow the captions in an infinite space, caching the min/max sizes for each
*/
- virtual ReflowStatus ResizeReflowCaptionsPass1(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyle);
+ virtual ReflowStatus ResizeReflowCaptionsPass1(nsIPresContext* aPresContext);
/** reflow the top captions in a space constrained by the computed table width
* and the heigth given to us by our parent. Top captions are laid down
@@ -147,8 +146,7 @@ protected:
virtual ReflowStatus ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle);
+ nsSize* aMaxElementSize);
/** reflow the bottom captions in a space constrained by the computed table width
* and the heigth given to us by our parent. Bottom captions are laid down
@@ -158,12 +156,11 @@ protected:
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle,
nscoord aYOffset);
nscoord GetTopMarginFor(nsIPresContext* aCX,
OuterTableReflowState& aState,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild( OuterTableReflowState& aState,
nsIFrame* aKidFrame,
diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp
index 318e92d5cbb..c433909404e 100644
--- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp
@@ -38,15 +38,11 @@ static const PRBool gsDebug1 = PR_FALSE;
static const PRBool gsDebug2 = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
/* ----------- RowReflowState ---------- */
struct RowReflowState {
-
- // The body's style molecule
- nsStyleMolecule* mol;
-
// The body's available size (computed from the body's parent)
nsSize availSize;
@@ -68,10 +64,8 @@ struct RowReflowState {
RowReflowState( nsIPresContext* aPresContext,
- const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ const nsSize& aMaxSize)
{
- mol = aMol;
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
prevMaxPosBottomMargin = 0;
@@ -175,12 +169,12 @@ PRInt32 nsTableRowFrame::GetTallestChild() const
// Collapse child's top margin with previous bottom margin
nscoord nsTableRowFrame::GetTopMarginFor( nsIPresContext* aCX,
RowReflowState& aState,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
nscoord margin;
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -284,9 +278,10 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// Get top margin for this kid
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
NS_RELEASE(kidSC);
// Figure out the amount of available size for the child (subtract
@@ -296,7 +291,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
}
// Subtract off for left and right margin
if (PR_FALSE == aState.unconstrainedWidth) {
- kidAvailSize.width -= kidMol->margin.left + kidMol->margin.right;
+ kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
@@ -315,7 +310,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
nscoord availWidth = 0;
for (PRInt32 numColSpan=0; numColSpanGetColumnWidth(cellStartingCol+numColSpan);
- NS_ASSERTION(0margin.left + kidMol->margin.right;
+ kidAvailSize.width += kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
// Get the next child
@@ -801,10 +796,10 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
// Resolve style
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(cell, this);
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidStyleContext->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
nsIFrame* kidFrame;
@@ -956,9 +951,7 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
// Check for an overflow list
MoveOverflowToChildList();
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- RowReflowState state(aPresContext, aMaxSize, myMol);
+ RowReflowState state(aPresContext, aMaxSize);
mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame));
// Reflow the existing frames
diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.h b/mozilla/layout/html/table/src/nsTableRowFrame.h
index c10efc5ba8b..141ef6a9a6d 100644
--- a/mozilla/layout/html/table/src/nsTableRowFrame.h
+++ b/mozilla/layout/html/table/src/nsTableRowFrame.h
@@ -22,7 +22,7 @@
#include "nsContainerFrame.h"
struct RowReflowState;
-
+struct nsStyleSpacing;
/**
* nsTableRowFrame is the frame that maps table rows
@@ -121,7 +121,7 @@ protected:
nscoord GetTopMarginFor(nsIPresContext* aCX,
RowReflowState& aState,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild( nsIPresContext* aPresContext,
RowReflowState& aState,
diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp
index e43975e4609..411a05ed2a4 100644
--- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp
@@ -37,7 +37,7 @@ static const PRBool gsDebug1 = PR_FALSE;
static const PRBool gsDebug2 = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -45,10 +45,6 @@ NS_DEF_PTR(nsIContent);
/* ----------- RowGroupReflowState ---------- */
struct RowGroupReflowState {
-
- // The body's style molecule
- nsStyleMolecule* mol;
-
// The body's available size (computed from the body's parent)
nsSize availSize;
@@ -70,10 +66,8 @@ struct RowGroupReflowState {
nscoord firstRowHeight;
RowGroupReflowState(nsIPresContext* aPresContext,
- const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ const nsSize& aMaxSize)
{
- mol = aMol;
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
prevMaxPosBottomMargin = 0;
@@ -170,12 +164,12 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
// Collapse child's top margin with previous bottom margin
nscoord nsTableRowGroupFrame::GetTopMarginFor(nsIPresContext* aCX,
RowGroupReflowState& aState,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
nscoord margin;
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -286,9 +280,10 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
// Figure out the amount of available size for the child (subtract
// off the top margin we are going to apply to it)
@@ -297,7 +292,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
}
// Subtract off for left and right margin
if (PR_FALSE == aState.unconstrainedWidth) {
- kidAvailSize.width -= kidMol->margin.left + kidMol->margin.right;
+ kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
// Reflow the child into the available space
@@ -330,7 +325,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
// Place the child after taking into account it's margin
aState.y += topMargin;
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
- kidRect.x += kidMol->margin.left;
+ kidRect.x += kidSpacing->mMargin.left;
kidRect.y += aState.y;
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize,
kidMaxElementSize);
@@ -396,7 +391,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
// Add back in the left and right margins, because one row does not
// impact another row's width
if (PR_FALSE == aState.unconstrainedWidth) {
- kidAvailSize.width += kidMol->margin.left + kidMol->margin.right;
+ kidAvailSize.width += kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
// Get the next child
@@ -731,12 +726,12 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
}
// Resolve style
- nsIStyleContextPtr kidStyleContext =
+ nsIStyleContextPtr kidSC =
aPresContext->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
nsIFrame* kidFrame;
@@ -746,7 +741,7 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, kidIndex, this);
NS_RELEASE(kidDel);
- kidFrame->SetStyleContext(kidStyleContext);
+ kidFrame->SetStyleContext(kidSC);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
}
@@ -840,9 +835,7 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
// Check for an overflow list
MoveOverflowToChildList();
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- RowGroupReflowState state(aPresContext, aMaxSize, myMol);
+ RowGroupReflowState state(aPresContext, aMaxSize);
// Reflow the existing frames
if (nsnull != mFirstChild) {
diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.h b/mozilla/layout/html/table/src/nsTableRowGroupFrame.h
index 45d26b1dccb..c341db18a06 100644
--- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.h
+++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.h
@@ -23,7 +23,7 @@
#include "nsIAtom.h"
struct RowGroupReflowState;
-struct nsStyleMolecule;
+struct nsStyleSpacing;
/**
* nsTableRowGroupFrame is the frame that maps row groups
@@ -114,7 +114,7 @@ protected:
nscoord GetTopMarginFor(nsIPresContext* aCX,
RowGroupReflowState& aState,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild( nsIPresContext* aPresContext,
RowGroupReflowState& aState,
diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp
index 736326dbbc3..51b8221f594 100644
--- a/mozilla/layout/tables/nsTableCellFrame.cpp
+++ b/mozilla/layout/tables/nsTableCellFrame.cpp
@@ -35,9 +35,10 @@ static PRBool gsDebug = PR_FALSE;
static const PRBool gsDebug = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
/**
*/
@@ -86,20 +87,15 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
**/
void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
- {
+{
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nsStyleText* textStyle =
+ (nsStyleText*)mStyleContext->GetData(kStyleTextSID);
- nsStyleMolecule* mol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull!=mol, "bad style molecule");
- nscoord topInset=0, bottomInset=0;
- PRInt32 verticalAlign = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
-
- if (nsnull!=mol)
- {
- topInset = mol->borderPadding.top;
- bottomInset =mol->borderPadding.bottom;
- verticalAlign = mol->verticalAlign;
- }
+ nscoord topInset = spacing->mBorderPadding.top;
+ nscoord bottomInset = spacing->mBorderPadding.bottom;
+ PRUint8 verticalAlign = textStyle->mVerticalAlign;
nscoord height = mRect.height;
nsRect kidRect;
@@ -225,17 +221,12 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
// SEC: what about ascent and decent???
// Compute the insets (sum of border and padding)
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull!=myMol, "bad style molecule");
- nscoord topInset=0,rightInset=0, bottomInset=0, leftInset=0;
- if (nsnull!=myMol)
- {
- topInset = myMol->borderPadding.top;
- rightInset = myMol->borderPadding.right;
- bottomInset =myMol->borderPadding.bottom;
- leftInset = myMol->borderPadding.left;
- }
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nscoord topInset = spacing->mBorderPadding.top;
+ nscoord rightInset = spacing->mBorderPadding.right;
+ nscoord bottomInset = spacing->mBorderPadding.bottom;
+ nscoord leftInset = spacing->mBorderPadding.left;
// reduce available space by insets
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
diff --git a/mozilla/layout/tables/nsTableCellFrame.h b/mozilla/layout/tables/nsTableCellFrame.h
index 65daa2c299a..c41849660b4 100644
--- a/mozilla/layout/tables/nsTableCellFrame.h
+++ b/mozilla/layout/tables/nsTableCellFrame.h
@@ -22,8 +22,6 @@
#include "nsContainerFrame.h"
#include "nsTableCell.h"
-struct nsStyleMolecule;
-
/**
* nsTableCellFrame
* data structure to maintain information about a single table cell's frame
diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp
index 8ad39a98188..9fc8d6a88ba 100644
--- a/mozilla/layout/tables/nsTableFrame.cpp
+++ b/mozilla/layout/tables/nsTableFrame.cpp
@@ -56,9 +56,10 @@ static const PRBool gsDebugMBP = PR_FALSE;
#define max(x, y) ((x) > (y) ? (x) : (y))
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
+static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -71,11 +72,12 @@ NS_DEF_PTR(nsTableCell);
struct InnerTableReflowState {
// The body's style molecule
- nsStyleMolecule* mol;
// The body's available size (computed from the body's parent)
nsSize availSize;
+ nscoord leftInset, topInset;
+
// Margin tracking information
nscoord prevMaxPosBottomMargin;
nscoord prevMaxNegBottomMargin;
@@ -98,16 +100,28 @@ struct InnerTableReflowState {
InnerTableReflowState(nsIPresContext* aPresContext,
const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ nsStyleSpacing* aStyleSpacing)
{
- mol = aMol;
- availSize.width = aMaxSize.width;
- availSize.height = aMaxSize.height;
prevMaxPosBottomMargin = 0;
prevMaxNegBottomMargin = 0;
y=0; // border/padding/margin???
+
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
+ availSize.width = aMaxSize.width;
+ if (!unconstrainedWidth) {
+ availSize.width -= aStyleSpacing->mBorderPadding.left +
+ aStyleSpacing->mBorderPadding.right;
+ }
+ leftInset = aStyleSpacing->mBorderPadding.left;
+
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
+ availSize.height = aMaxSize.height;
+ if (!unconstrainedHeight) {
+ availSize.height -= aStyleSpacing->mBorderPadding.top +
+ aStyleSpacing->mBorderPadding.bottom;
+ }
+ topInset = aStyleSpacing->mBorderPadding.top;
+
firstRowGroup = PR_TRUE;
footerHeight = 0;
footerList = nsnull;
@@ -483,37 +497,39 @@ NS_METHOD nsTableFrame::ResizeReflow(nsIPresContext* aPresContext,
aStatus = frComplete;
- PRIntervalTime startTime = PR_IntervalNow();
+ PRIntervalTime startTime;
+ if (gsTiming) {
+ startTime = PR_IntervalNow();
+ }
if (PR_TRUE==gsDebug)
printf ("*** tableframe reflow\t\t%p\n", this);
if (PR_TRUE==NeedsReflow(aMaxSize))
{
- nsStyleMolecule* tableStyleMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull != tableStyleMol, "null style molecule");
- if (nsnull==tableStyleMol)
- return frComplete; // SEC: this is an error!
-
if (PR_FALSE==IsFirstPassValid())
{ // we treat the table as if we've never seen the layout data before
mPass = kPASS_FIRST;
- aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, tableStyleMol);
+ aStatus = ResizeReflowPass1(aPresContext, aDesiredSize,
+ aMaxSize, aMaxElementSize);
// check result
}
mPass = kPASS_SECOND;
// assign column widths, and assign aMaxElementSize->width
- BalanceColumnWidths(aPresContext, tableStyleMol, aMaxSize, aMaxElementSize);
+ BalanceColumnWidths(aPresContext, aMaxSize, aMaxElementSize);
// assign table width
- SetTableWidth(aPresContext, tableStyleMol);
+ SetTableWidth(aPresContext);
- aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, tableStyleMol, 0, 0);
+ aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aMaxSize,
+ aMaxElementSize, 0, 0);
- PRIntervalTime endTime = PR_IntervalNow();
- if (gsTiming) printf("Table reflow took %ld ticks for frame %d\n", endTime-startTime, this);
+ if (gsTiming) {
+ PRIntervalTime endTime = PR_IntervalNow();
+ printf("Table reflow took %ld ticks for frame %d\n",
+ endTime-startTime, this);/* XXX need to use LL_* macros! */
+ }
mPass = kPASS_UNDEFINED;
}
@@ -540,11 +556,9 @@ NS_METHOD nsTableFrame::ResizeReflow(nsIPresContext* aPresContext,
nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle)
+ nsSize* aMaxElementSize)
{
NS_ASSERTION(nsnull!=aPresContext, "bad pres context param");
- NS_ASSERTION(nsnull!=aTableStyle, "bad style param");
NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame.");
if (gsDebug==PR_TRUE) printf("nsTableFrame::ResizeReflow Pass1: maxSize=%d,%d\n",
@@ -573,10 +587,12 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresCont
nsIFrame* prevKidFrame = nsnull;/* XXX incremental reflow! */
// Compute the insets (sum of border and padding)
- nscoord topInset = aTableStyle->borderPadding.top;
- nscoord rightInset = aTableStyle->borderPadding.right;
- nscoord bottomInset =aTableStyle->borderPadding.bottom;
- nscoord leftInset = aTableStyle->borderPadding.left;
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nscoord topInset = spacing->mBorderPadding.top;
+ nscoord rightInset = spacing->mBorderPadding.right;
+ nscoord bottomInset =spacing->mBorderPadding.bottom;
+ nscoord leftInset = spacing->mBorderPadding.left;
/* assumes that Table's children are in the following order:
* Captions
@@ -601,9 +617,6 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresCont
nsIStyleContextPtr kidStyleContext =
aPresContext->ResolveStyleContextFor(kid, this);
NS_ASSERTION(nsnull != kidStyleContext, "null style context for kid");
- nsStyleMolecule* kidStyle =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull != kidStyle, "null style molecule for kid");
// SEC: TODO: when content is appended or deleted, be sure to clear out the frame hierarchy!!!!
@@ -701,7 +714,6 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle,
PRInt32 aMinCaptionWidth,
PRInt32 mMaxCaptionWidth)
{
@@ -737,9 +749,9 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
// Check for an overflow list
MoveOverflowToChildList();
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- InnerTableReflowState state(aPresContext, aMaxSize, myMol);
+ nsStyleSpacing* mySpacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
+ InnerTableReflowState state(aPresContext, aMaxSize, mySpacing);
// Reflow the existing frames
if (nsnull != mFirstChild) {
@@ -795,13 +807,11 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
if (gsDebug==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
- printf("Reflow complete, returning %s with aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
- status==frComplete ? "Complete" : "Not Complete",
+ printf("Reflow complete, returning aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
else
- printf("Reflow complete, returning %s with aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
- status==frComplete ? "Complete" : "Not Complete",
+ printf("Reflow complete, returning aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
aDesiredSize.width, aDesiredSize.height);
}
@@ -820,12 +830,12 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
// Collapse child's top margin with previous bottom margin
nscoord nsTableFrame::GetTopMarginFor(nsIPresContext* aCX,
InnerTableReflowState& aState,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
nscoord margin;
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -976,9 +986,10 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
// Figure out the amount of available size for the child (subtract
// off the top margin we are going to apply to it)
@@ -987,7 +998,8 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
}
// Subtract off for left and right margin
if (PR_FALSE == aState.unconstrainedWidth) {
- kidAvailSize.width -= kidMol->margin.left + kidMol->margin.right;
+ kidAvailSize.width -= kidSpacing->mMargin.left +
+ kidSpacing->mMargin.right;
}
// Reflow the child into the available space
@@ -1013,9 +1025,10 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
// Place the child after taking into account it's margin
aState.y += topMargin;
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
- kidRect.x += kidMol->margin.left;
- kidRect.y += aState.y;
- PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, kidMaxElementSize);
+ kidRect.x += aState.leftInset + kidSpacing->mMargin.left;
+ kidRect.y += aState.topInset + aState.y ;
+ PlaceChild(aPresContext, aState, kidFrame, kidRect,
+ aMaxElementSize, kidMaxElementSize);
if (bottomMargin < 0) {
aState.prevMaxNegBottomMargin = -bottomMargin;
} else {
@@ -1389,8 +1402,6 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// Figure out how we should treat the child
nsIFrame* kidFrame;
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
// Create a child frame
if (nsnull == kidPrevInFlow) {
@@ -1427,7 +1438,6 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
// finish).
//aState.y += topMargin;
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
- //kidRect.x += kidMol->margin.left;
kidRect.y += aState.y;
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
@@ -1474,7 +1484,6 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
*/
// use the cell map to determine which cell is in which column.
void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyle,
const nsSize& aMaxSize,
nsSize* aMaxElementSize)
{
@@ -1498,21 +1507,34 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
PRInt32 maxTableWidth = 0;
PRInt32 totalFixedWidth = 0;
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+
// need to figure out the overall table width constraint
- PRInt32 maxWidth = aMaxSize.width; // default case, get 100% of available space
- if (-1!=aTableStyle->fixedWidth) // if there is a fixed width attribute, use it
- {
- maxWidth = aTableStyle->fixedWidth;
+ // default case, get 100% of available space
+ PRInt32 maxWidth;
+ nsStylePosition* position =
+ (nsStylePosition*)mStyleContext->GetData(kStylePositionSID);
+ switch (position->mWidthFlags) {
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ maxWidth = position->mWidth;
+ break;
+ case NS_STYLE_POSITION_VALUE_PCT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ // XXX for now these fall through
+
+ default:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ maxWidth = aMaxSize.width;
+ break;
}
- else if ((NS_UNCONSTRAINEDSIZE!=maxWidth) &&
- (-1!=aTableStyle->proportionalWidth && 0!=aTableStyle->proportionalWidth))
- {
- maxWidth = (maxWidth*aTableStyle->proportionalWidth)/100;
- }
- // now, if maxWidth is not NS_UNCONSTRAINED, subtract out my border and padding
+
+ // now, if maxWidth is not NS_UNCONSTRAINED, subtract out my border
+ // and padding
if (NS_UNCONSTRAINEDSIZE!=maxWidth)
{
- maxWidth -= aTableStyle->borderPadding.left + aTableStyle->borderPadding.right;
+ maxWidth -= spacing->mBorderPadding.left + spacing->mBorderPadding.right;
if (0>maxWidth) // nonsense style specification
maxWidth = 0;
}
@@ -1520,7 +1542,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
if (gsDebug) printf (" maxWidth=%d from aMaxSize=%d,%d\n", maxWidth, aMaxSize.width, aMaxSize.height);
// Step 1 - assign the width of all fixed-width columns
- AssignFixedColumnWidths(aPresContext, maxWidth, numCols, aTableStyle,
+ AssignFixedColumnWidths(aPresContext, maxWidth, numCols,
totalFixedWidth, minTableWidth, maxTableWidth);
if (nsnull!=aMaxElementSize)
@@ -1539,14 +1561,14 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
if (TableIsAutoWidth())
{
if (gsDebug==PR_TRUE) printf (" calling BalanceProportionalColumnsForAutoWidthTable\n");
- BalanceProportionalColumnsForAutoWidthTable(aPresContext, aTableStyle,
+ BalanceProportionalColumnsForAutoWidthTable(aPresContext,
availWidth, maxWidth,
minTableWidth, maxTableWidth);
}
else
{
if (gsDebug==PR_TRUE) printf (" calling BalanceProportionalColumnsForSpecifiedWidthTable\n");
- BalanceProportionalColumnsForSpecifiedWidthTable(aPresContext, aTableStyle,
+ BalanceProportionalColumnsForSpecifiedWidthTable(aPresContext,
availWidth, maxWidth,
minTableWidth, maxTableWidth);
}
@@ -1590,11 +1612,13 @@ if there is space left over
}
// Step 1 - assign the width of all fixed-width columns,
- // and calculate min/max table width
-PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt32 maxWidth,
- PRInt32 aNumCols, nsStyleMolecule* aTableStyleMol,
+// and calculate min/max table width
+PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext,
+ PRInt32 maxWidth,
+ PRInt32 aNumCols,
PRInt32 &aTotalFixedWidth,
- PRInt32 &aMinTableWidth, PRInt32 &aMaxTableWidth)
+ PRInt32 &aMinTableWidth,
+ PRInt32 &aMaxTableWidth)
{
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
@@ -1606,15 +1630,44 @@ PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt
NS_ASSERTION(nsnull != colData, "bad column data");
nsTableColPtr col = colData->GetCol(); // col: ADDREF++
NS_ASSERTION(nsnull != col, "bad col");
- nsStyleMolecule* colStyle =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull != colStyle, "bad style for col.");
+
// need to track min/max column width for setting min/max table widths
PRInt32 minColWidth = 0;
PRInt32 maxColWidth = 0;
nsVoidArray *cells = colData->GetCells();
PRInt32 numCells = cells->Count();
if (gsDebug==PR_TRUE) printf (" for column %d numCells = %d\n", colIndex, numCells);
+
+#if XXX_need_access_to_column_frame_help
+ // Get the columns's style
+ nsIStyleContextPtr colSC;
+ colFrame->GetStyleContext(aPresContext, colSC.AssignRef());
+ nsStylePosition* colPosition = (nsStylePosition*)
+ colSC->GetData(kStylePositionSID);
+
+ // Get column width if it has one
+ PRBool haveColWidth = PR_FALSE;
+ nscoord colWidth;
+ switch (colPosition->mWidthFlags) {
+ default:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ break;
+
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ haveColWidth = PR_TRUE;
+ colWidth = colPosition->mWidth;
+ break;
+
+ case NS_STYLE_POSITION_VALUE_PCT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ //XXX haveColWidth = PR_TRUE;
+ //XXX colWidth = colPosition->mWidthPCT * something;
+ break;
+ }
+#endif
+
+ // Scan the column
for (PRInt32 cellIndex = 0; cellIndexElementAt(cellIndex));
@@ -1625,62 +1678,112 @@ PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt
if (gsDebug==PR_TRUE)
printf (" for cell %d min = %d,%d and des = %d,%d\n", cellIndex, cellMinSize->width, cellMinSize->height,
cellDesiredSize->width, cellDesiredSize->height);
- /* the first cell in a column (in row 0) has special standing.
- * if the first cell has a width specification, it overrides the COL width
+
+ PRBool haveCellWidth = PR_FALSE;
+ nscoord cellWidth;
+
+ /*
+ * The first cell in a column (in row 0) has special standing.
+ * if the first cell has a width specification, it overrides the
+ * COL width
*/
if (0==cellIndex)
{
- // SEC: TODO -- when we have a style system, set the mol for the col
nsCellLayoutData * data = (nsCellLayoutData *)(cells->ElementAt(0));
nsTableCellFrame *cellFrame = data->GetCellFrame();
nsTableCellPtr cell;
cellFrame->GetContent((nsIContent*&)(cell.AssignRef())); // cell: REFCNT++
- nsStyleMolecule* cellStyle = (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- NS_ASSERTION(nsnull != cellStyle, "bad style for cell.");
- // SEC: this is the code to replace
- if (-1!=cellStyle->fixedWidth)
- colStyle->proportionalWidth = cellStyle->proportionalWidth;
- if (-1!=cellStyle->proportionalWidth)
- colStyle->proportionalWidth = cellStyle->proportionalWidth;
- // SEC: end code to replace
- }
- if (-1!=colStyle->fixedWidth)
- { // this col has fixed width, so set the cell's width
- // to the larger of (specified width, largest max_element_size of the cells in the column)
- PRInt32 widthForThisCell = max(cellMinSize->width, colStyle->fixedWidth);
- if (mColumnWidths[colIndex] < widthForThisCell)
- {
- if (gsDebug) printf (" setting fixed width to %d\n",widthForThisCell);
- mColumnWidths[colIndex] = widthForThisCell;
- maxColWidth = widthForThisCell;
+
+ // Get the cell's style
+ nsIStyleContextPtr cellSC;
+ cellFrame->GetStyleContext(aPresContext, cellSC.AssignRef());
+ nsStylePosition* cellPosition = (nsStylePosition*)
+ cellSC->GetData(kStylePositionSID);
+ switch (cellPosition->mWidthFlags) {
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ haveCellWidth = PR_TRUE;
+ cellWidth = cellPosition->mWidth;
+ break;
+
+ case NS_STYLE_POSITION_VALUE_PCT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ // XXX write me when pct/proportional are supported
+ // XXX haveCellWidth = PR_TRUE;
+ // XXX cellWidth = cellPosition->mWidth;
+ break;
+
+ default:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ break;
}
}
- // regardless of the width specification, keep track of the min/max column widths
- /* TODO: must distribute COLSPAN'd cell widths between columns, either here
- * or in the subsequent Balance***ColumnWidth routines
+
+#if XXX_need_access_to_column_frame_help
+ switch (colPosition->mWidthFlags) {
+ default:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ break;
+
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ {
+ // This col has a fixed width, so set the cell's width to the
+ // larger of (specified width, largest max_element_size of the
+ // cells in the column)
+ PRInt32 widthForThisCell = max(cellMinSize->width, colPosition->mWidth);
+ if (mColumnWidths[colIndex] < widthForThisCell)
+ {
+ if (gsDebug) printf (" setting fixed width to %d\n",widthForThisCell);
+ mColumnWidths[colIndex] = widthForThisCell;
+ maxColWidth = widthForThisCell;
+ }
+ }
+ break;
+
+ case NS_STYLE_POSITION_VALUE_PCT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ // XXX write me when pct/proportional are supported
+ break;
+ }
+#endif
+
+ // regardless of the width specification, keep track of the
+ // min/max column widths
+ /* TODO: must distribute COLSPAN'd cell widths between columns,
+ * either here or in the subsequent Balance***ColumnWidth
+ * routines
*/
if (minColWidth < cellMinSize->width)
minColWidth = cellMinSize->width;
if (maxColWidth < cellDesiredSize->width)
maxColWidth = cellDesiredSize->width;
- if (gsDebug==PR_TRUE)
- printf (" after cell %d, minColWidth = %d and maxColWidth = %d\n", cellIndex, minColWidth, maxColWidth);
+ if (gsDebug) {
+ printf (" after cell %d, minColWidth = %d and maxColWidth = %d\n",
+ cellIndex, minColWidth, maxColWidth);
+ }
/* take colspan into account? */
/*
PRInt32 colSpan = col->GetColSpan();
cellIndex += colSpan-1;
*/
}
- if (-1!=colStyle->fixedWidth)
- {
- // if the col is fixed-width, expand the col to the specified fixed width if necessary
- if (colStyle->fixedWidth > mColumnWidths[colIndex])
- mColumnWidths[colIndex] = colStyle->fixedWidth;
- // keep a running total of the amount of space taken up by all fixed-width columns
- aTotalFixedWidth += mColumnWidths[colIndex];
- if (gsDebug)
- printf (" after col %d, aTotalFixedWidth = %d\n", colIndex, aTotalFixedWidth);
+
+#if 0
+ // if the col is fixed-width, expand the col to the specified
+ // fixed width if necessary
+ if (colStyle->fixedWidth > mColumnWidths[colIndex])
+ mColumnWidths[colIndex] = colStyle->fixedWidth;
+
+ // keep a running total of the amount of space taken up by all
+ // fixed-width columns
+ aTotalFixedWidth += mColumnWidths[colIndex];
+ if (gsDebug) {
+ printf (" after col %d, aTotalFixedWidth = %d\n",
+ colIndex, aTotalFixedWidth);
}
+#endif
+
// add col[i] metrics to the running totals for the table min/max width
if (NS_UNCONSTRAINEDSIZE!=aMinTableWidth)
aMinTableWidth += minColWidth; // SEC: insets!
@@ -1698,7 +1801,6 @@ PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt
}
PRBool nsTableFrame::BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -1711,7 +1813,7 @@ PRBool nsTableFrame::BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresCon
if (NS_UNCONSTRAINEDSIZE==aMaxWidth)
{ // the max width of the table fits comfortably in the available space
if (gsDebug) printf (" * table laying out in NS_UNCONSTRAINEDSIZE, calling BalanceColumnsTableFits\n");
- result = BalanceColumnsTableFits(aPresContext, aTableStyleMol, aAvailWidth);
+ result = BalanceColumnsTableFits(aPresContext, aAvailWidth);
}
else if (aMinTableWidth > aMaxWidth)
{ // the table doesn't fit in the available space
@@ -1721,19 +1823,18 @@ PRBool nsTableFrame::BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresCon
else if (aMaxTableWidth <= aMaxWidth)
{ // the max width of the table fits comfortably in the available space
if (gsDebug) printf (" * table desired size fits, calling BalanceColumnsTableFits\n");
- result = BalanceColumnsTableFits(aPresContext, aTableStyleMol, aAvailWidth);
+ result = BalanceColumnsTableFits(aPresContext, aAvailWidth);
}
else
{ // the table fits somewhere between its min and desired size
if (gsDebug) printf (" * table desired size does not fit, calling BalanceColumnsHTML4Constrained\n");
- result = BalanceColumnsHTML4Constrained(aPresContext, aTableStyleMol, aAvailWidth,
+ result = BalanceColumnsHTML4Constrained(aPresContext, aAvailWidth,
aMaxWidth, aMinTableWidth, aMaxTableWidth);
}
return result;
}
PRBool nsTableFrame::BalanceProportionalColumnsForAutoWidthTable( nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -1744,7 +1845,7 @@ PRBool nsTableFrame::BalanceProportionalColumnsForAutoWidthTable( nsIPresContext
if (NS_UNCONSTRAINEDSIZE==aMaxWidth)
{ // the max width of the table fits comfortably in the available space
if (gsDebug) printf (" * table laying out in NS_UNCONSTRAINEDSIZE, calling BalanceColumnsTableFits\n");
- result = BalanceColumnsTableFits(aPresContext, aTableStyleMol, aAvailWidth);
+ result = BalanceColumnsTableFits(aPresContext, aAvailWidth);
}
else if (aMinTableWidth > aMaxWidth)
{ // the table doesn't fit in the available space
@@ -1754,12 +1855,12 @@ PRBool nsTableFrame::BalanceProportionalColumnsForAutoWidthTable( nsIPresContext
else if (aMaxTableWidth <= aMaxWidth)
{ // the max width of the table fits comfortably in the available space
if (gsDebug) printf (" * table desired size fits, calling BalanceColumnsTableFits\n");
- result = BalanceColumnsTableFits(aPresContext, aTableStyleMol, aAvailWidth);
+ result = BalanceColumnsTableFits(aPresContext, aAvailWidth);
}
else
{ // the table fits somewhere between its min and desired size
if (gsDebug) printf (" * table desired size does not fit, calling BalanceColumnsHTML4Constrained\n");
- result = BalanceColumnsHTML4Constrained(aPresContext, aTableStyleMol, aAvailWidth,
+ result = BalanceColumnsHTML4Constrained(aPresContext, aAvailWidth,
aMaxWidth, aMinTableWidth, aMaxTableWidth);
}
return result;
@@ -1774,14 +1875,16 @@ PRBool nsTableFrame::SetColumnsToMinWidth(nsIPresContext* aPresContext)
{
nsColLayoutData * colData = (nsColLayoutData *)(columnLayoutData->ElementAt(colIndex));
nsTableColPtr col = colData->GetCol(); // col: ADDREF++
- nsStyleMolecule* colStyle =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
nsVoidArray *cells = colData->GetCells();
PRInt32 minColWidth = 0;
PRInt32 maxColWidth = 0;
PRInt32 numCells = cells->Count();
if (gsDebug==PR_TRUE) printf (" for col %d\n", colIndex);
- if (PR_TRUE==IsProportionalWidth(colStyle))
+
+ // XXX need column frame to ask this question
+ nsStylePosition* colPosition = nsnull;
+
+ if (PR_TRUE==IsProportionalWidth(colPosition))
{
for (PRInt32 cellIndex = 0; cellIndexElementAt(colIndex));
nsTableColPtr col = colData->GetCol(); // col: ADDREF++
- nsStyleMolecule* colStyle =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
nsVoidArray *cells = colData->GetCells();
PRInt32 minColWidth = 0;
PRInt32 maxColWidth = 0;
@@ -1841,7 +1944,11 @@ PRBool nsTableFrame::BalanceColumnsTableFits(nsIPresContext* aPresContext,
/* TODO: must distribute COLSPAN'd cell widths between columns, either here
* or in the prior Balance***ColumnWidth routines
*/
- if (PR_TRUE==IsProportionalWidth(colStyle))
+
+ // XXX Need columnFrame to ask the style question
+ nsStylePosition* colPosition = nsnull;
+
+ if (PR_TRUE==IsProportionalWidth(colPosition))
{
for (PRInt32 cellIndex = 0; cellIndexproportionalWidth)
{ // col width is specified to be the minimum
mColumnWidths[colIndex] = minColWidth;
@@ -1875,7 +1986,9 @@ PRBool nsTableFrame::BalanceColumnsTableFits(nsIPresContext* aPresContext,
printf (" 3 (0): col %d set to min width = %d because style set proportionalWidth=0\n",
colIndex, mColumnWidths[colIndex]);
}
- if (PR_TRUE==AutoColumnWidths(aTableStyleMol))
+ else // BUG? else? other code below has the else
+#endif
+ if (PR_TRUE==AutoColumnWidths())
{ // give each remaining column it's desired width
// if there is width left over, we'll factor that in after this loop is complete
mColumnWidths[colIndex] = maxColWidth;
@@ -1892,8 +2005,10 @@ PRBool nsTableFrame::BalanceColumnsTableFits(nsIPresContext* aPresContext,
}
else
{
+#if XXX_bug_kipp_about_this
percentage = colStyle->proportionalWidth;
if (-1==percentage)
+#endif
percentage = 100/numCols;
mColumnWidths[colIndex] = (percentage*aAvailWidth)/100;
// if the column was computed to be too small, enlarge the column
@@ -1911,7 +2026,6 @@ PRBool nsTableFrame::BalanceColumnsTableFits(nsIPresContext* aPresContext,
}
PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -1927,14 +2041,22 @@ PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext
{
nsColLayoutData * colData = (nsColLayoutData *)(columnLayoutData->ElementAt(colIndex));
nsTableColPtr col = colData->GetCol(); // col: ADDREF++
+
+#if XXX_bug_kipp_about_this
+ // XXX BUG: mStyleContext is for the table frame not for the column.
nsStyleMolecule* colStyle =
(nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
+#else
+ nsStylePosition* colPosition = nsnull;
+#endif
+
nsVoidArray *cells = colData->GetCells();
PRInt32 minColWidth = 0;
PRInt32 maxColWidth = 0;
PRInt32 numCells = cells->Count();
if (gsDebug==PR_TRUE) printf (" for col %d\n", colIndex);
- if (PR_TRUE==IsProportionalWidth(colStyle))
+
+ if (PR_TRUE==IsProportionalWidth(colPosition))
{
for (PRInt32 cellIndex = 0; cellIndexproportionalWidth)
{ // col width is specified to be the minimum
mColumnWidths[colIndex] = minColWidth;
@@ -1973,7 +2099,9 @@ PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext
printf (" 4 (0): col %d set to min width = %d because style set proportionalWidth=0\n",
colIndex, mColumnWidths[colIndex]);
}
- else if (AutoColumnWidths(aTableStyleMol))
+ else
+#endif
+ if (AutoColumnWidths())
{
PRInt32 W = aMaxWidth - aMinTableWidth;
PRInt32 D = aMaxTableWidth - aMinTableWidth;
@@ -1985,9 +2113,11 @@ PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext
}
else
{ // give each remaining column an equal percentage of the remaining space
+#if XXX_bug_kipp_about_this
PRInt32 percentage = colStyle->proportionalWidth;
if (-1==percentage)
- percentage = 100/numCols;
+#endif
+ PRInt32 percentage = 100/numCols;
mColumnWidths[colIndex] = (percentage*aAvailWidth)/100;
// if the column was computed to be too small, enlarge the column
if (mColumnWidths[colIndex] <= minColWidth)
@@ -2012,7 +2142,7 @@ PRBool nsTableFrame::BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext
// if columns have equal width, and some column's content couldn't squeeze into the computed size,
// then expand every column to the min size of the column with the largest min size
- if (!AutoColumnWidths(aTableStyleMol) && 0!=maxOfAllMinColWidths)
+ if (!AutoColumnWidths() && 0!=maxOfAllMinColWidths)
{
if (gsDebug==PR_TRUE) printf(" EqualColWidths specified, so setting all col widths to %d\n", maxOfAllMinColWidths);
for (PRInt32 colIndex = 0; colIndexborderPadding.right;
- nscoord leftInset = aTableStyle->borderPadding.left;
+ nsStyleSpacing* spacing =
+ (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
+ nscoord rightInset = spacing->mBorderPadding.right;
+ nscoord leftInset = spacing->mBorderPadding.left;
tableWidth += (leftInset + rightInset);
nsRect tableSize = mRect;
tableSize.width = tableWidth;
@@ -2069,7 +2200,14 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
#endif
// iterate children, tell all row groups to ShrinkWrap
PRBool atLeastOneRowSpanningCell = PR_FALSE;
+
PRInt32 tableHeight = 0;
+
+ nsStyleSpacing* spacing = (nsStyleSpacing*)
+ mStyleContext->GetData(kStyleSpacingSID);
+ tableHeight +=
+ spacing->mBorderPadding.top + spacing->mBorderPadding.bottom;
+
PRInt32 childCount = mChildCount;
nsIFrame * kidFrame;
for (PRInt32 i = 0; i < childCount; i++)
@@ -2277,12 +2415,31 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
#endif
}
-PRBool nsTableFrame::IsProportionalWidth(nsStyleMolecule* aMol)
+// XXX Kipp wonders: what does this really mean? Are you really asking
+// "Is it fixed width"? If so, then VALUE_PCT may be wrong and the
+// name of the method should be changed.
+
+PRBool nsTableFrame::IsProportionalWidth(nsStylePosition* aStylePosition)
{
PRBool result = PR_FALSE;
- if ((-1!=aMol->proportionalWidth) ||
- ((-1==aMol->proportionalWidth) && (-1==aMol->fixedWidth)))
+ if (nsnull == aStylePosition) {
+ // Assume NS_STYLE_POSITION_VALUE_AUTO when no style is available
result = PR_TRUE;
+ }
+ else {
+ switch (aStylePosition->mWidthFlags) {
+ case NS_STYLE_POSITION_VALUE_LENGTH:
+ case NS_STYLE_POSITION_VALUE_PCT:
+ break;
+
+ default:
+ case NS_STYLE_POSITION_VALUE_AUTO:
+ case NS_STYLE_POSITION_VALUE_INHERIT:
+ case NS_STYLE_POSITION_VALUE_PROPORTIONAL:
+ result = PR_TRUE;
+ break;
+ }
+ }
return result;
}
@@ -2487,7 +2644,7 @@ PRBool nsTableFrame::TableIsAutoWidth()
return isTableAutoWidth;
}
-PRBool nsTableFrame::AutoColumnWidths(nsStyleMolecule* aTableStyleMol)
+PRBool nsTableFrame::AutoColumnWidths()
{ // ZZZ: TOTAL HACK
return isAutoColumnWidths;
}
@@ -2525,8 +2682,6 @@ NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
// Resolve style for the child
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(content, cf); // kidStyleContext: REFCNT++
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
nsIContentDelegate* kidDel = nsnull;
kidDel = content->GetDelegate(aPresContext); // kidDel: REFCNT++
nsIFrame * duplicateFrame = kidDel->CreateFrame(aPresContext, content, index, cf);
@@ -2577,6 +2732,12 @@ PRInt32 nsTableFrame::GetColumnWidth(PRInt32 aColIndex)
//printf("GET_COL_WIDTH: %p, FIF=%p getting col %d and returning %d\n", this, firstInFlow, aColIndex, result);
+ // XXX hack
+#if 0
+ if (result <= 0) {
+ result = 100;
+ }
+#endif
return result;
}
diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h
index 23ace38b50d..2683b86066c 100644
--- a/mozilla/layout/tables/nsTableFrame.h
+++ b/mozilla/layout/tables/nsTableFrame.h
@@ -26,8 +26,9 @@ class nsTableCell;
class nsVoidArray;
class nsTableCellFrame;
class CellData;
-struct nsStyleMolecule;
struct InnerTableReflowState;
+struct nsStylePosition;
+struct nsStyleSpacing;
/** nsTableFrame maps the inner portion of a table (everything except captions.)
* Used as a pseudo-frame within nsTableOuterFrame,
@@ -133,7 +134,7 @@ public:
/** returns PR_TRUE if this table has proportional width
*/
- PRBool IsProportionalWidth(nsStyleMolecule* aMol);
+ PRBool IsProportionalWidth(nsStylePosition* aStylePosition);
@@ -193,11 +194,10 @@ protected:
*
* @see ResizeReflow
*/
- virtual nsIFrame::ReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle);
+ virtual ReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsSize& aMaxSize,
+ nsSize* aMaxElementSize);
/** second pass of ResizeReflow.
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
@@ -210,17 +210,16 @@ protected:
* @see ResizeReflow
* @see NeedsReflow
*/
- virtual nsIFrame::ReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
- nsReflowMetrics& aDesiredSize,
- const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle,
- PRInt32 aMinCaptionWidth,
- PRInt32 mMaxCaptionWidth);
+ virtual ReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsSize& aMaxSize,
+ nsSize* aMaxElementSize,
+ PRInt32 aMinCaptionWidth,
+ PRInt32 mMaxCaptionWidth);
nscoord GetTopMarginFor(nsIPresContext* aCX,
InnerTableReflowState& aState,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild(nsIPresContext* aPresContext,
InnerTableReflowState& aState,
@@ -273,7 +272,6 @@ protected:
* @param aMaxElementSize the min size of the largest indivisible object
*/
virtual void BalanceColumnWidths(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyle,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
@@ -296,7 +294,6 @@ protected:
virtual PRBool AssignFixedColumnWidths(nsIPresContext* aPresContext,
PRInt32 aMaxWidth,
PRInt32 aNumCols,
- nsStyleMolecule* aTableStyleMol,
PRInt32 & aTotalFixedWidth,
PRInt32 & aMinTableWidth,
PRInt32 & aMaxTableWidth);
@@ -317,7 +314,6 @@ protected:
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -339,7 +335,6 @@ protected:
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceProportionalColumnsForAutoWidthTable(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
@@ -366,7 +361,6 @@ protected:
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*/
virtual PRBool BalanceColumnsTableFits(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth);
/** assign widths for each column that has proportional width inside a table that
@@ -386,15 +380,13 @@ protected:
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
PRInt32 aMaxWidth,
PRInt32 aMinTableWidth,
PRInt32 aMaxTableWidth);
/** sets the width of the table according to the computed widths of each column. */
- virtual void SetTableWidth(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyle);
+ virtual void SetTableWidth(nsIPresContext* aPresContext);
/**
*/
@@ -413,7 +405,7 @@ protected:
* according to its content.
* In NAV4, this is when there is a COLS attribute on the table.
*/
- virtual PRBool AutoColumnWidths(nsStyleMolecule* aTableStyleMol);
+ virtual PRBool AutoColumnWidths();
/** given the new parent size, do I really need to do a reflow? */
virtual PRBool NeedsReflow(const nsSize& aMaxSize);
diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp
index 704257e1516..60acd628377 100644
--- a/mozilla/layout/tables/nsTableOuterFrame.cpp
+++ b/mozilla/layout/tables/nsTableOuterFrame.cpp
@@ -43,7 +43,8 @@ static PRBool gsDebug = PR_FALSE;
static const PRBool gsDebug = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
static NS_DEFINE_IID(kITableContentIID, NS_ITABLECONTENT_IID);
NS_DEF_PTR(nsIStyleContext);
@@ -54,9 +55,6 @@ struct OuterTableReflowState {
// The presentation context
nsIPresContext *pc;
- // The body's style molecule
- nsStyleMolecule* mol;
-
// The total available size (computed from the parent)
nsSize availSize;
// The available size for the inner table frame
@@ -78,11 +76,9 @@ struct OuterTableReflowState {
PRBool processingCaption;
OuterTableReflowState(nsIPresContext* aPresContext,
- const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ const nsSize& aMaxSize)
{
pc = aPresContext;
- mol = aMol;
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
prevMaxPosBottomMargin = 0;
@@ -213,17 +209,14 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
aStatus = frComplete;
return NS_OK;
}
-
- nsStyleMolecule* tableStyleMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- OuterTableReflowState state(aPresContext, aMaxSize, tableStyleMol);
+ OuterTableReflowState state(aPresContext, aMaxSize);
// lay out captions pass 1, if necessary
if (PR_FALSE==IsFirstPassValid())
{
mFirstPassValid = PR_TRUE;
- aStatus = ResizeReflowCaptionsPass1(aPresContext, tableStyleMol);
+ aStatus = ResizeReflowCaptionsPass1(aPresContext);
}
@@ -232,7 +225,7 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
{ // we treat the table as if we've never seen the layout data before
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST);
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize, aMaxSize,
- &innerTableMaxElementSize, tableStyleMol);
+ &innerTableMaxElementSize);
#ifdef NOISY_MARGINS
nsIContentPtr content = mInnerTableFrame->GetContent();
@@ -252,9 +245,9 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
if (nsnull==prevInFlow)
{
// assign column widths, and assign aMaxElementSize->width
- mInnerTableFrame->BalanceColumnWidths(aPresContext, tableStyleMol, aMaxSize, aMaxElementSize);
+ mInnerTableFrame->BalanceColumnWidths(aPresContext, aMaxSize, aMaxElementSize);
// assign table width
- mInnerTableFrame->SetTableWidth(aPresContext, tableStyleMol);
+ mInnerTableFrame->SetTableWidth(aPresContext);
}
// inner table max is now the computed width and assigned height
nsSize innerTableSize;
@@ -350,12 +343,12 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
// Collapse child's top margin with previous bottom margin
nscoord nsTableOuterFrame::GetTopMarginFor(nsIPresContext* aCX,
OuterTableReflowState& aState,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
nscoord margin;
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -468,9 +461,10 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing =
+ (nsStyleSpacing*)kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
// Figure out the amount of available size for the child (subtract
// off the top margin we are going to apply to it)
@@ -479,7 +473,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
}
// Subtract off for left and right margin
if (PR_FALSE == aState.unconstrainedWidth) {
- aState.availSize.width -= kidMol->margin.left + kidMol->margin.right;
+ aState.availSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
// Only skip the reflow if this is not our first child and we are
@@ -509,7 +503,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
// Place the child after taking into account it's margin
aState.y += topMargin;
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
- kidRect.x += kidMol->margin.left;
+ kidRect.x += kidSpacing->mMargin.left;
kidRect.y += aState.y;
PlaceChild(aState, kidFrame, kidRect, aMaxElementSize, kidMaxElementSize);
if (bottomMargin < 0) {
@@ -894,29 +888,28 @@ nsTableOuterFrame::ReflowChild( nsIFrame* aKidFrame,
aKidFrame->GetStyleContext(aPresContext, captionStyleContext.AssignRef());
NS_ASSERTION(nsnull != captionStyleContext, "null style context for caption");
- nsStyleMolecule* captionStyle =
- (nsStyleMolecule*)captionStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleText* captionStyle =
+ (nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->verticalAlign)
+ if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign)
{
if (PR_TRUE==gsDebug) printf("reflowChild called with a bottom caption\n");
status = ResizeReflowBottomCaptionsPass2(aPresContext, aDesiredSize,
aMaxSize, aMaxElementSize,
- aState.mol, aState.y);
+ aState.y);
}
else
{
if (PR_TRUE==gsDebug) printf("reflowChild called with a top caption\n");
status = ResizeReflowTopCaptionsPass2(aPresContext, aDesiredSize,
- aMaxSize, aMaxElementSize,
- aState.mol);
+ aMaxSize, aMaxElementSize);
}
}
else
{
if (PR_TRUE==gsDebug) printf("reflowChild called with a table body\n");
- status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize, aState.availSize,
- aMaxElementSize, aState.mol,
+ status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize, aState.innerTableMaxSize,
+ aMaxElementSize,
mMinCaptionWidth, mMaxCaptionWidth);
}
if (PR_TRUE==gsDebug)
@@ -977,12 +970,12 @@ void nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext)
nsIStyleContextPtr captionStyleContext =
aPresContext->ResolveStyleContextFor(caption, this);
NS_ASSERTION(nsnull!=captionStyleContext, "bad style context for caption.");
- nsStyleMolecule* captionStyle =
- (nsStyleMolecule*)captionStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleText* captionStyle =
+ (nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
captionFrame->SetStyleContext(captionStyleContext);
mChildCount++;
// Link child frame into the list of children
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->verticalAlign)
+ if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign)
{ // bottom captions get added to the end of the outer frame child list
prevKidFrame->SetNextSibling(captionFrame);
prevKidFrame = captionFrame;
@@ -1018,7 +1011,7 @@ void nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext)
nsIFrame::ReflowStatus
-nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext, nsStyleMolecule* aTableStyle)
+nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext)
{
if (nsnull!=mCaptionFrames)
{
@@ -1046,8 +1039,7 @@ nsIFrame::ReflowStatus
nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle)
+ nsSize* aMaxElementSize)
{
ReflowStatus result = frComplete;
nscoord topCaptionY = 0;
@@ -1064,11 +1056,11 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
captionFrame->GetStyleContext(aPresContext, captionStyleContext.AssignRef());
NS_ASSERTION(nsnull != captionStyleContext, "null style context for caption");
- nsStyleMolecule* captionStyle =
- (nsStyleMolecule*)captionStyleContext->GetData(kStyleMoleculeSID);
+ nsStyleText* captionStyle =
+ (nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->verticalAlign)
+ if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign)
{
}
else
@@ -1113,7 +1105,6 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle,
nscoord aYOffset)
{
ReflowStatus result = frComplete;
diff --git a/mozilla/layout/tables/nsTableOuterFrame.h b/mozilla/layout/tables/nsTableOuterFrame.h
index 041f43c25fa..b53523daabc 100644
--- a/mozilla/layout/tables/nsTableOuterFrame.h
+++ b/mozilla/layout/tables/nsTableOuterFrame.h
@@ -23,9 +23,9 @@
class nsTableFrame;
class nsVoidArray;
-struct nsStyleMolecule;
class nsTableCaptionFrame;
struct OuterTableReflowState;
+struct nsStyleSpacing;
/**
* main frame for an nsTable content object,
@@ -137,8 +137,7 @@ protected:
/** reflow the captions in an infinite space, caching the min/max sizes for each
*/
- virtual ReflowStatus ResizeReflowCaptionsPass1(nsIPresContext* aPresContext,
- nsStyleMolecule* aTableStyle);
+ virtual ReflowStatus ResizeReflowCaptionsPass1(nsIPresContext* aPresContext);
/** reflow the top captions in a space constrained by the computed table width
* and the heigth given to us by our parent. Top captions are laid down
@@ -147,8 +146,7 @@ protected:
virtual ReflowStatus ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
- nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle);
+ nsSize* aMaxElementSize);
/** reflow the bottom captions in a space constrained by the computed table width
* and the heigth given to us by our parent. Bottom captions are laid down
@@ -158,12 +156,11 @@ protected:
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize,
- nsStyleMolecule* aTableStyle,
nscoord aYOffset);
nscoord GetTopMarginFor(nsIPresContext* aCX,
OuterTableReflowState& aState,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild( OuterTableReflowState& aState,
nsIFrame* aKidFrame,
diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp
index 318e92d5cbb..c433909404e 100644
--- a/mozilla/layout/tables/nsTableRowFrame.cpp
+++ b/mozilla/layout/tables/nsTableRowFrame.cpp
@@ -38,15 +38,11 @@ static const PRBool gsDebug1 = PR_FALSE;
static const PRBool gsDebug2 = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
/* ----------- RowReflowState ---------- */
struct RowReflowState {
-
- // The body's style molecule
- nsStyleMolecule* mol;
-
// The body's available size (computed from the body's parent)
nsSize availSize;
@@ -68,10 +64,8 @@ struct RowReflowState {
RowReflowState( nsIPresContext* aPresContext,
- const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ const nsSize& aMaxSize)
{
- mol = aMol;
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
prevMaxPosBottomMargin = 0;
@@ -175,12 +169,12 @@ PRInt32 nsTableRowFrame::GetTallestChild() const
// Collapse child's top margin with previous bottom margin
nscoord nsTableRowFrame::GetTopMarginFor( nsIPresContext* aCX,
RowReflowState& aState,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
nscoord margin;
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -284,9 +278,10 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// Get top margin for this kid
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
NS_RELEASE(kidSC);
// Figure out the amount of available size for the child (subtract
@@ -296,7 +291,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
}
// Subtract off for left and right margin
if (PR_FALSE == aState.unconstrainedWidth) {
- kidAvailSize.width -= kidMol->margin.left + kidMol->margin.right;
+ kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
@@ -315,7 +310,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
nscoord availWidth = 0;
for (PRInt32 numColSpan=0; numColSpanGetColumnWidth(cellStartingCol+numColSpan);
- NS_ASSERTION(0margin.left + kidMol->margin.right;
+ kidAvailSize.width += kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
// Get the next child
@@ -801,10 +796,10 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
// Resolve style
nsIStyleContext* kidStyleContext =
aPresContext->ResolveStyleContextFor(cell, this);
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidStyleContext->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
nsIFrame* kidFrame;
@@ -956,9 +951,7 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
// Check for an overflow list
MoveOverflowToChildList();
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- RowReflowState state(aPresContext, aMaxSize, myMol);
+ RowReflowState state(aPresContext, aMaxSize);
mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame));
// Reflow the existing frames
diff --git a/mozilla/layout/tables/nsTableRowFrame.h b/mozilla/layout/tables/nsTableRowFrame.h
index c10efc5ba8b..141ef6a9a6d 100644
--- a/mozilla/layout/tables/nsTableRowFrame.h
+++ b/mozilla/layout/tables/nsTableRowFrame.h
@@ -22,7 +22,7 @@
#include "nsContainerFrame.h"
struct RowReflowState;
-
+struct nsStyleSpacing;
/**
* nsTableRowFrame is the frame that maps table rows
@@ -121,7 +121,7 @@ protected:
nscoord GetTopMarginFor(nsIPresContext* aCX,
RowReflowState& aState,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild( nsIPresContext* aPresContext,
RowReflowState& aState,
diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp
index e43975e4609..411a05ed2a4 100644
--- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp
+++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp
@@ -37,7 +37,7 @@ static const PRBool gsDebug1 = PR_FALSE;
static const PRBool gsDebug2 = PR_FALSE;
#endif
-static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID);
+static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
NS_DEF_PTR(nsIStyleContext);
NS_DEF_PTR(nsIContent);
@@ -45,10 +45,6 @@ NS_DEF_PTR(nsIContent);
/* ----------- RowGroupReflowState ---------- */
struct RowGroupReflowState {
-
- // The body's style molecule
- nsStyleMolecule* mol;
-
// The body's available size (computed from the body's parent)
nsSize availSize;
@@ -70,10 +66,8 @@ struct RowGroupReflowState {
nscoord firstRowHeight;
RowGroupReflowState(nsIPresContext* aPresContext,
- const nsSize& aMaxSize,
- nsStyleMolecule* aMol)
+ const nsSize& aMaxSize)
{
- mol = aMol;
availSize.width = aMaxSize.width;
availSize.height = aMaxSize.height;
prevMaxPosBottomMargin = 0;
@@ -170,12 +164,12 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
// Collapse child's top margin with previous bottom margin
nscoord nsTableRowGroupFrame::GetTopMarginFor(nsIPresContext* aCX,
RowGroupReflowState& aState,
- nsStyleMolecule* aKidMol)
+ nsStyleSpacing* aKidSpacing)
{
nscoord margin;
nscoord maxNegTopMargin = 0;
nscoord maxPosTopMargin = 0;
- if ((margin = aKidMol->margin.top) < 0) {
+ if ((margin = aKidSpacing->mMargin.top) < 0) {
maxNegTopMargin = -margin;
} else {
maxPosTopMargin = margin;
@@ -286,9 +280,10 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
nsIStyleContextPtr kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
- nsStyleMolecule* kidMol = (nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
// Figure out the amount of available size for the child (subtract
// off the top margin we are going to apply to it)
@@ -297,7 +292,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
}
// Subtract off for left and right margin
if (PR_FALSE == aState.unconstrainedWidth) {
- kidAvailSize.width -= kidMol->margin.left + kidMol->margin.right;
+ kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
// Reflow the child into the available space
@@ -330,7 +325,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
// Place the child after taking into account it's margin
aState.y += topMargin;
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
- kidRect.x += kidMol->margin.left;
+ kidRect.x += kidSpacing->mMargin.left;
kidRect.y += aState.y;
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize,
kidMaxElementSize);
@@ -396,7 +391,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
// Add back in the left and right margins, because one row does not
// impact another row's width
if (PR_FALSE == aState.unconstrainedWidth) {
- kidAvailSize.width += kidMol->margin.left + kidMol->margin.right;
+ kidAvailSize.width += kidSpacing->mMargin.left + kidSpacing->mMargin.right;
}
// Get the next child
@@ -731,12 +726,12 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
}
// Resolve style
- nsIStyleContextPtr kidStyleContext =
+ nsIStyleContextPtr kidSC =
aPresContext->ResolveStyleContextFor(kid, this);
- nsStyleMolecule* kidMol =
- (nsStyleMolecule*)kidStyleContext->GetData(kStyleMoleculeSID);
- nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMol);
- nscoord bottomMargin = kidMol->margin.bottom;
+ nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
+ kidSC->GetData(kStyleSpacingSID);
+ nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
+ nscoord bottomMargin = kidSpacing->mMargin.bottom;
nsIFrame* kidFrame;
@@ -746,7 +741,7 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
kidDel = kid->GetDelegate(aPresContext);
kidFrame = kidDel->CreateFrame(aPresContext, kid, kidIndex, this);
NS_RELEASE(kidDel);
- kidFrame->SetStyleContext(kidStyleContext);
+ kidFrame->SetStyleContext(kidSC);
} else {
kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame);
}
@@ -840,9 +835,7 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
// Check for an overflow list
MoveOverflowToChildList();
- nsStyleMolecule* myMol =
- (nsStyleMolecule*)mStyleContext->GetData(kStyleMoleculeSID);
- RowGroupReflowState state(aPresContext, aMaxSize, myMol);
+ RowGroupReflowState state(aPresContext, aMaxSize);
// Reflow the existing frames
if (nsnull != mFirstChild) {
diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.h b/mozilla/layout/tables/nsTableRowGroupFrame.h
index 45d26b1dccb..c341db18a06 100644
--- a/mozilla/layout/tables/nsTableRowGroupFrame.h
+++ b/mozilla/layout/tables/nsTableRowGroupFrame.h
@@ -23,7 +23,7 @@
#include "nsIAtom.h"
struct RowGroupReflowState;
-struct nsStyleMolecule;
+struct nsStyleSpacing;
/**
* nsTableRowGroupFrame is the frame that maps row groups
@@ -114,7 +114,7 @@ protected:
nscoord GetTopMarginFor(nsIPresContext* aCX,
RowGroupReflowState& aState,
- nsStyleMolecule* aKidMol);
+ nsStyleSpacing* aKidSpacing);
void PlaceChild( nsIPresContext* aPresContext,
RowGroupReflowState& aState,