OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CompositionMarker_h | 5 #ifndef CompositionMarker_h |
6 #define CompositionMarker_h | 6 #define CompositionMarker_h |
7 | 7 |
8 #include "core/editing/markers/DocumentMarker.h" | 8 #include "core/editing/markers/StyleableMarker.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 // A subclass of DocumentMarker used to store information specific to | 12 // A subclass of DocumentMarker used to store information specific to |
13 // composition markers. We store what color to display the underline (possibly | 13 // composition markers. We store what color to display the underline (possibly |
14 // transparent), whether the underline should be thick or not, and what | 14 // transparent), whether the underline should be thick or not, and what |
15 // background color should be used under the marked text (also possibly | 15 // background color should be used under the marked text (also possibly |
16 // transparent). | 16 // transparent). |
17 class CORE_EXPORT CompositionMarker final : public DocumentMarker { | 17 class CORE_EXPORT CompositionMarker final : public StyleableMarker { |
18 public: | 18 public: |
19 enum class Thickness { kThin, kThick }; | |
20 | |
21 CompositionMarker(unsigned start_offset, | 19 CompositionMarker(unsigned start_offset, |
22 unsigned end_offset, | 20 unsigned end_offset, |
23 Color underline_color, | 21 Color underline_color, |
24 Thickness, | 22 Thickness, |
25 Color background_color); | 23 Color background_color); |
26 | 24 |
27 // DocumentMarker implementations | 25 // DocumentMarker implementations |
28 MarkerType GetType() const final; | 26 MarkerType GetType() const final; |
29 | 27 |
30 // CompositionMarker-specific | |
31 Color UnderlineColor() const; | |
32 bool IsThick() const; | |
33 Color BackgroundColor() const; | |
34 | |
35 private: | 28 private: |
36 const Color underline_color_; | |
37 const Color background_color_; | |
38 const Thickness thickness_; | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(CompositionMarker); | 29 DISALLOW_COPY_AND_ASSIGN(CompositionMarker); |
41 }; | 30 }; |
42 | 31 |
43 DEFINE_TYPE_CASTS(CompositionMarker, | 32 DEFINE_TYPE_CASTS(CompositionMarker, |
44 DocumentMarker, | 33 DocumentMarker, |
45 marker, | 34 marker, |
46 marker->GetType() == DocumentMarker::kComposition, | 35 marker->GetType() == DocumentMarker::kComposition, |
47 marker.GetType() == DocumentMarker::kComposition); | 36 marker.GetType() == DocumentMarker::kComposition); |
48 | 37 |
49 } // namespace blink | 38 } // namespace blink |
50 | 39 |
51 #endif | 40 #endif |
OLD | NEW |