From a2b07fa444280b5665d61a4f611ad0580af94eb5 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Fri, 4 Sep 1998 00:19:48 +0000 Subject: [PATCH] Fold in some code from nsHTMLImage.cpp --- .../html/content/src/nsHTMLImageElement.cpp | 45 ++++++++++++++++++- .../html/content/src/nsHTMLImageElement.cpp | 45 ++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/content/html/content/src/nsHTMLImageElement.cpp b/content/html/content/src/nsHTMLImageElement.cpp index 7da315045f9d..1a6befe33a5b 100644 --- a/content/html/content/src/nsHTMLImageElement.cpp +++ b/content/html/content/src/nsHTMLImageElement.cpp @@ -27,6 +27,8 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" +// XXX nav attrs: suppress + static NS_DEFINE_IID(kIDOMHTMLImageElementIID, NS_IDOMHTMLIMAGEELEMENT_IID); class nsHTMLImageElement : public nsIDOMHTMLImageElement, @@ -170,6 +172,18 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } + else if (aAttribute == nsHTMLAtoms::ismap) { + aResult.SetEmptyValue(); + return NS_CONTENT_ATTR_HAS_VALUE; + } + if ((aAttribute == nsHTMLAtoms::usemap) || + (aAttribute == nsHTMLAtoms::src) || + (aAttribute == nsHTMLAtoms::lowsrc)) { + nsAutoString tmp(aValue); + tmp.StripWhitespace(); + aResult.SetStringValue(tmp); + return NS_CONTENT_ATTR_HAS_VALUE; + } else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute, aValue, aResult)) { return NS_CONTENT_ATTR_HAS_VALUE; @@ -199,7 +213,36 @@ NS_IMETHODIMP nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { - mInner.MapImageAlignAttributeInto(aContext, aPresContext); + if (nsnull != mInner.mAttributes) { + nsHTMLValue value; + GetAttribute(nsHTMLAtoms::align, value); + if (value.GetUnit() == eHTMLUnit_Enumerated) { + PRUint8 align = value.GetIntValue(); + nsStyleDisplay* display = (nsStyleDisplay*) + aContext->GetMutableStyleData(eStyleStruct_Display); + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + nsStyleSpacing* spacing = (nsStyleSpacing*) + aContext->GetMutableStyleData(eStyleStruct_Spacing); + float p2t = aPresContext->GetPixelsToTwips(); + 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); + break; + case NS_STYLE_TEXT_ALIGN_RIGHT: + display->mFloats = NS_STYLE_FLOAT_RIGHT; + spacing->mMargin.SetLeft(three); + spacing->mMargin.SetRight(three); + break; + default: + text->mVerticalAlign.SetIntValue(align, eStyleUnit_Enumerated); + break; + } + } + } mInner.MapImageAttributesInto(aContext, aPresContext); mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); return mInner.MapAttributesInto(aContext, aPresContext); diff --git a/layout/html/content/src/nsHTMLImageElement.cpp b/layout/html/content/src/nsHTMLImageElement.cpp index 7da315045f9d..1a6befe33a5b 100644 --- a/layout/html/content/src/nsHTMLImageElement.cpp +++ b/layout/html/content/src/nsHTMLImageElement.cpp @@ -27,6 +27,8 @@ #include "nsStyleConsts.h" #include "nsIPresContext.h" +// XXX nav attrs: suppress + static NS_DEFINE_IID(kIDOMHTMLImageElementIID, NS_IDOMHTMLIMAGEELEMENT_IID); class nsHTMLImageElement : public nsIDOMHTMLImageElement, @@ -170,6 +172,18 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } + else if (aAttribute == nsHTMLAtoms::ismap) { + aResult.SetEmptyValue(); + return NS_CONTENT_ATTR_HAS_VALUE; + } + if ((aAttribute == nsHTMLAtoms::usemap) || + (aAttribute == nsHTMLAtoms::src) || + (aAttribute == nsHTMLAtoms::lowsrc)) { + nsAutoString tmp(aValue); + tmp.StripWhitespace(); + aResult.SetStringValue(tmp); + return NS_CONTENT_ATTR_HAS_VALUE; + } else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute, aValue, aResult)) { return NS_CONTENT_ATTR_HAS_VALUE; @@ -199,7 +213,36 @@ NS_IMETHODIMP nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { - mInner.MapImageAlignAttributeInto(aContext, aPresContext); + if (nsnull != mInner.mAttributes) { + nsHTMLValue value; + GetAttribute(nsHTMLAtoms::align, value); + if (value.GetUnit() == eHTMLUnit_Enumerated) { + PRUint8 align = value.GetIntValue(); + nsStyleDisplay* display = (nsStyleDisplay*) + aContext->GetMutableStyleData(eStyleStruct_Display); + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + nsStyleSpacing* spacing = (nsStyleSpacing*) + aContext->GetMutableStyleData(eStyleStruct_Spacing); + float p2t = aPresContext->GetPixelsToTwips(); + 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); + break; + case NS_STYLE_TEXT_ALIGN_RIGHT: + display->mFloats = NS_STYLE_FLOAT_RIGHT; + spacing->mMargin.SetLeft(three); + spacing->mMargin.SetRight(three); + break; + default: + text->mVerticalAlign.SetIntValue(align, eStyleUnit_Enumerated); + break; + } + } + } mInner.MapImageAttributesInto(aContext, aPresContext); mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); return mInner.MapAttributesInto(aContext, aPresContext);