| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 if (!isValidForPosition(node)) | 345 if (!isValidForPosition(node)) |
| 346 return; | 346 return; |
| 347 | 347 |
| 348 // FIXME: Eliminate legacy editing positions | 348 // FIXME: Eliminate legacy editing positions |
| 349 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n
ode, offset), DOWNSTREAM)); | 349 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n
ode, offset), DOWNSTREAM)); |
| 350 } | 350 } |
| 351 | 351 |
| 352 PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionS
tate) | 352 PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionS
tate) |
| 353 { | 353 { |
| 354 if (!m_frame) | 354 if (!m_frame) |
| 355 return 0; | 355 return nullptr; |
| 356 | 356 |
| 357 if (index < 0 || index >= rangeCount()) { | 357 if (index < 0 || index >= rangeCount()) { |
| 358 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); | 358 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); |
| 359 return 0; | 359 return nullptr; |
| 360 } | 360 } |
| 361 | 361 |
| 362 // If you're hitting this, you've added broken multi-range selection support | 362 // If you're hitting this, you've added broken multi-range selection support |
| 363 ASSERT(rangeCount() == 1); | 363 ASSERT(rangeCount() == 1); |
| 364 | 364 |
| 365 if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { | 365 if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { |
| 366 ASSERT(!shadowAncestor->isShadowRoot()); | 366 ASSERT(!shadowAncestor->isShadowRoot()); |
| 367 ContainerNode* container = shadowAncestor->parentOrShadowHostNode(); | 367 ContainerNode* container = shadowAncestor->parentOrShadowHostNode(); |
| 368 int offset = shadowAncestor->nodeIndex(); | 368 int offset = shadowAncestor->nodeIndex(); |
| 369 return Range::create(shadowAncestor->document(), container, offset, cont
ainer, offset); | 369 return Range::create(shadowAncestor->document(), container, offset, cont
ainer, offset); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 530 |
| 531 bool DOMSelection::isValidForPosition(Node* node) const | 531 bool DOMSelection::isValidForPosition(Node* node) const |
| 532 { | 532 { |
| 533 ASSERT(m_frame); | 533 ASSERT(m_frame); |
| 534 if (!node) | 534 if (!node) |
| 535 return true; | 535 return true; |
| 536 return node->document() == m_frame->document(); | 536 return node->document() == m_frame->document(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 } // namespace WebCore | 539 } // namespace WebCore |
| OLD | NEW |