OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |