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

Side by Side Diff: Source/core/inspector/InspectorDOMAgent.cpp

Issue 208223002: DevTools: [Elements] Restore selected shadow DOM elements on reload (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 // If a PseudoElement is bound, its parent element must be bound, too. 1994 // If a PseudoElement is bound, its parent element must be bound, too.
1995 Element* parent = pseudoElement->parentOrShadowHostElement(); 1995 Element* parent = pseudoElement->parentOrShadowHostElement();
1996 ASSERT(parent); 1996 ASSERT(parent);
1997 int parentId = m_documentNodeToIdMap.get(parent); 1997 int parentId = m_documentNodeToIdMap.get(parent);
1998 ASSERT(parentId); 1998 ASSERT(parentId);
1999 1999
2000 unbind(pseudoElement, &m_documentNodeToIdMap); 2000 unbind(pseudoElement, &m_documentNodeToIdMap);
2001 m_frontend->pseudoElementRemoved(parentId, pseudoElementId); 2001 m_frontend->pseudoElementRemoved(parentId, pseudoElementId);
2002 } 2002 }
2003 2003
2004 static ShadowRoot* shadowRootForNode(Node* node, const String& type)
2005 {
2006 if (!node->isElementNode())
2007 return 0;
2008 if (type == "a")
2009 return toElement(node)->shadowRoot();
2010 if (type == "u")
2011 return toElement(node)->userAgentShadowRoot();
2012 return 0;
2013 }
2014
2004 Node* InspectorDOMAgent::nodeForPath(const String& path) 2015 Node* InspectorDOMAgent::nodeForPath(const String& path)
2005 { 2016 {
2006 // The path is of form "1,HTML,2,BODY,1,DIV" 2017 // The path is of form "1,HTML,2,BODY,1,DIV" (<index> and <nodeName> interle aved).
2018 // <index> may also be "a" (author shadow root) or "u" (user-agent shadow ro ot),
2019 // in which case <nodeName> MUST be "#document-fragment".
2007 if (!m_document) 2020 if (!m_document)
2008 return 0; 2021 return 0;
2009 2022
2010 Node* node = m_document.get(); 2023 Node* node = m_document.get();
2011 Vector<String> pathTokens; 2024 Vector<String> pathTokens;
2012 path.split(",", false, pathTokens); 2025 path.split(",", false, pathTokens);
2013 if (!pathTokens.size()) 2026 if (!pathTokens.size())
2014 return 0; 2027 return 0;
2015 for (size_t i = 0; i < pathTokens.size() - 1; i += 2) { 2028 for (size_t i = 0; i < pathTokens.size() - 1; i += 2) {
2016 bool success = true; 2029 bool success = true;
2017 unsigned childNumber = pathTokens[i].toUInt(&success); 2030 String& indexValue = pathTokens[i];
2018 if (!success) 2031 unsigned childNumber = indexValue.toUInt(&success);
2019 return 0; 2032 Node* child;
2020 if (childNumber >= innerChildNodeCount(node)) 2033 if (!success) {
2021 return 0; 2034 child = shadowRootForNode(node, indexValue);
2035 } else {
2036 if (childNumber >= innerChildNodeCount(node))
2037 return 0;
2022 2038
2023 Node* child = innerFirstChild(node); 2039 child = innerFirstChild(node);
2040 }
2024 String childName = pathTokens[i + 1]; 2041 String childName = pathTokens[i + 1];
2025 for (size_t j = 0; child && j < childNumber; ++j) 2042 for (size_t j = 0; child && j < childNumber; ++j)
2026 child = innerNextSibling(child); 2043 child = innerNextSibling(child);
2027 2044
2028 if (!child || child->nodeName() != childName) 2045 if (!child || child->nodeName() != childName)
2029 return 0; 2046 return 0;
2030 node = child; 2047 node = child;
2031 } 2048 }
2032 return node; 2049 return node;
2033 } 2050 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 if (!m_documentNodeToIdMap.contains(m_document)) { 2114 if (!m_documentNodeToIdMap.contains(m_document)) {
2098 RefPtr<TypeBuilder::DOM::Node> root; 2115 RefPtr<TypeBuilder::DOM::Node> root;
2099 getDocument(errorString, root); 2116 getDocument(errorString, root);
2100 return errorString->isEmpty(); 2117 return errorString->isEmpty();
2101 } 2118 }
2102 return true; 2119 return true;
2103 } 2120 }
2104 2121
2105 } // namespace WebCore 2122 } // namespace WebCore
2106 2123
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698