in stetho/src/main/java/com/facebook/stetho/inspector/protocol/module/CSS.java [56:91]
public JsonRpcResult getComputedStyleForNode(JsonRpcPeer peer, JSONObject params) {
final GetComputedStyleForNodeRequest request = mObjectMapper.convertValue(
params,
GetComputedStyleForNodeRequest.class);
final GetComputedStyleForNodeResult result = new GetComputedStyleForNodeResult();
result.computedStyle = new ArrayList<>();
mDocument.postAndWait(new Runnable() {
@Override
public void run() {
Object element = mDocument.getElementForNodeId(request.nodeId);
if (element == null) {
LogUtil.e("Tried to get the style of an element that does not exist, using nodeid=" +
request.nodeId);
return;
}
mDocument.getElementComputedStyles(
element,
new ComputedStyleAccumulator() {
@Override
public void store(String name, String value) {
final CSSComputedStyleProperty property = new CSSComputedStyleProperty();
property.name = name;
property.value = value;
result.computedStyle.add(property);
}
});
}
});
return result;
}