| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/textfield/textfield.h" | 5 #include "views/controls/textfield/textfield.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return native_wrapper_->GetSelectedText(); | 151 return native_wrapper_->GetSelectedText(); |
| 152 return string16(); | 152 return string16(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void Textfield::ClearSelection() const { | 155 void Textfield::ClearSelection() const { |
| 156 if (native_wrapper_) | 156 if (native_wrapper_) |
| 157 native_wrapper_->ClearSelection(); | 157 native_wrapper_->ClearSelection(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool Textfield::HasSelection() const { | 160 bool Textfield::HasSelection() const { |
| 161 gfx::SelectionModel sel; | 161 ui::Range range; |
| 162 if (native_wrapper_) | 162 if (native_wrapper_) |
| 163 native_wrapper_->GetSelectionModel(&sel); | 163 native_wrapper_->GetSelectedRange(&range); |
| 164 return sel.selection_start() != sel.selection_end(); | 164 return !range.is_empty(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void Textfield::SetTextColor(SkColor color) { | 167 void Textfield::SetTextColor(SkColor color) { |
| 168 text_color_ = color; | 168 text_color_ = color; |
| 169 use_default_text_color_ = false; | 169 use_default_text_color_ = false; |
| 170 if (native_wrapper_) | 170 if (native_wrapper_) |
| 171 native_wrapper_->UpdateTextColor(); | 171 native_wrapper_->UpdateTextColor(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void Textfield::UseDefaultTextColor() { | 174 void Textfield::UseDefaultTextColor() { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (controller_) | 261 if (controller_) |
| 262 controller_->ContentsChanged(this, text_); | 262 controller_->ContentsChanged(this, text_); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 bool Textfield::IsIMEComposing() const { | 267 bool Textfield::IsIMEComposing() const { |
| 268 return native_wrapper_ && native_wrapper_->IsIMEComposing(); | 268 return native_wrapper_ && native_wrapper_->IsIMEComposing(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void Textfield::GetSelectedRange(ui::Range* range) const { |
| 272 DCHECK(native_wrapper_); |
| 273 native_wrapper_->GetSelectedRange(range); |
| 274 } |
| 275 |
| 276 void Textfield::SelectRange(const ui::Range& range) { |
| 277 DCHECK(native_wrapper_); |
| 278 native_wrapper_->SelectRange(range); |
| 279 } |
| 280 |
| 271 void Textfield::GetSelectionModel(gfx::SelectionModel* sel) const { | 281 void Textfield::GetSelectionModel(gfx::SelectionModel* sel) const { |
| 272 DCHECK(native_wrapper_); | 282 DCHECK(native_wrapper_); |
| 273 native_wrapper_->GetSelectionModel(sel); | 283 native_wrapper_->GetSelectionModel(sel); |
| 274 } | 284 } |
| 275 | 285 |
| 276 void Textfield::SelectSelectionModel(const gfx::SelectionModel& sel) { | 286 void Textfield::SelectSelectionModel(const gfx::SelectionModel& sel) { |
| 277 DCHECK(native_wrapper_); | 287 DCHECK(native_wrapper_); |
| 278 native_wrapper_->SelectSelectionModel(sel); | 288 native_wrapper_->SelectSelectionModel(sel); |
| 279 } | 289 } |
| 280 | 290 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 void Textfield::GetAccessibleState(ui::AccessibleViewState* state) { | 397 void Textfield::GetAccessibleState(ui::AccessibleViewState* state) { |
| 388 state->role = ui::AccessibilityTypes::ROLE_TEXT; | 398 state->role = ui::AccessibilityTypes::ROLE_TEXT; |
| 389 state->name = accessible_name_; | 399 state->name = accessible_name_; |
| 390 if (read_only()) | 400 if (read_only()) |
| 391 state->state |= ui::AccessibilityTypes::STATE_READONLY; | 401 state->state |= ui::AccessibilityTypes::STATE_READONLY; |
| 392 if (IsPassword()) | 402 if (IsPassword()) |
| 393 state->state |= ui::AccessibilityTypes::STATE_PROTECTED; | 403 state->state |= ui::AccessibilityTypes::STATE_PROTECTED; |
| 394 state->value = text_; | 404 state->value = text_; |
| 395 | 405 |
| 396 DCHECK(native_wrapper_); | 406 DCHECK(native_wrapper_); |
| 397 gfx::SelectionModel sel; | 407 ui::Range range; |
| 398 native_wrapper_->GetSelectionModel(&sel); | 408 native_wrapper_->GetSelectedRange(&range); |
| 399 state->selection_start = sel.selection_start(); | 409 state->selection_start = range.start(); |
| 400 state->selection_end = sel.selection_end(); | 410 state->selection_end = range.end(); |
| 401 } | 411 } |
| 402 | 412 |
| 403 TextInputClient* Textfield::GetTextInputClient() { | 413 TextInputClient* Textfield::GetTextInputClient() { |
| 404 return native_wrapper_ ? native_wrapper_->GetTextInputClient() : NULL; | 414 return native_wrapper_ ? native_wrapper_->GetTextInputClient() : NULL; |
| 405 } | 415 } |
| 406 | 416 |
| 407 void Textfield::OnEnabledChanged() { | 417 void Textfield::OnEnabledChanged() { |
| 408 View::OnEnabledChanged(); | 418 View::OnEnabledChanged(); |
| 409 if (native_wrapper_) | 419 if (native_wrapper_) |
| 410 native_wrapper_->UpdateEnabled(); | 420 native_wrapper_->UpdateEnabled(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 434 } | 444 } |
| 435 #endif | 445 #endif |
| 436 } | 446 } |
| 437 } | 447 } |
| 438 | 448 |
| 439 std::string Textfield::GetClassName() const { | 449 std::string Textfield::GetClassName() const { |
| 440 return kViewClassName; | 450 return kViewClassName; |
| 441 } | 451 } |
| 442 | 452 |
| 443 } // namespace views | 453 } // namespace views |
| OLD | NEW |