/src/mozilla-central/dom/base/ChromeNodeList.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #include "mozilla/dom/ChromeNodeList.h" |
8 | | #include "mozilla/dom/ChromeNodeListBinding.h" |
9 | | |
10 | | using namespace mozilla; |
11 | | using namespace mozilla::dom; |
12 | | |
13 | | already_AddRefed<ChromeNodeList> |
14 | | ChromeNodeList::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) |
15 | 0 | { |
16 | 0 | nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports()); |
17 | 0 | nsIDocument* root = win ? win->GetExtantDoc() : nullptr; |
18 | 0 | RefPtr<ChromeNodeList> list = new ChromeNodeList(root); |
19 | 0 | return list.forget(); |
20 | 0 | } |
21 | | |
22 | | JSObject* |
23 | | ChromeNodeList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
24 | 0 | { |
25 | 0 | return ChromeNodeList_Binding::Wrap(aCx, this, aGivenProto); |
26 | 0 | } |
27 | | |
28 | | void |
29 | | ChromeNodeList::Append(nsINode& aNode, ErrorResult& aError) |
30 | 0 | { |
31 | 0 | if (!aNode.IsContent()) { |
32 | 0 | // nsINodeList deals with nsIContent objects only, so need to |
33 | 0 | // filter out other nodes for now. |
34 | 0 | aError.Throw(NS_ERROR_DOM_TYPE_ERR); |
35 | 0 | return; |
36 | 0 | } |
37 | 0 | |
38 | 0 | AppendElement(aNode.AsContent()); |
39 | 0 | } |
40 | | |
41 | | void |
42 | | ChromeNodeList::Remove(nsINode& aNode, ErrorResult& aError) |
43 | 0 | { |
44 | 0 | if (!aNode.IsContent()) { |
45 | 0 | aError.Throw(NS_ERROR_DOM_TYPE_ERR); |
46 | 0 | return; |
47 | 0 | } |
48 | 0 | |
49 | 0 | RemoveElement(aNode.AsContent()); |
50 | 0 | } |