Source:
public JsonRpcResult getMatchedStylesForNode(JsonRpcPeer peer, JSONObject params) { final GetMatchedStylesForNodeRequest request = mObjectMapper.convertValue( params, GetMatchedStylesForNodeRequest.class); final Map<String, List<CSSProperty>> selectors = new HashMap<>(); mDocument.postAndWait(new Runnable() { @Override public void run() { Object elementForNodeId = mDocument.getElementForNodeId(request.nodeId); if (elementForNodeId == null) { LogUtil.w("Failed to get style of an element that does not exist, nodeid=" + request.nodeId); return; } mDocument.getElementStyles( elementForNodeId, new StyleAccumulator() { @Override public void store(String selector, String name, String value, boolean isDefault) { if (!isDefault) { List<CSSProperty> properties = selectors.get(selector); if (properties == null) { properties = new ArrayList<>(); selectors.put(selector, properties); } final CSSProperty property = new CSSProperty(); property.name = name; property.value = value; properties.add(property); } } }); } }); final GetMatchedStylesForNodeResult result = new GetMatchedStylesForNodeResult(); result.matchedCSSRules = new ArrayList<>(); for (String selectorName : selectors.keySet()) { final RuleMatch match = new RuleMatch(); match.matchingSelectors = ListUtil.newImmutableList(0); final Selector selector = new Selector(); selector.value = selectorName; final CSSRule rule = new CSSRule(); rule.origin = Origin.REGULAR; rule.selectorList = new SelectorList(); rule.selectorList.selectors = ListUtil.newImmutableList(selector); rule.style = new CSSStyle(); rule.style.cssProperties = new ArrayList<>(); match.rule = rule; result.matchedCSSRules.add(match); } return result; }

Target:
public JsonRpcResult getMatchedStylesForNode(JsonRpcPeer peer, JSONObject params) { final GetMatchedStylesForNodeRequest request = mObjectMapper.convertValue( params, GetMatchedStylesForNodeRequest.class); mDocument.postAndWait(new Runnable() { @Override public void run() { Object elementForNodeId = mDocument.getElementForNodeId(request.nodeId); if (elementForNodeId == null) { LogUtil.w("Failed to get style of an element that does not exist, nodeid=" + request.nodeId); return; } mDocument.getElementStyles( elementForNodeId, new StyleAccumulator() { @Override public void store(String selector, String name, String value, boolean isDefault) { if (!isDefault) { ArrayList<CSSProperty> properties = mSelectorCollector.get(selector); if (properties == null) { properties = new ArrayList<>(); mSelectorCollector.put(selector, properties); } final CSSProperty property = new CSSProperty(); property.name = name; property.value = value; properties.add(property); } } }); } }); final GetMatchedStylesForNodeResult result = new GetMatchedStylesForNodeResult(); result.matchedCSSRules = new ArrayList<>(); result.inherited = Collections.emptyList(); result.pseudoElements = Collections.emptyList(); for (Map.Entry<String, ArrayList<CSSProperty>> entry : mSelectorCollector.entrySet()) { final ArrayList<CSSProperty> properties = entry.getValue(); if (properties.isEmpty()) { continue; } final RuleMatch match = new RuleMatch(); match.matchingSelectors = ListUtil.newImmutableList(0); final Selector selector = new Selector(); selector.value = entry.getKey(); final CSSRule rule = new CSSRule(); rule.origin = Origin.REGULAR; rule.selectorList = new SelectorList(); rule.selectorList.selectors = ListUtil.newImmutableList(selector); rule.style = new CSSStyle(); rule.style.cssProperties = ListUtil.copyToImmutableList(properties); rule.style.shorthandEntries = Collections.emptyList(); match.rule = rule; result.matchedCSSRules.add(match); properties.clear(); } return result; }