| 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 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 // The selection ends in editable content or non-editable content inside
a different editable ancestor, | 852 // The selection ends in editable content or non-editable content inside
a different editable ancestor, |
| 853 // move backward until non-editable content inside the same lowest edita
ble ancestor is reached. | 853 // move backward until non-editable content inside the same lowest edita
ble ancestor is reached. |
| 854 Element* endEditableAncestor = lowestEditableAncestor(m_end.computeConta
inerNode()); | 854 Element* endEditableAncestor = lowestEditableAncestor(m_end.computeConta
inerNode()); |
| 855 if (endRoot || endEditableAncestor != baseEditableAncestor) { | 855 if (endRoot || endEditableAncestor != baseEditableAncestor) { |
| 856 | 856 |
| 857 PositionTemplate<Strategy>p = previousVisuallyDistinctCandidate(m_en
d); | 857 PositionTemplate<Strategy>p = previousVisuallyDistinctCandidate(m_en
d); |
| 858 Element* shadowAncestor = endRoot ? endRoot->shadowHost() : nullptr; | 858 Element* shadowAncestor = endRoot ? endRoot->shadowHost() : nullptr; |
| 859 if (p.isNull() && shadowAncestor) | 859 if (p.isNull() && shadowAncestor) |
| 860 p = PositionTemplate<Strategy>::afterNode(shadowAncestor); | 860 p = PositionTemplate<Strategy>::afterNode(shadowAncestor); |
| 861 while (p.isNotNull() && !(lowestEditableAncestor(p.computeContainerN
ode()) == baseEditableAncestor && !isEditablePosition(p))) { | 861 while (p.isNotNull() && !(lowestEditableAncestor(p.computeContainerN
ode()) == baseEditableAncestor && !isEditablePosition(p))) { |
| 862 Element* root = editableRootElementForPosition(p); | 862 Element* root = rootEditableElementOf(p); |
| 863 shadowAncestor = root ? root->shadowHost() : nullptr; | 863 shadowAncestor = root ? root->shadowHost() : nullptr; |
| 864 p = isAtomicNode(p.computeContainerNode()) ? PositionTemplate<St
rategy>::inParentBeforeNode(*p.computeContainerNode()) : previousVisuallyDistinc
tCandidate(p); | 864 p = isAtomicNode(p.computeContainerNode()) ? PositionTemplate<St
rategy>::inParentBeforeNode(*p.computeContainerNode()) : previousVisuallyDistinc
tCandidate(p); |
| 865 if (p.isNull() && shadowAncestor) | 865 if (p.isNull() && shadowAncestor) |
| 866 p = PositionTemplate<Strategy>::afterNode(shadowAncestor); | 866 p = PositionTemplate<Strategy>::afterNode(shadowAncestor); |
| 867 } | 867 } |
| 868 const VisiblePositionTemplate<Strategy> previous = createVisiblePosi
tion(p); | 868 const VisiblePositionTemplate<Strategy> previous = createVisiblePosi
tion(p); |
| 869 | 869 |
| 870 if (previous.isNull()) { | 870 if (previous.isNull()) { |
| 871 // The selection crosses an Editing boundary. This is a | 871 // The selection crosses an Editing boundary. This is a |
| 872 // programmer error in the editing code. Happy debugging! | 872 // programmer error in the editing code. Happy debugging! |
| 873 ASSERT_NOT_REACHED(); | 873 ASSERT_NOT_REACHED(); |
| 874 m_base = PositionTemplate<Strategy>(); | 874 m_base = PositionTemplate<Strategy>(); |
| 875 m_extent = PositionTemplate<Strategy>(); | 875 m_extent = PositionTemplate<Strategy>(); |
| 876 validate(); | 876 validate(); |
| 877 return; | 877 return; |
| 878 } | 878 } |
| 879 m_end = previous.deepEquivalent(); | 879 m_end = previous.deepEquivalent(); |
| 880 } | 880 } |
| 881 | 881 |
| 882 // The selection starts in editable content or non-editable content insi
de a different editable ancestor, | 882 // The selection starts in editable content or non-editable content insi
de a different editable ancestor, |
| 883 // move forward until non-editable content inside the same lowest editab
le ancestor is reached. | 883 // move forward until non-editable content inside the same lowest editab
le ancestor is reached. |
| 884 Element* startEditableAncestor = lowestEditableAncestor(m_start.computeC
ontainerNode()); | 884 Element* startEditableAncestor = lowestEditableAncestor(m_start.computeC
ontainerNode()); |
| 885 if (startRoot || startEditableAncestor != baseEditableAncestor) { | 885 if (startRoot || startEditableAncestor != baseEditableAncestor) { |
| 886 PositionTemplate<Strategy> p = nextVisuallyDistinctCandidate(m_start
); | 886 PositionTemplate<Strategy> p = nextVisuallyDistinctCandidate(m_start
); |
| 887 Element* shadowAncestor = startRoot ? startRoot->shadowHost() : null
ptr; | 887 Element* shadowAncestor = startRoot ? startRoot->shadowHost() : null
ptr; |
| 888 if (p.isNull() && shadowAncestor) | 888 if (p.isNull() && shadowAncestor) |
| 889 p = PositionTemplate<Strategy>::beforeNode(shadowAncestor); | 889 p = PositionTemplate<Strategy>::beforeNode(shadowAncestor); |
| 890 while (p.isNotNull() && !(lowestEditableAncestor(p.computeContainerN
ode()) == baseEditableAncestor && !isEditablePosition(p))) { | 890 while (p.isNotNull() && !(lowestEditableAncestor(p.computeContainerN
ode()) == baseEditableAncestor && !isEditablePosition(p))) { |
| 891 Element* root = editableRootElementForPosition(p); | 891 Element* root = rootEditableElementOf(p); |
| 892 shadowAncestor = root ? root->shadowHost() : nullptr; | 892 shadowAncestor = root ? root->shadowHost() : nullptr; |
| 893 p = isAtomicNode(p.computeContainerNode()) ? PositionTemplate<St
rategy>::inParentAfterNode(*p.computeContainerNode()) : nextVisuallyDistinctCand
idate(p); | 893 p = isAtomicNode(p.computeContainerNode()) ? PositionTemplate<St
rategy>::inParentAfterNode(*p.computeContainerNode()) : nextVisuallyDistinctCand
idate(p); |
| 894 if (p.isNull() && shadowAncestor) | 894 if (p.isNull() && shadowAncestor) |
| 895 p = PositionTemplate<Strategy>::beforeNode(shadowAncestor); | 895 p = PositionTemplate<Strategy>::beforeNode(shadowAncestor); |
| 896 } | 896 } |
| 897 const VisiblePositionTemplate<Strategy> next = createVisiblePosition
(p); | 897 const VisiblePositionTemplate<Strategy> next = createVisiblePosition
(p); |
| 898 | 898 |
| 899 if (next.isNull()) { | 899 if (next.isNull()) { |
| 900 // The selection crosses an Editing boundary. This is a | 900 // The selection crosses an Editing boundary. This is a |
| 901 // programmer error in the editing code. Happy debugging! | 901 // programmer error in the editing code. Happy debugging! |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 | 955 |
| 956 template <typename Strategy> | 956 template <typename Strategy> |
| 957 bool VisibleSelectionTemplate<Strategy>::isContentRichlyEditable() const | 957 bool VisibleSelectionTemplate<Strategy>::isContentRichlyEditable() const |
| 958 { | 958 { |
| 959 return isRichlyEditablePosition(toPositionInDOMTree(start())); | 959 return isRichlyEditablePosition(toPositionInDOMTree(start())); |
| 960 } | 960 } |
| 961 | 961 |
| 962 template <typename Strategy> | 962 template <typename Strategy> |
| 963 Element* VisibleSelectionTemplate<Strategy>::rootEditableElement() const | 963 Element* VisibleSelectionTemplate<Strategy>::rootEditableElement() const |
| 964 { | 964 { |
| 965 return editableRootElementForPosition(start()); | 965 return rootEditableElementOf(start()); |
| 966 } | 966 } |
| 967 | 967 |
| 968 template <typename Strategy> | 968 template <typename Strategy> |
| 969 Node* VisibleSelectionTemplate<Strategy>::nonBoundaryShadowTreeRootNode() const | 969 Node* VisibleSelectionTemplate<Strategy>::nonBoundaryShadowTreeRootNode() const |
| 970 { | 970 { |
| 971 return start().anchorNode() && !start().anchorNode()->isShadowRoot() ? start
().anchorNode()->nonBoundaryShadowTreeRootNode() : 0; | 971 return start().anchorNode() && !start().anchorNode()->isShadowRoot() ? start
().anchorNode()->nonBoundaryShadowTreeRootNode() : 0; |
| 972 } | 972 } |
| 973 | 973 |
| 974 VisibleSelectionChangeObserver::VisibleSelectionChangeObserver() | 974 VisibleSelectionChangeObserver::VisibleSelectionChangeObserver() |
| 975 { | 975 { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 { | 1137 { |
| 1138 sel.showTreeForThis(); | 1138 sel.showTreeForThis(); |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 void showTree(const blink::VisibleSelectionInComposedTree* sel) | 1141 void showTree(const blink::VisibleSelectionInComposedTree* sel) |
| 1142 { | 1142 { |
| 1143 if (sel) | 1143 if (sel) |
| 1144 sel->showTreeForThis(); | 1144 sel->showTreeForThis(); |
| 1145 } | 1145 } |
| 1146 #endif | 1146 #endif |
| OLD | NEW |