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> | 15 template <typename Strategy> |
16 class PositionTemplate; | 16 class PositionTemplate; |
17 | 17 |
18 template <typename Strategy> | 18 template <typename Strategy> |
19 class PositionIteratorAlgorithm; | 19 class PositionIteratorAlgorithm; |
20 | 20 |
21 // Editing algorithm defined on node traversal. | 21 // Editing algorithm defined on node traversal. |
22 template <typename Traversal> | 22 template <typename Traversal> |
23 class CORE_TEMPLATE_CLASS_EXPORT EditingAlgorithm : public Traversal { | 23 class CORE_TEMPLATE_CLASS_EXPORT EditingAlgorithm : public Traversal { |
24 STATIC_ONLY(EditingAlgorithm); | 24 STATIC_ONLY(EditingAlgorithm); |
25 | 25 |
26 public: | 26 public: |
27 static int caretMaxOffset(const Node&); | 27 static int caretMaxOffset(const Node&); |
28 // TODO(yosin) We should make following functions to take |Node&| instead | |
29 // of |Node*|. | |
30 static bool isEmptyNonEditableNodeInEditable(const Node*); | |
31 static bool editingIgnoresContent(const Node*); | |
32 | |
33 // This method is used to create positions in the DOM. It returns the | 28 // This method is used to create positions in the DOM. It returns the |
34 // maximum valid offset in a node. It returns 1 for some elements even | 29 // maximum valid offset in a node. It returns 1 for some elements even |
35 // though they do not have children, which creates technically invalid DOM | 30 // though they do not have children, which creates technically invalid DOM |
36 // Positions. Be sure to call |parentAnchoredEquivalent()| on a Position | 31 // Positions. Be sure to call |parentAnchoredEquivalent()| on a Position |
37 // before using it to create a DOM Range, or an exception will be thrown. | 32 // before using it to create a DOM Range, or an exception will be thrown. |
38 static int lastOffsetForEditing(const Node*); | 33 static int lastOffsetForEditing(const Node*); |
39 static Node* rootUserSelectAllForNode(Node*); | 34 static Node* rootUserSelectAllForNode(Node*); |
40 }; | 35 }; |
41 | 36 |
42 extern template class CORE_EXTERN_TEMPLATE_EXPORT | 37 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
43 EditingAlgorithm<NodeTraversal>; | 38 EditingAlgorithm<NodeTraversal>; |
44 extern template class CORE_EXTERN_TEMPLATE_EXPORT | 39 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
45 EditingAlgorithm<FlatTreeTraversal>; | 40 EditingAlgorithm<FlatTreeTraversal>; |
46 | 41 |
47 // DOM tree version of editing algorithm | 42 // DOM tree version of editing algorithm |
48 using EditingStrategy = EditingAlgorithm<NodeTraversal>; | 43 using EditingStrategy = EditingAlgorithm<NodeTraversal>; |
49 // Flat tree version of editing algorithm | 44 // Flat tree version of editing algorithm |
50 using EditingInFlatTreeStrategy = EditingAlgorithm<FlatTreeTraversal>; | 45 using EditingInFlatTreeStrategy = EditingAlgorithm<FlatTreeTraversal>; |
51 | 46 |
52 } // namespace blink | 47 } // namespace blink |
53 | 48 |
54 #endif // EditingStrategy_h | 49 #endif // EditingStrategy_h |
OLD | NEW |