OLD | NEW |
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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 if (!node) | 451 if (!node) |
452 return nullptr; | 452 return nullptr; |
453 | 453 |
454 if (!node->isElementNode()) { | 454 if (!node->isElementNode()) { |
455 *errorString = "Node is not an Element"; | 455 *errorString = "Node is not an Element"; |
456 return nullptr; | 456 return nullptr; |
457 } | 457 } |
458 return toElement(node); | 458 return toElement(node); |
459 } | 459 } |
460 | 460 |
461 static ShadowRoot* userAgentShadowRoot(Node* node) | 461 static ShadowRoot* closedShadowRoot(Node* node) |
462 { | 462 { |
463 if (!node || !node->isInShadowTree()) | 463 if (!node || !node->isInShadowTree()) |
464 return nullptr; | 464 return nullptr; |
465 | 465 |
466 Node* candidate = node; | 466 Node* candidate = node; |
467 while (candidate && !candidate->isShadowRoot()) | 467 while (candidate && !candidate->isShadowRoot()) |
468 candidate = candidate->parentOrShadowHostNode(); | 468 candidate = candidate->parentOrShadowHostNode(); |
469 ASSERT(candidate); | 469 ASSERT(candidate); |
470 ShadowRoot* shadowRoot = toShadowRoot(candidate); | 470 ShadowRoot* shadowRoot = toShadowRoot(candidate); |
471 | 471 |
472 return shadowRoot->type() == ShadowRoot::UserAgentShadowRoot ? shadowRoot :
nullptr; | 472 return shadowRoot->type() == ShadowRoot::ClosedShadowRoot ? shadowRoot : nul
lptr; |
473 } | 473 } |
474 | 474 |
475 Node* InspectorDOMAgent::assertEditableNode(ErrorString* errorString, int nodeId
) | 475 Node* InspectorDOMAgent::assertEditableNode(ErrorString* errorString, int nodeId
) |
476 { | 476 { |
477 Node* node = assertNode(errorString, nodeId); | 477 Node* node = assertNode(errorString, nodeId); |
478 if (!node) | 478 if (!node) |
479 return nullptr; | 479 return nullptr; |
480 | 480 |
481 if (node->isInShadowTree()) { | 481 if (node->isInShadowTree()) { |
482 if (node->isShadowRoot()) { | 482 if (node->isShadowRoot()) { |
483 *errorString = "Cannot edit shadow roots"; | 483 *errorString = "Cannot edit shadow roots"; |
484 return nullptr; | 484 return nullptr; |
485 } | 485 } |
486 if (userAgentShadowRoot(node)) { | 486 if (closedShadowRoot(node)) { |
487 *errorString = "Cannot edit nodes from user-agent shadow trees"; | 487 *errorString = "Cannot edit nodes from user-agent shadow trees"; |
488 return nullptr; | 488 return nullptr; |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 if (node->isPseudoElement()) { | 492 if (node->isPseudoElement()) { |
493 *errorString = "Cannot edit pseudo elements"; | 493 *errorString = "Cannot edit pseudo elements"; |
494 return nullptr; | 494 return nullptr; |
495 } | 495 } |
496 | 496 |
(...skipping 11 matching lines...) Expand all Loading... |
508 } | 508 } |
509 return node; | 509 return node; |
510 } | 510 } |
511 | 511 |
512 Element* InspectorDOMAgent::assertEditableElement(ErrorString* errorString, int
nodeId) | 512 Element* InspectorDOMAgent::assertEditableElement(ErrorString* errorString, int
nodeId) |
513 { | 513 { |
514 Element* element = assertElement(errorString, nodeId); | 514 Element* element = assertElement(errorString, nodeId); |
515 if (!element) | 515 if (!element) |
516 return nullptr; | 516 return nullptr; |
517 | 517 |
518 if (element->isInShadowTree() && userAgentShadowRoot(element)) { | 518 if (element->isInShadowTree() && closedShadowRoot(element)) { |
519 *errorString = "Cannot edit elements from user-agent shadow trees"; | 519 *errorString = "Cannot edit elements from user-agent shadow trees"; |
520 return nullptr; | 520 return nullptr; |
521 } | 521 } |
522 | 522 |
523 if (element->isPseudoElement()) { | 523 if (element->isPseudoElement()) { |
524 *errorString = "Cannot edit pseudo elements"; | 524 *errorString = "Cannot edit pseudo elements"; |
525 return nullptr; | 525 return nullptr; |
526 } | 526 } |
527 | 527 |
528 return element; | 528 return element; |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 | 1050 |
1051 static Node* nextNodeWithShadowDOMInMind(const Node& current, const Node* stayWi
thin, bool includeUserAgentShadowDOM) | 1051 static Node* nextNodeWithShadowDOMInMind(const Node& current, const Node* stayWi
thin, bool includeUserAgentShadowDOM) |
1052 { | 1052 { |
1053 // At first traverse the subtree. | 1053 // At first traverse the subtree. |
1054 if (current.isElementNode()) { | 1054 if (current.isElementNode()) { |
1055 const Element& element = toElement(current); | 1055 const Element& element = toElement(current); |
1056 ElementShadow* elementShadow = element.shadow(); | 1056 ElementShadow* elementShadow = element.shadow(); |
1057 if (elementShadow) { | 1057 if (elementShadow) { |
1058 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); | 1058 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); |
1059 if (shadowRoot) { | 1059 if (shadowRoot) { |
1060 if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot || includ
eUserAgentShadowDOM) | 1060 if (shadowRoot->type() == ShadowRoot::OpenShadowRoot || includeU
serAgentShadowDOM) |
1061 return shadowRoot; | 1061 return shadowRoot; |
1062 } | 1062 } |
1063 } | 1063 } |
1064 } | 1064 } |
1065 if (current.hasChildren()) | 1065 if (current.hasChildren()) |
1066 return current.firstChild(); | 1066 return current.firstChild(); |
1067 | 1067 |
1068 // Then traverse siblings of the node itself and its ancestors. | 1068 // Then traverse siblings of the node itself and its ancestors. |
1069 const Node* node = ¤t; | 1069 const Node* node = ¤t; |
1070 do { | 1070 do { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 | 1288 |
1289 bool InspectorDOMAgent::handleMouseMove(LocalFrame* frame, const PlatformMouseEv
ent& event) | 1289 bool InspectorDOMAgent::handleMouseMove(LocalFrame* frame, const PlatformMouseEv
ent& event) |
1290 { | 1290 { |
1291 if (m_searchingForNode == NotSearching) | 1291 if (m_searchingForNode == NotSearching) |
1292 return false; | 1292 return false; |
1293 | 1293 |
1294 if (!frame->view() || !frame->contentRenderer()) | 1294 if (!frame->view() || !frame->contentRenderer()) |
1295 return true; | 1295 return true; |
1296 Node* node = hoveredNodeForEvent(frame, event, event.shiftKey()); | 1296 Node* node = hoveredNodeForEvent(frame, event, event.shiftKey()); |
1297 | 1297 |
1298 // Do not highlight within UA shadow root unless requested. | 1298 // Do not highlight within closed shadow root unless requested. |
1299 if (m_searchingForNode != SearchingForUAShadow) { | 1299 if (m_searchingForNode != SearchingForUAShadow) { |
1300 ShadowRoot* uaShadowRoot = userAgentShadowRoot(node); | 1300 ShadowRoot* shadowRoot = closedShadowRoot(node); |
1301 if (uaShadowRoot) | 1301 if (shadowRoot) |
1302 node = uaShadowRoot->host(); | 1302 node = shadowRoot->host(); |
1303 } | 1303 } |
1304 | 1304 |
1305 // Shadow roots don't have boxes - use host element instead. | 1305 // Shadow roots don't have boxes - use host element instead. |
1306 if (node && node->isShadowRoot()) | 1306 if (node && node->isShadowRoot()) |
1307 node = node->parentOrShadowHostNode(); | 1307 node = node->parentOrShadowHostNode(); |
1308 | 1308 |
1309 if (!node) | 1309 if (!node) |
1310 return true; | 1310 return true; |
1311 | 1311 |
1312 Node* eventTarget = event.shiftKey() ? hoveredNodeForEvent(frame, event, fal
se) : nullptr; | 1312 Node* eventTarget = event.shiftKey() ? hoveredNodeForEvent(frame, event, fal
se) : nullptr; |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 } | 1628 } |
1629 | 1629 |
1630 static String documentBaseURLString(Document* document) | 1630 static String documentBaseURLString(Document* document) |
1631 { | 1631 { |
1632 return document->completeURL("").string(); | 1632 return document->completeURL("").string(); |
1633 } | 1633 } |
1634 | 1634 |
1635 static TypeBuilder::DOM::ShadowRootType::Enum shadowRootType(ShadowRoot* shadowR
oot) | 1635 static TypeBuilder::DOM::ShadowRootType::Enum shadowRootType(ShadowRoot* shadowR
oot) |
1636 { | 1636 { |
1637 switch (shadowRoot->type()) { | 1637 switch (shadowRoot->type()) { |
1638 case ShadowRoot::UserAgentShadowRoot: | 1638 case ShadowRoot::ClosedShadowRoot: |
1639 return TypeBuilder::DOM::ShadowRootType::User_agent; | 1639 return TypeBuilder::DOM::ShadowRootType::User_agent; |
1640 case ShadowRoot::AuthorShadowRoot: | 1640 case ShadowRoot::OpenShadowRoot: |
1641 return TypeBuilder::DOM::ShadowRootType::Author; | 1641 return TypeBuilder::DOM::ShadowRootType::Author; |
1642 } | 1642 } |
1643 ASSERT_NOT_REACHED(); | 1643 ASSERT_NOT_REACHED(); |
1644 return TypeBuilder::DOM::ShadowRootType::User_agent; | 1644 return TypeBuilder::DOM::ShadowRootType::User_agent; |
1645 } | 1645 } |
1646 | 1646 |
1647 PassRefPtr<TypeBuilder::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node* n
ode, int depth, NodeToIdMap* nodesMap) | 1647 PassRefPtr<TypeBuilder::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node* n
ode, int depth, NodeToIdMap* nodesMap) |
1648 { | 1648 { |
1649 int id = bind(node, nodesMap); | 1649 int id = bind(node, nodesMap); |
1650 String localName; | 1650 String localName; |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 m_frontend->pseudoElementRemoved(parentId, pseudoElementId); | 2166 m_frontend->pseudoElementRemoved(parentId, pseudoElementId); |
2167 } | 2167 } |
2168 | 2168 |
2169 static ShadowRoot* shadowRootForNode(Node* node, const String& type) | 2169 static ShadowRoot* shadowRootForNode(Node* node, const String& type) |
2170 { | 2170 { |
2171 if (!node->isElementNode()) | 2171 if (!node->isElementNode()) |
2172 return nullptr; | 2172 return nullptr; |
2173 if (type == "a") | 2173 if (type == "a") |
2174 return toElement(node)->shadowRoot(); | 2174 return toElement(node)->shadowRoot(); |
2175 if (type == "u") | 2175 if (type == "u") |
2176 return toElement(node)->userAgentShadowRoot(); | 2176 return toElement(node)->closedShadowRoot(); |
2177 return nullptr; | 2177 return nullptr; |
2178 } | 2178 } |
2179 | 2179 |
2180 Node* InspectorDOMAgent::nodeForPath(const String& path) | 2180 Node* InspectorDOMAgent::nodeForPath(const String& path) |
2181 { | 2181 { |
2182 // The path is of form "1,HTML,2,BODY,1,DIV" (<index> and <nodeName> interle
aved). | 2182 // The path is of form "1,HTML,2,BODY,1,DIV" (<index> and <nodeName> interle
aved). |
2183 // <index> may also be "a" (author shadow root) or "u" (user-agent shadow ro
ot), | 2183 // <index> may also be "a" (author shadow root) or "u" (user-agent shadow ro
ot), |
2184 // in which case <nodeName> MUST be "#document-fragment". | 2184 // in which case <nodeName> MUST be "#document-fragment". |
2185 if (!m_document) | 2185 if (!m_document) |
2186 return nullptr; | 2186 return nullptr; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 visitor->trace(m_revalidateTask); | 2304 visitor->trace(m_revalidateTask); |
2305 visitor->trace(m_searchResults); | 2305 visitor->trace(m_searchResults); |
2306 #endif | 2306 #endif |
2307 visitor->trace(m_history); | 2307 visitor->trace(m_history); |
2308 visitor->trace(m_domEditor); | 2308 visitor->trace(m_domEditor); |
2309 visitor->trace(m_listener); | 2309 visitor->trace(m_listener); |
2310 InspectorBaseAgent::trace(visitor); | 2310 InspectorBaseAgent::trace(visitor); |
2311 } | 2311 } |
2312 | 2312 |
2313 } // namespace blink | 2313 } // namespace blink |
OLD | NEW |