From c1e82cdc96bde5cc972a9029bef97c894648e5c4 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Wed, 31 Mar 1999 04:13:04 +0000 Subject: [PATCH] Support cols, wrap and width arguments git-svn-id: svn://10.0.0.236/trunk@25651 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsHTMLPreElement.cpp | 31 ++++++++++++++++--- .../html/content/src/nsHTMLPreElement.cpp | 31 ++++++++++++++++--- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/mozilla/content/html/content/src/nsHTMLPreElement.cpp b/mozilla/content/html/content/src/nsHTMLPreElement.cpp index b95411b0722..51e82028067 100644 --- a/mozilla/content/html/content/src/nsHTMLPreElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLPreElement.cpp @@ -179,7 +179,9 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, // wrap: empty aAttributes->GetAttribute(nsHTMLAtoms::wrap, value); if (value.GetUnit() == eHTMLUnit_Empty) { - // XXX set + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + text->mWhiteSpace = NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; } // variable: empty @@ -190,10 +192,30 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, font->mFont.name = "serif"; } - // cols: int + // cols: int (nav4 attribute) aAttributes->GetAttribute(nsHTMLAtoms::cols, value); if (value.GetUnit() == eHTMLUnit_Integer) { - // XXX set + nsStylePosition* position = (nsStylePosition*) + aContext->GetMutableStyleData(eStyleStruct_Position); + position->mWidth.SetIntValue(value.GetIntValue(), eStyleUnit_Chars); + // Force wrap property on since we want to wrap at a width + // boundary not just a newline. + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + text->mWhiteSpace = NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; + } + + // width: int (html4 attribute == nav4 cols) + aAttributes->GetAttribute(nsHTMLAtoms::width, value); + if (value.GetUnit() == eHTMLUnit_Integer) { + nsStylePosition* position = (nsStylePosition*) + aContext->GetMutableStyleData(eStyleStruct_Position); + position->mWidth.SetIntValue(value.GetIntValue(), eStyleUnit_Chars); + // Force wrap property on since we want to wrap at a width + // boundary not just a newline. + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + text->mWhiteSpace = NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; } // tabstop: int @@ -202,7 +224,8 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, // XXX set } } - nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext); + nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, + aPresContext); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLPreElement.cpp b/mozilla/layout/html/content/src/nsHTMLPreElement.cpp index b95411b0722..51e82028067 100644 --- a/mozilla/layout/html/content/src/nsHTMLPreElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLPreElement.cpp @@ -179,7 +179,9 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, // wrap: empty aAttributes->GetAttribute(nsHTMLAtoms::wrap, value); if (value.GetUnit() == eHTMLUnit_Empty) { - // XXX set + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + text->mWhiteSpace = NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; } // variable: empty @@ -190,10 +192,30 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, font->mFont.name = "serif"; } - // cols: int + // cols: int (nav4 attribute) aAttributes->GetAttribute(nsHTMLAtoms::cols, value); if (value.GetUnit() == eHTMLUnit_Integer) { - // XXX set + nsStylePosition* position = (nsStylePosition*) + aContext->GetMutableStyleData(eStyleStruct_Position); + position->mWidth.SetIntValue(value.GetIntValue(), eStyleUnit_Chars); + // Force wrap property on since we want to wrap at a width + // boundary not just a newline. + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + text->mWhiteSpace = NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; + } + + // width: int (html4 attribute == nav4 cols) + aAttributes->GetAttribute(nsHTMLAtoms::width, value); + if (value.GetUnit() == eHTMLUnit_Integer) { + nsStylePosition* position = (nsStylePosition*) + aContext->GetMutableStyleData(eStyleStruct_Position); + position->mWidth.SetIntValue(value.GetIntValue(), eStyleUnit_Chars); + // Force wrap property on since we want to wrap at a width + // boundary not just a newline. + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + text->mWhiteSpace = NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; } // tabstop: int @@ -202,7 +224,8 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, // XXX set } } - nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext); + nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, + aPresContext); } NS_IMETHODIMP