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

Side by Side Diff: Source/core/dom/Node.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 487
488 void Node::normalize() 488 void Node::normalize()
489 { 489 {
490 // Go through the subtree beneath us, normalizing all nodes. This means that 490 // Go through the subtree beneath us, normalizing all nodes. This means that
491 // any two adjacent text nodes are merged and any empty text nodes are remov ed. 491 // any two adjacent text nodes are merged and any empty text nodes are remov ed.
492 492
493 RefPtr<Node> node = this; 493 RefPtr<Node> node = this;
494 while (Node* firstChild = node->firstChild()) 494 while (Node* firstChild = node->firstChild())
495 node = firstChild; 495 node = firstChild;
496 while (node) { 496 while (node) {
497 NodeType type = node->nodeType(); 497 if (node->isElementNode())
498 if (type == ELEMENT_NODE)
499 toElement(node)->normalizeAttributes(); 498 toElement(node)->normalizeAttributes();
500 499
501 if (node == this) 500 if (node == this)
502 break; 501 break;
503 502
504 if (type == TEXT_NODE) 503 if (node->nodeType() == TEXT_NODE)
aandrey 2014/06/02 14:50:51 node->isTextNode() ?
Inactive 2014/06/02 15:48:02 This is not equivalent, isTextNode() returns true
505 node = toText(node)->mergeNextSiblingNodesIfPossible(); 504 node = toText(node)->mergeNextSiblingNodesIfPossible();
506 else 505 else
507 node = NodeTraversal::nextPostOrder(*node); 506 node = NodeTraversal::nextPostOrder(*node);
508 } 507 }
509 } 508 }
510 509
511 const AtomicString& Node::localName() const 510 const AtomicString& Node::localName() const
512 { 511 {
513 return nullAtom; 512 return nullAtom;
514 } 513 }
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 if (isHTMLBRElement(*node) && convertBRsToNewlines) { 1460 if (isHTMLBRElement(*node) && convertBRsToNewlines) {
1462 isNullString = false; 1461 isNullString = false;
1463 content.append('\n'); 1462 content.append('\n');
1464 break; 1463 break;
1465 } 1464 }
1466 // Fall through. 1465 // Fall through.
1467 case Node::ATTRIBUTE_NODE: 1466 case Node::ATTRIBUTE_NODE:
1468 case Node::DOCUMENT_FRAGMENT_NODE: 1467 case Node::DOCUMENT_FRAGMENT_NODE:
1469 isNullString = false; 1468 isNullString = false;
1470 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) { 1469 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) {
1471 if (child->nodeType() == Node::COMMENT_NODE || child->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) 1470 Node::NodeType childNodeType = child->nodeType();
1471 if (childNodeType == Node::COMMENT_NODE || childNodeType == Node::PR OCESSING_INSTRUCTION_NODE)
1472 continue; 1472 continue;
1473 appendTextContent(child, convertBRsToNewlines, isNullString, content ); 1473 appendTextContent(child, convertBRsToNewlines, isNullString, content );
1474 } 1474 }
1475 break; 1475 break;
1476 1476
1477 case Node::DOCUMENT_NODE: 1477 case Node::DOCUMENT_NODE:
1478 case Node::DOCUMENT_TYPE_NODE: 1478 case Node::DOCUMENT_TYPE_NODE:
1479 break; 1479 break;
1480 } 1480 }
1481 } 1481 }
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 node->showTreeForThis(); 2578 node->showTreeForThis();
2579 } 2579 }
2580 2580
2581 void showNodePath(const WebCore::Node* node) 2581 void showNodePath(const WebCore::Node* node)
2582 { 2582 {
2583 if (node) 2583 if (node)
2584 node->showNodePathForThis(); 2584 node->showNodePathForThis();
2585 } 2585 }
2586 2586
2587 #endif 2587 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698