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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 IndexSizeError, String::number(offset) + " is not a valid offset."); | 452 IndexSizeError, String::number(offset) + " is not a valid offset."); |
453 return; | 453 return; |
454 } | 454 } |
455 Range::checkNodeWOffset(node, offset, exceptionState); | 455 Range::checkNodeWOffset(node, offset, exceptionState); |
456 if (exceptionState.hadException()) | 456 if (exceptionState.hadException()) |
457 return; | 457 return; |
458 | 458 |
459 // 3. Let oldAnchor and oldFocus be the context object's anchor and focus, and | 459 // 3. Let oldAnchor and oldFocus be the context object's anchor and focus, and |
460 // let newFocus be the boundary point (node, offset). | 460 // let newFocus be the boundary point (node, offset). |
461 const Position& oldAnchor = anchorPosition(); | 461 const Position& oldAnchor = anchorPosition(); |
| 462 // TODO(tkent): Diagnostic checks for crbug.com/693578. They should be |
| 463 // removed before M58 branch. |
| 464 if (oldAnchor.isNull()) { |
| 465 if (Range* range = documentCachedRange()) { |
| 466 LOG(FATAL) |
| 467 << "Selection has a cached Range, but anchorPosition is null. start=" |
| 468 << range->startContainer() << " end=" << range->endContainer(); |
| 469 } else if (frame() && !frame()->selection().isNone()) { |
| 470 LOG(FATAL) << "FrameSelection is not none, but anchorPosition is null."; |
| 471 } |
| 472 } |
462 DCHECK(!oldAnchor.isNull()); | 473 DCHECK(!oldAnchor.isNull()); |
463 const Position newFocus(node, offset); | 474 const Position newFocus(node, offset); |
464 | 475 |
465 clearCachedRangeIfSelectionOfDocument(); | 476 clearCachedRangeIfSelectionOfDocument(); |
466 | 477 |
467 // 4. Let newRange be a new range. | 478 // 4. Let newRange be a new range. |
468 Range* newRange = Range::create(*frame()->document()); | 479 Range* newRange = Range::create(*frame()->document()); |
469 | 480 |
470 // 5. If node's root is not the same as the context object's range's root, set | 481 // 5. If node's root is not the same as the context object's range's root, set |
471 // newRange's start and end to newFocus. | 482 // newRange's start and end to newFocus. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 m_treeScope->document().addConsoleMessage( | 822 m_treeScope->document().addConsoleMessage( |
812 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 823 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
813 } | 824 } |
814 | 825 |
815 DEFINE_TRACE(DOMSelection) { | 826 DEFINE_TRACE(DOMSelection) { |
816 visitor->trace(m_treeScope); | 827 visitor->trace(m_treeScope); |
817 ContextClient::trace(visitor); | 828 ContextClient::trace(visitor); |
818 } | 829 } |
819 | 830 |
820 } // namespace blink | 831 } // namespace blink |
OLD | NEW |