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

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

Issue 2347963002: [DevTools] Show distribution for Shadow DOM V1. (Closed)
Patch Set: getDistributedNodes -> iteration Created 4 years, 3 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 0f5b4712fe0ab5954057bacea35eee015f31bd09..0ceb294c59525ae7a89873664d29373976394f87 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
@@ -55,6 +55,7 @@
#include "core/html/HTMLFrameOwnerElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLLinkElement.h"
+#include "core/html/HTMLSlotElement.h"
#include "core/html/HTMLTemplateElement.h"
#include "core/html/imports/HTMLImportChild.h"
#include "core/html/imports/HTMLImportLoader.h"
@@ -1537,6 +1538,10 @@ std::unique_ptr<protocol::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node*
value->setDistributedNodes(buildArrayForDistributedNodes(toInsertionPoint(element)));
forcePushChildren = true;
}
+ if (isHTMLSlotElement(*element)) {
+ value->setDistributedNodes(buildDistributedNodesForSlot(toHTMLSlotElement(element)));
+ forcePushChildren = true;
+ }
} else if (node->isDocumentNode()) {
Document* document = toDocument(node);
value->setDocumentURL(documentURLString(document));
@@ -1636,6 +1641,22 @@ std::unique_ptr<protocol::Array<protocol::DOM::BackendNode>> InspectorDOMAgent::
return distributedNodes;
}
+std::unique_ptr<protocol::Array<protocol::DOM::BackendNode>> InspectorDOMAgent::buildDistributedNodesForSlot(HTMLSlotElement* slotElement)
+{
+ std::unique_ptr<protocol::Array<protocol::DOM::BackendNode>> distributedNodes = protocol::Array<protocol::DOM::BackendNode>::create();
+ for (Node* node = slotElement->firstDistributedNode(); node; node = slotElement->distributedNodeNextTo(*node)) {
+ if (isWhitespace(node))
+ continue;
+
+ std::unique_ptr<protocol::DOM::BackendNode> backendNode = protocol::DOM::BackendNode::create()
+ .setNodeType(node->getNodeType())
+ .setNodeName(node->nodeName())
+ .setBackendNodeId(DOMNodeIds::idForNode(node)).build();
+ distributedNodes->addItem(std::move(backendNode));
+ }
+ return distributedNodes;
+}
+
Node* InspectorDOMAgent::innerFirstChild(Node* node)
{
node = node->firstChild();
@@ -1907,6 +1928,13 @@ void InspectorDOMAgent::didPerformElementShadowDistribution(Element* shadowHost)
}
}
+void InspectorDOMAgent::didPerformSlotDistribution(HTMLSlotElement* slotElement)
+{
+ int insertionPointId = m_documentNodeToIdMap->get(slotElement);
+ if (insertionPointId)
+ frontend()->distributedNodesUpdated(insertionPointId, buildDistributedNodesForSlot(slotElement));
+}
+
void InspectorDOMAgent::frameDocumentUpdated(LocalFrame* frame)
{
Document* document = frame->document();

Powered by Google App Engine
This is Rietveld 408576698