| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "ui/base/accessibility/accessible_view_state.h" | 12 #include "ui/base/accessibility/accessible_view_state.h" |
| 13 #include "ui/base/events/event.h" | 13 #include "ui/base/events/event.h" |
| 14 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
| 15 #include "ui/base/keycodes/keyboard_codes.h" | 15 #include "ui/base/keycodes/keyboard_codes.h" |
| 16 #include "ui/base/range/range.h" | |
| 17 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/base/ui_base_switches.h" | 17 #include "ui/base/ui_base_switches.h" |
| 19 #include "ui/gfx/insets.h" | 18 #include "ui/gfx/insets.h" |
| 19 #include "ui/gfx/range/range.h" |
| 20 #include "ui/gfx/selection_model.h" | 20 #include "ui/gfx/selection_model.h" |
| 21 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
| 22 #include "ui/views/controls/native/native_view_host.h" | 22 #include "ui/views/controls/native/native_view_host.h" |
| 23 #include "ui/views/controls/textfield/native_textfield_views.h" | 23 #include "ui/views/controls/textfield/native_textfield_views.h" |
| 24 #include "ui/views/controls/textfield/native_textfield_wrapper.h" | 24 #include "ui/views/controls/textfield/native_textfield_wrapper.h" |
| 25 #include "ui/views/controls/textfield/textfield_controller.h" | 25 #include "ui/views/controls/textfield/textfield_controller.h" |
| 26 #include "ui/views/views_delegate.h" | 26 #include "ui/views/views_delegate.h" |
| 27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 28 | 28 |
| 29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 if (controller_) | 356 if (controller_) |
| 357 controller_->ContentsChanged(this, text_); | 357 controller_->ContentsChanged(this, text_); |
| 358 } | 358 } |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 bool Textfield::IsIMEComposing() const { | 362 bool Textfield::IsIMEComposing() const { |
| 363 return native_wrapper_ && native_wrapper_->IsIMEComposing(); | 363 return native_wrapper_ && native_wrapper_->IsIMEComposing(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 ui::Range Textfield::GetSelectedRange() const { | 366 gfx::Range Textfield::GetSelectedRange() const { |
| 367 return native_wrapper_->GetSelectedRange(); | 367 return native_wrapper_->GetSelectedRange(); |
| 368 } | 368 } |
| 369 | 369 |
| 370 void Textfield::SelectRange(const ui::Range& range) { | 370 void Textfield::SelectRange(const gfx::Range& range) { |
| 371 native_wrapper_->SelectRange(range); | 371 native_wrapper_->SelectRange(range); |
| 372 } | 372 } |
| 373 | 373 |
| 374 gfx::SelectionModel Textfield::GetSelectionModel() const { | 374 gfx::SelectionModel Textfield::GetSelectionModel() const { |
| 375 return native_wrapper_->GetSelectionModel(); | 375 return native_wrapper_->GetSelectionModel(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void Textfield::SelectSelectionModel(const gfx::SelectionModel& sel) { | 378 void Textfield::SelectSelectionModel(const gfx::SelectionModel& sel) { |
| 379 native_wrapper_->SelectSelectionModel(sel); | 379 native_wrapper_->SelectSelectionModel(sel); |
| 380 } | 380 } |
| 381 | 381 |
| 382 size_t Textfield::GetCursorPosition() const { | 382 size_t Textfield::GetCursorPosition() const { |
| 383 return native_wrapper_->GetCursorPosition(); | 383 return native_wrapper_->GetCursorPosition(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void Textfield::SetColor(SkColor value) { | 386 void Textfield::SetColor(SkColor value) { |
| 387 return native_wrapper_->SetColor(value); | 387 return native_wrapper_->SetColor(value); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void Textfield::ApplyColor(SkColor value, const ui::Range& range) { | 390 void Textfield::ApplyColor(SkColor value, const gfx::Range& range) { |
| 391 return native_wrapper_->ApplyColor(value, range); | 391 return native_wrapper_->ApplyColor(value, range); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void Textfield::SetStyle(gfx::TextStyle style, bool value) { | 394 void Textfield::SetStyle(gfx::TextStyle style, bool value) { |
| 395 return native_wrapper_->SetStyle(style, value); | 395 return native_wrapper_->SetStyle(style, value); |
| 396 } | 396 } |
| 397 | 397 |
| 398 void Textfield::ApplyStyle(gfx::TextStyle style, | 398 void Textfield::ApplyStyle(gfx::TextStyle style, |
| 399 bool value, | 399 bool value, |
| 400 const ui::Range& range) { | 400 const gfx::Range& range) { |
| 401 return native_wrapper_->ApplyStyle(style, value, range); | 401 return native_wrapper_->ApplyStyle(style, value, range); |
| 402 } | 402 } |
| 403 | 403 |
| 404 void Textfield::ClearEditHistory() { | 404 void Textfield::ClearEditHistory() { |
| 405 native_wrapper_->ClearEditHistory(); | 405 native_wrapper_->ClearEditHistory(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void Textfield::SetAccessibleName(const string16& name) { | 408 void Textfield::SetAccessibleName(const string16& name) { |
| 409 accessible_name_ = name; | 409 accessible_name_ = name; |
| 410 } | 410 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 void Textfield::GetAccessibleState(ui::AccessibleViewState* state) { | 495 void Textfield::GetAccessibleState(ui::AccessibleViewState* state) { |
| 496 state->role = ui::AccessibilityTypes::ROLE_TEXT; | 496 state->role = ui::AccessibilityTypes::ROLE_TEXT; |
| 497 state->name = accessible_name_; | 497 state->name = accessible_name_; |
| 498 if (read_only()) | 498 if (read_only()) |
| 499 state->state |= ui::AccessibilityTypes::STATE_READONLY; | 499 state->state |= ui::AccessibilityTypes::STATE_READONLY; |
| 500 if (IsObscured()) | 500 if (IsObscured()) |
| 501 state->state |= ui::AccessibilityTypes::STATE_PROTECTED; | 501 state->state |= ui::AccessibilityTypes::STATE_PROTECTED; |
| 502 state->value = text_; | 502 state->value = text_; |
| 503 | 503 |
| 504 const ui::Range range = native_wrapper_->GetSelectedRange(); | 504 const gfx::Range range = native_wrapper_->GetSelectedRange(); |
| 505 state->selection_start = range.start(); | 505 state->selection_start = range.start(); |
| 506 state->selection_end = range.end(); | 506 state->selection_end = range.end(); |
| 507 | 507 |
| 508 if (!read_only()) { | 508 if (!read_only()) { |
| 509 state->set_value_callback = | 509 state->set_value_callback = |
| 510 base::Bind(&Textfield::AccessibilitySetValue, | 510 base::Bind(&Textfield::AccessibilitySetValue, |
| 511 weak_ptr_factory_.GetWeakPtr()); | 511 weak_ptr_factory_.GetWeakPtr()); |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 | 514 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 575 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
| 576 Textfield* field) { | 576 Textfield* field) { |
| 577 #if defined(OS_WIN) && !defined(USE_AURA) | 577 #if defined(OS_WIN) && !defined(USE_AURA) |
| 578 if (!Textfield::IsViewsTextfieldEnabled()) | 578 if (!Textfield::IsViewsTextfieldEnabled()) |
| 579 return new NativeTextfieldWin(field); | 579 return new NativeTextfieldWin(field); |
| 580 #endif | 580 #endif |
| 581 return new NativeTextfieldViews(field); | 581 return new NativeTextfieldViews(field); |
| 582 } | 582 } |
| 583 | 583 |
| 584 } // namespace views | 584 } // namespace views |
| OLD | NEW |