Search in sources :

Example 1 with NodeDescriptor

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;
}
Also used : ElementInfo(com.facebook.stetho.inspector.elements.ElementInfo) NodeDescriptor(com.facebook.stetho.inspector.elements.NodeDescriptor) JSONObject(org.json.JSONObject) Document(com.facebook.stetho.inspector.elements.Document)

Aggregations

Document (com.facebook.stetho.inspector.elements.Document)1 ElementInfo (com.facebook.stetho.inspector.elements.ElementInfo)1 NodeDescriptor (com.facebook.stetho.inspector.elements.NodeDescriptor)1 JSONObject (org.json.JSONObject)1