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

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

Issue 2383243002: Refactor MdFocusRing to make it easier to reuse on other controls. (Closed)
Patch Set: explicit onfocus 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
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 4642d23fc89a89633cc84ff72fbb5011959a7b9d..3639b883b68735affec8e871bbb517c0d9018645 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -33,6 +33,7 @@
#include "ui/native_theme/native_theme.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/background.h"
+#include "ui/views/controls/focus_ring.h"
#include "ui/views/controls/focusable_border.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/menu/menu_runner.h"
@@ -260,12 +261,17 @@ Textfield::Textfield()
aggregated_clicks_(0),
drag_start_display_offset_(0),
touch_handles_hidden_due_to_scroll_(false),
+ focus_ring_(nullptr),
weak_ptr_factory_(this) {
set_context_menu_controller(this);
set_drag_controller(this);
GetRenderText()->SetFontList(GetDefaultFontList());
SetBorder(std::unique_ptr<Border>(new FocusableBorder()));
SetFocusBehavior(FocusBehavior::ALWAYS);
+ if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ focus_ring_ = new FocusRing();
+ AddChildView(focus_ring_);
+ }
// These allow BrowserView to pass edit commands from the Chrome menu to us
// when we're focused by simply asking the FocusManager to
@@ -990,6 +996,8 @@ void Textfield::OnFocus() {
StartBlinkingCursor();
View::OnFocus();
SchedulePaint();
+ if (ui::MaterialDesignController::IsSecondaryUiMaterial())
+ focus_ring_->SetVisible(true);
}
void Textfield::OnBlur() {
@@ -1007,6 +1015,8 @@ void Textfield::OnBlur() {
// Border typically draws focus indicator.
SchedulePaint();
+ if (ui::MaterialDesignController::IsSecondaryUiMaterial())
+ focus_ring_->SetVisible(false);
sky 2016/10/03 23:53:15 Similar comment about deleting here.
}
gfx::Point Textfield::GetKeyboardContextMenuLocation() {

Powered by Google App Engine
This is Rietveld 408576698