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/controls/native/native_view_host_aura.h" | 5 #include "ui/views/controls/native/native_view_host_aura.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
9 #include "ui/aura/client/focus_client.h" | 9 #include "ui/aura/client/focus_client.h" |
10 #include "ui/aura/layout_manager.h" | |
10 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
11 #include "ui/base/cursor/cursor.h" | 12 #include "ui/base/cursor/cursor.h" |
12 #include "ui/views/controls/native/native_view_host.h" | 13 #include "ui/views/controls/native/native_view_host.h" |
13 #include "ui/views/view_constants_aura.h" | 14 #include "ui/views/view_constants_aura.h" |
14 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
15 | 16 |
16 namespace views { | 17 namespace views { |
17 | 18 |
19 namespace { | |
20 | |
21 // This layout manager positions popups relative to the screen | |
22 // coordinate system. | |
23 class PopupAwareLayoutManager : public aura::LayoutManager { | |
24 public: | |
25 PopupAwareLayoutManager() {} | |
26 virtual ~PopupAwareLayoutManager() {} | |
27 | |
28 virtual void OnWindowResized() OVERRIDE {} | |
29 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {} | |
30 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} | |
31 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {} | |
32 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | |
33 bool visible) OVERRIDE {} | |
34 virtual void SetChildBounds(aura::Window* child, | |
35 const gfx::Rect& requested_bounds) OVERRIDE { | |
36 gfx::Rect bounds = requested_bounds; | |
37 if (child->type() == ui::wm::WINDOW_TYPE_POPUP) | |
Evan Stade
2014/07/17 23:37:01
this may look hokey, but compare to https://code.g
| |
38 bounds.Offset(-child->parent()->GetBoundsInScreen().OffsetFromOrigin()); | |
sky
2014/07/18 15:33:49
How does the autofill code end up using NativeView
Evan Stade
2014/07/18 18:22:53
the web contents native view is the parent of the
| |
39 SetChildBoundsDirect(child, bounds); | |
40 } | |
41 }; | |
42 | |
43 } // namespace | |
44 | |
18 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) | 45 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) |
19 : host_(host), | 46 : host_(host), |
20 clipping_window_(NULL) { | 47 clipping_window_(NULL) { |
21 clipping_window_.Init(aura::WINDOW_LAYER_NOT_DRAWN); | 48 clipping_window_.Init(aura::WINDOW_LAYER_NOT_DRAWN); |
49 clipping_window_.SetLayoutManager(new PopupAwareLayoutManager()); | |
22 clipping_window_.set_owned_by_parent(false); | 50 clipping_window_.set_owned_by_parent(false); |
23 clipping_window_.SetName("NativeViewHostAuraClip"); | 51 clipping_window_.SetName("NativeViewHostAuraClip"); |
24 clipping_window_.layer()->SetMasksToBounds(true); | 52 clipping_window_.layer()->SetMasksToBounds(true); |
25 clipping_window_.SetProperty(views::kHostViewKey, static_cast<View*>(host_)); | 53 clipping_window_.SetProperty(views::kHostViewKey, static_cast<View*>(host_)); |
26 } | 54 } |
27 | 55 |
28 NativeViewHostAura::~NativeViewHostAura() { | 56 NativeViewHostAura::~NativeViewHostAura() { |
29 if (host_->native_view()) { | 57 if (host_->native_view()) { |
30 host_->native_view()->RemoveObserver(this); | 58 host_->native_view()->RemoveObserver(this); |
31 host_->native_view()->ClearProperty(views::kHostViewKey); | 59 host_->native_view()->ClearProperty(views::kHostViewKey); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 } else { | 201 } else { |
174 clipping_window_.RemoveChild(host_->native_view()); | 202 clipping_window_.RemoveChild(host_->native_view()); |
175 } | 203 } |
176 host_->native_view()->SetBounds(clipping_window_.bounds()); | 204 host_->native_view()->SetBounds(clipping_window_.bounds()); |
177 } | 205 } |
178 if (clipping_window_.parent()) | 206 if (clipping_window_.parent()) |
179 clipping_window_.parent()->RemoveChild(&clipping_window_); | 207 clipping_window_.parent()->RemoveChild(&clipping_window_); |
180 } | 208 } |
181 | 209 |
182 } // namespace views | 210 } // namespace views |
OLD | NEW |