Chromium Code Reviews| 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" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 state->name = accessible_name_; | 499 state->name = accessible_name_; |
| 500 if (read_only()) | 500 if (read_only()) |
| 501 state->state |= ui::AccessibilityTypes::STATE_READONLY; | 501 state->state |= ui::AccessibilityTypes::STATE_READONLY; |
| 502 if (IsObscured()) | 502 if (IsObscured()) |
| 503 state->state |= ui::AccessibilityTypes::STATE_PROTECTED; | 503 state->state |= ui::AccessibilityTypes::STATE_PROTECTED; |
| 504 state->value = text_; | 504 state->value = text_; |
| 505 | 505 |
| 506 const ui::Range range = native_wrapper_->GetSelectedRange(); | 506 const ui::Range range = native_wrapper_->GetSelectedRange(); |
| 507 state->selection_start = range.start(); | 507 state->selection_start = range.start(); |
| 508 state->selection_end = range.end(); | 508 state->selection_end = range.end(); |
| 509 | |
| 510 state->set_value_callback = base::Bind( | |
|
msw
2013/08/31 20:22:36
nit: wrap the line after '='.
dmazzoni
2013/09/03 20:20:11
Done.
| |
| 511 &Textfield::AccessibilitySetValue, base::Unretained(this)); | |
|
msw
2013/08/31 20:22:36
Ditto; avoid base::Unretained with a new Textfield
| |
| 509 } | 512 } |
| 510 | 513 |
| 511 ui::TextInputClient* Textfield::GetTextInputClient() { | 514 ui::TextInputClient* Textfield::GetTextInputClient() { |
| 512 return native_wrapper_ ? native_wrapper_->GetTextInputClient() : NULL; | 515 return native_wrapper_ ? native_wrapper_->GetTextInputClient() : NULL; |
| 513 } | 516 } |
| 514 | 517 |
| 515 void Textfield::OnEnabledChanged() { | 518 void Textfield::OnEnabledChanged() { |
| 516 View::OnEnabledChanged(); | 519 View::OnEnabledChanged(); |
| 517 if (native_wrapper_) | 520 if (native_wrapper_) |
| 518 native_wrapper_->UpdateEnabled(); | 521 native_wrapper_->UpdateEnabled(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 547 return kViewClassName; | 550 return kViewClassName; |
| 548 } | 551 } |
| 549 | 552 |
| 550 gfx::Insets Textfield::GetTextInsets() const { | 553 gfx::Insets Textfield::GetTextInsets() const { |
| 551 gfx::Insets insets = GetInsets(); | 554 gfx::Insets insets = GetInsets(); |
| 552 if (draw_border_ && native_wrapper_) | 555 if (draw_border_ && native_wrapper_) |
| 553 insets += native_wrapper_->CalculateInsets(); | 556 insets += native_wrapper_->CalculateInsets(); |
| 554 return insets; | 557 return insets; |
| 555 } | 558 } |
| 556 | 559 |
| 560 void Textfield::AccessibilitySetValue(const string16& new_value) { | |
| 561 SetText(new_value); | |
| 562 ClearSelection(); | |
| 563 } | |
| 564 | |
| 557 //////////////////////////////////////////////////////////////////////////////// | 565 //////////////////////////////////////////////////////////////////////////////// |
| 558 // NativeTextfieldWrapper, public: | 566 // NativeTextfieldWrapper, public: |
| 559 | 567 |
| 560 // static | 568 // static |
| 561 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 569 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
| 562 Textfield* field) { | 570 Textfield* field) { |
| 563 #if defined(OS_WIN) && !defined(USE_AURA) | 571 #if defined(OS_WIN) && !defined(USE_AURA) |
| 564 if (!Textfield::IsViewsTextfieldEnabled()) | 572 if (!Textfield::IsViewsTextfieldEnabled()) |
| 565 return new NativeTextfieldWin(field); | 573 return new NativeTextfieldWin(field); |
| 566 #endif | 574 #endif |
| 567 return new NativeTextfieldViews(field); | 575 return new NativeTextfieldViews(field); |
| 568 } | 576 } |
| 569 | 577 |
| 570 } // namespace views | 578 } // namespace views |
| OLD | NEW |