Bug 1690340 - Part 4: Insert the "Page Source" before the "Extensions for Developers...
[gecko.git] / js / public / UbiNodeUtils.h
blobbd48086af8744ed41f5bfeddd9eb9c0198b84830
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 #ifndef js_UbiNodeUtils_h
8 #define js_UbiNodeUtils_h
10 #include "jspubtd.h"
12 #include "js/UbiNode.h"
13 #include "js/UniquePtr.h"
15 using JS::ubi::Edge;
16 using JS::ubi::EdgeRange;
17 using JS::ubi::EdgeVector;
19 namespace JS {
20 namespace ubi {
21 // An EdgeRange concrete class that simply holds a vector of Edges,
22 // populated by the addTracerEdges method.
23 class SimpleEdgeRange : public EdgeRange {
24 EdgeVector edges;
25 size_t i;
27 protected:
28 void settle() { front_ = i < edges.length() ? &edges[i] : nullptr; }
30 public:
31 explicit SimpleEdgeRange() : edges(), i(0) {}
33 bool addTracerEdges(JSRuntime* rt, void* thing, JS::TraceKind kind,
34 bool wantNames);
36 bool addEdge(Edge edge) {
37 if (!edges.append(std::move(edge))) return false;
38 settle();
39 return true;
42 void popFront() override {
43 i++;
44 settle();
48 } // namespace ubi
49 } // namespace JS
51 #endif // js_UbiNodeUtils_h