From 12f074b44e5fae4a62f52eddf07be8fe3cce6dff Mon Sep 17 00:00:00 2001 From: "cvshook%sicking.cc" Date: Tue, 25 Jan 2005 00:02:58 +0000 Subject: [PATCH] Bug 236476: Change GetHTMLAttribute to GetParsedAttr. Also fixes bug 232706 by removing final uses of nsHTMLValue. r=bz sr=jst git-svn-id: svn://10.0.0.236/trunk@168269 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/Makefile.in | 2 - mozilla/content/base/src/nsAttrValue.cpp | 222 ++++++---- mozilla/content/base/src/nsAttrValue.h | 42 +- mozilla/content/base/src/nsHTMLValue.cpp | 181 --------- mozilla/content/base/src/nsHTMLValue.h | 380 ------------------ .../html/content/src/nsFormSubmission.cpp | 16 +- .../html/content/src/nsGenericHTMLElement.cpp | 147 +------ .../html/content/src/nsGenericHTMLElement.h | 97 +---- .../html/content/src/nsHTMLAppletElement.cpp | 17 - .../html/content/src/nsHTMLBRElement.cpp | 19 +- .../html/content/src/nsHTMLBodyElement.cpp | 39 +- .../html/content/src/nsHTMLButtonElement.cpp | 21 +- .../html/content/src/nsHTMLDivElement.cpp | 17 - .../html/content/src/nsHTMLFontElement.cpp | 70 ++-- .../html/content/src/nsHTMLFormElement.cpp | 28 +- .../html/content/src/nsHTMLFrameElement.cpp | 22 - .../content/src/nsHTMLFrameSetElement.cpp | 33 +- .../html/content/src/nsHTMLHRElement.cpp | 20 +- .../html/content/src/nsHTMLHeadingElement.cpp | 18 - .../html/content/src/nsHTMLIFrameElement.cpp | 28 -- .../html/content/src/nsHTMLImageElement.cpp | 32 +- .../html/content/src/nsHTMLInputElement.cpp | 54 +-- .../html/content/src/nsHTMLLIElement.cpp | 23 +- .../html/content/src/nsHTMLLegendElement.cpp | 21 +- .../html/content/src/nsHTMLOListElement.cpp | 35 +- .../html/content/src/nsHTMLObjectElement.cpp | 19 - .../content/src/nsHTMLParagraphElement.cpp | 18 - .../html/content/src/nsHTMLSharedElement.cpp | 37 +- .../content/src/nsHTMLSharedObjectElement.cpp | 19 - .../content/src/nsHTMLTableCaptionElement.cpp | 21 +- .../content/src/nsHTMLTableCellElement.cpp | 39 +- .../content/src/nsHTMLTableColElement.cpp | 28 -- .../html/content/src/nsHTMLTableElement.cpp | 43 +- .../content/src/nsHTMLTableRowElement.cpp | 28 -- .../content/src/nsHTMLTableSectionElement.cpp | 28 -- .../content/xul/content/src/nsXULElement.h | 1 - mozilla/layout/build/nsLayoutModule.cpp | 9 + mozilla/layout/forms/nsFormControlFrame.cpp | 26 +- mozilla/layout/forms/nsFormControlHelper.cpp | 39 +- mozilla/layout/forms/nsLegendFrame.cpp | 8 +- mozilla/layout/forms/nsTextControlFrame.cpp | 46 +-- mozilla/layout/forms/nsTextControlFrame.h | 1 - mozilla/layout/generic/nsAreaFrame.cpp | 1 - mozilla/layout/generic/nsBlockFrame.cpp | 10 +- mozilla/layout/generic/nsBulletFrame.cpp | 12 +- mozilla/layout/generic/nsFrameFrame.cpp | 13 +- mozilla/layout/generic/nsFrameSetFrame.cpp | 55 ++- .../layout/generic/nsHTMLContainerFrame.cpp | 1 - mozilla/layout/html/tests/TestAttributes.cpp | 11 +- .../layout/style/nsDOMCSSAttrDeclaration.cpp | 1 - mozilla/layout/tables/nsTableCellFrame.cpp | 15 +- mozilla/layout/tables/nsTableCellFrame.h | 1 - mozilla/layout/tables/nsTableFrame.cpp | 1 - mozilla/layout/tables/nsTableFrame.h | 1 - 54 files changed, 407 insertions(+), 1709 deletions(-) delete mode 100644 mozilla/content/base/src/nsHTMLValue.cpp delete mode 100644 mozilla/content/base/src/nsHTMLValue.h diff --git a/mozilla/content/base/src/Makefile.in b/mozilla/content/base/src/Makefile.in index 00397cbb330..8849fd979ca 100644 --- a/mozilla/content/base/src/Makefile.in +++ b/mozilla/content/base/src/Makefile.in @@ -82,7 +82,6 @@ REQUIRES = xpcom \ EXPORTS = \ nsAtomListUtils.h \ - nsHTMLValue.h \ nsNodeInfoManager.h \ nsPropertyTable.h \ nsStubDocumentObserver.h \ @@ -116,7 +115,6 @@ CPPSRCS = \ nsGenericDOMNodeList.cpp \ nsGenericElement.cpp \ nsHTMLContentSerializer.cpp \ - nsHTMLValue.cpp \ nsImageLoadingContent.cpp \ nsMappedAttributes.cpp \ nsNameSpaceManager.cpp \ diff --git a/mozilla/content/base/src/nsAttrValue.cpp b/mozilla/content/base/src/nsAttrValue.cpp index 6e300595561..07f26a8535f 100644 --- a/mozilla/content/base/src/nsAttrValue.cpp +++ b/mozilla/content/base/src/nsAttrValue.cpp @@ -37,7 +37,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsAttrValue.h" -#include "nsHTMLValue.h" #include "nsIAtom.h" #include "nsUnicharUtils.h" #include "nsICSSStyleRule.h" @@ -49,6 +48,100 @@ #include "nsISVGValue.h" #endif +nsVoidArray* nsAttrValue::sEnumTableArray = nsnull; + +class nsCheapStringBufferUtils { +public: + /** + * Get the string pointer + * @param aBuf the buffer + * @return a pointer to the string + */ + static const PRUnichar* StrPtr(const PRUnichar* aBuf) { + NS_ASSERTION(aBuf, "Cannot work on null buffer!"); + return (const PRUnichar*)( ((const char*)aBuf) + sizeof(PRUint32) ); + } + static PRUnichar* StrPtr(PRUnichar* aBuf) { + NS_ASSERTION(aBuf, "Cannot work on null buffer!"); + return (PRUnichar*)( ((char*)aBuf) + sizeof(PRUint32) ); + } + /** + * Get the string length + * @param aBuf the buffer + * @return the string length + */ + static PRUint32 Length(const PRUnichar* aBuf) { + NS_ASSERTION(aBuf, "Cannot work on null buffer!"); + return *((PRUint32*)aBuf); + } + /** + * Get a DependentString from a buffer + * + * @param aBuf the buffer to get string from + * @return a DependentString representing this string + */ + static nsDependentSubstring GetDependentString(const PRUnichar* aBuf) { + NS_ASSERTION(aBuf, "Cannot work on null buffer!"); + const PRUnichar* buf = StrPtr(aBuf); + return Substring(buf, buf + Length(aBuf)); + } + /** + * Construct from an AString + * @param aBuf the buffer to copy to + * @param aStr the string to construct from + */ + static void CopyToBuffer(PRUnichar*& aBuf, const nsAString& aStr) { + PRUint32 len = aStr.Length(); + aBuf = (PRUnichar*)nsMemory::Alloc(sizeof(PRUint32) + + len * sizeof(PRUnichar)); + *((PRUint32*)aBuf) = len; + CopyUnicodeTo(aStr, 0, StrPtr(aBuf), len); + } + /** + * Construct from an AString + * @param aBuf the buffer to copy to + * @param aStr the string to construct from + */ + static void CopyToExistingBuffer(PRUnichar*& aBuf, PRUnichar* aOldBuf, + const nsAString& aStr) { + NS_ASSERTION(aOldBuf, "Cannot work on null buffer!"); + PRUint32 len = aStr.Length(); + aBuf = NS_STATIC_CAST(PRUnichar*, + nsMemory::Realloc(aOldBuf, sizeof(PRUint32) + + len * sizeof(PRUnichar))); + *(NS_REINTERPRET_CAST(PRUint32*, aBuf)) = len; + CopyUnicodeTo(aStr, 0, StrPtr(aBuf), len); + } + /** + * Construct from another nsCheapStringBuffer + * @param aBuf the buffer to put into + * @param aSrc the buffer to construct from + */ + static void Clone(PRUnichar*& aBuf, const PRUnichar* aSrc) { + NS_ASSERTION(aSrc, "Cannot work on null buffer!"); + aBuf = (PRUnichar*)nsMemory::Clone(aSrc, sizeof(PRUint32) + + Length(aSrc) * sizeof(PRUnichar)); + } + /** + * Free the memory for the buf + * @param aBuf the buffer to free + */ + static void Free(PRUnichar* aBuf) { + NS_ASSERTION(aBuf, "Cannot work on null buffer!"); + nsMemory::Free(aBuf); + } + /** + * Get a hashcode for the buffer + * @param aBuf the buffer + * @return the hashcode + */ + static PRUint32 HashCode(const PRUnichar* aBuf) { + NS_ASSERTION(aBuf, "Cannot work on null buffer!"); + return nsCRT::BufferHashCode(StrPtr(aBuf), + Length(aBuf)); + } +}; + nsAttrValue::nsAttrValue() : mBits(0) { @@ -85,6 +178,26 @@ nsAttrValue::~nsAttrValue() ResetIfSet(); } +/* static */ +nsresult +nsAttrValue::Init() +{ + NS_ASSERTION(!sEnumTableArray, "nsAttrValue already initialized"); + + sEnumTableArray = new nsVoidArray; + NS_ENSURE_TRUE(sEnumTableArray, NS_ERROR_OUT_OF_MEMORY); + + return NS_OK; +} + +/* static */ +void +nsAttrValue::Shutdown() +{ + delete sEnumTableArray; + sEnumTableArray = nsnull; +} + nsAttrValue::ValueType nsAttrValue::Type() const { @@ -232,10 +345,10 @@ nsAttrValue::SetTo(const nsAString& aValue) } void -nsAttrValue::SetTo(PRInt16 aInt, ValueType aType) +nsAttrValue::SetTo(PRInt16 aInt) { ResetIfSet(); - SetIntValueAndType(aInt, aType); + SetIntValueAndType(aInt, eInteger); } void @@ -315,7 +428,19 @@ nsAttrValue::ToString(nsAString& aResult) const } case eEnum: { - NS_NOTREACHED("trying to convert enum to string"); + PRInt16 val = GetEnumValue(); + EnumTable* table = NS_STATIC_CAST(EnumTable*, sEnumTableArray-> + FastElementAt(GetIntInternal() & NS_ATTRVALUE_ENUMTABLEINDEX_MASK)); + while (table->tag) { + if (table->value == val) { + aResult.AssignASCII(table->tag); + + return; + } + table++; + } + + NS_NOTREACHED("couldn't find value in EnumTable"); break; } @@ -365,71 +490,6 @@ nsAttrValue::ToString(nsAString& aResult) const } } -void -nsAttrValue::ToHTMLValue(nsHTMLValue& aResult) const -{ - switch(Type()) { - case eString: - { - aResult.SetStringValue(GetStringValue()); - break; - } - case eAtom: - { - nsAutoString tmp; - GetAtomValue()->ToString(tmp); - aResult.SetStringValue(tmp); - break; - } - case eInteger: - { - aResult.SetIntValue(GetIntInternal(), eHTMLUnit_Integer); - break; - } - case eColor: - { - nscolor v; - GetColorValue(v); - aResult.SetColorValue(v); - break; - } - case eProportional: - { - aResult.SetIntValue(GetProportionalValue(), eHTMLUnit_Proportional); - break; - } - case eEnum: - { - aResult.SetIntValue(GetEnumValue(), eHTMLUnit_Enumerated); - break; - } - case ePercent: - { - aResult.SetPercentValue(GetPercentValue()); - break; - } - case eCSSStyleRule: - { - aResult.SetCSSStyleRuleValue(GetCSSStyleRuleValue()); - break; - } - case eAtomArray: - { - nsCOMArray* array = new nsCOMArray(*GetAtomArrayValue()); - aResult.SetAtomArrayValue(array); - break; - } -#ifdef MOZ_SVG - case eSVGValue: - { - nsAutoString tmp; - GetSVGValue()->GetValueString(tmp); - aResult.SetStringValue(tmp); - } -#endif - } -} - const nsDependentSubstring nsAttrValue::GetStringValue() const { @@ -738,16 +798,36 @@ nsAttrValue::ParseStringOrAtom(const nsAString& aValue) PRBool nsAttrValue::ParseEnumValue(const nsAString& aValue, - const nsHTMLValue::EnumTable* aTable, + const EnumTable* aTable, PRBool aCaseSensitive) { ResetIfSet(); + // Have to const cast here since nsVoidArray can't deal with constpointers + EnumTable* tableStart = NS_CONST_CAST(EnumTable*, aTable); + nsAutoString val(aValue); while (aTable->tag) { if (aCaseSensitive ? val.EqualsASCII(aTable->tag) : val.EqualsIgnoreCase(aTable->tag)) { - SetIntValueAndType(aTable->value, eEnum); + + // Find index of EnumTable + PRInt16 index = sEnumTableArray->IndexOf(tableStart); + if (index < 0) { + index = sEnumTableArray->Count(); + NS_ASSERTION(index <= NS_ATTRVALUE_ENUMTABLEINDEX_MAXVALUE, + "too many enum tables"); + if (!sEnumTableArray->AppendElement(tableStart)) { + return PR_FALSE; + } + } + + PRInt32 value = (aTable->value << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) + + index; + + SetIntValueAndType(value, eEnum); + NS_ASSERTION(GetEnumValue() == aTable->value, + "failed to store enum properly"); return PR_TRUE; } diff --git a/mozilla/content/base/src/nsAttrValue.h b/mozilla/content/base/src/nsAttrValue.h index 642290e4af3..39119a714c4 100644 --- a/mozilla/content/base/src/nsAttrValue.h +++ b/mozilla/content/base/src/nsAttrValue.h @@ -43,13 +43,13 @@ #include "nsDependentSubstring.h" #include "nsColor.h" #include "nsCOMArray.h" -#include "nsHTMLValue.h" typedef unsigned long PtrBits; class nsAString; class nsIAtom; class nsICSSStyleRule; class nsISVGValue; +class nsIDocument; #define NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM 12 @@ -62,6 +62,10 @@ class nsISVGValue; #define NS_ATTRVALUE_INTEGERTYPE_MAXVALUE ((1 << (31 - NS_ATTRVALUE_INTEGERTYPE_BITS)) - 1) #define NS_ATTRVALUE_INTEGERTYPE_MINVALUE (-NS_ATTRVALUE_INTEGERTYPE_MAXVALUE - 1) +#define NS_ATTRVALUE_ENUMTABLEINDEX_BITS (32 - 16 - NS_ATTRVALUE_INTEGERTYPE_BITS) +#define NS_ATTRVALUE_ENUMTABLEINDEX_MAXVALUE ((1 << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) - 1) +#define NS_ATTRVALUE_ENUMTABLEINDEX_MASK (PtrBits((1 << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) - 1)) + class nsAttrValue { public: nsAttrValue(); @@ -73,6 +77,9 @@ public: #endif ~nsAttrValue(); + static nsresult Init(); + static void Shutdown(); + // This has to be the same as in ValueBaseType enum ValueType { eString = 0x00, // 00 @@ -98,7 +105,7 @@ public: void SetTo(const nsAttrValue& aOther); void SetTo(const nsAString& aValue); - void SetTo(PRInt16 aInt, ValueType aType); + void SetTo(PRInt16 aInt); void SetTo(nsICSSStyleRule* aValue); #ifdef MOZ_SVG void SetTo(nsISVGValue* aValue); @@ -107,7 +114,6 @@ public: void SwapValueWith(nsAttrValue& aOther); void ToString(nsAString& aResult) const; - void ToHTMLValue(nsHTMLValue& aResult) const; // Methods to get value. These methods do not convert so only use them // to retrieve the datatype that this nsAttrValue has. @@ -117,7 +123,7 @@ public: inline PRInt32 GetIntegerValue() const; PRBool GetColorValue(nscolor& aColor) const; inline PRInt32 GetProportionalValue() const; - inline PRInt32 GetEnumValue() const; + inline PRInt16 GetEnumValue() const; inline float GetPercentValue() const; inline nsCOMArray* GetAtomArrayValue() const; inline nsICSSStyleRule* GetCSSStyleRuleValue() const; @@ -140,6 +146,23 @@ public: void ParseAtomArray(const nsAString& aValue); void ParseStringOrAtom(const nsAString& aValue); + /** + * Structure for a mapping from int (enum) values to strings. When you use + * it you generally create an array of them. + * Instantiate like this: + * EnumTable myTable[] = { + * { "string1", 1 }, + * { "string2", 2 }, + * { 0 } + * } + */ + struct EnumTable { + /** The string the value maps to */ + const char* tag; + /** The enum value that maps to this string */ + PRInt16 value; + }; + /** * Parse into an enum value. * @@ -149,7 +172,7 @@ public: * @return whether the enum value was found or not */ PRBool ParseEnumValue(const nsAString& aValue, - const nsHTMLValue::EnumTable* aTable, + const EnumTable* aTable, PRBool aCaseSensitive = PR_FALSE); /** @@ -233,6 +256,8 @@ private: PRBool EnsureEmptyMiscContainer(); PRBool EnsureEmptyAtomArray(); + static nsVoidArray* sEnumTableArray; + PtrBits mBits; }; @@ -261,11 +286,14 @@ nsAttrValue::GetProportionalValue() const return GetIntInternal(); } -inline PRInt32 +inline PRInt16 nsAttrValue::GetEnumValue() const { NS_PRECONDITION(Type() == eEnum, "wrong type"); - return GetIntInternal(); + // We don't need to worry about sign extension here since we're + // returning an PRInt16 which will cut away the top bits. + return NS_STATIC_CAST(PRInt16, + GetIntInternal() >> NS_ATTRVALUE_ENUMTABLEINDEX_BITS); } inline float diff --git a/mozilla/content/base/src/nsHTMLValue.cpp b/mozilla/content/base/src/nsHTMLValue.cpp deleted file mode 100644 index 4418a6a24aa..00000000000 --- a/mozilla/content/base/src/nsHTMLValue.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nscore.h" -#include "nsHTMLValue.h" -#include "nsString.h" -#include "nsReadableUtils.h" -#include "nsUnicharUtils.h" -#include "nsCRT.h" -#include "nsMemory.h" -#include "nsIDocument.h" -#include "nsIHTMLDocument.h" -#include "nsUnitConversion.h" -#include "prprf.h" -#include "nsICSSStyleRule.h" -#include "nsCSSDeclaration.h" - -nsHTMLValue::nsHTMLValue() - : mUnit(eHTMLUnit_String) -{ - mValue.mString = nsnull; -} - -nsHTMLValue::nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit) - : mUnit(aUnit) -{ - NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER, "unit not an integer unit"); - if (GetUnitClass() == HTMLUNIT_INTEGER) { - mValue.mInt = aValue; - } else { - mUnit = eHTMLUnit_String; - mValue.mString = nsnull; - } -} - -nsHTMLValue::~nsHTMLValue(void) -{ - Reset(); -} - -void nsHTMLValue::Reset(void) -{ - if (GetUnitClass() == HTMLUNIT_STRING) { - if (mValue.mString) { - nsCheapStringBufferUtils::Free(mValue.mString); - } - } - else if (mUnit == eHTMLUnit_CSSStyleRule) { - NS_IF_RELEASE(mValue.mCSSStyleRule); - } - else if (mUnit == eHTMLUnit_AtomArray) { - delete mValue.mAtomArray; - } - mUnit = eHTMLUnit_String; - mValue.mString = nsnull; -} - - -void nsHTMLValue::SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit) -{ - Reset(); - mUnit = aUnit; - NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER, "not an int value"); - if (GetUnitClass() == HTMLUNIT_INTEGER) { - mValue.mInt = aValue; - } else { - mUnit = eHTMLUnit_String; - mValue.mString = nsnull; - } -} - -void nsHTMLValue::SetPercentValue(float aValue) -{ - Reset(); - mUnit = eHTMLUnit_Percent; - mValue.mFloat = aValue; -} - -void nsHTMLValue::SetStringValueInternal(const nsAString& aValue, - nsHTMLUnit aUnit) -{ - NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING, "unit not a string unit!"); - if (GetUnitClass() == HTMLUNIT_STRING) { - // Remember the length of the string if necessary - if (aValue.IsEmpty()) { - mValue.mString = nsnull; - } else { - nsCheapStringBufferUtils::CopyToBuffer(mValue.mString, aValue); - } - } else { - mUnit = eHTMLUnit_String; - mValue.mString = nsnull; - } -} - -void nsHTMLValue::SetStringValue(const nsAString& aValue, - nsHTMLUnit aUnit) -{ - Reset(); - mUnit = aUnit; - SetStringValueInternal(aValue, aUnit); -} - -void nsHTMLValue::SetCSSStyleRuleValue(nsICSSStyleRule* aValue) -{ - Reset(); - mUnit = eHTMLUnit_CSSStyleRule; - mValue.mCSSStyleRule = aValue; - NS_IF_ADDREF(mValue.mCSSStyleRule); -} - -void nsHTMLValue::SetAtomArrayValue(nsCOMArray* aValue) -{ - Reset(); - mUnit = eHTMLUnit_AtomArray; - mValue.mAtomArray = aValue; -} - -void nsHTMLValue::SetColorValue(nscolor aValue) -{ - Reset(); - mUnit = eHTMLUnit_Color; - mValue.mColor = aValue; -} - -// -// Parsing methods -// - -PRBool -nsHTMLValue::EnumValueToString(const EnumTable* aTable, - nsAString& aResult) const -{ - if (GetUnit() == eHTMLUnit_Enumerated) { - PRInt32 v = GetIntValue(); - while (aTable->tag) { - if (aTable->value == v) { - CopyASCIItoUCS2(nsDependentCString(aTable->tag), aResult); - - return PR_TRUE; - } - aTable++; - } - } - aResult.Truncate(); - return PR_FALSE; -} diff --git a/mozilla/content/base/src/nsHTMLValue.h b/mozilla/content/base/src/nsHTMLValue.h deleted file mode 100644 index ee33b271c04..00000000000 --- a/mozilla/content/base/src/nsHTMLValue.h +++ /dev/null @@ -1,380 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsHTMLValue_h___ -#define nsHTMLValue_h___ - -#include "nscore.h" -#include "nsColor.h" -#include "nsString.h" -#include "nsCOMPtr.h" - -#include "nsReadableUtils.h" -#include "nsCRT.h" -#include "nsCOMArray.h" -#include "nsIAtom.h" - -class nsIDocument; -class nsICSSStyleRule; - -class nsCheapStringBufferUtils { -public: - /** - * Get the string pointer - * @param aBuf the buffer - * @return a pointer to the string - */ - static const PRUnichar* StrPtr(const PRUnichar* aBuf) { - NS_ASSERTION(aBuf, "Cannot work on null buffer!"); - return (const PRUnichar*)( ((const char*)aBuf) + sizeof(PRUint32) ); - } - static PRUnichar* StrPtr(PRUnichar* aBuf) { - NS_ASSERTION(aBuf, "Cannot work on null buffer!"); - return (PRUnichar*)( ((char*)aBuf) + sizeof(PRUint32) ); - } - /** - * Get the string length - * @param aBuf the buffer - * @return the string length - */ - static PRUint32 Length(const PRUnichar* aBuf) { - NS_ASSERTION(aBuf, "Cannot work on null buffer!"); - return *((PRUint32*)aBuf); - } - /** - * Get a DependentString from a buffer - * - * @param aBuf the buffer to get string from - * @return a DependentString representing this string - */ - static nsDependentSubstring GetDependentString(const PRUnichar* aBuf) { - NS_ASSERTION(aBuf, "Cannot work on null buffer!"); - const PRUnichar* buf = StrPtr(aBuf); - return Substring(buf, buf + Length(aBuf)); - } - /** - * Construct from an AString - * @param aBuf the buffer to copy to - * @param aStr the string to construct from - */ - static void CopyToBuffer(PRUnichar*& aBuf, const nsAString& aStr) { - PRUint32 len = aStr.Length(); - aBuf = (PRUnichar*)nsMemory::Alloc(sizeof(PRUint32) + - len * sizeof(PRUnichar)); - *((PRUint32*)aBuf) = len; - CopyUnicodeTo(aStr, 0, StrPtr(aBuf), len); - } - /** - * Construct from an AString - * @param aBuf the buffer to copy to - * @param aStr the string to construct from - */ - static void CopyToExistingBuffer(PRUnichar*& aBuf, PRUnichar* aOldBuf, - const nsAString& aStr) { - NS_ASSERTION(aOldBuf, "Cannot work on null buffer!"); - PRUint32 len = aStr.Length(); - aBuf = NS_STATIC_CAST(PRUnichar*, - nsMemory::Realloc(aOldBuf, sizeof(PRUint32) + - len * sizeof(PRUnichar))); - *(NS_REINTERPRET_CAST(PRUint32*, aBuf)) = len; - CopyUnicodeTo(aStr, 0, StrPtr(aBuf), len); - } - /** - * Construct from another nsCheapStringBuffer - * @param aBuf the buffer to put into - * @param aSrc the buffer to construct from - */ - static void Clone(PRUnichar*& aBuf, const PRUnichar* aSrc) { - NS_ASSERTION(aSrc, "Cannot work on null buffer!"); - aBuf = (PRUnichar*)nsMemory::Clone(aSrc, sizeof(PRUint32) + - Length(aSrc) * sizeof(PRUnichar)); - } - /** - * Free the memory for the buf - * @param aBuf the buffer to free - */ - static void Free(PRUnichar* aBuf) { - NS_ASSERTION(aBuf, "Cannot work on null buffer!"); - nsMemory::Free(aBuf); - } - /** - * Get a hashcode for the buffer - * @param aBuf the buffer - * @return the hashcode - */ - static PRUint32 HashCode(const PRUnichar* aBuf) { - NS_ASSERTION(aBuf, "Cannot work on null buffer!"); - return nsCRT::BufferHashCode(StrPtr(aBuf), - Length(aBuf)); - } -}; - -// -// nsHTMLUnit is two bytes: the class of type, and a specifier to distinguish -// between different things stored as the same type. Doing -// mUnit & HTMLUNIT_CLASS_MASK should give you the class of type. -// -#define HTMLUNIT_STRING 0x0100 -#define HTMLUNIT_INTEGER 0x0200 -#define HTMLUNIT_COLOR 0x0800 -#define HTMLUNIT_CSSSTYLERULE 0x1000 -#define HTMLUNIT_PERCENT 0x2000 -#define HTMLUNIT_ATOMARRAY 0x4000 -#define HTMLUNIT_CLASS_MASK 0xff00 - -enum nsHTMLUnit { - // a string value - eHTMLUnit_String = HTMLUNIT_STRING, - - // a simple int value - eHTMLUnit_Integer = HTMLUNIT_INTEGER, - // value has enumerated meaning - eHTMLUnit_Enumerated = HTMLUNIT_INTEGER | 1, - // value is a relative proportion of some whole - eHTMLUnit_Proportional = HTMLUNIT_INTEGER | 2, - - // an RGBA value - eHTMLUnit_Color = HTMLUNIT_COLOR, - - // a nsICSSStyleRule - eHTMLUnit_CSSStyleRule = HTMLUNIT_CSSSTYLERULE, - - // (1.0 == 100%) value is percentage of something - eHTMLUnit_Percent = HTMLUNIT_PERCENT, - - // an array of atoms - eHTMLUnit_AtomArray = HTMLUNIT_ATOMARRAY -}; - -/** - * Class which is used to represent the value of an attribute of an - * HTML element. The value has a unit which is an nsHTMLUnit; - * checking the unit is a must before asking for the value in any - * particular form. - */ -class nsHTMLValue { -public: - nsHTMLValue(); - nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit); - ~nsHTMLValue(void); - - - /** - * Get the unit of this HTMLValue - * @return the unit of this HTMLValue - */ - nsHTMLUnit GetUnit(void) const { return (nsHTMLUnit)mUnit; } - - PRInt32 GetIntValue(void) const; - float GetPercentValue(void) const; - nsAString& GetStringValue(nsAString& aBuffer) const; - PRBool GetColorValue(nscolor& aColor) const; - - PRBool IsEmptyString() const; - - /** - * Reset the string to null type, freeing things in the process if necessary. - */ - void Reset(void); - void SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit); - void SetPercentValue(float aValue); - void SetStringValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String); - void SetCSSStyleRuleValue(nsICSSStyleRule* aValue); - void SetAtomArrayValue(nsCOMArray* aValue); - void SetColorValue(nscolor aValue); - - /** - * Structure for a mapping from int (enum) values to strings. When you use - * it you generally create an array of them. - * Instantiate like this: - * EnumTable myTable[] = { - * { "string1", 1 }, - * { "string2", 2 }, - * { 0 } - * } - */ - struct EnumTable { - /** The string the value maps to */ - const char* tag; - /** The enum value that maps to this string */ - PRInt16 value; - }; - - /** - * Parse and output this HTMLValue in a variety of ways - */ - // Attribute parsing utilities - - /** - * Map an enum HTMLValue to its string - * - * @param aValue the HTMLValue with the int in it - * @param aTable the enumeration to map with - * @param aResult the string the value maps to [OUT] - * @return whether the enum value was found or not - */ - PRBool EnumValueToString(const EnumTable* aTable, - nsAString& aResult) const; - -protected: - /** - * The unit of the value - * @see nsHTMLUnit - */ - PRUint32 mUnit; - - /** - * The actual value. Please to not be adding more-than-4-byte things to this - * union. - */ - union { - /** Int. */ - PRInt32 mInt; - /** Float. */ - float mFloat; - /** String. First 4 bytes are the length, non-null-terminated. */ - PRUnichar* mString; - /** nsICSSStyleRule. Strong reference. */ - nsICSSStyleRule* mCSSStyleRule; - /** Color. */ - nscolor mColor; - /** Array if atoms */ - nsCOMArray* mAtomArray; - } mValue; - -private: - /** - * Helper to set string value (checks for embedded nulls or length); verifies - * that aUnit is a string type as well. - * @param aValue the value to set - * @param aUnit the unit to set - */ - void SetStringValueInternal(const nsAString& aValue, nsHTMLUnit aUnit); - /** - * Get a DependentString from mValue.mString (if the string is stored with - * length, passes that information to the DependentString). Do not call this - * if mValue.mString is null. - * - * @return a DependentString representing this string - */ - nsDependentSubstring GetDependentString() const; - /** - * Get the unit class (HTMLUNIT_*) - * @return the unit class - */ - PRUint32 GetUnitClass() const { return mUnit & HTMLUNIT_CLASS_MASK; } - - nsHTMLValue(const nsHTMLValue& aCopy); // NOT TO BE IMPLEMENTED - PRBool operator==(const nsHTMLValue& aOther) const; // NOT TO BE IMPLEMENTED - nsHTMLValue& operator=(const nsHTMLValue& aCopy); // NOT TO BE IMPLEMENTED - PRBool operator!=(const nsHTMLValue& aOther) const; // NOT TO BE IMPLEMENTED -}; - -inline nsDependentSubstring nsHTMLValue::GetDependentString() const -{ - NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING, - "Some dork called GetDependentString() on a non-string!"); - static const PRUnichar blankStr[] = { '\0' }; - return mValue.mString - ? nsCheapStringBufferUtils::GetDependentString(mValue.mString) - : Substring(blankStr, blankStr); -} - -inline PRInt32 nsHTMLValue::GetIntValue(void) const -{ - NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING || - GetUnitClass() == HTMLUNIT_INTEGER, - "not an int value"); - PRUint32 unitClass = GetUnitClass(); - if (unitClass == HTMLUNIT_INTEGER) { - return mValue.mInt; - } - - if (unitClass == HTMLUNIT_STRING) { - if (mValue.mString) { - PRInt32 err=0; - // XXX this copies. new string APIs will make this better, right? - nsAutoString str(GetDependentString()); - return str.ToInteger(&err); - } - } - - return 0; -} - -inline float nsHTMLValue::GetPercentValue(void) const -{ - NS_ASSERTION(mUnit == eHTMLUnit_Percent, "not a percent value"); - if (mUnit == eHTMLUnit_Percent) { - return mValue.mFloat; - } - return 0.0f; -} - -inline nsAString& nsHTMLValue::GetStringValue(nsAString& aBuffer) const -{ - NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING, - "not a string value"); - if (GetUnitClass() == HTMLUNIT_STRING && mValue.mString) { - aBuffer = GetDependentString(); - } else { - aBuffer.Truncate(); - } - return aBuffer; -} - -inline PRBool nsHTMLValue::GetColorValue(nscolor& aColor) const -{ - NS_ASSERTION((mUnit == eHTMLUnit_Color) || (mUnit == eHTMLUnit_String), - "not a color value"); - if (mUnit == eHTMLUnit_Color) { - aColor = mValue.mColor; - - return PR_TRUE; - } - if (mUnit == eHTMLUnit_String && mValue.mString) { - return NS_ColorNameToRGB(GetDependentString(), &aColor); - } - return PR_FALSE; -} - -inline PRBool nsHTMLValue::IsEmptyString() const -{ - return mUnit == eHTMLUnit_String && !mValue.mString; -} - -#endif /* nsHTMLValue_h___ */ - diff --git a/mozilla/content/html/content/src/nsFormSubmission.cpp b/mozilla/content/html/content/src/nsFormSubmission.cpp index 711e5a37f6d..c0d64101638 100644 --- a/mozilla/content/html/content/src/nsFormSubmission.cpp +++ b/mozilla/content/html/content/src/nsFormSubmission.cpp @@ -49,7 +49,6 @@ #include "nsIScriptGlobalObject.h" #include "nsIDOMHTMLFormElement.h" #include "nsDOMError.h" -#include "nsHTMLValue.h" #include "nsGenericHTMLElement.h" #include "nsISaveAsCharset.h" @@ -1226,11 +1225,8 @@ nsFormSubmission::GetSubmitCharset(nsGenericHTMLElement* aForm, nsresult rv = NS_OK; nsAutoString acceptCharsetValue; - nsHTMLValue value; - rv = aForm->GetHTMLAttribute(nsHTMLAtoms::acceptcharset, value); - if (rv == NS_CONTENT_ATTR_HAS_VALUE && value.GetUnit() == eHTMLUnit_String) { - value.GetStringValue(acceptCharsetValue); - } + aForm->GetAttr(kNameSpaceID_None, nsHTMLAtoms::acceptcharset, + acceptCharsetValue); PRInt32 charsetLen = acceptCharsetValue.Length(); if (charsetLen > 0) { @@ -1395,11 +1391,9 @@ void nsFormSubmission::GetEnumAttr(nsGenericHTMLElement* aContent, nsIAtom* atom, PRInt32* aValue) { - nsHTMLValue value; - if (aContent->GetHTMLAttribute(atom, value) == NS_CONTENT_ATTR_HAS_VALUE) { - if (eHTMLUnit_Enumerated == value.GetUnit()) { - *aValue = value.GetIntValue(); - } + const nsAttrValue* value = aContent->GetParsedAttr(atom); + if (value && value->Type() == nsAttrValue::eEnum) { + *aValue = value->GetEnumValue(); } } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 7fdb95f38f5..fff0f00513e 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -479,7 +479,7 @@ nsGenericHTMLElement::SetLang(const nsAString& aLang) return NS_OK; } -static const nsHTMLValue::EnumTable kDirTable[] = { +static const nsAttrValue::EnumTable kDirTable[] = { { "ltr", NS_STYLE_DIRECTION_LTR }, { "rtl", NS_STYLE_DIRECTION_RTL }, { 0 } @@ -488,11 +488,13 @@ static const nsHTMLValue::EnumTable kDirTable[] = { nsresult nsGenericHTMLElement::GetDir(nsAString& aDir) { - nsHTMLValue value; - nsresult result = GetHTMLAttribute(nsHTMLAtoms::dir, value); + const nsAttrValue* attr = mAttrsAndChildren.GetAttr(nsHTMLAtoms::dir); - if (NS_CONTENT_ATTR_HAS_VALUE == result) { - value.EnumValueToString(kDirTable, aDir); + if (attr && attr->Type() == nsAttrValue::eInteger) { + attr->ToString(aDir); + } + else { + aDir.Truncate(); } return NS_OK; @@ -1762,12 +1764,7 @@ nsGenericHTMLElement::SetAttrAndNotify(PRInt32 aNamespaceID, mutation.mAttrName = aAttribute; nsAutoString newValue; - // It sucks that we have to call GetAttr just to get the stringvalue - // here, but in SetInlineStyleRule we don't have the stringvalue - // directly and it would be a waste of time to get it since in the - // common case it's not needed. If we make nsHTMLValue->string - // conversion possible we wouldn't have to do this. - GetAttr(aNamespaceID, aAttribute, newValue); + aParsedValue.ToString(newValue); if (!newValue.IsEmpty()) { mutation.mNewAttrValue = do_GetAtom(newValue); } @@ -1873,40 +1870,11 @@ nsGenericHTMLElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute, return NS_CONTENT_ATTR_NOT_THERE; } - // Use subclass to convert enums to string. - if (attrValue->Type() == nsAttrValue::eEnum) { - nsHTMLValue htmlVal(attrValue->GetEnumValue(), eHTMLUnit_Enumerated); - if (aNameSpaceID != kNameSpaceID_None || - AttributeToString(aAttribute, htmlVal, aResult) != - NS_CONTENT_ATTR_HAS_VALUE) { - NS_NOTREACHED("no enum to string conversion found"); - - return NS_CONTENT_ATTR_NOT_THERE; - } - return NS_CONTENT_ATTR_HAS_VALUE; - } - attrValue->ToString(aResult); return NS_CONTENT_ATTR_HAS_VALUE; } -nsresult -nsGenericHTMLElement::GetHTMLAttribute(nsIAtom* aAttribute, - nsHTMLValue& aValue) const -{ - const nsAttrValue* val = mAttrsAndChildren.GetAttr(aAttribute); - - if (!val) { - aValue.Reset(); - return NS_CONTENT_ATTR_NOT_THERE; - } - - val->ToHTMLValue(aValue); - - return NS_CONTENT_ATTR_HAS_VALUE; -} - const nsAttrValue* nsGenericHTMLElement::GetClasses() const { @@ -2183,22 +2151,6 @@ nsGenericHTMLElement::IsContentOfType(PRUint32 aFlags) const //---------------------------------------------------------------------- -nsresult -nsGenericHTMLElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (nsHTMLAtoms::dir == aAttribute) { - if (aValue.GetUnit() == eHTMLUnit_Enumerated) { - aValue.EnumValueToString(kDirTable, aResult); - - return NS_OK; - } - } - aResult.Truncate(); - return NS_CONTENT_ATTR_NOT_THERE; -} - PRBool nsGenericHTMLElement::ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, @@ -2415,7 +2367,7 @@ nsGenericHTMLElement::GetPresContext() } // XXX check all mappings against ebina's usage -static const nsHTMLValue::EnumTable kAlignTable[] = { +static const nsAttrValue::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, @@ -2433,7 +2385,7 @@ static const nsHTMLValue::EnumTable kAlignTable[] = { // Elements that should return vertical align values "middle", "bottom", and "top" // instead of "center", "baseline", and "texttop" from GetAttribute() should use this -static const nsHTMLValue::EnumTable kVAlignTable[] = { +static const nsAttrValue::EnumTable kVAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, { "top", NS_STYLE_VERTICAL_ALIGN_TOP },//verified @@ -2448,7 +2400,7 @@ static const nsHTMLValue::EnumTable kVAlignTable[] = { { 0 } }; -static const nsHTMLValue::EnumTable kDivAlignTable[] = { +static const nsAttrValue::EnumTable kDivAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, @@ -2457,7 +2409,7 @@ static const nsHTMLValue::EnumTable kDivAlignTable[] = { { 0 } }; -static const nsHTMLValue::EnumTable kFrameborderTable[] = { +static const nsAttrValue::EnumTable kFrameborderTable[] = { { "yes", NS_STYLE_FRAME_YES }, { "no", NS_STYLE_FRAME_NO }, { "1", NS_STYLE_FRAME_1 }, @@ -2465,7 +2417,7 @@ static const nsHTMLValue::EnumTable kFrameborderTable[] = { { 0 } }; -static const nsHTMLValue::EnumTable kScrollingTable[] = { +static const nsAttrValue::EnumTable kScrollingTable[] = { { "yes", NS_STYLE_FRAME_YES }, { "no", NS_STYLE_FRAME_NO }, { "on", NS_STYLE_FRAME_ON }, @@ -2476,7 +2428,7 @@ static const nsHTMLValue::EnumTable kScrollingTable[] = { { 0 } }; -static const nsHTMLValue::EnumTable kTableVAlignTable[] = { +static const nsAttrValue::EnumTable kTableVAlignTable[] = { { "top", NS_STYLE_VERTICAL_ALIGN_TOP }, { "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE }, { "bottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM }, @@ -2494,7 +2446,7 @@ nsGenericHTMLElement::ParseAlignValue(const nsAString& aString, //---------------------------------------- // Vanilla table as defined by the html4 spec... -static const nsHTMLValue::EnumTable kTableHAlignTable[] = { +static const nsAttrValue::EnumTable kTableHAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_CENTER }, @@ -2504,7 +2456,7 @@ static const nsHTMLValue::EnumTable kTableHAlignTable[] = { }; // This table is used for TABLE when in compatability mode -static const nsHTMLValue::EnumTable kCompatTableHAlignTable[] = { +static const nsAttrValue::EnumTable kCompatTableHAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_CENTER }, @@ -2526,20 +2478,10 @@ nsGenericHTMLElement::ParseTableHAlignValue(const nsAString& aString, return aResult.ParseEnumValue(aString, kTableHAlignTable); } -PRBool -nsGenericHTMLElement::TableHAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (InNavQuirksMode(GetOwnerDoc())) { - return aValue.EnumValueToString(kCompatTableHAlignTable, aResult); - } - return aValue.EnumValueToString(kTableHAlignTable, aResult); -} - //---------------------------------------- // These tables are used for TD,TH,TR, etc (but not TABLE) -static const nsHTMLValue::EnumTable kTableCellHAlignTable[] = { +static const nsAttrValue::EnumTable kTableCellHAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, @@ -2548,7 +2490,7 @@ static const nsHTMLValue::EnumTable kTableCellHAlignTable[] = { { 0 } }; -static const nsHTMLValue::EnumTable kCompatTableCellHAlignTable[] = { +static const nsAttrValue::EnumTable kCompatTableCellHAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, @@ -2561,7 +2503,6 @@ static const nsHTMLValue::EnumTable kCompatTableCellHAlignTable[] = { // NS_STYLE_TEXT_ALIGN_CENTER to map to center by using the following order { "center", NS_STYLE_TEXT_ALIGN_CENTER }, { "absmiddle", NS_STYLE_TEXT_ALIGN_CENTER }, - { 0 } }; @@ -2575,16 +2516,6 @@ nsGenericHTMLElement::ParseTableCellHAlignValue(const nsAString& aString, return aResult.ParseEnumValue(aString, kTableCellHAlignTable); } -PRBool -nsGenericHTMLElement::TableCellHAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (InNavQuirksMode(GetOwnerDoc())) { - return aValue.EnumValueToString(kCompatTableCellHAlignTable, aResult); - } - return aValue.EnumValueToString(kTableCellHAlignTable, aResult); -} - //---------------------------------------- PRBool @@ -2594,27 +2525,6 @@ nsGenericHTMLElement::ParseTableVAlignValue(const nsAString& aString, return aResult.ParseEnumValue(aString, kTableVAlignTable); } -PRBool -nsGenericHTMLElement::AlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) -{ - return aValue.EnumValueToString(kAlignTable, aResult); -} - -PRBool -nsGenericHTMLElement::VAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) -{ - return aValue.EnumValueToString(kVAlignTable, aResult); -} - -PRBool -nsGenericHTMLElement::TableVAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) -{ - return aValue.EnumValueToString(kTableVAlignTable, aResult); -} - PRBool nsGenericHTMLElement::ParseDivAlignValue(const nsAString& aString, nsAttrValue& aResult) const @@ -2622,13 +2532,6 @@ nsGenericHTMLElement::ParseDivAlignValue(const nsAString& aString, return aResult.ParseEnumValue(aString, kDivAlignTable); } -PRBool -nsGenericHTMLElement::DivAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) const -{ - return aValue.EnumValueToString(kDivAlignTable, aResult); -} - PRBool nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute, const nsAString& aString, @@ -2653,13 +2556,6 @@ nsGenericHTMLElement::ParseFrameborderValue(const nsAString& aString, return aResult.ParseEnumValue(aString, kFrameborderTable); } -PRBool -nsGenericHTMLElement::FrameborderValueToString(const nsHTMLValue& aValue, - nsAString& aResult) -{ - return aValue.EnumValueToString(kFrameborderTable, aResult); -} - PRBool nsGenericHTMLElement::ParseScrollingValue(const nsAString& aString, nsAttrValue& aResult) @@ -2667,13 +2563,6 @@ nsGenericHTMLElement::ParseScrollingValue(const nsAString& aString, return aResult.ParseEnumValue(aString, kScrollingTable); } -PRBool -nsGenericHTMLElement::ScrollingValueToString(const nsHTMLValue& aValue, - nsAString& aResult) -{ - return aValue.EnumValueToString(kScrollingTable, aResult); -} - nsresult nsGenericHTMLElement::ReparseStyleAttribute() { diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index 569e881de3f..59d3fbecd4b 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -62,7 +62,6 @@ class nsIForm; class nsIPresState; class nsIScrollableView; class nsILayoutHistoryState; -class nsHTMLValue; struct nsRect; struct nsSize; struct nsRuleData; @@ -239,7 +238,10 @@ public: // HTML element methods void Compact() { mAttrsAndChildren.Compact(); } - nsresult GetHTMLAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const; + const nsAttrValue* GetParsedAttr(nsIAtom* aAttr) const + { + return mAttrsAndChildren.GetAttr(aAttr); + } virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; // Implementation for nsIStyledContent @@ -253,22 +255,6 @@ public: already_AddRefed GetBaseURI() const; //---------------------------------------- - /** - * Turn an attribute value into string based on the type of attribute - * (does not need to do standard types such as string, integer, - * color ...). Called by GetAttr(). - * - * @param aAttribute the attribute to convert - * @param aValue the value to convert - * @param aResult the string [OUT] - * @return NS_CONTENT_ATTR_HAS_VALUE if the value was successfully converted - * NS_CONTENT_ATTR_NOT_THERE if the value could not be converted - * @see nsGenericHTMLElement::GetAttr - */ - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; - /** * Convert an attribute string value to attribute type based on the type of * attribute. Called by SetAttr(). @@ -353,15 +339,6 @@ public: */ PRBool ParseDivAlignValue(const nsAString& aString, nsAttrValue& aResult) const; - /** - * Convert a div align value to string - * - * @param aValue the value to convert - * @param aResult the resulting string - * @return whether the value was converted - */ - PRBool DivAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) const; /** * Convert a table halign string to value (left/right/center/char/justify) @@ -372,15 +349,6 @@ public: */ PRBool ParseTableHAlignValue(const nsAString& aString, nsAttrValue& aResult) const; - /** - * Convert a table halign value to string - * - * @param aValue the value to convert - * @param aResult the resulting string - * @return whether the value was converted - */ - PRBool TableHAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) const; /** * Convert a table cell halign string to value @@ -391,15 +359,6 @@ public: */ PRBool ParseTableCellHAlignValue(const nsAString& aString, nsAttrValue& aResult) const; - /** - * Convert a table cell halign value to string - * - * @param aValue the value to convert - * @param aResult the resulting string - * @return whether the value was converted - */ - PRBool TableCellHAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult) const; /** * Convert a table valign string to value (left/right/center/char/justify/ @@ -411,36 +370,6 @@ public: */ static PRBool ParseTableVAlignValue(const nsAString& aString, nsAttrValue& aResult); - /** - * Convert a table valign value to string - * - * @param aValue the value to convert - * @param aResult the resulting string - * @return whether the value was converted - */ - static PRBool TableVAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult); - - /** - * Convert an align value to string (left/right/texttop/baseline/center/ - * bottom/top/middle/absbottom/abscenter/absmiddle) - * - * @param aValue the value to convert - * @param aResult the resulting string - * @return whether the value was converted - */ - static PRBool AlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult); - - /** - * Convert a valign value to string - * - * @param aValue the value to convert - * @param aResult the resulting string - * @return whether the value was converted - */ - static PRBool VAlignValueToString(const nsHTMLValue& aValue, - nsAString& aResult); /** * Convert an image attribute to value (width, height, hspace, vspace, border) @@ -462,15 +391,6 @@ public: */ static PRBool ParseFrameborderValue(const nsAString& aString, nsAttrValue& aResult); - /** - * Convert a frameborder value to string - * - * @param aValue the value to convert - * @param aResult the resulting string - * @return whether the value was converted - */ - static PRBool FrameborderValueToString(const nsHTMLValue& aValue, - nsAString& aResult); /** * Convert a scrolling string to value (yes/no/on/off/scroll/noscroll/auto) @@ -481,15 +401,6 @@ public: */ static PRBool ParseScrollingValue(const nsAString& aString, nsAttrValue& aResult); - /** - * Convert a scrolling value to string - * - * @param aValue the value to convert - * @param aResult the resulting string - * @return whether the value was converted - */ - static PRBool ScrollingValueToString(const nsHTMLValue& aValue, - nsAString& aResult); /** * Create the style struct from the style attr. Used when an element is first diff --git a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp index 7a0123e3c39..139ae26276f 100644 --- a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp @@ -85,9 +85,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -166,20 +163,6 @@ nsHTMLAppletElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - nsGenericHTMLElement::VAlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLBRElement.cpp b/mozilla/content/html/content/src/nsHTMLBRElement.cpp index 8ca6bdb0626..aa871e1b57b 100644 --- a/mozilla/content/html/content/src/nsHTMLBRElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBRElement.cpp @@ -68,9 +68,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -104,7 +101,7 @@ NS_IMPL_DOM_CLONENODE(nsHTMLBRElement) NS_IMPL_STRING_ATTR(nsHTMLBRElement, Clear, clear) -static const nsHTMLValue::EnumTable kClearTable[] = { +static const nsAttrValue::EnumTable kClearTable[] = { { "left", NS_STYLE_CLEAR_LEFT }, { "right", NS_STYLE_CLEAR_RIGHT }, { "all", NS_STYLE_CLEAR_LEFT_AND_RIGHT }, @@ -124,20 +121,6 @@ nsHTMLBRElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::clear) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - aValue.EnumValueToString(kClearTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 27a26b8c494..7cd12df5ef7 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -138,8 +138,6 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) if (!aData || (aData->mSID != eStyleStruct_Margin) || !aData->mMarginData || !mPart) return NS_OK; // We only care about margins. - nsHTMLValue value; - PRInt32 bodyMarginWidth = -1; PRInt32 bodyMarginHeight = -1; PRInt32 bodyTopMargin = -1; @@ -152,11 +150,12 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) nsCompatibility mode = aData->mPresContext->CompatibilityMode(); + const nsAttrValue* value; if (mPart->GetAttrCount() > 0) { // if marginwidth/marginheight are set, reflect them as 'margin' - mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - bodyMarginWidth = value.GetIntValue(); + value = mPart->GetParsedAttr(nsHTMLAtoms::marginwidth); + if (value && value->Type() == nsAttrValue::eInteger) { + bodyMarginWidth = value->GetIntegerValue(); if (bodyMarginWidth < 0) bodyMarginWidth = 0; nsCSSRect& margin = aData->mMarginData->mMargin; if (margin.mLeft.GetUnit() == eCSSUnit_Null) @@ -165,9 +164,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) margin.mRight.SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel); } - mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - bodyMarginHeight = value.GetIntValue(); + value = mPart->GetParsedAttr(nsHTMLAtoms::marginheight); + if (value && value->Type() == nsAttrValue::eInteger) { + bodyMarginHeight = value->GetIntegerValue(); if (bodyMarginHeight < 0) bodyMarginHeight = 0; nsCSSRect& margin = aData->mMarginData->mMargin; if (margin.mTop.GetUnit() == eCSSUnit_Null) @@ -178,9 +177,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) if (eCompatibility_NavQuirks == mode){ // topmargin (IE-attribute) - mPart->GetHTMLAttribute(nsHTMLAtoms::topmargin, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - bodyTopMargin = value.GetIntValue(); + value = mPart->GetParsedAttr(nsHTMLAtoms::topmargin); + if (value && value->Type() == nsAttrValue::eInteger) { + bodyTopMargin = value->GetIntegerValue(); if (bodyTopMargin < 0) bodyTopMargin = 0; nsCSSRect& margin = aData->mMarginData->mMargin; if (margin.mTop.GetUnit() == eCSSUnit_Null) @@ -188,9 +187,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) } // bottommargin (IE-attribute) - mPart->GetHTMLAttribute(nsHTMLAtoms::bottommargin, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - bodyBottomMargin = value.GetIntValue(); + value = mPart->GetParsedAttr(nsHTMLAtoms::bottommargin); + if (value && value->Type() == nsAttrValue::eInteger) { + bodyBottomMargin = value->GetIntegerValue(); if (bodyBottomMargin < 0) bodyBottomMargin = 0; nsCSSRect& margin = aData->mMarginData->mMargin; if (margin.mBottom.GetUnit() == eCSSUnit_Null) @@ -198,9 +197,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) } // leftmargin (IE-attribute) - mPart->GetHTMLAttribute(nsHTMLAtoms::leftmargin, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - bodyLeftMargin = value.GetIntValue(); + value = mPart->GetParsedAttr(nsHTMLAtoms::leftmargin); + if (value && value->Type() == nsAttrValue::eInteger) { + bodyLeftMargin = value->GetIntegerValue(); if (bodyLeftMargin < 0) bodyLeftMargin = 0; nsCSSRect& margin = aData->mMarginData->mMargin; if (margin.mLeft.GetUnit() == eCSSUnit_Null) @@ -208,9 +207,9 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) } // rightmargin (IE-attribute) - mPart->GetHTMLAttribute(nsHTMLAtoms::rightmargin, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - bodyRightMargin = value.GetIntValue(); + value = mPart->GetParsedAttr(nsHTMLAtoms::rightmargin); + if (value && value->Type() == nsAttrValue::eInteger) { + bodyRightMargin = value->GetIntegerValue(); if (bodyRightMargin < 0) bodyRightMargin = 0; nsCSSRect& margin = aData->mMarginData->mMargin; if (margin.mRight.GetUnit() == eCSSUnit_Null) diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index b4a22705b90..c290d761704 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -101,9 +101,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsresult HandleDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, @@ -253,7 +250,7 @@ nsHTMLButtonElement::SetFocus(nsPresContext* aPresContext) } } -static const nsHTMLValue::EnumTable kButtonTypeTable[] = { +static const nsAttrValue::EnumTable kButtonTypeTable[] = { { "button", NS_FORM_BUTTON_BUTTON }, { "reset", NS_FORM_BUTTON_RESET }, { "submit", NS_FORM_BUTTON_SUBMIT }, @@ -278,22 +275,6 @@ nsHTMLButtonElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLButtonElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::type) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - aValue.EnumValueToString(kButtonTypeTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue, - aResult); -} - nsresult nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent, diff --git a/mozilla/content/html/content/src/nsHTMLDivElement.cpp b/mozilla/content/html/content/src/nsHTMLDivElement.cpp index 03674a84845..5848b974d23 100644 --- a/mozilla/content/html/content/src/nsHTMLDivElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLDivElement.cpp @@ -70,9 +70,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -130,20 +127,6 @@ nsHTMLDivElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - DivAlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { diff --git a/mozilla/content/html/content/src/nsHTMLFontElement.cpp b/mozilla/content/html/content/src/nsHTMLFontElement.cpp index bbff6db96ad..e00009ed1be 100644 --- a/mozilla/content/html/content/src/nsHTMLFontElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFontElement.cpp @@ -72,9 +72,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -110,6 +107,32 @@ NS_IMPL_STRING_ATTR(nsHTMLFontElement, Color, color) NS_IMPL_STRING_ATTR(nsHTMLFontElement, Face, face) NS_IMPL_STRING_ATTR(nsHTMLFontElement, Size, size) +static const nsAttrValue::EnumTable kRelFontSizeTable[] = { + { "-10", -10 }, + { "-9", -9 }, + { "-8", -8 }, + { "-7", -7 }, + { "-6", -6 }, + { "-5", -5 }, + { "-4", -4 }, + { "-3", -3 }, + { "-2", -2 }, + { "-1", -1 }, + { "-0", 0 }, + { "+0", 0 }, + { "+1", 1 }, + { "+2", 2 }, + { "+3", 3 }, + { "+4", 4 }, + { "+5", 5 }, + { "+6", 6 }, + { "+7", 7 }, + { "+8", 8 }, + { "+9", 9 }, + { "+10", 10 }, + { 0 } +}; + PRBool nsHTMLFontElement::ParseAttribute(nsIAtom* aAttribute, @@ -118,15 +141,13 @@ nsHTMLFontElement::ParseAttribute(nsIAtom* aAttribute, { if (aAttribute == nsHTMLAtoms::size) { nsAutoString tmp(aValue); - PRInt32 ec, v = tmp.ToInteger(&ec); - if(NS_SUCCEEDED(ec)) { - tmp.CompressWhitespace(PR_TRUE, PR_FALSE); - PRUnichar ch = tmp.First(); - aResult.SetTo(v, (ch == '+' || ch == '-') ? - nsAttrValue::eEnum : nsAttrValue::eInteger); - return PR_TRUE; + tmp.CompressWhitespace(PR_TRUE, PR_TRUE); + PRUnichar ch = tmp.First(); + if (ch == '+' || ch == '-') { + return aResult.ParseEnumValue(aValue, kRelFontSizeTable); } - return PR_FALSE; + + return aResult.ParseIntValue(aValue); } if (aAttribute == nsHTMLAtoms::pointSize || aAttribute == nsHTMLAtoms::fontWeight) { @@ -139,33 +160,6 @@ nsHTMLFontElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if ((aAttribute == nsHTMLAtoms::size) || - (aAttribute == nsHTMLAtoms::pointSize) || - (aAttribute == nsHTMLAtoms::fontWeight)) { - if (aValue.GetUnit() == eHTMLUnit_Enumerated) { - nsAutoString intVal; - PRInt32 value = aValue.GetIntValue(); - intVal.AppendInt(value, 10); - if (value >= 0) { - aResult = NS_LITERAL_STRING("+") + intVal; - } - else { - aResult = intVal; - } - return NS_CONTENT_ATTR_HAS_VALUE; - } - - return NS_CONTENT_ATTR_NOT_THERE; - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index 6fdca1d869c..7e82f6fc4be 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -164,9 +164,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsresult HandleDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, @@ -586,13 +583,13 @@ nsHTMLFormElement::Reset() return rv; } -static const nsHTMLValue::EnumTable kFormMethodTable[] = { +static const nsAttrValue::EnumTable kFormMethodTable[] = { { "get", NS_FORM_METHOD_GET }, { "post", NS_FORM_METHOD_POST }, { 0 } }; -static const nsHTMLValue::EnumTable kFormEnctypeTable[] = { +static const nsAttrValue::EnumTable kFormEnctypeTable[] = { { "multipart/form-data", NS_FORM_ENCTYPE_MULTIPART }, { "application/x-www-form-urlencoded", NS_FORM_ENCTYPE_URLENCODED }, { "text/plain", NS_FORM_ENCTYPE_TEXTPLAIN }, @@ -614,27 +611,6 @@ nsHTMLFormElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLFormElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::method) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - aValue.EnumValueToString(kFormMethodTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::enctype) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - aValue.EnumValueToString(kFormEnctypeTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - void nsHTMLFormElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) diff --git a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp index e30a08c0843..5f7964cb462 100644 --- a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp @@ -69,10 +69,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; - NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -146,24 +142,6 @@ nsHTMLFrameElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLFrameElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLFrameElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::frameborder) { - FrameborderValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - else if (aAttribute == nsHTMLAtoms::scrolling) { - ScrollingValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - - return nsGenericHTMLFrameElement::AttributeToString(aAttribute, aValue, - aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp index d0feeeecc5f..523d3fba98e 100644 --- a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp @@ -85,9 +85,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const; private: @@ -221,12 +218,9 @@ nsHTMLFrameSetElement::GetRowSpec(PRInt32 *aNumValues, *aSpecs = nsnull; if (!mRowSpecs) { - nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == GetHTMLAttribute(nsHTMLAtoms::rows, value) && - eHTMLUnit_String == value.GetUnit()) { - nsAutoString rows; - value.GetStringValue(rows); - nsresult rv = ParseRowCol(rows, mNumRows, &mRowSpecs); + const nsAttrValue* value = GetParsedAttr(nsHTMLAtoms::rows); + if (value && value->Type() == nsAttrValue::eString) { + nsresult rv = ParseRowCol(value->GetStringValue(), mNumRows, &mRowSpecs); NS_ENSURE_SUCCESS(rv, rv); } @@ -257,12 +251,9 @@ nsHTMLFrameSetElement::GetColSpec(PRInt32 *aNumValues, *aSpecs = nsnull; if (!mColSpecs) { - nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == GetHTMLAttribute(nsHTMLAtoms::cols, value) && - eHTMLUnit_String == value.GetUnit()) { - nsAutoString cols; - value.GetStringValue(cols); - nsresult rv = ParseRowCol(cols, mNumCols, &mColSpecs); + const nsAttrValue* value = GetParsedAttr(nsHTMLAtoms::cols); + if (value && value->Type() == nsAttrValue::eString) { + nsresult rv = ParseRowCol(value->GetStringValue(), mNumCols, &mColSpecs); NS_ENSURE_SUCCESS(rv, rv); } @@ -302,18 +293,6 @@ nsHTMLFrameSetElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLFrameSetElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::frameborder) { - nsGenericHTMLElement::FrameborderValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - nsChangeHint nsHTMLFrameSetElement::GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const diff --git a/mozilla/content/html/content/src/nsHTMLHRElement.cpp b/mozilla/content/html/content/src/nsHTMLHRElement.cpp index 6d12d487074..a8d296c13b1 100644 --- a/mozilla/content/html/content/src/nsHTMLHRElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLHRElement.cpp @@ -73,9 +73,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -115,7 +112,7 @@ NS_IMPL_STRING_ATTR(nsHTMLHRElement, Size, size) NS_IMPL_STRING_ATTR(nsHTMLHRElement, Width, width) NS_IMPL_STRING_ATTR(nsHTMLHRElement, Color, color) -static const nsHTMLValue::EnumTable kAlignTable[] = { +static const nsAttrValue::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_CENTER }, @@ -143,21 +140,6 @@ nsHTMLHRElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLHRElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - aValue.EnumValueToString(kAlignTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp index fcdb6647518..da11e710d39 100644 --- a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp @@ -68,9 +68,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -118,21 +115,6 @@ nsHTMLHeadingElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLHeadingElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - DivAlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { diff --git a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp index 84e0dde7e2b..3251c0d3fd4 100644 --- a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp @@ -70,10 +70,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; - NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -152,30 +148,6 @@ nsHTMLIFrameElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLFrameElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLIFrameElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::frameborder) { - FrameborderValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - else if (aAttribute == nsHTMLAtoms::scrolling) { - ScrollingValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - else if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - VAlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLFrameElement::AttributeToString(aAttribute, aValue, - aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index 0a25ec6ca3f..ce24d439123 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -117,9 +117,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -363,22 +360,22 @@ nsHTMLImageElement::GetWidthHeight() size.height = NSTwipsToIntPixels(size.height, t2p); } } else { - nsHTMLValue value; + const nsAttrValue* value; nsCOMPtr image; if (mCurrentRequest) { mCurrentRequest->GetImage(getter_AddRefs(image)); } - if (GetHTMLAttribute(nsHTMLAtoms::width, - value) == NS_CONTENT_ATTR_HAS_VALUE) { - size.width = value.GetIntValue(); + if ((value = GetParsedAttr(nsHTMLAtoms::width)) && + value->Type() == nsAttrValue::eInteger) { + size.width = value->GetIntegerValue(); } else if (image) { image->GetWidth(&size.width); } - if (GetHTMLAttribute(nsHTMLAtoms::height, - value) == NS_CONTENT_ATTR_HAS_VALUE) { - size.height = value.GetIntValue(); + if ((value = GetParsedAttr(nsHTMLAtoms::height)) && + value->Type() == nsAttrValue::eInteger) { + size.height = value->GetIntegerValue(); } else if (image) { image->GetHeight(&size.height); } @@ -443,21 +440,6 @@ nsHTMLImageElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - VAlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index c67a2c212f2..500a233b1de 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -179,9 +179,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -564,13 +561,12 @@ NS_IMPL_STRING_ATTR(nsHTMLInputElement, UseMap, usemap) NS_IMETHODIMP nsHTMLInputElement::GetSize(PRUint32* aValue) { - *aValue = 0; - - nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == - GetHTMLAttribute(nsHTMLAtoms::size, value) && - value.GetUnit() == eHTMLUnit_Integer) { - *aValue = value.GetIntValue(); + const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(nsHTMLAtoms::size); + if (attrVal && attrVal->Type() == nsAttrValue::eInteger) { + *aValue = attrVal->GetIntegerValue(); + } + else { + *aValue = 0; } return NS_OK; @@ -1727,8 +1723,7 @@ nsHTMLInputElement::SetParent(nsIContent* aParent) } } - -static const nsHTMLValue::EnumTable kInputTypeTable[] = { +static const nsAttrValue::EnumTable kInputTypeTable[] = { { "button", NS_FORM_INPUT_BUTTON }, { "checkbox", NS_FORM_INPUT_CHECKBOX }, { "file", NS_FORM_INPUT_FILE }, @@ -1795,43 +1790,10 @@ nsHTMLInputElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::type) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - // The DOM spec says that input types should be capitalized but - // AFAIK all existing browsers return the type in lower case, - // http://bugzilla.mozilla.org/show_bug.cgi?id=32369 is the bug - // about this problem. -- jst@netscape.com - // Update. The DOM spec will be changed to have input types be - // all-lowercase. See - // http://bugzilla.mozilla.org/show_bug.cgi?id=113174#c12 - // -- bzbarsky@mit.edu - - aValue.EnumValueToString(kInputTypeTable, aResult); - - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - AlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue, - aResult); -} - - NS_IMETHODIMP nsHTMLInputElement::GetType(nsAString& aValue) { - const nsHTMLValue::EnumTable *table = kInputTypeTable; + const nsAttrValue::EnumTable *table = kInputTypeTable; while (table->tag) { if (mType == table->value) { diff --git a/mozilla/content/html/content/src/nsHTMLLIElement.cpp b/mozilla/content/html/content/src/nsHTMLLIElement.cpp index 71a18ba0dfc..ba13e9ddef7 100644 --- a/mozilla/content/html/content/src/nsHTMLLIElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLIElement.cpp @@ -68,9 +68,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -107,7 +104,7 @@ NS_IMPL_STRING_ATTR(nsHTMLLIElement, Type, type) NS_IMPL_INT_ATTR(nsHTMLLIElement, Value, value) -static const nsHTMLValue::EnumTable kUnorderedListItemTypeTable[] = { +static const nsAttrValue::EnumTable kUnorderedListItemTypeTable[] = { { "disc", NS_STYLE_LIST_STYLE_DISC }, { "circle", NS_STYLE_LIST_STYLE_CIRCLE }, { "round", NS_STYLE_LIST_STYLE_CIRCLE }, @@ -115,7 +112,7 @@ static const nsHTMLValue::EnumTable kUnorderedListItemTypeTable[] = { { 0 } }; -static const nsHTMLValue::EnumTable kOrderedListItemTypeTable[] = { +static const nsAttrValue::EnumTable kOrderedListItemTypeTable[] = { { "A", NS_STYLE_LIST_STYLE_OLD_UPPER_ALPHA }, { "a", NS_STYLE_LIST_STYLE_OLD_LOWER_ALPHA }, { "I", NS_STYLE_LIST_STYLE_OLD_UPPER_ROMAN }, @@ -140,22 +137,6 @@ nsHTMLLIElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLLIElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::type) { - if (!aValue.EnumValueToString(kOrderedListItemTypeTable, aResult)) { - aValue.EnumValueToString(kUnorderedListItemTypeTable, aResult); - } - - return NS_CONTENT_ATTR_HAS_VALUE; - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp index c2c736d4f7b..8f7980918f8 100644 --- a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp @@ -85,9 +85,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const; nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, @@ -145,7 +142,7 @@ NS_IMPL_STRING_ATTR(nsHTMLLegendElement, AccessKey, accesskey) NS_IMPL_STRING_ATTR(nsHTMLLegendElement, Align, align) // this contains center, because IE4 does -static const nsHTMLValue::EnumTable kAlignTable[] = { +static const nsAttrValue::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_CENTER }, @@ -166,22 +163,6 @@ nsHTMLLegendElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLLegendElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - aValue.EnumValueToString(kAlignTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue, - aResult); -} - nsChangeHint nsHTMLLegendElement::GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const diff --git a/mozilla/content/html/content/src/nsHTMLOListElement.cpp b/mozilla/content/html/content/src/nsHTMLOListElement.cpp index cfcc68cf599..91ec33149e7 100644 --- a/mozilla/content/html/content/src/nsHTMLOListElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOListElement.cpp @@ -78,9 +78,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; }; @@ -126,7 +123,7 @@ NS_IMPL_INT_ATTR(nsHTMLSharedListElement, Start, start) NS_IMPL_STRING_ATTR(nsHTMLSharedListElement, Type, type) -nsHTMLValue::EnumTable kListTypeTable[] = { +nsAttrValue::EnumTable kListTypeTable[] = { { "none", NS_STYLE_LIST_STYLE_NONE }, { "disc", NS_STYLE_LIST_STYLE_DISC }, { "circle", NS_STYLE_LIST_STYLE_CIRCLE }, @@ -140,7 +137,7 @@ nsHTMLValue::EnumTable kListTypeTable[] = { { 0 } }; -nsHTMLValue::EnumTable kOldListTypeTable[] = { +nsAttrValue::EnumTable kOldListTypeTable[] = { { "1", NS_STYLE_LIST_STYLE_OLD_DECIMAL }, { "A", NS_STYLE_LIST_STYLE_OLD_UPPER_ALPHA }, { "a", NS_STYLE_LIST_STYLE_OLD_LOWER_ALPHA }, @@ -168,34 +165,6 @@ nsHTMLSharedListElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLSharedListElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::type && - (mNodeInfo->Equals(nsHTMLAtoms::ol) || - mNodeInfo->Equals(nsHTMLAtoms::ul))) { - PRInt32 v = aValue.GetIntValue(); - switch (v) { - case NS_STYLE_LIST_STYLE_OLD_DECIMAL: - case NS_STYLE_LIST_STYLE_OLD_LOWER_ROMAN: - case NS_STYLE_LIST_STYLE_OLD_UPPER_ROMAN: - case NS_STYLE_LIST_STYLE_OLD_LOWER_ALPHA: - case NS_STYLE_LIST_STYLE_OLD_UPPER_ALPHA: - aValue.EnumValueToString(kOldListTypeTable, aResult); - break; - default: - aValue.EnumValueToString(kListTypeTable, aResult); - break; - } - - return NS_CONTENT_ATTR_HAS_VALUE; - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp index c305bb829fd..f338e76d681 100644 --- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp @@ -87,9 +87,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -262,22 +259,6 @@ nsHTMLObjectElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - VAlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue, - aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp index bea31dfc9eb..dc75547767f 100644 --- a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp @@ -71,9 +71,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; }; @@ -122,21 +119,6 @@ nsHTMLParagraphElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - DivAlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { diff --git a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp index 8225497eedf..81383c99407 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp @@ -53,7 +53,7 @@ #include "nsStyleContext.h" // XXX nav4 has type= start= (same as OL/UL) -extern nsHTMLValue::EnumTable kListTypeTable[]; +extern nsAttrValue::EnumTable kListTypeTable[]; class nsHTMLSharedElement : public nsGenericHTMLElement, public nsImageLoadingContent, @@ -120,9 +120,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -294,38 +291,6 @@ nsHTMLSharedElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLSharedElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (mNodeInfo->Equals(nsHTMLAtoms::embed)) { - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - AlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - } - else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) { - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - AlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - } - else if (mNodeInfo->Equals(nsHTMLAtoms::dir) || - mNodeInfo->Equals(nsHTMLAtoms::menu)) { - if (aAttribute == nsHTMLAtoms::type) { - aValue.EnumValueToString(kListTypeTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - // spacer element code static void diff --git a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp index 7674558a580..e7363ecbc67 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -85,9 +85,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; }; @@ -211,22 +208,6 @@ nsHTMLObjectElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - VAlignValueToString(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue, - aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp index 39d8f6972d0..9dd55c250ad 100644 --- a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp @@ -68,9 +68,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; }; @@ -107,7 +104,7 @@ NS_IMPL_DOM_CLONENODE(nsHTMLTableCaptionElement) NS_IMPL_STRING_ATTR(nsHTMLTableCaptionElement, Align, align) -static const nsHTMLValue::EnumTable kCaptionAlignTable[] = { +static const nsAttrValue::EnumTable kCaptionAlignTable[] = { { "left", NS_SIDE_LEFT }, { "right", NS_SIDE_RIGHT }, { "top", NS_SIDE_TOP}, @@ -127,22 +124,6 @@ nsHTMLTableCaptionElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLTableCaptionElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - if (aAttribute == nsHTMLAtoms::align) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - aValue.EnumValueToString(kCaptionAlignTable, aResult); - - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { diff --git a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp index 878b517368c..c304332f68f 100644 --- a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp @@ -71,9 +71,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -254,7 +251,7 @@ nsHTMLTableCellElement::SetAlign(const nsAString& aValue) } -static const nsHTMLValue::EnumTable kCellScopeTable[] = { +static const nsAttrValue::EnumTable kCellScopeTable[] = { { "row", NS_STYLE_CELL_SCOPE_ROW }, { "col", NS_STYLE_CELL_SCOPE_COL }, { "rowgroup", NS_STYLE_CELL_SCOPE_ROWGROUP }, @@ -284,7 +281,7 @@ nsHTMLTableCellElement::ParseAttribute(nsIAtom* aAttribute, // reset large colspan values as IE and opera do // quirks mode does not honor the special html 4 value of 0 if (val > MAX_COLSPAN || val < 0 || (0 == val && InNavQuirksMode(GetOwnerDoc()))) { - aResult.SetTo(1, nsAttrValue::eInteger); + aResult.SetTo(1); } } return res; @@ -295,7 +292,7 @@ nsHTMLTableCellElement::ParseAttribute(nsIAtom* aAttribute, PRInt32 val = aResult.GetIntegerValue(); // quirks mode does not honor the special html 4 value of 0 if (val < 0 || (0 == val && InNavQuirksMode(GetOwnerDoc()))) { - aResult.SetTo(1, nsAttrValue::eInteger); + aResult.SetTo(1); } } return res; @@ -322,36 +319,6 @@ nsHTMLTableCellElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLTableCellElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - /* ignore these attributes, stored already as strings - abbr, axis, ch, headers - */ - /* ignore attributes that are of standard types - charoff, colspan, rowspan, height, width, nowrap, background, bgcolor - */ - if (aAttribute == nsHTMLAtoms::align) { - if (TableCellHAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::scope) { - if (aValue.EnumValueToString(kCellScopeTable, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::valign) { - if (TableVAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) diff --git a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp index 8b40233c3e3..80d38794ac9 100644 --- a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp @@ -72,9 +72,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; }; @@ -142,31 +139,6 @@ nsHTMLTableColElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - /* ignore these attributes, stored already as strings - ch - */ - /* ignore attributes that are of standard types - charoff, span - */ - if (aAttribute == nsHTMLAtoms::align) { - if (TableCellHAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::valign) { - if (TableVAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp index 86565e8c8d0..36d7a46786b 100644 --- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -84,9 +84,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -834,7 +831,7 @@ nsHTMLTableElement::DeleteRow(PRInt32 aValue) return parent->RemoveChild(row, getter_AddRefs(deleted_row)); } -static const nsHTMLValue::EnumTable kFrameTable[] = { +static const nsAttrValue::EnumTable kFrameTable[] = { { "void", NS_STYLE_TABLE_FRAME_NONE }, { "above", NS_STYLE_TABLE_FRAME_ABOVE }, { "below", NS_STYLE_TABLE_FRAME_BELOW }, @@ -847,7 +844,7 @@ static const nsHTMLValue::EnumTable kFrameTable[] = { { 0 } }; -static const nsHTMLValue::EnumTable kRulesTable[] = { +static const nsAttrValue::EnumTable kRulesTable[] = { { "none", NS_STYLE_TABLE_RULES_NONE }, { "groups", NS_STYLE_TABLE_RULES_GROUPS }, { "rows", NS_STYLE_TABLE_RULES_ROWS }, @@ -856,7 +853,7 @@ static const nsHTMLValue::EnumTable kRulesTable[] = { { 0 } }; -static const nsHTMLValue::EnumTable kLayoutTable[] = { +static const nsAttrValue::EnumTable kLayoutTable[] = { { "auto", NS_STYLE_TABLE_LAYOUT_AUTO }, { "fixed", NS_STYLE_TABLE_LAYOUT_FIXED }, { 0 } @@ -879,7 +876,7 @@ nsHTMLTableElement::ParseAttribute(nsIAtom* aAttribute, if (aAttribute == nsHTMLAtoms::border) { if (!aResult.ParseIntWithBounds(aValue, 0)) { // XXX this should really be NavQuirks only to allow non numeric value - aResult.SetTo(1, nsAttrValue::eInteger); + aResult.SetTo(1); } return PR_TRUE; @@ -922,38 +919,6 @@ nsHTMLTableElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLTableElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - /* ignore summary, just a string */ - /* ignore attributes that are of standard types border, cellpadding, - cellspacing, cols, height, width, background, bgcolor */ - if (aAttribute == nsHTMLAtoms::align) { - if (TableHAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::frame) { - if (aValue.EnumValueToString(kFrameTable, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::layout) { - if (aValue.EnumValueToString(kLayoutTable, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::rules) { - if (aValue.EnumValueToString(kRulesTable, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapTableFrameInto(const nsMappedAttributes* aAttributes, nsRuleData* aData, PRUint8 aBorderStyle) diff --git a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp index f13acb7839e..97d7c3a182d 100644 --- a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp @@ -79,9 +79,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -410,31 +407,6 @@ nsHTMLTableRowElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLTableRowElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - /* ignore these attributes, stored already as strings - ch - */ - /* ignore attributes that are of standard types - charoff, height, width, background, bgcolor - */ - if (aAttribute == nsHTMLAtoms::align) { - if (TableCellHAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::valign) { - if (TableVAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { diff --git a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp index 5e2119d0d11..5d52df81a6a 100644 --- a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -74,9 +74,6 @@ public: virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; @@ -260,31 +257,6 @@ nsHTMLTableSectionElement::ParseAttribute(nsIAtom* aAttribute, return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult); } -NS_IMETHODIMP -nsHTMLTableSectionElement::AttributeToString(nsIAtom* aAttribute, - const nsHTMLValue& aValue, - nsAString& aResult) const -{ - /* ignore these attributes, stored already as strings - ch - */ - /* ignore attributes that are of standard types - charoff, height, width, background, bgcolor - */ - if (aAttribute == nsHTMLAtoms::align) { - if (TableCellHAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - else if (aAttribute == nsHTMLAtoms::valign) { - if (TableVAlignValueToString(aValue, aResult)) { - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - - return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult); -} - static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) { diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index b33eeb0d5a1..7d6f38401fd 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -51,7 +51,6 @@ // XXX because nsIEventListenerManager has broken includes #include "nsIDOMEvent.h" #include "nsIServiceManager.h" -#include "nsHTMLValue.h" #include "nsIAtom.h" #include "nsINodeInfo.h" #include "nsIControllers.h" diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index d3bbb0a7895..5e86feeb3d9 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -274,6 +274,14 @@ Initialize(nsIModule* aSelf) return rv; } + rv = nsAttrValue::Init(); + if (NS_FAILED(rv)) { + NS_ERROR("Could not initialize nsAttrValue"); + + Shutdown(); + + return rv; + } // Register all of our atoms once nsCSSAnonBoxes::AddRefAtoms(); @@ -417,6 +425,7 @@ Shutdown() NS_IF_RELEASE(nsRuleNode::gLangService); nsGenericHTMLElement::Shutdown(); + nsAttrValue::Shutdown(); nsContentUtils::Shutdown(); nsLayoutStylesheetCache::Shutdown(); NS_NameSpaceManagerShutdown(); diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index 8bd056b52a8..66953fc213e 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -661,36 +661,34 @@ NS_IMETHODIMP nsFormControlFrame::GetMaxLength(PRInt32* aSize) { *aSize = -1; - nsresult result = NS_CONTENT_ATTR_NOT_THERE; nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); - if (content) { - nsHTMLValue value; - result = content->GetHTMLAttribute(nsHTMLAtoms::maxlength, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - *aSize = value.GetIntValue(); + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::maxlength); + if (attr && attr->Type() == nsAttrValue::eInteger) { + *aSize = attr->GetIntegerValue(); + + return NS_CONTENT_ATTR_HAS_VALUE; } } - return result; + return NS_CONTENT_ATTR_NOT_THERE; } nsresult nsFormControlFrame::GetSizeFromContent(PRInt32* aSize) const { *aSize = -1; - nsresult result = NS_CONTENT_ATTR_NOT_THERE; nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); - if (content) { - nsHTMLValue value; - result = content->GetHTMLAttribute(nsHTMLAtoms::size, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - *aSize = value.GetIntValue(); + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::size); + if (attr && attr->Type() == nsAttrValue::eInteger) { + *aSize = attr->GetIntegerValue(); + + return NS_CONTENT_ATTR_HAS_VALUE; } } - return result; + return NS_CONTENT_ATTR_NOT_THERE; } NS_IMETHODIMP_(PRInt32) diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index 51f44ae8024..0932e772ebd 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -132,18 +132,13 @@ nsresult nsFormControlHelper::GetFrameFontFM(nsIFrame* aFrame, nsresult nsFormControlHelper::GetWrapProperty(nsIContent * aContent, nsString &aOutValue) { - aOutValue.SetLength(0); - nsresult result = NS_CONTENT_ATTR_NOT_THERE; - nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(aContent); - - if (content) { - nsHTMLValue value; - result = content->GetHTMLAttribute(nsHTMLAtoms::wrap, value); - if (eHTMLUnit_String == value.GetUnit()) { - value.GetStringValue(aOutValue); - } + if (aContent->IsContentOfType(nsIContent::eHTML)) { + return aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::wrap, aOutValue); } - return result; + + aOutValue.Truncate(); + + return NS_CONTENT_ATTR_NOT_THERE; } @@ -340,17 +335,10 @@ nsresult nsFormControlHelper::GetName(nsIContent* aContent, nsAString* aResult) { NS_PRECONDITION(aResult, "Null pointer bad!"); - nsGenericHTMLElement *formControl = - nsGenericHTMLElement::FromContent(aContent); - if (!formControl) + if (!aContent->IsContentOfType(nsIContent::eHTML)) return NS_ERROR_FAILURE; - nsHTMLValue value; - nsresult rv = formControl->GetHTMLAttribute(nsHTMLAtoms::name, value); - if (NS_CONTENT_ATTR_HAS_VALUE == rv && eHTMLUnit_String == value.GetUnit()) { - value.GetStringValue(*aResult); - } - return rv; + return aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, *aResult); } PRInt32 @@ -369,17 +357,10 @@ nsresult nsFormControlHelper::GetValueAttr(nsIContent* aContent, nsAString* aResult) { NS_PRECONDITION(aResult, "Null pointer bad!"); - nsGenericHTMLElement *formControl = - nsGenericHTMLElement::FromContent(aContent); - if (!formControl) + if (!aContent->IsContentOfType(nsIContent::eHTML)) return NS_ERROR_FAILURE; - nsHTMLValue value; - nsresult rv = formControl->GetHTMLAttribute(nsHTMLAtoms::value, value); - if (NS_CONTENT_ATTR_HAS_VALUE == rv && eHTMLUnit_String == value.GetUnit()) { - value.GetStringValue(*aResult); - } - return rv; + return aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, *aResult); } //---------------------------------------------------------------------------------- diff --git a/mozilla/layout/forms/nsLegendFrame.cpp b/mozilla/layout/forms/nsLegendFrame.cpp index 1bb7a9eef79..4e0dc0fe713 100644 --- a/mozilla/layout/forms/nsLegendFrame.cpp +++ b/mozilla/layout/forms/nsLegendFrame.cpp @@ -150,11 +150,9 @@ PRInt32 nsLegendFrame::GetAlign() nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); if (content) { - nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::align, value))) { - if (eHTMLUnit_Enumerated == value.GetUnit()) { - intValue = value.GetIntValue(); - } + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::align); + if (attr && attr->Type() == nsAttrValue::eEnum) { + intValue = attr->GetEnumValue(); } } return intValue; diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 741cad52158..0d14e358551 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -1474,19 +1474,18 @@ nsTextControlFrame::GetCols() NS_ASSERTION(content, "Content is not HTML content!"); if (IsTextArea()) { - nsHTMLValue attr; - nsresult rv = content->GetHTMLAttribute(nsHTMLAtoms::cols, attr); - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { - PRInt32 cols = attr.GetIntValue(); + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::cols); + if (attr) { + PRInt32 cols = attr->Type() == nsAttrValue::eInteger ? + attr->GetIntegerValue() : 0; // XXX why a default of 1 char, why hide it return (cols <= 0) ? 1 : cols; } } else { // Else we know (assume) it is an input with size attr - nsHTMLValue attr; - nsresult rv = content->GetHTMLAttribute(nsHTMLAtoms::size, attr); - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { - PRInt32 cols = attr.GetIntValue(); + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::size); + if (attr && attr->Type() == nsAttrValue::eInteger) { + PRInt32 cols = attr->GetIntegerValue(); if (cols > 0) { return cols; } @@ -1505,10 +1504,9 @@ nsTextControlFrame::GetRows() nsGenericHTMLElement::FromContent(mContent); NS_ASSERTION(content, "Content is not HTML content!"); - nsHTMLValue attr; - nsresult rv = content->GetHTMLAttribute(nsHTMLAtoms::rows, attr); - if (rv == NS_CONTENT_ATTR_HAS_VALUE) { - PRInt32 rows = attr.GetIntValue(); + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::rows); + if (attr && attr->Type() == nsAttrValue::eInteger) { + PRInt32 rows = attr->GetIntegerValue(); return (rows <= 0) ? DEFAULT_ROWS_TEXTAREA : rows; } return DEFAULT_ROWS_TEXTAREA; @@ -2902,18 +2900,17 @@ nsresult nsTextControlFrame::GetMaxLength(PRInt32* aSize) { *aSize = -1; - nsresult rv = NS_CONTENT_ATTR_NOT_THERE; nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); - if (content) { - nsHTMLValue value; - rv = content->GetHTMLAttribute(nsHTMLAtoms::maxlength, value); - if (eHTMLUnit_Integer == value.GetUnit()) { - *aSize = value.GetIntValue(); + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::maxlength); + if (attr && attr->Type() == nsAttrValue::eInteger) { + *aSize = attr->GetIntegerValue(); + + return NS_CONTENT_ATTR_HAS_VALUE; } } - return rv; + return NS_CONTENT_ATTR_NOT_THERE; } // this is where we propagate a content changed event @@ -3197,14 +3194,9 @@ nsTextControlFrame::GetWidthInCharacters() const nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); if (content) { - nsHTMLValue resultValue; - nsresult rv = content->GetHTMLAttribute(nsHTMLAtoms::cols, resultValue); - if (NS_CONTENT_ATTR_NOT_THERE != rv) - { - if (resultValue.GetUnit() == eHTMLUnit_Integer) - { - return (resultValue.GetIntValue()); - } + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::cols); + if (attr && attr->Type() == nsAttrValue::eInteger) { + return attr->GetIntegerValue(); } } diff --git a/mozilla/layout/forms/nsTextControlFrame.h b/mozilla/layout/forms/nsTextControlFrame.h index 89c6c4f3aa3..a8b9701be65 100644 --- a/mozilla/layout/forms/nsTextControlFrame.h +++ b/mozilla/layout/forms/nsTextControlFrame.h @@ -46,7 +46,6 @@ #include "nsIEditor.h" #include "nsITextControlFrame.h" #include "nsFormControlHelper.h"//for the inputdimensions -#include "nsHTMLValue.h" //for nsHTMLValue #include "nsIFontMetrics.h" #include "nsWeakReference.h" //for service and presshell pointers #include "nsIScrollableViewProvider.h" diff --git a/mozilla/layout/generic/nsAreaFrame.cpp b/mozilla/layout/generic/nsAreaFrame.cpp index a1b6f9b46e1..f99d6d96557 100644 --- a/mozilla/layout/generic/nsAreaFrame.cpp +++ b/mozilla/layout/generic/nsAreaFrame.cpp @@ -43,7 +43,6 @@ #include "nsINodeInfo.h" #include "nsHTMLAtoms.h" #include "nsIView.h" -#include "nsHTMLValue.h" #include "nsHTMLParts.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index d29c28f66f1..dbeae9005fd 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -59,7 +59,6 @@ #include "nsIFontMetrics.h" #include "nsHTMLParts.h" #include "nsHTMLAtoms.h" -#include "nsHTMLValue.h" #include "nsIDOMEvent.h" #include "nsGenericHTMLElement.h" #include "prprf.h" @@ -6839,12 +6838,9 @@ nsBlockFrame::RenumberLists(nsPresContext* aPresContext) nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent); if (hc) { - nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == - hc->GetHTMLAttribute(nsHTMLAtoms::start, value)) { - if (eHTMLUnit_Integer == value.GetUnit()) { - ordinal = value.GetIntValue(); - } + const nsAttrValue* attr = hc->GetParsedAttr(nsHTMLAtoms::start); + if (attr && attr->Type() == nsAttrValue::eInteger) { + ordinal = attr->GetIntegerValue(); } } diff --git a/mozilla/layout/generic/nsBulletFrame.cpp b/mozilla/layout/generic/nsBulletFrame.cpp index 75abf240413..bdc22b0e985 100644 --- a/mozilla/layout/generic/nsBulletFrame.cpp +++ b/mozilla/layout/generic/nsBulletFrame.cpp @@ -38,7 +38,6 @@ #include "nsBulletFrame.h" #include "nsHTMLAtoms.h" #include "nsHTMLParts.h" -#include "nsHTMLValue.h" #include "nsHTMLContainerFrame.h" #include "nsIFontMetrics.h" #include "nsGenericHTMLElement.h" @@ -392,18 +391,15 @@ nsBulletFrame::SetListItemOrdinal(PRInt32 aNextOrdinal, // Try to get value directly from the list-item, if it specifies a // value attribute. Note: we do this with our parent's content // because our parent is the list-item. - nsHTMLValue value; nsIContent* parentContent = mParent->GetContent(); if (parentContent) { nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(parentContent); if (hc) { - if (NS_CONTENT_ATTR_HAS_VALUE == - hc->GetHTMLAttribute(nsHTMLAtoms::value, value)) { - if (eHTMLUnit_Integer == value.GetUnit()) { - // Use ordinal specified by the value attribute - mOrdinal = value.GetIntValue(); - } + const nsAttrValue* attr = hc->GetParsedAttr(nsHTMLAtoms::value); + if (attr && attr->Type() == nsAttrValue::eInteger) { + // Use ordinal specified by the value attribute + mOrdinal = attr->GetIntegerValue(); } } } diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 6d07bcdd7cb..ea71dbdb833 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -574,13 +574,12 @@ nsSize nsSubDocumentFrame::GetMargin() nsSize result(-1, -1); nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); if (content) { - nsHTMLValue value; - content->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value); - if (eHTMLUnit_Integer == value.GetUnit()) - result.width = value.GetIntValue(); - content->GetHTMLAttribute(nsHTMLAtoms::marginheight, value); - if (eHTMLUnit_Integer == value.GetUnit()) - result.height = value.GetIntValue(); + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::marginwidth); + if (attr && attr->Type() == nsAttrValue::eInteger) + result.width = attr->GetIntegerValue(); + attr = content->GetParsedAttr(nsHTMLAtoms::marginheight); + if (attr && attr->Type() == nsAttrValue::eInteger) + result.height = attr->GetIntegerValue(); } return result; } diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index d1172d89385..0952d6c51df 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -670,18 +670,17 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext, } } float p2t = aPresContext->ScaledPixelsToTwips(); - nsHTMLValue htmlVal; nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); if (content) { - if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::border, htmlVal))) { - nsHTMLUnit unit = htmlVal.GetUnit(); + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::border); + if (attr) { PRInt32 intVal = 0; - if (eHTMLUnit_Integer == unit) { - intVal = htmlVal.GetIntValue(); - } - if (intVal < 0) { - intVal = 0; + if (attr->Type() == nsAttrValue::eInteger) { + intVal = attr->GetIntegerValue(); + if (intVal < 0) { + intVal = 0; + } } if (forcing && intVal == 0) { @@ -895,22 +894,20 @@ static nsFrameborder GetFrameBorderHelper(nsGenericHTMLElement* aContent) { if (nsnull != aContent) { - nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetHTMLAttribute(nsHTMLAtoms::frameborder, value))) { - if (eHTMLUnit_Enumerated == value.GetUnit()) { - switch (value.GetIntValue()) - { - case NS_STYLE_FRAME_YES: - case NS_STYLE_FRAME_1: - return eFrameborder_Yes; - break; + const nsAttrValue* attr = aContent->GetParsedAttr(nsHTMLAtoms::frameborder); + if (attr && attr->Type() == nsAttrValue::eEnum) { + switch (attr->GetEnumValue()) + { + case NS_STYLE_FRAME_YES: + case NS_STYLE_FRAME_1: + return eFrameborder_Yes; + break; - case NS_STYLE_FRAME_NO: - case NS_STYLE_FRAME_0: - return eFrameborder_No; - break; - } - } + case NS_STYLE_FRAME_NO: + case NS_STYLE_FRAME_0: + return eFrameborder_No; + break; + } } } return eFrameborder_Notset; @@ -950,10 +947,10 @@ nscolor nsHTMLFramesetFrame::GetBorderColor() nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent); if (content) { - nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) { + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::bordercolor); + if (attr) { nscolor color; - if (value.GetColorValue(color)) { + if (attr->GetColorValue(color)) { return color; } } @@ -967,10 +964,10 @@ nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent) nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(aContent); if (content) { - nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) { + const nsAttrValue* attr = content->GetParsedAttr(nsHTMLAtoms::bordercolor); + if (attr) { nscolor color; - if (value.GetColorValue(color)) { + if (attr->GetColorValue(color)) { return color; } } diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index 6636948ca18..d9bf29c5800 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -46,7 +46,6 @@ #include "nsCSSAnonBoxes.h" #include "nsIWidget.h" #include "nsILinkHandler.h" -#include "nsHTMLValue.h" #include "nsGUIEvent.h" #include "nsIDocument.h" #include "nsIURL.h" diff --git a/mozilla/layout/html/tests/TestAttributes.cpp b/mozilla/layout/html/tests/TestAttributes.cpp index a08e13f90aa..1c611e0eb84 100644 --- a/mozilla/layout/html/tests/TestAttributes.cpp +++ b/mozilla/layout/html/tests/TestAttributes.cpp @@ -61,15 +61,14 @@ void testAttributes(nsGenericHTMLElement* content) { content->SetAttribute(kNameSpaceID_None, sHEIGHT, sempty, PR_FALSE); content->SetAttribute(kNameSpaceID_None, sSRC, sfoo_gif, PR_FALSE); - nsHTMLValue ret; - nsresult rv; - rv = content->GetHTMLAttribute(sBORDER, ret); - if (rv == NS_CONTENT_ATTR_NOT_THERE || ret.GetUnit() != eHTMLUnit_String) { + const nsAttrValue* attr; + attr = content->GetParsedAttr(sBORDER); + if (!attr || attr->Type() != nsAttrValue::eString) { printf("test 0 failed\n"); } - rv = content->GetHTMLAttribute(sBAD, ret); - if (rv != NS_CONTENT_ATTR_NOT_THERE) { + attr = content->GetParsedAttr(sBAD); + if (attr) { printf("test 2 failed\n"); } diff --git a/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp b/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp index bb0cd8060fe..ba67b687649 100644 --- a/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/mozilla/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -41,7 +41,6 @@ #include "nsHTMLAtoms.h" #include "nsIStyledContent.h" #include "nsIDOMMutationEvent.h" -#include "nsHTMLValue.h" #include "nsICSSStyleRule.h" #include "nsINodeInfo.h" #include "nsICSSLoader.h" diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index 3611be7f0b5..ccef548af12 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -50,7 +50,6 @@ #include "nsIContent.h" #include "nsGenericHTMLElement.h" #include "nsHTMLParts.h" -#include "nsHTMLValue.h" #include "nsHTMLAtoms.h" #include "nsVoidArray.h" #include "nsIView.h" @@ -636,10 +635,9 @@ PRInt32 nsTableCellFrame::GetRowSpan() nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent); if (hc) { - nsHTMLValue val; - hc->GetHTMLAttribute(nsHTMLAtoms::rowspan, val); - if (eHTMLUnit_Integer == val.GetUnit()) { - rowSpan=val.GetIntValue(); + const nsAttrValue* attr = hc->GetParsedAttr(nsHTMLAtoms::rowspan); + if (attr && attr->Type() == nsAttrValue::eInteger) { + rowSpan = attr->GetIntegerValue(); } } return rowSpan; @@ -651,10 +649,9 @@ PRInt32 nsTableCellFrame::GetColSpan() nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent); if (hc) { - nsHTMLValue val; - hc->GetHTMLAttribute(nsHTMLAtoms::colspan, val); - if (eHTMLUnit_Integer == val.GetUnit()) { - colSpan=val.GetIntValue(); + const nsAttrValue* attr = hc->GetParsedAttr(nsHTMLAtoms::colspan); + if (attr && attr->Type() == nsAttrValue::eInteger) { + colSpan = attr->GetIntegerValue(); } } return colSpan; diff --git a/mozilla/layout/tables/nsTableCellFrame.h b/mozilla/layout/tables/nsTableCellFrame.h index 9232b39628a..c85a46d92a7 100644 --- a/mozilla/layout/tables/nsTableCellFrame.h +++ b/mozilla/layout/tables/nsTableCellFrame.h @@ -46,7 +46,6 @@ #include "nsLayoutAtoms.h" class nsTableFrame; -class nsHTMLValue; /** * Additional frame-state bits diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 7fb094d7a84..df0fe38961e 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -51,7 +51,6 @@ #include "nsTableRowGroupFrame.h" #include "nsTableOuterFrame.h" #include "nsTablePainter.h" -#include "nsHTMLValue.h" #include "BasicTableLayoutStrategy.h" #include "FixedTableLayoutStrategy.h" diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index d2d6cfeb61e..279ab0e0e58 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -54,7 +54,6 @@ class nsTableRowGroupFrame; class nsTableRowFrame; class nsTableColGroupFrame; class nsITableLayoutStrategy; -class nsHTMLValue; class nsStyleContext; struct nsTableReflowState;