1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/ChromeNodeList.h"
8 #include "mozilla/dom/ChromeNodeListBinding.h"
10 using namespace mozilla
;
11 using namespace mozilla::dom
;
13 already_AddRefed
<ChromeNodeList
> ChromeNodeList::Constructor(
14 const GlobalObject
& aGlobal
, ErrorResult
& aRv
) {
15 nsCOMPtr
<nsPIDOMWindowInner
> win
= do_QueryInterface(aGlobal
.GetAsSupports());
16 Document
* root
= win
? win
->GetExtantDoc() : nullptr;
17 RefPtr
<ChromeNodeList
> list
= new ChromeNodeList(root
);
21 JSObject
* ChromeNodeList::WrapObject(JSContext
* aCx
,
22 JS::Handle
<JSObject
*> aGivenProto
) {
23 return ChromeNodeList_Binding::Wrap(aCx
, this, aGivenProto
);
26 void ChromeNodeList::Append(nsINode
& aNode
, ErrorResult
& aError
) {
27 if (!aNode
.IsContent()) {
28 // nsINodeList deals with nsIContent objects only, so need to
29 // filter out other nodes for now.
30 aError
.Throw(NS_ERROR_DOM_TYPE_ERR
);
34 AppendElement(aNode
.AsContent());
37 void ChromeNodeList::Remove(nsINode
& aNode
, ErrorResult
& aError
) {
38 if (!aNode
.IsContent()) {
39 aError
.Throw(NS_ERROR_DOM_TYPE_ERR
);
43 RemoveElement(aNode
.AsContent());