Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Source/core/editing/EditingStrategy.cpp

Issue 1675163002: Rename ComposedTree to FlatTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/EditingStrategy.h" 5 #include "core/editing/EditingStrategy.h"
6 6
7 #include "core/editing/EditingUtilities.h" 7 #include "core/editing/EditingUtilities.h"
8 #include "core/layout/LayoutObject.h" 8 #include "core/layout/LayoutObject.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 // If a node can contain candidates for VisiblePositions, return the offset of 12 // If a node can contain candidates for VisiblePositions, return the offset of
13 // the last candidate, otherwise return the number of children for container 13 // the last candidate, otherwise return the number of children for container
14 // nodes and the length for unrendered text nodes. 14 // nodes and the length for unrendered text nodes.
15 template <typename Traversal> 15 template <typename Traversal>
16 int EditingAlgorithm<Traversal>::caretMaxOffset(const Node& node) 16 int EditingAlgorithm<Traversal>::caretMaxOffset(const Node& node)
17 { 17 {
18 // For rendered text nodes, return the last position that a caret could 18 // For rendered text nodes, return the last position that a caret could
19 // occupy. 19 // occupy.
20 if (node.isTextNode() && node.layoutObject()) 20 if (node.isTextNode() && node.layoutObject())
21 return node.layoutObject()->caretMaxOffset(); 21 return node.layoutObject()->caretMaxOffset();
22 // For containers return the number of children. For others do the same as 22 // For containers return the number of children. For others do the same as
23 // above. 23 // above.
24 return lastOffsetForEditing(&node); 24 return lastOffsetForEditing(&node);
25 } 25 }
26 26
27 template <typename Traversal> 27 template <typename Traversal>
28 bool EditingAlgorithm<Traversal>::isEmptyNonEditableNodeInEditable(const Node* n ode) 28 bool EditingAlgorithm<Traversal>::isEmptyNonEditableNodeInEditable(const Node* n ode)
29 { 29 {
30 // Editability is defined the DOM tree rather than the composed tree. For ex ample: 30 // Editability is defined the DOM tree rather than the flat tree. For exampl e:
31 // DOM: 31 // DOM:
32 // <host><span>unedittable</span><shadowroot><div ce><content /></div></sh adowroot></host> 32 // <host><span>unedittable</span><shadowroot><div ce><content /></div></sh adowroot></host>
33 // Composed Tree: 33 // Flat Tree:
34 // <host><div ce><span1>unedittable</span></div></host> 34 // <host><div ce><span1>unedittable</span></div></host>
35 // e.g. editing/shadow/breaking-editing-boundaries.html 35 // e.g. editing/shadow/breaking-editing-boundaries.html
36 return !Traversal::hasChildren(*node) && !node->hasEditableStyle() && node-> parentNode() && node->parentNode()->hasEditableStyle(); 36 return !Traversal::hasChildren(*node) && !node->hasEditableStyle() && node-> parentNode() && node->parentNode()->hasEditableStyle();
37 } 37 }
38 38
39 template <typename Traversal> 39 template <typename Traversal>
40 bool EditingAlgorithm<Traversal>::editingIgnoresContent(const Node* node) 40 bool EditingAlgorithm<Traversal>::editingIgnoresContent(const Node* node)
41 { 41 {
42 return !node->canContainRangeEndPoint() || isEmptyNonEditableNodeInEditable( node); 42 return !node->canContainRangeEndPoint() || isEmptyNonEditableNodeInEditable( node);
43 } 43 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 if (!nodeIsUserSelectAll(parent)) 84 if (!nodeIsUserSelectAll(parent))
85 break; 85 break;
86 candidateRoot = parent; 86 candidateRoot = parent;
87 parent = Strategy::parent(*candidateRoot); 87 parent = Strategy::parent(*candidateRoot);
88 } 88 }
89 return candidateRoot; 89 return candidateRoot;
90 } 90 }
91 91
92 template class CORE_TEMPLATE_EXPORT EditingAlgorithm<NodeTraversal>; 92 template class CORE_TEMPLATE_EXPORT EditingAlgorithm<NodeTraversal>;
93 template class CORE_TEMPLATE_EXPORT EditingAlgorithm<ComposedTreeTraversal>; 93 template class CORE_TEMPLATE_EXPORT EditingAlgorithm<FlatTreeTraversal>;
94 94
95 } // namespace blink 95 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698