| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 725 |
| 726 template <typename Strategy> | 726 template <typename Strategy> |
| 727 Element* VisibleSelectionTemplate<Strategy>::rootEditableElement() const | 727 Element* VisibleSelectionTemplate<Strategy>::rootEditableElement() const |
| 728 { | 728 { |
| 729 return rootEditableElementOf(start()); | 729 return rootEditableElementOf(start()); |
| 730 } | 730 } |
| 731 | 731 |
| 732 template <typename Strategy> | 732 template <typename Strategy> |
| 733 static bool isValidPosition(const PositionTemplate<Strategy>& position) | 733 static bool isValidPosition(const PositionTemplate<Strategy>& position) |
| 734 { | 734 { |
| 735 if (!position.inShadowIncludingDocument()) | 735 if (!position.isConnected()) |
| 736 return false; | 736 return false; |
| 737 | 737 |
| 738 if (!position.isOffsetInAnchor()) | 738 if (!position.isOffsetInAnchor()) |
| 739 return true; | 739 return true; |
| 740 | 740 |
| 741 if (position.offsetInContainerNode() < 0) | 741 if (position.offsetInContainerNode() < 0) |
| 742 return false; | 742 return false; |
| 743 | 743 |
| 744 const unsigned offset = static_cast<unsigned>(position.offsetInContainerNode
()); | 744 const unsigned offset = static_cast<unsigned>(position.offsetInContainerNode
()); |
| 745 const unsigned nodeLength = position.anchorNode()->lengthOfContents(); | 745 const unsigned nodeLength = position.anchorNode()->lengthOfContents(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 756 const bool hasTrailingWhitespace = m_hasTrailingWhitespace; | 756 const bool hasTrailingWhitespace = m_hasTrailingWhitespace; |
| 757 validate(m_granularity); | 757 validate(m_granularity); |
| 758 if (!hasTrailingWhitespace) | 758 if (!hasTrailingWhitespace) |
| 759 return; | 759 return; |
| 760 appendTrailingWhitespace(); | 760 appendTrailingWhitespace(); |
| 761 } | 761 } |
| 762 | 762 |
| 763 template <typename Strategy> | 763 template <typename Strategy> |
| 764 void VisibleSelectionTemplate<Strategy>::validatePositionsIfNeeded() | 764 void VisibleSelectionTemplate<Strategy>::validatePositionsIfNeeded() |
| 765 { | 765 { |
| 766 if (!m_base.inShadowIncludingDocument() || !m_extent.inShadowIncludingDocume
nt()) { | 766 if (!m_base.isConnected() || !m_extent.isConnected()) { |
| 767 *this = VisibleSelectionTemplate(); | 767 *this = VisibleSelectionTemplate(); |
| 768 return; | 768 return; |
| 769 } | 769 } |
| 770 if (isValidPosition(m_base) && isValidPosition(m_extent) && isValidPosition(
m_start) && isValidPosition(m_end)) | 770 if (isValidPosition(m_base) && isValidPosition(m_extent) && isValidPosition(
m_start) && isValidPosition(m_end)) |
| 771 return; | 771 return; |
| 772 validate(); | 772 validate(); |
| 773 } | 773 } |
| 774 | 774 |
| 775 template <typename Strategy> | 775 template <typename Strategy> |
| 776 static bool equalSelectionsAlgorithm(const VisibleSelectionTemplate<Strategy>& s
election1, const VisibleSelectionTemplate<Strategy>& selection2) | 776 static bool equalSelectionsAlgorithm(const VisibleSelectionTemplate<Strategy>& s
election1, const VisibleSelectionTemplate<Strategy>& selection2) |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 { | 908 { |
| 909 sel.showTreeForThis(); | 909 sel.showTreeForThis(); |
| 910 } | 910 } |
| 911 | 911 |
| 912 void showTree(const blink::VisibleSelectionInFlatTree* sel) | 912 void showTree(const blink::VisibleSelectionInFlatTree* sel) |
| 913 { | 913 { |
| 914 if (sel) | 914 if (sel) |
| 915 sel->showTreeForThis(); | 915 sel->showTreeForThis(); |
| 916 } | 916 } |
| 917 #endif | 917 #endif |
| OLD | NEW |