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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) | 265 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) |
266 return; | 266 return; |
267 | 267 |
268 // FIXME: Eliminate legacy editing positions | 268 // FIXME: Eliminate legacy editing positions |
269 VisiblePosition visibleBase = VisiblePosition(createLegacyEditingPosition(ba
seNode, baseOffset), DOWNSTREAM); | 269 VisiblePosition visibleBase = VisiblePosition(createLegacyEditingPosition(ba
seNode, baseOffset), DOWNSTREAM); |
270 VisiblePosition visibleExtent = VisiblePosition(createLegacyEditingPosition(
extentNode, extentOffset), DOWNSTREAM); | 270 VisiblePosition visibleExtent = VisiblePosition(createLegacyEditingPosition(
extentNode, extentOffset), DOWNSTREAM); |
271 | 271 |
272 m_frame->selection().moveTo(visibleBase, visibleExtent); | 272 m_frame->selection().moveTo(visibleBase, visibleExtent); |
273 } | 273 } |
274 | 274 |
275 void DOMSelection::setPosition(Node* node, int offset, ExceptionState& exception
State) | |
276 { | |
277 if (!m_frame) | |
278 return; | |
279 if (offset < 0) { | |
280 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); | |
281 return; | |
282 } | |
283 | |
284 if (!isValidForPosition(node)) | |
285 return; | |
286 | |
287 // FIXME: Eliminate legacy editing positions | |
288 m_frame->selection().moveTo(VisiblePosition(createLegacyEditingPosition(node
, offset), DOWNSTREAM)); | |
289 } | |
290 | |
291 void DOMSelection::modify(const String& alterString, const String& directionStri
ng, const String& granularityString) | 275 void DOMSelection::modify(const String& alterString, const String& directionStri
ng, const String& granularityString) |
292 { | 276 { |
293 if (!m_frame) | 277 if (!m_frame) |
294 return; | 278 return; |
295 | 279 |
296 FrameSelection::EAlteration alter; | 280 FrameSelection::EAlteration alter; |
297 if (equalIgnoringCase(alterString, "extend")) | 281 if (equalIgnoringCase(alterString, "extend")) |
298 alter = FrameSelection::AlterationExtend; | 282 alter = FrameSelection::AlterationExtend; |
299 else if (equalIgnoringCase(alterString, "move")) | 283 else if (equalIgnoringCase(alterString, "move")) |
300 alter = FrameSelection::AlterationMove; | 284 alter = FrameSelection::AlterationMove; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 529 |
546 bool DOMSelection::isValidForPosition(Node* node) const | 530 bool DOMSelection::isValidForPosition(Node* node) const |
547 { | 531 { |
548 ASSERT(m_frame); | 532 ASSERT(m_frame); |
549 if (!node) | 533 if (!node) |
550 return true; | 534 return true; |
551 return node->document() == m_frame->document(); | 535 return node->document() == m_frame->document(); |
552 } | 536 } |
553 | 537 |
554 } // namespace WebCore | 538 } // namespace WebCore |
OLD | NEW |