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

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

Issue 16561003: DevTools: Inspect element mode does not select element in ShadowDOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 static Node* hoveredNodeForPoint(Frame* frame, const IntPoint& point, bool ignor ePointerEventsNone) 150 static Node* hoveredNodeForPoint(Frame* frame, const IntPoint& point, bool ignor ePointerEventsNone)
151 { 151 {
152 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move | HitTestR equest::ReadOnly | HitTestRequest::AllowChildFrameContent; 152 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move | HitTestR equest::ReadOnly | HitTestRequest::AllowChildFrameContent;
153 if (ignorePointerEventsNone) 153 if (ignorePointerEventsNone)
154 hitType |= HitTestRequest::IgnorePointerEventsNone; 154 hitType |= HitTestRequest::IgnorePointerEventsNone;
155 HitTestRequest request(hitType); 155 HitTestRequest request(hitType);
156 HitTestResult result(frame->view()->windowToContents(point)); 156 HitTestResult result(frame->view()->windowToContents(point));
157 frame->contentRenderer()->hitTest(request, result); 157 frame->contentRenderer()->hitTest(request, result);
158 result.setToShadowHostIfInUserAgentShadowRoot();
159 Node* node = result.innerNode(); 158 Node* node = result.innerNode();
160 while (node && node->nodeType() == Node::TEXT_NODE) 159 while (node && node->nodeType() == Node::TEXT_NODE)
161 node = node->parentNode(); 160 node = node->parentNode();
162 return node; 161 return node;
163 } 162 }
164 163
165 static Node* hoveredNodeForEvent(Frame* frame, const PlatformMouseEvent& event, bool ignorePointerEventsNone) 164 static Node* hoveredNodeForEvent(Frame* frame, const PlatformMouseEvent& event, bool ignorePointerEventsNone)
166 { 165 {
167 return hoveredNodeForPoint(frame, event.position(), ignorePointerEventsNone) ; 166 return hoveredNodeForPoint(frame, event.position(), ignorePointerEventsNone) ;
168 } 167 }
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 break; 1366 break;
1368 } 1367 }
1369 1368
1370 RefPtr<TypeBuilder::DOM::Node> value = TypeBuilder::DOM::Node::create() 1369 RefPtr<TypeBuilder::DOM::Node> value = TypeBuilder::DOM::Node::create()
1371 .setNodeId(id) 1370 .setNodeId(id)
1372 .setNodeType(static_cast<int>(node->nodeType())) 1371 .setNodeType(static_cast<int>(node->nodeType()))
1373 .setNodeName(nodeName) 1372 .setNodeName(nodeName)
1374 .setLocalName(localName) 1373 .setLocalName(localName)
1375 .setNodeValue(nodeValue); 1374 .setNodeValue(nodeValue);
1376 1375
1377 if (node->isContainerNode()) { 1376 bool forcePushChildren = false;
1378 int nodeCount = innerChildNodeCount(node);
1379 value->setChildNodeCount(nodeCount);
1380 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArra yForContainerChildren(node, depth, nodesMap);
1381 if (children->length() > 0)
1382 value->setChildren(children.release());
1383 }
1384
1385 if (node->isElementNode()) { 1377 if (node->isElementNode()) {
1386 Element* element = toElement(node); 1378 Element* element = toElement(node);
1387 value->setAttributes(buildArrayForElementAttributes(element)); 1379 value->setAttributes(buildArrayForElementAttributes(element));
1388 if (node->isFrameOwnerElement()) { 1380 if (node->isFrameOwnerElement()) {
1389 HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElemen t*>(node); 1381 HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElemen t*>(node);
1390 Frame* frame = frameOwner->contentFrame(); 1382 Frame* frame = frameOwner->contentFrame();
1391 if (frame) 1383 if (frame)
1392 value->setFrameId(m_pageAgent->frameId(frame)); 1384 value->setFrameId(m_pageAgent->frameId(frame));
1393 Document* doc = frameOwner->contentDocument(); 1385 Document* doc = frameOwner->contentDocument();
1394 if (doc) 1386 if (doc)
1395 value->setContentDocument(buildObjectForNode(doc, 0, nodesMap)); 1387 value->setContentDocument(buildObjectForNode(doc, 0, nodesMap));
1396 } 1388 }
1397 1389
1398 ElementShadow* shadow = element->shadow(); 1390 ElementShadow* shadow = element->shadow();
1399 if (shadow) { 1391 if (shadow) {
1400 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > shadowRoots = Ty peBuilder::Array<TypeBuilder::DOM::Node>::create(); 1392 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > shadowRoots = Ty peBuilder::Array<TypeBuilder::DOM::Node>::create();
1401 for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = r oot->olderShadowRoot()) 1393 for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = r oot->olderShadowRoot())
1402 shadowRoots->addItem(buildObjectForNode(root, 0, nodesMap)); 1394 shadowRoots->addItem(buildObjectForNode(root, 0, nodesMap));
1403 value->setShadowRoots(shadowRoots); 1395 value->setShadowRoots(shadowRoots);
1396 forcePushChildren = true;
1404 } 1397 }
1405 1398
1406 if (element->hasTagName(templateTag)) 1399 if (element->hasTagName(templateTag)) {
1407 value->setTemplateContent(buildObjectForNode(static_cast<HTMLTemplat eElement*>(element)->content(), 0, nodesMap)); 1400 value->setTemplateContent(buildObjectForNode(static_cast<HTMLTemplat eElement*>(element)->content(), 0, nodesMap));
1401 forcePushChildren = true;
1402 }
1408 } else if (node->isDocumentNode()) { 1403 } else if (node->isDocumentNode()) {
1409 Document* document = toDocument(node); 1404 Document* document = toDocument(node);
1410 value->setDocumentURL(documentURLString(document)); 1405 value->setDocumentURL(documentURLString(document));
1411 value->setBaseURL(documentBaseURLString(document)); 1406 value->setBaseURL(documentBaseURLString(document));
1412 value->setXmlVersion(document->xmlVersion()); 1407 value->setXmlVersion(document->xmlVersion());
1413 } else if (node->nodeType() == Node::DOCUMENT_TYPE_NODE) { 1408 } else if (node->nodeType() == Node::DOCUMENT_TYPE_NODE) {
1414 DocumentType* docType = static_cast<DocumentType*>(node); 1409 DocumentType* docType = static_cast<DocumentType*>(node);
1415 value->setPublicId(docType->publicId()); 1410 value->setPublicId(docType->publicId());
1416 value->setSystemId(docType->systemId()); 1411 value->setSystemId(docType->systemId());
1417 value->setInternalSubset(docType->internalSubset()); 1412 value->setInternalSubset(docType->internalSubset());
1418 } else if (node->isAttributeNode()) { 1413 } else if (node->isAttributeNode()) {
1419 Attr* attribute = static_cast<Attr*>(node); 1414 Attr* attribute = static_cast<Attr*>(node);
1420 value->setName(attribute->name()); 1415 value->setName(attribute->name());
1421 value->setValue(attribute->value()); 1416 value->setValue(attribute->value());
1422 } 1417 }
1418
1419 if (node->isContainerNode()) {
1420 int nodeCount = innerChildNodeCount(node);
1421 value->setChildNodeCount(nodeCount);
1422 if (forcePushChildren && !depth)
1423 depth = 1;
1424 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArra yForContainerChildren(node, depth, nodesMap);
1425 if (children->length() > 0 || forcePushChildren) // Push children along with shadow in any case.
vsevik 2013/06/07 08:41:00 || depth
pfeldman 2013/06/07 08:53:49 Done.
1426 value->setChildren(children.release());
1427 }
1428
1423 return value.release(); 1429 return value.release();
1424 } 1430 }
1425 1431
1426 PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA ttributes(Element* element) 1432 PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA ttributes(Element* element)
1427 { 1433 {
1428 RefPtr<TypeBuilder::Array<String> > attributesValue = TypeBuilder::Array<Str ing>::create(); 1434 RefPtr<TypeBuilder::Array<String> > attributesValue = TypeBuilder::Array<Str ing>::create();
1429 // Go through all attributes and serialize them. 1435 // Go through all attributes and serialize them.
1430 if (!element->hasAttributes()) 1436 if (!element->hasAttributes())
1431 return attributesValue.release(); 1437 return attributesValue.release();
1432 unsigned numAttrs = element->attributeCount(); 1438 unsigned numAttrs = element->attributeCount();
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 1829
1824 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m ainWorldScriptState(frame)); 1830 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m ainWorldScriptState(frame));
1825 if (injectedScript.hasNoValue()) 1831 if (injectedScript.hasNoValue())
1826 return 0; 1832 return 0;
1827 1833
1828 return injectedScript.wrapNode(node, objectGroup); 1834 return injectedScript.wrapNode(node, objectGroup);
1829 } 1835 }
1830 1836
1831 } // namespace WebCore 1837 } // namespace WebCore
1832 1838
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698