OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "core/editing/CompositionUnderline.h" | 5 #include "core/editing/CompositionUnderline.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 CompositionUnderline::CompositionUnderline(unsigned startOffset, | 9 CompositionUnderline::CompositionUnderline(unsigned startOffset, |
10 unsigned endOffset, | 10 unsigned endOffset, |
11 const Color& color, | 11 const Color& color, |
12 bool thick, | 12 bool thick, |
13 const Color& backgroundColor) | 13 const Color& backgroundColor) |
14 : m_color(color), m_thick(thick), m_backgroundColor(backgroundColor) { | 14 : CompositionUnderline(startOffset, |
| 15 endOffset, |
| 16 color, |
| 17 thick, |
| 18 backgroundColor, |
| 19 std::vector<std::string>()) {} |
| 20 |
| 21 CompositionUnderline::CompositionUnderline( |
| 22 unsigned startOffset, |
| 23 unsigned endOffset, |
| 24 const Color& color, |
| 25 bool thick, |
| 26 const Color& backgroundColor, |
| 27 const std::vector<std::string>& suggestions) |
| 28 : m_color(color), |
| 29 m_thick(thick), |
| 30 m_backgroundColor(backgroundColor), |
| 31 m_suggestions(suggestions) { |
15 // Sanitize offsets by ensuring a valid range corresponding to the last | 32 // Sanitize offsets by ensuring a valid range corresponding to the last |
16 // possible position. | 33 // possible position. |
17 // TODO(wkorman): Consider replacing with DCHECK_LT(startOffset, endOffset). | 34 // TODO(wkorman): Consider replacing with DCHECK_LT(startOffset, endOffset). |
18 m_startOffset = | 35 m_startOffset = |
19 std::min(startOffset, std::numeric_limits<unsigned>::max() - 1u); | 36 std::min(startOffset, std::numeric_limits<unsigned>::max() - 1u); |
20 m_endOffset = std::max(m_startOffset + 1u, endOffset); | 37 m_endOffset = std::max(m_startOffset + 1u, endOffset); |
21 } | 38 } |
22 | 39 |
23 } // namespace blink | 40 } // namespace blink |
OLD | NEW |