Title: [108993] trunk
Revision
108993
Author
pfeld...@chromium.org
Date
2012-02-27 07:22:31 -0800 (Mon, 27 Feb 2012)

Log Message

Source/WebCore: [Shadow]: Expose one ShadowRoot in the Elements panel (under experiment flag)
https://bugs.webkit.org/show_bug.cgi?id=78202

Reviewed by Yury Semikhatsky.

* dom/ShadowTree.cpp:
(WebCore::ShadowTree::pushShadowRoot):
(WebCore::ShadowTree::popShadowRoot):
* inspector/Inspector.json:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::unbind):
(WebCore::InspectorDOMAgent::assertEditableNode):
(WebCore::InspectorDOMAgent::assertEditableElement):
(WebCore::InspectorDOMAgent::pushChildNodesToFrontend):
(WebCore::InspectorDOMAgent::setAttributeValue):
(WebCore::InspectorDOMAgent::setAttributesAsText):
(WebCore::InspectorDOMAgent::removeAttribute):
(WebCore::InspectorDOMAgent::removeNode):
(WebCore::InspectorDOMAgent::setOuterHTML):
(WebCore::InspectorDOMAgent::setNodeValue):
(WebCore::InspectorDOMAgent::moveTo):
(WebCore::InspectorDOMAgent::buildObjectForNode):
(WebCore::InspectorDOMAgent::didPushShadowRoot):
(WebCore):
(WebCore::InspectorDOMAgent::willPopShadowRoot):
* inspector/InspectorDOMAgent.h:
(WebCore):
(InspectorDOMAgent):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didPushShadowRootImpl):
(WebCore):
(WebCore::InspectorInstrumentation::willPopShadowRootImpl):
* inspector/InspectorInstrumentation.h:
(WebCore):
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::didPushShadowRoot):
(WebCore::InspectorInstrumentation::willPopShadowRoot):
* inspector/PageConsoleAgent.cpp:
(WebCore::PageConsoleAgent::addInspectedNode):
* inspector/front-end/DOMAgent.js:
(WebInspector.DOMNode):
(WebInspector.DOMNode.prototype.hasChildNodes):
(WebInspector.DOMNode.prototype.isInShadowTree):
(WebInspector.DOMNode.prototype._insertChild):
(WebInspector.DOMNode.prototype._setChildrenPayload):
(WebInspector.DOMDocument):
(WebInspector.DOMAgent.prototype._setDetachedRoot):
(WebInspector.DOMAgent.prototype._shadowRootPopped):
(WebInspector.DOMDispatcher.prototype.childNodeRemoved):
(WebInspector.DOMDispatcher.prototype.shadowRootPushed):
(WebInspector.DOMDispatcher.prototype.shadowRootPopped):
* inspector/front-end/ElementsTreeOutline.js:
* inspector/front-end/MemoryStatistics.js:
* inspector/front-end/Settings.js:
(WebInspector.ExperimentsSettings):
* inspector/front-end/inspector.css:
(.webkit-html-tag.shadow, .webkit-html-fragment.shadow):

LayoutTests: [Shadow]: Expose one ShadowRoot in the Elements panel
https://bugs.webkit.org/show_bug.cgi?id=78202

Reviewed by Yury Semikhatsky.

* inspector/console/console-dirxml-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (108992 => 108993)


--- trunk/LayoutTests/ChangeLog	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/LayoutTests/ChangeLog	2012-02-27 15:22:31 UTC (rev 108993)
@@ -1,5 +1,14 @@
 2012-02-27  Pavel Feldman  <pfeld...@google.com>
 
+        [Shadow]: Expose one ShadowRoot in the Elements panel
+        https://bugs.webkit.org/show_bug.cgi?id=78202
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/console/console-dirxml-expected.txt:
+
+2012-02-27  Pavel Feldman  <pfeld...@google.com>
+
         Web Inspector: drop protocol-level tests
         https://bugs.webkit.org/show_bug.cgi?id=79671
 

Modified: trunk/LayoutTests/inspector/console/console-dirxml-expected.txt (108992 => 108993)


--- trunk/LayoutTests/inspector/console/console-dirxml-expected.txt	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/LayoutTests/inspector/console/console-dirxml-expected.txt	2012-02-27 15:22:31 UTC (rev 108993)
@@ -5,7 +5,7 @@
 Tests that console logging dumps proper messages.
 
 console-dirxml.html:12#document
-console-dirxml.html:13Document Fragment
+console-dirxml.html:13#document-fragment
 console-dirxml.html:14<p></p>
 console-dirxml.html:15[<p></p>]
 

Modified: trunk/Source/WebCore/ChangeLog (108992 => 108993)


--- trunk/Source/WebCore/ChangeLog	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/ChangeLog	2012-02-27 15:22:31 UTC (rev 108993)
@@ -1,3 +1,63 @@
+2012-02-27  Pavel Feldman  <pfeld...@google.com>
+
+        [Shadow]: Expose one ShadowRoot in the Elements panel (under experiment flag)
+        https://bugs.webkit.org/show_bug.cgi?id=78202
+
+        Reviewed by Yury Semikhatsky.
+
+        * dom/ShadowTree.cpp:
+        (WebCore::ShadowTree::pushShadowRoot):
+        (WebCore::ShadowTree::popShadowRoot):
+        * inspector/Inspector.json:
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::unbind):
+        (WebCore::InspectorDOMAgent::assertEditableNode):
+        (WebCore::InspectorDOMAgent::assertEditableElement):
+        (WebCore::InspectorDOMAgent::pushChildNodesToFrontend):
+        (WebCore::InspectorDOMAgent::setAttributeValue):
+        (WebCore::InspectorDOMAgent::setAttributesAsText):
+        (WebCore::InspectorDOMAgent::removeAttribute):
+        (WebCore::InspectorDOMAgent::removeNode):
+        (WebCore::InspectorDOMAgent::setOuterHTML):
+        (WebCore::InspectorDOMAgent::setNodeValue):
+        (WebCore::InspectorDOMAgent::moveTo):
+        (WebCore::InspectorDOMAgent::buildObjectForNode):
+        (WebCore::InspectorDOMAgent::didPushShadowRoot):
+        (WebCore):
+        (WebCore::InspectorDOMAgent::willPopShadowRoot):
+        * inspector/InspectorDOMAgent.h:
+        (WebCore):
+        (InspectorDOMAgent):
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didPushShadowRootImpl):
+        (WebCore):
+        (WebCore::InspectorInstrumentation::willPopShadowRootImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore):
+        (InspectorInstrumentation):
+        (WebCore::InspectorInstrumentation::didPushShadowRoot):
+        (WebCore::InspectorInstrumentation::willPopShadowRoot):
+        * inspector/PageConsoleAgent.cpp:
+        (WebCore::PageConsoleAgent::addInspectedNode):
+        * inspector/front-end/DOMAgent.js:
+        (WebInspector.DOMNode):
+        (WebInspector.DOMNode.prototype.hasChildNodes):
+        (WebInspector.DOMNode.prototype.isInShadowTree):
+        (WebInspector.DOMNode.prototype._insertChild):
+        (WebInspector.DOMNode.prototype._setChildrenPayload):
+        (WebInspector.DOMDocument):
+        (WebInspector.DOMAgent.prototype._setDetachedRoot):
+        (WebInspector.DOMAgent.prototype._shadowRootPopped):
+        (WebInspector.DOMDispatcher.prototype.childNodeRemoved):
+        (WebInspector.DOMDispatcher.prototype.shadowRootPushed):
+        (WebInspector.DOMDispatcher.prototype.shadowRootPopped):
+        * inspector/front-end/ElementsTreeOutline.js:
+        * inspector/front-end/MemoryStatistics.js:
+        * inspector/front-end/Settings.js:
+        (WebInspector.ExperimentsSettings):
+        * inspector/front-end/inspector.css:
+        (.webkit-html-tag.shadow, .webkit-html-fragment.shadow):
+
 2012-02-27  Andrey Kosyakov  <ca...@chromium.org>
 
         Web Inspector: [refactoring] remove dependencies from TimelinePanel from most of FormattedRecord

Modified: trunk/Source/WebCore/dom/ShadowTree.cpp (108992 => 108993)


--- trunk/Source/WebCore/dom/ShadowTree.cpp	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/dom/ShadowTree.cpp	2012-02-27 15:22:31 UTC (rev 108993)
@@ -30,6 +30,7 @@
 #include "Document.h"
 #include "Element.h"
 #include "HTMLContentSelector.h"
+#include "InspectorInstrumentation.h"
 #include "RuntimeEnabledFeatures.h"
 #include "ShadowRoot.h"
 #include "Text.h"
@@ -56,6 +57,7 @@
 #endif
 
     m_shadowRoots.push(shadowRoot);
+    InspectorInstrumentation::didPushShadowRoot(host(), shadowRoot);
 }
 
 ShadowRoot* ShadowTree::popShadowRoot()
@@ -63,6 +65,7 @@
     if (!hasShadowRoot())
         return 0;
 
+    InspectorInstrumentation::willPopShadowRoot(host(), m_shadowRoots.head());
     return m_shadowRoots.removeHead();
 }
 

Modified: trunk/Source/WebCore/inspector/Inspector.json (108992 => 108993)


--- trunk/Source/WebCore/inspector/Inspector.json	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/Inspector.json	2012-02-27 15:22:31 UTC (rev 108993)
@@ -1298,7 +1298,8 @@
                     { "name": "xmlVersion", "type": "string", "optional": true, "description": "<code>Document</code>'s XML version in case of XML documents." },
                     { "name": "name", "type": "string", "optional": true, "description": "<code>Attr</code>'s name." },
                     { "name": "value", "type": "string", "optional": true, "description": "<code>Attr</code>'s value." },
-                    { "name": "contentDocument", "$ref": "Node", "optional": true, "description": "Content document for frame owner elements." }
+                    { "name": "contentDocument", "$ref": "Node", "optional": true, "description": "Content document for frame owner elements." },
+                    { "name": "shadowRoots", "type": "array", "optional": true, "items": { "$ref": "Node" }, "description": "Shadow root list for given element host." }
                 ],
                 "description": "DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type."
             },
@@ -1682,6 +1683,24 @@
                     { "name": "nodeId", "$ref": "NodeId", "description": "Id of the node that has been removed." }
                 ],
                 "description": "Mirrors <code>DOMNodeRemoved</code> event."
+            },
+            {
+                "name": "shadowRootPushed",
+                "parameters": [
+                    { "name": "hostId", "$ref": "NodeId", "description": "Host element id." },
+                    { "name": "root", "$ref": "Node", "description": "Shadow root." }
+                ],
+                "description": "Called when shadow root is pushed into the element.",
+                "hidden": true
+            },
+            {
+                "name": "shadowRootPopped",
+                "parameters": [
+                    { "name": "hostId", "$ref": "NodeId", "description": "Host element id." },
+                    { "name": "rootId", "$ref": "NodeId", "description": "Shadow root id." }
+                ],
+                "description": "Called when shadow root is popped from the element.",
+                "hidden": true
             }
         ]
     },

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (108992 => 108993)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2012-02-27 15:22:31 UTC (rev 108993)
@@ -81,6 +81,8 @@
 #include "RenderStyleConstants.h"
 #include "ScriptEventListener.h"
 #include "Settings.h"
+#include "ShadowRoot.h"
+#include "ShadowTree.h"
 #include "StylePropertySet.h"
 #include "StyleSheetList.h"
 #include "Text.h"
@@ -335,6 +337,11 @@
         unbind(frameOwner->contentDocument(), nodesMap);
     }
 
+    if (node->isElementNode() && toElement(node)->hasShadowRoot()) {
+        for (ShadowRoot* root = toElement(node)->shadowTree()->youngestShadowRoot(); root; root = root->olderShadowRoot())
+            unbind(root, nodesMap);
+    }
+
     nodesMap->remove(node);
     bool childrenRequested = m_childrenRequested.contains(id);
     if (childrenRequested) {
@@ -371,18 +378,31 @@
     return toElement(node);
 }
 
+Node* InspectorDOMAgent::assertEditableNode(ErrorString* errorString, int nodeId)
+{
+    Node* node = assertNode(errorString, nodeId);
+    if (!node)
+        return 0;
 
-HTMLElement* InspectorDOMAgent::assertHTMLElement(ErrorString* errorString, int nodeId)
+    if (node->isInShadowTree()) {
+        *errorString = "Can not edit nodes from shadow trees";
+        return 0;
+    }
+
+    return node;
+}
+
+Element* InspectorDOMAgent::assertEditableElement(ErrorString* errorString, int nodeId)
 {
     Element* element = assertElement(errorString, nodeId);
     if (!element)
         return 0;
 
-    if (!element->isHTMLElement()) {
-        *errorString = "Node is not an HTML Element";
+    if (element->isInShadowTree()) {
+        *errorString = "Can not edit elements from shadow trees";
         return 0;
     }
-    return toHTMLElement(element);
+    return element;
 }
 
 void InspectorDOMAgent::getDocument(ErrorString*, RefPtr<InspectorObject>& root)
@@ -403,7 +423,7 @@
 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId)
 {
     Node* node = nodeForId(nodeId);
-    if (!node || (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE && node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) || node->isShadowRoot())
+    if (!node || (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE && node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE))
         return;
     if (m_childrenRequested.contains(nodeId))
         return;
@@ -534,7 +554,7 @@
 
 void InspectorDOMAgent::setAttributeValue(ErrorString* errorString, int elementId, const String& name, const String& value)
 {
-    Element* element = assertElement(errorString, elementId);
+    Element* element = assertEditableElement(errorString, elementId);
     if (!element)
         return;
 
@@ -543,7 +563,7 @@
 
 void InspectorDOMAgent::setAttributesAsText(ErrorString* errorString, int elementId, const String& text, const String* const name)
 {
-    Element* element = assertElement(errorString, elementId);
+    Element* element = assertEditableElement(errorString, elementId);
     if (!element)
         return;
 
@@ -588,7 +608,7 @@
 
 void InspectorDOMAgent::removeAttribute(ErrorString* errorString, int elementId, const String& name)
 {
-    Element* element = assertElement(errorString, elementId);
+    Element* element = assertEditableElement(errorString, elementId);
     if (!element)
         return;
 
@@ -597,7 +617,7 @@
 
 void InspectorDOMAgent::removeNode(ErrorString* errorString, int nodeId)
 {
-    Node* node = assertNode(errorString, nodeId);
+    Node* node = assertEditableNode(errorString, nodeId);
     if (!node)
         return;
 
@@ -662,7 +682,7 @@
         return;
     }
 
-    Node* node = assertNode(errorString, nodeId);
+    Node* node = assertEditableNode(errorString, nodeId);
     if (!node)
         return;
 
@@ -690,7 +710,7 @@
 
 void InspectorDOMAgent::setNodeValue(ErrorString* errorString, int nodeId, const String& value)
 {
-    Node* node = assertNode(errorString, nodeId);
+    Node* node = assertEditableNode(errorString, nodeId);
     if (!node)
         return;
 
@@ -1038,17 +1058,17 @@
 
 void InspectorDOMAgent::moveTo(ErrorString* errorString, int nodeId, int targetElementId, const int* const anchorNodeId, int* newNodeId)
 {
-    Node* node = assertNode(errorString, nodeId);
+    Node* node = assertEditableNode(errorString, nodeId);
     if (!node)
         return;
 
-    Element* targetElement = assertElement(errorString, targetElementId);
+    Element* targetElement = assertEditableElement(errorString, targetElementId);
     if (!targetElement)
         return;
 
     Node* anchorNode = 0;
     if (anchorNodeId && *anchorNodeId) {
-        anchorNode = assertNode(errorString, *anchorNodeId);
+        anchorNode = assertEditableNode(errorString, *anchorNodeId);
         if (!anchorNode)
             return;
         if (anchorNode->parentNode() != targetElement) {
@@ -1159,9 +1179,6 @@
         localName = node->localName();
         break;
     case Node::DOCUMENT_FRAGMENT_NODE:
-        if (!node->isShadowRoot())
-            break;
-        // Fall through
     case Node::DOCUMENT_NODE:
     case Node::ELEMENT_NODE:
     default:
@@ -1194,6 +1211,12 @@
             if (doc)
                 value->setContentDocument(buildObjectForNode(doc, 0, nodesMap));
         }
+        if (element->hasShadowRoot()) {
+            RefPtr<InspectorArray> shadowRoots = InspectorArray::create();
+            for (ShadowRoot* root = element->shadowTree()->youngestShadowRoot(); root; root = root->olderShadowRoot())
+                shadowRoots->pushObject(buildObjectForNode(root, 0, nodesMap));
+            value->setShadowRoots(shadowRoots);
+        }
     } else if (node->isDocumentNode()) {
         Document* document = static_cast<Document*>(node);
         value->setDocumentURL(documentURLString(document));
@@ -1475,6 +1498,21 @@
     m_revalidateStyleAttrTask->scheduleFor(static_cast<Element*>(node));
 }
 
+void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root)
+{
+    int hostId = m_documentNodeToIdMap.get(host);
+    if (hostId)
+        m_frontend->shadowRootPushed(hostId, buildObjectForNode(root, 0, &m_documentNodeToIdMap));
+}
+
+void InspectorDOMAgent::willPopShadowRoot(Element* host, ShadowRoot* root)
+{
+    int hostId = m_documentNodeToIdMap.get(host);
+    int rootId = m_documentNodeToIdMap.get(root);
+    if (hostId && rootId)
+        m_frontend->shadowRootPopped(hostId, rootId);
+}
+
 Node* InspectorDOMAgent::nodeForPath(const String& path)
 {
     // The path is of form "1,HTML,2,BODY,1,DIV"

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.h (108992 => 108993)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.h	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.h	2012-02-27 15:22:31 UTC (rev 108993)
@@ -69,6 +69,7 @@
 class Node;
 class RevalidateStyleAttributeTask;
 class ScriptValue;
+class ShadowRoot;
 
 struct Highlight;
 struct HighlightData;
@@ -167,6 +168,8 @@
     void styleAttributeInvalidated(const Vector<Element*>& elements);
     void characterDataModified(CharacterData*);
     void didInvalidateStyleAttr(Node*);
+    void didPushShadowRoot(Element* host, ShadowRoot*);
+    void willPopShadowRoot(Element* host, ShadowRoot*);
 
     Node* nodeForId(int nodeId);
     int boundNodeId(Node*);
@@ -207,8 +210,10 @@
     typedef HashMap<RefPtr<Node>, int> NodeToIdMap;
     int bind(Node*, NodeToIdMap*);
     void unbind(Node*, NodeToIdMap*);
+
     Element* assertElement(ErrorString*, int nodeId);
-    HTMLElement* assertHTMLElement(ErrorString*, int nodeId);
+    Node* assertEditableNode(ErrorString*, int nodeId);
+    Element* assertEditableElement(ErrorString*, int nodeId);
 
     int pushNodePathToFrontend(Node*);
     void pushChildNodesToFrontend(int nodeId);

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (108992 => 108993)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2012-02-27 15:22:31 UTC (rev 108993)
@@ -201,6 +201,18 @@
         cssAgent->mediaQueryResultChanged();
 }
 
+void InspectorInstrumentation::didPushShadowRootImpl(InstrumentingAgents* instrumentingAgents, Element* host, ShadowRoot* root)
+{
+    if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
+        domAgent->didPushShadowRoot(host, root);
+}
+
+void InspectorInstrumentation::willPopShadowRootImpl(InstrumentingAgents* instrumentingAgents, Element* host, ShadowRoot* root)
+{
+    if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
+        domAgent->willPopShadowRoot(host, root);
+}
+
 void InspectorInstrumentation::mouseDidMoveOverElementImpl(InstrumentingAgents* instrumentingAgents, const HitTestResult& result, unsigned modifierFlags)
 {
     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (108992 => 108993)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2012-02-27 15:22:31 UTC (rev 108993)
@@ -64,6 +64,7 @@
 class ScriptCallStack;
 class ScriptExecutionContext;
 class ScriptProfile;
+class ShadowRoot;
 class StorageArea;
 class WorkerContext;
 class WorkerContextProxy;
@@ -93,6 +94,8 @@
     static void didInvalidateStyleAttr(Document*, Node*);
     static void frameWindowDiscarded(Frame*, DOMWindow*);
     static void mediaQueryResultChanged(Document*);
+    static void didPushShadowRoot(Element* host, ShadowRoot*);
+    static void willPopShadowRoot(Element* host, ShadowRoot*);
 
     static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags);
     static bool handleMousePress(Page*);
@@ -243,6 +246,8 @@
     static void didInvalidateStyleAttrImpl(InstrumentingAgents*, Node*);
     static void frameWindowDiscardedImpl(InstrumentingAgents*, DOMWindow*);
     static void mediaQueryResultChangedImpl(InstrumentingAgents*);
+    static void didPushShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
+    static void willPopShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
 
     static void mouseDidMoveOverElementImpl(InstrumentingAgents*, const HitTestResult&, unsigned modifierFlags);
     static bool handleMousePressImpl(InstrumentingAgents*);
@@ -478,6 +483,24 @@
 #endif
 }
 
+inline void InspectorInstrumentation::didPushShadowRoot(Element* host, ShadowRoot* root)
+{
+#if ENABLE(INSPECTOR)
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host->ownerDocument()))
+        didPushShadowRootImpl(instrumentingAgents, host, root);
+#endif
+}
+
+inline void InspectorInstrumentation::willPopShadowRoot(Element* host, ShadowRoot* root)
+{
+#if ENABLE(INSPECTOR)
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host->ownerDocument()))
+        willPopShadowRootImpl(instrumentingAgents, host, root);
+#endif
+}
+
 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page* page, const HitTestResult& result, unsigned modifierFlags)
 {
 #if ENABLE(INSPECTOR)

Modified: trunk/Source/WebCore/inspector/PageConsoleAgent.cpp (108992 => 108993)


--- trunk/Source/WebCore/inspector/PageConsoleAgent.cpp	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/PageConsoleAgent.cpp	2012-02-27 15:22:31 UTC (rev 108993)
@@ -77,7 +77,7 @@
 void PageConsoleAgent::addInspectedNode(ErrorString* errorString, int nodeId)
 {
     Node* node = m_inspectorDOMAgent->nodeForId(nodeId);
-    if (!node) {
+    if (!node || node->isInShadowTree()) {
         *errorString = "nodeId is not valid";
         return;
     }

Modified: trunk/Source/WebCore/inspector/front-end/DOMAgent.js (108992 => 108993)


--- trunk/Source/WebCore/inspector/front-end/DOMAgent.js	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/front-end/DOMAgent.js	2012-02-27 15:22:31 UTC (rev 108993)
@@ -33,11 +33,13 @@
  * @constructor
  * @param {WebInspector.DOMAgent} domAgent
  * @param {?WebInspector.DOMDocument} doc
+ * @param {boolean} isInShadowTree
  * @param {DOMAgent.Node} payload
  */
-WebInspector.DOMNode = function(domAgent, doc, payload) {
+WebInspector.DOMNode = function(domAgent, doc, isInShadowTree, payload) {
     this._domAgent = domAgent;
     this.ownerDocument = doc;
+    this._isInShadowTree = isInShadowTree;
 
     this.id = payload.nodeId;
     domAgent._idToDOMNode[this.id] = this;
@@ -46,6 +48,8 @@
     this._localName = payload.localName;
     this._nodeValue = payload.nodeValue;
 
+    this._shadowRoots = [];
+
     this._attributes = [];
     this._attributesMap = {};
     if (payload.attributes)
@@ -69,6 +73,14 @@
         this._renumber();
     }
 
+    if (payload.shadowRoots && WebInspector.experimentsSettings.showShadowDOM.isEnabled()) {
+        for (var i = 0; i < payload.shadowRoots.length; ++i) {
+            var root = payload.shadowRoots[i];
+            var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocument, true, root);
+            this._shadowRoots.push(node);
+        }
+    }
+
     if (this._nodeType === Node.ELEMENT_NODE) {
         // HTML and BODY from internal iframes should not overwrite top-level ones.
         if (this.ownerDocument && !this.ownerDocument.documentElement && this._nodeName === "HTML")
@@ -117,7 +129,7 @@
      */
     hasChildNodes: function()
     {
-        return this._childNodeCount > 0;
+        return this._childNodeCount > 0 || !!this._shadowRoots.length;
     },
 
     /**
@@ -137,6 +149,14 @@
     },
 
     /**
+     * @return {boolean}
+     */
+    isInShadowTree: function()
+    {
+        return this._isInShadowTree;
+    },
+
+    /**
      * @return {string}
      */
     nodeNameInCorrectCase: function()
@@ -400,11 +420,11 @@
      */
     _insertChild: function(prev, payload)
     {
-        var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocument, payload);
+        var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocument, this._isInShadowTree, payload);
         if (!prev) {
             if (!this.children) {
                 // First node
-                this.children = [ node ];
+                this.children = this._shadowRoots.concat([ node ]);
             } else
                 this.children.unshift(node);
         } else
@@ -432,10 +452,10 @@
         if (this._contentDocument)
             return;
 
-        this.children = [];
+        this.children = this._shadowRoots.slice();
         for (var i = 0; i < payloads.length; ++i) {
             var payload = payloads[i];
-            var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocument, payload);
+            var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocument, this._isInShadowTree, payload);
             this.children.push(node);
         }
         this._renumber();
@@ -642,7 +662,7 @@
  */
 WebInspector.DOMDocument = function(domAgent, payload)
 {
-    WebInspector.DOMNode.call(this, domAgent, this, payload);
+    WebInspector.DOMNode.call(this, domAgent, this, false, payload);
     this.documentURL = payload.documentURL || "";
     this.xmlVersion = payload.xmlVersion;
     this._listeners = {};
@@ -887,7 +907,7 @@
      */
     _setDetachedRoot: function(payload)
     {
-        new WebInspector.DOMNode(this, null, payload);
+        new WebInspector.DOMNode(this, null, false, payload);
     },
 
     /**
@@ -944,6 +964,13 @@
     },
 
     /**
+     * @param {DOMAgent.NodeId} rootId
+     */
+    _shadowRootPopped: function(rootId)
+    {
+    },
+
+    /**
      * @param {DOMAgent.Node} node
      */
     _unbind: function(node)
@@ -1253,6 +1280,24 @@
     childNodeRemoved: function(parentNodeId, nodeId)
     {
         this._domAgent._childNodeRemoved(parentNodeId, nodeId);
+    },
+
+    /**
+     * @param {DOMAgent.NodeId} hostId
+     * @param {DOMAgent.Node} root
+     */
+    shadowRootPushed: function(hostId, root)
+    {
+        this._domAgent._childNodeInserted(hostId, 0, root);
+    },
+
+    /**
+     * @param {DOMAgent.NodeId} hostId
+     * @param {DOMAgent.NodeId} rootId
+     */
+    shadowRootPopped: function(hostId, rootId)
+    {
+        this._domAgent._childNodeRemoved(hostId, rootId);
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js (108992 => 108993)


--- trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js	2012-02-27 15:22:31 UTC (rev 108993)
@@ -1505,6 +1505,8 @@
         var classes = [ "webkit-html-tag" ];
         if (isClosingTag && isDistinctTreeElement)
             classes.push("close");
+        if (node.isInShadowTree())
+            classes.push("shadow");
         var tagElement = parentElement.createChild("span", classes.join(" "));
         tagElement.appendChild(document.createTextNode("<"));
         var tagNameElement = tagElement.createChild("span", isClosingTag ? "" : "webkit-html-tag-name");
@@ -1527,10 +1529,6 @@
         var info = {titleDOM: document.createDocumentFragment(), hasChildren: this.hasChildren};
 
         switch (node.nodeType()) {
-            case Node.DOCUMENT_FRAGMENT_NODE:
-                info.titleDOM.appendChild(document.createTextNode("Document Fragment"));
-                break;
-
             case Node.ATTRIBUTE_NODE:
                 var value = node.value || "\u200B"; // Zero width space to force showing an empty value.
                 this._buildAttributeDOM(info.titleDOM, node.name, value);
@@ -1616,10 +1614,15 @@
                 var cdataElement = info.titleDOM.createChild("span", "webkit-html-text-node");
                 cdataElement.appendChild(document.createTextNode("<![CDATA[" + node.nodeValue() + "]]>"));
                 break;
+            case Node.DOCUMENT_FRAGMENT_NODE:
+                var fragmentElement = info.titleDOM.createChild("span", "webkit-html-fragment");
+                fragmentElement.textContent = node.nodeNameInCorrectCase().collapseWhitespace();
+                if (node.isInShadowTree())
+                    fragmentElement.addStyleClass("shadow");
+                break;
             default:
-                var defaultElement = info.titleDOM.appendChild(document.createTextNode(node.nodeNameInCorrectCase().collapseWhitespace()));
+                info.titleDOM.appendChild(document.createTextNode(node.nodeNameInCorrectCase().collapseWhitespace()));
         }
-
         return info;
     },
 

Modified: trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js (108992 => 108993)


--- trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js	2012-02-27 15:22:31 UTC (rev 108993)
@@ -80,7 +80,10 @@
     TimelineAgent.setIncludeMemoryDetails(true);
 }
 
-
+/**
+ * @constructor
+ * @extends {WebInspector.Object}
+ */
 WebInspector.SwatchCheckbox = function(title, color)
 {
     this.element = document.createElement("div");
@@ -120,7 +123,9 @@
 
 WebInspector.SwatchCheckbox.prototype.__proto__ = WebInspector.Object.prototype;
 
-
+/**
+ * @constructor
+ */
 WebInspector.CounterUI = function(memoryCountersPane, title, currentValueLabel, rgb, valueGetter)
 {
     this._memoryCountersPane = memoryCountersPane;

Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (108992 => 108993)


--- trunk/Source/WebCore/inspector/front-end/Settings.js	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js	2012-02-27 15:22:31 UTC (rev 108993)
@@ -180,6 +180,7 @@
     // FIXME: Enable http/tests/inspector/indexeddb/resources-panel.html when removed from experiments.
     this.showIndexedDB = this._createExperiment("showIndexedDB", "Show IndexedDB in Resources panel");
     this.debugCSS = this._createExperiment("debugCSS", "Load CSS via link tags for debugging");
+    this.showShadowDOM = this._createExperiment("showShadowDOM", "Show shadow DOM");
 
     this._cleanUpSetting();
 }

Modified: trunk/Source/WebCore/inspector/front-end/inspector.css (108992 => 108993)


--- trunk/Source/WebCore/inspector/front-end/inspector.css	2012-02-27 15:13:12 UTC (rev 108992)
+++ trunk/Source/WebCore/inspector/front-end/inspector.css	2012-02-27 15:22:31 UTC (rev 108993)
@@ -1075,6 +1075,10 @@
     margin-left: -12px;
 }
 
+.webkit-html-tag.shadow, .webkit-html-fragment.shadow {
+    opacity: 0.6;
+}
+
 .outline-disclosure li.parent::before {
     content: url(Images/treeRightTriangleBlack.png);
     float: left;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to