| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); | 211 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); |
| 212 range->setStart(node, offset, exceptionState); | 212 range->setStart(node, offset, exceptionState); |
| 213 if (exceptionState.hadException()) | 213 if (exceptionState.hadException()) |
| 214 return; | 214 return; |
| 215 range->setEnd(node, offset, exceptionState); | 215 range->setEnd(node, offset, exceptionState); |
| 216 if (exceptionState.hadException()) | 216 if (exceptionState.hadException()) |
| 217 return; | 217 return; |
| 218 m_frame->selection().setSelectedRange(range.get(), DOWNSTREAM, m_frame->sele
ction().isDirectional() ? FrameSelection::Directional : FrameSelection::NonDirec
tional); | 218 m_frame->selection().setSelectedRange(range.get(), DOWNSTREAM, m_frame->sele
ction().isDirectional() ? FrameSelection::Directional : FrameSelection::NonDirec
tional); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void DOMSelection::collapse(Node* node, ExceptionState& exceptionState) | |
| 222 { | |
| 223 collapse(node, 0, exceptionState); | |
| 224 } | |
| 225 | |
| 226 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) | 221 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) |
| 227 { | 222 { |
| 228 if (!m_frame) | 223 if (!m_frame) |
| 229 return; | 224 return; |
| 230 | 225 |
| 231 const VisibleSelection& selection = m_frame->selection().selection(); | 226 const VisibleSelection& selection = m_frame->selection().selection(); |
| 232 | 227 |
| 233 if (selection.isNone()) { | 228 if (selection.isNone()) { |
| 234 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); | 229 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); |
| 235 return; | 230 return; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 return; | 346 return; |
| 352 } | 347 } |
| 353 | 348 |
| 354 if (!isValidForPosition(node)) | 349 if (!isValidForPosition(node)) |
| 355 return; | 350 return; |
| 356 | 351 |
| 357 // FIXME: Eliminate legacy editing positions | 352 // FIXME: Eliminate legacy editing positions |
| 358 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n
ode, offset), DOWNSTREAM)); | 353 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n
ode, offset), DOWNSTREAM)); |
| 359 } | 354 } |
| 360 | 355 |
| 361 void DOMSelection::extend(Node* node, ExceptionState& exceptionState) | |
| 362 { | |
| 363 // This default value implementation differs from the spec, which says |offs
et| is not optional. | |
| 364 // FIXME: Specify this default value in Selection.idl. | |
| 365 extend(node, 0, exceptionState); | |
| 366 } | |
| 367 | |
| 368 PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState
& exceptionState) | 356 PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState
& exceptionState) |
| 369 { | 357 { |
| 370 if (!m_frame) | 358 if (!m_frame) |
| 371 return nullptr; | 359 return nullptr; |
| 372 | 360 |
| 373 if (index < 0 || index >= rangeCount()) { | 361 if (index < 0 || index >= rangeCount()) { |
| 374 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); | 362 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); |
| 375 return nullptr; | 363 return nullptr; |
| 376 } | 364 } |
| 377 | 365 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 return node->document() == m_frame->document(); | 548 return node->document() == m_frame->document(); |
| 561 } | 549 } |
| 562 | 550 |
| 563 void DOMSelection::addConsoleError(const String& message) | 551 void DOMSelection::addConsoleError(const String& message) |
| 564 { | 552 { |
| 565 if (m_treeScope) | 553 if (m_treeScope) |
| 566 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); | 554 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); |
| 567 } | 555 } |
| 568 | 556 |
| 569 } // namespace blink | 557 } // namespace blink |
| OLD | NEW |