| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 209 } |
| 210 | 210 |
| 211 void DOMSelection::collapseToEnd(ExceptionCode& ec) | 211 void DOMSelection::collapseToEnd(ExceptionCode& ec) |
| 212 { | 212 { |
| 213 if (!m_frame) | 213 if (!m_frame) |
| 214 return; | 214 return; |
| 215 | 215 |
| 216 const VisibleSelection& selection = m_frame->selection()->selection(); | 216 const VisibleSelection& selection = m_frame->selection()->selection(); |
| 217 | 217 |
| 218 if (selection.isNone()) { | 218 if (selection.isNone()) { |
| 219 ec = INVALID_STATE_ERR; | 219 ec = InvalidStateError; |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 | 222 |
| 223 m_frame->selection()->moveTo(VisiblePosition(selection.end(), DOWNSTREAM)); | 223 m_frame->selection()->moveTo(VisiblePosition(selection.end(), DOWNSTREAM)); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void DOMSelection::collapseToStart(ExceptionCode& ec) | 226 void DOMSelection::collapseToStart(ExceptionCode& ec) |
| 227 { | 227 { |
| 228 if (!m_frame) | 228 if (!m_frame) |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 const VisibleSelection& selection = m_frame->selection()->selection(); | 231 const VisibleSelection& selection = m_frame->selection()->selection(); |
| 232 | 232 |
| 233 if (selection.isNone()) { | 233 if (selection.isNone()) { |
| 234 ec = INVALID_STATE_ERR; | 234 ec = InvalidStateError; |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 m_frame->selection()->moveTo(VisiblePosition(selection.start(), DOWNSTREAM))
; | 238 m_frame->selection()->moveTo(VisiblePosition(selection.start(), DOWNSTREAM))
; |
| 239 } | 239 } |
| 240 | 240 |
| 241 void DOMSelection::empty() | 241 void DOMSelection::empty() |
| 242 { | 242 { |
| 243 if (!m_frame) | 243 if (!m_frame) |
| 244 return; | 244 return; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 330 |
| 331 m_frame->selection()->modify(alter, direction, granularity); | 331 m_frame->selection()->modify(alter, direction, granularity); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void DOMSelection::extend(Node* node, int offset, ExceptionCode& ec) | 334 void DOMSelection::extend(Node* node, int offset, ExceptionCode& ec) |
| 335 { | 335 { |
| 336 if (!m_frame) | 336 if (!m_frame) |
| 337 return; | 337 return; |
| 338 | 338 |
| 339 if (!node) { | 339 if (!node) { |
| 340 ec = TYPE_MISMATCH_ERR; | 340 ec = TypeMismatchError; |
| 341 return; | 341 return; |
| 342 } | 342 } |
| 343 | 343 |
| 344 if (offset < 0 || offset > (node->offsetInCharacters() ? caretMaxOffset(node
) : (int)node->childNodeCount())) { | 344 if (offset < 0 || offset > (node->offsetInCharacters() ? caretMaxOffset(node
) : (int)node->childNodeCount())) { |
| 345 ec = IndexSizeError; | 345 ec = IndexSizeError; |
| 346 return; | 346 return; |
| 347 } | 347 } |
| 348 | 348 |
| 349 if (!isValidForPosition(node)) | 349 if (!isValidForPosition(node)) |
| 350 return; | 350 return; |
| (...skipping 179 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 |