diff --git a/mozilla/content/html/style/src/nsCSSLayout.cpp b/mozilla/content/html/style/src/nsCSSLayout.cpp
index 59bb9ba101e..e9e1fe42219 100644
--- a/mozilla/content/html/style/src/nsCSSLayout.cpp
+++ b/mozilla/content/html/style/src/nsCSSLayout.cpp
@@ -65,59 +65,75 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
kid->GetStyleContext(aCX, kidSC.AssignRef());
kid->GetContent(kidContent.AssignRef());
nsStyleText* textStyle = (nsStyleText*)kidSC->GetData(kStyleTextSID);
- PRUint8 verticalAlignFlags = textStyle->mVerticalAlignFlags;
+ nsStyleUnit verticalAlignUnit = textStyle->mVerticalAlign.GetUnit();
+ PRUint8 verticalAlignEnum = NS_STYLE_VERTICAL_ALIGN_BASELINE;
kid->GetRect(kidRect);
// Vertically align the child
nscoord kidYTop = 0;
- switch (verticalAlignFlags) {
- default:
- case NS_STYLE_VERTICAL_ALIGN_BASELINE:
- // Align the kid's baseline at the max baseline
- kidYTop = aMaxAscent - kidAscent;
- break;
- case NS_STYLE_VERTICAL_ALIGN_TOP:
- // Align the top of the kid with the top of the line box
- break;
+ switch (verticalAlignUnit) {
+ case eStyleUnit_Twips:
+ kidYTop = aMaxAscent + textStyle->mVerticalAlign.GetCoordValue();
+ break;
- case NS_STYLE_VERTICAL_ALIGN_SUB:
- // Move baseline by 1/2 the ascent of the child.
- // NOTE: CSSx doesn't seem to specify what subscripting does
- // so we are using ebina's logic
- kidYTop = aMaxAscent + (kidAscent/2) - kidAscent;
- break;
+ case eStyleUnit_Percent:
+ pass2Kids++;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_SUPER:
- // Move baseline by 1/2 the ascent of the child
- // NOTE: CSSx doesn't seem to specify what superscripting does
- // so we are using ebina's logic
- kidYTop = aMaxAscent - (kidAscent/2) - kidAscent;
- break;
+ case eStyleUnit_Enumerated:
+ verticalAlignEnum = textStyle->mVerticalAlign.GetIntValue();
+ switch (verticalAlignEnum) {
+ default:
+ case NS_STYLE_VERTICAL_ALIGN_BASELINE:
+ // Align the kid's baseline at the max baseline
+ kidYTop = aMaxAscent - kidAscent;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
- case NS_STYLE_VERTICAL_ALIGN_PERCENT:
- pass2Kids++;
- break;
+ case NS_STYLE_VERTICAL_ALIGN_TOP:
+ // Align the top of the kid with the top of the line box
+ break;
- case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
- // XXX spec says use the 'x' height but our font api doesn't give us
- // that information.
- kidYTop = aMaxAscent - (fm->GetHeight() / 2) - kidRect.height/2;
- break;
+ case NS_STYLE_VERTICAL_ALIGN_SUB:
+ // Move baseline by 1/2 the ascent of the child.
+ // NOTE: CSSx doesn't seem to specify what subscripting does
+ // so we are using ebina's logic
+ kidYTop = aMaxAscent + (kidAscent/2) - kidAscent;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM:
- kidYTop = aMaxAscent + fm->GetMaxDescent() - kidRect.height;
- break;
+ case NS_STYLE_VERTICAL_ALIGN_SUPER:
+ // Move baseline by 1/2 the ascent of the child
+ // NOTE: CSSx doesn't seem to specify what superscripting does
+ // so we are using ebina's logic
+ kidYTop = aMaxAscent - (kidAscent/2) - kidAscent;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_TEXT_TOP:
- kidYTop = aMaxAscent - fm->GetMaxAscent();
- break;
+ case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
+ pass2Kids++;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_LENGTH:
- kidYTop = aMaxAscent + textStyle->mVerticalAlign.coord;
- break;
+ case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
+ // XXX spec says use the 'x' height but our font api doesn't give us
+ // that information.
+ kidYTop = aMaxAscent - (fm->GetHeight() / 2) - kidRect.height/2;
+ break;
+
+ case NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM:
+ kidYTop = aMaxAscent + fm->GetMaxDescent() - kidRect.height;
+ break;
+
+ case NS_STYLE_VERTICAL_ALIGN_TEXT_TOP:
+ kidYTop = aMaxAscent - fm->GetMaxAscent();
+ break;
+
+ }
+ break;
+
+ default:
+ // Align the kid's baseline at the max baseline
+ kidYTop = aMaxAscent - kidAscent;
+ break;
}
// Place kid and update min and max Y values
@@ -144,21 +160,11 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
kid->GetStyleContext(aCX, kidSC.AssignRef());
kid->GetContent(kidContent.AssignRef());
nsStyleText* textStyle = (nsStyleText*)kidSC->GetData(kStyleTextSID);
- PRUint8 verticalAlignFlags = textStyle->mVerticalAlignFlags;
+ nsStyleUnit verticalAlignUnit = textStyle->mVerticalAlign.GetUnit();
- // Vertically align the child
- if (verticalAlignFlags == NS_STYLE_VERTICAL_ALIGN_BOTTOM) {
- // Place kid along the bottom
- kid->GetRect(kidRect);
- kid->MoveTo(kidRect.x, aY0 + lineHeight - kidRect.height);
- if (--pass2Kids == 0) {
- // Stop on last pass2 kid
- break;
- }
- }
- else if (verticalAlignFlags == NS_STYLE_VERTICAL_ALIGN_PERCENT) {
+ if (eStyleUnit_Percent == verticalAlignUnit) {
nscoord kidYTop = aMaxAscent +
- nscoord(textStyle->mVerticalAlign.percent * lineHeight);
+ nscoord(textStyle->mVerticalAlign.GetFloatValue() * lineHeight);
kid->GetRect(kidRect);
kid->MoveTo(kidRect.x, aY0 + kidYTop);
if (--pass2Kids == 0) {
@@ -166,6 +172,19 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
break;
}
}
+ else if (verticalAlignUnit == eStyleUnit_Enumerated) {
+ PRUint8 verticalAlignEnum = textStyle->mVerticalAlign.GetIntValue();
+ // Vertically align the child
+ if (NS_STYLE_VERTICAL_ALIGN_BOTTOM == verticalAlignEnum) {
+ // Place kid along the bottom
+ kid->GetRect(kidRect);
+ kid->MoveTo(kidRect.x, aY0 + lineHeight - kidRect.height);
+ if (--pass2Kids == 0) {
+ // Stop on last pass2 kid
+ break;
+ }
+ }
+ }
kid->GetNextSibling(kid);
}
diff --git a/mozilla/layout/html/base/src/nsHTMLImage.cpp b/mozilla/layout/html/base/src/nsHTMLImage.cpp
index bf72e4c9840..50d1aca142d 100644
--- a/mozilla/layout/html/base/src/nsHTMLImage.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLImage.cpp
@@ -565,7 +565,7 @@ void ImagePart::MapAttributesInto(nsIStyleContext* aContext,
display->mFloats = NS_STYLE_FLOAT_RIGHT;
break;
default:
- text->mVerticalAlignFlags = mAlign;
+ text->mVerticalAlign.Set(mAlign, eStyleUnit_Enumerated);
break;
}
}
diff --git a/mozilla/layout/html/style/src/nsCSSLayout.cpp b/mozilla/layout/html/style/src/nsCSSLayout.cpp
index 59bb9ba101e..e9e1fe42219 100644
--- a/mozilla/layout/html/style/src/nsCSSLayout.cpp
+++ b/mozilla/layout/html/style/src/nsCSSLayout.cpp
@@ -65,59 +65,75 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
kid->GetStyleContext(aCX, kidSC.AssignRef());
kid->GetContent(kidContent.AssignRef());
nsStyleText* textStyle = (nsStyleText*)kidSC->GetData(kStyleTextSID);
- PRUint8 verticalAlignFlags = textStyle->mVerticalAlignFlags;
+ nsStyleUnit verticalAlignUnit = textStyle->mVerticalAlign.GetUnit();
+ PRUint8 verticalAlignEnum = NS_STYLE_VERTICAL_ALIGN_BASELINE;
kid->GetRect(kidRect);
// Vertically align the child
nscoord kidYTop = 0;
- switch (verticalAlignFlags) {
- default:
- case NS_STYLE_VERTICAL_ALIGN_BASELINE:
- // Align the kid's baseline at the max baseline
- kidYTop = aMaxAscent - kidAscent;
- break;
- case NS_STYLE_VERTICAL_ALIGN_TOP:
- // Align the top of the kid with the top of the line box
- break;
+ switch (verticalAlignUnit) {
+ case eStyleUnit_Twips:
+ kidYTop = aMaxAscent + textStyle->mVerticalAlign.GetCoordValue();
+ break;
- case NS_STYLE_VERTICAL_ALIGN_SUB:
- // Move baseline by 1/2 the ascent of the child.
- // NOTE: CSSx doesn't seem to specify what subscripting does
- // so we are using ebina's logic
- kidYTop = aMaxAscent + (kidAscent/2) - kidAscent;
- break;
+ case eStyleUnit_Percent:
+ pass2Kids++;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_SUPER:
- // Move baseline by 1/2 the ascent of the child
- // NOTE: CSSx doesn't seem to specify what superscripting does
- // so we are using ebina's logic
- kidYTop = aMaxAscent - (kidAscent/2) - kidAscent;
- break;
+ case eStyleUnit_Enumerated:
+ verticalAlignEnum = textStyle->mVerticalAlign.GetIntValue();
+ switch (verticalAlignEnum) {
+ default:
+ case NS_STYLE_VERTICAL_ALIGN_BASELINE:
+ // Align the kid's baseline at the max baseline
+ kidYTop = aMaxAscent - kidAscent;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
- case NS_STYLE_VERTICAL_ALIGN_PERCENT:
- pass2Kids++;
- break;
+ case NS_STYLE_VERTICAL_ALIGN_TOP:
+ // Align the top of the kid with the top of the line box
+ break;
- case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
- // XXX spec says use the 'x' height but our font api doesn't give us
- // that information.
- kidYTop = aMaxAscent - (fm->GetHeight() / 2) - kidRect.height/2;
- break;
+ case NS_STYLE_VERTICAL_ALIGN_SUB:
+ // Move baseline by 1/2 the ascent of the child.
+ // NOTE: CSSx doesn't seem to specify what subscripting does
+ // so we are using ebina's logic
+ kidYTop = aMaxAscent + (kidAscent/2) - kidAscent;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM:
- kidYTop = aMaxAscent + fm->GetMaxDescent() - kidRect.height;
- break;
+ case NS_STYLE_VERTICAL_ALIGN_SUPER:
+ // Move baseline by 1/2 the ascent of the child
+ // NOTE: CSSx doesn't seem to specify what superscripting does
+ // so we are using ebina's logic
+ kidYTop = aMaxAscent - (kidAscent/2) - kidAscent;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_TEXT_TOP:
- kidYTop = aMaxAscent - fm->GetMaxAscent();
- break;
+ case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
+ pass2Kids++;
+ break;
- case NS_STYLE_VERTICAL_ALIGN_LENGTH:
- kidYTop = aMaxAscent + textStyle->mVerticalAlign.coord;
- break;
+ case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
+ // XXX spec says use the 'x' height but our font api doesn't give us
+ // that information.
+ kidYTop = aMaxAscent - (fm->GetHeight() / 2) - kidRect.height/2;
+ break;
+
+ case NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM:
+ kidYTop = aMaxAscent + fm->GetMaxDescent() - kidRect.height;
+ break;
+
+ case NS_STYLE_VERTICAL_ALIGN_TEXT_TOP:
+ kidYTop = aMaxAscent - fm->GetMaxAscent();
+ break;
+
+ }
+ break;
+
+ default:
+ // Align the kid's baseline at the max baseline
+ kidYTop = aMaxAscent - kidAscent;
+ break;
}
// Place kid and update min and max Y values
@@ -144,21 +160,11 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
kid->GetStyleContext(aCX, kidSC.AssignRef());
kid->GetContent(kidContent.AssignRef());
nsStyleText* textStyle = (nsStyleText*)kidSC->GetData(kStyleTextSID);
- PRUint8 verticalAlignFlags = textStyle->mVerticalAlignFlags;
+ nsStyleUnit verticalAlignUnit = textStyle->mVerticalAlign.GetUnit();
- // Vertically align the child
- if (verticalAlignFlags == NS_STYLE_VERTICAL_ALIGN_BOTTOM) {
- // Place kid along the bottom
- kid->GetRect(kidRect);
- kid->MoveTo(kidRect.x, aY0 + lineHeight - kidRect.height);
- if (--pass2Kids == 0) {
- // Stop on last pass2 kid
- break;
- }
- }
- else if (verticalAlignFlags == NS_STYLE_VERTICAL_ALIGN_PERCENT) {
+ if (eStyleUnit_Percent == verticalAlignUnit) {
nscoord kidYTop = aMaxAscent +
- nscoord(textStyle->mVerticalAlign.percent * lineHeight);
+ nscoord(textStyle->mVerticalAlign.GetFloatValue() * lineHeight);
kid->GetRect(kidRect);
kid->MoveTo(kidRect.x, aY0 + kidYTop);
if (--pass2Kids == 0) {
@@ -166,6 +172,19 @@ nscoord nsCSSLayout::VerticallyAlignChildren(nsIPresContext* aCX,
break;
}
}
+ else if (verticalAlignUnit == eStyleUnit_Enumerated) {
+ PRUint8 verticalAlignEnum = textStyle->mVerticalAlign.GetIntValue();
+ // Vertically align the child
+ if (NS_STYLE_VERTICAL_ALIGN_BOTTOM == verticalAlignEnum) {
+ // Place kid along the bottom
+ kid->GetRect(kidRect);
+ kid->MoveTo(kidRect.x, aY0 + lineHeight - kidRect.height);
+ if (--pass2Kids == 0) {
+ // Stop on last pass2 kid
+ break;
+ }
+ }
+ }
kid->GetNextSibling(kid);
}
diff --git a/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp b/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp
index 3b49ca32fc1..0a2abc5e839 100644
--- a/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp
@@ -137,7 +137,11 @@ void nsTableCaptionFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
nscoord topInset = spacing->mBorderPadding.top;
nscoord bottomInset = spacing->mBorderPadding.bottom;
- PRUint8 verticalAlignFlags = textStyle->mVerticalAlignFlags;
+ PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
+
+ if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
+ verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
+ }
nscoord height = mRect.height;
diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp
index 1caff0b138e..4d90bd1475f 100644
--- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp
@@ -95,7 +95,11 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
nscoord topInset = spacing->mBorderPadding.top;
nscoord bottomInset = spacing->mBorderPadding.bottom;
- PRUint8 verticalAlignFlags = textStyle->mVerticalAlignFlags;
+ PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
+ if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
+ verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
+ }
+
nscoord height = mRect.height;
nsRect kidRect;
diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp
index 41c4a876cf9..ce00afbce76 100644
--- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp
@@ -892,7 +892,8 @@ nsTableOuterFrame::ReflowChild( nsIFrame* aKidFrame,
nsStyleText* captionStyle =
(nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlignFlags)
+ if ((eStyleUnit_Enumerated == captionStyle->mVerticalAlign.GetUnit()) &&
+ (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign.GetIntValue()))
{
if (PR_TRUE==gsDebug) printf("reflowChild called with a bottom caption\n");
status = ResizeReflowBottomCaptionsPass2(aPresContext, aDesiredSize,
@@ -976,7 +977,8 @@ void nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext)
captionFrame->SetStyleContext(captionStyleContext);
mChildCount++;
// Link child frame into the list of children
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlignFlags)
+ if ((eStyleUnit_Enumerated == captionStyle->mVerticalAlign.GetUnit()) &&
+ (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign.GetIntValue()))
{ // bottom captions get added to the end of the outer frame child list
prevKidFrame->SetNextSibling(captionFrame);
prevKidFrame = captionFrame;
@@ -1061,7 +1063,8 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
(nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlignFlags)
+ if ((eStyleUnit_Enumerated == captionStyle->mVerticalAlign.GetUnit()) &&
+ (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign.GetIntValue()))
{
}
else
diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp
index 1caff0b138e..4d90bd1475f 100644
--- a/mozilla/layout/tables/nsTableCellFrame.cpp
+++ b/mozilla/layout/tables/nsTableCellFrame.cpp
@@ -95,7 +95,11 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
nscoord topInset = spacing->mBorderPadding.top;
nscoord bottomInset = spacing->mBorderPadding.bottom;
- PRUint8 verticalAlignFlags = textStyle->mVerticalAlignFlags;
+ PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
+ if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
+ verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
+ }
+
nscoord height = mRect.height;
nsRect kidRect;
diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp
index 41c4a876cf9..ce00afbce76 100644
--- a/mozilla/layout/tables/nsTableOuterFrame.cpp
+++ b/mozilla/layout/tables/nsTableOuterFrame.cpp
@@ -892,7 +892,8 @@ nsTableOuterFrame::ReflowChild( nsIFrame* aKidFrame,
nsStyleText* captionStyle =
(nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlignFlags)
+ if ((eStyleUnit_Enumerated == captionStyle->mVerticalAlign.GetUnit()) &&
+ (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign.GetIntValue()))
{
if (PR_TRUE==gsDebug) printf("reflowChild called with a bottom caption\n");
status = ResizeReflowBottomCaptionsPass2(aPresContext, aDesiredSize,
@@ -976,7 +977,8 @@ void nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext)
captionFrame->SetStyleContext(captionStyleContext);
mChildCount++;
// Link child frame into the list of children
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlignFlags)
+ if ((eStyleUnit_Enumerated == captionStyle->mVerticalAlign.GetUnit()) &&
+ (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign.GetIntValue()))
{ // bottom captions get added to the end of the outer frame child list
prevKidFrame->SetNextSibling(captionFrame);
prevKidFrame = captionFrame;
@@ -1061,7 +1063,8 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresContext,
(nsStyleText*)captionStyleContext->GetData(kStyleTextSID);
NS_ASSERTION(nsnull != captionStyle, "null style molecule for caption");
- if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlignFlags)
+ if ((eStyleUnit_Enumerated == captionStyle->mVerticalAlign.GetUnit()) &&
+ (NS_STYLE_VERTICAL_ALIGN_BOTTOM==captionStyle->mVerticalAlign.GetIntValue()))
{
}
else