Bug 571390 - classList is always empty on xul elements, r=bz

--HG--
extra : rebase_source : 00d58d4fa7e0bffe2bf6b60b4d8a74fd0e27eebe
This commit is contained in:
Olli Pettay 2010-06-14 10:29:54 +03:00
Родитель 2197cac278
Коммит facc6b93cb
5 изменённых файлов: 62 добавлений и 18 удалений

Просмотреть файл

@ -63,7 +63,7 @@ protected:
if (!mElement) {
return nsnull;
}
return mElement->GetParsedAttr(mAttrAtom);
return mElement->GetAttrInfo(kNameSpaceID_None, mAttrAtom).mValue;
}
nsresult CheckToken(const nsAString& aStr);

Просмотреть файл

@ -746,6 +746,16 @@ public:
nsIDOMDOMTokenList* GetClassList(nsresult *aResult);
PRBool MozMatchesSelector(const nsAString& aSelector);
/**
* Get the attr info for the given namespace ID and attribute name. The
* namespace ID must not be kNameSpaceID_Unknown and the name must not be
* null. Note that this can only return info on attributes that actually
* live on this element (and is only virtual to handle XUL prototypes). That
* is, this should only be called from methods that only care about attrs
* that effectively live in mAttrsAndChildren.
*/
virtual nsAttrInfo GetAttrInfo(PRInt32 aNamespaceID, nsIAtom* aName) const;
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsGenericElement)
protected:
@ -863,16 +873,6 @@ protected:
nsISupports** aTarget,
PRBool* aDefer);
/**
* Get the attr info for the given namespace ID and attribute name. The
* namespace ID must not be kNameSpaceID_Unknown and the name must not be
* null. Note that this can only return info on attributes that actually
* live on this element (and is only virtual to handle XUL prototypes). That
* is, this should only be called from methods that only care about attrs
* that effectively live in mAttrsAndChildren.
*/
virtual nsAttrInfo GetAttrInfo(PRInt32 aNamespaceID, nsIAtom* aName) const;
/**
* Copy attributes and state to another element
* @param aDest the object to copy to

Просмотреть файл

@ -393,6 +393,7 @@ _TEST_FILES2 = \
file_bug548193.sjs \
test_html_colors_quirks.html \
test_html_colors_standards.html \
test_bug571390.xul \
$(NULL)
# This test fails on the Mac for some reason

Просмотреть файл

@ -0,0 +1,43 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=571390
-->
<window title="Mozilla Bug 571390"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="foo bar">
<script type="application/javascript" src="/MochiKit/packed.js"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=571390"
target="_blank">Mozilla Bug 571390</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 571390 **/
is(document.documentElement.classList.length, 2, "Should have 2 classes.");
ok(document.documentElement.classList.contains("foo"), "Should contain 'foo' class.");
ok(document.documentElement.classList.contains("bar"), "Should contain 'bar' class.");
ok(!document.documentElement.classList.contains("foobar"), "Shouldn't contain 'foobar' class.");
document.documentElement.classList.add("foobar");
is(document.documentElement.classList.length, 3, "Should have 3 classes.");
ok(document.documentElement.classList.contains("foo"), "Should contain 'foo' class.");
ok(document.documentElement.classList.contains("bar"), "Should contain 'bar' class.");
ok(document.documentElement.classList.contains("foobar"), "Should contain 'foobar' class.");
document.documentElement.classList.remove("foobar");
is(document.documentElement.classList.length, 2, "Should have 2 classes.");
ok(document.documentElement.classList.contains("foo"), "Should contain 'foo' class.");
ok(document.documentElement.classList.contains("bar"), "Should contain 'bar' class.");
ok(!document.documentElement.classList.contains("foobar"), "Shouldn't contain 'foobar' class.");
]]>
</script>
</window>

Просмотреть файл

@ -577,6 +577,13 @@ public:
mBindingParent = aBindingParent;
}
/**
* Get the attr info for the given namespace ID and attribute name.
* The namespace ID must not be kNameSpaceID_Unknown and the name
* must not be null.
*/
virtual nsAttrInfo GetAttrInfo(PRInt32 aNamespaceID, nsIAtom* aName) const;
protected:
// XXX This can be removed when nsNodeUtils::CloneAndAdopt doesn't need
// access to mPrototype anymore.
@ -627,13 +634,6 @@ protected:
*/
nsresult MakeHeavyweight();
/**
* Get the attr info for the given namespace ID and attribute name.
* The namespace ID must not be kNameSpaceID_Unknown and the name
* must not be null.
*/
virtual nsAttrInfo GetAttrInfo(PRInt32 aNamespaceID, nsIAtom* aName) const;
const nsAttrValue* FindLocalOrProtoAttr(PRInt32 aNameSpaceID,
nsIAtom *aName) const {
return nsXULElement::GetAttrInfo(aNameSpaceID, aName).mValue;