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

Unified Diff: ui/views/focus/focus_traversal_unittest.cc

Issue 2345183002: Views: Draw Textfield selected text in gray when top-level Widget loses focus.
Patch Set: Refactor to use SelectionController(Delegate). Unfinished! Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield_unittest.cc ('k') | ui/views/selection_controller_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/focus/focus_traversal_unittest.cc
diff --git a/ui/views/focus/focus_traversal_unittest.cc b/ui/views/focus/focus_traversal_unittest.cc
index 352b4e481d0fdac354983ca47cf3ad9eef904d5d..6516bc13d14b76b69c2d9374817a39e037645108 100644
--- a/ui/views/focus/focus_traversal_unittest.cc
+++ b/ui/views/focus/focus_traversal_unittest.cc
@@ -139,11 +139,11 @@ class BorderView : public NativeViewHost {
}
virtual internal::RootView* GetContentsRootView() {
- return static_cast<internal::RootView*>(widget_->GetRootView());
+ return static_cast<internal::RootView*>(widget_.GetRootView());
}
FocusTraversable* GetFocusTraversable() override {
- return static_cast<internal::RootView*>(widget_->GetRootView());
+ return static_cast<internal::RootView*>(widget_.GetRootView());
}
void ViewHierarchyChanged(
@@ -151,27 +151,24 @@ class BorderView : public NativeViewHost {
NativeViewHost::ViewHierarchyChanged(details);
if (details.child == this && details.is_add) {
- if (!widget_) {
- widget_ = base::MakeUnique<Widget>();
- Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
- params.parent = details.parent->GetWidget()->GetNativeView();
- params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- widget_->Init(params);
- widget_->SetFocusTraversableParentView(this);
- widget_->SetContentsView(child_);
- }
+ Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
+ params.parent = details.parent->GetWidget()->GetNativeView();
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ widget_.Init(params);
+ widget_.SetFocusTraversableParentView(this);
+ widget_.SetContentsView(child_);
// We have been added to a view hierarchy, attach the native view.
- Attach(widget_->GetNativeView());
+ Attach(widget_.GetNativeView());
// Also update the FocusTraversable parent so the focus traversal works.
- static_cast<internal::RootView*>(widget_->GetRootView())->
+ static_cast<internal::RootView*>(widget_.GetRootView())->
SetFocusTraversableParent(GetWidget()->GetFocusTraversable());
}
}
private:
View* child_;
- std::unique_ptr<Widget> widget_;
+ Widget widget_;
DISALLOW_COPY_AND_ASSIGN(BorderView);
};
« no previous file with comments | « ui/views/controls/textfield/textfield_unittest.cc ('k') | ui/views/selection_controller_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698