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

Side by Side Diff: Source/core/page/DOMSelection.cpp

Issue 171773008: Rename childNodeCount() / childNode() methods for clarity (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Further renaming for consistency 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/inspector/DOMPatchSupport.cpp ('k') | Source/core/page/SpatialNavigation.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) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 if (!node) { 330 if (!node) {
331 exceptionState.throwDOMException(TypeMismatchError, "The node provided i s invalid."); 331 exceptionState.throwDOMException(TypeMismatchError, "The node provided i s invalid.");
332 return; 332 return;
333 } 333 }
334 334
335 if (offset < 0) { 335 if (offset < 0) {
336 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is not a valid offset."); 336 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is not a valid offset.");
337 return; 337 return;
338 } 338 }
339 if (offset > (node->offsetInCharacters() ? caretMaxOffset(node) : (int)node- >childNodeCount())) { 339 if (offset > (node->offsetInCharacters() ? caretMaxOffset(node) : (int)node- >countChildren())) {
340 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is larger than the given node's length."); 340 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is larger than the given node's length.");
341 return; 341 return;
342 } 342 }
343 343
344 if (!isValidForPosition(node)) 344 if (!isValidForPosition(node))
345 return; 345 return;
346 346
347 // FIXME: Eliminate legacy editing positions 347 // FIXME: Eliminate legacy editing positions
348 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n ode, offset), DOWNSTREAM)); 348 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n ode, offset), DOWNSTREAM));
349 } 349 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 return allowPartial || n->isTextNode(); 475 return allowPartial || n->isTextNode();
476 } 476 }
477 477
478 void DOMSelection::selectAllChildren(Node* n, ExceptionState& exceptionState) 478 void DOMSelection::selectAllChildren(Node* n, ExceptionState& exceptionState)
479 { 479 {
480 if (!n) 480 if (!n)
481 return; 481 return;
482 482
483 // This doesn't (and shouldn't) select text node characters. 483 // This doesn't (and shouldn't) select text node characters.
484 setBaseAndExtent(n, 0, n, n->childNodeCount(), exceptionState); 484 setBaseAndExtent(n, 0, n, n->countChildren(), exceptionState);
485 } 485 }
486 486
487 String DOMSelection::toString() 487 String DOMSelection::toString()
488 { 488 {
489 if (!m_frame) 489 if (!m_frame)
490 return String(); 490 return String();
491 491
492 return plainText(m_frame->selection().selection().toNormalizedRange().get()) ; 492 return plainText(m_frame->selection().selection().toNormalizedRange().get()) ;
493 } 493 }
494 494
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 529
530 bool DOMSelection::isValidForPosition(Node* node) const 530 bool DOMSelection::isValidForPosition(Node* node) const
531 { 531 {
532 ASSERT(m_frame); 532 ASSERT(m_frame);
533 if (!node) 533 if (!node)
534 return true; 534 return true;
535 return node->document() == m_frame->document(); 535 return node->document() == m_frame->document();
536 } 536 }
537 537
538 } // namespace WebCore 538 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/page/SpatialNavigation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698