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

Side by Side Diff: third_party/WebKit/Source/core/editing/GranularityStrategy.h

Issue 2735143002: Make GranularityStrategy::updateExtent() to return SelectionInDOM instead of VisibleSelection (Closed)
Patch Set: 2017-03-09T16:45:24 rebase Created 3 years, 9 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
OLDNEW
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 GranularityStrategy_h 5 #ifndef GranularityStrategy_h
6 #define GranularityStrategy_h 6 #define GranularityStrategy_h
7 7
8 #include "core/editing/SelectionStrategy.h" 8 #include "core/editing/SelectionStrategy.h"
9 #include "core/editing/VisibleSelection.h" 9 #include "core/editing/SelectionTemplate.h"
10 #include "wtf/Allocator.h" 10 #include "wtf/Allocator.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class GranularityStrategy { 14 class GranularityStrategy {
15 USING_FAST_MALLOC(GranularityStrategy); 15 USING_FAST_MALLOC(GranularityStrategy);
16 16
17 public: 17 public:
18 virtual ~GranularityStrategy(); 18 virtual ~GranularityStrategy();
19 virtual SelectionStrategy GetType() const = 0; 19 virtual SelectionStrategy GetType() const = 0;
20 virtual void Clear() = 0; 20 virtual void Clear() = 0;
21 21
22 // Calculates and returns the new selection based on the updated extent 22 // Calculates and returns the new selection based on the updated extent
23 // location in absolute coordinates. 23 // location in absolute coordinates.
24 virtual VisibleSelection updateExtent(const IntPoint&, LocalFrame*) = 0; 24 virtual SelectionInDOMTree updateExtent(const IntPoint&, LocalFrame*) = 0;
25 25
26 protected: 26 protected:
27 GranularityStrategy(); 27 GranularityStrategy();
28 }; 28 };
29 29
30 // Always uses character granularity. 30 // Always uses character granularity.
31 class CharacterGranularityStrategy final : public GranularityStrategy { 31 class CharacterGranularityStrategy final : public GranularityStrategy {
32 public: 32 public:
33 CharacterGranularityStrategy(); 33 CharacterGranularityStrategy();
34 ~CharacterGranularityStrategy() final; 34 ~CharacterGranularityStrategy() final;
35 35
36 // GranularityStrategy: 36 // GranularityStrategy:
37 SelectionStrategy GetType() const final; 37 SelectionStrategy GetType() const final;
38 void Clear() final; 38 void Clear() final;
39 VisibleSelection updateExtent(const IntPoint&, LocalFrame*) final; 39 SelectionInDOMTree updateExtent(const IntPoint&, LocalFrame*) final;
40 }; 40 };
41 41
42 // "Expand by word, shrink by character" selection strategy. 42 // "Expand by word, shrink by character" selection strategy.
43 // Uses character granularity when selection is shrinking. If the selection is 43 // Uses character granularity when selection is shrinking. If the selection is
44 // expanding, granularity doesn't change until a word boundary is passed, after 44 // expanding, granularity doesn't change until a word boundary is passed, after
45 // which the granularity switches to "word". 45 // which the granularity switches to "word".
46 // In word granularity, the word is not selected until the extent point passes 46 // In word granularity, the word is not selected until the extent point passes
47 // the middle of the word. 47 // the middle of the word.
48 // 48 //
49 // The "offset" feature: 49 // The "offset" feature:
(...skipping 27 matching lines...) Expand all
77 // Move forward one character. End moves with extent in character granularity. 77 // Move forward one character. End moves with extent in character granularity.
78 // Lorem ip^sum dolor|> sit amet, consectetur 78 // Lorem ip^sum dolor|> sit amet, consectetur
79 class DirectionGranularityStrategy final : public GranularityStrategy { 79 class DirectionGranularityStrategy final : public GranularityStrategy {
80 public: 80 public:
81 DirectionGranularityStrategy(); 81 DirectionGranularityStrategy();
82 ~DirectionGranularityStrategy() final; 82 ~DirectionGranularityStrategy() final;
83 83
84 // GranularityStrategy: 84 // GranularityStrategy:
85 SelectionStrategy GetType() const final; 85 SelectionStrategy GetType() const final;
86 void Clear() final; 86 void Clear() final;
87 VisibleSelection updateExtent(const IntPoint&, LocalFrame*) final; 87 SelectionInDOMTree updateExtent(const IntPoint&, LocalFrame*) final;
88 88
89 private: 89 private:
90 enum class StrategyState { 90 enum class StrategyState {
91 // Starting state. 91 // Starting state.
92 // Selection was cleared and there were no extent updates since then. 92 // Selection was cleared and there were no extent updates since then.
93 // One an update is performed, the strategy goes into the Expanding 93 // One an update is performed, the strategy goes into the Expanding
94 // state unless the update shrinks the selection without changing 94 // state unless the update shrinks the selection without changing
95 // relative base/extent order, in which case the strategy goes into the 95 // relative base/extent order, in which case the strategy goes into the
96 // Shrinking state. 96 // Shrinking state.
97 Cleared, 97 Cleared,
(...skipping 16 matching lines...) Expand all
114 114
115 // This defines location of the offset-adjusted extent point (from the 115 // This defines location of the offset-adjusted extent point (from the
116 // latest updateExtent call) relative to the location of extent's 116 // latest updateExtent call) relative to the location of extent's
117 // VisiblePosition. It is used to detect sub-position extent movement. 117 // VisiblePosition. It is used to detect sub-position extent movement.
118 IntSize m_diffExtentPointFromExtentPosition; 118 IntSize m_diffExtentPointFromExtentPosition;
119 }; 119 };
120 120
121 } // namespace blink 121 } // namespace blink
122 122
123 #endif // GranularityStrategy_h 123 #endif // GranularityStrategy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698