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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (!m_frame) | 200 if (!m_frame) |
201 return; | 201 return; |
202 | 202 |
203 if (offset < 0) { | 203 if (offset < 0) { |
204 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); | 204 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); |
205 return; | 205 return; |
206 } | 206 } |
207 | 207 |
208 if (!isValidForPosition(node)) | 208 if (!isValidForPosition(node)) |
209 return; | 209 return; |
210 | 210 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); |
211 // FIXME: Eliminate legacy editing positions | 211 range->setStart(node, offset, exceptionState); |
212 m_frame->selection().moveTo(VisiblePosition(createLegacyEditingPosition(node
, offset), DOWNSTREAM)); | 212 if (exceptionState.hadException()) |
| 213 return; |
| 214 range->setEnd(node, offset, exceptionState); |
| 215 if (exceptionState.hadException()) |
| 216 return; |
| 217 m_frame->selection().setSelectedRange(range.get(), DOWNSTREAM, m_frame->sele
ction().isDirectional()); |
213 } | 218 } |
214 | 219 |
215 void DOMSelection::collapse(Node* node, ExceptionState& exceptionState) | 220 void DOMSelection::collapse(Node* node, ExceptionState& exceptionState) |
216 { | 221 { |
217 collapse(node, 0, exceptionState); | 222 collapse(node, 0, exceptionState); |
218 } | 223 } |
219 | 224 |
220 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) | 225 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) |
221 { | 226 { |
222 if (!m_frame) | 227 if (!m_frame) |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 return node->document() == m_frame->document(); | 555 return node->document() == m_frame->document(); |
551 } | 556 } |
552 | 557 |
553 void DOMSelection::addConsoleError(const String& message) | 558 void DOMSelection::addConsoleError(const String& message) |
554 { | 559 { |
555 if (m_treeScope) | 560 if (m_treeScope) |
556 m_treeScope->document().addConsoleMessage(JSMessageSource, ErrorMessageL
evel, message); | 561 m_treeScope->document().addConsoleMessage(JSMessageSource, ErrorMessageL
evel, message); |
557 } | 562 } |
558 | 563 |
559 } // namespace WebCore | 564 } // namespace WebCore |
OLD | NEW |