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

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

Issue 308963002: Minimize calls to Node::nodeType() as it is virtual (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo Created 6 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 409 }
410 return toDocument(node); 410 return toDocument(node);
411 } 411 }
412 412
413 Element* InspectorDOMAgent::assertElement(ErrorString* errorString, int nodeId) 413 Element* InspectorDOMAgent::assertElement(ErrorString* errorString, int nodeId)
414 { 414 {
415 Node* node = assertNode(errorString, nodeId); 415 Node* node = assertNode(errorString, nodeId);
416 if (!node) 416 if (!node)
417 return 0; 417 return 0;
418 418
419 if (node->nodeType() != Node::ELEMENT_NODE) { 419 if (!node->isElementNode()) {
420 *errorString = "Node is not an Element"; 420 *errorString = "Node is not an Element";
421 return 0; 421 return 0;
422 } 422 }
423 return toElement(node); 423 return toElement(node);
424 } 424 }
425 425
426 static ShadowRoot* userAgentShadowRoot(Node* node) 426 static ShadowRoot* userAgentShadowRoot(Node* node)
427 { 427 {
428 if (!node || !node->isInShadowTree()) 428 if (!node || !node->isInShadowTree())
429 return 0; 429 return 0;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 512 }
513 513
514 discardFrontendBindings(); 514 discardFrontendBindings();
515 515
516 root = buildObjectForNode(m_document.get(), 2, &m_documentNodeToIdMap); 516 root = buildObjectForNode(m_document.get(), 2, &m_documentNodeToIdMap);
517 } 517 }
518 518
519 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth) 519 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth)
520 { 520 {
521 Node* node = nodeForId(nodeId); 521 Node* node = nodeForId(nodeId);
522 if (!node || (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE && node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE)) 522 if (!node || (!node->isElementNode() && !node->isDocumentNode() && !node->is DocumentFragment()))
523 return; 523 return;
524 524
525 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); 525 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId);
526 526
527 if (m_childrenRequested.contains(nodeId)) { 527 if (m_childrenRequested.contains(nodeId)) {
528 if (depth <= 1) 528 if (depth <= 1)
529 return; 529 return;
530 530
531 depth--; 531 depth--;
532 532
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 } 1102 }
1103 return false; 1103 return false;
1104 } 1104 }
1105 1105
1106 void InspectorDOMAgent::inspect(Node* inspectedNode) 1106 void InspectorDOMAgent::inspect(Node* inspectedNode)
1107 { 1107 {
1108 if (!m_frontend || !inspectedNode) 1108 if (!m_frontend || !inspectedNode)
1109 return; 1109 return;
1110 1110
1111 Node* node = inspectedNode; 1111 Node* node = inspectedNode;
1112 while (node && node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE && node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) 1112 while (node && !node->isElementNode() && !node->isDocumentNode() && !node->i sDocumentFragment())
1113 node = node->parentOrShadowHostNode(); 1113 node = node->parentOrShadowHostNode();
1114 1114
1115 if (!node) 1115 if (!node)
1116 return; 1116 return;
1117 1117
1118 int nodeId = pushNodePathToFrontend(node); 1118 int nodeId = pushNodePathToFrontend(node);
1119 if (nodeId) 1119 if (nodeId)
1120 m_frontend->inspectNodeRequested(nodeId); 1120 m_frontend->inspectNodeRequested(nodeId);
1121 } 1121 }
1122 1122
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 if (!m_documentNodeToIdMap.contains(m_document)) { 2084 if (!m_documentNodeToIdMap.contains(m_document)) {
2085 RefPtr<TypeBuilder::DOM::Node> root; 2085 RefPtr<TypeBuilder::DOM::Node> root;
2086 getDocument(errorString, root); 2086 getDocument(errorString, root);
2087 return errorString->isEmpty(); 2087 return errorString->isEmpty();
2088 } 2088 }
2089 return true; 2089 return true;
2090 } 2090 }
2091 2091
2092 } // namespace WebCore 2092 } // namespace WebCore
2093 2093
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698