| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 358 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 359 | 359 |
| 360 frame()->selection().modify(alter, direction, granularity); | 360 frame()->selection().modify(alter, direction, granularity); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void DOMSelection::extend(Node* node, | 363 void DOMSelection::extend(Node* node, |
| 364 int offset, | 364 int offset, |
| 365 ExceptionState& exceptionState) { | 365 ExceptionState& exceptionState) { |
| 366 DCHECK(node); | 366 DCHECK(node); |
| 367 | 367 |
| 368 if (!isAvailable()) | 368 if (rangeCount() == 0) { |
| 369 exceptionState.throwDOMException( |
| 370 InvalidStateError, "This Selection object doesn't have any Ranges."); |
| 369 return; | 371 return; |
| 372 } |
| 370 | 373 |
| 371 if (offset < 0) { | 374 if (offset < 0) { |
| 372 exceptionState.throwDOMException( | 375 exceptionState.throwDOMException( |
| 373 IndexSizeError, String::number(offset) + " is not a valid offset."); | 376 IndexSizeError, String::number(offset) + " is not a valid offset."); |
| 374 return; | 377 return; |
| 375 } | 378 } |
| 376 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { | 379 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { |
| 377 exceptionState.throwDOMException( | 380 exceptionState.throwDOMException( |
| 378 IndexSizeError, | 381 IndexSizeError, |
| 379 String::number(offset) + " is larger than the given node's length."); | 382 String::number(offset) + " is larger than the given node's length."); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 m_treeScope->document().addConsoleMessage( | 671 m_treeScope->document().addConsoleMessage( |
| 669 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 672 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
| 670 } | 673 } |
| 671 | 674 |
| 672 DEFINE_TRACE(DOMSelection) { | 675 DEFINE_TRACE(DOMSelection) { |
| 673 visitor->trace(m_treeScope); | 676 visitor->trace(m_treeScope); |
| 674 ContextClient::trace(visitor); | 677 ContextClient::trace(visitor); |
| 675 } | 678 } |
| 676 | 679 |
| 677 } // namespace blink | 680 } // namespace blink |
| OLD | NEW |