OLD | NEW |
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 #ifndef EditingStrategy_h | 5 #ifndef EditingStrategy_h |
6 #define EditingStrategy_h | 6 #define EditingStrategy_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/dom/NodeTraversal.h" | 9 #include "core/dom/NodeTraversal.h" |
10 #include "core/dom/shadow/FlatTreeTraversal.h" | 10 #include "core/dom/shadow/FlatTreeTraversal.h" |
11 #include "wtf/Allocator.h" | 11 #include "wtf/Allocator.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 template <typename Strategy> | |
16 class PositionTemplate; | |
17 | |
18 template <typename Strategy> | |
19 class PositionIteratorAlgorithm; | |
20 | |
21 // Editing algorithm defined on node traversal. | 15 // Editing algorithm defined on node traversal. |
22 template <typename Traversal> | 16 template <typename Traversal> |
23 class CORE_TEMPLATE_CLASS_EXPORT EditingAlgorithm : public Traversal { | 17 class CORE_TEMPLATE_CLASS_EXPORT EditingAlgorithm : public Traversal { |
24 STATIC_ONLY(EditingAlgorithm); | 18 STATIC_ONLY(EditingAlgorithm); |
25 | 19 |
26 public: | 20 public: |
27 static int caretMaxOffset(const Node&); | 21 static int caretMaxOffset(const Node&); |
28 // This method is used to create positions in the DOM. It returns the | 22 // This method is used to create positions in the DOM. It returns the |
29 // maximum valid offset in a node. It returns 1 for some elements even | 23 // maximum valid offset in a node. It returns 1 for some elements even |
30 // though they do not have children, which creates technically invalid DOM | 24 // though they do not have children, which creates technically invalid DOM |
31 // Positions. Be sure to call |parentAnchoredEquivalent()| on a Position | 25 // Positions. Be sure to call |parentAnchoredEquivalent()| on a Position |
32 // before using it to create a DOM Range, or an exception will be thrown. | 26 // before using it to create a DOM Range, or an exception will be thrown. |
33 static int lastOffsetForEditing(const Node*); | 27 static int lastOffsetForEditing(const Node*); |
34 static Node* rootUserSelectAllForNode(Node*); | 28 static Node* rootUserSelectAllForNode(Node*); |
35 }; | 29 }; |
36 | 30 |
37 extern template class CORE_EXTERN_TEMPLATE_EXPORT | 31 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
38 EditingAlgorithm<NodeTraversal>; | 32 EditingAlgorithm<NodeTraversal>; |
39 extern template class CORE_EXTERN_TEMPLATE_EXPORT | 33 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
40 EditingAlgorithm<FlatTreeTraversal>; | 34 EditingAlgorithm<FlatTreeTraversal>; |
41 | 35 |
42 // DOM tree version of editing algorithm | 36 // DOM tree version of editing algorithm |
43 using EditingStrategy = EditingAlgorithm<NodeTraversal>; | 37 using EditingStrategy = EditingAlgorithm<NodeTraversal>; |
44 // Flat tree version of editing algorithm | 38 // Flat tree version of editing algorithm |
45 using EditingInFlatTreeStrategy = EditingAlgorithm<FlatTreeTraversal>; | 39 using EditingInFlatTreeStrategy = EditingAlgorithm<FlatTreeTraversal>; |
46 | 40 |
47 } // namespace blink | 41 } // namespace blink |
48 | 42 |
49 #endif // EditingStrategy_h | 43 #endif // EditingStrategy_h |
OLD | NEW |