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

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: Fix lifetime issues with BorderView's widget_ and address review comments. 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
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 1bf6ebccd3aa234598892b4d3ca8a172515acc18..29b1cd88b8c7efec48f22a31bdf000c40b23572d 100644
--- a/ui/views/focus/focus_traversal_unittest.cc
+++ b/ui/views/focus/focus_traversal_unittest.cc
@@ -132,13 +132,11 @@ class PaneView : public View, public FocusTraversable {
// view hierarchy.
class BorderView : public NativeViewHost {
public:
- explicit BorderView(View* child) : child_(child), widget_(NULL) {
+ explicit BorderView(View* child) : child_(child) {
DCHECK(child);
SetFocusBehavior(FocusBehavior::NEVER);
}
- ~BorderView() override {}
-
virtual internal::RootView* GetContentsRootView() {
return static_cast<internal::RootView*>(widget_->GetRootView());
}
@@ -153,9 +151,10 @@ class BorderView : public NativeViewHost {
if (details.child == this && details.is_add) {
if (!widget_) {
- widget_ = new Widget;
+ widget_.reset(new 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_);
@@ -171,7 +170,7 @@ class BorderView : public NativeViewHost {
private:
View* child_;
- Widget* widget_;
+ std::unique_ptr<Widget> widget_;
Patti Lor 2016/11/08 04:00:27 BorderView uses a Widget as convenient way to crea
tapted 2016/11/08 23:35:19 See also http://crbug.com/663418 about this - let'
msw 2016/11/09 02:08:53 Scott already has context on this nuanced issue; s
Patti Lor 2016/11/10 07:29:09 Reverted this file, changes are in https://coderev
msw 2016/11/10 18:45:01 If you just do |Widget widget_;|, it'll be automat
Patti Lor 2016/11/10 23:37:48 Oops, sorry - I didn't realise you meant a non-poi
DISALLOW_COPY_AND_ASSIGN(BorderView);
};

Powered by Google App Engine
This is Rietveld 408576698