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

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

Issue 2627423002: Make FrameCaret contains CaretBase instead of deriving from it (Closed)
Patch Set: 2017-01-16T16:55:39 Created 3 years, 11 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 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef FrameCaret_h 26 #ifndef FrameCaret_h
27 #define FrameCaret_h 27 #define FrameCaret_h
28 28
29 #include "core/CoreExport.h" 29 #include "core/CoreExport.h"
30 #include "core/editing/CaretBase.h" 30 #include "core/editing/PositionWithAffinity.h"
31 #include "platform/geometry/IntRect.h" 31 #include "platform/Timer.h"
32 #include "platform/geometry/LayoutRect.h"
33 #include "platform/heap/GarbageCollected.h"
34 #include "platform/heap/Member.h"
35 #include <memory>
32 36
33 namespace blink { 37 namespace blink {
34 38
39 class CaretBase;
40 class CharacterData;
41 class DisplayItemClient;
42 class Document;
43 class GraphicsContext;
44 class Node;
45 class LocalFrame;
35 class SelectionEditor; 46 class SelectionEditor;
36 47
37 enum class CaretVisibility { Visible, Hidden }; 48 enum class CaretVisibility { Visible, Hidden };
38 49
39 class CORE_EXPORT FrameCaret final : public CaretBase { 50 class CORE_EXPORT FrameCaret final
51 : public GarbageCollectedFinalized<FrameCaret> {
40 public: 52 public:
41 FrameCaret(LocalFrame&, const SelectionEditor&); 53 FrameCaret(LocalFrame&, const SelectionEditor&);
42 ~FrameCaret() override; 54 ~FrameCaret();
43 55
56 const DisplayItemClient& displayItemClient() const;
44 bool isActive() const { return caretPosition().isNotNull(); } 57 bool isActive() const { return caretPosition().isNotNull(); }
45 58
46 void updateAppearance(); 59 void updateAppearance();
47 60
48 // Used to suspend caret blinking while the mouse is down. 61 // Used to suspend caret blinking while the mouse is down.
49 void setCaretBlinkingSuspended(bool suspended) { 62 void setCaretBlinkingSuspended(bool suspended) {
50 m_isCaretBlinkingSuspended = suspended; 63 m_isCaretBlinkingSuspended = suspended;
51 } 64 }
52 bool isCaretBlinkingSuspended() const { return m_isCaretBlinkingSuspended; } 65 bool isCaretBlinkingSuspended() const { return m_isCaretBlinkingSuspended; }
53 void stopCaretBlinkTimer(); 66 void stopCaretBlinkTimer();
(...skipping 14 matching lines...) Expand all
68 81
69 void dataWillChange(const CharacterData&); 82 void dataWillChange(const CharacterData&);
70 void nodeWillBeRemoved(Node&); 83 void nodeWillBeRemoved(Node&);
71 84
72 void documentDetached(); 85 void documentDetached();
73 86
74 // For unittests 87 // For unittests
75 bool shouldPaintCaretForTesting() const { return m_shouldPaintCaret; } 88 bool shouldPaintCaretForTesting() const { return m_shouldPaintCaret; }
76 bool isPreviousCaretDirtyForTesting() const { return m_previousCaretNode; } 89 bool isPreviousCaretDirtyForTesting() const { return m_previousCaretNode; }
77 90
78 DECLARE_VIRTUAL_TRACE(); 91 DECLARE_TRACE();
79 92
80 private: 93 private:
81 friend class FrameSelectionTest; 94 friend class FrameSelectionTest;
82 95
83 const PositionWithAffinity caretPosition() const; 96 const PositionWithAffinity caretPosition() const;
84 97
85 bool shouldBlinkCaret() const; 98 bool shouldBlinkCaret() const;
86 void caretBlinkTimerFired(TimerBase*); 99 void caretBlinkTimerFired(TimerBase*);
87 bool caretPositionIsValidForDocument(const Document&) const; 100 bool caretPositionIsValidForDocument(const Document&) const;
88 101
89 const Member<const SelectionEditor> m_selectionEditor; 102 const Member<const SelectionEditor> m_selectionEditor;
90 const Member<LocalFrame> m_frame; 103 const Member<LocalFrame> m_frame;
104 const std::unique_ptr<CaretBase> m_caretBase;
91 // The last node which painted the caret. Retained for clearing the old 105 // The last node which painted the caret. Retained for clearing the old
92 // caret when it moves. 106 // caret when it moves.
93 Member<Node> m_previousCaretNode; 107 Member<Node> m_previousCaretNode;
94 Member<Node> m_previousCaretAnchorNode; 108 Member<Node> m_previousCaretAnchorNode;
95 LayoutRect m_previousCaretRect; 109 LayoutRect m_previousCaretRect;
96 CaretVisibility m_caretVisibility; 110 CaretVisibility m_caretVisibility;
97 CaretVisibility m_previousCaretVisibility; 111 CaretVisibility m_previousCaretVisibility;
98 // TODO(https://crbug.com/668758): Consider using BeginFrame update for this. 112 // TODO(https://crbug.com/668758): Consider using BeginFrame update for this.
99 TaskRunnerTimer<FrameCaret> m_caretBlinkTimer; 113 TaskRunnerTimer<FrameCaret> m_caretBlinkTimer;
100 bool m_caretRectDirty : 1; 114 bool m_caretRectDirty : 1;
101 bool m_shouldPaintCaret : 1; 115 bool m_shouldPaintCaret : 1;
102 bool m_isCaretBlinkingSuspended : 1; 116 bool m_isCaretBlinkingSuspended : 1;
103 bool m_shouldShowBlockCursor : 1; 117 bool m_shouldShowBlockCursor : 1;
104 }; 118 };
105 119
106 } // namespace blink 120 } // namespace blink
107 121
108 #endif // FrameCaret_h 122 #endif // FrameCaret_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/DragCaretController.cpp ('k') | third_party/WebKit/Source/core/editing/FrameCaret.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698