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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2395033002: Harmony - Don't paint focus ring on unless border requests it. (Closed)
Patch Set: uninstall Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 56ae56b8dd9d7be85ec284cd0eb4e95767f20934..0601ac064121af98f9f9444ca96740ad65b4c7f6 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -261,11 +261,12 @@ Textfield::Textfield()
aggregated_clicks_(0),
drag_start_display_offset_(0),
touch_handles_hidden_due_to_scroll_(false),
+ use_focus_ring_(ui::MaterialDesignController::IsSecondaryUiMaterial()),
weak_ptr_factory_(this) {
set_context_menu_controller(this);
set_drag_controller(this);
GetRenderText()->SetFontList(GetDefaultFontList());
- SetBorder(std::unique_ptr<Border>(new FocusableBorder()));
+ View::SetBorder(std::unique_ptr<Border>(new FocusableBorder()));
SetFocusBehavior(FocusBehavior::ALWAYS);
// These allow BrowserView to pass edit commands from the Chrome menu to us
@@ -558,6 +559,13 @@ const char* Textfield::GetClassName() const {
return kViewClassName;
}
+void Textfield::SetBorder(std::unique_ptr<Border> b) {
+ if (use_focus_ring_ && HasFocus())
+ FocusRing::Uninstall(this);
+ use_focus_ring_ = false;
+ View::SetBorder(std::move(b));
+}
+
gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) {
bool in_selection = GetRenderText()->IsPointInSelection(event.location());
bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED;
@@ -987,16 +995,15 @@ void Textfield::OnFocus() {
GetRenderText()->set_focused(true);
if (ShouldShowCursor())
GetRenderText()->set_cursor_visible(true);
- SchedulePaint();
if (GetInputMethod())
GetInputMethod()->SetFocusedTextInputClient(this);
OnCaretBoundsChanged();
if (ShouldBlinkCursor())
StartBlinkingCursor();
- View::OnFocus();
- SchedulePaint();
- if (ui::MaterialDesignController::IsSecondaryUiMaterial())
+ if (use_focus_ring_)
FocusRing::Install(this);
+ SchedulePaint();
+ View::OnFocus();
}
void Textfield::OnBlur() {
@@ -1012,10 +1019,10 @@ void Textfield::OnBlur() {
DestroyTouchSelection();
- // Border typically draws focus indicator.
- SchedulePaint();
- if (ui::MaterialDesignController::IsSecondaryUiMaterial())
+ if (use_focus_ring_)
FocusRing::Uninstall(this);
+ SchedulePaint();
+ View::OnBlur();
}
gfx::Point Textfield::GetKeyboardContextMenuLocation() {
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698