Bug 1055773 - Move hasAttributes method from Node to Element. r=bz

This commit is contained in:
Nick Lebedev 2014-10-01 10:16:00 +02:00
parent 7546b0c638
commit 3694da2a86
25 changed files with 32 additions and 43 deletions

View File

@ -646,6 +646,10 @@ public:
}
bool HasAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName) const;
bool HasAttributes() const
{
return HasAttrs();
}
Element* Closest(const nsAString& aSelector,
ErrorResult& aResult);
bool Matches(const nsAString& aSelector,
@ -1349,11 +1353,6 @@ inline const mozilla::dom::Element* nsINode::AsElement() const
return static_cast<const mozilla::dom::Element*>(this);
}
inline bool nsINode::HasAttributes() const
{
return IsElement() && AsElement()->HasAttrs();
}
/**
* Macros to implement Clone(). _elementName is the class for which to implement
* Clone.
@ -1537,6 +1536,11 @@ NS_IMETHOD HasAttributeNS(const nsAString& namespaceURI, \
*_retval = Element::HasAttributeNS(namespaceURI, localName); \
return NS_OK; \
} \
NS_IMETHOD HasAttributes(bool* _retval) MOZ_FINAL \
{ \
*_retval = Element::HasAttributes(); \
return NS_OK; \
} \
NS_IMETHOD GetAttributeNode(const nsAString& name, \
nsIDOMAttr** _retval) MOZ_FINAL \
{ \

View File

@ -1640,8 +1640,7 @@ public:
localName.Length());
}
}
// HasAttributes is defined inline in Element.h.
bool HasAttributes() const;
nsDOMAttributeMap* GetAttributes();
void SetUserData(JSContext* aCx, const nsAString& aKey,
JS::Handle<JS::Value> aData,
@ -1994,12 +1993,6 @@ ToCanonicalSupports(nsINode* aPointer)
aLocalName = nsINode::LocalName(); \
return NS_OK; \
} \
using nsINode::HasAttributes; \
NS_IMETHOD HasAttributes(bool* aResult) __VA_ARGS__ \
{ \
*aResult = nsINode::HasAttributes(); \
return NS_OK; \
} \
NS_IMETHOD GetDOMBaseURI(nsAString& aBaseURI) __VA_ARGS__ \
{ \
nsINode::GetBaseURI(aBaseURI); \

View File

@ -8,6 +8,5 @@
"Historical DOM features must be removed: getAttributeNodeNS": true,
"Historical DOM features must be removed: setAttributeNode": true,
"Historical DOM features must be removed: removeAttributeNode": true,
"DocumentType member must be nuked: internalSubset": true,
"Node member must be nuked: hasAttributes": true
"DocumentType member must be nuked: internalSubset": true
}

View File

@ -14,7 +14,7 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[builtinclass, uuid(93bf61ba-9ffa-42b7-9594-2de803c9627c)]
[builtinclass, uuid(7d0582bd-09a7-430e-969b-054abbea19fe)]
interface nsIDOMAttr : nsIDOMNode
{
readonly attribute DOMString name;

View File

@ -15,7 +15,7 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[uuid(864c4e6a-3933-4f8a-8dd8-3883be60ea10)]
[uuid(4ac42d40-69b7-4506-b730-c41ec74b74bd)]
interface nsIDOMCDATASection : nsIDOMText
{
};

View File

@ -13,7 +13,7 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[uuid(7b1b8719-6669-4614-bf96-93ddf7966f64)]
[uuid(844b8e7e-6d37-4fa1-8196-86e3afdfa0ca)]
interface nsIDOMCharacterData : nsIDOMNode
{
attribute DOMString data;

View File

@ -14,7 +14,7 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[uuid(8edde4d9-dc26-492c-8477-2be0f95088ad)]
[uuid(c1a1d2ea-e106-4ee8-806d-2633468e8098)]
interface nsIDOMComment : nsIDOMCharacterData
{
};

View File

@ -32,7 +32,7 @@ interface nsIDOMLocation;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[uuid(950ca868-e09f-4a7d-9b87-e4ec9aedb3e5)]
[uuid(08c6400b-0b6d-4ce6-b88d-e7a15a9c7c03)]
interface nsIDOMDocument : nsIDOMNode
{
readonly attribute nsIDOMDocumentType doctype;

View File

@ -14,7 +14,7 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[builtinclass, uuid(5c601878-5b77-4f88-9425-3fe8d2dc8813)]
[builtinclass, uuid(24b34c61-7326-42d4-87ec-5d3b5c0b1b26)]
interface nsIDOMDocumentFragment : nsIDOMNode
{
/**

View File

@ -15,7 +15,7 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[uuid(55fe2f3f-35e8-4cb0-b39d-bea1bd0061c7)]
[uuid(23c1f549-d40b-49b8-992e-2a1136afa13f)]
interface nsIDOMDocumentType : nsIDOMNode
{
readonly attribute DOMString name;

View File

@ -15,7 +15,7 @@ interface nsIDOMMozNamedAttrMap;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element
*/
[uuid(ea94c5e2-5d5d-4afe-b3ab-431903797f31)]
[uuid(59eb63f9-c8c0-41d2-bf73-739de43b17f9)]
interface nsIDOMElement : nsIDOMNode
{
readonly attribute DOMString tagName;
@ -42,6 +42,7 @@ interface nsIDOMElement : nsIDOMNode
boolean hasAttribute(in DOMString name);
boolean hasAttributeNS(in DOMString namespaceURI,
in DOMString localName);
boolean hasAttributes();
// Obsolete methods.
nsIDOMAttr getAttributeNode(in DOMString name);

View File

@ -16,7 +16,7 @@ interface nsIVariant;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[uuid(3eef1ab9-2f87-4eda-9bb9-469c37294f72)]
[uuid(238222a9-7aa5-4804-9f86-484853ce4b15)]
interface nsIDOMNode : nsISupports
{
const unsigned short ELEMENT_NODE = 1;
@ -68,8 +68,6 @@ interface nsIDOMNode : nsISupports
// Introduced in DOM Level 2:
readonly attribute DOMString localName;
// Introduced in DOM Level 2:
boolean hasAttributes();
// Introduced in DOM Level 3:
// This uses a binaryname to avoid warnings due to name collision with

View File

@ -15,7 +15,7 @@
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[uuid(ca632936-4c6b-48b4-9920-fbe1e3710802)]
[uuid(d0163f44-8f5b-4234-b3aa-43cab64e2039)]
interface nsIDOMProcessingInstruction : nsIDOMCharacterData
{
readonly attribute DOMString target;

View File

@ -13,7 +13,7 @@
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[uuid(b16d449b-60f1-444a-a7e5-dc50a5d0ffad)]
[uuid(775bbd26-1581-4e54-b82c-5d9dc5a3363b)]
interface nsIDOMText : nsIDOMCharacterData
{
nsIDOMText splitText(in unsigned long offset)

View File

@ -5,7 +5,7 @@
#include "nsIDOMDocument.idl"
[uuid(dc767223-838f-4ca2-9f4c-ae685862d1df)]
[uuid(1d54e44a-2012-4567-805d-bd5455fc6421)]
interface nsIDOMXMLDocument : nsIDOMDocument
{
// DOM Level 3 Load & Save, DocumentLS

View File

@ -13,7 +13,7 @@
*/
interface nsISelection;
[uuid(b7fcb58a-9ad5-44b5-8c6f-b7181c249413)]
[uuid(abf369fb-a8b2-4fba-95f5-9e4a896e40a8)]
interface nsIDOMHTMLDocument : nsIDOMDocument
{
attribute DOMString domain;

View File

@ -19,7 +19,7 @@ interface nsIDOMHTMLMenuElement;
* with changes from the work-in-progress WHATWG HTML specification:
* http://www.whatwg.org/specs/web-apps/current-work/
*/
[uuid(2728c077-9ecc-4a75-ac95-16fbfcb007df)]
[uuid(8c9472c2-785a-40b6-ad47-4d98e64562bd)]
interface nsIDOMHTMLElement : nsIDOMElement
{
// metadata attributes

View File

@ -9,7 +9,7 @@ interface nsIDOMCSSStyleDeclaration;
interface nsIDOMCSSValue;
[uuid(7a11697a-668b-4a6e-a44a-909abffee230)]
[uuid(6618074e-0c77-4fec-8870-a6f79aa79b07)]
interface nsIDOMSVGElement : nsIDOMElement
{
// raises DOMException on setting

View File

@ -10,7 +10,7 @@ interface nsIDOMXULCommandDispatcher;
interface nsIObserver;
interface nsIBoxObject;
[uuid(546c658e-805f-4293-9738-6e6a00d75839)]
[uuid(6f932360-ae43-4fa7-9200-66f64e05a356)]
interface nsIDOMXULDocument : nsIDOMDocument
{
attribute nsIDOMNode popupNode;

View File

@ -12,7 +12,7 @@ interface nsIControllers;
interface nsIBoxObject;
[uuid(1bd9303d-0854-4ed3-9fda-added29a570e)]
[uuid(ef62515d-3160-4463-abd7-fc9b7385ecef)]
interface nsIDOMXULElement : nsIDOMElement
{
// Layout properties

View File

@ -27,7 +27,7 @@ bug371552 = ["elementhasattributens02"];
wrongDocError = ["elementsetattributenodens05", "namednodemapsetnameditemns03",
"setAttributeNodeNS05", "setNamedItemNS02"];
attrExodus = ["elementsetattributenodens06", "importNode01",
"hc_namednodemapinvalidtype1"];
"hc_namednodemapinvalidtype1", "nodehasattributes02"];
bogusPrefix = ["nodesetprefix05", "nodesetprefix09", "prefix06", "prefix07"];
prefixReplacement = ["setAttributeNodeNS04"];

View File

@ -51,6 +51,8 @@ interface Element : Node {
boolean hasAttribute(DOMString name);
[Pure]
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
[Pure]
boolean hasAttributes();
[Throws, Pure]
Element? closest(DOMString selector);

View File

@ -101,8 +101,6 @@ interface Node : EventTarget {
[Constant]
readonly attribute DOMString? localName;
[Pure]
boolean hasAttributes();
[Throws, Func="IsChromeOrXBL"]
any setUserData(DOMString key, any data);
[Throws, Func="IsChromeOrXBL"]

View File

@ -30,9 +30,6 @@
[DocumentType member must be nuked: internalSubset]
expected: FAIL
[Node member must be nuked: hasAttributes]
expected: FAIL
[Node member must be nuked: namespaceURI]
expected: FAIL

View File

@ -327,9 +327,6 @@
[Document interface: xmlDoc must inherit property "queryAll" with the proper type (34)]
expected: FAIL
[Element interface: operation hasAttributes()]
expected: FAIL
[Element interface: element must inherit property "prepend" with the proper type (31)]
expected: FAIL