Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: trunk/src/ui/views/controls/textfield/native_textfield_views.cc

Issue 77173004: Revert 233759 "Make NativeTextfieldViews update the win system c..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/ui/views/controls/textfield/native_textfield_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
59 namespace { 54 namespace {
60 55
61 void ConvertRectToScreen(const views::View* src, gfx::Rect* r) { 56 void ConvertRectToScreen(const views::View* src, gfx::Rect* r) {
62 DCHECK(src); 57 DCHECK(src);
63 58
64 gfx::Point new_origin = r->origin(); 59 gfx::Point new_origin = r->origin();
65 views::View::ConvertPointToScreen(src, &new_origin); 60 views::View::ConvertPointToScreen(src, &new_origin);
66 r->set_origin(new_origin); 61 r->set_origin(new_origin);
67 } 62 }
68 63
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 void NativeTextfieldViews::HandleBlur() { 690 void NativeTextfieldViews::HandleBlur() {
696 GetRenderText()->set_focused(false); 691 GetRenderText()->set_focused(false);
697 GetInputMethod()->OnBlur(); 692 GetInputMethod()->OnBlur();
698 // Stop blinking cursor. 693 // Stop blinking cursor.
699 cursor_timer_.InvalidateWeakPtrs(); 694 cursor_timer_.InvalidateWeakPtrs();
700 if (is_cursor_visible_) { 695 if (is_cursor_visible_) {
701 is_cursor_visible_ = false; 696 is_cursor_visible_ = false;
702 RepaintCursor(); 697 RepaintCursor();
703 } 698 }
704 699
705 PlatformHideSystemCaret();
706
707 touch_selection_controller_.reset(); 700 touch_selection_controller_.reset();
708 } 701 }
709 702
710 ui::TextInputClient* NativeTextfieldViews::GetTextInputClient() { 703 ui::TextInputClient* NativeTextfieldViews::GetTextInputClient() {
711 return textfield_->read_only() ? NULL : this; 704 return textfield_->read_only() ? NULL : this;
712 } 705 }
713 706
714 void NativeTextfieldViews::ClearEditHistory() { 707 void NativeTextfieldViews::ClearEditHistory() {
715 model_->ClearEditHistory(); 708 model_->ClearEditHistory();
716 } 709 }
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 base::Bind(&NativeTextfieldViews::UpdateCursor, 1156 base::Bind(&NativeTextfieldViews::UpdateCursor,
1164 cursor_timer_.GetWeakPtr()), 1157 cursor_timer_.GetWeakPtr()),
1165 base::TimeDelta::FromMilliseconds(caret_blink_ms)); 1158 base::TimeDelta::FromMilliseconds(caret_blink_ms));
1166 } 1159 }
1167 } 1160 }
1168 1161
1169 void NativeTextfieldViews::RepaintCursor() { 1162 void NativeTextfieldViews::RepaintCursor() {
1170 gfx::Rect r(GetRenderText()->GetUpdatedCursorBounds()); 1163 gfx::Rect r(GetRenderText()->GetUpdatedCursorBounds());
1171 r.Inset(-1, -1, -1, -1); 1164 r.Inset(-1, -1, -1, -1);
1172 SchedulePaintInRect(r); 1165 SchedulePaintInRect(r);
1173 PlatformUpdateSystemCaret();
1174 } 1166 }
1175 1167
1176 void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { 1168 void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) {
1177 TRACE_EVENT0("views", "NativeTextfieldViews::PaintTextAndCursor"); 1169 TRACE_EVENT0("views", "NativeTextfieldViews::PaintTextAndCursor");
1178 canvas->Save(); 1170 canvas->Save();
1179 GetRenderText()->set_cursor_visible(!is_drop_cursor_visible_ && 1171 GetRenderText()->set_cursor_visible(!is_drop_cursor_visible_ &&
1180 is_cursor_visible_ && !model_->HasSelection()); 1172 is_cursor_visible_ && !model_->HasSelection());
1181 // Draw the text, cursor, and selection. 1173 // Draw the text, cursor, and selection.
1182 GetRenderText()->Draw(canvas); 1174 GetRenderText()->Draw(canvas);
1183 1175
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 1528
1537 if (index != -1) { 1529 if (index != -1) {
1538 obscured_reveal_timer_.Start( 1530 obscured_reveal_timer_.Start(
1539 FROM_HERE, 1531 FROM_HERE,
1540 duration, 1532 duration,
1541 base::Bind(&NativeTextfieldViews::RevealObscuredChar, 1533 base::Bind(&NativeTextfieldViews::RevealObscuredChar,
1542 base::Unretained(this), -1, base::TimeDelta())); 1534 base::Unretained(this), -1, base::TimeDelta()));
1543 } 1535 }
1544 } 1536 }
1545 1537
1546
1547 void NativeTextfieldViews::PlatformUpdateSystemCaret() {
1548 #if defined(OS_WIN)
1549 if (!GetRenderText()->focused())
1550 return;
1551
1552 // Move an invisible system caret to this location for accessibility.
1553 if (!is_drop_cursor_visible_) {
1554 gfx::Rect caret_rect(GetRenderText()->GetUpdatedCursorBounds());
1555 caret_rect = ConvertRectToWidget(caret_rect);
1556 caret_rect += GetWidget()->GetClientAreaBoundsInScreen().OffsetFromOrigin();
1557 if (caret_rect != last_caret_rect_) {
1558 base::win::SetInvisibleSystemCaretRect(HWNDForView(this), caret_rect);
1559 last_caret_rect_ = caret_rect;
1560 }
1561 } else {
1562 DestroyCaret();
1563 last_caret_rect_ = gfx::Rect();
1564 }
1565 #endif
1566 }
1567
1568 void NativeTextfieldViews::PlatformHideSystemCaret() {
1569 #if defined(OS_WIN)
1570 DestroyCaret();
1571 last_caret_rect_ = gfx::Rect();
1572 #endif
1573 }
1574
1575 } // namespace views 1538 } // namespace views
OLDNEW
« no previous file with comments | « trunk/src/ui/views/controls/textfield/native_textfield_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698