Bug 816343 - Add querySelector* to *Element/DocumentFragment/Document.idl r=bz

This commit is contained in:
Jacek Caban 2013-07-08 14:09:18 +02:00
Родитель 8bcd332fb1
Коммит c71c460685
9 изменённых файлов: 101 добавлений и 15 удалений

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

@ -1615,6 +1615,18 @@ NS_IMETHOD MozRequestPointerLock(void) MOZ_FINAL \
{ \
Element::MozRequestPointerLock(); \
return NS_OK; \
} \
using nsINode::QuerySelector; \
NS_IMETHOD QuerySelector(const nsAString& aSelector, \
nsIDOMElement **aReturn) MOZ_FINAL \
{ \
return nsINode::QuerySelector(aSelector, aReturn); \
} \
using nsINode::QuerySelectorAll; \
NS_IMETHOD QuerySelectorAll(const nsAString& aSelector, \
nsIDOMNodeList **aReturn) MOZ_FINAL \
{ \
return nsINode::QuerySelectorAll(aSelector, aReturn); \
}
#endif // mozilla_dom_Element_h__

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

@ -1084,6 +1084,9 @@ public:
already_AddRefed<nsINodeList> QuerySelectorAll(const nsAString& aSelector,
mozilla::ErrorResult& aResult);
nsresult QuerySelector(const nsAString& aSelector, nsIDOMElement **aReturn);
nsresult QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn);
/**
* Associate an object aData to aKey on this node. If aData is null any
* previously registered object and UserDataHandler associated to aKey on

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

@ -45,6 +45,20 @@ DocumentFragment::GetIDAttributeName() const
return nullptr;
}
NS_IMETHODIMP
DocumentFragment::QuerySelector(const nsAString& aSelector,
nsIDOMElement **aReturn)
{
return nsINode::QuerySelector(aSelector, aReturn);
}
NS_IMETHODIMP
DocumentFragment::QuerySelectorAll(const nsAString& aSelector,
nsIDOMNodeList **aReturn)
{
return nsINode::QuerySelectorAll(aSelector, aReturn);
}
#ifdef DEBUG
void
DocumentFragment::List(FILE* out, int32_t aIndent) const

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

@ -26,18 +26,6 @@ class HTMLTemplateElement;
class DocumentFragment : public FragmentOrElement,
public nsIDOMDocumentFragment
{
public:
using FragmentOrElement::GetFirstChild;
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// interface nsIDOMNode
NS_FORWARD_NSIDOMNODE_TO_NSINODE
// interface nsIDOMDocumentFragment
// NS_DECL_NSIDOCUMENTFRAGMENT Empty
private:
void Init()
{
@ -51,6 +39,19 @@ private:
}
public:
using FragmentOrElement::GetFirstChild;
using nsINode::QuerySelector;
using nsINode::QuerySelectorAll;
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// interface nsIDOMNode
NS_FORWARD_NSIDOMNODE_TO_NSINODE
// interface nsIDOMDocumentFragment
NS_DECL_NSIDOMDOCUMENTFRAGMENT
DocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo)
: FragmentOrElement(aNodeInfo), mHost(nullptr)
{

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

@ -11231,6 +11231,18 @@ nsDocument::DocSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
// - many!
}
NS_IMETHODIMP
nsDocument::QuerySelector(const nsAString& aSelector, nsIDOMElement **aReturn)
{
return nsINode::QuerySelector(aSelector, aReturn);
}
NS_IMETHODIMP
nsDocument::QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn)
{
return nsINode::QuerySelectorAll(aSelector, aReturn);
}
already_AddRefed<nsIDocument>
nsIDocument::Constructor(const GlobalObject& aGlobal, ErrorResult& rv)
{

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

@ -2360,6 +2360,27 @@ nsINode::QuerySelectorAll(const nsAString& aSelector, ErrorResult& aResult)
return contentList.forget();
}
nsresult
nsINode::QuerySelector(const nsAString& aSelector, nsIDOMElement **aReturn)
{
ErrorResult rv;
Element* result = nsINode::QuerySelector(aSelector, rv);
if (rv.Failed()) {
return rv.ErrorCode();
}
nsCOMPtr<nsIDOMElement> elt = do_QueryInterface(result);
elt.forget(aReturn);
return NS_OK;
}
nsresult
nsINode::QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn)
{
ErrorResult rv;
*aReturn = nsINode::QuerySelectorAll(aSelector, rv).get();
return rv.ErrorCode();
}
JSObject*
nsINode::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
{

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

@ -27,7 +27,7 @@ interface nsIDOMLocation;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[scriptable, uuid(75996de6-6b0f-43e5-ae79-c98fa669da9a)]
[scriptable, uuid(18de0c13-f82e-4c7e-9a48-b778e00df9ca)]
interface nsIDOMDocument : nsIDOMNode
{
readonly attribute nsIDOMDocumentType doctype;
@ -408,4 +408,12 @@ interface nsIDOMDocument : nsIDOMNode
* strict mode. (XML documents are always in strict mode.)
*/
readonly attribute DOMString compatMode;
/**
* Return nodes that match a given CSS selector.
*
* @see <http://dev.w3.org/2006/webapi/selectors-api/>
*/
nsIDOMElement querySelector([Null(Stringify)] in DOMString selectors);
nsIDOMNodeList querySelectorAll([Null(Stringify)] in DOMString selectors);
};

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

@ -14,7 +14,14 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[scriptable, builtinclass, uuid(33127aed-9d6a-4b0d-95aa-0529f51bcb9c)]
[scriptable, builtinclass, uuid(75a237af-133e-40f0-8196-2a172867c41a)]
interface nsIDOMDocumentFragment : nsIDOMNode
{
/**
* Return nodes that match a given CSS selector.
*
* @see <http://dev.w3.org/2006/webapi/selectors-api/>
*/
nsIDOMElement querySelector([Null(Stringify)] in DOMString selectors);
nsIDOMNodeList querySelectorAll([Null(Stringify)] in DOMString selectors);
};

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

@ -15,7 +15,7 @@ interface nsIDOMMozNamedAttrMap;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element
*/
[scriptable, uuid(43d985da-b7ee-4d1f-a26f-348ccd9506f3)]
[scriptable, uuid(c3646b5d-a07d-470a-8e40-784459833c9f)]
interface nsIDOMElement : nsIDOMNode
{
readonly attribute DOMString tagName;
@ -212,4 +212,12 @@ interface nsIDOMElement : nsIDOMNode
* @see <http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html>
*/
void mozRequestPointerLock();
/**
* Return nodes that match a given CSS selector.
*
* @see <http://dev.w3.org/2006/webapi/selectors-api/>
*/
nsIDOMElement querySelector([Null(Stringify)] in DOMString selectors);
nsIDOMNodeList querySelectorAll([Null(Stringify)] in DOMString selectors);
};