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
3 // found in the LICENSE file.
4 
5 #include "third_party/blink/renderer/core/editing/markers/styleable_marker.h"
6 
7 using ui::mojom::ImeTextSpanThickness;
8 using ui::mojom::ImeTextSpanUnderlineStyle;
9 
10 namespace blink {
11 
StyleableMarker(unsigned start_offset,unsigned end_offset,Color underline_color,ImeTextSpanThickness thickness,ImeTextSpanUnderlineStyle underline_style,Color text_color,Color background_color)12 StyleableMarker::StyleableMarker(unsigned start_offset,
13                                  unsigned end_offset,
14                                  Color underline_color,
15                                  ImeTextSpanThickness thickness,
16                                  ImeTextSpanUnderlineStyle underline_style,
17                                  Color text_color,
18                                  Color background_color)
19     : DocumentMarker(start_offset, end_offset),
20       underline_color_(underline_color),
21       background_color_(background_color),
22       thickness_(thickness),
23       underline_style_(underline_style),
24       text_color_(text_color) {}
25 
UnderlineColor() const26 Color StyleableMarker::UnderlineColor() const {
27   return underline_color_;
28 }
29 
HasThicknessNone() const30 bool StyleableMarker::HasThicknessNone() const {
31   return thickness_ == ImeTextSpanThickness::kNone;
32 }
33 
HasThicknessThin() const34 bool StyleableMarker::HasThicknessThin() const {
35   return thickness_ == ImeTextSpanThickness::kThin;
36 }
37 
HasThicknessThick() const38 bool StyleableMarker::HasThicknessThick() const {
39   return thickness_ == ImeTextSpanThickness::kThick;
40 }
41 
UnderlineStyle() const42 ui::mojom::ImeTextSpanUnderlineStyle StyleableMarker::UnderlineStyle() const {
43   return underline_style_;
44 }
45 
TextColor() const46 Color StyleableMarker::TextColor() const {
47   return text_color_;
48 }
49 
UseTextColor() const50 bool StyleableMarker::UseTextColor() const {
51   return thickness_ != ImeTextSpanThickness::kNone &&
52          underline_color_ == Color::kTransparent;
53 }
54 
BackgroundColor() const55 Color StyleableMarker::BackgroundColor() const {
56   return background_color_;
57 }
58 
IsStyleableMarker(const DocumentMarker & marker)59 bool IsStyleableMarker(const DocumentMarker& marker) {
60   DocumentMarker::MarkerType type = marker.GetType();
61   return type == DocumentMarker::kComposition ||
62          type == DocumentMarker::kActiveSuggestion ||
63          type == DocumentMarker::kSuggestion;
64 }
65 
66 }  // namespace blink
67