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