From 7f7afdabd38fca149951b4f4e3a50366aae55657 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Mon, 9 Nov 1998 17:51:05 +0000 Subject: [PATCH] Repaired marginwidth/marginheight handling code --- .../html/content/src/nsHTMLBodyElement.cpp | 21 ++++++++++++++++++- layout/html/content/src/nsHTMLBodyElement.cpp | 21 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp index a7350eda9a6..943727e1536 100644 --- a/content/html/content/src/nsHTMLBodyElement.cpp +++ b/content/html/content/src/nsHTMLBodyElement.cpp @@ -400,7 +400,26 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, NS_RELEASE(presShell); } - // marginwidth/height get set by a special style rule + // marginwidth/marginheight + // XXX: see ua.css for related code in the BODY rule + float p2t; + p2t = aPresContext->GetPixelsToTwips(); + nsStyleSpacing* spacing = (nsStyleSpacing*) + aContext->GetMutableStyleData(eStyleStruct_Spacing); + aAttributes->GetAttribute(nsHTMLAtoms::marginwidth, value); + if (eHTMLUnit_Pixel == value.GetUnit()) { + nscoord v = NSToCoordFloor(value.GetPixelValue() * p2t); + nsStyleCoord c(v); + spacing->mPadding.SetLeft(c); + spacing->mPadding.SetRight(c); + } + aAttributes->GetAttribute(nsHTMLAtoms::marginheight, value); + if (eHTMLUnit_Pixel == value.GetUnit()) { + nscoord v = NSToCoordFloor(value.GetPixelValue() * p2t); + nsStyleCoord c(v); + spacing->mPadding.SetTop(c); + spacing->mPadding.SetBottom(c); + } // set up the basefont (defaults to 3) nsStyleFont* font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font); diff --git a/layout/html/content/src/nsHTMLBodyElement.cpp b/layout/html/content/src/nsHTMLBodyElement.cpp index a7350eda9a6..943727e1536 100644 --- a/layout/html/content/src/nsHTMLBodyElement.cpp +++ b/layout/html/content/src/nsHTMLBodyElement.cpp @@ -400,7 +400,26 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, NS_RELEASE(presShell); } - // marginwidth/height get set by a special style rule + // marginwidth/marginheight + // XXX: see ua.css for related code in the BODY rule + float p2t; + p2t = aPresContext->GetPixelsToTwips(); + nsStyleSpacing* spacing = (nsStyleSpacing*) + aContext->GetMutableStyleData(eStyleStruct_Spacing); + aAttributes->GetAttribute(nsHTMLAtoms::marginwidth, value); + if (eHTMLUnit_Pixel == value.GetUnit()) { + nscoord v = NSToCoordFloor(value.GetPixelValue() * p2t); + nsStyleCoord c(v); + spacing->mPadding.SetLeft(c); + spacing->mPadding.SetRight(c); + } + aAttributes->GetAttribute(nsHTMLAtoms::marginheight, value); + if (eHTMLUnit_Pixel == value.GetUnit()) { + nscoord v = NSToCoordFloor(value.GetPixelValue() * p2t); + nsStyleCoord c(v); + spacing->mPadding.SetTop(c); + spacing->mPadding.SetBottom(c); + } // set up the basefont (defaults to 3) nsStyleFont* font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font);