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 "chrome/browser/ui/views/dropdown_bar_host.h" | 5 #include "chrome/browser/ui/views/dropdown_bar_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/ui/views/frame/browser_view.h" | |
8 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
9 #include "ui/base/events/event.h" | 10 #include "ui/base/events/event.h" |
11 #include "ui/views/view.h" | |
12 #include "ui/views/view_constants_aura.h" | |
10 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
11 | 14 |
12 using content::NativeWebKeyboardEvent; | 15 using content::NativeWebKeyboardEvent; |
13 using content::WebContents; | 16 using content::WebContents; |
14 | 17 |
15 NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( | 18 NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( |
16 const WebContents* contents, | 19 const WebContents* contents, |
17 const ui::KeyEvent& key_event) { | 20 const ui::KeyEvent& key_event) { |
18 // NativeWebKeyboardEvent should take a const gfx::NativeEvent, which would | 21 // NativeWebKeyboardEvent should take a const gfx::NativeEvent, which would |
19 // prevent this casting. | 22 // prevent this casting. |
20 ui::Event* ui_event = | 23 ui::Event* ui_event = |
21 static_cast<ui::Event*>(const_cast<ui::KeyEvent*>(&key_event)); | 24 static_cast<ui::Event*>(const_cast<ui::KeyEvent*>(&key_event)); |
22 return NativeWebKeyboardEvent(ui_event); | 25 return NativeWebKeyboardEvent(ui_event); |
23 } | 26 } |
24 | 27 |
25 void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, | 28 void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, |
26 bool no_redraw) { | 29 bool no_redraw) { |
27 if (!host_->IsVisible()) | 30 if (!host_->IsVisible()) |
28 host_->GetNativeView()->Show(); | 31 host_->GetNativeView()->Show(); |
29 host_->GetNativeView()->SetBounds(new_pos); | 32 host_->GetNativeView()->SetBounds(new_pos); |
33 | |
34 if (!host_view_.get()) { | |
35 // Create view to denote the z-order of |host_| relative to child views of | |
36 // |browser_view_| which have layers and NativeViews attached to a child | |
37 // NativeViewHost of |browser_view_|. | |
38 host_view_.reset(new views::View()); | |
39 host_view_->set_owned_by_client(); | |
40 browser_view_->AddChildView(host_view_.get()); | |
sky
2013/05/13 22:54:17
One reason I like binding to an existing view owne
| |
41 | |
42 // Set the mapping between the view and the NativeView. The property does | |
43 // not need to be cleared because |host_view_| and |host_| are both | |
44 // destroyed when DropdownBarHost is destroyed. | |
45 host_->GetNativeView()->SetProperty(views::kHostViewKey, host_view_.get()); | |
46 } | |
47 browser_view_->ReorderChildView(host_view_.get(), -1); | |
48 | |
49 // TODO(pkotwicz): Complete implementing denoting the z-order via | |
50 // aura::client::kHostViewKey and remove once the implementation is done. | |
30 host_->StackAtTop(); | 51 host_->StackAtTop(); |
31 } | 52 } |
OLD | NEW |