Chromium Code Reviews| 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/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/base/cursor/cursor.h" | 11 #include "ui/base/cursor/cursor.h" |
| 12 #include "ui/views/controls/native/native_view_host.h" | 12 #include "ui/views/controls/native/native_view_host.h" |
| 13 #include "ui/views/view_constants_aura.h" | 13 #include "ui/views/view_constants_aura.h" |
| 14 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 | 17 |
| 18 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) | 18 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) |
| 19 : host_(host), | 19 : host_(host), |
| 20 clipping_window_(NULL) { | 20 clipping_window_(NULL) { |
| 21 clipping_window_.SetType(ui::wm::WINDOW_TYPE_CONTROL); | |
|
sky
2014/07/22 22:36:59
As this is so subtle I was hoping for a comment he
Evan Stade
2014/07/22 22:41:19
I will add one.
| |
| 21 clipping_window_.Init(aura::WINDOW_LAYER_NOT_DRAWN); | 22 clipping_window_.Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 22 clipping_window_.set_owned_by_parent(false); | 23 clipping_window_.set_owned_by_parent(false); |
| 23 clipping_window_.SetName("NativeViewHostAuraClip"); | 24 clipping_window_.SetName("NativeViewHostAuraClip"); |
| 24 clipping_window_.layer()->SetMasksToBounds(true); | 25 clipping_window_.layer()->SetMasksToBounds(true); |
| 25 clipping_window_.SetProperty(views::kHostViewKey, static_cast<View*>(host_)); | 26 clipping_window_.SetProperty(views::kHostViewKey, static_cast<View*>(host_)); |
| 26 } | 27 } |
| 27 | 28 |
| 28 NativeViewHostAura::~NativeViewHostAura() { | 29 NativeViewHostAura::~NativeViewHostAura() { |
| 29 if (host_->native_view()) { | 30 if (host_->native_view()) { |
| 30 host_->native_view()->RemoveObserver(this); | 31 host_->native_view()->RemoveObserver(this); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 // static | 141 // static |
| 141 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( | 142 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( |
| 142 NativeViewHost* host) { | 143 NativeViewHost* host) { |
| 143 return new NativeViewHostAura(host); | 144 return new NativeViewHostAura(host); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void NativeViewHostAura::AddClippingWindow() { | 147 void NativeViewHostAura::AddClippingWindow() { |
| 147 RemoveClippingWindow(); | 148 RemoveClippingWindow(); |
| 148 | 149 |
| 149 gfx::Rect bounds = host_->native_view()->bounds(); | 150 gfx::Rect bounds = host_->native_view()->bounds(); |
| 151 Widget::ReparentNativeView(host_->native_view(), | |
|
sky
2014/07/22 22:36:59
Did you intend to include this?
Evan Stade
2014/07/22 22:41:19
no
| |
| 152 &clipping_window_); | |
| 150 if (host_->GetWidget()->GetNativeView()) { | 153 if (host_->GetWidget()->GetNativeView()) { |
| 151 Widget::ReparentNativeView(&clipping_window_, | 154 Widget::ReparentNativeView(&clipping_window_, |
| 152 host_->GetWidget()->GetNativeView()); | 155 host_->GetWidget()->GetNativeView()); |
| 153 } | 156 } |
| 154 host_->native_view()->SetProperty(aura::client::kHostWindowKey, | 157 host_->native_view()->SetProperty(aura::client::kHostWindowKey, |
| 155 host_->GetWidget()->GetNativeView()); | 158 host_->GetWidget()->GetNativeView()); |
| 156 Widget::ReparentNativeView(host_->native_view(), | |
| 157 &clipping_window_); | |
| 158 clipping_window_.SetBounds(bounds); | 159 clipping_window_.SetBounds(bounds); |
| 159 bounds.set_origin(gfx::Point(0, 0)); | 160 bounds.set_origin(gfx::Point(0, 0)); |
| 160 host_->native_view()->SetBounds(bounds); | 161 host_->native_view()->SetBounds(bounds); |
| 161 clipping_window_.Show(); | 162 clipping_window_.Show(); |
| 162 } | 163 } |
| 163 | 164 |
| 164 void NativeViewHostAura::RemoveClippingWindow() { | 165 void NativeViewHostAura::RemoveClippingWindow() { |
| 165 clipping_window_.Hide(); | 166 clipping_window_.Hide(); |
| 166 if (host_->native_view()) | 167 if (host_->native_view()) |
| 167 host_->native_view()->ClearProperty(aura::client::kHostWindowKey); | 168 host_->native_view()->ClearProperty(aura::client::kHostWindowKey); |
| 168 | 169 |
| 169 if (host_->native_view()->parent() == &clipping_window_) { | 170 if (host_->native_view()->parent() == &clipping_window_) { |
| 170 if (host_->GetWidget() && host_->GetWidget()->GetNativeView()) { | 171 if (host_->GetWidget() && host_->GetWidget()->GetNativeView()) { |
| 171 Widget::ReparentNativeView(host_->native_view(), | 172 Widget::ReparentNativeView(host_->native_view(), |
| 172 host_->GetWidget()->GetNativeView()); | 173 host_->GetWidget()->GetNativeView()); |
| 173 } else { | 174 } else { |
| 174 clipping_window_.RemoveChild(host_->native_view()); | 175 clipping_window_.RemoveChild(host_->native_view()); |
| 175 } | 176 } |
| 176 host_->native_view()->SetBounds(clipping_window_.bounds()); | 177 host_->native_view()->SetBounds(clipping_window_.bounds()); |
| 177 } | 178 } |
| 178 if (clipping_window_.parent()) | 179 if (clipping_window_.parent()) |
| 179 clipping_window_.parent()->RemoveChild(&clipping_window_); | 180 clipping_window_.parent()->RemoveChild(&clipping_window_); |
| 180 } | 181 } |
| 181 | 182 |
| 182 } // namespace views | 183 } // namespace views |
| OLD | NEW |