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 Vector<String>()) {} |
| 20 |
| 21 CompositionUnderline::CompositionUnderline(unsigned startOffset, |
| 22 unsigned endOffset, |
| 23 const Color& color, |
| 24 bool thick, |
| 25 const Color& backgroundColor, |
| 26 const Vector<String>& suggestions) |
| 27 : m_color(color), |
| 28 m_thick(thick), |
| 29 m_backgroundColor(backgroundColor), |
| 30 m_suggestions(suggestions) { |
15 // Sanitize offsets by ensuring a valid range corresponding to the last | 31 // Sanitize offsets by ensuring a valid range corresponding to the last |
16 // possible position. | 32 // possible position. |
17 // TODO(wkorman): Consider replacing with DCHECK_LT(startOffset, endOffset). | 33 // TODO(wkorman): Consider replacing with DCHECK_LT(startOffset, endOffset). |
18 m_startOffset = | 34 m_startOffset = |
19 std::min(startOffset, std::numeric_limits<unsigned>::max() - 1u); | 35 std::min(startOffset, std::numeric_limits<unsigned>::max() - 1u); |
20 m_endOffset = std::max(m_startOffset + 1u, endOffset); | 36 m_endOffset = std::max(m_startOffset + 1u, endOffset); |
21 } | 37 } |
22 | 38 |
23 } // namespace blink | 39 } // namespace blink |
OLD | NEW |