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

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

Issue 788053002: Prefer lengthOfContents over countChildren (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | no next file » | 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 { 337 {
338 ASSERT(node); 338 ASSERT(node);
339 339
340 if (!m_frame) 340 if (!m_frame)
341 return; 341 return;
342 342
343 if (offset < 0) { 343 if (offset < 0) {
344 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is not a valid offset."); 344 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is not a valid offset.");
345 return; 345 return;
346 } 346 }
347 if (static_cast<unsigned>(offset) > (node->offsetInCharacters() ? node->leng thOfContents() : node->countChildren())) { 347 if (static_cast<unsigned>(offset) > node->lengthOfContents()) {
348 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is larger than the given node's length."); 348 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is larger than the given node's length.");
349 return; 349 return;
350 } 350 }
351 351
352 if (!isValidForPosition(node)) 352 if (!isValidForPosition(node))
353 return; 353 return;
354 354
355 // FIXME: Eliminate legacy editing positions 355 // FIXME: Eliminate legacy editing positions
356 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n ode, offset), DOWNSTREAM)); 356 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n ode, offset), DOWNSTREAM));
357 } 357 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); 560 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message));
561 } 561 }
562 562
563 void DOMSelection::trace(Visitor* visitor) 563 void DOMSelection::trace(Visitor* visitor)
564 { 564 {
565 visitor->trace(m_treeScope); 565 visitor->trace(m_treeScope);
566 DOMWindowProperty::trace(visitor); 566 DOMWindowProperty::trace(visitor);
567 } 567 }
568 568
569 } // namespace blink 569 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698