gecko-dev/js/public/UbiNodeUtils.h
Kristen Wright 82fd1509ba Bug 1474383 - JSRuntime hook to construct ubi::Nodes specialized for nsINode instances. r=sfink,jimb,bz
Created a runtime hook to handle DOM nodes. Specialized ubi::Concrete for nsINode-inheriting objects. Displayed outgoing nsISupports* edges on reflector JSObjects. Generated outgoing child edges from nsINodes by examining their children. Updated the UbiNodeCensus to ignore zone checks if there is no zone to be found in a node.

--HG--
extra : rebase_source : 319dccb3277a39e51a79588eac9c8f2b4ff97c2f
2018-07-06 16:52:42 -07:00

52 lines
1.2 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef js_UbiNodeUtils_h
#define js_UbiNodeUtils_h
#include "jspubtd.h"
#include "js/UbiNode.h"
#include "js/UniquePtr.h"
using JS::ubi::Edge;
using JS::ubi::EdgeRange;
using JS::ubi::EdgeVector;
namespace JS {
namespace ubi {
// An EdgeRange concrete class that simply holds a vector of Edges,
// populated by the addTracerEdges method.
class SimpleEdgeRange : public EdgeRange {
EdgeVector edges;
size_t i;
protected:
void settle() {
front_ = i < edges.length() ? &edges[i] : nullptr;
}
public:
explicit SimpleEdgeRange() : edges(), i(0) { }
bool addTracerEdges(JSRuntime* rt, void* thing, JS::TraceKind kind, bool wantNames);
bool addEdge(Edge edge) {
if(!edges.append(std::move(edge)))
return false;
settle();
return true;
}
void popFront() override { i++; settle(); }
};
} // namespace JS
} // namespace ubi
#endif // js_UbiNodeUtils_h