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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 int DOMSelection::rangeCount() const | 198 int DOMSelection::rangeCount() const |
199 { | 199 { |
200 if (!m_frame) | 200 if (!m_frame) |
201 return 0; | 201 return 0; |
202 return m_frame->selection().isNone() ? 0 : 1; | 202 return m_frame->selection().isNone() ? 0 : 1; |
203 } | 203 } |
204 | 204 |
205 void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta
te) | 205 void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta
te) |
206 { | 206 { |
| 207 ASSERT(node); |
| 208 |
207 if (!m_frame) | 209 if (!m_frame) |
208 return; | 210 return; |
209 | 211 |
210 if (!node) { | |
211 m_frame->selection().clear(); | |
212 return; | |
213 } | |
214 | |
215 if (offset < 0) { | 212 if (offset < 0) { |
216 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); | 213 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); |
217 return; | 214 return; |
218 } | 215 } |
219 | 216 |
220 if (!isValidForPosition(node)) | 217 if (!isValidForPosition(node)) |
221 return; | 218 return; |
222 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); | 219 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); |
223 range->setStart(node, offset, exceptionState); | 220 range->setStart(node, offset, exceptionState); |
224 if (exceptionState.hadException()) | 221 if (exceptionState.hadException()) |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); | 563 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); |
567 } | 564 } |
568 | 565 |
569 DEFINE_TRACE(DOMSelection) | 566 DEFINE_TRACE(DOMSelection) |
570 { | 567 { |
571 visitor->trace(m_treeScope); | 568 visitor->trace(m_treeScope); |
572 DOMWindowProperty::trace(visitor); | 569 DOMWindowProperty::trace(visitor); |
573 } | 570 } |
574 | 571 |
575 } // namespace blink | 572 } // namespace blink |
OLD | NEW |