use of com.facebook.stetho.inspector.elements.NodeDescriptor in project stetho by facebook.
the class DOM method createNodeForElement.
private Node createNodeForElement(Object element, DocumentView view, @Nullable Accumulator<Object> processedElements) {
if (processedElements != null) {
processedElements.store(element);
}
NodeDescriptor descriptor = mDocument.getNodeDescriptor(element);
Node node = new DOM.Node();
node.nodeId = mDocument.getNodeIdForElement(element);
node.nodeType = descriptor.getNodeType(element);
node.nodeName = descriptor.getNodeName(element);
node.localName = descriptor.getLocalName(element);
node.nodeValue = descriptor.getNodeValue(element);
Document.AttributeListAccumulator accumulator = new Document.AttributeListAccumulator();
descriptor.getAttributes(element, accumulator);
// Attributes
node.attributes = accumulator;
// Children
ElementInfo elementInfo = view.getElementInfo(element);
List<Node> childrenNodes = (elementInfo.children.size() == 0) ? Collections.<Node>emptyList() : new ArrayList<Node>(elementInfo.children.size());
for (int i = 0, N = elementInfo.children.size(); i < N; ++i) {
final Object childElement = elementInfo.children.get(i);
Node childNode = createNodeForElement(childElement, view, processedElements);
childrenNodes.add(childNode);
}
node.children = childrenNodes;
node.childNodeCount = childrenNodes.size();
return node;
}
Aggregations