| 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" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 //////////////////////////////////////////////////////////////////////////////// | 90 //////////////////////////////////////////////////////////////////////////////// |
| 91 // NativeViewHostAura, NativeViewHostWrapper implementation: | 91 // NativeViewHostAura, NativeViewHostWrapper implementation: |
| 92 void NativeViewHostAura::AttachNativeView() { | 92 void NativeViewHostAura::AttachNativeView() { |
| 93 clipping_window_delegate_->set_native_view(host_->native_view()); | 93 clipping_window_delegate_->set_native_view(host_->native_view()); |
| 94 host_->native_view()->AddObserver(this); | 94 host_->native_view()->AddObserver(this); |
| 95 host_->native_view()->SetProperty(views::kHostViewKey, | 95 host_->native_view()->SetProperty(views::kHostViewKey, |
| 96 static_cast<View*>(host_)); | 96 static_cast<View*>(host_)); |
| 97 original_transform_ = host_->native_view()->transform(); |
| 97 AddClippingWindow(); | 98 AddClippingWindow(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 void NativeViewHostAura::NativeViewDetaching(bool destroyed) { | 101 void NativeViewHostAura::NativeViewDetaching(bool destroyed) { |
| 101 clipping_window_delegate_->set_native_view(NULL); | 102 clipping_window_delegate_->set_native_view(NULL); |
| 102 RemoveClippingWindow(); | 103 RemoveClippingWindow(); |
| 103 if (!destroyed) { | 104 if (!destroyed) { |
| 104 host_->native_view()->RemoveObserver(this); | 105 host_->native_view()->RemoveObserver(this); |
| 105 host_->native_view()->ClearProperty(views::kHostViewKey); | 106 host_->native_view()->ClearProperty(views::kHostViewKey); |
| 106 host_->native_view()->ClearProperty(aura::client::kHostWindowKey); | 107 host_->native_view()->ClearProperty(aura::client::kHostWindowKey); |
| 108 host_->native_view()->SetTransform(original_transform_); |
| 107 host_->native_view()->Hide(); | 109 host_->native_view()->Hide(); |
| 108 if (host_->native_view()->parent()) | 110 if (host_->native_view()->parent()) |
| 109 Widget::ReparentNativeView(host_->native_view(), NULL); | 111 Widget::ReparentNativeView(host_->native_view(), NULL); |
| 110 } | 112 } |
| 111 } | 113 } |
| 112 | 114 |
| 113 void NativeViewHostAura::AddedToWidget() { | 115 void NativeViewHostAura::AddedToWidget() { |
| 114 if (!host_->native_view()) | 116 if (!host_->native_view()) |
| 115 return; | 117 return; |
| 116 | 118 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 138 } | 140 } |
| 139 | 141 |
| 140 bool NativeViewHostAura::HasInstalledClip() { | 142 bool NativeViewHostAura::HasInstalledClip() { |
| 141 return !!clip_rect_; | 143 return !!clip_rect_; |
| 142 } | 144 } |
| 143 | 145 |
| 144 void NativeViewHostAura::UninstallClip() { | 146 void NativeViewHostAura::UninstallClip() { |
| 145 clip_rect_.reset(); | 147 clip_rect_.reset(); |
| 146 } | 148 } |
| 147 | 149 |
| 148 void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) { | 150 void NativeViewHostAura::ShowWidget(int x, |
| 149 int width = w; | 151 int y, |
| 150 int height = h; | 152 int w, |
| 153 int h, |
| 154 int render_w, |
| 155 int render_h) { |
| 151 if (host_->fast_resize()) { | 156 if (host_->fast_resize()) { |
| 152 gfx::Point origin(x, y); | 157 gfx::Point origin(x, y); |
| 153 views::View::ConvertPointFromWidget(host_, &origin); | 158 views::View::ConvertPointFromWidget(host_, &origin); |
| 154 InstallClip(origin.x(), origin.y(), w, h); | 159 InstallClip(origin.x(), origin.y(), w, h); |
| 155 width = host_->native_view()->bounds().width(); | 160 render_w = host_->native_view()->bounds().width(); |
| 156 height = host_->native_view()->bounds().height(); | 161 render_h = host_->native_view()->bounds().height(); |
| 162 } else { |
| 163 gfx::Transform transform = original_transform_; |
| 164 if (w > 0 && h > 0 && render_w > 0 && render_h > 0) { |
| 165 transform.Scale(static_cast<SkMScalar>(w) / render_w, |
| 166 static_cast<SkMScalar>(h) / render_h); |
| 167 } |
| 168 host_->native_view()->SetTransform(transform); |
| 157 } | 169 } |
| 170 |
| 158 clipping_window_.SetBounds(clip_rect_ ? *clip_rect_ | 171 clipping_window_.SetBounds(clip_rect_ ? *clip_rect_ |
| 159 : gfx::Rect(x, y, w, h)); | 172 : gfx::Rect(x, y, w, h)); |
| 160 | |
| 161 gfx::Point clip_offset = clipping_window_.bounds().origin(); | 173 gfx::Point clip_offset = clipping_window_.bounds().origin(); |
| 162 host_->native_view()->SetBounds( | 174 host_->native_view()->SetBounds( |
| 163 gfx::Rect(x - clip_offset.x(), y - clip_offset.y(), width, height)); | 175 gfx::Rect(x - clip_offset.x(), y - clip_offset.y(), render_w, render_h)); |
| 164 host_->native_view()->Show(); | 176 host_->native_view()->Show(); |
| 165 clipping_window_.Show(); | 177 clipping_window_.Show(); |
| 166 } | 178 } |
| 167 | 179 |
| 168 void NativeViewHostAura::HideWidget() { | 180 void NativeViewHostAura::HideWidget() { |
| 169 host_->native_view()->Hide(); | 181 host_->native_view()->Hide(); |
| 170 clipping_window_.Hide(); | 182 clipping_window_.Hide(); |
| 171 } | 183 } |
| 172 | 184 |
| 173 void NativeViewHostAura::SetFocus() { | 185 void NativeViewHostAura::SetFocus() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } else { | 240 } else { |
| 229 clipping_window_.RemoveChild(host_->native_view()); | 241 clipping_window_.RemoveChild(host_->native_view()); |
| 230 } | 242 } |
| 231 host_->native_view()->SetBounds(clipping_window_.bounds()); | 243 host_->native_view()->SetBounds(clipping_window_.bounds()); |
| 232 } | 244 } |
| 233 if (clipping_window_.parent()) | 245 if (clipping_window_.parent()) |
| 234 clipping_window_.parent()->RemoveChild(&clipping_window_); | 246 clipping_window_.parent()->RemoveChild(&clipping_window_); |
| 235 } | 247 } |
| 236 | 248 |
| 237 } // namespace views | 249 } // namespace views |
| OLD | NEW |