OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/textfield/native_textfield_views.h" | 5 #include "ui/views/controls/textfield/native_textfield_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
45 | 45 |
46 #if defined(USE_AURA) | 46 #if defined(USE_AURA) |
47 #include "ui/base/cursor/cursor.h" | 47 #include "ui/base/cursor/cursor.h" |
48 #endif | 48 #endif |
49 | 49 |
50 #if defined(OS_WIN) && defined(USE_AURA) | 50 #if defined(OS_WIN) && defined(USE_AURA) |
51 #include "base/win/win_util.h" | 51 #include "base/win/win_util.h" |
52 #endif | 52 #endif |
53 | 53 |
54 #if defined(OS_WIN) | |
55 #include "ui/base/win/accessibility_misc_utils.h" | |
56 #include "ui/views/win/hwnd_util.h" | |
57 #endif | |
58 | |
54 namespace { | 59 namespace { |
55 | 60 |
56 void ConvertRectToScreen(const views::View* src, gfx::Rect* r) { | 61 void ConvertRectToScreen(const views::View* src, gfx::Rect* r) { |
57 DCHECK(src); | 62 DCHECK(src); |
58 | 63 |
59 gfx::Point new_origin = r->origin(); | 64 gfx::Point new_origin = r->origin(); |
60 views::View::ConvertPointToScreen(src, &new_origin); | 65 views::View::ConvertPointToScreen(src, &new_origin); |
61 r->set_origin(new_origin); | 66 r->set_origin(new_origin); |
62 } | 67 } |
63 | 68 |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 | 694 |
690 void NativeTextfieldViews::HandleBlur() { | 695 void NativeTextfieldViews::HandleBlur() { |
691 GetRenderText()->set_focused(false); | 696 GetRenderText()->set_focused(false); |
692 GetInputMethod()->OnBlur(); | 697 GetInputMethod()->OnBlur(); |
693 // Stop blinking cursor. | 698 // Stop blinking cursor. |
694 cursor_timer_.InvalidateWeakPtrs(); | 699 cursor_timer_.InvalidateWeakPtrs(); |
695 if (is_cursor_visible_) { | 700 if (is_cursor_visible_) { |
696 is_cursor_visible_ = false; | 701 is_cursor_visible_ = false; |
697 RepaintCursor(); | 702 RepaintCursor(); |
698 } | 703 } |
704 #if defined(OS_WIN) | |
705 DestroyCaret(); | |
706 #endif | |
699 | 707 |
700 touch_selection_controller_.reset(); | 708 touch_selection_controller_.reset(); |
701 } | 709 } |
702 | 710 |
703 ui::TextInputClient* NativeTextfieldViews::GetTextInputClient() { | 711 ui::TextInputClient* NativeTextfieldViews::GetTextInputClient() { |
704 return textfield_->read_only() ? NULL : this; | 712 return textfield_->read_only() ? NULL : this; |
705 } | 713 } |
706 | 714 |
707 void NativeTextfieldViews::ClearEditHistory() { | 715 void NativeTextfieldViews::ClearEditHistory() { |
708 model_->ClearEditHistory(); | 716 model_->ClearEditHistory(); |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1357 | 1365 |
1358 context_menu_delegate_->BuildMenu(context_menu_runner_->GetMenu()); | 1366 context_menu_delegate_->BuildMenu(context_menu_runner_->GetMenu()); |
1359 } | 1367 } |
1360 | 1368 |
1361 void NativeTextfieldViews::OnTextInputTypeChanged() { | 1369 void NativeTextfieldViews::OnTextInputTypeChanged() { |
1362 // TODO(suzhe): changed from DCHECK. See http://crbug.com/81320. | 1370 // TODO(suzhe): changed from DCHECK. See http://crbug.com/81320. |
1363 if (textfield_->GetInputMethod()) | 1371 if (textfield_->GetInputMethod()) |
1364 textfield_->GetInputMethod()->OnTextInputTypeChanged(textfield_); | 1372 textfield_->GetInputMethod()->OnTextInputTypeChanged(textfield_); |
1365 } | 1373 } |
1366 | 1374 |
1367 void NativeTextfieldViews::OnCaretBoundsChanged() { | 1375 void NativeTextfieldViews::OnCaretBoundsChanged() { |
sky
2013/11/07 01:34:42
I'm not sure if this is invoked if the bounds of t
dmazzoni
2013/11/07 20:07:14
I moved it to RepaintCursor, that should update ev
| |
1368 // TODO(suzhe): changed from DCHECK. See http://crbug.com/81320. | 1376 // TODO(suzhe): changed from DCHECK. See http://crbug.com/81320. |
1369 if (textfield_->GetInputMethod()) | 1377 if (textfield_->GetInputMethod()) |
1370 textfield_->GetInputMethod()->OnCaretBoundsChanged(textfield_); | 1378 textfield_->GetInputMethod()->OnCaretBoundsChanged(textfield_); |
1371 | 1379 |
1372 // Notify selection controller | 1380 // Notify selection controller |
1373 if (touch_selection_controller_.get()) | 1381 if (touch_selection_controller_.get()) |
1374 touch_selection_controller_->SelectionChanged(); | 1382 touch_selection_controller_->SelectionChanged(); |
1383 | |
1384 #if defined(OS_WIN) | |
1385 // Move an invisible system caret to this location for accessibility. | |
1386 if (GetRenderText()->focused() && | |
1387 !model_->HasSelection() && | |
sky
2013/11/07 01:34:42
How come you don't do this when there is a selecti
dmazzoni
2013/11/07 20:07:14
You're right - I thought we didn't need to update
| |
1388 !is_drop_cursor_visible_) { | |
1389 gfx::Rect caret_rect(GetRenderText()->GetUpdatedCursorBounds()); | |
1390 caret_rect = ConvertRectToWidget(caret_rect); | |
1391 caret_rect += GetWidget()->GetClientAreaBoundsInScreen().OffsetFromOrigin(); | |
1392 base::win::SetInvisibleSystemCaretRect(HWNDForView(this), caret_rect); | |
1393 } else { | |
1394 DestroyCaret(); | |
1395 } | |
1396 #endif | |
1375 } | 1397 } |
1376 | 1398 |
1377 void NativeTextfieldViews::OnBeforeUserAction() { | 1399 void NativeTextfieldViews::OnBeforeUserAction() { |
1378 TextfieldController* controller = textfield_->GetController(); | 1400 TextfieldController* controller = textfield_->GetController(); |
1379 if (controller) | 1401 if (controller) |
1380 controller->OnBeforeUserAction(textfield_); | 1402 controller->OnBeforeUserAction(textfield_); |
1381 } | 1403 } |
1382 | 1404 |
1383 void NativeTextfieldViews::OnAfterUserAction() { | 1405 void NativeTextfieldViews::OnAfterUserAction() { |
1384 TextfieldController* controller = textfield_->GetController(); | 1406 TextfieldController* controller = textfield_->GetController(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1520 if (index != -1) { | 1542 if (index != -1) { |
1521 obscured_reveal_timer_.Start( | 1543 obscured_reveal_timer_.Start( |
1522 FROM_HERE, | 1544 FROM_HERE, |
1523 duration, | 1545 duration, |
1524 base::Bind(&NativeTextfieldViews::RevealObscuredChar, | 1546 base::Bind(&NativeTextfieldViews::RevealObscuredChar, |
1525 base::Unretained(this), -1, base::TimeDelta())); | 1547 base::Unretained(this), -1, base::TimeDelta())); |
1526 } | 1548 } |
1527 } | 1549 } |
1528 | 1550 |
1529 } // namespace views | 1551 } // namespace views |
OLD | NEW |