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