зеркало из https://github.com/mozilla/gecko-dev.git
Bug 742030. When cloning nodes with inline style, preserve the inline style string. r=sicking
This commit is contained in:
Родитель
949747f4f6
Коммит
a25824bd5d
|
@ -800,9 +800,14 @@ public:
|
|||
|
||||
/**
|
||||
* Set the inline style rule for this node. This will send an
|
||||
* appropriate AttributeChanged notification if aNotify is true.
|
||||
* appropriate AttributeChanged notification if aNotify is true. If
|
||||
* a serialized form of aStyleRule is available, a pointer to it
|
||||
* should be passed in aSerialized. Otherwise, aSerialized should
|
||||
* be null.
|
||||
*/
|
||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, bool aNotify) = 0;
|
||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
|
||||
const nsAString* aSerialized,
|
||||
bool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Is the attribute named stored in the mapped attributes?
|
||||
|
|
|
@ -980,6 +980,7 @@ nsGenericDOMDataNode::GetInlineStyleRule()
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsGenericDOMDataNode::SetInlineStyleRule(css::StyleRule* aStyleRule,
|
||||
const nsAString* aSerialized,
|
||||
bool aNotify)
|
||||
{
|
||||
NS_NOTREACHED("How come we're setting inline style on a non-element?");
|
||||
|
|
|
@ -248,7 +248,8 @@ public:
|
|||
virtual const nsAttrValue* DoGetClasses() const;
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
||||
virtual mozilla::css::StyleRule* GetInlineStyleRule();
|
||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, bool aNotify);
|
||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
|
||||
const nsAString* aSerialized, bool aNotify);
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
PRInt32 aModType) const;
|
||||
|
|
|
@ -3609,6 +3609,7 @@ nsGenericElement::GetInlineStyleRule()
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::SetInlineStyleRule(css::StyleRule* aStyleRule,
|
||||
const nsAString* aSerialized,
|
||||
bool aNotify)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("nsGenericElement::SetInlineStyleRule");
|
||||
|
|
|
@ -368,7 +368,9 @@ public:
|
|||
virtual const nsAttrValue* DoGetClasses() const;
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
||||
virtual mozilla::css::StyleRule* GetInlineStyleRule();
|
||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, bool aNotify);
|
||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
|
||||
const nsAString* aSerialized,
|
||||
bool aNotify);
|
||||
NS_IMETHOD_(bool)
|
||||
IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
|
|
|
@ -163,6 +163,7 @@ nsStyledElementNotElementCSSInlineStyle::AfterSetAttr(PRInt32 aNamespaceID,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aStyleRule,
|
||||
const nsAString* aSerialized,
|
||||
bool aNotify)
|
||||
{
|
||||
SetMayHaveStyle();
|
||||
|
@ -193,7 +194,7 @@ nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aSty
|
|||
modification = !!mAttrsAndChildren.GetAttr(nsGkAtoms::style);
|
||||
}
|
||||
|
||||
nsAttrValue attrValue(aStyleRule, nsnull);
|
||||
nsAttrValue attrValue(aStyleRule, aSerialized);
|
||||
|
||||
// XXXbz do we ever end up with ADDITION here? I doubt it.
|
||||
PRUint8 modType = modification ?
|
||||
|
|
|
@ -74,7 +74,9 @@ public:
|
|||
virtual const nsAttrValue* DoGetClasses() const;
|
||||
|
||||
virtual mozilla::css::StyleRule* GetInlineStyleRule();
|
||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, bool aNotify);
|
||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
|
||||
const nsAString* aSerialized,
|
||||
bool aNotify);
|
||||
|
||||
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
bool aNotify);
|
||||
|
|
|
@ -314,6 +314,10 @@ nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst) const
|
|||
for (i = 0; i < count; ++i) {
|
||||
const nsAttrName *name = mAttrsAndChildren.AttrNameAt(i);
|
||||
const nsAttrValue *value = mAttrsAndChildren.AttrAt(i);
|
||||
|
||||
nsAutoString valStr;
|
||||
value->ToString(valStr);
|
||||
|
||||
if (name->Equals(nsGkAtoms::style, kNameSpaceID_None) &&
|
||||
value->Type() == nsAttrValue::eCSSStyleRule) {
|
||||
// We can't just set this as a string, because that will fail
|
||||
|
@ -323,14 +327,12 @@ nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst) const
|
|||
nsRefPtr<mozilla::css::StyleRule> styleRule = do_QueryObject(ruleClone);
|
||||
NS_ENSURE_TRUE(styleRule, NS_ERROR_UNEXPECTED);
|
||||
|
||||
rv = aDst->SetInlineStyleRule(styleRule, false);
|
||||
rv = aDst->SetInlineStyleRule(styleRule, &valStr, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAutoString valStr;
|
||||
value->ToString(valStr);
|
||||
rv = aDst->SetAttr(name->NamespaceID(), name->LocalName(),
|
||||
name->GetPrefix(), valStr, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -299,6 +299,7 @@ _TEST_FILES = \
|
|||
test_bug651956.html \
|
||||
test_bug694503.html \
|
||||
test_object_plugin_nav.html \
|
||||
test_bug742030.html \
|
||||
$(NULL)
|
||||
|
||||
_BROWSER_TEST_FILES = \
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=742030
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 742030</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=742030">Mozilla Bug 742030</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 742030 **/
|
||||
const str = " color: #ff0000 ";
|
||||
var span = document.createElement("span");
|
||||
span.setAttribute("style", str);
|
||||
is(span.getAttribute("style"), str, "Should have set properly");
|
||||
var span2 = span.cloneNode(false);
|
||||
is(span2.getAttribute("style"), str, "Should have cloned properly");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -114,7 +114,7 @@ nsDOMCSSAttributeDeclaration::SetCSSDeclaration(css::Declaration* aDecl)
|
|||
|
||||
return
|
||||
mIsSMILOverride ? mElement->SetSMILOverrideStyleRule(newRule, true) :
|
||||
mElement->SetInlineStyleRule(newRule, true);
|
||||
mElement->SetInlineStyleRule(newRule, nsnull, true);
|
||||
}
|
||||
|
||||
nsIDocument*
|
||||
|
@ -164,7 +164,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(bool aAllocate)
|
|||
if (mIsSMILOverride)
|
||||
rv = mElement->SetSMILOverrideStyleRule(newRule, false);
|
||||
else
|
||||
rv = mElement->SetInlineStyleRule(newRule, false);
|
||||
rv = mElement->SetInlineStyleRule(newRule, nsnull, false);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return nsnull; // the decl will be destroyed along with the style rule
|
||||
|
|
Загрузка…
Ссылка в новой задаче