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

Side by Side Diff: Source/core/dom/Range.cpp

Issue 171953002: Get rid of inefficient uses of childNodeCount() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Small clean up Created 6 years, 10 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no)
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
5 * (C) 2001 Peter Kelly (pmk@post.com) 5 * (C) 2001 Peter Kelly (pmk@post.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 switch (node->nodeType()) { 650 switch (node->nodeType()) {
651 case Node::TEXT_NODE: 651 case Node::TEXT_NODE:
652 case Node::CDATA_SECTION_NODE: 652 case Node::CDATA_SECTION_NODE:
653 case Node::COMMENT_NODE: 653 case Node::COMMENT_NODE:
654 return toCharacterData(node)->length(); 654 return toCharacterData(node)->length();
655 case Node::PROCESSING_INSTRUCTION_NODE: 655 case Node::PROCESSING_INSTRUCTION_NODE:
656 return toProcessingInstruction(node)->data().length(); 656 return toProcessingInstruction(node)->data().length();
657 case Node::ELEMENT_NODE: 657 case Node::ELEMENT_NODE:
658 case Node::ATTRIBUTE_NODE: 658 case Node::ATTRIBUTE_NODE:
659 case Node::DOCUMENT_NODE: 659 case Node::DOCUMENT_NODE:
660 case Node::DOCUMENT_FRAGMENT_NODE:
661 return toContainerNode(node)->childNodeCount();
Inactive 2014/02/19 04:13:33 Those are all ContainerNodes so we can cast and by
660 case Node::DOCUMENT_TYPE_NODE: 662 case Node::DOCUMENT_TYPE_NODE:
Inactive 2014/02/19 04:13:33 DocumentType is not a ContainerNode and thus canno
661 case Node::DOCUMENT_FRAGMENT_NODE: 663 return 0;
662 return node->childNodeCount();
663 } 664 }
664 ASSERT_NOT_REACHED(); 665 ASSERT_NOT_REACHED();
665 return 0; 666 return 0;
666 } 667 }
667 668
668 PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception State& exceptionState) 669 PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception State& exceptionState)
669 { 670 {
670 typedef Vector<RefPtr<Node> > NodeVector; 671 typedef Vector<RefPtr<Node> > NodeVector;
671 672
672 RefPtr<DocumentFragment> fragment; 673 RefPtr<DocumentFragment> fragment;
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 1887
1887 void showTree(const WebCore::Range* range) 1888 void showTree(const WebCore::Range* range)
1888 { 1889 {
1889 if (range && range->boundaryPointsValid()) { 1890 if (range && range->boundaryPointsValid()) {
1890 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1891 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1891 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1892 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1892 } 1893 }
1893 } 1894 }
1894 1895
1895 #endif 1896 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698