Made attributes topmargin and leftmargin work on the BODY element in Quirks Mode. b=9258 r=alexsavulov sr=jst

This commit is contained in:
attinasi%netscape.com 2001-08-15 22:22:41 +00:00
Родитель ad705a48cc
Коммит 3f88a6807a
3 изменённых файлов: 38 добавлений и 3 удалений

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

@ -183,6 +183,7 @@ HTML_ATOM(layout, "layout")
HTML_ATOM(li, "li")
HTML_ATOM(link, "link")
HTML_ATOM(left, "left")
HTML_ATOM(leftmargin, "leftmargin")
HTML_ATOM(leftpadding, "leftpadding")
HTML_ATOM(legend, "legend")
HTML_ATOM(legendContentPseudo, ":legend-content")
@ -275,6 +276,7 @@ HTML_ATOM(textPseudo, ":-moz-text")
HTML_ATOM(th, "th")
HTML_ATOM(title, "title")
HTML_ATOM(top, "top")
HTML_ATOM(topmargin, "topmargin")
HTML_ATOM(toppadding, "toppadding")
HTML_ATOM(tr, "tr")
HTML_ATOM(tt, "tt")

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

@ -289,6 +289,14 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
PRInt32 bodyMarginWidth = -1;
PRInt32 bodyMarginHeight = -1;
PRInt32 bodyTopMargin = -1;
PRInt32 bodyLeftMargin = -1;
// check the mode (fortunately, the ruleData has a presContext for us to use!)
nsCompatibility mode;
NS_ASSERTION(aData->mPresContext, "null presContext in ruleNode was unexpected");
aData->mPresContext->GetCompatibilityMode(&mode);
if (attrCount > 0) {
// if marginwidth/marginheight are set, reflect them as 'margin'
@ -313,6 +321,29 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
if (margin->mBottom.GetUnit() == eCSSUnit_Null)
margin->mBottom.SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
}
if (eCompatibility_NavQuirks == mode){
// topmargin (IE-attribute)
mPart->GetHTMLAttribute(nsHTMLAtoms::topmargin, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
bodyTopMargin = value.GetPixelValue();
if (bodyTopMargin < 0) bodyTopMargin = 0;
nsCSSRect* margin = aData->mMarginData->mMargin;
if (margin->mTop.GetUnit() == eCSSUnit_Null)
margin->mTop.SetFloatValue((float)bodyTopMargin, eCSSUnit_Pixel);
}
// leftmargin (IE-attribute)
mPart->GetHTMLAttribute(nsHTMLAtoms::leftmargin, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
bodyLeftMargin = value.GetPixelValue();
if (bodyLeftMargin < 0) bodyLeftMargin = 0;
nsCSSRect* margin = aData->mMarginData->mMargin;
if (margin->mLeft.GetUnit() == eCSSUnit_Null)
margin->mLeft.SetFloatValue((float)bodyLeftMargin, eCSSUnit_Pixel);
}
}
}
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
@ -321,8 +352,6 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
nsCOMPtr<nsISupports> container;
aData->mPresContext->GetContainer(getter_AddRefs(container));
if (container) {
nsCompatibility mode;
aData->mPresContext->GetCompatibilityMode(&mode);
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
nscoord frameMarginWidth=-1; // default value
@ -843,7 +872,9 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute,
}
}
else if ((aAttribute == nsHTMLAtoms::marginwidth) ||
(aAttribute == nsHTMLAtoms::marginheight)) {
(aAttribute == nsHTMLAtoms::marginheight) ||
(aAttribute == nsHTMLAtoms::topmargin) ||
(aAttribute == nsHTMLAtoms::leftmargin)) {
if (ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}

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

@ -183,6 +183,7 @@ HTML_ATOM(layout, "layout")
HTML_ATOM(li, "li")
HTML_ATOM(link, "link")
HTML_ATOM(left, "left")
HTML_ATOM(leftmargin, "leftmargin")
HTML_ATOM(leftpadding, "leftpadding")
HTML_ATOM(legend, "legend")
HTML_ATOM(legendContentPseudo, ":legend-content")
@ -275,6 +276,7 @@ HTML_ATOM(textPseudo, ":-moz-text")
HTML_ATOM(th, "th")
HTML_ATOM(title, "title")
HTML_ATOM(top, "top")
HTML_ATOM(topmargin, "topmargin")
HTML_ATOM(toppadding, "toppadding")
HTML_ATOM(tr, "tr")
HTML_ATOM(tt, "tt")