1// Copyright (c) 2012 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#ifndef UI_BASE_IME_COMPOSITION_UNDERLINE_H_
6#define UI_BASE_IME_COMPOSITION_UNDERLINE_H_
7
8#include <vector>
9
10#include "base/basictypes.h"
11#include "third_party/skia/include/core/SkColor.h"
12
13namespace ui {
14
15// Intentionally keep sync with blink::WebCompositionUnderline defined in:
16// third_party/WebKit/public/web/WebCompositionUnderline.h
17struct CompositionUnderline {
18  CompositionUnderline()
19      : start_offset(0),
20        end_offset(0),
21        color(SK_ColorTRANSPARENT),
22        thick(false),
23        background_color(SK_ColorTRANSPARENT) {}
24
25  // TODO(huangs): remove this constructor.
26  CompositionUnderline(uint32 s, uint32 e, SkColor c, bool t)
27      : start_offset(s),
28        end_offset(e),
29        color(c),
30        thick(t),
31        background_color(SK_ColorTRANSPARENT) {}
32
33  CompositionUnderline(uint32 s, uint32 e, SkColor c, bool t, SkColor bc)
34      : start_offset(s),
35        end_offset(e),
36        color(c),
37        thick(t),
38        background_color(bc) {}
39
40  bool operator==(const CompositionUnderline& rhs) const {
41    return (this->start_offset == rhs.start_offset) &&
42           (this->end_offset == rhs.end_offset) && (this->color == rhs.color) &&
43           (this->thick == rhs.thick) &&
44           (this->background_color == rhs.background_color);
45  }
46
47  bool operator!=(const CompositionUnderline& rhs) const {
48    return !(*this == rhs);
49  }
50
51  uint32 start_offset;
52  uint32 end_offset;
53  SkColor color;
54  bool thick;
55  SkColor background_color;
56};
57
58typedef std::vector<CompositionUnderline> CompositionUnderlines;
59
60}  // namespace ui
61
62#endif  // UI_BASE_IME_COMPOSITION_UNDERLINE_H_
63