#43457 split nsStyleSpacing into 4 smaller structures: nsStyleBorder, nsStylePadding, nsStyleMargin, nsStyleOutline. Review=attinasi. Pending Approval: buster.

This commit is contained in:
pierre%netscape.com 2001-01-20 22:46:54 +00:00
Родитель e2bc4b330b
Коммит 531ba68b54
117 изменённых файлов: 4364 добавлений и 2949 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -715,28 +715,28 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
}
// For the origin, add in the border for the frame
const nsStyleSpacing* spacing;
const nsStyleBorder* border;
nsStyleCoord coord;
frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing) {
if (eStyleUnit_Coord == spacing->mBorder.GetLeftUnit()) {
origin.x += spacing->mBorder.GetLeft(coord).GetCoordValue();
frame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border);
if (border) {
if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) {
origin.x += border->mBorder.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetTopUnit()) {
origin.y += spacing->mBorder.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) {
origin.y += border->mBorder.GetTop(coord).GetCoordValue();
}
}
// And subtract out the border for the parent
if (parent) {
const nsStyleSpacing* parentSpacing;
parent->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)parentSpacing);
if (parentSpacing) {
if (eStyleUnit_Coord == parentSpacing->mBorder.GetLeftUnit()) {
origin.x -= parentSpacing->mBorder.GetLeft(coord).GetCoordValue();
const nsStyleBorder* parentBorder;
parent->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)parentBorder);
if (parentBorder) {
if (eStyleUnit_Coord == parentBorder->mBorder.GetLeftUnit()) {
origin.x -= parentBorder->mBorder.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == parentSpacing->mBorder.GetTopUnit()) {
origin.y -= parentSpacing->mBorder.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == parentBorder->mBorder.GetTopUnit()) {
origin.y -= parentBorder->mBorder.GetTop(coord).GetCoordValue();
}
}
}
@ -2911,8 +2911,8 @@ nsGenericHTMLElement::MapImageAttributesInto(const nsIHTMLMappedAttributes* aAtt
aPresContext->GetScaledPixelsToTwips(&p2t);
nsStylePosition* pos = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)
aContext->GetMutableStyleData(eStyleStruct_Margin);
// width: value
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
@ -2939,13 +2939,13 @@ nsGenericHTMLElement::MapImageAttributesInto(const nsIHTMLMappedAttributes* aAtt
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
nsStyleCoord c(twips);
spacing->mMargin.SetLeft(c);
spacing->mMargin.SetRight(c);
margin->mMargin.SetLeft(c);
margin->mMargin.SetRight(c);
}
else if (value.GetUnit() == eHTMLUnit_Percent) {
nsStyleCoord c(value.GetPercentValue(), eStyleUnit_Percent);
spacing->mMargin.SetLeft(c);
spacing->mMargin.SetRight(c);
margin->mMargin.SetLeft(c);
margin->mMargin.SetRight(c);
}
// vspace: value
@ -2953,13 +2953,13 @@ nsGenericHTMLElement::MapImageAttributesInto(const nsIHTMLMappedAttributes* aAtt
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
nsStyleCoord c(twips);
spacing->mMargin.SetTop(c);
spacing->mMargin.SetBottom(c);
margin->mMargin.SetTop(c);
margin->mMargin.SetBottom(c);
}
else if (value.GetUnit() == eHTMLUnit_Percent) {
nsStyleCoord c(value.GetPercentValue(), eStyleUnit_Percent);
spacing->mMargin.SetTop(c);
spacing->mMargin.SetBottom(c);
margin->mMargin.SetTop(c);
margin->mMargin.SetBottom(c);
}
}
@ -2990,21 +2990,21 @@ nsGenericHTMLElement::MapImageAlignAttributeInto(const nsIHTMLMappedAttributes*
aContext->GetMutableStyleData(eStyleStruct_Display);
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)
aContext->GetMutableStyleData(eStyleStruct_Margin);
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nsStyleCoord three(NSIntPixelsToTwips(3, p2t));
switch (align) {
case NS_STYLE_TEXT_ALIGN_LEFT:
display->mFloats = NS_STYLE_FLOAT_LEFT;
spacing->mMargin.SetLeft(three);
spacing->mMargin.SetRight(three);
margin->mMargin.SetLeft(three);
margin->mMargin.SetRight(three);
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
display->mFloats = NS_STYLE_FLOAT_RIGHT;
spacing->mMargin.SetLeft(three);
spacing->mMargin.SetRight(three);
margin->mMargin.SetLeft(three);
margin->mMargin.SetRight(three);
break;
default:
text->mVerticalAlign.SetIntValue(align, eStyleUnit_Enumerated);
@ -3053,38 +3053,39 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsIHTMLMappedAttributes*
// Fixup border-padding sums: subtract out the old size and then
// add in the new size.
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleCoord coord;
coord.SetCoordValue(twips);
spacing->mBorder.SetTop(coord);
spacing->mBorder.SetRight(coord);
spacing->mBorder.SetBottom(coord);
spacing->mBorder.SetLeft(coord);
border->mBorder.SetTop(coord);
border->mBorder.SetRight(coord);
border->mBorder.SetBottom(coord);
border->mBorder.SetLeft(coord);
spacing->SetBorderStyle(0,NS_STYLE_BORDER_STYLE_SOLID);
spacing->SetBorderStyle(1,NS_STYLE_BORDER_STYLE_SOLID);
spacing->SetBorderStyle(2,NS_STYLE_BORDER_STYLE_SOLID);
spacing->SetBorderStyle(3,NS_STYLE_BORDER_STYLE_SOLID);
border->SetBorderStyle(0,NS_STYLE_BORDER_STYLE_SOLID);
border->SetBorderStyle(1,NS_STYLE_BORDER_STYLE_SOLID);
border->SetBorderStyle(2,NS_STYLE_BORDER_STYLE_SOLID);
border->SetBorderStyle(3,NS_STYLE_BORDER_STYLE_SOLID);
// Use supplied colors if provided, otherwise use color for border
// color
if (nsnull != aBorderColors) {
spacing->SetBorderColor(0, aBorderColors[0]);
spacing->SetBorderColor(1, aBorderColors[1]);
spacing->SetBorderColor(2, aBorderColors[2]);
spacing->SetBorderColor(3, aBorderColors[3]);
border->SetBorderColor(0, aBorderColors[0]);
border->SetBorderColor(1, aBorderColors[1]);
border->SetBorderColor(2, aBorderColors[2]);
border->SetBorderColor(3, aBorderColors[3]);
}
else {
// Color is inherited from "color"
const nsStyleColor* styleColor = (const nsStyleColor*)
aContext->GetStyleData(eStyleStruct_Color);
nscolor color = styleColor->mColor;
spacing->SetBorderColor(0, color);
spacing->SetBorderColor(1, color);
spacing->SetBorderColor(2, color);
spacing->SetBorderColor(3, color);
border->SetBorderColor(0, color);
border->SetBorderColor(1, color);
border->SetBorderColor(2, color);
border->SetBorderColor(3, color);
}
}

Просмотреть файл

@ -293,9 +293,9 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext,
nsIPresContext* aPresContext)
{
if (mPart) {
nsStyleSpacing* styleSpacing = (nsStyleSpacing*)(aContext->GetMutableStyleData(eStyleStruct_Spacing));
nsStyleMargin* marginStyle = (nsStyleMargin*)(aContext->GetMutableStyleData(eStyleStruct_Margin));
if (nsnull != styleSpacing) {
if (nsnull != marginStyle) {
nsHTMLValue value;
PRInt32 attrCount;
float p2t;
@ -313,8 +313,8 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext,
bodyMarginWidth = 0;
}
nsStyleCoord widthCoord(bodyMarginWidth);
styleSpacing->mMargin.SetLeft(widthCoord);
styleSpacing->mMargin.SetRight(widthCoord);
marginStyle->mMargin.SetLeft(widthCoord);
marginStyle->mMargin.SetRight(widthCoord);
}
mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
@ -325,8 +325,8 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext,
}
nsStyleCoord heightCoord(bodyMarginHeight);
styleSpacing->mMargin.SetTop(heightCoord);
styleSpacing->mMargin.SetBottom(heightCoord);
marginStyle->mMargin.SetTop(heightCoord);
marginStyle->mMargin.SetBottom(heightCoord);
}
}
@ -363,14 +363,14 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext,
if ((0 > bodyMarginWidth) && (frameMarginWidth >= 0)) {
nsStyleCoord widthCoord(frameMarginWidth);
styleSpacing->mMargin.SetLeft(widthCoord);
styleSpacing->mMargin.SetRight(widthCoord);
marginStyle->mMargin.SetLeft(widthCoord);
marginStyle->mMargin.SetRight(widthCoord);
}
if ((0 > bodyMarginHeight) && (frameMarginHeight >= 0)) {
nsStyleCoord heightCoord(frameMarginHeight);
styleSpacing->mMargin.SetTop(heightCoord);
styleSpacing->mMargin.SetBottom(heightCoord);
marginStyle->mMargin.SetTop(heightCoord);
marginStyle->mMargin.SetBottom(heightCoord);
}
}
NS_RELEASE(container);

Просмотреть файл

@ -207,22 +207,22 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (eHTMLUnit_Enumerated == value.GetUnit()) {
// Map align attribute into auto side margins
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)
aContext->GetMutableStyleData(eStyleStruct_Margin);
nsStyleCoord otto(eStyleUnit_Auto);
nsStyleCoord zero(nscoord(0));
switch (value.GetIntValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
spacing->mMargin.SetLeft(zero);
spacing->mMargin.SetRight(otto);
margin->mMargin.SetLeft(zero);
margin->mMargin.SetRight(otto);
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
spacing->mMargin.SetLeft(otto);
spacing->mMargin.SetRight(zero);
margin->mMargin.SetLeft(otto);
margin->mMargin.SetRight(zero);
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
spacing->mMargin.SetLeft(otto);
spacing->mMargin.SetRight(otto);
margin->mMargin.SetLeft(otto);
margin->mMargin.SetRight(otto);
break;
}
}

Просмотреть файл

@ -314,15 +314,15 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if (NS_STYLE_FRAME_0 == frameborder ||
NS_STYLE_FRAME_NO == frameborder ||
NS_STYLE_FRAME_OFF == frameborder) {
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
if (spacing) {
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
if (border) {
nsStyleCoord coord;
coord.SetCoordValue(0);
spacing->mBorder.SetTop(coord);
spacing->mBorder.SetRight(coord);
spacing->mBorder.SetBottom(coord);
spacing->mBorder.SetLeft(coord);
border->mBorder.SetTop(coord);
border->mBorder.SetRight(coord);
border->mBorder.SetBottom(coord);
border->mBorder.SetLeft(coord);
}
}
}

Просмотреть файл

@ -1323,23 +1323,23 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
nscoord pad = NSIntPixelsToTwips(3, p2t);
// add left and right padding around the radio button via css
nsStyleSpacing* spacing = (nsStyleSpacing*) aContext->GetMutableStyleData(eStyleStruct_Spacing);
if (eStyleUnit_Null == spacing->mMargin.GetLeftUnit()) {
nsStyleMargin* margin = (nsStyleMargin*) aContext->GetMutableStyleData(eStyleStruct_Margin);
if (eStyleUnit_Null == margin->mMargin.GetLeftUnit()) {
nsStyleCoord left(pad);
spacing->mMargin.SetLeft(left);
margin->mMargin.SetLeft(left);
}
if (eStyleUnit_Null == spacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Null == margin->mMargin.GetRightUnit()) {
nsStyleCoord right(NSIntPixelsToTwips(5, p2t));
spacing->mMargin.SetRight(right);
margin->mMargin.SetRight(right);
}
// add bottom padding if backward mode
// XXX why isn't this working?
nsCompatibility mode;
aPresContext->GetCompatibilityMode(&mode);
if (eCompatibility_NavQuirks == mode) {
if (eStyleUnit_Null == spacing->mMargin.GetBottomUnit()) {
if (eStyleUnit_Null == margin->mMargin.GetBottomUnit()) {
nsStyleCoord bottom(pad);
spacing->mMargin.SetBottom(bottom);
margin->mMargin.SetBottom(bottom);
}
}
break;

Просмотреть файл

@ -1063,13 +1063,13 @@ static void
MapTableFrameInto(const nsIHTMLMappedAttributes* aAttributes,
nsIMutableStyleContext* aContext,
nsIPresContext* aPresContext,
nsStyleSpacing* aSpacing,
nsStyleBorder* aBorder,
PRUint8 aBorderStyle)
{
// set up defaults
for (PRInt32 sideX = NS_SIDE_TOP; sideX <= NS_SIDE_LEFT; sideX++) {
if (aSpacing->GetBorderStyle(sideX) == NS_STYLE_BORDER_STYLE_NONE) {
aSpacing->SetBorderStyle(sideX, aBorderStyle);
if (aBorder->GetBorderStyle(sideX) == NS_STYLE_BORDER_STYLE_NONE) {
aBorder->SetBorderStyle(sideX, aBorderStyle);
}
}
@ -1082,44 +1082,44 @@ MapTableFrameInto(const nsIHTMLMappedAttributes* aAttributes,
switch (frameValue.GetIntValue())
{
case NS_STYLE_TABLE_FRAME_NONE:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_ABOVE:
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_BELOW:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_HSIDES:
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_LEFT:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_RIGHT:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_VSIDES:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
break;
// BOX and BORDER are ignored, the caller has already set all the border sides
@ -1151,8 +1151,8 @@ MapTableBorderInto(const nsIHTMLMappedAttributes* aAttributes,
}
if (borderValue.GetUnit() != eHTMLUnit_Null) {
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleTable *tableStyle = (nsStyleTable*)
aContext->GetMutableStyleData(eStyleStruct_Table);
nsStyleCoord twips;
@ -1183,12 +1183,12 @@ MapTableBorderInto(const nsIHTMLMappedAttributes* aAttributes,
}
// by default, set all border sides to the specified width
spacing->mBorder.SetTop(twips);
spacing->mBorder.SetRight(twips);
spacing->mBorder.SetBottom(twips);
spacing->mBorder.SetLeft(twips);
border->mBorder.SetTop(twips);
border->mBorder.SetRight(twips);
border->mBorder.SetBottom(twips);
border->mBorder.SetLeft(twips);
// then account for the frame attribute
MapTableFrameInto(aAttributes, aContext, aPresContext, spacing,
MapTableFrameInto(aAttributes, aContext, aPresContext, border,
aBorderStyle);
}
}
@ -1219,14 +1219,14 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
aPresContext->GetPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nsStyleSpacing* spacingStyle = (nsStyleSpacing*)aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* borderStyleData = (nsStyleBorder*)aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleCoord width;
width.SetCoordValue(onePixel);
spacingStyle->mBorder.SetTop(width);
spacingStyle->mBorder.SetLeft(width);
spacingStyle->mBorder.SetBottom(width);
spacingStyle->mBorder.SetRight(width);
borderStyleData->mBorder.SetTop(width);
borderStyleData->mBorder.SetLeft(width);
borderStyleData->mBorder.SetBottom(width);
borderStyleData->mBorder.SetRight(width);
nsCompatibility mode;
aPresContext->GetCompatibilityMode(&mode);
@ -1235,10 +1235,10 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
// BG_INSET results in a border color based on background colors
// used for NavQuirks only...
spacingStyle->SetBorderStyle(NS_SIDE_TOP, borderStyle);
spacingStyle->SetBorderStyle(NS_SIDE_LEFT, borderStyle);
spacingStyle->SetBorderStyle(NS_SIDE_BOTTOM, borderStyle);
spacingStyle->SetBorderStyle(NS_SIDE_RIGHT, borderStyle);
borderStyleData->SetBorderStyle(NS_SIDE_TOP, borderStyle);
borderStyleData->SetBorderStyle(NS_SIDE_LEFT, borderStyle);
borderStyleData->SetBorderStyle(NS_SIDE_BOTTOM, borderStyle);
borderStyleData->SetBorderStyle(NS_SIDE_RIGHT, borderStyle);
}
}
else { // handle attributes for table
@ -1289,8 +1289,10 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
}
}
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* borderStyleData = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleMargin* marginStyleData = (nsStyleMargin*)
aContext->GetMutableStyleData(eStyleStruct_Margin);
// default border style is the Nav4.6 extension which uses the
// background color as the basis of the outset border. If the
@ -1312,10 +1314,10 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if ((eHTMLUnit_Color == value.GetUnit()) ||
(eHTMLUnit_ColorName == value.GetUnit())) {
nscolor color = value.GetColorValue();
spacing->SetBorderColor(0, color);
spacing->SetBorderColor(1, color);
spacing->SetBorderColor(2, color);
spacing->SetBorderColor(3, color);
borderStyleData->SetBorderColor(0, color);
borderStyleData->SetBorderColor(1, color);
borderStyleData->SetBorderColor(2, color);
borderStyleData->SetBorderColor(3, color);
borderStyle = NS_STYLE_BORDER_STYLE_OUTSET; // use css outset
}
@ -1330,8 +1332,8 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if ((NS_STYLE_TEXT_ALIGN_CENTER == value.GetIntValue()) ||
(NS_STYLE_TEXT_ALIGN_MOZ_CENTER == value.GetIntValue())) {
nsStyleCoord otto(eStyleUnit_Auto);
spacing->mMargin.SetLeft(otto);
spacing->mMargin.SetRight(otto);
marginStyleData->mMargin.SetLeft(otto);
marginStyleData->mMargin.SetRight(otto);
}
else {
nsStyleDisplay* display = (nsStyleDisplay*)
@ -1415,8 +1417,8 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), sp2t);
nsStyleCoord hspace(twips);
spacing->mMargin.SetLeft(hspace);
spacing->mMargin.SetRight(hspace);
marginStyleData->mMargin.SetLeft(hspace);
marginStyleData->mMargin.SetRight(hspace);
}
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
@ -1424,8 +1426,8 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), sp2t);
nsStyleCoord vspace(twips);
spacing->mMargin.SetTop(vspace);
spacing->mMargin.SetBottom(vspace);
marginStyleData->mMargin.SetTop(vspace);
marginStyleData->mMargin.SetBottom(vspace);
}
}

Просмотреть файл

@ -2253,33 +2253,41 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nsCSSMargin* ourMargin;
if (NS_OK == aDeclaration->GetData(kCSSMarginSID, (nsCSSStruct**)&ourMargin)) {
if (nsnull != ourMargin) {
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)aContext->GetMutableStyleData(eStyleStruct_Margin);
nsStylePadding* padding = (nsStylePadding*)aContext->GetMutableStyleData(eStyleStruct_Padding);
nsStyleBorder* border = (nsStyleBorder*)aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleOutline* outline = (nsStyleOutline*)aContext->GetMutableStyleData(eStyleStruct_Outline);
const nsStyleSpacing* parentSpacing = spacing;
const nsStyleMargin* parentMargin = margin;
const nsStylePadding* parentPadding = padding;
const nsStyleBorder* parentBorder = border;
const nsStyleOutline* parentOutline = outline;
if (nsnull != aParentContext) {
parentSpacing = (const nsStyleSpacing*)aParentContext->GetStyleData(eStyleStruct_Spacing);
parentMargin = (const nsStyleMargin*)aParentContext->GetStyleData(eStyleStruct_Margin);
parentPadding = (const nsStylePadding*)aParentContext->GetStyleData(eStyleStruct_Padding);
parentBorder = (const nsStyleBorder*)aParentContext->GetStyleData(eStyleStruct_Border);
parentOutline = (const nsStyleOutline*)aParentContext->GetStyleData(eStyleStruct_Outline);
}
// margin: length, percent, auto, inherit
if (nsnull != ourMargin->mMargin) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mMargin.GetLeft(parentCoord);
parentMargin->mMargin.GetLeft(parentCoord);
if (SetCoord(ourMargin->mMargin->mLeft, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetLeft(coord);
margin->mMargin.SetLeft(coord);
}
parentSpacing->mMargin.GetTop(parentCoord);
parentMargin->mMargin.GetTop(parentCoord);
if (SetCoord(ourMargin->mMargin->mTop, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetTop(coord);
margin->mMargin.SetTop(coord);
}
parentSpacing->mMargin.GetRight(parentCoord);
parentMargin->mMargin.GetRight(parentCoord);
if (SetCoord(ourMargin->mMargin->mRight, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetRight(coord);
margin->mMargin.SetRight(coord);
}
parentSpacing->mMargin.GetBottom(parentCoord);
parentMargin->mMargin.GetBottom(parentCoord);
if (SetCoord(ourMargin->mMargin->mBottom, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetBottom(coord);
margin->mMargin.SetBottom(coord);
}
}
@ -2287,21 +2295,21 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mPadding) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mPadding.GetLeft(parentCoord);
parentPadding->mPadding.GetLeft(parentCoord);
if (SetCoord(ourMargin->mPadding->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetLeft(coord);
padding->mPadding.SetLeft(coord);
}
parentSpacing->mPadding.GetTop(parentCoord);
parentPadding->mPadding.GetTop(parentCoord);
if (SetCoord(ourMargin->mPadding->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetTop(coord);
padding->mPadding.SetTop(coord);
}
parentSpacing->mPadding.GetRight(parentCoord);
parentPadding->mPadding.GetRight(parentCoord);
if (SetCoord(ourMargin->mPadding->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetRight(coord);
padding->mPadding.SetRight(coord);
}
parentSpacing->mPadding.GetBottom(parentCoord);
parentPadding->mPadding.GetBottom(parentCoord);
if (SetCoord(ourMargin->mPadding->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetBottom(coord);
padding->mPadding.SetBottom(coord);
}
}
@ -2310,31 +2318,31 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nsStyleCoord coord;
nsStyleCoord parentCoord;
if (SetCoord(ourMargin->mBorderWidth->mLeft, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetLeft(coord);
border->mBorder.SetLeft(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mLeft.GetUnit()) {
spacing->mBorder.SetLeft(parentSpacing->mBorder.GetLeft(coord));
border->mBorder.SetLeft(parentBorder->mBorder.GetLeft(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mTop, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetTop(coord);
border->mBorder.SetTop(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mTop.GetUnit()) {
spacing->mBorder.SetTop(parentSpacing->mBorder.GetTop(coord));
border->mBorder.SetTop(parentBorder->mBorder.GetTop(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mRight, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetRight(coord);
border->mBorder.SetRight(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mRight.GetUnit()) {
spacing->mBorder.SetRight(parentSpacing->mBorder.GetRight(coord));
border->mBorder.SetRight(parentBorder->mBorder.GetRight(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mBottom, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetBottom(coord);
border->mBorder.SetBottom(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mBottom.GetUnit()) {
spacing->mBorder.SetBottom(parentSpacing->mBorder.GetBottom(coord));
border->mBorder.SetBottom(parentBorder->mBorder.GetBottom(coord));
}
}
@ -2342,43 +2350,43 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mBorderStyle) {
nsCSSRect* ourStyle = ourMargin->mBorderStyle;
if (eCSSUnit_Enumerated == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, ourStyle->mTop.GetIntValue());
border->SetBorderStyle(NS_SIDE_TOP, ourStyle->mTop.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, parentSpacing->GetBorderStyle(NS_SIDE_TOP));
border->SetBorderStyle(NS_SIDE_TOP, parentBorder->GetBorderStyle(NS_SIDE_TOP));
}
if (eCSSUnit_Enumerated == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, ourStyle->mRight.GetIntValue());
border->SetBorderStyle(NS_SIDE_RIGHT, ourStyle->mRight.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, parentSpacing->GetBorderStyle(NS_SIDE_RIGHT));
border->SetBorderStyle(NS_SIDE_RIGHT, parentBorder->GetBorderStyle(NS_SIDE_RIGHT));
}
if (eCSSUnit_Enumerated == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, ourStyle->mBottom.GetIntValue());
border->SetBorderStyle(NS_SIDE_BOTTOM, ourStyle->mBottom.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, parentSpacing->GetBorderStyle(NS_SIDE_BOTTOM));
border->SetBorderStyle(NS_SIDE_BOTTOM, parentBorder->GetBorderStyle(NS_SIDE_BOTTOM));
}
if (eCSSUnit_Enumerated == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, ourStyle->mLeft.GetIntValue());
border->SetBorderStyle(NS_SIDE_LEFT, ourStyle->mLeft.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, parentSpacing->GetBorderStyle(NS_SIDE_LEFT));
border->SetBorderStyle(NS_SIDE_LEFT, parentBorder->GetBorderStyle(NS_SIDE_LEFT));
}
}
@ -2389,63 +2397,63 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nscolor unused = NS_RGB(0,0,0);
if (eCSSUnit_Inherit == ourBorderColor->mTop.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_TOP, borderColor)) {
spacing->SetBorderColor(NS_SIDE_TOP, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_TOP, borderColor)) {
border->SetBorderColor(NS_SIDE_TOP, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_TOP);
border->SetBorderTransparent(NS_SIDE_TOP);
}
}
else if (SetColor(ourBorderColor->mTop, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_TOP, borderColor);
border->SetBorderColor(NS_SIDE_TOP, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_TOP);
border->SetBorderTransparent(NS_SIDE_TOP);
}
if (eCSSUnit_Inherit == ourBorderColor->mRight.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_RIGHT, borderColor)) {
spacing->SetBorderColor(NS_SIDE_RIGHT, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_RIGHT, borderColor)) {
border->SetBorderColor(NS_SIDE_RIGHT, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_RIGHT);
border->SetBorderTransparent(NS_SIDE_RIGHT);
}
}
else if (SetColor(ourBorderColor->mRight, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_RIGHT, borderColor);
border->SetBorderColor(NS_SIDE_RIGHT, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mRight.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_RIGHT);
border->SetBorderTransparent(NS_SIDE_RIGHT);
}
if (eCSSUnit_Inherit == ourBorderColor->mBottom.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_BOTTOM, borderColor)) {
spacing->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_BOTTOM, borderColor)) {
border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_BOTTOM);
border->SetBorderTransparent(NS_SIDE_BOTTOM);
}
}
else if (SetColor(ourBorderColor->mBottom, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mBottom.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_BOTTOM);
border->SetBorderTransparent(NS_SIDE_BOTTOM);
}
if (eCSSUnit_Inherit == ourBorderColor->mLeft.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_LEFT, borderColor)) {
spacing->SetBorderColor(NS_SIDE_LEFT, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_LEFT, borderColor)) {
border->SetBorderColor(NS_SIDE_LEFT, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_LEFT);
border->SetBorderTransparent(NS_SIDE_LEFT);
}
}
else if (SetColor(ourBorderColor->mLeft, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_LEFT, borderColor);
border->SetBorderColor(NS_SIDE_LEFT, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mLeft.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_LEFT);
border->SetBorderTransparent(NS_SIDE_LEFT);
}
}
@ -2453,21 +2461,21 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mBorderRadius) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mBorderRadius.GetLeft(parentCoord);
parentBorder->mBorderRadius.GetLeft(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetLeft(coord);
border->mBorderRadius.SetLeft(coord);
}
parentSpacing->mBorderRadius.GetTop(parentCoord);
parentBorder->mBorderRadius.GetTop(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetTop(coord);
border->mBorderRadius.SetTop(coord);
}
parentSpacing->mBorderRadius.GetRight(parentCoord);
parentBorder->mBorderRadius.GetRight(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetRight(coord);
border->mBorderRadius.SetRight(coord);
}
parentSpacing->mBorderRadius.GetBottom(parentCoord);
parentBorder->mBorderRadius.GetBottom(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetBottom(coord);
border->mBorderRadius.SetBottom(coord);
}
}
@ -2475,26 +2483,26 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mOutlineRadius) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mOutlineRadius.GetLeft(parentCoord);
parentOutline->mOutlineRadius.GetLeft(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetLeft(coord);
outline->mOutlineRadius.SetLeft(coord);
}
parentSpacing->mOutlineRadius.GetTop(parentCoord);
parentOutline->mOutlineRadius.GetTop(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetTop(coord);
outline->mOutlineRadius.SetTop(coord);
}
parentSpacing->mOutlineRadius.GetRight(parentCoord);
parentOutline->mOutlineRadius.GetRight(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetRight(coord);
outline->mOutlineRadius.SetRight(coord);
}
parentSpacing->mOutlineRadius.GetBottom(parentCoord);
parentOutline->mOutlineRadius.GetBottom(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetBottom(coord);
outline->mOutlineRadius.SetBottom(coord);
}
}
// outline-width: length, enum, inherit
if (! SetCoord(ourMargin->mOutlineWidth, spacing->mOutlineWidth, parentSpacing->mOutlineWidth,
if (! SetCoord(ourMargin->mOutlineWidth, outline->mOutlineWidth, parentOutline->mOutlineWidth,
SETCOORD_LEH, aFont->mFont, aPresContext)) {
}
@ -2502,37 +2510,37 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nscolor outlineColor;
nscolor unused = NS_RGB(0,0,0);
if (eCSSUnit_Inherit == ourMargin->mOutlineColor.GetUnit()) {
if (parentSpacing->GetOutlineColor(outlineColor)) {
spacing->SetOutlineColor(outlineColor);
if (parentOutline->GetOutlineColor(outlineColor)) {
outline->SetOutlineColor(outlineColor);
}
else {
spacing->SetOutlineInvert();
outline->SetOutlineInvert();
}
}
else if (SetColor(ourMargin->mOutlineColor, unused, aPresContext, outlineColor)) {
spacing->SetOutlineColor(outlineColor);
outline->SetOutlineColor(outlineColor);
}
else if (eCSSUnit_Enumerated == ourMargin->mOutlineColor.GetUnit()) {
spacing->SetOutlineInvert();
outline->SetOutlineInvert();
}
// outline-style: enum, none, inherit
if (eCSSUnit_Enumerated == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(ourMargin->mOutlineStyle.GetIntValue());
outline->SetOutlineStyle(ourMargin->mOutlineStyle.GetIntValue());
}
else if (eCSSUnit_None == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(NS_STYLE_BORDER_STYLE_NONE);
outline->SetOutlineStyle(NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(parentSpacing->GetOutlineStyle());
outline->SetOutlineStyle(parentOutline->GetOutlineStyle());
}
// float-edge: enum, inherit
if (eCSSUnit_Enumerated == ourMargin->mFloatEdge.GetUnit()) {
spacing->mFloatEdge = ourMargin->mFloatEdge.GetIntValue();
border->mFloatEdge = ourMargin->mFloatEdge.GetIntValue();
}
else if (eCSSUnit_Inherit == ourMargin->mFloatEdge.GetUnit()) {
spacing->mFloatEdge = parentSpacing->mFloatEdge;
border->mFloatEdge = parentBorder->mFloatEdge;
}
}
}

Просмотреть файл

@ -844,15 +844,15 @@ nsComputedDOMStyle::GetMargin(nsAWritableString& aMargin)
nsresult GetMargins(nsIFrame *aFrame, nscoord& left, nscoord& top,
nscoord& right, nscoord& bottom)
{
const nsStyleSpacing* spacing;
const nsStyleBorder* border;
nsStyleCoord coord;
frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing) {
if (eStyleUnit_Coord == spacing->mBorder.GetLeftUnit()) {
origin.x += spacing->mBorder.GetLeft(coord).GetCoordValue();
frame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border);
if (border) {
if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) {
origin.x += border->mBorder.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetTopUnit()) {
origin.y += spacing->mBorder.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) {
origin.y += border->mBorder.GetTop(coord).GetCoordValue();
}
}
}
@ -1267,31 +1267,33 @@ nsComputedDOMStyle::GetAbsoluteFrameRect(nsIFrame *aFrame, nsRect& aRect)
}
// For the origin, add in the border for the frame
const nsStyleSpacing* spacing;
const nsStyleBorder* border;
const nsStylePadding* padding;
nsStyleCoord coord;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing) {
if (eStyleUnit_Coord == spacing->mBorder.GetLeftUnit()) {
origin.x += spacing->mBorder.GetLeft(coord).GetCoordValue();
aRect.width -= spacing->mBorder.GetLeft(coord).GetCoordValue();
//aRect.width -= spacing->mMargin.GetLeft(coord).GetCoordValue();
aRect.width -= spacing->mPadding.GetLeft(coord).GetCoordValue();
aFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border);
aFrame->GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)padding);
if (border && padding) {
if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) {
origin.x += border->mBorder.GetLeft(coord).GetCoordValue();
aRect.width -= border->mBorder.GetLeft(coord).GetCoordValue();
//aRect.width -= margin->mMargin.GetLeft(coord).GetCoordValue();
aRect.width -= padding->mPadding.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetTopUnit()) {
origin.y += spacing->mBorder.GetTop(coord).GetCoordValue();
aRect.height -= spacing->mBorder.GetTop(coord).GetCoordValue();
//aRect.height -= spacing->mMargin.GetTop(coord).GetCoordValue();
aRect.height -= spacing->mPadding.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) {
origin.y += border->mBorder.GetTop(coord).GetCoordValue();
aRect.height -= border->mBorder.GetTop(coord).GetCoordValue();
//aRect.height -= margin->mMargin.GetTop(coord).GetCoordValue();
aRect.height -= padding->mPadding.GetTop(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetRightUnit()) {
aRect.width -= spacing->mBorder.GetRight(coord).GetCoordValue();
//aRect.width -= spacing->mMargin.GetRight(coord).GetCoordValue();
aRect.width -= spacing->mPadding.GetRight(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetRightUnit()) {
aRect.width -= border->mBorder.GetRight(coord).GetCoordValue();
//aRect.width -= margin->mMargin.GetRight(coord).GetCoordValue();
aRect.width -= padding->mPadding.GetRight(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetBottomUnit()) {
aRect.height -= spacing->mBorder.GetBottom(coord).GetCoordValue();
//aRect.height -= spacing->mMargin.GetBottom(coord).GetCoordValue();
aRect.height -= spacing->mPadding.GetBottom(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetBottomUnit()) {
aRect.height -= border->mBorder.GetBottom(coord).GetCoordValue();
//aRect.height -= margin->mMargin.GetBottom(coord).GetCoordValue();
aRect.height -= padding->mPadding.GetBottom(coord).GetCoordValue();
}
}

Просмотреть файл

@ -132,13 +132,13 @@ CSSFirstLineRule::MapStyleInto(nsIMutableStyleContext* aContext,
parentContext = aContext->GetParent();
// Disable border
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
if (spacing) {
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
if (border) {
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
}
// Undo any change made to "direction"

Просмотреть файл

@ -9490,10 +9490,10 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext,
if (! view) { // if frame has view, will already be invalidated
// XXX Instead of calling this we should really be calling
// Invalidate on on the nsFrame (which does this)
const nsStyleSpacing* spacing;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
const nsStyleOutline* outline;
aFrame->GetStyleData(eStyleStruct_Outline, (const nsStyleStruct*&)outline);
nscoord width;
spacing->GetOutlineWidth(width);
outline->GetOutlineWidth(width);
if (width > 0) {
invalidRect.Inflate(width, width);
}

Просмотреть файл

@ -740,21 +740,26 @@ nscoord xstart,xwidth,ystart,ywidth;
void nsCSSRendering::DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const nsStyleSpacing& aSpacing,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
PRBool aDoOutline,
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
nsRect* aGap)
{
PRIntn dashLength;
nsRect dashRect, currRect;
nscoord xstart,xwidth,ystart,ywidth,temp,temp1,adjust;
PRBool bSolid = PR_TRUE;
float over = 0.0f;
PRUint8 style = aDoOutline?aSpacing.GetOutlineStyle():aSpacing.GetBorderStyle(startSide);
PRBool skippedSide = PR_FALSE;
NS_ASSERTION((aDoOutline && aOutlineStyle) || (!aDoOutline && aBorderStyle), "null params not allowed");
PRUint8 style = aDoOutline
? aOutlineStyle->GetOutlineStyle()
: aBorderStyle->GetBorderStyle(startSide);
// find out were x and y start
if(aDirtyRect.x > borderInside.x) {
@ -777,7 +782,9 @@ PRBool skippedSide = PR_FALSE;
for (PRIntn whichSide = startSide; whichSide < 4; whichSide++) {
PRUint8 prevStyle = style;
style = aDoOutline?aSpacing.GetOutlineStyle():aSpacing.GetBorderStyle(whichSide);
style = aDoOutline
? aOutlineStyle->GetOutlineStyle()
: aBorderStyle->GetBorderStyle(whichSide);
if ((1<<whichSide) & aSkipSides) {
// Skipped side
skippedSide = PR_TRUE;
@ -800,9 +807,9 @@ PRBool skippedSide = PR_FALSE;
nscolor sideColor;
if (aDoOutline) {
aSpacing.GetOutlineColor(sideColor);
aOutlineStyle->GetOutlineColor(sideColor);
} else {
if (!aSpacing.GetBorderColor(whichSide, sideColor)) {
if (!aBorderStyle->GetBorderColor(whichSide, sideColor)) {
continue; // side is transparent
}
}
@ -1488,7 +1495,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder& aBorderStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap,
@ -1569,7 +1576,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
// check for any corner that is rounded
for(i=0;i<4;i++){
if(borderRadii[i] > 0){
PaintRoundedBorder(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aBorderStyle,aStyleContext,aSkipSides,borderRadii,aGap,PR_FALSE);
PaintRoundedBorder(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,&aBorderStyle,nsnull,aStyleContext,aSkipSides,borderRadii,aGap,PR_FALSE);
return;
}
}
@ -1600,7 +1607,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
}
}
if (cnt < 4) {
DrawDashedSides(cnt, aRenderingContext,aDirtyRect,aBorderStyle, PR_FALSE,
DrawDashedSides(cnt, aRenderingContext,aDirtyRect,&aBorderStyle,nsnull, PR_FALSE,
inside, outside, aSkipSides, aGap);
}
@ -1670,7 +1677,8 @@ void nsCSSRendering::PaintOutline(nsIPresContext* aPresContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder& aBorderStyle,
const nsStyleOutline& aOutlineStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap)
@ -1682,7 +1690,7 @@ const nsStyleColor* bgColor = nsStyleUtil::FindNonTransparentBackground(aStyleCo
nscoord width;
aBorderStyle.GetOutlineWidth(width);
aOutlineStyle.GetOutlineWidth(width);
if (0 == width) {
// Empty outline
@ -1690,10 +1698,10 @@ nscoord width;
}
// get the radius for our border
aBorderStyle.mOutlineRadius.GetTop(bordStyleRadius[0]); //topleft
aBorderStyle.mOutlineRadius.GetRight(bordStyleRadius[1]); //topright
aBorderStyle.mOutlineRadius.GetBottom(bordStyleRadius[2]); //bottomright
aBorderStyle.mOutlineRadius.GetLeft(bordStyleRadius[3]); //bottomleft
aOutlineStyle.mOutlineRadius.GetTop(bordStyleRadius[0]); //topleft
aOutlineStyle.mOutlineRadius.GetRight(bordStyleRadius[1]); //topright
aOutlineStyle.mOutlineRadius.GetBottom(bordStyleRadius[2]); //bottomright
aOutlineStyle.mOutlineRadius.GetLeft(bordStyleRadius[3]); //bottomleft
for(i=0;i<4;i++) {
borderRadii[i] = 0;
@ -1744,18 +1752,18 @@ nscoord width;
// rounded version of the border
for(i=0;i<4;i++){
if(borderRadii[i] > 0){
PaintRoundedBorder(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aBorderStyle,aStyleContext,aSkipSides,borderRadii,aGap,PR_TRUE);
PaintRoundedBorder(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,nsnull,&aOutlineStyle,aStyleContext,aSkipSides,borderRadii,aGap,PR_TRUE);
aRenderingContext.PopState(clipState);
return;
}
}
PRUint8 outlineStyle = aBorderStyle.GetOutlineStyle();
PRUint8 outlineStyle = aOutlineStyle.GetOutlineStyle();
//see if any sides are dotted or dashed
if ((outlineStyle == NS_STYLE_BORDER_STYLE_DOTTED) ||
(outlineStyle == NS_STYLE_BORDER_STYLE_DASHED)) {
DrawDashedSides(0, aRenderingContext, aDirtyRect, aBorderStyle, PR_TRUE,
DrawDashedSides(0, aRenderingContext, aDirtyRect, nsnull, &aOutlineStyle, PR_TRUE,
outside, inside, aSkipSides, aGap);
aRenderingContext.PopState(clipState);
return;
@ -1771,7 +1779,7 @@ nscoord width;
nscolor outlineColor;
if (aBorderStyle.GetOutlineColor(outlineColor)) {
if (aOutlineStyle.GetOutlineColor(outlineColor)) {
DrawSide(aRenderingContext, NS_SIDE_BOTTOM,
outlineStyle,
outlineColor,
@ -2070,7 +2078,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleColor& aColor,
const nsStyleSpacing& aSpacing,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY)
{
@ -2125,7 +2133,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
nsRect paddingArea(aBorderArea);
nsMargin border;
if (!aSpacing.GetBorder(border)) {
if (!aBorder.GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
paddingArea.Deflate(border);
@ -2483,10 +2491,10 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
// is rendered over the 'border' 'padding' and 'content' areas
if (!transparentBG) {
// get the radius for our border
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
aSpacing.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
aSpacing.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
aBorder.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
aBorder.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
aBorder.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
aBorder.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
for(i=0;i<4;i++) {
borderRadii[i] = 0;
@ -2509,7 +2517,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
// rounded version of the border
for(i=0;i<4;i++){
if (borderRadii[i] > 0){
PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aColor,aSpacing,aDX,aDY,borderRadii);
PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aColor,aDX,aDY,borderRadii);
return;
}
}
@ -2563,7 +2571,6 @@ nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleColor& aColor,
const nsStyleSpacing& aSpacing,
nscoord aDX,
nscoord aDY,
PRInt16 aTheRadius[4])
@ -2652,7 +2659,8 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
PRInt16 aBorderRadius[4],
@ -2670,16 +2678,16 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
nscoord twipsPerPixel,qtwips;
float p2t;
NS_ASSERTION((aIsOutline && aOutlineStyle) || (!aIsOutline && aBorderStyle), "null params not allowed");
if (!aIsOutline) {
aBorderStyle.CalcBorderFor(aForFrame, border);
aBorderStyle->CalcBorderFor(aForFrame, border);
if ((0 == border.left) && (0 == border.right) &&
(0 == border.top) && (0 == border.bottom)) {
return;
}
} else {
nscoord width;
if (!aBorderStyle.GetOutlineWidth(width)) {
if (!aOutlineStyle->GetOutlineWidth(width)) {
return;
}
border.left = width;
@ -2720,7 +2728,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
thePath[np++].MoveTo(Icr2.mAnc2.x, Icr2.mAnc2.y);
thePath[np++].MoveTo(Icr2.mCon.x, Icr2.mCon.y);
thePath[np++].MoveTo(Icr2.mAnc1.x, Icr2.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aStyleContext,NS_SIDE_TOP,border,qtwips, aIsOutline);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_TOP,border,qtwips, aIsOutline);
}
// RIGHT LINE ----------------------------------------------------------------
LR.MidPointDivide(&cr2,&cr3);
@ -2740,7 +2748,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
thePath[np++].MoveTo(Icr4.mAnc2.x,Icr4.mAnc2.y);
thePath[np++].MoveTo(Icr4.mCon.x, Icr4.mCon.y);
thePath[np++].MoveTo(Icr4.mAnc1.x,Icr4.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aStyleContext,NS_SIDE_RIGHT,border,qtwips, aIsOutline);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_RIGHT,border,qtwips, aIsOutline);
}
// bottom line ----------------------------------------------------------------
@ -2761,7 +2769,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
thePath[np++].MoveTo(Icr3.mAnc2.x, Icr3.mAnc2.y);
thePath[np++].MoveTo(Icr3.mCon.x, Icr3.mCon.y);
thePath[np++].MoveTo(Icr3.mAnc1.x, Icr3.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aStyleContext,NS_SIDE_BOTTOM,border,qtwips, aIsOutline);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_BOTTOM,border,qtwips, aIsOutline);
}
// left line ----------------------------------------------------------------
if(0==border.left)
@ -2782,7 +2790,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
thePath[np++].MoveTo(Icr4.mCon.x, Icr4.mCon.y);
thePath[np++].MoveTo(Icr4.mAnc1.x, Icr4.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aStyleContext,NS_SIDE_LEFT,border,qtwips, aIsOutline);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_LEFT,border,qtwips, aIsOutline);
}
@ -2792,7 +2800,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
*/
void
nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext,
const nsStyleSpacing& aBorderStyle,nsIStyleContext* aStyleContext,
const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsIStyleContext* aStyleContext,
PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel,
PRBool aIsOutline)
{
@ -2803,11 +2811,12 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin
PRInt8 border_Style;
PRInt16 thickness;
NS_ASSERTION((aIsOutline && aOutlineStyle) || (!aIsOutline && aBorderStyle), "null params not allowed");
// set the style information
if (!aIsOutline) {
aBorderStyle.GetBorderColor(aSide,sideColor);
aBorderStyle->GetBorderColor(aSide,sideColor);
} else {
aBorderStyle.GetOutlineColor(sideColor);
aOutlineStyle->GetOutlineColor(sideColor);
}
aRenderingContext.SetColor ( sideColor );
@ -2838,16 +2847,15 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin
} else {
if (!aIsOutline) {
border_Style = aBorderStyle.GetBorderStyle(aSide);
border_Style = aBorderStyle->GetBorderStyle(aSide);
} else {
border_Style = aBorderStyle.GetOutlineStyle();
border_Style = aOutlineStyle->GetOutlineStyle();
}
switch (border_Style){
case NS_STYLE_BORDER_STYLE_OUTSET:
case NS_STYLE_BORDER_STYLE_INSET:
{
const nsStyleColor* bgColor = nsStyleUtil::FindNonTransparentBackground(aStyleContext);
aBorderStyle.GetBorderColor(aSide,sideColor);
aRenderingContext.SetColor ( MakeBevelColor (aSide, border_Style, bgColor->mBackgroundColor,sideColor, PR_TRUE));
}
case NS_STYLE_BORDER_STYLE_DOTTED:
@ -2892,7 +2900,6 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin
case NS_STYLE_BORDER_STYLE_GROOVE:
{
const nsStyleColor* bgColor = nsStyleUtil::FindNonTransparentBackground(aStyleContext);
aBorderStyle.GetBorderColor(aSide,sideColor);
aRenderingContext.SetColor ( MakeBevelColor (aSide, border_Style, bgColor->mBackgroundColor,sideColor, PR_TRUE));
polypath[0].x = NSToCoordRound(aPoints[0].x);

Просмотреть файл

@ -41,7 +41,7 @@ public:
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder& aBorderStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0,
@ -61,7 +61,8 @@ public:
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder& aBorderStyle,
const nsStyleOutline& aOutlineStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0);
@ -101,7 +102,7 @@ public:
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleColor& aColor,
const nsStyleSpacing& aStyle,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY);
@ -118,7 +119,8 @@ public:
static void DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const nsStyleSpacing& aSpacing,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
PRBool aDoOutline,
const nsRect& borderOutside,
const nsRect& borderInside,
@ -147,7 +149,8 @@ protected:
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
PRInt16 aBorderRadius[4],nsRect* aGap = 0,
@ -155,7 +158,7 @@ protected:
static void RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext,
const nsStyleSpacing& aBorderStyle,nsIStyleContext* aStyleContext,
const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsIStyleContext* aStyleContext,
PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel,
PRBool aIsOutline=PR_FALSE);
@ -165,7 +168,6 @@ protected:
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleColor& aColor,
const nsStyleSpacing& aStyle,
nscoord aDX,
nscoord aDY,
PRInt16 aTheRadius[4]);

Просмотреть файл

@ -195,13 +195,13 @@
#define NS_STYLE_BORDER_COLLAPSE 0
#define NS_STYLE_BORDER_SEPARATE 1
// See nsStyleSpacing mBorder enum values
// See nsStyleBorder mBorder enum values
#define NS_STYLE_BORDER_WIDTH_THIN 0
#define NS_STYLE_BORDER_WIDTH_MEDIUM 1
#define NS_STYLE_BORDER_WIDTH_THICK 2
// XXX chopping block #define NS_STYLE_BORDER_WIDTH_LENGTH_VALUE 3
// See nsStyleSpacing mBorderStyle
// See nsStyleBorder mBorderStyle
#define NS_STYLE_BORDER_STYLE_NONE 0
#define NS_STYLE_BORDER_STYLE_GROOVE 1
#define NS_STYLE_BORDER_STYLE_RIDGE 2
@ -450,7 +450,7 @@
#define NS_STYLE_LIST_STYLE_POSITION_INSIDE 0
#define NS_STYLE_LIST_STYLE_POSITION_OUTSIDE 1
// See nsStyleSpacing
// See nsStyleMargin
#define NS_STYLE_MARGIN_SIZE_AUTO 0
// See nsStyleText

Просмотреть файл

@ -33,7 +33,9 @@ class nsLineLayout;
struct nsStyleDisplay;
struct nsStylePosition;
struct nsStyleSpacing;
struct nsStyleBorder;
struct nsStyleMargin;
struct nsStylePadding;
struct nsStyleText;
struct nsHypotheticalBox;
@ -206,7 +208,9 @@ struct nsHTMLReflowState {
// Cached pointers to the various style structs used during intialization
const nsStyleDisplay* mStyleDisplay;
const nsStylePosition* mStylePosition;
const nsStyleSpacing* mStyleSpacing;
const nsStyleBorder* mStyleBorder;
const nsStyleMargin* mStyleMargin;
const nsStylePadding* mStylePadding;
const nsStyleText* mStyleText;
// This value keeps track of how deeply nested a given reflow state

Просмотреть файл

@ -621,6 +621,10 @@ public:
*/
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const = 0;
// Fill a style struct with data
NS_IMETHOD GetStyle(nsStyleStructID aSID, nsStyleStruct& aStruct) const = 0;
// Utility function: more convenient than 2 calls to GetStyleData to get border and padding
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const = 0;
/**
* These methods are to access any additional style contexts that

Просмотреть файл

@ -85,25 +85,47 @@ struct nsStyleColor : public nsStyleStruct {
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE);}
};
struct nsStyleSpacing: public nsStyleStruct {
nsStyleSpacing(void);
struct nsStyleMargin: public nsStyleStruct {
nsStyleMargin(void);
nsStyleSides mMargin; // [reset] length, percent, auto, inherit
nsStyleSides mPadding; // [reset] length, percent, inherit
nsStyleSides mBorder; // [reset] length, enum (see nsStyleConsts.h)
nsStyleSides mBorderRadius; // [reset] length, percent, inherit
nsStyleSides mOutlineRadius; // [reset] length, percent, inherit
// (top=topLeft, right=topRight, bottom=bottomRight, left=bottomLeft)
nsStyleCoord mOutlineWidth; // [reset] length, enum (see nsStyleConsts.h)
PRUint8 mFloatEdge; // [reset] see nsStyleConsts.h
PRBool GetMargin(nsMargin& aMargin) const;
// XXX this is a deprecated method
void CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const;
protected:
PRPackedBool mHasCachedMargin;
nsMargin mCachedMargin;
};
struct nsStylePadding: public nsStyleStruct {
nsStylePadding(void);
nsStyleSides mPadding; // [reset] length, percent, inherit
PRBool GetPadding(nsMargin& aPadding) const;
// XXX this is a deprecated method
void CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const;
protected:
PRPackedBool mHasCachedPadding;
nsMargin mCachedPadding;
};
struct nsStyleBorder: public nsStyleStruct {
nsStyleBorder(void);
nsStyleSides mBorder; // [reset] length, enum (see nsStyleConsts.h)
nsStyleSides mBorderRadius; // [reset] length, percent, inherit
PRUint8 mFloatEdge; // [reset] see nsStyleConsts.h
PRBool GetBorder(nsMargin& aBorder) const;
PRBool GetBorderPadding(nsMargin& aBorderPadding) const;
PRUint8 GetBorderStyle(PRUint8 aSide) const;
void SetBorderStyle(PRUint8 aSide, PRUint8 aStyle);
@ -112,6 +134,37 @@ struct nsStyleSpacing: public nsStyleStruct {
void SetBorderTransparent(PRUint8 aSide);
void UnsetBorderColor(PRUint8 aSide);
// XXX these are deprecated methods
void CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const;
protected:
PRPackedBool mHasCachedBorder;
nsMargin mCachedBorder;
PRUint8 mBorderStyle[4]; // [reset] See nsStyleConsts.h
nscolor mBorderColor[4]; // [reset]
};
struct nsStyleBorderPadding: public nsStyleStruct {
nsStyleBorderPadding(void);
PRBool GetBorderPadding(nsMargin& aBorderPadding) const;
void SetBorderPadding(nsMargin aBorderPadding);
protected:
nsMargin mCachedBorderPadding;
PRPackedBool mHasCachedBorderPadding;
};
struct nsStyleOutline: public nsStyleStruct {
nsStyleOutline(void);
nsStyleSides mOutlineRadius; // [reset] length, percent, inherit
// (top=topLeft, right=topRight, bottom=bottomRight, left=bottomLeft)
nsStyleCoord mOutlineWidth; // [reset] length, enum (see nsStyleConsts.h)
PRBool GetOutlineWidth(nscoord& aWidth) const; // PR_TRUE if pre-computed
PRUint8 GetOutlineStyle(void) const;
void SetOutlineStyle(PRUint8 aStyle);
@ -119,29 +172,16 @@ struct nsStyleSpacing: public nsStyleStruct {
void SetOutlineColor(nscolor aColor);
void SetOutlineInvert(void);
// XXX these are deprecated methods
void CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const;
void CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const;
void CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const;
void CalcBorderPaddingFor(const nsIFrame* aFrame, nsMargin& aBorderPadding) const;
protected:
PRPackedBool mHasCachedMargin;
PRPackedBool mHasCachedPadding;
PRPackedBool mHasCachedBorder;
PRPackedBool mHasCachedOutline;
nsMargin mCachedMargin;
nsMargin mCachedPadding;
nsMargin mCachedBorder;
nsMargin mCachedBorderPadding;
nscoord mCachedOutlineWidth;
PRUint8 mBorderStyle[4]; // [reset] See nsStyleConsts.h
nscolor mBorderColor[4]; // [reset]
PRUint8 mOutlineStyle; // [reset] See nsStyleConsts.h
nscolor mOutlineColor; // [reset]
};
struct nsStyleList : public nsStyleStruct {
nsStyleList(void);
~nsStyleList(void);
@ -452,6 +492,9 @@ public:
// call if you change style data after creation
virtual void RecalcAutomaticData(nsIPresContext* aPresContext) = 0;
// utility function: more convenient than 2 calls to GetStyleData to get border and padding
virtual void CalcBorderPaddingFor(const nsIFrame* aFrame, nsMargin& aBorderPadding) const = 0;
};
// this is private to nsStyleSet, don't call it

Просмотреть файл

@ -195,13 +195,13 @@
#define NS_STYLE_BORDER_COLLAPSE 0
#define NS_STYLE_BORDER_SEPARATE 1
// See nsStyleSpacing mBorder enum values
// See nsStyleBorder mBorder enum values
#define NS_STYLE_BORDER_WIDTH_THIN 0
#define NS_STYLE_BORDER_WIDTH_MEDIUM 1
#define NS_STYLE_BORDER_WIDTH_THICK 2
// XXX chopping block #define NS_STYLE_BORDER_WIDTH_LENGTH_VALUE 3
// See nsStyleSpacing mBorderStyle
// See nsStyleBorder mBorderStyle
#define NS_STYLE_BORDER_STYLE_NONE 0
#define NS_STYLE_BORDER_STYLE_GROOVE 1
#define NS_STYLE_BORDER_STYLE_RIDGE 2
@ -450,7 +450,7 @@
#define NS_STYLE_LIST_STYLE_POSITION_INSIDE 0
#define NS_STYLE_LIST_STYLE_POSITION_OUTSIDE 1
// See nsStyleSpacing
// See nsStyleMargin
#define NS_STYLE_MARGIN_SIZE_AUTO 0
// See nsStyleText

Просмотреть файл

@ -25,15 +25,22 @@
enum nsStyleStructID {
eStyleStruct_Font = 1,
eStyleStruct_Color = 2,
eStyleStruct_Spacing = 3,
eStyleStruct_List = 4,
eStyleStruct_Position = 5,
eStyleStruct_Text = 6,
eStyleStruct_Display = 7,
eStyleStruct_Table = 8,
eStyleStruct_Content = 9,
eStyleStruct_UserInterface = 10,
eStyleStruct_Print = 11
eStyleStruct_List = 3,
eStyleStruct_Position = 4,
eStyleStruct_Text = 5,
eStyleStruct_Display = 6,
eStyleStruct_Table = 7,
eStyleStruct_Content = 8,
eStyleStruct_UserInterface = 9,
eStyleStruct_Print = 10,
eStyleStruct_Margin = 11,
eStyleStruct_Padding = 12,
eStyleStruct_Border = 13,
eStyleStruct_Outline = 14,
eStyleStruct_Max = eStyleStruct_Outline,
eStyleStruct_BorderPaddingShortcut = 15 // only for use in GetStyle()
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -144,10 +144,10 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
GetButtonOuterFocusRect(aRect, rect);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Border);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mOuterFocusStyle, 0);
aDirtyRect, rect, *border, mOuterFocusStyle, 0);
}
// ---------- paint the inner focus border -------------
@ -155,10 +155,10 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
GetButtonInnerFocusRect(aRect, rect);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Border);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mInnerFocusStyle, 0);
aDirtyRect, rect, *border, mInnerFocusStyle, 0);
}
}
@ -186,8 +186,8 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
// get the styles
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)context->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border =
(const nsStyleBorder*)context->GetStyleData(eStyleStruct_Border);
const nsStyleColor* color =
(const nsStyleColor*)context->GetStyleData(eStyleStruct_Color);
@ -195,10 +195,10 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
// paint the border and background
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *color, *spacing, 0, 0);
aDirtyRect, buttonRect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *spacing, context, 0);
aDirtyRect, buttonRect, *border, context, 0);
}
@ -247,9 +247,9 @@ nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding()
nsMargin focusBorderAndPadding(0,0,0,0);
if (mOuterFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(focusBorderAndPadding)) {
nsStyleBorderPadding bPad;
mOuterFocusStyle->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad);
if (!bPad.GetBorderPadding(focusBorderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}
@ -263,12 +263,13 @@ nsButtonFrameRenderer::GetButtonBorderAndPadding()
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
nsMargin borderAndPadding(0,0,0,0);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)context ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(borderAndPadding)) {
nsMargin innerFocusBorderAndPadding(0,0,0,0);
nsStyleBorderPadding bPad;
context->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad);
if (!bPad.GetBorderPadding(innerFocusBorderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
return borderAndPadding;
return innerFocusBorderAndPadding;
}
/**
@ -281,8 +282,8 @@ nsButtonFrameRenderer::GetButtonInnerFocusMargin()
if (mInnerFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
spacing->GetMargin(innerFocusMargin);
const nsStyleMargin* margin = (const nsStyleMargin*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Margin);
margin->GetMargin(innerFocusMargin);
}
return innerFocusMargin;
@ -295,8 +296,9 @@ nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding()
if (mInnerFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(innerFocusBorderAndPadding)) {
nsStyleBorderPadding bPad;
mInnerFocusStyle->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad);
if (!bPad.GetBorderPadding(innerFocusBorderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}

Просмотреть файл

@ -830,11 +830,8 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext,
delete [] str;
// get the borderPadding for the display area
const nsStyleSpacing* dspSpacing;
mDisplayFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dspSpacing);
nsMargin dspBorderPadding;
dspBorderPadding.SizeTo(0, 0, 0, 0);
dspSpacing->CalcBorderPaddingFor(mDisplayFrame, dspBorderPadding);
nsMargin dspBorderPadding(0, 0, 0, 0);
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
nscoord frmWidth = maxWidth+dspBorderPadding.left+dspBorderPadding.right+
aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
@ -886,11 +883,8 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
REFLOW_NOISY_MSG3("mCacheSize.height:%d - %d\n", PX(mCacheSize.height), PX((aBorderPadding.top + aBorderPadding.bottom)));
// get the border and padding for the DisplayArea (block frame & textframe)
const nsStyleSpacing* dspSpacing;
aDisplayFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dspSpacing);
nsMargin dspBorderPadding;
dspBorderPadding.SizeTo(0, 0, 0, 0);
dspSpacing->CalcBorderPaddingFor(aDisplayFrame, dspBorderPadding);
nsMargin dspBorderPadding(0, 0, 0, 0);
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
// adjust the height
if (mCacheSize.height == kSizeNotSet) {
@ -1154,11 +1148,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
bailOnWidth, bailOnHeight);
if (bailOnWidth) {
#ifdef DO_REFLOW_DEBUG // check or size
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
nsMargin borderPadding;
borderPadding.SizeTo(0, 0, 0, 0);
spacing->CalcBorderPaddingFor(this, borderPadding);
nsMargin borderPadding(0, 0, 0, 0);
CalcBorderPadding(borderPadding);
UNCONSTRAINED_CHECK();
#endif
REFLOW_DEBUG_MSG3("^** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
@ -1199,11 +1190,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// get our border and padding,
// XXX - should be the same mComputedBorderPadding?
// maybe we should use that?
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
nsMargin borderPadding;
borderPadding.SizeTo(0, 0, 0, 0);
spacing->CalcBorderPaddingFor(this, borderPadding);
nsMargin borderPadding(0, 0, 0, 0);
CalcBorderPadding(borderPadding);
// Get the current sizes of the combo box child frames
mDisplayFrame->GetRect(displayRect);
@ -1480,18 +1468,12 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
}
// Get the border and padding for the dropdown
const nsStyleSpacing* dropSpacing;
mDropdownFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dropSpacing);
nsMargin dropBorderPadding;
dropBorderPadding.SizeTo(0, 0, 0, 0);
dropSpacing->CalcBorderPaddingFor(mDropdownFrame, dropBorderPadding);
nsMargin dropBorderPadding(0, 0, 0, 0);
mDropdownFrame->CalcBorderPadding(dropBorderPadding);
// get the borderPadding for the display area
const nsStyleSpacing* dspSpacing;
mDisplayFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dspSpacing);
nsMargin dspBorderPadding;
dspBorderPadding.SizeTo(0, 0, 0, 0);
dspSpacing->CalcBorderPaddingFor(mDisplayFrame, dspBorderPadding);
nsMargin dspBorderPadding(0, 0, 0, 0);
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
// Substract dropdown's borderPadding from the width of the dropdown rect
// to get the size of the content area
@ -1571,12 +1553,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
}
// get the borderPadding for the display area
const nsStyleSpacing* dspSpacing;
mDisplayFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dspSpacing);
nsMargin dspBorderPadding;
dspBorderPadding.SizeTo(0, 0, 0, 0);
dspSpacing->CalcBorderPaddingFor(mDisplayFrame, dspBorderPadding);
nsMargin dspBorderPadding(0, 0, 0, 0);
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
if (NS_UNCONSTRAINEDSIZE == firstPassState.mComputedWidth) {
mItemDisplayWidth = aDesiredSize.width - (dspBorderPadding.left + dspBorderPadding.right);

Просмотреть файл

@ -163,11 +163,11 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* borderStyle =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsMargin border;
if (!spacing->GetBorder(border)) {
if (!borderStyle->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
@ -181,7 +181,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
nsRect rect(0, yoff, mRect.width, mRect.height - yoff);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *borderStyle, 0, 0);
if (mLegendFrame) {
@ -198,7 +198,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState(clipState);
@ -212,7 +212,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState(clipState);
@ -226,14 +226,14 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState(clipState);
} else {
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, nsRect(0,0,mRect.width, mRect.height), *spacing, mStyleContext, skipSides);
aDirtyRect, nsRect(0,0,mRect.width, mRect.height), *borderStyle, mStyleContext, skipSides);
}
}
}
@ -347,10 +347,10 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext,
nsMargin legendMargin(0,0,0,0);
// reflow the legend only if needed
if (mLegendFrame) {
const nsStyleSpacing* legendSpacing;
mLegendFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) legendSpacing);
legendSpacing->GetMargin(legendMargin);
const nsStyleMargin* marginStyle;
mLegendFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) marginStyle);
marginStyle->GetMargin(legendMargin);
if (reflowLegend) {
nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
@ -482,12 +482,12 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext,
} else {
// if we don't need to reflow just get the old size
mContentFrame->GetRect(contentRect);
const nsStyleSpacing* spacing;
mContentFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
const nsStyleMargin* marginStyle;
mContentFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) marginStyle);
nsMargin m(0,0,0,0);
spacing->GetMargin(m);
marginStyle->GetMargin(m);
contentRect.Inflate(m);
}
}

Просмотреть файл

@ -925,9 +925,9 @@ nsresult nsFormControlFrame::PaintSpecialBorder(nsIPresContext* aPresContext,
if (specialBorderStyle){
// paint the border
const nsStyleSpacing* spacing = (const nsStyleSpacing*)specialBorderStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)specialBorderStyle ->GetStyleData(eStyleStruct_Border);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, aFrame,
aDirtyRect, aRect, *spacing, specialBorderStyle, 0);
aDirtyRect, aRect, *border, specialBorderStyle, 0);
}
} else {

Просмотреть файл

@ -268,13 +268,10 @@ nsGfxCheckboxControlFrame::PaintCheckBox(nsIPresContext* aPresContext,
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding(0,0,0,0);
CalcBorderPadding(borderPadding);
nsRect checkRect(0,0, mRect.width, mRect.height);
nsMargin borderPadding;
spacing->CalcBorderPaddingFor(this, borderPadding);
checkRect.Deflate(borderPadding);
const nsStyleColor* color = (const nsStyleColor*)
@ -382,8 +379,8 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
mCheckButtonFaceStyle->GetStyleData(eStyleStruct_Color);
if (myColor->mBackgroundImage.Length() > 0) {
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mCheckButtonFaceStyle->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder = (const nsStyleBorder*)
mCheckButtonFaceStyle->GetStyleData(eStyleStruct_Border);
const nsStylePosition* myPosition = (const nsStylePosition*)
mCheckButtonFaceStyle->GetStyleData(eStyleStruct_Position);
@ -395,9 +392,9 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
nsRect rect(x, y, width, height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
aDirtyRect, rect, *myColor, *myBorder, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mCheckButtonFaceStyle, 0);
aDirtyRect, rect, *myBorder, mCheckButtonFaceStyle, 0);
doDefaultPainting = PR_FALSE;
}
}

Просмотреть файл

@ -282,8 +282,8 @@ nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
if (nsnull != mRadioButtonFaceStyle) {
const nsStyleColor* myColor = (const nsStyleColor*)
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder = (const nsStyleBorder*)
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Border);
const nsStylePosition* myPosition = (const nsStylePosition*)
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Position);
@ -300,9 +300,9 @@ nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
nsStyleColor tmpColor = *myColor;
tmpColor.mBackgroundColor = myColor->mColor;
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, tmpColor, *mySpacing, 0, 0);
aDirtyRect, rect, tmpColor, *myBorder, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mRadioButtonFaceStyle, 0);
aDirtyRect, rect, *myBorder, mRadioButtonFaceStyle, 0);
}
}
}

Просмотреть файл

@ -492,11 +492,11 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
// but the real problem is the FirstChild (the AreaFrame)
// isn't being constrained properly
// Bug #17474
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
const nsStyleBorder* borderStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
nsMargin border;
border.SizeTo(0, 0, 0, 0);
spacing->CalcBorderFor(this, border);
borderStyle->CalcBorderFor(this, border);
nsRect rect;
GetRect(rect);

Просмотреть файл

@ -381,7 +381,7 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
nsMargin border;
// Get the border values
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}

Просмотреть файл

@ -800,10 +800,10 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
if (mBand.GetFloaterCount()) {
// Use the float-edge property to determine how the child block
// will interact with the floater.
const nsStyleSpacing* spacing;
aFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
switch (spacing->mFloatEdge) {
const nsStyleBorder* borderStyle;
aFrame->GetStyleData(eStyleStruct_Border,
(const nsStyleStruct*&) borderStyle);
switch (borderStyle->mFloatEdge) {
default:
case NS_STYLE_FLOAT_EDGE_CONTENT: // content and only content does runaround of floaters
// The child block will flow around the floater. Therefore
@ -819,11 +819,14 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
// The child block's border should be placed adjacent to,
// but not overlap the floater(s).
nsMargin m(0, 0, 0, 0);
spacing->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == spacing->mFloatEdge) {
const nsStyleMargin* styleMargin;
aFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) styleMargin);
styleMargin->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == borderStyle->mFloatEdge) {
// Add in border too
nsMargin b;
spacing->GetBorder(b);
borderStyle->GetBorder(b);
m += b;
}
@ -1487,7 +1490,7 @@ CalculateContainingBlock(const nsHTMLReflowState& aReflowState,
// Containing block is relative to the padding edge
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aContainingBlockWidth -= border.left + border.right;
@ -2018,15 +2021,32 @@ HaveAutoWidth(const nsHTMLReflowState& aReflowState)
static PRBool
IsPercentageAwareChild(const nsIFrame* aFrame)
{
const nsStyleSpacing* space;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct*&) space);
nsresult rv;
const nsStyleMargin* margin;
rv = aFrame->GetStyleData(eStyleStruct_Margin,(const nsStyleStruct*&) margin);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&margin->mMargin)) {
return PR_TRUE;
}
if (nsLineLayout::IsPercentageUnitSides(&space->mMargin)
|| nsLineLayout::IsPercentageUnitSides(&space->mPadding)
|| nsLineLayout::IsPercentageUnitSides(&space->mBorderRadius)) {
const nsStylePadding* padding;
rv = aFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct*&) padding);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&padding->mPadding)) {
return PR_TRUE;
}
const nsStyleBorder* border;
rv = aFrame->GetStyleData(eStyleStruct_Border,(const nsStyleStruct*&) border);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&border->mBorder)) {
return PR_TRUE;
}
@ -5929,12 +5949,9 @@ nsBlockReflowState::PlaceFloater(nsFloaterCache* aFloaterCache,
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
const nsStyleSpacing* floaterSpacing;
const nsStylePosition* floaterPosition;
floater->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)floaterDisplay);
floater->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)floaterSpacing);
floater->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&)floaterPosition);
@ -6254,18 +6271,20 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* outline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
// Paint background, border and outline
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext,
aDirtyRect, rect, *border, mStyleContext,
skipSides);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, 0);
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
}
// If overflow is hidden then set the clip rect so that children don't

Просмотреть файл

@ -58,7 +58,9 @@ nsBlockReflowContext::nsBlockReflowContext(nsIPresContext* aPresContext,
mComputeMaximumWidth(aComputeMaximumWidth),
mBlockShouldInvalidateItself(PR_FALSE)
{
mStyleSpacing = nsnull;
mStyleBorder = nsnull;
mStyleMargin = nsnull;
mStylePadding = nsnull;
if (mComputeMaximumWidth)
mMetrics.mFlags |= NS_REFLOW_CALC_MAX_WIDTH;
}
@ -137,11 +139,11 @@ nsBlockReflowContext::AlignBlockHorizontally(nscoord aWidth,
aAlign.mRightMargin = mMargin.right;
// Get style unit associated with the left and right margins
nsStyleUnit leftUnit = mStyleSpacing->mMargin.GetLeftUnit();
nsStyleUnit leftUnit = mStyleMargin->mMargin.GetLeftUnit();
if (eStyleUnit_Inherit == leftUnit) {
leftUnit = GetRealMarginLeftUnit();
}
nsStyleUnit rightUnit = mStyleSpacing->mMargin.GetRightUnit();
nsStyleUnit rightUnit = mStyleMargin->mMargin.GetRightUnit();
if (eStyleUnit_Inherit == rightUnit) {
rightUnit = GetRealMarginRightUnit();
}
@ -335,25 +337,25 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame,
}
static void
ComputeShrinkwrapMargins(const nsStyleSpacing* aStyleSpacing, nscoord aWidth, nsMargin& aMargin, nscoord& aXToUpdate) {
ComputeShrinkwrapMargins(const nsStyleMargin* aStyleMargin, nscoord aWidth, nsMargin& aMargin, nscoord& aXToUpdate) {
nscoord boxWidth = aWidth;
float leftPct = 0.0;
float rightPct = 0.0;
if (eStyleUnit_Percent == aStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Percent == aStyleMargin->mMargin.GetLeftUnit()) {
nsStyleCoord leftCoord;
aStyleSpacing->mMargin.GetLeft(leftCoord);
aStyleMargin->mMargin.GetLeft(leftCoord);
leftPct = leftCoord.GetPercentValue();
} else {
boxWidth += aMargin.left;
}
if (eStyleUnit_Percent == aStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Percent == aStyleMargin->mMargin.GetRightUnit()) {
nsStyleCoord rightCoord;
aStyleSpacing->mMargin.GetRight(rightCoord);
aStyleMargin->mMargin.GetRight(rightCoord);
rightPct = rightCoord.GetPercentValue();
} else {
@ -379,11 +381,11 @@ ComputeShrinkwrapMargins(const nsStyleSpacing* aStyleSpacing, nscoord aWidth, ns
if ((marginPct > 0.0) && (marginPct < 1.0)) {
double shrinkWrapWidth = float(boxWidth) / (1.0 - marginPct);
if (eStyleUnit_Percent == aStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Percent == aStyleMargin->mMargin.GetLeftUnit()) {
aMargin.left = NSToCoordFloor((float)(shrinkWrapWidth * leftPct));
aXToUpdate += aMargin.left;
}
if (eStyleUnit_Percent == aStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Percent == aStyleMargin->mMargin.GetRightUnit()) {
aMargin.right = NSToCoordFloor((float)(shrinkWrapWidth * rightPct));
}
}
@ -442,7 +444,9 @@ nsBlockReflowContext::DoReflowBlock(nsHTMLReflowState &aReflowState,
// from 10.3.3 to determine what to apply. At this point in the
// reflow auto left/right margins will have a zero value.
mMargin = aReflowState.mComputedMargin;
mStyleSpacing = aReflowState.mStyleSpacing;
mStyleBorder = aReflowState.mStyleBorder;
mStyleMargin = aReflowState.mStyleMargin;
mStylePadding = aReflowState.mStylePadding;
nscoord x;
nscoord y = aSpace.y + topMargin;
@ -658,7 +662,7 @@ nsBlockReflowContext::DoReflowBlock(nsHTMLReflowState &aReflowState,
// based margins. If so, we can calculate them now that we know the shrink
// wrap width
if (NS_SHRINKWRAPWIDTH == aReflowState.mComputedWidth) {
ComputeShrinkwrapMargins(aReflowState.mStyleSpacing, mMetrics.width, mMargin, mX);
ComputeShrinkwrapMargins(aReflowState.mStyleMargin, mMetrics.width, mMargin, mX);
}
return rv;
@ -771,15 +775,15 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit,
if (NS_SHRINKWRAPWIDTH == mComputedWidth) {
nscoord dummyXOffset;
// Base the margins on the max-element size
ComputeShrinkwrapMargins(mStyleSpacing, m->width, maxElemMargin, dummyXOffset);
ComputeShrinkwrapMargins(mStyleMargin, m->width, maxElemMargin, dummyXOffset);
}
// Do not allow auto margins to impact the max-element size
// since they are springy and don't really count!
if (eStyleUnit_Auto != mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Auto != mStyleMargin->mMargin.GetLeftUnit()) {
m->width += maxElemMargin.left;
}
if (eStyleUnit_Auto != mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Auto != mStyleMargin->mMargin.GetRightUnit()) {
m->width += maxElemMargin.right;
}
@ -817,9 +821,9 @@ nsBlockReflowContext::GetRealMarginLeftUnit()
NS_RELEASE(sc);
sc = psc;
if (nsnull != sc) {
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
sc->GetStyleData(eStyleStruct_Spacing);
unit = spacing->mMargin.GetLeftUnit();
const nsStyleMargin* margin = (const nsStyleMargin*)
sc->GetStyleData(eStyleStruct_Margin);
unit = margin->mMargin.GetLeftUnit();
}
}
NS_IF_RELEASE(sc);
@ -842,9 +846,9 @@ nsBlockReflowContext::GetRealMarginRightUnit()
NS_RELEASE(sc);
sc = psc;
if (nsnull != sc) {
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
sc->GetStyleData(eStyleStruct_Spacing);
unit = spacing->mMargin.GetRightUnit();
const nsStyleMargin* margin = (const nsStyleMargin*)
sc->GetStyleData(eStyleStruct_Margin);
unit = margin->mMargin.GetRightUnit();
}
}
NS_IF_RELEASE(sc);

Просмотреть файл

@ -29,7 +29,6 @@ class nsIFrame;
class nsIPresContext;
class nsLineLayout;
struct nsStylePosition;
struct nsStyleSpacing;
struct nsBlockHorizontalAlign;
/**
@ -137,7 +136,9 @@ protected:
nsIFrame* mNextRCFrame;
// Spacing style for the frame we are reflowing; only valid after reflow
const nsStyleSpacing* mStyleSpacing;
const nsStyleBorder* mStyleBorder;
const nsStyleMargin* mStyleMargin;
const nsStylePadding* mStylePadding;
nscoord mComputedWidth; // copy of reflowstate's computedWidth
nsMargin mMargin;

Просмотреть файл

@ -800,10 +800,10 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
if (mBand.GetFloaterCount()) {
// Use the float-edge property to determine how the child block
// will interact with the floater.
const nsStyleSpacing* spacing;
aFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
switch (spacing->mFloatEdge) {
const nsStyleBorder* borderStyle;
aFrame->GetStyleData(eStyleStruct_Border,
(const nsStyleStruct*&) borderStyle);
switch (borderStyle->mFloatEdge) {
default:
case NS_STYLE_FLOAT_EDGE_CONTENT: // content and only content does runaround of floaters
// The child block will flow around the floater. Therefore
@ -819,11 +819,14 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
// The child block's border should be placed adjacent to,
// but not overlap the floater(s).
nsMargin m(0, 0, 0, 0);
spacing->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == spacing->mFloatEdge) {
const nsStyleMargin* styleMargin;
aFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) styleMargin);
styleMargin->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == borderStyle->mFloatEdge) {
// Add in border too
nsMargin b;
spacing->GetBorder(b);
borderStyle->GetBorder(b);
m += b;
}
@ -1487,7 +1490,7 @@ CalculateContainingBlock(const nsHTMLReflowState& aReflowState,
// Containing block is relative to the padding edge
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aContainingBlockWidth -= border.left + border.right;
@ -2018,15 +2021,32 @@ HaveAutoWidth(const nsHTMLReflowState& aReflowState)
static PRBool
IsPercentageAwareChild(const nsIFrame* aFrame)
{
const nsStyleSpacing* space;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct*&) space);
nsresult rv;
const nsStyleMargin* margin;
rv = aFrame->GetStyleData(eStyleStruct_Margin,(const nsStyleStruct*&) margin);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&margin->mMargin)) {
return PR_TRUE;
}
if (nsLineLayout::IsPercentageUnitSides(&space->mMargin)
|| nsLineLayout::IsPercentageUnitSides(&space->mPadding)
|| nsLineLayout::IsPercentageUnitSides(&space->mBorderRadius)) {
const nsStylePadding* padding;
rv = aFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct*&) padding);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&padding->mPadding)) {
return PR_TRUE;
}
const nsStyleBorder* border;
rv = aFrame->GetStyleData(eStyleStruct_Border,(const nsStyleStruct*&) border);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&border->mBorder)) {
return PR_TRUE;
}
@ -5929,12 +5949,9 @@ nsBlockReflowState::PlaceFloater(nsFloaterCache* aFloaterCache,
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
const nsStyleSpacing* floaterSpacing;
const nsStylePosition* floaterPosition;
floater->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)floaterDisplay);
floater->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)floaterSpacing);
floater->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&)floaterPosition);
@ -6254,18 +6271,20 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* outline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
// Paint background, border and outline
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext,
aDirtyRect, rect, *border, mStyleContext,
skipSides);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, 0);
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
}
// If overflow is hidden then set the clip rect so that children don't

Просмотреть файл

@ -800,10 +800,10 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
if (mBand.GetFloaterCount()) {
// Use the float-edge property to determine how the child block
// will interact with the floater.
const nsStyleSpacing* spacing;
aFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
switch (spacing->mFloatEdge) {
const nsStyleBorder* borderStyle;
aFrame->GetStyleData(eStyleStruct_Border,
(const nsStyleStruct*&) borderStyle);
switch (borderStyle->mFloatEdge) {
default:
case NS_STYLE_FLOAT_EDGE_CONTENT: // content and only content does runaround of floaters
// The child block will flow around the floater. Therefore
@ -819,11 +819,14 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
// The child block's border should be placed adjacent to,
// but not overlap the floater(s).
nsMargin m(0, 0, 0, 0);
spacing->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == spacing->mFloatEdge) {
const nsStyleMargin* styleMargin;
aFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) styleMargin);
styleMargin->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == borderStyle->mFloatEdge) {
// Add in border too
nsMargin b;
spacing->GetBorder(b);
borderStyle->GetBorder(b);
m += b;
}
@ -1487,7 +1490,7 @@ CalculateContainingBlock(const nsHTMLReflowState& aReflowState,
// Containing block is relative to the padding edge
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aContainingBlockWidth -= border.left + border.right;
@ -2018,15 +2021,32 @@ HaveAutoWidth(const nsHTMLReflowState& aReflowState)
static PRBool
IsPercentageAwareChild(const nsIFrame* aFrame)
{
const nsStyleSpacing* space;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct*&) space);
nsresult rv;
const nsStyleMargin* margin;
rv = aFrame->GetStyleData(eStyleStruct_Margin,(const nsStyleStruct*&) margin);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&margin->mMargin)) {
return PR_TRUE;
}
if (nsLineLayout::IsPercentageUnitSides(&space->mMargin)
|| nsLineLayout::IsPercentageUnitSides(&space->mPadding)
|| nsLineLayout::IsPercentageUnitSides(&space->mBorderRadius)) {
const nsStylePadding* padding;
rv = aFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct*&) padding);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&padding->mPadding)) {
return PR_TRUE;
}
const nsStyleBorder* border;
rv = aFrame->GetStyleData(eStyleStruct_Border,(const nsStyleStruct*&) border);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&border->mBorder)) {
return PR_TRUE;
}
@ -5929,12 +5949,9 @@ nsBlockReflowState::PlaceFloater(nsFloaterCache* aFloaterCache,
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
const nsStyleSpacing* floaterSpacing;
const nsStylePosition* floaterPosition;
floater->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)floaterDisplay);
floater->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)floaterSpacing);
floater->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&)floaterPosition);
@ -6254,18 +6271,20 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* outline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
// Paint background, border and outline
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext,
aDirtyRect, rect, *border, mStyleContext,
skipSides);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, 0);
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
}
// If overflow is hidden then set the clip rect so that children don't

Просмотреть файл

@ -599,18 +599,20 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
}
if (hasOverflowClip) {
const nsStyleSpacing* spacing;
const nsStyleBorder* borderStyle;
const nsStylePadding* paddingStyle;
nsMargin border, padding;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
aFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderStyle);
aFrame->GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingStyle);
// XXX We don't support the 'overflow-clip' property yet so just use the
// content area (which is the default value) as the clip shape
overflowClipRect.SetRect(0, 0, frameSize.width, frameSize.height);
spacing->GetBorder(border);
borderStyle->GetBorder(border);
overflowClipRect.Deflate(border);
// XXX We need to handle percentage padding
if (spacing->GetPadding(padding)) {
if (paddingStyle->GetPadding(padding)) {
overflowClipRect.Deflate(padding);
}
}

Просмотреть файл

@ -493,6 +493,23 @@ NS_IMETHODIMP nsFrame::GetStyleData(nsStyleStructID aSID, const nsStyleStruct*&
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetStyle(nsStyleStructID aSID, nsStyleStruct& aStruct) const {
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
return mStyleContext->GetStyle(aSID, aStruct);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsFrame::CalcBorderPadding(nsMargin& aBorderPadding) const {
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
mStyleContext->CalcBorderPaddingFor(this, aBorderPadding);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsFrame::GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const
@ -624,8 +641,10 @@ nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext)
// 'overflow-clip' only applies to block-level elements and replaced
// elements that have 'overflow' set to 'hidden', and it is relative
// to the content area and applies to content only (not border or background)
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
const nsStyleBorder* borderStyle;
const nsStylePadding* paddingStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderStyle);
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingStyle);
// Start with the 'auto' values and then factor in user specified values
nsRect clipRect(0, 0, mRect.width, mRect.height);
@ -634,10 +653,10 @@ nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext)
// content area (which is the default value) as the clip shape
nsMargin border, padding;
spacing->GetBorder(border);
borderStyle->GetBorder(border);
clipRect.Deflate(border);
// XXX We need to handle percentage padding
if (spacing->GetPadding(padding)) {
if (paddingStyle->GetPadding(padding)) {
clipRect.Deflate(padding);
}
@ -2073,10 +2092,10 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
// Checks to see if the damaged rect should be infalted
// to include the outline
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
const nsStyleOutline* outline;
GetStyleData(eStyleStruct_Outline, (const nsStyleStruct*&)outline);
nscoord width;
spacing->GetOutlineWidth(width);
outline->GetOutlineWidth(width);
if (width > 0) {
damageRect.Inflate(width, width);
}

Просмотреть файл

@ -173,6 +173,8 @@ public:
nsIStyleContext* aContext);
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const;
NS_IMETHOD GetStyle(nsStyleStructID aSID, nsStyleStruct& aStruct) const;
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const;
NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,

Просмотреть файл

@ -73,16 +73,18 @@ nsHTMLContainerFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* outline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *border, mStyleContext, skipSides);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, 0);
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
// The sole purpose of this is to trigger display
// of the selection window for Named Anchors,

Просмотреть файл

@ -304,7 +304,7 @@ CanvasFrame::Reflow(nsIPresContext* aPresContext,
nsMargin border;
nsFrameState kidState;
if (!kidReflowState.mStyleSpacing->GetBorder(border)) {
if (!kidReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
kidFrame->GetFrameState(&kidState);

Просмотреть файл

@ -179,8 +179,12 @@ nsHTMLReflowState::Init(nsIPresContext* aPresContext,
(const nsStyleStruct*&)mStylePosition);
frame->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)mStyleDisplay);
frame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)mStyleSpacing);
frame->GetStyleData(eStyleStruct_Border,
(const nsStyleStruct*&)mStyleBorder);
frame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&)mStyleMargin);
frame->GetStyleData(eStyleStruct_Padding,
(const nsStyleStruct*&)mStylePadding);
frame->GetStyleData(eStyleStruct_Text,
(const nsStyleStruct*&)mStyleText);
mFrameType = DetermineFrameType(frame, mStylePosition, mStyleDisplay);
@ -475,10 +479,10 @@ GetNearestContainingBlock(nsIFrame* aFrame, nsMargin& aContentArea)
// Subtract off for border and padding. If it can't be computed because
// it's percentage based (for example) then just ignore it
nsStyleSpacing* spacing;
nsStyleBorderPadding bPad;
nsMargin borderPadding;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing->GetBorderPadding(borderPadding)) {
aFrame->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad);
if (bPad.GetBorderPadding(borderPadding)) {
aContentArea.left += borderPadding.left;
aContentArea.top += borderPadding.top;
aContentArea.right -= borderPadding.right;
@ -534,55 +538,55 @@ nsHTMLReflowState::CalculateHorizBorderPaddingMargin(nscoord aContainingBlockWid
nsMargin border, padding, margin;
// Get the border
if (!mStyleSpacing->GetBorder(border)) {
if (!mStyleBorder->GetBorder(border)) {
// CSS2 has no percentage borders
border.SizeTo(0, 0, 0, 0);
}
// See if the style system can provide us the padding directly
if (!mStyleSpacing->GetPadding(padding)) {
if (!mStylePadding->GetPadding(padding)) {
nsStyleCoord left, right;
// We have to compute the left and right values
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetLeftUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetLeftUnit()) {
padding.left = 0; // just ignore
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetLeftUnit(),
mStyleSpacing->mPadding.GetLeft(left),
mStylePadding->mPadding.GetLeftUnit(),
mStylePadding->mPadding.GetLeft(left),
padding.left);
}
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetRightUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetRightUnit()) {
padding.right = 0; // just ignore
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetRightUnit(),
mStyleSpacing->mPadding.GetRight(right),
mStylePadding->mPadding.GetRightUnit(),
mStylePadding->mPadding.GetRight(right),
padding.right);
}
}
// See if the style system can provide us the margin directly
if (!mStyleSpacing->GetMargin(margin)) {
if (!mStyleMargin->GetMargin(margin)) {
nsStyleCoord left, right;
// We have to compute the left and right values
if ((eStyleUnit_Auto == mStyleSpacing->mMargin.GetLeftUnit()) ||
(eStyleUnit_Inherit == mStyleSpacing->mMargin.GetLeftUnit())) {
if ((eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit()) ||
(eStyleUnit_Inherit == mStyleMargin->mMargin.GetLeftUnit())) {
margin.left = 0; // just ignore
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetLeftUnit(),
mStyleSpacing->mMargin.GetLeft(left),
mStyleMargin->mMargin.GetLeftUnit(),
mStyleMargin->mMargin.GetLeft(left),
margin.left);
}
if ((eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit()) ||
(eStyleUnit_Inherit == mStyleSpacing->mMargin.GetRightUnit())) {
if ((eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit()) ||
(eStyleUnit_Inherit == mStyleMargin->mMargin.GetRightUnit())) {
margin.right = 0; // just ignore
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetRightUnit(),
mStyleSpacing->mMargin.GetRight(right),
mStyleMargin->mMargin.GetRightUnit(),
mStyleMargin->mMargin.GetRight(right),
margin.right);
}
}
@ -843,10 +847,10 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsIPresContext* aPresContext,
// The specified offsets are relative to the absolute containing block's padding
// edge, and our current values are relative to the border edge so translate
nsMargin border;
const nsStyleSpacing* spacing;
const nsStyleBorder* borderStyle;
aAbsoluteContainingBlockFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (!spacing->GetBorder(border)) {
aAbsoluteContainingBlockFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderStyle);
if (!borderStyle->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aHypotheticalBox.mLeft -= border.left;
@ -964,8 +968,8 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext* aPresContext,
} else {
// Calculate any 'auto' margin values
PRBool marginLeftIsAuto = (eStyleUnit_Auto == mStyleSpacing->mMargin.GetLeftUnit());
PRBool marginRightIsAuto = (eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit());
PRBool marginLeftIsAuto = (eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit());
PRBool marginRightIsAuto = (eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit());
PRInt32 availMarginSpace = availContentSpace - mComputedWidth;
if (marginLeftIsAuto) {
@ -1167,8 +1171,8 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext* aPresContext,
} else {
// Calculate any 'auto' margin values
PRBool marginTopIsAuto = (eStyleUnit_Auto == mStyleSpacing->mMargin.GetTopUnit());
PRBool marginBottomIsAuto = (eStyleUnit_Auto == mStyleSpacing->mMargin.GetBottomUnit());
PRBool marginTopIsAuto = (eStyleUnit_Auto == mStyleMargin->mMargin.GetTopUnit());
PRBool marginBottomIsAuto = (eStyleUnit_Auto == mStyleMargin->mMargin.GetBottomUnit());
PRInt32 availMarginSpace = availContentSpace - mComputedHeight;
if (marginTopIsAuto) {
@ -1531,7 +1535,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext* aPresContext,
// inline-non-replaced elements
ComputeMargin(aContainingBlockWidth, cbrs);
ComputePadding(aContainingBlockWidth, cbrs);
if (!mStyleSpacing->GetBorder(mComputedBorderPadding)) {
if (!mStyleBorder->GetBorder(mComputedBorderPadding)) {
// CSS2 has no percentage borders
mComputedBorderPadding.SizeTo(0, 0, 0, 0);
}
@ -1858,10 +1862,10 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext,
mComputedWidth = 0; // XXX temp fix for trees
} else if (nsLayoutAtoms::tableFrame == fType.get()) {
mComputedWidth = NS_SHRINKWRAPWIDTH;
if (eStyleUnit_Auto == mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit()) {
mComputedMargin.left = NS_AUTOMARGIN;
}
if (eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit()) {
mComputedMargin.right = NS_AUTOMARGIN;
}
} else {
@ -1997,9 +2001,9 @@ nsHTMLReflowState::CalculateBlockSideMargins(nscoord aAvailWidth,
// Determine the left and right margin values. The width value
// remains constant while we do this.
PRBool isAutoLeftMargin =
eStyleUnit_Auto == mStyleSpacing->mMargin.GetLeftUnit();
eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit();
PRBool isAutoRightMargin =
eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit();
eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit();
// Calculate how much space is available for margins
nscoord availMarginSpace = aAvailWidth - aComputedWidth -
@ -2291,42 +2295,42 @@ nsHTMLReflowState::ComputeMargin(nscoord aContainingBlockWidth,
const nsHTMLReflowState* aContainingBlockRS)
{
// If style style can provide us the margin directly, then use it.
if (!mStyleSpacing->GetMargin(mComputedMargin)) {
if (!mStyleMargin->GetMargin(mComputedMargin)) {
// We have to compute the value
if (NS_UNCONSTRAINEDSIZE == aContainingBlockWidth) {
mComputedMargin.left = 0;
mComputedMargin.right = 0;
if (eStyleUnit_Coord == mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Coord == mStyleMargin->mMargin.GetLeftUnit()) {
nsStyleCoord left;
mStyleSpacing->mMargin.GetLeft(left),
mStyleMargin->mMargin.GetLeft(left),
mComputedMargin.left = left.GetCoordValue();
}
if (eStyleUnit_Coord == mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Coord == mStyleMargin->mMargin.GetRightUnit()) {
nsStyleCoord right;
mStyleSpacing->mMargin.GetRight(right),
mStyleMargin->mMargin.GetRight(right),
mComputedMargin.right = right.GetCoordValue();
}
} else {
nsStyleCoord left, right;
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetLeftUnit()) {
mComputedMargin.left = aContainingBlockRS->mComputedMargin.left;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetLeftUnit(),
mStyleSpacing->mMargin.GetLeft(left),
mStyleMargin->mMargin.GetLeftUnit(),
mStyleMargin->mMargin.GetLeft(left),
mComputedMargin.left);
}
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetRightUnit()) {
mComputedMargin.right = aContainingBlockRS->mComputedMargin.right;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetRightUnit(),
mStyleSpacing->mMargin.GetRight(right),
mStyleMargin->mMargin.GetRightUnit(),
mStyleMargin->mMargin.GetRight(right),
mComputedMargin.right);
}
}
@ -2337,20 +2341,20 @@ nsHTMLReflowState::ComputeMargin(nscoord aContainingBlockWidth,
// According to the CSS2 spec, margin percentages are
// calculated with respect to the *height* of the containing
// block when in a paginated context.
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetTopUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetTopUnit()) {
mComputedMargin.top = aContainingBlockRS->mComputedMargin.top;
} else {
ComputeVerticalValue(rs2->mComputedHeight,
mStyleSpacing->mMargin.GetTopUnit(),
mStyleSpacing->mMargin.GetTop(top),
mStyleMargin->mMargin.GetTopUnit(),
mStyleMargin->mMargin.GetTop(top),
mComputedMargin.top);
}
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetBottomUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetBottomUnit()) {
mComputedMargin.bottom = aContainingBlockRS->mComputedMargin.bottom;
} else {
ComputeVerticalValue(rs2->mComputedHeight,
mStyleSpacing->mMargin.GetBottomUnit(),
mStyleSpacing->mMargin.GetBottom(bottom),
mStyleMargin->mMargin.GetBottomUnit(),
mStyleMargin->mMargin.GetBottom(bottom),
mComputedMargin.bottom);
}
}
@ -2363,20 +2367,20 @@ nsHTMLReflowState::ComputeMargin(nscoord aContainingBlockWidth,
mComputedMargin.bottom = 0;
} else {
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetTopUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetTopUnit()) {
mComputedMargin.top = aContainingBlockRS->mComputedMargin.top;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetTopUnit(),
mStyleSpacing->mMargin.GetTop(top),
mStyleMargin->mMargin.GetTopUnit(),
mStyleMargin->mMargin.GetTop(top),
mComputedMargin.top);
}
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetBottomUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetBottomUnit()) {
mComputedMargin.bottom = aContainingBlockRS->mComputedMargin.bottom;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetBottomUnit(),
mStyleSpacing->mMargin.GetBottom(bottom),
mStyleMargin->mMargin.GetBottomUnit(),
mStyleMargin->mMargin.GetBottom(bottom),
mComputedMargin.bottom);
}
}
@ -2390,43 +2394,43 @@ nsHTMLReflowState::ComputePadding(nscoord aContainingBlockWidth,
{
// If style can provide us the padding directly, then use it.
if (!mStyleSpacing->GetPadding(mComputedPadding)) {
if (!mStylePadding->GetPadding(mComputedPadding)) {
// We have to compute the value
nsStyleCoord left, right, top, bottom;
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetLeftUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetLeftUnit()) {
mComputedPadding.left = aContainingBlockRS->mComputedPadding.left;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetLeftUnit(),
mStyleSpacing->mPadding.GetLeft(left),
mStylePadding->mPadding.GetLeftUnit(),
mStylePadding->mPadding.GetLeft(left),
mComputedPadding.left);
}
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetRightUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetRightUnit()) {
mComputedPadding.right = aContainingBlockRS->mComputedPadding.right;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetRightUnit(),
mStyleSpacing->mPadding.GetRight(right),
mStylePadding->mPadding.GetRightUnit(),
mStylePadding->mPadding.GetRight(right),
mComputedPadding.right);
}
// According to the CSS2 spec, percentages are calculated with respect to
// containing block width for padding-top and padding-bottom
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetTopUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetTopUnit()) {
mComputedPadding.top = aContainingBlockRS->mComputedPadding.top;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetTopUnit(),
mStyleSpacing->mPadding.GetTop(top),
mStylePadding->mPadding.GetTopUnit(),
mStylePadding->mPadding.GetTop(top),
mComputedPadding.top);
}
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetBottomUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetBottomUnit()) {
mComputedPadding.bottom = aContainingBlockRS->mComputedPadding.bottom;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetBottomUnit(),
mStyleSpacing->mPadding.GetBottom(bottom),
mStylePadding->mPadding.GetBottomUnit(),
mStylePadding->mPadding.GetBottom(bottom),
mComputedPadding.bottom);
}
}

Просмотреть файл

@ -33,7 +33,9 @@ class nsLineLayout;
struct nsStyleDisplay;
struct nsStylePosition;
struct nsStyleSpacing;
struct nsStyleBorder;
struct nsStyleMargin;
struct nsStylePadding;
struct nsStyleText;
struct nsHypotheticalBox;
@ -206,7 +208,9 @@ struct nsHTMLReflowState {
// Cached pointers to the various style structs used during intialization
const nsStyleDisplay* mStyleDisplay;
const nsStylePosition* mStylePosition;
const nsStyleSpacing* mStyleSpacing;
const nsStyleBorder* mStyleBorder;
const nsStyleMargin* mStyleMargin;
const nsStylePadding* mStylePadding;
const nsStyleText* mStyleText;
// This value keeps track of how deeply nested a given reflow state

Просмотреть файл

@ -621,6 +621,10 @@ public:
*/
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const = 0;
// Fill a style struct with data
NS_IMETHOD GetStyle(nsStyleStructID aSID, nsStyleStruct& aStruct) const = 0;
// Utility function: more convenient than 2 calls to GetStyleData to get border and padding
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const = 0;
/**
* These methods are to access any additional style contexts that

Просмотреть файл

@ -491,9 +491,9 @@ nsImageFrame::DisplayAltText(nsIPresContext* aPresContext,
NS_RELEASE(fm);
}
struct nsRecessedBorder : public nsStyleSpacing {
struct nsRecessedBorder : public nsStyleBorder {
nsRecessedBorder(nscoord aBorderWidth)
: nsStyleSpacing()
: nsStyleBorder()
{
nsStyleCoord styleCoord(aBorderWidth);
@ -512,7 +512,7 @@ struct nsRecessedBorder : public nsStyleSpacing {
mBorderColor[2] = 0;
mBorderColor[3] = 0;
mHasCachedMargin = mHasCachedPadding = mHasCachedBorder = PR_FALSE;
mHasCachedBorder = PR_FALSE;
}
};

Просмотреть файл

@ -45,17 +45,19 @@ nsLeafFrame::Paint(nsIPresContext* aPresContext,
if (disp->IsVisibleOrCollapsed()) {
const nsStyleColor* myColor = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* myOutline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
aDirtyRect, rect, *myColor, *myBorder, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mStyleContext, 0);
aDirtyRect, rect, *myBorder, mStyleContext, 0);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mStyleContext, 0);
aDirtyRect, rect, *myBorder, *myOutline, mStyleContext, 0);
}
}
return NS_OK;

Просмотреть файл

@ -1570,15 +1570,32 @@ nsLineLayout::IsPercentageAwareReplacedElement(nsIPresContext *aPresContext,
if (nsLayoutAtoms::brFrame != frameType.get() &&
nsLayoutAtoms::textFrame != frameType.get())
{
const nsStyleSpacing* space;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct*&) space);
nsresult rv;
const nsStyleMargin* margin;
rv = aFrame->GetStyleData(eStyleStruct_Margin,(const nsStyleStruct*&) margin);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (IsPercentageUnitSides(&margin->mMargin)) {
return PR_TRUE;
}
if (IsPercentageUnitSides(&space->mMargin)
|| IsPercentageUnitSides(&space->mPadding)
|| IsPercentageUnitSides(&space->mBorderRadius)) {
const nsStylePadding* padding;
rv = aFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct*&) padding);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (IsPercentageUnitSides(&padding->mPadding)) {
return PR_TRUE;
}
const nsStyleBorder* border;
rv = aFrame->GetStyleData(eStyleStruct_Border,(const nsStyleStruct*&) border);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (IsPercentageUnitSides(&border->mBorder)) {
return PR_TRUE;
}
@ -2705,19 +2722,19 @@ nsLineLayout::HorizontalAlignFrames(nsRect& aLineBounds,
if (nsLayoutAtoms::hrFrame == frameType.get()) {
// get the alignment from the HR frame
{
const nsStyleSpacing* spacing;
psd->mFirstFrame->mFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)spacing);
const nsStyleMargin* margin;
psd->mFirstFrame->mFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&)margin);
textAlign = NS_STYLE_TEXT_ALIGN_CENTER;
nsStyleCoord zero(nscoord(0));
nsStyleCoord temp;
if ((eStyleUnit_Coord==spacing->mMargin.GetLeftUnit()) &&
(zero==spacing->mMargin.GetLeft(temp)))
if ((eStyleUnit_Coord==margin->mMargin.GetLeftUnit()) &&
(zero==margin->mMargin.GetLeft(temp)))
{
textAlign = NS_STYLE_TEXT_ALIGN_LEFT;
}
else if ((eStyleUnit_Coord==spacing->mMargin.GetRightUnit()) &&
(zero==spacing->mMargin.GetRight(temp))) {
else if ((eStyleUnit_Coord==margin->mMargin.GetRightUnit()) &&
(zero==margin->mMargin.GetRight(temp))) {
textAlign = NS_STYLE_TEXT_ALIGN_RIGHT;
}
}

Просмотреть файл

@ -381,7 +381,7 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
nsMargin border;
// Get the border values
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}

Просмотреть файл

@ -800,10 +800,10 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
if (mBand.GetFloaterCount()) {
// Use the float-edge property to determine how the child block
// will interact with the floater.
const nsStyleSpacing* spacing;
aFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
switch (spacing->mFloatEdge) {
const nsStyleBorder* borderStyle;
aFrame->GetStyleData(eStyleStruct_Border,
(const nsStyleStruct*&) borderStyle);
switch (borderStyle->mFloatEdge) {
default:
case NS_STYLE_FLOAT_EDGE_CONTENT: // content and only content does runaround of floaters
// The child block will flow around the floater. Therefore
@ -819,11 +819,14 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
// The child block's border should be placed adjacent to,
// but not overlap the floater(s).
nsMargin m(0, 0, 0, 0);
spacing->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == spacing->mFloatEdge) {
const nsStyleMargin* styleMargin;
aFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) styleMargin);
styleMargin->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == borderStyle->mFloatEdge) {
// Add in border too
nsMargin b;
spacing->GetBorder(b);
borderStyle->GetBorder(b);
m += b;
}
@ -1487,7 +1490,7 @@ CalculateContainingBlock(const nsHTMLReflowState& aReflowState,
// Containing block is relative to the padding edge
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aContainingBlockWidth -= border.left + border.right;
@ -2018,15 +2021,32 @@ HaveAutoWidth(const nsHTMLReflowState& aReflowState)
static PRBool
IsPercentageAwareChild(const nsIFrame* aFrame)
{
const nsStyleSpacing* space;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct*&) space);
nsresult rv;
const nsStyleMargin* margin;
rv = aFrame->GetStyleData(eStyleStruct_Margin,(const nsStyleStruct*&) margin);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&margin->mMargin)) {
return PR_TRUE;
}
if (nsLineLayout::IsPercentageUnitSides(&space->mMargin)
|| nsLineLayout::IsPercentageUnitSides(&space->mPadding)
|| nsLineLayout::IsPercentageUnitSides(&space->mBorderRadius)) {
const nsStylePadding* padding;
rv = aFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct*&) padding);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&padding->mPadding)) {
return PR_TRUE;
}
const nsStyleBorder* border;
rv = aFrame->GetStyleData(eStyleStruct_Border,(const nsStyleStruct*&) border);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&border->mBorder)) {
return PR_TRUE;
}
@ -5929,12 +5949,9 @@ nsBlockReflowState::PlaceFloater(nsFloaterCache* aFloaterCache,
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
const nsStyleSpacing* floaterSpacing;
const nsStylePosition* floaterPosition;
floater->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)floaterDisplay);
floater->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)floaterSpacing);
floater->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&)floaterPosition);
@ -6254,18 +6271,20 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* outline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
// Paint background, border and outline
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext,
aDirtyRect, rect, *border, mStyleContext,
skipSides);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, 0);
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
}
// If overflow is hidden then set the clip rect so that children don't

Просмотреть файл

@ -58,7 +58,9 @@ nsBlockReflowContext::nsBlockReflowContext(nsIPresContext* aPresContext,
mComputeMaximumWidth(aComputeMaximumWidth),
mBlockShouldInvalidateItself(PR_FALSE)
{
mStyleSpacing = nsnull;
mStyleBorder = nsnull;
mStyleMargin = nsnull;
mStylePadding = nsnull;
if (mComputeMaximumWidth)
mMetrics.mFlags |= NS_REFLOW_CALC_MAX_WIDTH;
}
@ -137,11 +139,11 @@ nsBlockReflowContext::AlignBlockHorizontally(nscoord aWidth,
aAlign.mRightMargin = mMargin.right;
// Get style unit associated with the left and right margins
nsStyleUnit leftUnit = mStyleSpacing->mMargin.GetLeftUnit();
nsStyleUnit leftUnit = mStyleMargin->mMargin.GetLeftUnit();
if (eStyleUnit_Inherit == leftUnit) {
leftUnit = GetRealMarginLeftUnit();
}
nsStyleUnit rightUnit = mStyleSpacing->mMargin.GetRightUnit();
nsStyleUnit rightUnit = mStyleMargin->mMargin.GetRightUnit();
if (eStyleUnit_Inherit == rightUnit) {
rightUnit = GetRealMarginRightUnit();
}
@ -335,25 +337,25 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame,
}
static void
ComputeShrinkwrapMargins(const nsStyleSpacing* aStyleSpacing, nscoord aWidth, nsMargin& aMargin, nscoord& aXToUpdate) {
ComputeShrinkwrapMargins(const nsStyleMargin* aStyleMargin, nscoord aWidth, nsMargin& aMargin, nscoord& aXToUpdate) {
nscoord boxWidth = aWidth;
float leftPct = 0.0;
float rightPct = 0.0;
if (eStyleUnit_Percent == aStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Percent == aStyleMargin->mMargin.GetLeftUnit()) {
nsStyleCoord leftCoord;
aStyleSpacing->mMargin.GetLeft(leftCoord);
aStyleMargin->mMargin.GetLeft(leftCoord);
leftPct = leftCoord.GetPercentValue();
} else {
boxWidth += aMargin.left;
}
if (eStyleUnit_Percent == aStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Percent == aStyleMargin->mMargin.GetRightUnit()) {
nsStyleCoord rightCoord;
aStyleSpacing->mMargin.GetRight(rightCoord);
aStyleMargin->mMargin.GetRight(rightCoord);
rightPct = rightCoord.GetPercentValue();
} else {
@ -379,11 +381,11 @@ ComputeShrinkwrapMargins(const nsStyleSpacing* aStyleSpacing, nscoord aWidth, ns
if ((marginPct > 0.0) && (marginPct < 1.0)) {
double shrinkWrapWidth = float(boxWidth) / (1.0 - marginPct);
if (eStyleUnit_Percent == aStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Percent == aStyleMargin->mMargin.GetLeftUnit()) {
aMargin.left = NSToCoordFloor((float)(shrinkWrapWidth * leftPct));
aXToUpdate += aMargin.left;
}
if (eStyleUnit_Percent == aStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Percent == aStyleMargin->mMargin.GetRightUnit()) {
aMargin.right = NSToCoordFloor((float)(shrinkWrapWidth * rightPct));
}
}
@ -442,7 +444,9 @@ nsBlockReflowContext::DoReflowBlock(nsHTMLReflowState &aReflowState,
// from 10.3.3 to determine what to apply. At this point in the
// reflow auto left/right margins will have a zero value.
mMargin = aReflowState.mComputedMargin;
mStyleSpacing = aReflowState.mStyleSpacing;
mStyleBorder = aReflowState.mStyleBorder;
mStyleMargin = aReflowState.mStyleMargin;
mStylePadding = aReflowState.mStylePadding;
nscoord x;
nscoord y = aSpace.y + topMargin;
@ -658,7 +662,7 @@ nsBlockReflowContext::DoReflowBlock(nsHTMLReflowState &aReflowState,
// based margins. If so, we can calculate them now that we know the shrink
// wrap width
if (NS_SHRINKWRAPWIDTH == aReflowState.mComputedWidth) {
ComputeShrinkwrapMargins(aReflowState.mStyleSpacing, mMetrics.width, mMargin, mX);
ComputeShrinkwrapMargins(aReflowState.mStyleMargin, mMetrics.width, mMargin, mX);
}
return rv;
@ -771,15 +775,15 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit,
if (NS_SHRINKWRAPWIDTH == mComputedWidth) {
nscoord dummyXOffset;
// Base the margins on the max-element size
ComputeShrinkwrapMargins(mStyleSpacing, m->width, maxElemMargin, dummyXOffset);
ComputeShrinkwrapMargins(mStyleMargin, m->width, maxElemMargin, dummyXOffset);
}
// Do not allow auto margins to impact the max-element size
// since they are springy and don't really count!
if (eStyleUnit_Auto != mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Auto != mStyleMargin->mMargin.GetLeftUnit()) {
m->width += maxElemMargin.left;
}
if (eStyleUnit_Auto != mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Auto != mStyleMargin->mMargin.GetRightUnit()) {
m->width += maxElemMargin.right;
}
@ -817,9 +821,9 @@ nsBlockReflowContext::GetRealMarginLeftUnit()
NS_RELEASE(sc);
sc = psc;
if (nsnull != sc) {
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
sc->GetStyleData(eStyleStruct_Spacing);
unit = spacing->mMargin.GetLeftUnit();
const nsStyleMargin* margin = (const nsStyleMargin*)
sc->GetStyleData(eStyleStruct_Margin);
unit = margin->mMargin.GetLeftUnit();
}
}
NS_IF_RELEASE(sc);
@ -842,9 +846,9 @@ nsBlockReflowContext::GetRealMarginRightUnit()
NS_RELEASE(sc);
sc = psc;
if (nsnull != sc) {
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
sc->GetStyleData(eStyleStruct_Spacing);
unit = spacing->mMargin.GetRightUnit();
const nsStyleMargin* margin = (const nsStyleMargin*)
sc->GetStyleData(eStyleStruct_Margin);
unit = margin->mMargin.GetRightUnit();
}
}
NS_IF_RELEASE(sc);

Просмотреть файл

@ -29,7 +29,6 @@ class nsIFrame;
class nsIPresContext;
class nsLineLayout;
struct nsStylePosition;
struct nsStyleSpacing;
struct nsBlockHorizontalAlign;
/**
@ -137,7 +136,9 @@ protected:
nsIFrame* mNextRCFrame;
// Spacing style for the frame we are reflowing; only valid after reflow
const nsStyleSpacing* mStyleSpacing;
const nsStyleBorder* mStyleBorder;
const nsStyleMargin* mStyleMargin;
const nsStylePadding* mStylePadding;
nscoord mComputedWidth; // copy of reflowstate's computedWidth
nsMargin mMargin;

Просмотреть файл

@ -800,10 +800,10 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
if (mBand.GetFloaterCount()) {
// Use the float-edge property to determine how the child block
// will interact with the floater.
const nsStyleSpacing* spacing;
aFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
switch (spacing->mFloatEdge) {
const nsStyleBorder* borderStyle;
aFrame->GetStyleData(eStyleStruct_Border,
(const nsStyleStruct*&) borderStyle);
switch (borderStyle->mFloatEdge) {
default:
case NS_STYLE_FLOAT_EDGE_CONTENT: // content and only content does runaround of floaters
// The child block will flow around the floater. Therefore
@ -819,11 +819,14 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
// The child block's border should be placed adjacent to,
// but not overlap the floater(s).
nsMargin m(0, 0, 0, 0);
spacing->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == spacing->mFloatEdge) {
const nsStyleMargin* styleMargin;
aFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) styleMargin);
styleMargin->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == borderStyle->mFloatEdge) {
// Add in border too
nsMargin b;
spacing->GetBorder(b);
borderStyle->GetBorder(b);
m += b;
}
@ -1487,7 +1490,7 @@ CalculateContainingBlock(const nsHTMLReflowState& aReflowState,
// Containing block is relative to the padding edge
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aContainingBlockWidth -= border.left + border.right;
@ -2018,15 +2021,32 @@ HaveAutoWidth(const nsHTMLReflowState& aReflowState)
static PRBool
IsPercentageAwareChild(const nsIFrame* aFrame)
{
const nsStyleSpacing* space;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct*&) space);
nsresult rv;
const nsStyleMargin* margin;
rv = aFrame->GetStyleData(eStyleStruct_Margin,(const nsStyleStruct*&) margin);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&margin->mMargin)) {
return PR_TRUE;
}
if (nsLineLayout::IsPercentageUnitSides(&space->mMargin)
|| nsLineLayout::IsPercentageUnitSides(&space->mPadding)
|| nsLineLayout::IsPercentageUnitSides(&space->mBorderRadius)) {
const nsStylePadding* padding;
rv = aFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct*&) padding);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&padding->mPadding)) {
return PR_TRUE;
}
const nsStyleBorder* border;
rv = aFrame->GetStyleData(eStyleStruct_Border,(const nsStyleStruct*&) border);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&border->mBorder)) {
return PR_TRUE;
}
@ -5929,12 +5949,9 @@ nsBlockReflowState::PlaceFloater(nsFloaterCache* aFloaterCache,
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
const nsStyleSpacing* floaterSpacing;
const nsStylePosition* floaterPosition;
floater->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)floaterDisplay);
floater->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)floaterSpacing);
floater->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&)floaterPosition);
@ -6254,18 +6271,20 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* outline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
// Paint background, border and outline
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext,
aDirtyRect, rect, *border, mStyleContext,
skipSides);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, 0);
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
}
// If overflow is hidden then set the clip rect so that children don't

Просмотреть файл

@ -800,10 +800,10 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
if (mBand.GetFloaterCount()) {
// Use the float-edge property to determine how the child block
// will interact with the floater.
const nsStyleSpacing* spacing;
aFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
switch (spacing->mFloatEdge) {
const nsStyleBorder* borderStyle;
aFrame->GetStyleData(eStyleStruct_Border,
(const nsStyleStruct*&) borderStyle);
switch (borderStyle->mFloatEdge) {
default:
case NS_STYLE_FLOAT_EDGE_CONTENT: // content and only content does runaround of floaters
// The child block will flow around the floater. Therefore
@ -819,11 +819,14 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
// The child block's border should be placed adjacent to,
// but not overlap the floater(s).
nsMargin m(0, 0, 0, 0);
spacing->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == spacing->mFloatEdge) {
const nsStyleMargin* styleMargin;
aFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) styleMargin);
styleMargin->GetMargin(m); // XXX percentage margins
if (NS_STYLE_FLOAT_EDGE_PADDING == borderStyle->mFloatEdge) {
// Add in border too
nsMargin b;
spacing->GetBorder(b);
borderStyle->GetBorder(b);
m += b;
}
@ -1487,7 +1490,7 @@ CalculateContainingBlock(const nsHTMLReflowState& aReflowState,
// Containing block is relative to the padding edge
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aContainingBlockWidth -= border.left + border.right;
@ -2018,15 +2021,32 @@ HaveAutoWidth(const nsHTMLReflowState& aReflowState)
static PRBool
IsPercentageAwareChild(const nsIFrame* aFrame)
{
const nsStyleSpacing* space;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct*&) space);
nsresult rv;
const nsStyleMargin* margin;
rv = aFrame->GetStyleData(eStyleStruct_Margin,(const nsStyleStruct*&) margin);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&margin->mMargin)) {
return PR_TRUE;
}
if (nsLineLayout::IsPercentageUnitSides(&space->mMargin)
|| nsLineLayout::IsPercentageUnitSides(&space->mPadding)
|| nsLineLayout::IsPercentageUnitSides(&space->mBorderRadius)) {
const nsStylePadding* padding;
rv = aFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct*&) padding);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&padding->mPadding)) {
return PR_TRUE;
}
const nsStyleBorder* border;
rv = aFrame->GetStyleData(eStyleStruct_Border,(const nsStyleStruct*&) border);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (nsLineLayout::IsPercentageUnitSides(&border->mBorder)) {
return PR_TRUE;
}
@ -5929,12 +5949,9 @@ nsBlockReflowState::PlaceFloater(nsFloaterCache* aFloaterCache,
// Get the type of floater
const nsStyleDisplay* floaterDisplay;
const nsStyleSpacing* floaterSpacing;
const nsStylePosition* floaterPosition;
floater->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)floaterDisplay);
floater->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)floaterSpacing);
floater->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&)floaterPosition);
@ -6254,18 +6271,20 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* outline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
// Paint background, border and outline
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext,
aDirtyRect, rect, *border, mStyleContext,
skipSides);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, 0);
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
}
// If overflow is hidden then set the clip rect so that children don't

Просмотреть файл

@ -599,18 +599,20 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
}
if (hasOverflowClip) {
const nsStyleSpacing* spacing;
const nsStyleBorder* borderStyle;
const nsStylePadding* paddingStyle;
nsMargin border, padding;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
aFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderStyle);
aFrame->GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingStyle);
// XXX We don't support the 'overflow-clip' property yet so just use the
// content area (which is the default value) as the clip shape
overflowClipRect.SetRect(0, 0, frameSize.width, frameSize.height);
spacing->GetBorder(border);
borderStyle->GetBorder(border);
overflowClipRect.Deflate(border);
// XXX We need to handle percentage padding
if (spacing->GetPadding(padding)) {
if (paddingStyle->GetPadding(padding)) {
overflowClipRect.Deflate(padding);
}
}

Просмотреть файл

@ -493,6 +493,23 @@ NS_IMETHODIMP nsFrame::GetStyleData(nsStyleStructID aSID, const nsStyleStruct*&
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetStyle(nsStyleStructID aSID, nsStyleStruct& aStruct) const {
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
return mStyleContext->GetStyle(aSID, aStruct);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsFrame::CalcBorderPadding(nsMargin& aBorderPadding) const {
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
mStyleContext->CalcBorderPaddingFor(this, aBorderPadding);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsFrame::GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const
@ -624,8 +641,10 @@ nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext)
// 'overflow-clip' only applies to block-level elements and replaced
// elements that have 'overflow' set to 'hidden', and it is relative
// to the content area and applies to content only (not border or background)
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
const nsStyleBorder* borderStyle;
const nsStylePadding* paddingStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderStyle);
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingStyle);
// Start with the 'auto' values and then factor in user specified values
nsRect clipRect(0, 0, mRect.width, mRect.height);
@ -634,10 +653,10 @@ nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext)
// content area (which is the default value) as the clip shape
nsMargin border, padding;
spacing->GetBorder(border);
borderStyle->GetBorder(border);
clipRect.Deflate(border);
// XXX We need to handle percentage padding
if (spacing->GetPadding(padding)) {
if (paddingStyle->GetPadding(padding)) {
clipRect.Deflate(padding);
}
@ -2073,10 +2092,10 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
// Checks to see if the damaged rect should be infalted
// to include the outline
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
const nsStyleOutline* outline;
GetStyleData(eStyleStruct_Outline, (const nsStyleStruct*&)outline);
nscoord width;
spacing->GetOutlineWidth(width);
outline->GetOutlineWidth(width);
if (width > 0) {
damageRect.Inflate(width, width);
}

Просмотреть файл

@ -173,6 +173,8 @@ public:
nsIStyleContext* aContext);
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const;
NS_IMETHOD GetStyle(nsStyleStructID aSID, nsStyleStruct& aStruct) const;
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const;
NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,

Просмотреть файл

@ -133,15 +133,15 @@ HRuleFrame::Paint(nsIPresContext* aPresContext,
if (!noShadeAttribute) {
nsRect rect(x0, y0, width, height);
const nsStyleSpacing* spacing =
(nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
color = (nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext,
this,aDirtyRect, rect, *color,
*spacing, 0, 0);
*border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext,
this,aDirtyRect, rect, *spacing,
this,aDirtyRect, rect, *border,
mStyleContext, 0);
} else {
nscolor colors[2];

Просмотреть файл

@ -73,16 +73,18 @@ nsHTMLContainerFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* outline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *border, mStyleContext, skipSides);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, 0);
aDirtyRect, rect, *border, *outline, mStyleContext, 0);
// The sole purpose of this is to trigger display
// of the selection window for Named Anchors,

Просмотреть файл

@ -304,7 +304,7 @@ CanvasFrame::Reflow(nsIPresContext* aPresContext,
nsMargin border;
nsFrameState kidState;
if (!kidReflowState.mStyleSpacing->GetBorder(border)) {
if (!kidReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
kidFrame->GetFrameState(&kidState);

Просмотреть файл

@ -179,8 +179,12 @@ nsHTMLReflowState::Init(nsIPresContext* aPresContext,
(const nsStyleStruct*&)mStylePosition);
frame->GetStyleData(eStyleStruct_Display,
(const nsStyleStruct*&)mStyleDisplay);
frame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)mStyleSpacing);
frame->GetStyleData(eStyleStruct_Border,
(const nsStyleStruct*&)mStyleBorder);
frame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&)mStyleMargin);
frame->GetStyleData(eStyleStruct_Padding,
(const nsStyleStruct*&)mStylePadding);
frame->GetStyleData(eStyleStruct_Text,
(const nsStyleStruct*&)mStyleText);
mFrameType = DetermineFrameType(frame, mStylePosition, mStyleDisplay);
@ -475,10 +479,10 @@ GetNearestContainingBlock(nsIFrame* aFrame, nsMargin& aContentArea)
// Subtract off for border and padding. If it can't be computed because
// it's percentage based (for example) then just ignore it
nsStyleSpacing* spacing;
nsStyleBorderPadding bPad;
nsMargin borderPadding;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing->GetBorderPadding(borderPadding)) {
aFrame->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad);
if (bPad.GetBorderPadding(borderPadding)) {
aContentArea.left += borderPadding.left;
aContentArea.top += borderPadding.top;
aContentArea.right -= borderPadding.right;
@ -534,55 +538,55 @@ nsHTMLReflowState::CalculateHorizBorderPaddingMargin(nscoord aContainingBlockWid
nsMargin border, padding, margin;
// Get the border
if (!mStyleSpacing->GetBorder(border)) {
if (!mStyleBorder->GetBorder(border)) {
// CSS2 has no percentage borders
border.SizeTo(0, 0, 0, 0);
}
// See if the style system can provide us the padding directly
if (!mStyleSpacing->GetPadding(padding)) {
if (!mStylePadding->GetPadding(padding)) {
nsStyleCoord left, right;
// We have to compute the left and right values
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetLeftUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetLeftUnit()) {
padding.left = 0; // just ignore
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetLeftUnit(),
mStyleSpacing->mPadding.GetLeft(left),
mStylePadding->mPadding.GetLeftUnit(),
mStylePadding->mPadding.GetLeft(left),
padding.left);
}
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetRightUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetRightUnit()) {
padding.right = 0; // just ignore
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetRightUnit(),
mStyleSpacing->mPadding.GetRight(right),
mStylePadding->mPadding.GetRightUnit(),
mStylePadding->mPadding.GetRight(right),
padding.right);
}
}
// See if the style system can provide us the margin directly
if (!mStyleSpacing->GetMargin(margin)) {
if (!mStyleMargin->GetMargin(margin)) {
nsStyleCoord left, right;
// We have to compute the left and right values
if ((eStyleUnit_Auto == mStyleSpacing->mMargin.GetLeftUnit()) ||
(eStyleUnit_Inherit == mStyleSpacing->mMargin.GetLeftUnit())) {
if ((eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit()) ||
(eStyleUnit_Inherit == mStyleMargin->mMargin.GetLeftUnit())) {
margin.left = 0; // just ignore
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetLeftUnit(),
mStyleSpacing->mMargin.GetLeft(left),
mStyleMargin->mMargin.GetLeftUnit(),
mStyleMargin->mMargin.GetLeft(left),
margin.left);
}
if ((eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit()) ||
(eStyleUnit_Inherit == mStyleSpacing->mMargin.GetRightUnit())) {
if ((eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit()) ||
(eStyleUnit_Inherit == mStyleMargin->mMargin.GetRightUnit())) {
margin.right = 0; // just ignore
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetRightUnit(),
mStyleSpacing->mMargin.GetRight(right),
mStyleMargin->mMargin.GetRightUnit(),
mStyleMargin->mMargin.GetRight(right),
margin.right);
}
}
@ -843,10 +847,10 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsIPresContext* aPresContext,
// The specified offsets are relative to the absolute containing block's padding
// edge, and our current values are relative to the border edge so translate
nsMargin border;
const nsStyleSpacing* spacing;
const nsStyleBorder* borderStyle;
aAbsoluteContainingBlockFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (!spacing->GetBorder(border)) {
aAbsoluteContainingBlockFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderStyle);
if (!borderStyle->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aHypotheticalBox.mLeft -= border.left;
@ -964,8 +968,8 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext* aPresContext,
} else {
// Calculate any 'auto' margin values
PRBool marginLeftIsAuto = (eStyleUnit_Auto == mStyleSpacing->mMargin.GetLeftUnit());
PRBool marginRightIsAuto = (eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit());
PRBool marginLeftIsAuto = (eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit());
PRBool marginRightIsAuto = (eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit());
PRInt32 availMarginSpace = availContentSpace - mComputedWidth;
if (marginLeftIsAuto) {
@ -1167,8 +1171,8 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext* aPresContext,
} else {
// Calculate any 'auto' margin values
PRBool marginTopIsAuto = (eStyleUnit_Auto == mStyleSpacing->mMargin.GetTopUnit());
PRBool marginBottomIsAuto = (eStyleUnit_Auto == mStyleSpacing->mMargin.GetBottomUnit());
PRBool marginTopIsAuto = (eStyleUnit_Auto == mStyleMargin->mMargin.GetTopUnit());
PRBool marginBottomIsAuto = (eStyleUnit_Auto == mStyleMargin->mMargin.GetBottomUnit());
PRInt32 availMarginSpace = availContentSpace - mComputedHeight;
if (marginTopIsAuto) {
@ -1531,7 +1535,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext* aPresContext,
// inline-non-replaced elements
ComputeMargin(aContainingBlockWidth, cbrs);
ComputePadding(aContainingBlockWidth, cbrs);
if (!mStyleSpacing->GetBorder(mComputedBorderPadding)) {
if (!mStyleBorder->GetBorder(mComputedBorderPadding)) {
// CSS2 has no percentage borders
mComputedBorderPadding.SizeTo(0, 0, 0, 0);
}
@ -1858,10 +1862,10 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext,
mComputedWidth = 0; // XXX temp fix for trees
} else if (nsLayoutAtoms::tableFrame == fType.get()) {
mComputedWidth = NS_SHRINKWRAPWIDTH;
if (eStyleUnit_Auto == mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit()) {
mComputedMargin.left = NS_AUTOMARGIN;
}
if (eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit()) {
mComputedMargin.right = NS_AUTOMARGIN;
}
} else {
@ -1997,9 +2001,9 @@ nsHTMLReflowState::CalculateBlockSideMargins(nscoord aAvailWidth,
// Determine the left and right margin values. The width value
// remains constant while we do this.
PRBool isAutoLeftMargin =
eStyleUnit_Auto == mStyleSpacing->mMargin.GetLeftUnit();
eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit();
PRBool isAutoRightMargin =
eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit();
eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit();
// Calculate how much space is available for margins
nscoord availMarginSpace = aAvailWidth - aComputedWidth -
@ -2291,42 +2295,42 @@ nsHTMLReflowState::ComputeMargin(nscoord aContainingBlockWidth,
const nsHTMLReflowState* aContainingBlockRS)
{
// If style style can provide us the margin directly, then use it.
if (!mStyleSpacing->GetMargin(mComputedMargin)) {
if (!mStyleMargin->GetMargin(mComputedMargin)) {
// We have to compute the value
if (NS_UNCONSTRAINEDSIZE == aContainingBlockWidth) {
mComputedMargin.left = 0;
mComputedMargin.right = 0;
if (eStyleUnit_Coord == mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Coord == mStyleMargin->mMargin.GetLeftUnit()) {
nsStyleCoord left;
mStyleSpacing->mMargin.GetLeft(left),
mStyleMargin->mMargin.GetLeft(left),
mComputedMargin.left = left.GetCoordValue();
}
if (eStyleUnit_Coord == mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Coord == mStyleMargin->mMargin.GetRightUnit()) {
nsStyleCoord right;
mStyleSpacing->mMargin.GetRight(right),
mStyleMargin->mMargin.GetRight(right),
mComputedMargin.right = right.GetCoordValue();
}
} else {
nsStyleCoord left, right;
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetLeftUnit()) {
mComputedMargin.left = aContainingBlockRS->mComputedMargin.left;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetLeftUnit(),
mStyleSpacing->mMargin.GetLeft(left),
mStyleMargin->mMargin.GetLeftUnit(),
mStyleMargin->mMargin.GetLeft(left),
mComputedMargin.left);
}
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetRightUnit()) {
mComputedMargin.right = aContainingBlockRS->mComputedMargin.right;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetRightUnit(),
mStyleSpacing->mMargin.GetRight(right),
mStyleMargin->mMargin.GetRightUnit(),
mStyleMargin->mMargin.GetRight(right),
mComputedMargin.right);
}
}
@ -2337,20 +2341,20 @@ nsHTMLReflowState::ComputeMargin(nscoord aContainingBlockWidth,
// According to the CSS2 spec, margin percentages are
// calculated with respect to the *height* of the containing
// block when in a paginated context.
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetTopUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetTopUnit()) {
mComputedMargin.top = aContainingBlockRS->mComputedMargin.top;
} else {
ComputeVerticalValue(rs2->mComputedHeight,
mStyleSpacing->mMargin.GetTopUnit(),
mStyleSpacing->mMargin.GetTop(top),
mStyleMargin->mMargin.GetTopUnit(),
mStyleMargin->mMargin.GetTop(top),
mComputedMargin.top);
}
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetBottomUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetBottomUnit()) {
mComputedMargin.bottom = aContainingBlockRS->mComputedMargin.bottom;
} else {
ComputeVerticalValue(rs2->mComputedHeight,
mStyleSpacing->mMargin.GetBottomUnit(),
mStyleSpacing->mMargin.GetBottom(bottom),
mStyleMargin->mMargin.GetBottomUnit(),
mStyleMargin->mMargin.GetBottom(bottom),
mComputedMargin.bottom);
}
}
@ -2363,20 +2367,20 @@ nsHTMLReflowState::ComputeMargin(nscoord aContainingBlockWidth,
mComputedMargin.bottom = 0;
} else {
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetTopUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetTopUnit()) {
mComputedMargin.top = aContainingBlockRS->mComputedMargin.top;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetTopUnit(),
mStyleSpacing->mMargin.GetTop(top),
mStyleMargin->mMargin.GetTopUnit(),
mStyleMargin->mMargin.GetTop(top),
mComputedMargin.top);
}
if (eStyleUnit_Inherit == mStyleSpacing->mMargin.GetBottomUnit()) {
if (eStyleUnit_Inherit == mStyleMargin->mMargin.GetBottomUnit()) {
mComputedMargin.bottom = aContainingBlockRS->mComputedMargin.bottom;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mMargin.GetBottomUnit(),
mStyleSpacing->mMargin.GetBottom(bottom),
mStyleMargin->mMargin.GetBottomUnit(),
mStyleMargin->mMargin.GetBottom(bottom),
mComputedMargin.bottom);
}
}
@ -2390,43 +2394,43 @@ nsHTMLReflowState::ComputePadding(nscoord aContainingBlockWidth,
{
// If style can provide us the padding directly, then use it.
if (!mStyleSpacing->GetPadding(mComputedPadding)) {
if (!mStylePadding->GetPadding(mComputedPadding)) {
// We have to compute the value
nsStyleCoord left, right, top, bottom;
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetLeftUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetLeftUnit()) {
mComputedPadding.left = aContainingBlockRS->mComputedPadding.left;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetLeftUnit(),
mStyleSpacing->mPadding.GetLeft(left),
mStylePadding->mPadding.GetLeftUnit(),
mStylePadding->mPadding.GetLeft(left),
mComputedPadding.left);
}
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetRightUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetRightUnit()) {
mComputedPadding.right = aContainingBlockRS->mComputedPadding.right;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetRightUnit(),
mStyleSpacing->mPadding.GetRight(right),
mStylePadding->mPadding.GetRightUnit(),
mStylePadding->mPadding.GetRight(right),
mComputedPadding.right);
}
// According to the CSS2 spec, percentages are calculated with respect to
// containing block width for padding-top and padding-bottom
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetTopUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetTopUnit()) {
mComputedPadding.top = aContainingBlockRS->mComputedPadding.top;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetTopUnit(),
mStyleSpacing->mPadding.GetTop(top),
mStylePadding->mPadding.GetTopUnit(),
mStylePadding->mPadding.GetTop(top),
mComputedPadding.top);
}
if (eStyleUnit_Inherit == mStyleSpacing->mPadding.GetBottomUnit()) {
if (eStyleUnit_Inherit == mStylePadding->mPadding.GetBottomUnit()) {
mComputedPadding.bottom = aContainingBlockRS->mComputedPadding.bottom;
} else {
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetBottomUnit(),
mStyleSpacing->mPadding.GetBottom(bottom),
mStylePadding->mPadding.GetBottomUnit(),
mStylePadding->mPadding.GetBottom(bottom),
mComputedPadding.bottom);
}
}

Просмотреть файл

@ -491,9 +491,9 @@ nsImageFrame::DisplayAltText(nsIPresContext* aPresContext,
NS_RELEASE(fm);
}
struct nsRecessedBorder : public nsStyleSpacing {
struct nsRecessedBorder : public nsStyleBorder {
nsRecessedBorder(nscoord aBorderWidth)
: nsStyleSpacing()
: nsStyleBorder()
{
nsStyleCoord styleCoord(aBorderWidth);
@ -512,7 +512,7 @@ struct nsRecessedBorder : public nsStyleSpacing {
mBorderColor[2] = 0;
mBorderColor[3] = 0;
mHasCachedMargin = mHasCachedPadding = mHasCachedBorder = PR_FALSE;
mHasCachedBorder = PR_FALSE;
}
};

Просмотреть файл

@ -45,17 +45,19 @@ nsLeafFrame::Paint(nsIPresContext* aPresContext,
if (disp->IsVisibleOrCollapsed()) {
const nsStyleColor* myColor = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder = (const nsStyleBorder*)
mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleOutline* myOutline = (const nsStyleOutline*)
mStyleContext->GetStyleData(eStyleStruct_Outline);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
aDirtyRect, rect, *myColor, *myBorder, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mStyleContext, 0);
aDirtyRect, rect, *myBorder, mStyleContext, 0);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mStyleContext, 0);
aDirtyRect, rect, *myBorder, *myOutline, mStyleContext, 0);
}
}
return NS_OK;

Просмотреть файл

@ -1570,15 +1570,32 @@ nsLineLayout::IsPercentageAwareReplacedElement(nsIPresContext *aPresContext,
if (nsLayoutAtoms::brFrame != frameType.get() &&
nsLayoutAtoms::textFrame != frameType.get())
{
const nsStyleSpacing* space;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct*&) space);
nsresult rv;
const nsStyleMargin* margin;
rv = aFrame->GetStyleData(eStyleStruct_Margin,(const nsStyleStruct*&) margin);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (IsPercentageUnitSides(&margin->mMargin)) {
return PR_TRUE;
}
if (IsPercentageUnitSides(&space->mMargin)
|| IsPercentageUnitSides(&space->mPadding)
|| IsPercentageUnitSides(&space->mBorderRadius)) {
const nsStylePadding* padding;
rv = aFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct*&) padding);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (IsPercentageUnitSides(&padding->mPadding)) {
return PR_TRUE;
}
const nsStyleBorder* border;
rv = aFrame->GetStyleData(eStyleStruct_Border,(const nsStyleStruct*&) border);
if (NS_FAILED(rv)) {
return PR_TRUE; // just to be on the safe side
}
if (IsPercentageUnitSides(&border->mBorder)) {
return PR_TRUE;
}
@ -2705,19 +2722,19 @@ nsLineLayout::HorizontalAlignFrames(nsRect& aLineBounds,
if (nsLayoutAtoms::hrFrame == frameType.get()) {
// get the alignment from the HR frame
{
const nsStyleSpacing* spacing;
psd->mFirstFrame->mFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&)spacing);
const nsStyleMargin* margin;
psd->mFirstFrame->mFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&)margin);
textAlign = NS_STYLE_TEXT_ALIGN_CENTER;
nsStyleCoord zero(nscoord(0));
nsStyleCoord temp;
if ((eStyleUnit_Coord==spacing->mMargin.GetLeftUnit()) &&
(zero==spacing->mMargin.GetLeft(temp)))
if ((eStyleUnit_Coord==margin->mMargin.GetLeftUnit()) &&
(zero==margin->mMargin.GetLeft(temp)))
{
textAlign = NS_STYLE_TEXT_ALIGN_LEFT;
}
else if ((eStyleUnit_Coord==spacing->mMargin.GetRightUnit()) &&
(zero==spacing->mMargin.GetRight(temp))) {
else if ((eStyleUnit_Coord==margin->mMargin.GetRightUnit()) &&
(zero==margin->mMargin.GetRight(temp))) {
textAlign = NS_STYLE_TEXT_ALIGN_RIGHT;
}
}

Просмотреть файл

@ -715,28 +715,28 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect,
}
// For the origin, add in the border for the frame
const nsStyleSpacing* spacing;
const nsStyleBorder* border;
nsStyleCoord coord;
frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing) {
if (eStyleUnit_Coord == spacing->mBorder.GetLeftUnit()) {
origin.x += spacing->mBorder.GetLeft(coord).GetCoordValue();
frame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border);
if (border) {
if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) {
origin.x += border->mBorder.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetTopUnit()) {
origin.y += spacing->mBorder.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) {
origin.y += border->mBorder.GetTop(coord).GetCoordValue();
}
}
// And subtract out the border for the parent
if (parent) {
const nsStyleSpacing* parentSpacing;
parent->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)parentSpacing);
if (parentSpacing) {
if (eStyleUnit_Coord == parentSpacing->mBorder.GetLeftUnit()) {
origin.x -= parentSpacing->mBorder.GetLeft(coord).GetCoordValue();
const nsStyleBorder* parentBorder;
parent->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)parentBorder);
if (parentBorder) {
if (eStyleUnit_Coord == parentBorder->mBorder.GetLeftUnit()) {
origin.x -= parentBorder->mBorder.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == parentSpacing->mBorder.GetTopUnit()) {
origin.y -= parentSpacing->mBorder.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == parentBorder->mBorder.GetTopUnit()) {
origin.y -= parentBorder->mBorder.GetTop(coord).GetCoordValue();
}
}
}
@ -2911,8 +2911,8 @@ nsGenericHTMLElement::MapImageAttributesInto(const nsIHTMLMappedAttributes* aAtt
aPresContext->GetScaledPixelsToTwips(&p2t);
nsStylePosition* pos = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)
aContext->GetMutableStyleData(eStyleStruct_Margin);
// width: value
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
@ -2939,13 +2939,13 @@ nsGenericHTMLElement::MapImageAttributesInto(const nsIHTMLMappedAttributes* aAtt
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
nsStyleCoord c(twips);
spacing->mMargin.SetLeft(c);
spacing->mMargin.SetRight(c);
margin->mMargin.SetLeft(c);
margin->mMargin.SetRight(c);
}
else if (value.GetUnit() == eHTMLUnit_Percent) {
nsStyleCoord c(value.GetPercentValue(), eStyleUnit_Percent);
spacing->mMargin.SetLeft(c);
spacing->mMargin.SetRight(c);
margin->mMargin.SetLeft(c);
margin->mMargin.SetRight(c);
}
// vspace: value
@ -2953,13 +2953,13 @@ nsGenericHTMLElement::MapImageAttributesInto(const nsIHTMLMappedAttributes* aAtt
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
nsStyleCoord c(twips);
spacing->mMargin.SetTop(c);
spacing->mMargin.SetBottom(c);
margin->mMargin.SetTop(c);
margin->mMargin.SetBottom(c);
}
else if (value.GetUnit() == eHTMLUnit_Percent) {
nsStyleCoord c(value.GetPercentValue(), eStyleUnit_Percent);
spacing->mMargin.SetTop(c);
spacing->mMargin.SetBottom(c);
margin->mMargin.SetTop(c);
margin->mMargin.SetBottom(c);
}
}
@ -2990,21 +2990,21 @@ nsGenericHTMLElement::MapImageAlignAttributeInto(const nsIHTMLMappedAttributes*
aContext->GetMutableStyleData(eStyleStruct_Display);
nsStyleText* text = (nsStyleText*)
aContext->GetMutableStyleData(eStyleStruct_Text);
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)
aContext->GetMutableStyleData(eStyleStruct_Margin);
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nsStyleCoord three(NSIntPixelsToTwips(3, p2t));
switch (align) {
case NS_STYLE_TEXT_ALIGN_LEFT:
display->mFloats = NS_STYLE_FLOAT_LEFT;
spacing->mMargin.SetLeft(three);
spacing->mMargin.SetRight(three);
margin->mMargin.SetLeft(three);
margin->mMargin.SetRight(three);
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
display->mFloats = NS_STYLE_FLOAT_RIGHT;
spacing->mMargin.SetLeft(three);
spacing->mMargin.SetRight(three);
margin->mMargin.SetLeft(three);
margin->mMargin.SetRight(three);
break;
default:
text->mVerticalAlign.SetIntValue(align, eStyleUnit_Enumerated);
@ -3053,38 +3053,39 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsIHTMLMappedAttributes*
// Fixup border-padding sums: subtract out the old size and then
// add in the new size.
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleCoord coord;
coord.SetCoordValue(twips);
spacing->mBorder.SetTop(coord);
spacing->mBorder.SetRight(coord);
spacing->mBorder.SetBottom(coord);
spacing->mBorder.SetLeft(coord);
border->mBorder.SetTop(coord);
border->mBorder.SetRight(coord);
border->mBorder.SetBottom(coord);
border->mBorder.SetLeft(coord);
spacing->SetBorderStyle(0,NS_STYLE_BORDER_STYLE_SOLID);
spacing->SetBorderStyle(1,NS_STYLE_BORDER_STYLE_SOLID);
spacing->SetBorderStyle(2,NS_STYLE_BORDER_STYLE_SOLID);
spacing->SetBorderStyle(3,NS_STYLE_BORDER_STYLE_SOLID);
border->SetBorderStyle(0,NS_STYLE_BORDER_STYLE_SOLID);
border->SetBorderStyle(1,NS_STYLE_BORDER_STYLE_SOLID);
border->SetBorderStyle(2,NS_STYLE_BORDER_STYLE_SOLID);
border->SetBorderStyle(3,NS_STYLE_BORDER_STYLE_SOLID);
// Use supplied colors if provided, otherwise use color for border
// color
if (nsnull != aBorderColors) {
spacing->SetBorderColor(0, aBorderColors[0]);
spacing->SetBorderColor(1, aBorderColors[1]);
spacing->SetBorderColor(2, aBorderColors[2]);
spacing->SetBorderColor(3, aBorderColors[3]);
border->SetBorderColor(0, aBorderColors[0]);
border->SetBorderColor(1, aBorderColors[1]);
border->SetBorderColor(2, aBorderColors[2]);
border->SetBorderColor(3, aBorderColors[3]);
}
else {
// Color is inherited from "color"
const nsStyleColor* styleColor = (const nsStyleColor*)
aContext->GetStyleData(eStyleStruct_Color);
nscolor color = styleColor->mColor;
spacing->SetBorderColor(0, color);
spacing->SetBorderColor(1, color);
spacing->SetBorderColor(2, color);
spacing->SetBorderColor(3, color);
border->SetBorderColor(0, color);
border->SetBorderColor(1, color);
border->SetBorderColor(2, color);
border->SetBorderColor(3, color);
}
}

Просмотреть файл

@ -293,9 +293,9 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext,
nsIPresContext* aPresContext)
{
if (mPart) {
nsStyleSpacing* styleSpacing = (nsStyleSpacing*)(aContext->GetMutableStyleData(eStyleStruct_Spacing));
nsStyleMargin* marginStyle = (nsStyleMargin*)(aContext->GetMutableStyleData(eStyleStruct_Margin));
if (nsnull != styleSpacing) {
if (nsnull != marginStyle) {
nsHTMLValue value;
PRInt32 attrCount;
float p2t;
@ -313,8 +313,8 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext,
bodyMarginWidth = 0;
}
nsStyleCoord widthCoord(bodyMarginWidth);
styleSpacing->mMargin.SetLeft(widthCoord);
styleSpacing->mMargin.SetRight(widthCoord);
marginStyle->mMargin.SetLeft(widthCoord);
marginStyle->mMargin.SetRight(widthCoord);
}
mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
@ -325,8 +325,8 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext,
}
nsStyleCoord heightCoord(bodyMarginHeight);
styleSpacing->mMargin.SetTop(heightCoord);
styleSpacing->mMargin.SetBottom(heightCoord);
marginStyle->mMargin.SetTop(heightCoord);
marginStyle->mMargin.SetBottom(heightCoord);
}
}
@ -363,14 +363,14 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext,
if ((0 > bodyMarginWidth) && (frameMarginWidth >= 0)) {
nsStyleCoord widthCoord(frameMarginWidth);
styleSpacing->mMargin.SetLeft(widthCoord);
styleSpacing->mMargin.SetRight(widthCoord);
marginStyle->mMargin.SetLeft(widthCoord);
marginStyle->mMargin.SetRight(widthCoord);
}
if ((0 > bodyMarginHeight) && (frameMarginHeight >= 0)) {
nsStyleCoord heightCoord(frameMarginHeight);
styleSpacing->mMargin.SetTop(heightCoord);
styleSpacing->mMargin.SetBottom(heightCoord);
marginStyle->mMargin.SetTop(heightCoord);
marginStyle->mMargin.SetBottom(heightCoord);
}
}
NS_RELEASE(container);

Просмотреть файл

@ -207,22 +207,22 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
if (eHTMLUnit_Enumerated == value.GetUnit()) {
// Map align attribute into auto side margins
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)
aContext->GetMutableStyleData(eStyleStruct_Margin);
nsStyleCoord otto(eStyleUnit_Auto);
nsStyleCoord zero(nscoord(0));
switch (value.GetIntValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
spacing->mMargin.SetLeft(zero);
spacing->mMargin.SetRight(otto);
margin->mMargin.SetLeft(zero);
margin->mMargin.SetRight(otto);
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
spacing->mMargin.SetLeft(otto);
spacing->mMargin.SetRight(zero);
margin->mMargin.SetLeft(otto);
margin->mMargin.SetRight(zero);
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
spacing->mMargin.SetLeft(otto);
spacing->mMargin.SetRight(otto);
margin->mMargin.SetLeft(otto);
margin->mMargin.SetRight(otto);
break;
}
}

Просмотреть файл

@ -314,15 +314,15 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if (NS_STYLE_FRAME_0 == frameborder ||
NS_STYLE_FRAME_NO == frameborder ||
NS_STYLE_FRAME_OFF == frameborder) {
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
if (spacing) {
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
if (border) {
nsStyleCoord coord;
coord.SetCoordValue(0);
spacing->mBorder.SetTop(coord);
spacing->mBorder.SetRight(coord);
spacing->mBorder.SetBottom(coord);
spacing->mBorder.SetLeft(coord);
border->mBorder.SetTop(coord);
border->mBorder.SetRight(coord);
border->mBorder.SetBottom(coord);
border->mBorder.SetLeft(coord);
}
}
}

Просмотреть файл

@ -1323,23 +1323,23 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
nscoord pad = NSIntPixelsToTwips(3, p2t);
// add left and right padding around the radio button via css
nsStyleSpacing* spacing = (nsStyleSpacing*) aContext->GetMutableStyleData(eStyleStruct_Spacing);
if (eStyleUnit_Null == spacing->mMargin.GetLeftUnit()) {
nsStyleMargin* margin = (nsStyleMargin*) aContext->GetMutableStyleData(eStyleStruct_Margin);
if (eStyleUnit_Null == margin->mMargin.GetLeftUnit()) {
nsStyleCoord left(pad);
spacing->mMargin.SetLeft(left);
margin->mMargin.SetLeft(left);
}
if (eStyleUnit_Null == spacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Null == margin->mMargin.GetRightUnit()) {
nsStyleCoord right(NSIntPixelsToTwips(5, p2t));
spacing->mMargin.SetRight(right);
margin->mMargin.SetRight(right);
}
// add bottom padding if backward mode
// XXX why isn't this working?
nsCompatibility mode;
aPresContext->GetCompatibilityMode(&mode);
if (eCompatibility_NavQuirks == mode) {
if (eStyleUnit_Null == spacing->mMargin.GetBottomUnit()) {
if (eStyleUnit_Null == margin->mMargin.GetBottomUnit()) {
nsStyleCoord bottom(pad);
spacing->mMargin.SetBottom(bottom);
margin->mMargin.SetBottom(bottom);
}
}
break;

Просмотреть файл

@ -1063,13 +1063,13 @@ static void
MapTableFrameInto(const nsIHTMLMappedAttributes* aAttributes,
nsIMutableStyleContext* aContext,
nsIPresContext* aPresContext,
nsStyleSpacing* aSpacing,
nsStyleBorder* aBorder,
PRUint8 aBorderStyle)
{
// set up defaults
for (PRInt32 sideX = NS_SIDE_TOP; sideX <= NS_SIDE_LEFT; sideX++) {
if (aSpacing->GetBorderStyle(sideX) == NS_STYLE_BORDER_STYLE_NONE) {
aSpacing->SetBorderStyle(sideX, aBorderStyle);
if (aBorder->GetBorderStyle(sideX) == NS_STYLE_BORDER_STYLE_NONE) {
aBorder->SetBorderStyle(sideX, aBorderStyle);
}
}
@ -1082,44 +1082,44 @@ MapTableFrameInto(const nsIHTMLMappedAttributes* aAttributes,
switch (frameValue.GetIntValue())
{
case NS_STYLE_TABLE_FRAME_NONE:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_ABOVE:
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_BELOW:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_HSIDES:
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_LEFT:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_RIGHT:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_FRAME_VSIDES:
aSpacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorder->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
break;
// BOX and BORDER are ignored, the caller has already set all the border sides
@ -1151,8 +1151,8 @@ MapTableBorderInto(const nsIHTMLMappedAttributes* aAttributes,
}
if (borderValue.GetUnit() != eHTMLUnit_Null) {
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleTable *tableStyle = (nsStyleTable*)
aContext->GetMutableStyleData(eStyleStruct_Table);
nsStyleCoord twips;
@ -1183,12 +1183,12 @@ MapTableBorderInto(const nsIHTMLMappedAttributes* aAttributes,
}
// by default, set all border sides to the specified width
spacing->mBorder.SetTop(twips);
spacing->mBorder.SetRight(twips);
spacing->mBorder.SetBottom(twips);
spacing->mBorder.SetLeft(twips);
border->mBorder.SetTop(twips);
border->mBorder.SetRight(twips);
border->mBorder.SetBottom(twips);
border->mBorder.SetLeft(twips);
// then account for the frame attribute
MapTableFrameInto(aAttributes, aContext, aPresContext, spacing,
MapTableFrameInto(aAttributes, aContext, aPresContext, border,
aBorderStyle);
}
}
@ -1219,14 +1219,14 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
aPresContext->GetPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nsStyleSpacing* spacingStyle = (nsStyleSpacing*)aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* borderStyleData = (nsStyleBorder*)aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleCoord width;
width.SetCoordValue(onePixel);
spacingStyle->mBorder.SetTop(width);
spacingStyle->mBorder.SetLeft(width);
spacingStyle->mBorder.SetBottom(width);
spacingStyle->mBorder.SetRight(width);
borderStyleData->mBorder.SetTop(width);
borderStyleData->mBorder.SetLeft(width);
borderStyleData->mBorder.SetBottom(width);
borderStyleData->mBorder.SetRight(width);
nsCompatibility mode;
aPresContext->GetCompatibilityMode(&mode);
@ -1235,10 +1235,10 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
// BG_INSET results in a border color based on background colors
// used for NavQuirks only...
spacingStyle->SetBorderStyle(NS_SIDE_TOP, borderStyle);
spacingStyle->SetBorderStyle(NS_SIDE_LEFT, borderStyle);
spacingStyle->SetBorderStyle(NS_SIDE_BOTTOM, borderStyle);
spacingStyle->SetBorderStyle(NS_SIDE_RIGHT, borderStyle);
borderStyleData->SetBorderStyle(NS_SIDE_TOP, borderStyle);
borderStyleData->SetBorderStyle(NS_SIDE_LEFT, borderStyle);
borderStyleData->SetBorderStyle(NS_SIDE_BOTTOM, borderStyle);
borderStyleData->SetBorderStyle(NS_SIDE_RIGHT, borderStyle);
}
}
else { // handle attributes for table
@ -1289,8 +1289,10 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
}
}
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* borderStyleData = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleMargin* marginStyleData = (nsStyleMargin*)
aContext->GetMutableStyleData(eStyleStruct_Margin);
// default border style is the Nav4.6 extension which uses the
// background color as the basis of the outset border. If the
@ -1312,10 +1314,10 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if ((eHTMLUnit_Color == value.GetUnit()) ||
(eHTMLUnit_ColorName == value.GetUnit())) {
nscolor color = value.GetColorValue();
spacing->SetBorderColor(0, color);
spacing->SetBorderColor(1, color);
spacing->SetBorderColor(2, color);
spacing->SetBorderColor(3, color);
borderStyleData->SetBorderColor(0, color);
borderStyleData->SetBorderColor(1, color);
borderStyleData->SetBorderColor(2, color);
borderStyleData->SetBorderColor(3, color);
borderStyle = NS_STYLE_BORDER_STYLE_OUTSET; // use css outset
}
@ -1330,8 +1332,8 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if ((NS_STYLE_TEXT_ALIGN_CENTER == value.GetIntValue()) ||
(NS_STYLE_TEXT_ALIGN_MOZ_CENTER == value.GetIntValue())) {
nsStyleCoord otto(eStyleUnit_Auto);
spacing->mMargin.SetLeft(otto);
spacing->mMargin.SetRight(otto);
marginStyleData->mMargin.SetLeft(otto);
marginStyleData->mMargin.SetRight(otto);
}
else {
nsStyleDisplay* display = (nsStyleDisplay*)
@ -1415,8 +1417,8 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), sp2t);
nsStyleCoord hspace(twips);
spacing->mMargin.SetLeft(hspace);
spacing->mMargin.SetRight(hspace);
marginStyleData->mMargin.SetLeft(hspace);
marginStyleData->mMargin.SetRight(hspace);
}
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
@ -1424,8 +1426,8 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
if (value.GetUnit() == eHTMLUnit_Pixel) {
nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), sp2t);
nsStyleCoord vspace(twips);
spacing->mMargin.SetTop(vspace);
spacing->mMargin.SetBottom(vspace);
marginStyleData->mMargin.SetTop(vspace);
marginStyleData->mMargin.SetBottom(vspace);
}
}

Просмотреть файл

@ -144,10 +144,10 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
GetButtonOuterFocusRect(aRect, rect);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Border);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mOuterFocusStyle, 0);
aDirtyRect, rect, *border, mOuterFocusStyle, 0);
}
// ---------- paint the inner focus border -------------
@ -155,10 +155,10 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
GetButtonInnerFocusRect(aRect, rect);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Border);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mInnerFocusStyle, 0);
aDirtyRect, rect, *border, mInnerFocusStyle, 0);
}
}
@ -186,8 +186,8 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
// get the styles
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)context->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border =
(const nsStyleBorder*)context->GetStyleData(eStyleStruct_Border);
const nsStyleColor* color =
(const nsStyleColor*)context->GetStyleData(eStyleStruct_Color);
@ -195,10 +195,10 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
// paint the border and background
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *color, *spacing, 0, 0);
aDirtyRect, buttonRect, *color, *border, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *spacing, context, 0);
aDirtyRect, buttonRect, *border, context, 0);
}
@ -247,9 +247,9 @@ nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding()
nsMargin focusBorderAndPadding(0,0,0,0);
if (mOuterFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(focusBorderAndPadding)) {
nsStyleBorderPadding bPad;
mOuterFocusStyle->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad);
if (!bPad.GetBorderPadding(focusBorderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}
@ -263,12 +263,13 @@ nsButtonFrameRenderer::GetButtonBorderAndPadding()
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
nsMargin borderAndPadding(0,0,0,0);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)context ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(borderAndPadding)) {
nsMargin innerFocusBorderAndPadding(0,0,0,0);
nsStyleBorderPadding bPad;
context->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad);
if (!bPad.GetBorderPadding(innerFocusBorderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
return borderAndPadding;
return innerFocusBorderAndPadding;
}
/**
@ -281,8 +282,8 @@ nsButtonFrameRenderer::GetButtonInnerFocusMargin()
if (mInnerFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
spacing->GetMargin(innerFocusMargin);
const nsStyleMargin* margin = (const nsStyleMargin*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Margin);
margin->GetMargin(innerFocusMargin);
}
return innerFocusMargin;
@ -295,8 +296,9 @@ nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding()
if (mInnerFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(innerFocusBorderAndPadding)) {
nsStyleBorderPadding bPad;
mInnerFocusStyle->GetStyle(eStyleStruct_BorderPaddingShortcut, (nsStyleStruct&)bPad);
if (!bPad.GetBorderPadding(innerFocusBorderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}

Просмотреть файл

@ -830,11 +830,8 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext,
delete [] str;
// get the borderPadding for the display area
const nsStyleSpacing* dspSpacing;
mDisplayFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dspSpacing);
nsMargin dspBorderPadding;
dspBorderPadding.SizeTo(0, 0, 0, 0);
dspSpacing->CalcBorderPaddingFor(mDisplayFrame, dspBorderPadding);
nsMargin dspBorderPadding(0, 0, 0, 0);
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
nscoord frmWidth = maxWidth+dspBorderPadding.left+dspBorderPadding.right+
aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
@ -886,11 +883,8 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
REFLOW_NOISY_MSG3("mCacheSize.height:%d - %d\n", PX(mCacheSize.height), PX((aBorderPadding.top + aBorderPadding.bottom)));
// get the border and padding for the DisplayArea (block frame & textframe)
const nsStyleSpacing* dspSpacing;
aDisplayFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dspSpacing);
nsMargin dspBorderPadding;
dspBorderPadding.SizeTo(0, 0, 0, 0);
dspSpacing->CalcBorderPaddingFor(aDisplayFrame, dspBorderPadding);
nsMargin dspBorderPadding(0, 0, 0, 0);
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
// adjust the height
if (mCacheSize.height == kSizeNotSet) {
@ -1154,11 +1148,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
bailOnWidth, bailOnHeight);
if (bailOnWidth) {
#ifdef DO_REFLOW_DEBUG // check or size
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
nsMargin borderPadding;
borderPadding.SizeTo(0, 0, 0, 0);
spacing->CalcBorderPaddingFor(this, borderPadding);
nsMargin borderPadding(0, 0, 0, 0);
CalcBorderPadding(borderPadding);
UNCONSTRAINED_CHECK();
#endif
REFLOW_DEBUG_MSG3("^** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
@ -1199,11 +1190,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// get our border and padding,
// XXX - should be the same mComputedBorderPadding?
// maybe we should use that?
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
nsMargin borderPadding;
borderPadding.SizeTo(0, 0, 0, 0);
spacing->CalcBorderPaddingFor(this, borderPadding);
nsMargin borderPadding(0, 0, 0, 0);
CalcBorderPadding(borderPadding);
// Get the current sizes of the combo box child frames
mDisplayFrame->GetRect(displayRect);
@ -1480,18 +1468,12 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
}
// Get the border and padding for the dropdown
const nsStyleSpacing* dropSpacing;
mDropdownFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dropSpacing);
nsMargin dropBorderPadding;
dropBorderPadding.SizeTo(0, 0, 0, 0);
dropSpacing->CalcBorderPaddingFor(mDropdownFrame, dropBorderPadding);
nsMargin dropBorderPadding(0, 0, 0, 0);
mDropdownFrame->CalcBorderPadding(dropBorderPadding);
// get the borderPadding for the display area
const nsStyleSpacing* dspSpacing;
mDisplayFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dspSpacing);
nsMargin dspBorderPadding;
dspBorderPadding.SizeTo(0, 0, 0, 0);
dspSpacing->CalcBorderPaddingFor(mDisplayFrame, dspBorderPadding);
nsMargin dspBorderPadding(0, 0, 0, 0);
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
// Substract dropdown's borderPadding from the width of the dropdown rect
// to get the size of the content area
@ -1571,12 +1553,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
}
// get the borderPadding for the display area
const nsStyleSpacing* dspSpacing;
mDisplayFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)dspSpacing);
nsMargin dspBorderPadding;
dspBorderPadding.SizeTo(0, 0, 0, 0);
dspSpacing->CalcBorderPaddingFor(mDisplayFrame, dspBorderPadding);
nsMargin dspBorderPadding(0, 0, 0, 0);
mDisplayFrame->CalcBorderPadding(dspBorderPadding);
if (NS_UNCONSTRAINEDSIZE == firstPassState.mComputedWidth) {
mItemDisplayWidth = aDesiredSize.width - (dspBorderPadding.left + dspBorderPadding.right);

Просмотреть файл

@ -163,11 +163,11 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* borderStyle =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsMargin border;
if (!spacing->GetBorder(border)) {
if (!borderStyle->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
@ -181,7 +181,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
nsRect rect(0, yoff, mRect.width, mRect.height - yoff);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *borderStyle, 0, 0);
if (mLegendFrame) {
@ -198,7 +198,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState(clipState);
@ -212,7 +212,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState(clipState);
@ -226,14 +226,14 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState(clipState);
} else {
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, nsRect(0,0,mRect.width, mRect.height), *spacing, mStyleContext, skipSides);
aDirtyRect, nsRect(0,0,mRect.width, mRect.height), *borderStyle, mStyleContext, skipSides);
}
}
}
@ -347,10 +347,10 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext,
nsMargin legendMargin(0,0,0,0);
// reflow the legend only if needed
if (mLegendFrame) {
const nsStyleSpacing* legendSpacing;
mLegendFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) legendSpacing);
legendSpacing->GetMargin(legendMargin);
const nsStyleMargin* marginStyle;
mLegendFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) marginStyle);
marginStyle->GetMargin(legendMargin);
if (reflowLegend) {
nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
@ -482,12 +482,12 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext,
} else {
// if we don't need to reflow just get the old size
mContentFrame->GetRect(contentRect);
const nsStyleSpacing* spacing;
mContentFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
const nsStyleMargin* marginStyle;
mContentFrame->GetStyleData(eStyleStruct_Margin,
(const nsStyleStruct*&) marginStyle);
nsMargin m(0,0,0,0);
spacing->GetMargin(m);
marginStyle->GetMargin(m);
contentRect.Inflate(m);
}
}

Просмотреть файл

@ -925,9 +925,9 @@ nsresult nsFormControlFrame::PaintSpecialBorder(nsIPresContext* aPresContext,
if (specialBorderStyle){
// paint the border
const nsStyleSpacing* spacing = (const nsStyleSpacing*)specialBorderStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border = (const nsStyleBorder*)specialBorderStyle ->GetStyleData(eStyleStruct_Border);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, aFrame,
aDirtyRect, aRect, *spacing, specialBorderStyle, 0);
aDirtyRect, aRect, *border, specialBorderStyle, 0);
}
} else {

Просмотреть файл

@ -268,13 +268,10 @@ nsGfxCheckboxControlFrame::PaintCheckBox(nsIPresContext* aPresContext,
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding(0,0,0,0);
CalcBorderPadding(borderPadding);
nsRect checkRect(0,0, mRect.width, mRect.height);
nsMargin borderPadding;
spacing->CalcBorderPaddingFor(this, borderPadding);
checkRect.Deflate(borderPadding);
const nsStyleColor* color = (const nsStyleColor*)
@ -382,8 +379,8 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
mCheckButtonFaceStyle->GetStyleData(eStyleStruct_Color);
if (myColor->mBackgroundImage.Length() > 0) {
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mCheckButtonFaceStyle->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder = (const nsStyleBorder*)
mCheckButtonFaceStyle->GetStyleData(eStyleStruct_Border);
const nsStylePosition* myPosition = (const nsStylePosition*)
mCheckButtonFaceStyle->GetStyleData(eStyleStruct_Position);
@ -395,9 +392,9 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
nsRect rect(x, y, width, height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
aDirtyRect, rect, *myColor, *myBorder, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mCheckButtonFaceStyle, 0);
aDirtyRect, rect, *myBorder, mCheckButtonFaceStyle, 0);
doDefaultPainting = PR_FALSE;
}
}

Просмотреть файл

@ -554,11 +554,8 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext,
} else if (targetFrame == firstChildFrame) {
nsRect rect;
firstChildFrame->GetRect(rect);
const nsStyleSpacing* scrollSpacing;
firstChildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)scrollSpacing);
nsMargin scrollBorderPadding;
scrollBorderPadding.SizeTo(0, 0, 0, 0);
scrollSpacing->CalcBorderPaddingFor(firstChildFrame, scrollBorderPadding);
nsMargin scrollBorderPadding(0, 0, 0, 0);
firstChildFrame->CalcBorderPadding(scrollBorderPadding);
rect.width -= (scrollBorderPadding.left + scrollBorderPadding.right);
rect.height -= (scrollBorderPadding.top + scrollBorderPadding.bottom)*2;
printf("Inc Pass CW: %d CH: %d\n", rect.width, rect.height);
@ -741,22 +738,19 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext,
// Subtract out the borders
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
if (!aReflowState.mStyleBorder->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
border.SizeTo(0, 0, 0, 0);
}
nsMargin padding;
if (!aReflowState.mStyleSpacing->GetPadding(padding)) {
if (!aReflowState.mStylePadding->GetPadding(padding)) {
NS_NOTYETIMPLEMENTED("percentage padding");
padding.SizeTo(0, 0, 0, 0);
}
const nsStyleSpacing* scrollSpacing;
firstChildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)scrollSpacing);
nsMargin scrollBorderPadding;
scrollBorderPadding.SizeTo(0, 0, 0, 0);
scrollSpacing->CalcBorderPaddingFor(firstChildFrame, scrollBorderPadding);
nsMargin scrollBorderPadding(0, 0, 0, 0);
firstChildFrame->CalcBorderPadding(scrollBorderPadding);
mMaxWidth -= (scrollBorderPadding.left + scrollBorderPadding.right);

Просмотреть файл

@ -282,8 +282,8 @@ nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
if (nsnull != mRadioButtonFaceStyle) {
const nsStyleColor* myColor = (const nsStyleColor*)
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder = (const nsStyleBorder*)
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Border);
const nsStylePosition* myPosition = (const nsStylePosition*)
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Position);
@ -300,9 +300,9 @@ nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
nsStyleColor tmpColor = *myColor;
tmpColor.mBackgroundColor = myColor->mColor;
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, tmpColor, *mySpacing, 0, 0);
aDirtyRect, rect, tmpColor, *myBorder, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mRadioButtonFaceStyle, 0);
aDirtyRect, rect, *myBorder, mRadioButtonFaceStyle, 0);
}
}
}

Просмотреть файл

@ -1022,10 +1022,12 @@ nsGfxTextControlFrame::RedispatchMouseEventToSubDoc(nsIPresContext* aPresContext
nsMargin padding;
border.SizeTo(0, 0, 0, 0);
padding.SizeTo(0, 0, 0, 0);
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
spacing->CalcBorderFor(this, border);
spacing->CalcPaddingFor(this, padding);
const nsStyleBorder* borderStyle;
const nsStylePadding* paddingStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)paddingStyle);
borderStyle->CalcBorderFor(this, border);
paddingStyle->CalcPaddingFor(this, padding);
CalcSizeOfSubDocInTwips(border, padding, size, subBounds);
event.point.x -= (border.left + padding.left);
if (0>event.point.x) {
@ -1343,10 +1345,12 @@ nsGfxTextControlFrame::CreateSubDoc(nsRect *aSizeOfSubdocContainer)
border.SizeTo(0, 0, 0, 0);
padding.SizeTo(0, 0, 0, 0);
// Get the CSS border
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
spacing->CalcBorderFor(this, border);
spacing->CalcPaddingFor(this, padding);
const nsStyleBorder* borderStyle;
const nsStylePadding* paddingStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)paddingStyle);
borderStyle->CalcBorderFor(this, border);
paddingStyle->CalcPaddingFor(this, padding);
CalcSizeOfSubDocInTwips(border, padding, size, subBounds);
float t2p;
mFramePresContext->GetTwipsToPixels(&t2p);
@ -1620,14 +1624,14 @@ nsGfxTextControlFrame::PaintTextControl(nsIPresContext* aPresContext,
{
nsCompatibility mode;
aPresContext->GetCompatibilityMode(&mode);
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)aStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder = (const nsStyleBorder*)aStyleContext->GetStyleData(eStyleStruct_Border);
PRIntn skipSides = 0;
nsRect rect(0, 0, mRect.width, mRect.height);
const nsStyleColor* color = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *mySpacing, 0, 0);
aDirtyRect, rect, *color, *myBorder, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, aStyleContext, skipSides);
aDirtyRect, rect, *myBorder, aStyleContext, skipSides);
if (!mDocShell)
{
if (mDisplayFrame) {
@ -1961,10 +1965,10 @@ nsGfxTextControlFrame::CreateDocShell(nsIPresContext* aPresContext,
view->SetVisibility(nsViewVisibility_kHide);
}
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
const nsStyleBorder* borderStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
nsMargin border;
spacing->CalcBorderFor(this, border);
borderStyle->CalcBorderFor(this, border);
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));
@ -2091,12 +2095,6 @@ nsGfxTextControlFrame::ReflowNavQuirks(nsIPresContext* aPresContext,
nsMargin& aBorder,
nsMargin& aPadding)
{
nsMargin borderPadding;
borderPadding.SizeTo(0, 0, 0, 0);
// Get the CSS border
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
// This calculates the reflow size
// get the css size and let the frame use or override it
nsSize styleSize;
@ -2146,9 +2144,10 @@ nsGfxTextControlFrame::ReflowNavQuirks(nsIPresContext* aPresContext,
}
// In Nav Quirks mode we only add in extra size for padding
nsMargin padding;
padding.SizeTo(0, 0, 0, 0);
spacing->CalcPaddingFor(this, padding);
nsMargin padding(0, 0, 0, 0);
const nsStylePadding* paddingStyle;
GetStyleData(nsStylePadding, (const nsStyleStruct *&)paddingStyle);
paddingStyle->CalcPaddingFor(this, padding);
// Check to see if style was responsible
// for setting the height or the width
@ -2165,9 +2164,9 @@ nsGfxTextControlFrame::ReflowNavQuirks(nsIPresContext* aPresContext,
if (addBorder) {
if (CSS_NOTSET != styleSize.width ||
CSS_NOTSET != styleSize.height) { // css provides width
nsMargin border;
border.SizeTo(0, 0, 0, 0);
spacing->CalcBorderFor(this, border);
nsMargin border(0, 0, 0, 0);
GetStyleData(nsStyleBorder, (const nsStyleStruct *&)borderStyle);
borderStyle->CalcBorderFor(this, border);
if (CSS_NOTSET != styleSize.width) { // css provides width
aDesiredSize.width += border.left + border.right;
}
@ -2456,10 +2455,12 @@ nsGfxTextControlFrame::Reflow(nsIPresContext* aPresContext,
nsMargin padding;
padding.SizeTo(0, 0, 0, 0);
// Get the CSS border
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
spacing->CalcBorderFor(this, border);
spacing->CalcPaddingFor(this, padding);
const nsStyleBorder* borderStyle;
const nsStylePadding* paddingStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct *&)paddingStyle);
borderStyle->CalcBorderFor(this, border);
paddingStyle->CalcPaddingFor(this, padding);
// calculate the the desired size for the text control
// use the suggested size if it has been set

Просмотреть файл

@ -2061,10 +2061,12 @@ nsGfxTextControlFrame2::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
padding.SizeTo(0, 0, 0, 0);
// Get the CSS border
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
spacing->CalcBorderFor(this, border);
spacing->CalcPaddingFor(this, padding);
const nsStyleBorder* borderStyle;
const nsStylePadding* paddingStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
GetStyleData(eStyleStruct_Padding, (const nsStyleStruct *&)paddingStyle);
borderStyle->CalcBorderFor(this, border);
paddingStyle->CalcPaddingFor(this, padding);
nsresult rv;
if (navQuirksMode) {

Просмотреть файл

@ -492,11 +492,11 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
// but the real problem is the FirstChild (the AreaFrame)
// isn't being constrained properly
// Bug #17474
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
const nsStyleBorder* borderStyle;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
nsMargin border;
border.SizeTo(0, 0, 0, 0);
spacing->CalcBorderFor(this, border);
borderStyle->CalcBorderFor(this, border);
nsRect rect;
GetRect(rect);

Просмотреть файл

@ -589,10 +589,8 @@ nsLabelFrame::Reflow(nsIPresContext* aPresContext,
nsSize availSize(aReflowState.availableWidth, aReflowState.availableHeight);
// get border and padding
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding;
spacing->CalcBorderPaddingFor(this, borderPadding);
nsMargin borderPadding(0,0,0,0);
CalcBorderPadding(borderPadding);
if (NS_INTRINSICSIZE != availSize.width) {
availSize.width -= borderPadding.left + borderPadding.right;

Просмотреть файл

@ -9490,10 +9490,10 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext,
if (! view) { // if frame has view, will already be invalidated
// XXX Instead of calling this we should really be calling
// Invalidate on on the nsFrame (which does this)
const nsStyleSpacing* spacing;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
const nsStyleOutline* outline;
aFrame->GetStyleData(eStyleStruct_Outline, (const nsStyleStruct*&)outline);
nscoord width;
spacing->GetOutlineWidth(width);
outline->GetOutlineWidth(width);
if (width > 0) {
invalidRect.Inflate(width, width);
}

Просмотреть файл

@ -740,21 +740,26 @@ nscoord xstart,xwidth,ystart,ywidth;
void nsCSSRendering::DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const nsStyleSpacing& aSpacing,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
PRBool aDoOutline,
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
nsRect* aGap)
{
PRIntn dashLength;
nsRect dashRect, currRect;
nscoord xstart,xwidth,ystart,ywidth,temp,temp1,adjust;
PRBool bSolid = PR_TRUE;
float over = 0.0f;
PRUint8 style = aDoOutline?aSpacing.GetOutlineStyle():aSpacing.GetBorderStyle(startSide);
PRBool skippedSide = PR_FALSE;
NS_ASSERTION((aDoOutline && aOutlineStyle) || (!aDoOutline && aBorderStyle), "null params not allowed");
PRUint8 style = aDoOutline
? aOutlineStyle->GetOutlineStyle()
: aBorderStyle->GetBorderStyle(startSide);
// find out were x and y start
if(aDirtyRect.x > borderInside.x) {
@ -777,7 +782,9 @@ PRBool skippedSide = PR_FALSE;
for (PRIntn whichSide = startSide; whichSide < 4; whichSide++) {
PRUint8 prevStyle = style;
style = aDoOutline?aSpacing.GetOutlineStyle():aSpacing.GetBorderStyle(whichSide);
style = aDoOutline
? aOutlineStyle->GetOutlineStyle()
: aBorderStyle->GetBorderStyle(whichSide);
if ((1<<whichSide) & aSkipSides) {
// Skipped side
skippedSide = PR_TRUE;
@ -800,9 +807,9 @@ PRBool skippedSide = PR_FALSE;
nscolor sideColor;
if (aDoOutline) {
aSpacing.GetOutlineColor(sideColor);
aOutlineStyle->GetOutlineColor(sideColor);
} else {
if (!aSpacing.GetBorderColor(whichSide, sideColor)) {
if (!aBorderStyle->GetBorderColor(whichSide, sideColor)) {
continue; // side is transparent
}
}
@ -1488,7 +1495,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder& aBorderStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap,
@ -1569,7 +1576,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
// check for any corner that is rounded
for(i=0;i<4;i++){
if(borderRadii[i] > 0){
PaintRoundedBorder(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aBorderStyle,aStyleContext,aSkipSides,borderRadii,aGap,PR_FALSE);
PaintRoundedBorder(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,&aBorderStyle,nsnull,aStyleContext,aSkipSides,borderRadii,aGap,PR_FALSE);
return;
}
}
@ -1600,7 +1607,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
}
}
if (cnt < 4) {
DrawDashedSides(cnt, aRenderingContext,aDirtyRect,aBorderStyle, PR_FALSE,
DrawDashedSides(cnt, aRenderingContext,aDirtyRect,&aBorderStyle,nsnull, PR_FALSE,
inside, outside, aSkipSides, aGap);
}
@ -1670,7 +1677,8 @@ void nsCSSRendering::PaintOutline(nsIPresContext* aPresContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder& aBorderStyle,
const nsStyleOutline& aOutlineStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap)
@ -1682,7 +1690,7 @@ const nsStyleColor* bgColor = nsStyleUtil::FindNonTransparentBackground(aStyleCo
nscoord width;
aBorderStyle.GetOutlineWidth(width);
aOutlineStyle.GetOutlineWidth(width);
if (0 == width) {
// Empty outline
@ -1690,10 +1698,10 @@ nscoord width;
}
// get the radius for our border
aBorderStyle.mOutlineRadius.GetTop(bordStyleRadius[0]); //topleft
aBorderStyle.mOutlineRadius.GetRight(bordStyleRadius[1]); //topright
aBorderStyle.mOutlineRadius.GetBottom(bordStyleRadius[2]); //bottomright
aBorderStyle.mOutlineRadius.GetLeft(bordStyleRadius[3]); //bottomleft
aOutlineStyle.mOutlineRadius.GetTop(bordStyleRadius[0]); //topleft
aOutlineStyle.mOutlineRadius.GetRight(bordStyleRadius[1]); //topright
aOutlineStyle.mOutlineRadius.GetBottom(bordStyleRadius[2]); //bottomright
aOutlineStyle.mOutlineRadius.GetLeft(bordStyleRadius[3]); //bottomleft
for(i=0;i<4;i++) {
borderRadii[i] = 0;
@ -1744,18 +1752,18 @@ nscoord width;
// rounded version of the border
for(i=0;i<4;i++){
if(borderRadii[i] > 0){
PaintRoundedBorder(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aBorderStyle,aStyleContext,aSkipSides,borderRadii,aGap,PR_TRUE);
PaintRoundedBorder(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,nsnull,&aOutlineStyle,aStyleContext,aSkipSides,borderRadii,aGap,PR_TRUE);
aRenderingContext.PopState(clipState);
return;
}
}
PRUint8 outlineStyle = aBorderStyle.GetOutlineStyle();
PRUint8 outlineStyle = aOutlineStyle.GetOutlineStyle();
//see if any sides are dotted or dashed
if ((outlineStyle == NS_STYLE_BORDER_STYLE_DOTTED) ||
(outlineStyle == NS_STYLE_BORDER_STYLE_DASHED)) {
DrawDashedSides(0, aRenderingContext, aDirtyRect, aBorderStyle, PR_TRUE,
DrawDashedSides(0, aRenderingContext, aDirtyRect, nsnull, &aOutlineStyle, PR_TRUE,
outside, inside, aSkipSides, aGap);
aRenderingContext.PopState(clipState);
return;
@ -1771,7 +1779,7 @@ nscoord width;
nscolor outlineColor;
if (aBorderStyle.GetOutlineColor(outlineColor)) {
if (aOutlineStyle.GetOutlineColor(outlineColor)) {
DrawSide(aRenderingContext, NS_SIDE_BOTTOM,
outlineStyle,
outlineColor,
@ -2070,7 +2078,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleColor& aColor,
const nsStyleSpacing& aSpacing,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY)
{
@ -2125,7 +2133,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
nsRect paddingArea(aBorderArea);
nsMargin border;
if (!aSpacing.GetBorder(border)) {
if (!aBorder.GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
paddingArea.Deflate(border);
@ -2483,10 +2491,10 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
// is rendered over the 'border' 'padding' and 'content' areas
if (!transparentBG) {
// get the radius for our border
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
aSpacing.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
aSpacing.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
aBorder.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
aBorder.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
aBorder.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
aBorder.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
for(i=0;i<4;i++) {
borderRadii[i] = 0;
@ -2509,7 +2517,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
// rounded version of the border
for(i=0;i<4;i++){
if (borderRadii[i] > 0){
PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aColor,aSpacing,aDX,aDY,borderRadii);
PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aColor,aDX,aDY,borderRadii);
return;
}
}
@ -2563,7 +2571,6 @@ nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleColor& aColor,
const nsStyleSpacing& aSpacing,
nscoord aDX,
nscoord aDY,
PRInt16 aTheRadius[4])
@ -2652,7 +2659,8 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
PRInt16 aBorderRadius[4],
@ -2670,16 +2678,16 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
nscoord twipsPerPixel,qtwips;
float p2t;
NS_ASSERTION((aIsOutline && aOutlineStyle) || (!aIsOutline && aBorderStyle), "null params not allowed");
if (!aIsOutline) {
aBorderStyle.CalcBorderFor(aForFrame, border);
aBorderStyle->CalcBorderFor(aForFrame, border);
if ((0 == border.left) && (0 == border.right) &&
(0 == border.top) && (0 == border.bottom)) {
return;
}
} else {
nscoord width;
if (!aBorderStyle.GetOutlineWidth(width)) {
if (!aOutlineStyle->GetOutlineWidth(width)) {
return;
}
border.left = width;
@ -2720,7 +2728,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
thePath[np++].MoveTo(Icr2.mAnc2.x, Icr2.mAnc2.y);
thePath[np++].MoveTo(Icr2.mCon.x, Icr2.mCon.y);
thePath[np++].MoveTo(Icr2.mAnc1.x, Icr2.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aStyleContext,NS_SIDE_TOP,border,qtwips, aIsOutline);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_TOP,border,qtwips, aIsOutline);
}
// RIGHT LINE ----------------------------------------------------------------
LR.MidPointDivide(&cr2,&cr3);
@ -2740,7 +2748,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
thePath[np++].MoveTo(Icr4.mAnc2.x,Icr4.mAnc2.y);
thePath[np++].MoveTo(Icr4.mCon.x, Icr4.mCon.y);
thePath[np++].MoveTo(Icr4.mAnc1.x,Icr4.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aStyleContext,NS_SIDE_RIGHT,border,qtwips, aIsOutline);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_RIGHT,border,qtwips, aIsOutline);
}
// bottom line ----------------------------------------------------------------
@ -2761,7 +2769,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
thePath[np++].MoveTo(Icr3.mAnc2.x, Icr3.mAnc2.y);
thePath[np++].MoveTo(Icr3.mCon.x, Icr3.mCon.y);
thePath[np++].MoveTo(Icr3.mAnc1.x, Icr3.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aStyleContext,NS_SIDE_BOTTOM,border,qtwips, aIsOutline);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_BOTTOM,border,qtwips, aIsOutline);
}
// left line ----------------------------------------------------------------
if(0==border.left)
@ -2782,7 +2790,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
thePath[np++].MoveTo(Icr4.mCon.x, Icr4.mCon.y);
thePath[np++].MoveTo(Icr4.mAnc1.x, Icr4.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aStyleContext,NS_SIDE_LEFT,border,qtwips, aIsOutline);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_LEFT,border,qtwips, aIsOutline);
}
@ -2792,7 +2800,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
*/
void
nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext,
const nsStyleSpacing& aBorderStyle,nsIStyleContext* aStyleContext,
const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsIStyleContext* aStyleContext,
PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel,
PRBool aIsOutline)
{
@ -2803,11 +2811,12 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin
PRInt8 border_Style;
PRInt16 thickness;
NS_ASSERTION((aIsOutline && aOutlineStyle) || (!aIsOutline && aBorderStyle), "null params not allowed");
// set the style information
if (!aIsOutline) {
aBorderStyle.GetBorderColor(aSide,sideColor);
aBorderStyle->GetBorderColor(aSide,sideColor);
} else {
aBorderStyle.GetOutlineColor(sideColor);
aOutlineStyle->GetOutlineColor(sideColor);
}
aRenderingContext.SetColor ( sideColor );
@ -2838,16 +2847,15 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin
} else {
if (!aIsOutline) {
border_Style = aBorderStyle.GetBorderStyle(aSide);
border_Style = aBorderStyle->GetBorderStyle(aSide);
} else {
border_Style = aBorderStyle.GetOutlineStyle();
border_Style = aOutlineStyle->GetOutlineStyle();
}
switch (border_Style){
case NS_STYLE_BORDER_STYLE_OUTSET:
case NS_STYLE_BORDER_STYLE_INSET:
{
const nsStyleColor* bgColor = nsStyleUtil::FindNonTransparentBackground(aStyleContext);
aBorderStyle.GetBorderColor(aSide,sideColor);
aRenderingContext.SetColor ( MakeBevelColor (aSide, border_Style, bgColor->mBackgroundColor,sideColor, PR_TRUE));
}
case NS_STYLE_BORDER_STYLE_DOTTED:
@ -2892,7 +2900,6 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin
case NS_STYLE_BORDER_STYLE_GROOVE:
{
const nsStyleColor* bgColor = nsStyleUtil::FindNonTransparentBackground(aStyleContext);
aBorderStyle.GetBorderColor(aSide,sideColor);
aRenderingContext.SetColor ( MakeBevelColor (aSide, border_Style, bgColor->mBackgroundColor,sideColor, PR_TRUE));
polypath[0].x = NSToCoordRound(aPoints[0].x);

Просмотреть файл

@ -41,7 +41,7 @@ public:
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder& aBorderStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0,
@ -61,7 +61,8 @@ public:
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder& aBorderStyle,
const nsStyleOutline& aOutlineStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0);
@ -101,7 +102,7 @@ public:
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleColor& aColor,
const nsStyleSpacing& aStyle,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY);
@ -118,7 +119,8 @@ public:
static void DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const nsStyleSpacing& aSpacing,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
PRBool aDoOutline,
const nsRect& borderOutside,
const nsRect& borderInside,
@ -147,7 +149,8 @@ protected:
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleSpacing& aBorderStyle,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
nsIStyleContext* aStyleContext,
PRIntn aSkipSides,
PRInt16 aBorderRadius[4],nsRect* aGap = 0,
@ -155,7 +158,7 @@ protected:
static void RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext,
const nsStyleSpacing& aBorderStyle,nsIStyleContext* aStyleContext,
const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsIStyleContext* aStyleContext,
PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel,
PRBool aIsOutline=PR_FALSE);
@ -165,7 +168,6 @@ protected:
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleColor& aColor,
const nsStyleSpacing& aStyle,
nscoord aDX,
nscoord aDY,
PRInt16 aTheRadius[4]);

Просмотреть файл

@ -2253,33 +2253,41 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nsCSSMargin* ourMargin;
if (NS_OK == aDeclaration->GetData(kCSSMarginSID, (nsCSSStruct**)&ourMargin)) {
if (nsnull != ourMargin) {
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)aContext->GetMutableStyleData(eStyleStruct_Margin);
nsStylePadding* padding = (nsStylePadding*)aContext->GetMutableStyleData(eStyleStruct_Padding);
nsStyleBorder* border = (nsStyleBorder*)aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleOutline* outline = (nsStyleOutline*)aContext->GetMutableStyleData(eStyleStruct_Outline);
const nsStyleSpacing* parentSpacing = spacing;
const nsStyleMargin* parentMargin = margin;
const nsStylePadding* parentPadding = padding;
const nsStyleBorder* parentBorder = border;
const nsStyleOutline* parentOutline = outline;
if (nsnull != aParentContext) {
parentSpacing = (const nsStyleSpacing*)aParentContext->GetStyleData(eStyleStruct_Spacing);
parentMargin = (const nsStyleMargin*)aParentContext->GetStyleData(eStyleStruct_Margin);
parentPadding = (const nsStylePadding*)aParentContext->GetStyleData(eStyleStruct_Padding);
parentBorder = (const nsStyleBorder*)aParentContext->GetStyleData(eStyleStruct_Border);
parentOutline = (const nsStyleOutline*)aParentContext->GetStyleData(eStyleStruct_Outline);
}
// margin: length, percent, auto, inherit
if (nsnull != ourMargin->mMargin) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mMargin.GetLeft(parentCoord);
parentMargin->mMargin.GetLeft(parentCoord);
if (SetCoord(ourMargin->mMargin->mLeft, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetLeft(coord);
margin->mMargin.SetLeft(coord);
}
parentSpacing->mMargin.GetTop(parentCoord);
parentMargin->mMargin.GetTop(parentCoord);
if (SetCoord(ourMargin->mMargin->mTop, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetTop(coord);
margin->mMargin.SetTop(coord);
}
parentSpacing->mMargin.GetRight(parentCoord);
parentMargin->mMargin.GetRight(parentCoord);
if (SetCoord(ourMargin->mMargin->mRight, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetRight(coord);
margin->mMargin.SetRight(coord);
}
parentSpacing->mMargin.GetBottom(parentCoord);
parentMargin->mMargin.GetBottom(parentCoord);
if (SetCoord(ourMargin->mMargin->mBottom, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetBottom(coord);
margin->mMargin.SetBottom(coord);
}
}
@ -2287,21 +2295,21 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mPadding) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mPadding.GetLeft(parentCoord);
parentPadding->mPadding.GetLeft(parentCoord);
if (SetCoord(ourMargin->mPadding->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetLeft(coord);
padding->mPadding.SetLeft(coord);
}
parentSpacing->mPadding.GetTop(parentCoord);
parentPadding->mPadding.GetTop(parentCoord);
if (SetCoord(ourMargin->mPadding->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetTop(coord);
padding->mPadding.SetTop(coord);
}
parentSpacing->mPadding.GetRight(parentCoord);
parentPadding->mPadding.GetRight(parentCoord);
if (SetCoord(ourMargin->mPadding->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetRight(coord);
padding->mPadding.SetRight(coord);
}
parentSpacing->mPadding.GetBottom(parentCoord);
parentPadding->mPadding.GetBottom(parentCoord);
if (SetCoord(ourMargin->mPadding->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetBottom(coord);
padding->mPadding.SetBottom(coord);
}
}
@ -2310,31 +2318,31 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nsStyleCoord coord;
nsStyleCoord parentCoord;
if (SetCoord(ourMargin->mBorderWidth->mLeft, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetLeft(coord);
border->mBorder.SetLeft(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mLeft.GetUnit()) {
spacing->mBorder.SetLeft(parentSpacing->mBorder.GetLeft(coord));
border->mBorder.SetLeft(parentBorder->mBorder.GetLeft(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mTop, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetTop(coord);
border->mBorder.SetTop(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mTop.GetUnit()) {
spacing->mBorder.SetTop(parentSpacing->mBorder.GetTop(coord));
border->mBorder.SetTop(parentBorder->mBorder.GetTop(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mRight, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetRight(coord);
border->mBorder.SetRight(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mRight.GetUnit()) {
spacing->mBorder.SetRight(parentSpacing->mBorder.GetRight(coord));
border->mBorder.SetRight(parentBorder->mBorder.GetRight(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mBottom, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetBottom(coord);
border->mBorder.SetBottom(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mBottom.GetUnit()) {
spacing->mBorder.SetBottom(parentSpacing->mBorder.GetBottom(coord));
border->mBorder.SetBottom(parentBorder->mBorder.GetBottom(coord));
}
}
@ -2342,43 +2350,43 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mBorderStyle) {
nsCSSRect* ourStyle = ourMargin->mBorderStyle;
if (eCSSUnit_Enumerated == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, ourStyle->mTop.GetIntValue());
border->SetBorderStyle(NS_SIDE_TOP, ourStyle->mTop.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, parentSpacing->GetBorderStyle(NS_SIDE_TOP));
border->SetBorderStyle(NS_SIDE_TOP, parentBorder->GetBorderStyle(NS_SIDE_TOP));
}
if (eCSSUnit_Enumerated == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, ourStyle->mRight.GetIntValue());
border->SetBorderStyle(NS_SIDE_RIGHT, ourStyle->mRight.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, parentSpacing->GetBorderStyle(NS_SIDE_RIGHT));
border->SetBorderStyle(NS_SIDE_RIGHT, parentBorder->GetBorderStyle(NS_SIDE_RIGHT));
}
if (eCSSUnit_Enumerated == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, ourStyle->mBottom.GetIntValue());
border->SetBorderStyle(NS_SIDE_BOTTOM, ourStyle->mBottom.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, parentSpacing->GetBorderStyle(NS_SIDE_BOTTOM));
border->SetBorderStyle(NS_SIDE_BOTTOM, parentBorder->GetBorderStyle(NS_SIDE_BOTTOM));
}
if (eCSSUnit_Enumerated == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, ourStyle->mLeft.GetIntValue());
border->SetBorderStyle(NS_SIDE_LEFT, ourStyle->mLeft.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, parentSpacing->GetBorderStyle(NS_SIDE_LEFT));
border->SetBorderStyle(NS_SIDE_LEFT, parentBorder->GetBorderStyle(NS_SIDE_LEFT));
}
}
@ -2389,63 +2397,63 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nscolor unused = NS_RGB(0,0,0);
if (eCSSUnit_Inherit == ourBorderColor->mTop.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_TOP, borderColor)) {
spacing->SetBorderColor(NS_SIDE_TOP, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_TOP, borderColor)) {
border->SetBorderColor(NS_SIDE_TOP, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_TOP);
border->SetBorderTransparent(NS_SIDE_TOP);
}
}
else if (SetColor(ourBorderColor->mTop, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_TOP, borderColor);
border->SetBorderColor(NS_SIDE_TOP, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_TOP);
border->SetBorderTransparent(NS_SIDE_TOP);
}
if (eCSSUnit_Inherit == ourBorderColor->mRight.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_RIGHT, borderColor)) {
spacing->SetBorderColor(NS_SIDE_RIGHT, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_RIGHT, borderColor)) {
border->SetBorderColor(NS_SIDE_RIGHT, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_RIGHT);
border->SetBorderTransparent(NS_SIDE_RIGHT);
}
}
else if (SetColor(ourBorderColor->mRight, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_RIGHT, borderColor);
border->SetBorderColor(NS_SIDE_RIGHT, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mRight.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_RIGHT);
border->SetBorderTransparent(NS_SIDE_RIGHT);
}
if (eCSSUnit_Inherit == ourBorderColor->mBottom.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_BOTTOM, borderColor)) {
spacing->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_BOTTOM, borderColor)) {
border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_BOTTOM);
border->SetBorderTransparent(NS_SIDE_BOTTOM);
}
}
else if (SetColor(ourBorderColor->mBottom, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mBottom.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_BOTTOM);
border->SetBorderTransparent(NS_SIDE_BOTTOM);
}
if (eCSSUnit_Inherit == ourBorderColor->mLeft.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_LEFT, borderColor)) {
spacing->SetBorderColor(NS_SIDE_LEFT, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_LEFT, borderColor)) {
border->SetBorderColor(NS_SIDE_LEFT, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_LEFT);
border->SetBorderTransparent(NS_SIDE_LEFT);
}
}
else if (SetColor(ourBorderColor->mLeft, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_LEFT, borderColor);
border->SetBorderColor(NS_SIDE_LEFT, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mLeft.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_LEFT);
border->SetBorderTransparent(NS_SIDE_LEFT);
}
}
@ -2453,21 +2461,21 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mBorderRadius) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mBorderRadius.GetLeft(parentCoord);
parentBorder->mBorderRadius.GetLeft(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetLeft(coord);
border->mBorderRadius.SetLeft(coord);
}
parentSpacing->mBorderRadius.GetTop(parentCoord);
parentBorder->mBorderRadius.GetTop(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetTop(coord);
border->mBorderRadius.SetTop(coord);
}
parentSpacing->mBorderRadius.GetRight(parentCoord);
parentBorder->mBorderRadius.GetRight(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetRight(coord);
border->mBorderRadius.SetRight(coord);
}
parentSpacing->mBorderRadius.GetBottom(parentCoord);
parentBorder->mBorderRadius.GetBottom(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetBottom(coord);
border->mBorderRadius.SetBottom(coord);
}
}
@ -2475,26 +2483,26 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mOutlineRadius) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mOutlineRadius.GetLeft(parentCoord);
parentOutline->mOutlineRadius.GetLeft(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetLeft(coord);
outline->mOutlineRadius.SetLeft(coord);
}
parentSpacing->mOutlineRadius.GetTop(parentCoord);
parentOutline->mOutlineRadius.GetTop(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetTop(coord);
outline->mOutlineRadius.SetTop(coord);
}
parentSpacing->mOutlineRadius.GetRight(parentCoord);
parentOutline->mOutlineRadius.GetRight(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetRight(coord);
outline->mOutlineRadius.SetRight(coord);
}
parentSpacing->mOutlineRadius.GetBottom(parentCoord);
parentOutline->mOutlineRadius.GetBottom(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetBottom(coord);
outline->mOutlineRadius.SetBottom(coord);
}
}
// outline-width: length, enum, inherit
if (! SetCoord(ourMargin->mOutlineWidth, spacing->mOutlineWidth, parentSpacing->mOutlineWidth,
if (! SetCoord(ourMargin->mOutlineWidth, outline->mOutlineWidth, parentOutline->mOutlineWidth,
SETCOORD_LEH, aFont->mFont, aPresContext)) {
}
@ -2502,37 +2510,37 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nscolor outlineColor;
nscolor unused = NS_RGB(0,0,0);
if (eCSSUnit_Inherit == ourMargin->mOutlineColor.GetUnit()) {
if (parentSpacing->GetOutlineColor(outlineColor)) {
spacing->SetOutlineColor(outlineColor);
if (parentOutline->GetOutlineColor(outlineColor)) {
outline->SetOutlineColor(outlineColor);
}
else {
spacing->SetOutlineInvert();
outline->SetOutlineInvert();
}
}
else if (SetColor(ourMargin->mOutlineColor, unused, aPresContext, outlineColor)) {
spacing->SetOutlineColor(outlineColor);
outline->SetOutlineColor(outlineColor);
}
else if (eCSSUnit_Enumerated == ourMargin->mOutlineColor.GetUnit()) {
spacing->SetOutlineInvert();
outline->SetOutlineInvert();
}
// outline-style: enum, none, inherit
if (eCSSUnit_Enumerated == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(ourMargin->mOutlineStyle.GetIntValue());
outline->SetOutlineStyle(ourMargin->mOutlineStyle.GetIntValue());
}
else if (eCSSUnit_None == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(NS_STYLE_BORDER_STYLE_NONE);
outline->SetOutlineStyle(NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(parentSpacing->GetOutlineStyle());
outline->SetOutlineStyle(parentOutline->GetOutlineStyle());
}
// float-edge: enum, inherit
if (eCSSUnit_Enumerated == ourMargin->mFloatEdge.GetUnit()) {
spacing->mFloatEdge = ourMargin->mFloatEdge.GetIntValue();
border->mFloatEdge = ourMargin->mFloatEdge.GetIntValue();
}
else if (eCSSUnit_Inherit == ourMargin->mFloatEdge.GetUnit()) {
spacing->mFloatEdge = parentSpacing->mFloatEdge;
border->mFloatEdge = parentBorder->mFloatEdge;
}
}
}

Просмотреть файл

@ -844,15 +844,15 @@ nsComputedDOMStyle::GetMargin(nsAWritableString& aMargin)
nsresult GetMargins(nsIFrame *aFrame, nscoord& left, nscoord& top,
nscoord& right, nscoord& bottom)
{
const nsStyleSpacing* spacing;
const nsStyleBorder* border;
nsStyleCoord coord;
frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing) {
if (eStyleUnit_Coord == spacing->mBorder.GetLeftUnit()) {
origin.x += spacing->mBorder.GetLeft(coord).GetCoordValue();
frame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border);
if (border) {
if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) {
origin.x += border->mBorder.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetTopUnit()) {
origin.y += spacing->mBorder.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) {
origin.y += border->mBorder.GetTop(coord).GetCoordValue();
}
}
}
@ -1267,31 +1267,33 @@ nsComputedDOMStyle::GetAbsoluteFrameRect(nsIFrame *aFrame, nsRect& aRect)
}
// For the origin, add in the border for the frame
const nsStyleSpacing* spacing;
const nsStyleBorder* border;
const nsStylePadding* padding;
nsStyleCoord coord;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing) {
if (eStyleUnit_Coord == spacing->mBorder.GetLeftUnit()) {
origin.x += spacing->mBorder.GetLeft(coord).GetCoordValue();
aRect.width -= spacing->mBorder.GetLeft(coord).GetCoordValue();
//aRect.width -= spacing->mMargin.GetLeft(coord).GetCoordValue();
aRect.width -= spacing->mPadding.GetLeft(coord).GetCoordValue();
aFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border);
aFrame->GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)padding);
if (border && padding) {
if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) {
origin.x += border->mBorder.GetLeft(coord).GetCoordValue();
aRect.width -= border->mBorder.GetLeft(coord).GetCoordValue();
//aRect.width -= margin->mMargin.GetLeft(coord).GetCoordValue();
aRect.width -= padding->mPadding.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetTopUnit()) {
origin.y += spacing->mBorder.GetTop(coord).GetCoordValue();
aRect.height -= spacing->mBorder.GetTop(coord).GetCoordValue();
//aRect.height -= spacing->mMargin.GetTop(coord).GetCoordValue();
aRect.height -= spacing->mPadding.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) {
origin.y += border->mBorder.GetTop(coord).GetCoordValue();
aRect.height -= border->mBorder.GetTop(coord).GetCoordValue();
//aRect.height -= margin->mMargin.GetTop(coord).GetCoordValue();
aRect.height -= padding->mPadding.GetTop(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetRightUnit()) {
aRect.width -= spacing->mBorder.GetRight(coord).GetCoordValue();
//aRect.width -= spacing->mMargin.GetRight(coord).GetCoordValue();
aRect.width -= spacing->mPadding.GetRight(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetRightUnit()) {
aRect.width -= border->mBorder.GetRight(coord).GetCoordValue();
//aRect.width -= margin->mMargin.GetRight(coord).GetCoordValue();
aRect.width -= padding->mPadding.GetRight(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetBottomUnit()) {
aRect.height -= spacing->mBorder.GetBottom(coord).GetCoordValue();
//aRect.height -= spacing->mMargin.GetBottom(coord).GetCoordValue();
aRect.height -= spacing->mPadding.GetBottom(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetBottomUnit()) {
aRect.height -= border->mBorder.GetBottom(coord).GetCoordValue();
//aRect.height -= margin->mMargin.GetBottom(coord).GetCoordValue();
aRect.height -= padding->mPadding.GetBottom(coord).GetCoordValue();
}
}

Просмотреть файл

@ -132,13 +132,13 @@ CSSFirstLineRule::MapStyleInto(nsIMutableStyleContext* aContext,
parentContext = aContext->GetParent();
// Disable border
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
if (spacing) {
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
if (border) {
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
}
// Undo any change made to "direction"

Просмотреть файл

@ -187,19 +187,19 @@ void nsTableBorderCollapser::ComputeLeftBorderForEdgeAt(nsIPresContext* aPresCon
nsVoidArray styles;
// styles are added to the array in the order least dominant -> most dominant
// 1. table
const nsStyleSpacing *spacing;
mTableFrame.GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
const nsStyleBorder *borderStyleData;
mTableFrame.GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 2. colgroup
nsTableColFrame* colFrame;
mTableFrame.GetColumnFrame(aColIndex, colFrame);
nsIFrame* colGroupFrame;
colFrame->GetParent(&colGroupFrame);
colGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
colGroupFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 3. col
colFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
colFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 4. rowgroup
nsTableCellFrame* cellFrame = mTableFrame.GetCellInfoAt(aRowIndex, aColIndex);
nsRect rowRect(0,0,0,0);
@ -209,14 +209,14 @@ void nsTableBorderCollapser::ComputeLeftBorderForEdgeAt(nsIPresContext* aPresCon
rowFrame->GetRect(rowRect);
nsIFrame* rowGroupFrame;
rowFrame->GetParent(&rowGroupFrame);
rowGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rowGroupFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 5. row
rowFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rowFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 6. cell (need to do something smart for rowspanner with row frame)
cellFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
cellFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
ComputeBorderSegment(NS_SIDE_LEFT, &styles, *border, PR_FALSE);
// now give half the computed border to the table segment, and half to the cell
@ -293,21 +293,21 @@ void nsTableBorderCollapser::ComputeRightBorderForEdgeAt(nsIPresContext* aPresCo
}
}
}
const nsStyleSpacing *spacing;
const nsStyleBorder *borderStyleData;
if (!rightNeighborFrame) {
// if rightNeighborFrame is null, our right neighbor is the table
mTableFrame.GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
mTableFrame.GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
// 2. colgroup //XXX: need to test if we're really on a colgroup border
nsTableColFrame* colFrame = mTableFrame.GetColFrame(aColIndex);
nsIFrame* colGroupFrame;
colFrame->GetParent(&colGroupFrame);
colGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
colGroupFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 3. col
colFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
colFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 4. rowgroup
nsTableCellFrame* cellFrame = cellMap->GetCellInfoAt(aRowIndex, aColIndex);
nsRect rowRect(0,0,0,0);
@ -319,20 +319,20 @@ void nsTableBorderCollapser::ComputeRightBorderForEdgeAt(nsIPresContext* aPresCo
rowFrame->GetParent(&rowGroupFrame);
if (!rightNeighborFrame) {
// if rightNeighborFrame is null, our right neighbor is the table so we include the rowgroup and row
rowGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rowGroupFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 5. row
rowFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rowFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
// 6. cell (need to do something smart for rowspanner with row frame)
cellFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
cellFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
// 7. left edge of rightNeighborCell, if there is one
if (rightNeighborFrame) {
rightNeighborFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rightNeighborFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
ComputeBorderSegment(NS_SIDE_RIGHT, &styles, border, (nsnull != rightNeighborFrame));
// now give half the computed border to each of the two neighbors
@ -393,18 +393,18 @@ void nsTableBorderCollapser::ComputeTopBorderForEdgeAt(nsIPresContext* aPresCont
nsVoidArray styles;
// styles are added to the array in the order least dominant -> most dominant
// 1. table
const nsStyleSpacing *spacing;
mTableFrame.GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
const nsStyleBorder *borderStyleData;
mTableFrame.GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 2. colgroup
nsTableColFrame* colFrame = mTableFrame.GetColFrame(aColIndex);
nsIFrame* colGroupFrame;
colFrame->GetParent(&colGroupFrame);
colGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
colGroupFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 3. col
colFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
colFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 4. rowgroup
nsTableCellFrame* cellFrame = cellMap->GetCellInfoAt(aRowIndex, aColIndex);
if (cellFrame) {
@ -412,14 +412,14 @@ void nsTableBorderCollapser::ComputeTopBorderForEdgeAt(nsIPresContext* aPresCont
cellFrame->GetParent(&rowFrame);
nsIFrame* rowGroupFrame;
rowFrame->GetParent(&rowGroupFrame);
rowGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rowGroupFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 5. row
rowFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rowFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 6. cell (need to do something smart for rowspanner with row frame)
cellFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
cellFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
ComputeBorderSegment(NS_SIDE_TOP, &styles, *border, PR_FALSE);
// now give half the computed border to the table segment, and half to the cell
@ -505,21 +505,21 @@ void nsTableBorderCollapser::ComputeBottomBorderForEdgeAt(nsIPresContext* aPresC
}
}
}
const nsStyleSpacing *spacing;
const nsStyleBorder *borderStyleData;
if (!bottomNeighborFrame) {
// if bottomNeighborFrame is null, our bottom neighbor is the table
mTableFrame.GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
mTableFrame.GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 2. colgroup // XXX: need to deterine if we're on a colgroup boundary
nsTableColFrame* colFrame = mTableFrame.GetColFrame(aColIndex);
nsIFrame* colGroupFrame;
colFrame->GetParent(&colGroupFrame);
colGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
colGroupFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 3. col
colFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
colFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
// 4. rowgroup // XXX: use rowgroup only if we're on a table edge
nsTableCellFrame* cellFrame = cellMap->GetCellInfoAt(aRowIndex, aColIndex);
@ -530,19 +530,19 @@ void nsTableBorderCollapser::ComputeBottomBorderForEdgeAt(nsIPresContext* aPresC
rowFrame->GetRect(rowRect);
nsIFrame* rowGroupFrame;
rowFrame->GetParent(&rowGroupFrame);
rowGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rowGroupFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 5. row
rowFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
rowFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
// 6. cell (need to do something smart for rowspanner with row frame)
cellFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
cellFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
// 7. top edge of bottomNeighborCell, if there is one
if (bottomNeighborFrame) {
bottomNeighborFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
styles.AppendElement((void*)spacing);
bottomNeighborFrame->GetStyleData(eStyleStruct_Border, ((const nsStyleStruct *&)borderStyleData));
styles.AppendElement((void*)borderStyleData);
}
ComputeBorderSegment(NS_SIDE_BOTTOM, &styles, border, (nsnull != bottomNeighborFrame));
// now give half the computed border to each of the two neighbors
@ -740,33 +740,33 @@ void nsTableBorderCollapser::ComputeBorderSegment(PRUint8 aSide,
PRInt32 styleCount = aStyles->Count();
if (0 != styleCount) {
nsVoidArray sameWidthBorders;
nsStyleSpacing * spacing;
nsStyleSpacing * lastSpacing=nsnull;
nsStyleBorder * borderStyleData;
nsStyleBorder * lastBorderStyleData=nsnull;
nsMargin border;
PRInt32 maxWidth=0;
PRUint8 side = aSide;
PRInt32 i;
for (i = 0; i < styleCount; i++) {
spacing = (nsStyleSpacing *)(aStyles->ElementAt(i));
borderStyleData = (nsStyleBorder *)(aStyles->ElementAt(i));
if (aFlipLastSide && (i == styleCount-1)) {
side = GetOpposingEdge(aSide);
lastSpacing = spacing;
lastBorderStyleData = borderStyleData;
}
if (spacing->GetBorderStyle(side) == NS_STYLE_BORDER_STYLE_HIDDEN) {
if (borderStyleData->GetBorderStyle(side) == NS_STYLE_BORDER_STYLE_HIDDEN) {
aBorder.mStyle=NS_STYLE_BORDER_STYLE_HIDDEN;
aBorder.mWidth=0;
return;
}
else if (spacing->GetBorderStyle(side)!=NS_STYLE_BORDER_STYLE_NONE) {
if (spacing->GetBorder(border)) {
else if (borderStyleData->GetBorderStyle(side)!=NS_STYLE_BORDER_STYLE_NONE) {
if (borderStyleData->GetBorder(border)) {
nscoord borderWidth = GetWidthForSide(border, side);
if (borderWidth == maxWidth) {
sameWidthBorders.AppendElement(spacing);
sameWidthBorders.AppendElement(borderStyleData);
}
else if (borderWidth > maxWidth) {
maxWidth = borderWidth;
sameWidthBorders.Clear();
sameWidthBorders.AppendElement(spacing);
sameWidthBorders.AppendElement(borderStyleData);
}
}
}
@ -782,38 +782,38 @@ void nsTableBorderCollapser::ComputeBorderSegment(PRUint8 aSide,
return;
}
else if (1 == styleCount) { // there was just one border of the largest width
spacing = (nsStyleSpacing *)(sameWidthBorders.ElementAt(0));
borderStyleData = (nsStyleBorder *)(sameWidthBorders.ElementAt(0));
side = aSide;
if (spacing == lastSpacing)
if (borderStyleData == lastBorderStyleData)
side = GetOpposingEdge(aSide);
if (!spacing->GetBorderColor(side, aBorder.mColor)) {
if (!borderStyleData->GetBorderColor(side, aBorder.mColor)) {
// XXX EEEK handle transparent border color somehow...
}
aBorder.mStyle = spacing->GetBorderStyle(side);
aBorder.mStyle = borderStyleData->GetBorderStyle(side);
return;
}
else {
nsStyleSpacing* winningStyleBorder;
nsStyleBorder* winningStyleBorder;
PRUint8 winningStyle=NS_STYLE_BORDER_STYLE_NONE;
for (i = 0; i < styleCount; i++) {
spacing = (nsStyleSpacing *)(sameWidthBorders.ElementAt(i));
borderStyleData = (nsStyleBorder *)(sameWidthBorders.ElementAt(i));
side = aSide;
if (spacing == lastSpacing)
if (borderStyleData == lastBorderStyleData)
side = GetOpposingEdge(aSide);
PRUint8 thisStyle = spacing->GetBorderStyle(side);
PRUint8 thisStyle = borderStyleData->GetBorderStyle(side);
PRUint8 borderCompare = CompareBorderStyles(thisStyle, winningStyle);
if (BORDER_PRECEDENT_HIGHER == borderCompare) {
winningStyle = thisStyle;
winningStyleBorder = spacing;
winningStyleBorder = borderStyleData;
}
else if (BORDER_PRECEDENT_EQUAL == borderCompare) {
// we're in lowest-to-highest precedence order, so later border styles win
winningStyleBorder=spacing;
winningStyleBorder=borderStyleData;
}
}
aBorder.mStyle = winningStyle;
side = aSide;
if (winningStyleBorder == lastSpacing)
if (winningStyleBorder == lastBorderStyleData)
side = GetOpposingEdge(aSide);
if (!winningStyleBorder->GetBorderColor(side, aBorder.mColor)) {
// XXX handle transparent border colors somehow

Просмотреть файл

@ -291,10 +291,10 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext* aPresContext,
}
//END SELECTION
const nsStyleSpacing* mySpacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
NS_ASSERTION(nsnull!=myColor, "bad style color");
NS_ASSERTION(nsnull!=mySpacing, "bad style spacing");
NS_ASSERTION(nsnull!=myBorder, "bad style spacing");
const nsStyleTable* cellTableStyle;
GetStyleData(eStyleStruct_Table, ((const nsStyleStruct *&)cellTableStyle));
@ -303,7 +303,7 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext* aPresContext,
// only non empty cells render their background
if (PR_FALSE == GetContentEmpty()) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
aDirtyRect, rect, *myColor, *myBorder, 0, 0);
}
// empty cells do not render their border
@ -325,7 +325,7 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext* aPresContext,
if (NS_STYLE_BORDER_SEPARATE == tableFrame->GetBorderCollapseStyle())
{
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mStyleContext, skipSides);
aDirtyRect, rect, *myBorder, mStyleContext, skipSides);
}
else
{
@ -787,7 +787,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
kidOrigin.MoveTo(leftInset, topInset);
} else {
// handle percent padding-left which was 0 during initial reflow
if (eStyleUnit_Percent == aReflowState.mStyleSpacing->mPadding.GetLeftUnit()) {
if (eStyleUnit_Percent == aReflowState.mStylePadding->mPadding.GetLeftUnit()) {
nsRect kidRect;
firstKid->GetRect(kidRect);
// only move in the x direction for the same reason as above
@ -928,7 +928,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
*
*/
void nsTableCellFrame::MapHTMLBorderStyle(nsIPresContext* aPresContext,
nsStyleSpacing& aSpacingStyle,
nsStyleBorder& aBorderStyle,
nsTableFrame* aTableFrame)
{
//adjust the border style based on the table rules attribute
@ -942,20 +942,20 @@ void nsTableCellFrame::MapHTMLBorderStyle(nsIPresContext* aPresContext,
switch (tableStyle->mRules)
{
case NS_STYLE_TABLE_RULES_NONE:
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_RULES_COLS:
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_RULES_ROWS:
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
break;
default:
@ -996,9 +996,9 @@ void nsTableCellFrame::MapBorderPadding(nsIPresContext* aPresContext)
// get the table frame style context, and from it get cellpadding, cellspacing, and border info
const nsStyleTable* tableStyle;
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
const nsStyleSpacing* tableSpacingStyle;
tableFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct *&)tableSpacingStyle);
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
const nsStylePadding* tablePaddingStyle;
tableFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct *&)tablePaddingStyle);
nsStylePadding* paddingData = (nsStylePadding*)mStyleContext->GetMutableStyleData(eStyleStruct_Padding);
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
@ -1011,16 +1011,17 @@ void nsTableCellFrame::MapBorderPadding(nsIPresContext* aPresContext)
}
// if the padding is not already set, set it to the table's cellpadding
if (eStyleUnit_Null == spacingData->mPadding.GetTopUnit())
spacingData->mPadding.SetTop(defaultPadding);
if (eStyleUnit_Null == spacingData->mPadding.GetRightUnit())
spacingData->mPadding.SetRight(defaultPadding);
if (eStyleUnit_Null == spacingData->mPadding.GetBottomUnit())
spacingData->mPadding.SetBottom(defaultPadding);
if (eStyleUnit_Null == spacingData->mPadding.GetLeftUnit())
spacingData->mPadding.SetLeft(defaultPadding);
if (eStyleUnit_Null == paddingData->mPadding.GetTopUnit())
paddingData->mPadding.SetTop(defaultPadding);
if (eStyleUnit_Null == paddingData->mPadding.GetRightUnit())
paddingData->mPadding.SetRight(defaultPadding);
if (eStyleUnit_Null == paddingData->mPadding.GetBottomUnit())
paddingData->mPadding.SetBottom(defaultPadding);
if (eStyleUnit_Null == paddingData->mPadding.GetLeftUnit())
paddingData->mPadding.SetLeft(defaultPadding);
MapHTMLBorderStyle(aPresContext, *spacingData, tableFrame);
nsStyleBorder* borderData = (nsStyleBorder*)mStyleContext->GetMutableStyleData(eStyleStruct_Border);
MapHTMLBorderStyle(aPresContext, *borderData, tableFrame);
MapVAlignAttribute(aPresContext, tableFrame);
MapHAlignAttribute(aPresContext, tableFrame);
@ -1271,9 +1272,9 @@ nsTableCellFrame::GetCellBorder(nsMargin& aBorder,
NS_PRECONDITION(mBorderEdges, "haven't allocated border edges struct");
aBorder = mBorderEdges->mMaxBorderWidth;
} else {
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
spacing->GetBorder(aBorder);
const nsStyleBorder* borderData;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderData);
borderData->GetBorder(aBorder);
}
}

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex
#include "nsIStyleContext.h"
struct nsStyleSpacing;
class nsTableFrame;
class nsHTMLValue;
@ -257,7 +256,7 @@ protected:
void MapBorderPadding(nsIPresContext* aPresContext);
void MapHTMLBorderStyle(nsIPresContext* aPresContext,
nsStyleSpacing& aSpacingStyle,
nsStyleBorder& aBorderStyle,
nsTableFrame* aTableFrame);
void MapVAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame);

Просмотреть файл

@ -115,13 +115,13 @@ NS_METHOD nsTableColFrame::Paint(nsIPresContext* aPresContext,
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisibleOrCollapsed()) {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
}
}
}

Просмотреть файл

@ -441,13 +441,13 @@ NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext* aPresContext,
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisibleOrCollapsed()) {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
}
}
}

Просмотреть файл

@ -575,16 +575,16 @@ void nsTableFrame::ProcessGroupRules(nsIPresContext* aPresContext)
if (originates) {
nsCOMPtr<nsIStyleContext> styleContext;
cell->GetStyleContext(getter_AddRefs(styleContext));
nsStyleSpacing* spacing = (nsStyleSpacing*)styleContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* border = (nsStyleBorder*)styleContext->GetMutableStyleData(eStyleStruct_Border);
if (rowX == startRow) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
}
else if (rowX == endRow) {
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
}
else {
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
}
styleContext->RecalcAutomaticData(aPresContext);
}
@ -1330,8 +1330,8 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext* aPresContext,
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisibleOrCollapsed()) {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
@ -1341,7 +1341,7 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext* aPresContext,
aPresContext->GetCompatibilityMode(&mode);
if (eCompatibility_NavQuirks != mode) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
}
// paint the column groups and columns
nsIFrame* colGroupFrame = mColGroups.FirstChild();
@ -1354,7 +1354,7 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext* aPresContext,
if (NS_STYLE_BORDER_SEPARATE == GetBorderCollapseStyle())
{
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
aDirtyRect, rect, *border, mStyleContext, skipSides);
}
else
{
@ -1515,8 +1515,6 @@ nsresult nsTableFrame::AdjustSiblingsAfterReflow(nsIPresContext* aPresCon
// Update the max element size
//XXX: this should call into layout strategy to get the width field
if (aMaxElementSize) {
const nsStyleSpacing* tableSpacing;
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
nsMargin borderPadding;
GetTableBorder (borderPadding); // gets the max border thickness for each edge
borderPadding += aReflowState.reflowState.mComputedPadding;
@ -1865,10 +1863,10 @@ NS_METHOD nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
// Get the table's border padding
nsMargin borderPadding;
GetTableBorderForRowGroup(GetRowGroupFrame(kidFrame), borderPadding);
const nsStyleSpacing* tableSpacing;
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)tableSpacing));
const nsStylePadding* tablePadding;
GetStyleData(eStyleStruct_Padding, ((const nsStyleStruct *&)tablePadding));
nsMargin padding;
tableSpacing->GetPadding(padding);
tablePadding->GetPadding(padding);
borderPadding += padding;
y += cellSpacingY;
@ -1923,12 +1921,12 @@ NS_METHOD nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
}
// Get the table's border/padding
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStylePadding* myPadding = (const nsStylePadding*)
mStyleContext->GetStyleData(eStyleStruct_Padding);
nsMargin tableBorderPadding;
GetTableBorder (tableBorderPadding); // this gets the max border thickness at each edge
nsMargin tablePadding;
mySpacing->GetPadding(tablePadding);
myPadding->GetPadding(tablePadding);
tableBorderPadding += tablePadding;
aDesiredSize.width = kidSize.width;
@ -2790,8 +2788,6 @@ nsTableFrame::RecoverState(InnerTableReflowState& aReflowState,
//XXX: this should call into layout strategy to get the width field
if (nsnull != aMaxElementSize)
{
const nsStyleSpacing* tableSpacing;
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
nsMargin borderPadding;
GetTableBorder (borderPadding); // gets the max border thickness for each edge
borderPadding += aReflowState.reflowState.mComputedPadding;
@ -2852,8 +2848,6 @@ NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
//XXX: this should call into layout strategy to get the width field
if (nsnull != aDesiredSize.maxElementSize)
{
const nsStyleSpacing* tableSpacing;
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
nsMargin borderPadding;
GetTableBorder (borderPadding); // gets the max border thickness for each edge
borderPadding += aReflowState.reflowState.mComputedPadding;
@ -2972,8 +2966,6 @@ void nsTableFrame::PlaceChild(nsIPresContext* aPresContext,
//XXX: this should call into layout strategy to get the width field
if (nsnull != aMaxElementSize) {
const nsStyleSpacing* tableSpacing;
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
nsMargin borderPadding;
GetTableBorder (borderPadding); // gets the max border thickness for each edge
borderPadding += aReflowState.reflowState.mComputedPadding;
@ -3106,8 +3098,6 @@ NS_METHOD nsTableFrame::ReflowMappedChildren(nsIPresContext* aPresContext
nsMargin borderPadding;
GetTableBorderForRowGroup(GetRowGroupFrame(kidFrame), borderPadding);
const nsStyleSpacing* tableSpacing;
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)tableSpacing));
borderPadding += aReflowState.reflowState.mComputedPadding;
// Reflow the child into the available space
@ -3789,19 +3779,19 @@ void nsTableFrame::SetColumnWidth(PRInt32 aColIndex, nscoord aWidth)
* Update the border style to map to the HTML border style
*
*/
void nsTableFrame::MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth)
void nsTableFrame::MapHTMLBorderStyle(nsStyleBorder& aBorderStyle, nscoord aBorderWidth)
{
nsStyleCoord width;
width.SetCoordValue(aBorderWidth);
aSpacingStyle.mBorder.SetTop(width);
aSpacingStyle.mBorder.SetLeft(width);
aSpacingStyle.mBorder.SetBottom(width);
aSpacingStyle.mBorder.SetRight(width);
aBorderStyle.mBorder.SetTop(width);
aBorderStyle.mBorder.SetLeft(width);
aBorderStyle.mBorder.SetBottom(width);
aBorderStyle.mBorder.SetRight(width);
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_BG_OUTSET);
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_BG_OUTSET);
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_BG_OUTSET);
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_BG_OUTSET);
aBorderStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_BG_OUTSET);
aBorderStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_BG_OUTSET);
aBorderStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_BG_OUTSET);
aBorderStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_BG_OUTSET);
nsIStyleContext* styleContext = mStyleContext;
const nsStyleColor* colorData = (const nsStyleColor*)
@ -3839,10 +3829,10 @@ void nsTableFrame::MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBo
if (borderColor == 0xFFFFFFFF)
borderColor = 0xFFC0C0C0;
aSpacingStyle.SetBorderColor(NS_SIDE_TOP, borderColor);
aSpacingStyle.SetBorderColor(NS_SIDE_LEFT, borderColor);
aSpacingStyle.SetBorderColor(NS_SIDE_BOTTOM, borderColor);
aSpacingStyle.SetBorderColor(NS_SIDE_RIGHT, borderColor);
aBorderStyle.SetBorderColor(NS_SIDE_TOP, borderColor);
aBorderStyle.SetBorderColor(NS_SIDE_LEFT, borderColor);
aBorderStyle.SetBorderColor(NS_SIDE_BOTTOM, borderColor);
aBorderStyle.SetBorderColor(NS_SIDE_RIGHT, borderColor);
}
@ -3890,7 +3880,7 @@ void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
if (!table)
return;
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleBorder* borderData = (nsStyleBorder*)mStyleContext->GetMutableStyleData(eStyleStruct_Border);
border_result = table->GetAttribute(nsHTMLAtoms::border,border_value);
if (border_result == NS_CONTENT_ATTR_HAS_VALUE)
@ -3900,7 +3890,7 @@ void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
if (ConvertToPixelValue(border_value,1,intValue)) //XXX this is busted if this code is ever used again. MMP
border = NSIntPixelsToTwips(intValue, p2t);
}
MapHTMLBorderStyle(*spacingData,border);
MapHTMLBorderStyle(*borderData,border);
#endif
}
@ -3915,39 +3905,39 @@ CalcPercentPadding(nscoord aBasis,
void
GetPaddingFor(const nsSize& aBasis,
const nsStyleSpacing& aSpacing,
const nsStylePadding& aPaddingData,
nsMargin& aPadding)
{
nsStyleCoord styleCoord;
aSpacing.mPadding.GetTop(styleCoord);
if (eStyleUnit_Percent == aSpacing.mPadding.GetTopUnit()) {
aPaddingData.mPadding.GetTop(styleCoord);
if (eStyleUnit_Percent == aPaddingData.mPadding.GetTopUnit()) {
aPadding.top = CalcPercentPadding(aBasis.height, styleCoord);
}
else if (eStyleUnit_Coord == aSpacing.mPadding.GetTopUnit()) {
else if (eStyleUnit_Coord == aPaddingData.mPadding.GetTopUnit()) {
aPadding.top = styleCoord.GetCoordValue();
}
aSpacing.mPadding.GetRight(styleCoord);
if (eStyleUnit_Percent == aSpacing.mPadding.GetRightUnit()) {
aPaddingData.mPadding.GetRight(styleCoord);
if (eStyleUnit_Percent == aPaddingData.mPadding.GetRightUnit()) {
aPadding.right = CalcPercentPadding(aBasis.width, styleCoord);
}
else if (eStyleUnit_Coord == aSpacing.mPadding.GetTopUnit()) {
else if (eStyleUnit_Coord == aPaddingData.mPadding.GetTopUnit()) {
aPadding.right = styleCoord.GetCoordValue();
}
aSpacing.mPadding.GetBottom(styleCoord);
if (eStyleUnit_Percent == aSpacing.mPadding.GetBottomUnit()) {
aPaddingData.mPadding.GetBottom(styleCoord);
if (eStyleUnit_Percent == aPaddingData.mPadding.GetBottomUnit()) {
aPadding.bottom = CalcPercentPadding(aBasis.height, styleCoord);
}
else if (eStyleUnit_Coord == aSpacing.mPadding.GetTopUnit()) {
else if (eStyleUnit_Coord == aPaddingData.mPadding.GetTopUnit()) {
aPadding.bottom = styleCoord.GetCoordValue();
}
aSpacing.mPadding.GetLeft(styleCoord);
if (eStyleUnit_Percent == aSpacing.mPadding.GetLeftUnit()) {
aPaddingData.mPadding.GetLeft(styleCoord);
if (eStyleUnit_Percent == aPaddingData.mPadding.GetLeftUnit()) {
aPadding.left = CalcPercentPadding(aBasis.width, styleCoord);
}
else if (eStyleUnit_Coord == aSpacing.mPadding.GetTopUnit()) {
else if (eStyleUnit_Coord == aPaddingData.mPadding.GetTopUnit()) {
aPadding.left = styleCoord.GetCoordValue();
}
}
@ -3956,10 +3946,10 @@ nsMargin
nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState,
const nsTableCellFrame* aCellFrame)
{
const nsStyleSpacing* spacing;
aCellFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct *&)spacing);
const nsStylePadding* paddingData;
aCellFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct *&)paddingData);
nsMargin padding(0,0,0,0);
if (!spacing->GetPadding(padding)) {
if (!paddingData->GetPadding(padding)) {
const nsHTMLReflowState* parentRS = aReflowState.parentReflowState;
while (parentRS) {
if (parentRS->frame) {
@ -3967,7 +3957,7 @@ nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState,
parentRS->frame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::tableFrame == frameType.get()) {
nsSize basis(parentRS->mComputedWidth, parentRS->mComputedHeight);
GetPaddingFor(basis, *spacing, padding);
GetPaddingFor(basis, *paddingData, padding);
break;
}
}
@ -3981,11 +3971,11 @@ nsMargin
nsTableFrame::GetPadding(const nsSize& aBasis,
const nsTableCellFrame* aCellFrame)
{
const nsStyleSpacing* spacing;
aCellFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct *&)spacing);
const nsStylePadding* paddingData;
aCellFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct *&)paddingData);
nsMargin padding(0,0,0,0);
if (!spacing->GetPadding(padding)) {
GetPaddingFor(aBasis, *spacing, padding);
if (!paddingData->GetPadding(padding)) {
GetPaddingFor(aBasis, *paddingData, padding);
}
return padding;
}
@ -3997,9 +3987,9 @@ void nsTableFrame::GetTableBorder(nsMargin &aBorder)
mBorderCollapser->GetBorder(aBorder);
}
else {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
spacing->GetBorder(aBorder);
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
border->GetBorder(aBorder);
}
}
@ -4019,9 +4009,9 @@ void nsTableFrame::GetTableBorderAt(PRInt32 aRowIndex,
}
}
else {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
spacing->GetBorder(aBorder);
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
border->GetBorder(aBorder);
}
}
@ -4211,13 +4201,16 @@ nscoord nsTableFrame::CalcBorderBoxWidth(const nsHTMLReflowState& aState)
}
if (NS_UNCONSTRAINEDSIZE != aState.availableWidth) {
nsMargin margin(0,0,0,0);
aState.mStyleSpacing->GetMargin(margin);
aState.mStyleMargin->GetMargin(margin);
width = aState.availableWidth - margin.left - margin.right;
}
}
else if (width != NS_UNCONSTRAINEDSIZE) {
nsMargin border(0,0,0,0);
aState.mStyleBorder->GetBorder(border);
nsMargin borderPadding(0,0,0,0);
aState.mStyleSpacing->GetBorderPadding(borderPadding);
aState.mStylePadding->GetPadding(borderPadding);
borderPadding += border;
width += borderPadding.left + borderPadding.right;
}
width = PR_MAX(width, 0);

Просмотреть файл

@ -44,7 +44,6 @@ class nsHTMLValue;
struct InnerTableReflowState;
struct nsStylePosition;
struct nsStyleSpacing;
/**
* Child list name indices
@ -708,7 +707,7 @@ protected:
/** Support methods for DidSetStyleContext */
void MapBorderMarginPadding(nsIPresContext* aPresContext);
void MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth);
void MapHTMLBorderStyle(nsStyleBorder& aBorderStyle, nscoord aBorderWidth);
PRBool ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
public:

Просмотреть файл

@ -432,10 +432,10 @@ void
nsTableOuterFrame::ZeroAutoMargin(nsHTMLReflowState& aReflowState,
nsMargin& aMargin)
{
if (eStyleUnit_Auto == aReflowState.mStyleSpacing->mMargin.GetLeftUnit()) {
if (eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetLeftUnit()) {
aMargin.left = 0;
}
if (eStyleUnit_Auto == aReflowState.mStyleSpacing->mMargin.GetRightUnit()) {
if (eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetRightUnit()) {
aMargin.right = 0;
}
}
@ -445,8 +445,8 @@ FixAutoMargins(nscoord aAvailWidth,
nsHTMLReflowState& aReflowState)
{
// see if there are auto margins. they may have been set to 0 in mComputedMargin
PRBool hasAutoMargin = eStyleUnit_Auto == aReflowState.mStyleSpacing->mMargin.GetLeftUnit() ||
eStyleUnit_Auto == aReflowState.mStyleSpacing->mMargin.GetRightUnit();
PRBool hasAutoMargin = eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetLeftUnit() ||
eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetRightUnit();
if (hasAutoMargin) {
nsRect rect;
aReflowState.frame->GetRect(rect);

Просмотреть файл

@ -511,8 +511,8 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisibleOrCollapsed()) {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nsTableFrame* tableFrame = nsnull;
@ -525,7 +525,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
nsRect rect(0, 0, mRect.width + cellSpacingX, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
}
}
}

Просмотреть файл

@ -199,8 +199,8 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisibleOrCollapsed()) {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nsTableFrame* tableFrame = nsnull;
@ -210,7 +210,7 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
}
nsRect rect(0,0,mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
}
}
}

Просмотреть файл

@ -2253,33 +2253,41 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nsCSSMargin* ourMargin;
if (NS_OK == aDeclaration->GetData(kCSSMarginSID, (nsCSSStruct**)&ourMargin)) {
if (nsnull != ourMargin) {
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
nsStyleMargin* margin = (nsStyleMargin*)aContext->GetMutableStyleData(eStyleStruct_Margin);
nsStylePadding* padding = (nsStylePadding*)aContext->GetMutableStyleData(eStyleStruct_Padding);
nsStyleBorder* border = (nsStyleBorder*)aContext->GetMutableStyleData(eStyleStruct_Border);
nsStyleOutline* outline = (nsStyleOutline*)aContext->GetMutableStyleData(eStyleStruct_Outline);
const nsStyleSpacing* parentSpacing = spacing;
const nsStyleMargin* parentMargin = margin;
const nsStylePadding* parentPadding = padding;
const nsStyleBorder* parentBorder = border;
const nsStyleOutline* parentOutline = outline;
if (nsnull != aParentContext) {
parentSpacing = (const nsStyleSpacing*)aParentContext->GetStyleData(eStyleStruct_Spacing);
parentMargin = (const nsStyleMargin*)aParentContext->GetStyleData(eStyleStruct_Margin);
parentPadding = (const nsStylePadding*)aParentContext->GetStyleData(eStyleStruct_Padding);
parentBorder = (const nsStyleBorder*)aParentContext->GetStyleData(eStyleStruct_Border);
parentOutline = (const nsStyleOutline*)aParentContext->GetStyleData(eStyleStruct_Outline);
}
// margin: length, percent, auto, inherit
if (nsnull != ourMargin->mMargin) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mMargin.GetLeft(parentCoord);
parentMargin->mMargin.GetLeft(parentCoord);
if (SetCoord(ourMargin->mMargin->mLeft, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetLeft(coord);
margin->mMargin.SetLeft(coord);
}
parentSpacing->mMargin.GetTop(parentCoord);
parentMargin->mMargin.GetTop(parentCoord);
if (SetCoord(ourMargin->mMargin->mTop, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetTop(coord);
margin->mMargin.SetTop(coord);
}
parentSpacing->mMargin.GetRight(parentCoord);
parentMargin->mMargin.GetRight(parentCoord);
if (SetCoord(ourMargin->mMargin->mRight, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetRight(coord);
margin->mMargin.SetRight(coord);
}
parentSpacing->mMargin.GetBottom(parentCoord);
parentMargin->mMargin.GetBottom(parentCoord);
if (SetCoord(ourMargin->mMargin->mBottom, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
spacing->mMargin.SetBottom(coord);
margin->mMargin.SetBottom(coord);
}
}
@ -2287,21 +2295,21 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mPadding) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mPadding.GetLeft(parentCoord);
parentPadding->mPadding.GetLeft(parentCoord);
if (SetCoord(ourMargin->mPadding->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetLeft(coord);
padding->mPadding.SetLeft(coord);
}
parentSpacing->mPadding.GetTop(parentCoord);
parentPadding->mPadding.GetTop(parentCoord);
if (SetCoord(ourMargin->mPadding->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetTop(coord);
padding->mPadding.SetTop(coord);
}
parentSpacing->mPadding.GetRight(parentCoord);
parentPadding->mPadding.GetRight(parentCoord);
if (SetCoord(ourMargin->mPadding->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetRight(coord);
padding->mPadding.SetRight(coord);
}
parentSpacing->mPadding.GetBottom(parentCoord);
parentPadding->mPadding.GetBottom(parentCoord);
if (SetCoord(ourMargin->mPadding->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mPadding.SetBottom(coord);
padding->mPadding.SetBottom(coord);
}
}
@ -2310,31 +2318,31 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nsStyleCoord coord;
nsStyleCoord parentCoord;
if (SetCoord(ourMargin->mBorderWidth->mLeft, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetLeft(coord);
border->mBorder.SetLeft(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mLeft.GetUnit()) {
spacing->mBorder.SetLeft(parentSpacing->mBorder.GetLeft(coord));
border->mBorder.SetLeft(parentBorder->mBorder.GetLeft(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mTop, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetTop(coord);
border->mBorder.SetTop(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mTop.GetUnit()) {
spacing->mBorder.SetTop(parentSpacing->mBorder.GetTop(coord));
border->mBorder.SetTop(parentBorder->mBorder.GetTop(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mRight, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetRight(coord);
border->mBorder.SetRight(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mRight.GetUnit()) {
spacing->mBorder.SetRight(parentSpacing->mBorder.GetRight(coord));
border->mBorder.SetRight(parentBorder->mBorder.GetRight(coord));
}
if (SetCoord(ourMargin->mBorderWidth->mBottom, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
spacing->mBorder.SetBottom(coord);
border->mBorder.SetBottom(coord);
}
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mBottom.GetUnit()) {
spacing->mBorder.SetBottom(parentSpacing->mBorder.GetBottom(coord));
border->mBorder.SetBottom(parentBorder->mBorder.GetBottom(coord));
}
}
@ -2342,43 +2350,43 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mBorderStyle) {
nsCSSRect* ourStyle = ourMargin->mBorderStyle;
if (eCSSUnit_Enumerated == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, ourStyle->mTop.GetIntValue());
border->SetBorderStyle(NS_SIDE_TOP, ourStyle->mTop.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mTop.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_TOP, parentSpacing->GetBorderStyle(NS_SIDE_TOP));
border->SetBorderStyle(NS_SIDE_TOP, parentBorder->GetBorderStyle(NS_SIDE_TOP));
}
if (eCSSUnit_Enumerated == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, ourStyle->mRight.GetIntValue());
border->SetBorderStyle(NS_SIDE_RIGHT, ourStyle->mRight.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mRight.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_RIGHT, parentSpacing->GetBorderStyle(NS_SIDE_RIGHT));
border->SetBorderStyle(NS_SIDE_RIGHT, parentBorder->GetBorderStyle(NS_SIDE_RIGHT));
}
if (eCSSUnit_Enumerated == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, ourStyle->mBottom.GetIntValue());
border->SetBorderStyle(NS_SIDE_BOTTOM, ourStyle->mBottom.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mBottom.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_BOTTOM, parentSpacing->GetBorderStyle(NS_SIDE_BOTTOM));
border->SetBorderStyle(NS_SIDE_BOTTOM, parentBorder->GetBorderStyle(NS_SIDE_BOTTOM));
}
if (eCSSUnit_Enumerated == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, ourStyle->mLeft.GetIntValue());
border->SetBorderStyle(NS_SIDE_LEFT, ourStyle->mLeft.GetIntValue());
}
else if (eCSSUnit_None == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourStyle->mLeft.GetUnit()) {
spacing->SetBorderStyle(NS_SIDE_LEFT, parentSpacing->GetBorderStyle(NS_SIDE_LEFT));
border->SetBorderStyle(NS_SIDE_LEFT, parentBorder->GetBorderStyle(NS_SIDE_LEFT));
}
}
@ -2389,63 +2397,63 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nscolor unused = NS_RGB(0,0,0);
if (eCSSUnit_Inherit == ourBorderColor->mTop.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_TOP, borderColor)) {
spacing->SetBorderColor(NS_SIDE_TOP, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_TOP, borderColor)) {
border->SetBorderColor(NS_SIDE_TOP, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_TOP);
border->SetBorderTransparent(NS_SIDE_TOP);
}
}
else if (SetColor(ourBorderColor->mTop, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_TOP, borderColor);
border->SetBorderColor(NS_SIDE_TOP, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_TOP);
border->SetBorderTransparent(NS_SIDE_TOP);
}
if (eCSSUnit_Inherit == ourBorderColor->mRight.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_RIGHT, borderColor)) {
spacing->SetBorderColor(NS_SIDE_RIGHT, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_RIGHT, borderColor)) {
border->SetBorderColor(NS_SIDE_RIGHT, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_RIGHT);
border->SetBorderTransparent(NS_SIDE_RIGHT);
}
}
else if (SetColor(ourBorderColor->mRight, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_RIGHT, borderColor);
border->SetBorderColor(NS_SIDE_RIGHT, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mRight.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_RIGHT);
border->SetBorderTransparent(NS_SIDE_RIGHT);
}
if (eCSSUnit_Inherit == ourBorderColor->mBottom.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_BOTTOM, borderColor)) {
spacing->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_BOTTOM, borderColor)) {
border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_BOTTOM);
border->SetBorderTransparent(NS_SIDE_BOTTOM);
}
}
else if (SetColor(ourBorderColor->mBottom, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mBottom.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_BOTTOM);
border->SetBorderTransparent(NS_SIDE_BOTTOM);
}
if (eCSSUnit_Inherit == ourBorderColor->mLeft.GetUnit()) {
if (parentSpacing->GetBorderColor(NS_SIDE_LEFT, borderColor)) {
spacing->SetBorderColor(NS_SIDE_LEFT, borderColor);
if (parentBorder->GetBorderColor(NS_SIDE_LEFT, borderColor)) {
border->SetBorderColor(NS_SIDE_LEFT, borderColor);
}
else {
spacing->SetBorderTransparent(NS_SIDE_LEFT);
border->SetBorderTransparent(NS_SIDE_LEFT);
}
}
else if (SetColor(ourBorderColor->mLeft, unused, aPresContext, borderColor)) {
spacing->SetBorderColor(NS_SIDE_LEFT, borderColor);
border->SetBorderColor(NS_SIDE_LEFT, borderColor);
}
else if (eCSSUnit_Enumerated == ourBorderColor->mLeft.GetUnit()) {
spacing->SetBorderTransparent(NS_SIDE_LEFT);
border->SetBorderTransparent(NS_SIDE_LEFT);
}
}
@ -2453,21 +2461,21 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mBorderRadius) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mBorderRadius.GetLeft(parentCoord);
parentBorder->mBorderRadius.GetLeft(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetLeft(coord);
border->mBorderRadius.SetLeft(coord);
}
parentSpacing->mBorderRadius.GetTop(parentCoord);
parentBorder->mBorderRadius.GetTop(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetTop(coord);
border->mBorderRadius.SetTop(coord);
}
parentSpacing->mBorderRadius.GetRight(parentCoord);
parentBorder->mBorderRadius.GetRight(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetRight(coord);
border->mBorderRadius.SetRight(coord);
}
parentSpacing->mBorderRadius.GetBottom(parentCoord);
parentBorder->mBorderRadius.GetBottom(parentCoord);
if (SetCoord(ourMargin->mBorderRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mBorderRadius.SetBottom(coord);
border->mBorderRadius.SetBottom(coord);
}
}
@ -2475,26 +2483,26 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
if (nsnull != ourMargin->mOutlineRadius) {
nsStyleCoord coord;
nsStyleCoord parentCoord;
parentSpacing->mOutlineRadius.GetLeft(parentCoord);
parentOutline->mOutlineRadius.GetLeft(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetLeft(coord);
outline->mOutlineRadius.SetLeft(coord);
}
parentSpacing->mOutlineRadius.GetTop(parentCoord);
parentOutline->mOutlineRadius.GetTop(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetTop(coord);
outline->mOutlineRadius.SetTop(coord);
}
parentSpacing->mOutlineRadius.GetRight(parentCoord);
parentOutline->mOutlineRadius.GetRight(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetRight(coord);
outline->mOutlineRadius.SetRight(coord);
}
parentSpacing->mOutlineRadius.GetBottom(parentCoord);
parentOutline->mOutlineRadius.GetBottom(parentCoord);
if (SetCoord(ourMargin->mOutlineRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
spacing->mOutlineRadius.SetBottom(coord);
outline->mOutlineRadius.SetBottom(coord);
}
}
// outline-width: length, enum, inherit
if (! SetCoord(ourMargin->mOutlineWidth, spacing->mOutlineWidth, parentSpacing->mOutlineWidth,
if (! SetCoord(ourMargin->mOutlineWidth, outline->mOutlineWidth, parentOutline->mOutlineWidth,
SETCOORD_LEH, aFont->mFont, aPresContext)) {
}
@ -2502,37 +2510,37 @@ MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
nscolor outlineColor;
nscolor unused = NS_RGB(0,0,0);
if (eCSSUnit_Inherit == ourMargin->mOutlineColor.GetUnit()) {
if (parentSpacing->GetOutlineColor(outlineColor)) {
spacing->SetOutlineColor(outlineColor);
if (parentOutline->GetOutlineColor(outlineColor)) {
outline->SetOutlineColor(outlineColor);
}
else {
spacing->SetOutlineInvert();
outline->SetOutlineInvert();
}
}
else if (SetColor(ourMargin->mOutlineColor, unused, aPresContext, outlineColor)) {
spacing->SetOutlineColor(outlineColor);
outline->SetOutlineColor(outlineColor);
}
else if (eCSSUnit_Enumerated == ourMargin->mOutlineColor.GetUnit()) {
spacing->SetOutlineInvert();
outline->SetOutlineInvert();
}
// outline-style: enum, none, inherit
if (eCSSUnit_Enumerated == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(ourMargin->mOutlineStyle.GetIntValue());
outline->SetOutlineStyle(ourMargin->mOutlineStyle.GetIntValue());
}
else if (eCSSUnit_None == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(NS_STYLE_BORDER_STYLE_NONE);
outline->SetOutlineStyle(NS_STYLE_BORDER_STYLE_NONE);
}
else if (eCSSUnit_Inherit == ourMargin->mOutlineStyle.GetUnit()) {
spacing->SetOutlineStyle(parentSpacing->GetOutlineStyle());
outline->SetOutlineStyle(parentOutline->GetOutlineStyle());
}
// float-edge: enum, inherit
if (eCSSUnit_Enumerated == ourMargin->mFloatEdge.GetUnit()) {
spacing->mFloatEdge = ourMargin->mFloatEdge.GetIntValue();
border->mFloatEdge = ourMargin->mFloatEdge.GetIntValue();
}
else if (eCSSUnit_Inherit == ourMargin->mFloatEdge.GetUnit()) {
spacing->mFloatEdge = parentSpacing->mFloatEdge;
border->mFloatEdge = parentBorder->mFloatEdge;
}
}
}

Просмотреть файл

@ -844,15 +844,15 @@ nsComputedDOMStyle::GetMargin(nsAWritableString& aMargin)
nsresult GetMargins(nsIFrame *aFrame, nscoord& left, nscoord& top,
nscoord& right, nscoord& bottom)
{
const nsStyleSpacing* spacing;
const nsStyleBorder* border;
nsStyleCoord coord;
frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing) {
if (eStyleUnit_Coord == spacing->mBorder.GetLeftUnit()) {
origin.x += spacing->mBorder.GetLeft(coord).GetCoordValue();
frame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border);
if (border) {
if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) {
origin.x += border->mBorder.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetTopUnit()) {
origin.y += spacing->mBorder.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) {
origin.y += border->mBorder.GetTop(coord).GetCoordValue();
}
}
}
@ -1267,31 +1267,33 @@ nsComputedDOMStyle::GetAbsoluteFrameRect(nsIFrame *aFrame, nsRect& aRect)
}
// For the origin, add in the border for the frame
const nsStyleSpacing* spacing;
const nsStyleBorder* border;
const nsStylePadding* padding;
nsStyleCoord coord;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
if (spacing) {
if (eStyleUnit_Coord == spacing->mBorder.GetLeftUnit()) {
origin.x += spacing->mBorder.GetLeft(coord).GetCoordValue();
aRect.width -= spacing->mBorder.GetLeft(coord).GetCoordValue();
//aRect.width -= spacing->mMargin.GetLeft(coord).GetCoordValue();
aRect.width -= spacing->mPadding.GetLeft(coord).GetCoordValue();
aFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border);
aFrame->GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)padding);
if (border && padding) {
if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) {
origin.x += border->mBorder.GetLeft(coord).GetCoordValue();
aRect.width -= border->mBorder.GetLeft(coord).GetCoordValue();
//aRect.width -= margin->mMargin.GetLeft(coord).GetCoordValue();
aRect.width -= padding->mPadding.GetLeft(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetTopUnit()) {
origin.y += spacing->mBorder.GetTop(coord).GetCoordValue();
aRect.height -= spacing->mBorder.GetTop(coord).GetCoordValue();
//aRect.height -= spacing->mMargin.GetTop(coord).GetCoordValue();
aRect.height -= spacing->mPadding.GetTop(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) {
origin.y += border->mBorder.GetTop(coord).GetCoordValue();
aRect.height -= border->mBorder.GetTop(coord).GetCoordValue();
//aRect.height -= margin->mMargin.GetTop(coord).GetCoordValue();
aRect.height -= padding->mPadding.GetTop(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetRightUnit()) {
aRect.width -= spacing->mBorder.GetRight(coord).GetCoordValue();
//aRect.width -= spacing->mMargin.GetRight(coord).GetCoordValue();
aRect.width -= spacing->mPadding.GetRight(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetRightUnit()) {
aRect.width -= border->mBorder.GetRight(coord).GetCoordValue();
//aRect.width -= margin->mMargin.GetRight(coord).GetCoordValue();
aRect.width -= padding->mPadding.GetRight(coord).GetCoordValue();
}
if (eStyleUnit_Coord == spacing->mBorder.GetBottomUnit()) {
aRect.height -= spacing->mBorder.GetBottom(coord).GetCoordValue();
//aRect.height -= spacing->mMargin.GetBottom(coord).GetCoordValue();
aRect.height -= spacing->mPadding.GetBottom(coord).GetCoordValue();
if (eStyleUnit_Coord == border->mBorder.GetBottomUnit()) {
aRect.height -= border->mBorder.GetBottom(coord).GetCoordValue();
//aRect.height -= margin->mMargin.GetBottom(coord).GetCoordValue();
aRect.height -= padding->mPadding.GetBottom(coord).GetCoordValue();
}
}

Просмотреть файл

@ -132,13 +132,13 @@ CSSFirstLineRule::MapStyleInto(nsIMutableStyleContext* aContext,
parentContext = aContext->GetParent();
// Disable border
nsStyleSpacing* spacing = (nsStyleSpacing*)
aContext->GetMutableStyleData(eStyleStruct_Spacing);
if (spacing) {
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
spacing->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
nsStyleBorder* border = (nsStyleBorder*)
aContext->GetMutableStyleData(eStyleStruct_Border);
if (border) {
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
border->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
}
// Undo any change made to "direction"

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -291,10 +291,10 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext* aPresContext,
}
//END SELECTION
const nsStyleSpacing* mySpacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* myBorder =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
NS_ASSERTION(nsnull!=myColor, "bad style color");
NS_ASSERTION(nsnull!=mySpacing, "bad style spacing");
NS_ASSERTION(nsnull!=myBorder, "bad style spacing");
const nsStyleTable* cellTableStyle;
GetStyleData(eStyleStruct_Table, ((const nsStyleStruct *&)cellTableStyle));
@ -303,7 +303,7 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext* aPresContext,
// only non empty cells render their background
if (PR_FALSE == GetContentEmpty()) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
aDirtyRect, rect, *myColor, *myBorder, 0, 0);
}
// empty cells do not render their border
@ -325,7 +325,7 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext* aPresContext,
if (NS_STYLE_BORDER_SEPARATE == tableFrame->GetBorderCollapseStyle())
{
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, mStyleContext, skipSides);
aDirtyRect, rect, *myBorder, mStyleContext, skipSides);
}
else
{
@ -787,7 +787,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
kidOrigin.MoveTo(leftInset, topInset);
} else {
// handle percent padding-left which was 0 during initial reflow
if (eStyleUnit_Percent == aReflowState.mStyleSpacing->mPadding.GetLeftUnit()) {
if (eStyleUnit_Percent == aReflowState.mStylePadding->mPadding.GetLeftUnit()) {
nsRect kidRect;
firstKid->GetRect(kidRect);
// only move in the x direction for the same reason as above
@ -928,7 +928,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
*
*/
void nsTableCellFrame::MapHTMLBorderStyle(nsIPresContext* aPresContext,
nsStyleSpacing& aSpacingStyle,
nsStyleBorder& aBorderStyle,
nsTableFrame* aTableFrame)
{
//adjust the border style based on the table rules attribute
@ -942,20 +942,20 @@ void nsTableCellFrame::MapHTMLBorderStyle(nsIPresContext* aPresContext,
switch (tableStyle->mRules)
{
case NS_STYLE_TABLE_RULES_NONE:
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_RULES_COLS:
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
break;
case NS_STYLE_TABLE_RULES_ROWS:
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
aBorderStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
break;
default:
@ -996,9 +996,9 @@ void nsTableCellFrame::MapBorderPadding(nsIPresContext* aPresContext)
// get the table frame style context, and from it get cellpadding, cellspacing, and border info
const nsStyleTable* tableStyle;
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
const nsStyleSpacing* tableSpacingStyle;
tableFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct *&)tableSpacingStyle);
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
const nsStylePadding* tablePaddingStyle;
tableFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct *&)tablePaddingStyle);
nsStylePadding* paddingData = (nsStylePadding*)mStyleContext->GetMutableStyleData(eStyleStruct_Padding);
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
@ -1011,16 +1011,17 @@ void nsTableCellFrame::MapBorderPadding(nsIPresContext* aPresContext)
}
// if the padding is not already set, set it to the table's cellpadding
if (eStyleUnit_Null == spacingData->mPadding.GetTopUnit())
spacingData->mPadding.SetTop(defaultPadding);
if (eStyleUnit_Null == spacingData->mPadding.GetRightUnit())
spacingData->mPadding.SetRight(defaultPadding);
if (eStyleUnit_Null == spacingData->mPadding.GetBottomUnit())
spacingData->mPadding.SetBottom(defaultPadding);
if (eStyleUnit_Null == spacingData->mPadding.GetLeftUnit())
spacingData->mPadding.SetLeft(defaultPadding);
if (eStyleUnit_Null == paddingData->mPadding.GetTopUnit())
paddingData->mPadding.SetTop(defaultPadding);
if (eStyleUnit_Null == paddingData->mPadding.GetRightUnit())
paddingData->mPadding.SetRight(defaultPadding);
if (eStyleUnit_Null == paddingData->mPadding.GetBottomUnit())
paddingData->mPadding.SetBottom(defaultPadding);
if (eStyleUnit_Null == paddingData->mPadding.GetLeftUnit())
paddingData->mPadding.SetLeft(defaultPadding);
MapHTMLBorderStyle(aPresContext, *spacingData, tableFrame);
nsStyleBorder* borderData = (nsStyleBorder*)mStyleContext->GetMutableStyleData(eStyleStruct_Border);
MapHTMLBorderStyle(aPresContext, *borderData, tableFrame);
MapVAlignAttribute(aPresContext, tableFrame);
MapHAlignAttribute(aPresContext, tableFrame);
@ -1271,9 +1272,9 @@ nsTableCellFrame::GetCellBorder(nsMargin& aBorder,
NS_PRECONDITION(mBorderEdges, "haven't allocated border edges struct");
aBorder = mBorderEdges->mMaxBorderWidth;
} else {
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
spacing->GetBorder(aBorder);
const nsStyleBorder* borderData;
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderData);
borderData->GetBorder(aBorder);
}
}

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex
#include "nsIStyleContext.h"
struct nsStyleSpacing;
class nsTableFrame;
class nsHTMLValue;
@ -257,7 +256,7 @@ protected:
void MapBorderPadding(nsIPresContext* aPresContext);
void MapHTMLBorderStyle(nsIPresContext* aPresContext,
nsStyleSpacing& aSpacingStyle,
nsStyleBorder& aBorderStyle,
nsTableFrame* aTableFrame);
void MapVAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame);

Просмотреть файл

@ -115,13 +115,13 @@ NS_METHOD nsTableColFrame::Paint(nsIPresContext* aPresContext,
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->IsVisibleOrCollapsed()) {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleBorder* border =
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
aDirtyRect, rect, *color, *border, 0, 0);
}
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше