Chromium Code Reviews| Index: third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp |
| diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp |
| index 7ed5a9c0565280f5f17062fd8b95b99a931f7895..63fc9552d228e6bab30ee471e453bb5cd45f7071 100644 |
| --- a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp |
| +++ b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp |
| @@ -581,6 +581,28 @@ Node* InspectorDOMAgent::nodeForId(int id) |
| return nullptr; |
| } |
| +void InspectorDOMAgent::collectClassNames(ErrorString* errorString, int nodeId, Maybe<protocol::Array<String>>* classNames) |
| +{ |
| + HashSet<String> uniqueNames; |
| + *classNames = protocol::Array<String>::create(); |
| + Node* node = nodeForId(nodeId); |
| + if (!node || (!node->isElementNode() && !node->isDocumentNode() && !node->isDocumentFragment())) |
| + return; |
|
lushnikov
2016/09/01 20:50:35
let's return an error in this case
ahmetemirercin
2016/09/02 19:59:54
Done.
|
| + for (Node& child : NodeTraversal::inclusiveDescendantsOf(*node)) { |
| + if (child.isElementNode()) { |
| + const Element& element = toElement(child); |
| + if (!element.hasClass()) |
| + continue; |
| + const SpaceSplitString& classNameList = element.classNames(); |
| + for (unsigned i = 0; i < classNameList.size(); ++i) { |
|
lushnikov
2016/09/01 20:50:36
style: drop {} around one-line blocks
ahmetemirercin
2016/09/02 19:59:54
Done.
|
| + uniqueNames.add(classNameList[i]); |
| + } |
| + } |
| + } |
| + for (const String& className : uniqueNames) |
| + classNames->fromJust()->addItem(className); |
| +} |
| + |
| void InspectorDOMAgent::requestChildNodes(ErrorString* errorString, int nodeId, const Maybe<int>& depth) |
| { |
| int sanitizedDepth = depth.fromMaybe(1); |