Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1522)

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp

Issue 2296323002: DevTools: Add features to collect classnames from Stylesheets and DOM (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698