Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef mozilla_devtools_DominatorTree__
7 : #define mozilla_devtools_DominatorTree__
8 :
9 : #include "mozilla/devtools/HeapSnapshot.h"
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/ErrorResult.h"
12 : #include "mozilla/RefCounted.h"
13 : #include "js/UbiNodeDominatorTree.h"
14 : #include "nsWrapperCache.h"
15 :
16 : namespace mozilla {
17 : namespace devtools {
18 :
19 : class DominatorTree final : public nsISupports
20 : , public nsWrapperCache
21 : {
22 : protected:
23 : nsCOMPtr<nsISupports> mParent;
24 :
25 0 : virtual ~DominatorTree() { }
26 :
27 : private:
28 : JS::ubi::DominatorTree mDominatorTree;
29 : RefPtr<HeapSnapshot> mHeapSnapshot;
30 :
31 : public:
32 0 : explicit DominatorTree(JS::ubi::DominatorTree&& aDominatorTree, HeapSnapshot* aHeapSnapshot,
33 : nsISupports* aParent)
34 0 : : mParent(aParent)
35 0 : , mDominatorTree(Move(aDominatorTree))
36 0 : , mHeapSnapshot(aHeapSnapshot)
37 : {
38 0 : MOZ_ASSERT(aParent);
39 0 : MOZ_ASSERT(aHeapSnapshot);
40 0 : };
41 :
42 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS;
43 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DominatorTree);
44 :
45 0 : nsISupports* GetParentObject() const { return mParent; }
46 :
47 : virtual JSObject* WrapObject(JSContext* aCx,
48 : JS::Handle<JSObject*> aGivenProto) override;
49 :
50 : // readonly attribute NodeId root
51 0 : uint64_t Root() const { return mDominatorTree.root().identifier(); }
52 :
53 : // [Throws] NodeSize getRetainedSize(NodeId node)
54 : dom::Nullable<uint64_t> GetRetainedSize(uint64_t aNodeId, ErrorResult& aRv);
55 :
56 : // [Throws] sequence<NodeId>? getImmediatelyDominated(NodeId node);
57 : void GetImmediatelyDominated(uint64_t aNodeId, dom::Nullable<nsTArray<uint64_t>>& aOutDominated,
58 : ErrorResult& aRv);
59 :
60 : // NodeId? getImmediateDominator(NodeId node);
61 : dom::Nullable<uint64_t> GetImmediateDominator(uint64_t aNodeId) const;
62 : };
63 :
64 : } // namespace devtools
65 : } // namespace mozilla
66 :
67 : #endif // mozilla_devtools_DominatorTree__
|