diff --git a/mozilla/content/base/src/nsStyledElement.cpp b/mozilla/content/base/src/nsStyledElement.cpp index e5198607698..1aaf7872c50 100644 --- a/mozilla/content/base/src/nsStyledElement.cpp +++ b/mozilla/content/base/src/nsStyledElement.cpp @@ -86,7 +86,7 @@ nsStyledElement::ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute, if (aNamespaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::style) { SetFlags(NODE_MAY_HAVE_STYLE); - ParseStyleAttribute(this, aValue, aResult); + ParseStyleAttribute(this, aValue, aResult, PR_FALSE); return PR_TRUE; } if (aAttribute == nsGkAtoms::_class) { @@ -165,7 +165,7 @@ nsStyledElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, // XXXbz if we already have a style attr parsed, this won't do // anything... need to fix that. - ReparseStyleAttribute(); + ReparseStyleAttribute(PR_FALSE); return rv; } @@ -184,7 +184,7 @@ nsStyledElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) if (!slots->mStyle) { // Just in case... - ReparseStyleAttribute(); + ReparseStyleAttribute(PR_TRUE); nsresult rv; if (!gCSSOMFactory) { @@ -204,7 +204,7 @@ nsStyledElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) } nsresult -nsStyledElement::ReparseStyleAttribute() +nsStyledElement::ReparseStyleAttribute(PRBool aForceInDataDoc) { if (!HasFlag(NODE_MAY_HAVE_STYLE)) { return NS_OK; @@ -215,7 +215,7 @@ nsStyledElement::ReparseStyleAttribute() nsAttrValue attrValue; nsAutoString stringValue; oldVal->ToString(stringValue); - ParseStyleAttribute(this, stringValue, attrValue); + ParseStyleAttribute(this, stringValue, attrValue, aForceInDataDoc); // Don't bother going through SetInlineStyleRule, we don't want to fire off // mutation events or document notifications anyway nsresult rv = mAttrsAndChildren.SetAndTakeAttr(nsGkAtoms::style, attrValue); @@ -228,12 +228,13 @@ nsStyledElement::ReparseStyleAttribute() void nsStyledElement::ParseStyleAttribute(nsIContent* aContent, const nsAString& aValue, - nsAttrValue& aResult) + nsAttrValue& aResult, + PRBool aForceInDataDoc) { nsresult result = NS_OK; nsIDocument* doc = aContent->GetOwnerDoc(); - if (doc) { + if (doc && (aForceInDataDoc || !doc->IsLoadedAsData())) { PRBool isCSS = PR_TRUE; // assume CSS until proven otherwise if (!aContent->IsNativeAnonymous()) { // native anonymous content diff --git a/mozilla/content/base/src/nsStyledElement.h b/mozilla/content/base/src/nsStyledElement.h index 7dbb3afa6b7..c09f4c62f2d 100644 --- a/mozilla/content/base/src/nsStyledElement.h +++ b/mozilla/content/base/src/nsStyledElement.h @@ -76,11 +76,6 @@ public: nsIContent* aBindingParent, PRBool aCompileEventHandlers); - /** - * Create the style struct from the style attr. Used when an element is first - * put into a document. Only has an effect if the old value is a string. - */ - nsresult ReparseStyleAttribute(void); /** * Parse a style attr value into a CSS rulestruct (or, if there is no * document, leave it as a string) and return as nsAttrValue. @@ -91,7 +86,8 @@ public: */ static void ParseStyleAttribute(nsIContent* aContent, const nsAString& aValue, - nsAttrValue& aResult); + nsAttrValue& aResult, + PRBool aForceInDataDoc); static void Shutdown(); @@ -102,6 +98,13 @@ protected: nsresult GetStyle(nsIDOMCSSStyleDeclaration** aStyle); + /** + * Create the style struct from the style attr. Used when an element is + * first put into a document. Only has an effect if the old value is a + * string. If aForceInDataDoc is true, will reparse even if we're in a data + * document. + */ + nsresult ReparseStyleAttribute(PRBool aForceInDataDoc); }; #endif // __NS_STYLEDELEMENT_H_ diff --git a/mozilla/content/base/test/Makefile.in b/mozilla/content/base/test/Makefile.in index b0f0ba600af..4c2c9e4b832 100644 --- a/mozilla/content/base/test/Makefile.in +++ b/mozilla/content/base/test/Makefile.in @@ -144,6 +144,7 @@ _TEST_FILES = test_bug5141.html \ test_bug414796.html \ test_bug416383.html \ test_bug417384.html \ + test_bug418214.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/mozilla/content/base/test/test_bug418214.html b/mozilla/content/base/test/test_bug418214.html new file mode 100644 index 00000000000..9420c0aeb17 --- /dev/null +++ b/mozilla/content/base/test/test_bug418214.html @@ -0,0 +1,84 @@ + + + +
++ ++ + + diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index 094531cef18..0f84c747bce 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -195,7 +195,8 @@ nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsAttrValue attrValue; nsAutoString stringValue; oldVal->ToString(stringValue); - ParseStyleAttribute(this, stringValue, attrValue); + // Force in data doc, since we already have a style rule + ParseStyleAttribute(this, stringValue, attrValue, PR_TRUE); // Don't bother going through SetInlineStyleRule, we don't want to fire off // mutation events or document notifications anyway rv = mAttrsAndChildren.SetAndTakeAttr(nsGkAtoms::style, attrValue); diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 7b51e42c4e7..1d3960ab4bc 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1088,7 +1088,7 @@ nsXULElement::ParseAttribute(PRInt32 aNamespaceID, if (aNamespaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::style) { SetFlags(NODE_MAY_HAVE_STYLE); - nsStyledElement::ParseStyleAttribute(this, aValue, aResult); + nsStyledElement::ParseStyleAttribute(this, aValue, aResult, PR_FALSE); return PR_TRUE; }