| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
| 3 * Copyright (C) 2005 Alexey Proskuryakov. | 3 * Copyright (C) 2005 Alexey Proskuryakov. |
| 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 template <> | 69 template <> |
| 70 TextIteratorBehaviorFlags adjustBehaviorFlags<EditingStrategy>(TextIteratorBehav
iorFlags flags) | 70 TextIteratorBehaviorFlags adjustBehaviorFlags<EditingStrategy>(TextIteratorBehav
iorFlags flags) |
| 71 { | 71 { |
| 72 if (flags & TextIteratorForSelectionToString) | 72 if (flags & TextIteratorForSelectionToString) |
| 73 return flags | TextIteratorExcludeAutofilledValue; | 73 return flags | TextIteratorExcludeAutofilledValue; |
| 74 return flags; | 74 return flags; |
| 75 } | 75 } |
| 76 | 76 |
| 77 template <> | 77 template <> |
| 78 TextIteratorBehaviorFlags adjustBehaviorFlags<EditingInComposedTreeStrategy>(Tex
tIteratorBehaviorFlags flags) | 78 TextIteratorBehaviorFlags adjustBehaviorFlags<EditingInFlatTreeStrategy>(TextIte
ratorBehaviorFlags flags) |
| 79 { | 79 { |
| 80 if (flags & TextIteratorForSelectionToString) | 80 if (flags & TextIteratorForSelectionToString) |
| 81 flags |= TextIteratorExcludeAutofilledValue; | 81 flags |= TextIteratorExcludeAutofilledValue; |
| 82 return flags & ~(TextIteratorEntersOpenShadowRoots | TextIteratorEntersTextC
ontrols); | 82 return flags & ~(TextIteratorEntersOpenShadowRoots | TextIteratorEntersTextC
ontrols); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // This function is like Range::pastLastNode, except for the fact that it can | 85 // This function is like Range::pastLastNode, except for the fact that it can |
| 86 // climb up out of shadow trees. | 86 // climb up out of shadow trees. |
| 87 template <typename Strategy> | 87 template <typename Strategy> |
| 88 Node* pastLastNode(const Node& rangeEndContainer, int rangeEndOffset) | 88 Node* pastLastNode(const Node& rangeEndContainer, int rangeEndOffset) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 108 { | 108 { |
| 109 const TreeScope* commonAncestorTreeScope = startContainer.treeScope().common
AncestorTreeScope(endContainer.treeScope()); | 109 const TreeScope* commonAncestorTreeScope = startContainer.treeScope().common
AncestorTreeScope(endContainer.treeScope()); |
| 110 ASSERT(commonAncestorTreeScope); | 110 ASSERT(commonAncestorTreeScope); |
| 111 int shadowDepth = 0; | 111 int shadowDepth = 0; |
| 112 for (const TreeScope* treeScope = &startContainer.treeScope(); treeScope !=
commonAncestorTreeScope; treeScope = treeScope->parentTreeScope()) | 112 for (const TreeScope* treeScope = &startContainer.treeScope(); treeScope !=
commonAncestorTreeScope; treeScope = treeScope->parentTreeScope()) |
| 113 ++shadowDepth; | 113 ++shadowDepth; |
| 114 return shadowDepth; | 114 return shadowDepth; |
| 115 } | 115 } |
| 116 | 116 |
| 117 template <> | 117 template <> |
| 118 int shadowDepthOf<EditingInComposedTreeStrategy>(const Node& startContainer, con
st Node& endContainer) | 118 int shadowDepthOf<EditingInFlatTreeStrategy>(const Node& startContainer, const N
ode& endContainer) |
| 119 { | 119 { |
| 120 return 0; | 120 return 0; |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace | 123 } // namespace |
| 124 | 124 |
| 125 template<typename Strategy> | 125 template<typename Strategy> |
| 126 TextIteratorAlgorithm<Strategy>::TextIteratorAlgorithm(const PositionTemplate<St
rategy>& start, const PositionTemplate<Strategy>& end, TextIteratorBehaviorFlags
behavior) | 126 TextIteratorAlgorithm<Strategy>::TextIteratorAlgorithm(const PositionTemplate<St
rategy>& start, const PositionTemplate<Strategy>& end, TextIteratorBehaviorFlags
behavior) |
| 127 : m_offset(0) | 127 : m_offset(0) |
| 128 , m_startContainer(nullptr) | 128 , m_startContainer(nullptr) |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 if (m_textState.positionNode()) | 332 if (m_textState.positionNode()) |
| 333 return; | 333 return; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 | 336 |
| 337 // Find a new current node to handle in depth-first manner, | 337 // Find a new current node to handle in depth-first manner, |
| 338 // calling exitNode() as we come back thru a parent node. | 338 // calling exitNode() as we come back thru a parent node. |
| 339 // | 339 // |
| 340 // 1. Iterate over child nodes, if we haven't done yet. | 340 // 1. Iterate over child nodes, if we haven't done yet. |
| 341 // To support |TextIteratorEmitsImageAltText|, we don't traversal child | 341 // To support |TextIteratorEmitsImageAltText|, we don't traversal child |
| 342 // nodes, in composed tree. | 342 // nodes, in flat tree. |
| 343 Node* next = m_iterationProgress < HandledChildren && !isHTMLImageElemen
t(*m_node) ? Strategy::firstChild(*m_node) : nullptr; | 343 Node* next = m_iterationProgress < HandledChildren && !isHTMLImageElemen
t(*m_node) ? Strategy::firstChild(*m_node) : nullptr; |
| 344 m_offset = 0; | 344 m_offset = 0; |
| 345 if (!next) { | 345 if (!next) { |
| 346 // 2. If we've already iterated children or they are not available,
go to the next sibling node. | 346 // 2. If we've already iterated children or they are not available,
go to the next sibling node. |
| 347 next = Strategy::nextSibling(*m_node); | 347 next = Strategy::nextSibling(*m_node); |
| 348 if (!next) { | 348 if (!next) { |
| 349 // 3. If we are at the last child, go up the node tree until we
find a next sibling. | 349 // 3. If we are at the last child, go up the node tree until we
find a next sibling. |
| 350 bool pastEnd = Strategy::next(*m_node) == m_pastEndNode; | 350 bool pastEnd = Strategy::next(*m_node) == m_pastEndNode; |
| 351 ContainerNode* parentNode = Strategy::parent(*m_node); | 351 ContainerNode* parentNode = Strategy::parent(*m_node); |
| 352 while (!next && parentNode) { | 352 while (!next && parentNode) { |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 return emptyString(); | 1158 return emptyString(); |
| 1159 | 1159 |
| 1160 return builder.toString(); | 1160 return builder.toString(); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 String plainText(const EphemeralRange& range, TextIteratorBehaviorFlags behavior
) | 1163 String plainText(const EphemeralRange& range, TextIteratorBehaviorFlags behavior
) |
| 1164 { | 1164 { |
| 1165 return createPlainText<EditingStrategy>(range, behavior); | 1165 return createPlainText<EditingStrategy>(range, behavior); |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 String plainText(const EphemeralRangeInComposedTree& range, TextIteratorBehavior
Flags behavior) | 1168 String plainText(const EphemeralRangeInFlatTree& range, TextIteratorBehaviorFlag
s behavior) |
| 1169 { | 1169 { |
| 1170 return createPlainText<EditingInComposedTreeStrategy>(range, behavior); | 1170 return createPlainText<EditingInFlatTreeStrategy>(range, behavior); |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; | 1173 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; |
| 1174 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS
trategy>; | 1174 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInFlatTreeStrat
egy>; |
| 1175 | 1175 |
| 1176 } // namespace blink | 1176 } // namespace blink |
| OLD | NEW |