Chromium Code Reviews| 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..7b999f8ea121145e55db0384c462d2da404104af 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,11 @@ const char* Textfield::GetClassName() const { |
| return kViewClassName; |
| } |
| +void Textfield::SetBorder(std::unique_ptr<Border> b) { |
| + use_focus_ring_ = false; |
| + View::SetBorder(std::move(b)); |
|
sky
2016/10/07 03:10:48
Should you also call FocusRing::Uninstall?
Evan Stade
2016/10/10 17:08:28
I didn't add that because it's dead code, but if y
sky
2016/10/10 19:55:19
Can you clarify what you mean by dead code? If the
|
| +} |
| + |
| 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 +993,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 +1017,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() { |