diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 66efd95eed4b..bf63205c2c0a 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -411,6 +411,23 @@ static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument) return sheet; } +PRBool +nsGenericHTMLElement::InNavQuirksMode() const +{ + PRBool status = PR_FALSE; + if (mDocument) { + nsCOMPtr hdoc(do_QueryInterface(mDocument)); + if (hdoc) { + nsDTDMode mode; + hdoc->GetDTDMode(mode); + if (eDTDMode_Nav == mode) { + status = PR_TRUE; + } + } + } + return status; +} + nsresult nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) { @@ -1749,24 +1766,22 @@ nsGenericHTMLElement::TableVAlignValueToString(const nsHTMLValue& aValue, PRBool nsGenericHTMLElement::ParseDivAlignValue(const nsString& aString, - nsHTMLValue& aResult) + nsHTMLValue& aResult) const { -#if XXX_no_nav_compat + if (InNavQuirksMode()) { + return ParseEnumValue(aString, kCompatDivAlignTable, aResult); + } return ParseEnumValue(aString, kDivAlignTable, aResult); -#else - return ParseEnumValue(aString, kCompatDivAlignTable, aResult); -#endif } PRBool nsGenericHTMLElement::DivAlignValueToString(const nsHTMLValue& aValue, - nsString& aResult) + nsString& aResult) const { -#if XXX_no_nav_compat + if (InNavQuirksMode()) { + return EnumValueToString(aValue, kCompatDivAlignTable, aResult); + } return EnumValueToString(aValue, kDivAlignTable, aResult); -#else - return EnumValueToString(aValue, kCompatDivAlignTable, aResult); -#endif } PRBool diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 82c2e6891fd3..ab0fb6d615a9 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -187,8 +187,8 @@ public: nsHTMLValue& aResult); static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult); - static PRBool ParseDivAlignValue(const nsString& aString, - nsHTMLValue& aResult); + PRBool ParseDivAlignValue(const nsString& aString, + nsHTMLValue& aResult) const; static PRBool ParseTableHAlignValue(const nsString& aString, nsHTMLValue& aResult); @@ -205,8 +205,8 @@ public: static PRBool AlignValueToString(const nsHTMLValue& aValue, nsString& aResult); - static PRBool DivAlignValueToString(const nsHTMLValue& aValue, - nsString& aResult); + PRBool DivAlignValueToString(const nsHTMLValue& aValue, + nsString& aResult) const; static PRBool ParseImageAttribute(nsIAtom* aAttribute, const nsString& aString, @@ -277,6 +277,10 @@ public: nsIDocument* aDocument, nsIURI** aResult); + // See if the content object is in a document that has nav-quirks + // mode enabled. + PRBool InNavQuirksMode() const; + nsIHTMLAttributes* mAttributes; }; diff --git a/layout/html/content/src/nsGenericHTMLElement.cpp b/layout/html/content/src/nsGenericHTMLElement.cpp index 66efd95eed4b..bf63205c2c0a 100644 --- a/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/layout/html/content/src/nsGenericHTMLElement.cpp @@ -411,6 +411,23 @@ static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument) return sheet; } +PRBool +nsGenericHTMLElement::InNavQuirksMode() const +{ + PRBool status = PR_FALSE; + if (mDocument) { + nsCOMPtr hdoc(do_QueryInterface(mDocument)); + if (hdoc) { + nsDTDMode mode; + hdoc->GetDTDMode(mode); + if (eDTDMode_Nav == mode) { + status = PR_TRUE; + } + } + } + return status; +} + nsresult nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) { @@ -1749,24 +1766,22 @@ nsGenericHTMLElement::TableVAlignValueToString(const nsHTMLValue& aValue, PRBool nsGenericHTMLElement::ParseDivAlignValue(const nsString& aString, - nsHTMLValue& aResult) + nsHTMLValue& aResult) const { -#if XXX_no_nav_compat + if (InNavQuirksMode()) { + return ParseEnumValue(aString, kCompatDivAlignTable, aResult); + } return ParseEnumValue(aString, kDivAlignTable, aResult); -#else - return ParseEnumValue(aString, kCompatDivAlignTable, aResult); -#endif } PRBool nsGenericHTMLElement::DivAlignValueToString(const nsHTMLValue& aValue, - nsString& aResult) + nsString& aResult) const { -#if XXX_no_nav_compat + if (InNavQuirksMode()) { + return EnumValueToString(aValue, kCompatDivAlignTable, aResult); + } return EnumValueToString(aValue, kDivAlignTable, aResult); -#else - return EnumValueToString(aValue, kCompatDivAlignTable, aResult); -#endif } PRBool diff --git a/layout/html/content/src/nsGenericHTMLElement.h b/layout/html/content/src/nsGenericHTMLElement.h index 82c2e6891fd3..ab0fb6d615a9 100644 --- a/layout/html/content/src/nsGenericHTMLElement.h +++ b/layout/html/content/src/nsGenericHTMLElement.h @@ -187,8 +187,8 @@ public: nsHTMLValue& aResult); static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult); - static PRBool ParseDivAlignValue(const nsString& aString, - nsHTMLValue& aResult); + PRBool ParseDivAlignValue(const nsString& aString, + nsHTMLValue& aResult) const; static PRBool ParseTableHAlignValue(const nsString& aString, nsHTMLValue& aResult); @@ -205,8 +205,8 @@ public: static PRBool AlignValueToString(const nsHTMLValue& aValue, nsString& aResult); - static PRBool DivAlignValueToString(const nsHTMLValue& aValue, - nsString& aResult); + PRBool DivAlignValueToString(const nsHTMLValue& aValue, + nsString& aResult) const; static PRBool ParseImageAttribute(nsIAtom* aAttribute, const nsString& aString, @@ -277,6 +277,10 @@ public: nsIDocument* aDocument, nsIURI** aResult); + // See if the content object is in a document that has nav-quirks + // mode enabled. + PRBool InNavQuirksMode() const; + nsIHTMLAttributes* mAttributes; };