| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/base/models/combobox_model.h" | 10 #include "ui/base/models/combobox_model.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 | 152 |
| 153 virtual void ViewHierarchyChanged( | 153 virtual void ViewHierarchyChanged( |
| 154 const ViewHierarchyChangedDetails& details) OVERRIDE { | 154 const ViewHierarchyChangedDetails& details) OVERRIDE { |
| 155 NativeViewHost::ViewHierarchyChanged(details); | 155 NativeViewHost::ViewHierarchyChanged(details); |
| 156 | 156 |
| 157 if (details.child == this && details.is_add) { | 157 if (details.child == this && details.is_add) { |
| 158 if (!widget_) { | 158 if (!widget_) { |
| 159 widget_ = new Widget; | 159 widget_ = new Widget; |
| 160 Widget::InitParams params(Widget::InitParams::TYPE_CONTROL); | 160 Widget::InitParams params(Widget::InitParams::TYPE_CONTROL); |
| 161 #if defined(OS_WIN) || defined(USE_AURA) | |
| 162 params.parent = details.parent->GetWidget()->GetNativeView(); | 161 params.parent = details.parent->GetWidget()->GetNativeView(); |
| 163 #else | |
| 164 NOTREACHED(); | |
| 165 #endif | |
| 166 widget_->Init(params); | 162 widget_->Init(params); |
| 167 widget_->SetFocusTraversableParentView(this); | 163 widget_->SetFocusTraversableParentView(this); |
| 168 widget_->SetContentsView(child_); | 164 widget_->SetContentsView(child_); |
| 169 } | 165 } |
| 170 | 166 |
| 171 // We have been added to a view hierarchy, attach the native view. | 167 // We have been added to a view hierarchy, attach the native view. |
| 172 Attach(widget_->GetNativeView()); | 168 Attach(widget_->GetNativeView()); |
| 173 // Also update the FocusTraversable parent so the focus traversal works. | 169 // Also update the FocusTraversable parent so the focus traversal works. |
| 174 static_cast<internal::RootView*>(widget_->GetRootView())-> | 170 static_cast<internal::RootView*>(widget_->GetRootView())-> |
| 175 SetFocusTraversableParent(GetWidget()->GetFocusTraversable()); | 171 SetFocusTraversableParent(GetWidget()->GetFocusTraversable()); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 GetFocusManager()->AdvanceFocus(true); | 770 GetFocusManager()->AdvanceFocus(true); |
| 775 View* focused_view = GetFocusManager()->GetFocusedView(); | 771 View* focused_view = GetFocusManager()->GetFocusedView(); |
| 776 EXPECT_TRUE(focused_view != NULL); | 772 EXPECT_TRUE(focused_view != NULL); |
| 777 if (focused_view) | 773 if (focused_view) |
| 778 EXPECT_EQ(kRightTraversalIDs[j], focused_view->id()); | 774 EXPECT_EQ(kRightTraversalIDs[j], focused_view->id()); |
| 779 } | 775 } |
| 780 } | 776 } |
| 781 } | 777 } |
| 782 | 778 |
| 783 } // namespace views | 779 } // namespace views |
| OLD | NEW |