OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/views/controls/prefix_selector.h" | 5 #include "ui/views/controls/prefix_selector.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "ui/base/ime/input_method.h" | 8 #include "ui/base/ime/input_method.h" |
9 #include "ui/base/ime/text_input_type.h" | 9 #include "ui/base/ime/text_input_type.h" |
| 10 #include "ui/display/display.h" |
| 11 #include "ui/display/screen.h" |
10 #include "ui/gfx/range/range.h" | 12 #include "ui/gfx/range/range.h" |
11 #include "ui/views/controls/prefix_delegate.h" | 13 #include "ui/views/controls/prefix_delegate.h" |
12 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
13 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
14 | 16 |
15 namespace views { | 17 namespace views { |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
19 const int64_t kTimeBeforeClearingMS = 1000; | 21 const int64_t kTimeBeforeClearingMS = 1000; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 72 } |
71 | 73 |
72 int PrefixSelector::GetTextInputFlags() const { | 74 int PrefixSelector::GetTextInputFlags() const { |
73 return 0; | 75 return 0; |
74 } | 76 } |
75 | 77 |
76 bool PrefixSelector::CanComposeInline() const { | 78 bool PrefixSelector::CanComposeInline() const { |
77 return false; | 79 return false; |
78 } | 80 } |
79 | 81 |
| 82 float PrefixSelector::GetScaleFactor() const { |
| 83 return display::Screen::GetScreen()->GetDisplayNearestWindow( |
| 84 host_view_->GetWidget()->GetNativeWindow()).device_scale_factor(); |
| 85 } |
| 86 |
80 gfx::Rect PrefixSelector::GetCaretBounds() const { | 87 gfx::Rect PrefixSelector::GetCaretBounds() const { |
81 gfx::Rect rect(host_view_->GetVisibleBounds().origin(), gfx::Size()); | 88 gfx::Rect rect(host_view_->GetVisibleBounds().origin(), gfx::Size()); |
82 // TextInputClient::GetCaretBounds is expected to return a value in screen | 89 // TextInputClient::GetCaretBounds is expected to return a value in screen |
83 // coordinates. | 90 // coordinates. |
84 ConvertRectToScreen(host_view_, &rect); | 91 ConvertRectToScreen(host_view_, &rect); |
85 return rect; | 92 return rect; |
86 } | 93 } |
87 | 94 |
88 bool PrefixSelector::GetCompositionCharacterBounds(uint32_t index, | 95 bool PrefixSelector::GetCompositionCharacterBounds(uint32_t index, |
89 gfx::Rect* rect) const { | 96 gfx::Rect* rect) const { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 return (model_text.size() >= lower_text.size()) && | 199 return (model_text.size() >= lower_text.size()) && |
193 (model_text.compare(0, lower_text.size(), lower_text) == 0); | 200 (model_text.compare(0, lower_text.size(), lower_text) == 0); |
194 } | 201 } |
195 | 202 |
196 void PrefixSelector::ClearText() { | 203 void PrefixSelector::ClearText() { |
197 current_text_.clear(); | 204 current_text_.clear(); |
198 time_of_last_key_ = base::TimeTicks(); | 205 time_of_last_key_ = base::TimeTicks(); |
199 } | 206 } |
200 | 207 |
201 } // namespace views | 208 } // namespace views |
OLD | NEW |