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

Side by Side Diff: Source/core/editing/htmlediting.cpp

Issue 171953002: Get rid of inefficient uses of childNodeCount() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use lastChild() 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
« no previous file with comments | « Source/core/editing/TextIterator.cpp ('k') | Source/core/editing/markup.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 if (isRenderedTable(downstream.deprecatedNode()) && downstream.atFirstEditin gPositionForNode()) 496 if (isRenderedTable(downstream.deprecatedNode()) && downstream.atFirstEditin gPositionForNode())
497 return downstream.deprecatedNode(); 497 return downstream.deprecatedNode();
498 498
499 return 0; 499 return 0;
500 } 500 }
501 501
502 // Returns the visible position at the beginning of a node 502 // Returns the visible position at the beginning of a node
503 VisiblePosition visiblePositionBeforeNode(Node* node) 503 VisiblePosition visiblePositionBeforeNode(Node* node)
504 { 504 {
505 ASSERT(node); 505 ASSERT(node);
506 if (node->childNodeCount()) 506 if (node->hasChildNodes())
507 return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM); 507 return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM);
508 ASSERT(node->parentNode()); 508 ASSERT(node->parentNode());
509 ASSERT(!node->parentNode()->isShadowRoot()); 509 ASSERT(!node->parentNode()->isShadowRoot());
510 return positionInParentBeforeNode(node); 510 return positionInParentBeforeNode(node);
511 } 511 }
512 512
513 // Returns the visible position at the ending of a node 513 // Returns the visible position at the ending of a node
514 VisiblePosition visiblePositionAfterNode(Node* node) 514 VisiblePosition visiblePositionAfterNode(Node* node)
515 { 515 {
516 ASSERT(node); 516 ASSERT(node);
517 if (node->childNodeCount()) 517 if (node->hasChildNodes())
518 return VisiblePosition(lastPositionInOrAfterNode(node), DOWNSTREAM); 518 return VisiblePosition(lastPositionInOrAfterNode(node), DOWNSTREAM);
519 ASSERT(node->parentNode()); 519 ASSERT(node->parentNode());
520 ASSERT(!node->parentNode()->isShadowRoot()); 520 ASSERT(!node->parentNode()->isShadowRoot());
521 return positionInParentAfterNode(node); 521 return positionInParentAfterNode(node);
522 } 522 }
523 523
524 // Create a range object with two visible positions, start and end. 524 // Create a range object with two visible positions, start and end.
525 // create(Document*, const Position&, const Position&); will use deprecatedEditi ngOffset 525 // create(Document*, const Position&, const Position&); will use deprecatedEditi ngOffset
526 // Use this function instead of create a regular range object (avoiding editing offset). 526 // Use this function instead of create a regular range object (avoiding editing offset).
527 PassRefPtr<Range> createRange(Document& document, const VisiblePosition& start, const VisiblePosition& end, ExceptionState& exceptionState) 527 PassRefPtr<Range> createRange(Document& document, const VisiblePosition& start, const VisiblePosition& end, ExceptionState& exceptionState)
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 // if the selection starts just before a paragraph break, skip over it 1118 // if the selection starts just before a paragraph break, skip over it
1119 if (isEndOfParagraph(visiblePosition)) 1119 if (isEndOfParagraph(visiblePosition))
1120 return visiblePosition.next().deepEquivalent().downstream(); 1120 return visiblePosition.next().deepEquivalent().downstream();
1121 1121
1122 // otherwise, make sure to be at the start of the first selected node, 1122 // otherwise, make sure to be at the start of the first selected node,
1123 // instead of possibly at the end of the last node before the selection 1123 // instead of possibly at the end of the last node before the selection
1124 return visiblePosition.deepEquivalent().downstream(); 1124 return visiblePosition.deepEquivalent().downstream();
1125 } 1125 }
1126 1126
1127 } // namespace WebCore 1127 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/TextIterator.cpp ('k') | Source/core/editing/markup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698