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

Side by Side Diff: Source/core/editing/VisiblePosition.h

Issue 1319753004: Introduce composed tree version of VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-07T14:06:02 Rebase for VisibleSelectionChangeObserver and PendingSelection::commit Created 5 years, 3 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
« no previous file with comments | « Source/core/editing/SelectionController.cpp ('k') | Source/core/editing/VisiblePosition.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // 67 //
68 // NOTE: UPSTREAM affinity will be used only if pos is at end of a wrapped line, 68 // NOTE: UPSTREAM affinity will be used only if pos is at end of a wrapped line,
69 // otherwise it will be converted to DOWNSTREAM. 69 // otherwise it will be converted to DOWNSTREAM.
70 template <typename Strategy> 70 template <typename Strategy>
71 class CORE_TEMPLATE_CLASS_EXPORT VisiblePositionTemplate final { 71 class CORE_TEMPLATE_CLASS_EXPORT VisiblePositionTemplate final {
72 DISALLOW_ALLOCATION(); 72 DISALLOW_ALLOCATION();
73 public: 73 public:
74 VisiblePositionTemplate(); 74 VisiblePositionTemplate();
75 75
76 // Node: Other than |createVisiblePosition()|, we should not use 76 // Node: Other than |createVisiblePosition()|, we should not use
77 // |createWithoutCanonicalization()|. 77 // |create()|.
78 static VisiblePositionTemplate createWithoutCanonicalization(const PositionW ithAffinityTemplate<Strategy>& canonicalized); 78 static VisiblePositionTemplate create(const PositionWithAffinityTemplate<Str ategy>&);
79 79
80 // Intentionally delete |operator==()| and |operator!=()| for reducing 80 // Intentionally delete |operator==()| and |operator!=()| for reducing
81 // compilation error message. 81 // compilation error message.
82 // TODO(yosin) We'll have |equals()| when we have use cases of checking 82 // TODO(yosin) We'll have |equals()| when we have use cases of checking
83 // equality of both position and affinity. 83 // equality of both position and affinity.
84 bool operator==(const VisiblePositionTemplate&) const = delete; 84 bool operator==(const VisiblePositionTemplate&) const = delete;
85 bool operator!=(const VisiblePositionTemplate&) const = delete; 85 bool operator!=(const VisiblePositionTemplate&) const = delete;
86 86
87 bool isNull() const { return m_positionWithAffinity.isNull(); } 87 bool isNull() const { return m_positionWithAffinity.isNull(); }
88 bool isNotNull() const { return m_positionWithAffinity.isNotNull(); } 88 bool isNotNull() const { return m_positionWithAffinity.isNotNull(); }
(...skipping 15 matching lines...) Expand all
104 void showTreeForThis() const; 104 void showTreeForThis() const;
105 #endif 105 #endif
106 106
107 private: 107 private:
108 explicit VisiblePositionTemplate(const PositionWithAffinityTemplate<Strategy >&); 108 explicit VisiblePositionTemplate(const PositionWithAffinityTemplate<Strategy >&);
109 109
110 PositionWithAffinityTemplate<Strategy> m_positionWithAffinity; 110 PositionWithAffinityTemplate<Strategy> m_positionWithAffinity;
111 }; 111 };
112 112
113 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisiblePositionTemplate<Editin gStrategy>; 113 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisiblePositionTemplate<Editin gStrategy>;
114 extern template class CORE_EXTERN_TEMPLATE_EXPORT VisiblePositionTemplate<Editin gInComposedTreeStrategy>;
114 115
115 using VisiblePosition = VisiblePositionTemplate<EditingStrategy>; 116 using VisiblePosition = VisiblePositionTemplate<EditingStrategy>;
117 using VisiblePositionInComposedTree = VisiblePositionTemplate<EditingInComposedT reeStrategy>;
116 118
117 CORE_EXPORT VisiblePosition createVisiblePosition(const Position&, TextAffinity = VP_DEFAULT_AFFINITY); 119 CORE_EXPORT VisiblePosition createVisiblePosition(const Position&, TextAffinity = VP_DEFAULT_AFFINITY);
118 CORE_EXPORT VisiblePosition createVisiblePosition(const PositionWithAffinity&); 120 CORE_EXPORT VisiblePosition createVisiblePosition(const PositionWithAffinity&);
119 CORE_EXPORT VisiblePosition createVisiblePosition(const PositionInComposedTree&, TextAffinity = VP_DEFAULT_AFFINITY); 121 CORE_EXPORT VisiblePositionInComposedTree createVisiblePosition(const PositionIn ComposedTree&, TextAffinity = VP_DEFAULT_AFFINITY);
122
123 // TODO(yosin) Once we have composed tree version of VisibleUnits, we should not
124 // use |createVisiblePositionInDOMTree()|.
125 VisiblePosition createVisiblePositionInDOMTree(const Position&, TextAffinity = V P_DEFAULT_AFFINITY);
126 VisiblePosition createVisiblePositionInDOMTree(const PositionInComposedTree&, Te xtAffinity = VP_DEFAULT_AFFINITY);
120 127
121 } // namespace blink 128 } // namespace blink
122 129
123 #ifndef NDEBUG 130 #ifndef NDEBUG
124 // Outside the WebCore namespace for ease of invocation from gdb. 131 // Outside the WebCore namespace for ease of invocation from gdb.
125 void showTree(const blink::VisiblePosition*); 132 void showTree(const blink::VisiblePosition*);
126 void showTree(const blink::VisiblePosition&); 133 void showTree(const blink::VisiblePosition&);
127 #endif 134 #endif
128 135
129 #endif // VisiblePosition_h 136 #endif // VisiblePosition_h
OLDNEW
« no previous file with comments | « Source/core/editing/SelectionController.cpp ('k') | Source/core/editing/VisiblePosition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698