Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: ui/views/controls/native/native_view_host_aura.cc

Issue 339663003: Revert of Implement NativeViewHostAura::InstallClip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/native/native_view_host_aura.cc
diff --git a/ui/views/controls/native/native_view_host_aura.cc b/ui/views/controls/native/native_view_host_aura.cc
index f370a5c587915eae884226a4073aa4571ef238cd..49bf733bbe2ae06567f1b9d148db2255b743ab85 100644
--- a/ui/views/controls/native/native_view_host_aura.cc
+++ b/ui/views/controls/native/native_view_host_aura.cc
@@ -5,7 +5,6 @@
#include "ui/views/controls/native/native_view_host_aura.h"
#include "base/logging.h"
-#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/window.h"
#include "ui/base/cursor/cursor.h"
@@ -17,43 +16,31 @@
NativeViewHostAura::NativeViewHostAura(NativeViewHost* host)
: host_(host),
- clipping_window_(NULL) {
- clipping_window_.Init(aura::WINDOW_LAYER_NOT_DRAWN);
- clipping_window_.set_owned_by_parent(false);
- clipping_window_.SetName("NativeViewHostAuraClip");
- clipping_window_.layer()->SetMasksToBounds(true);
- clipping_window_.SetProperty(views::kHostViewKey, static_cast<View*>(host_));
+ installed_clip_(false) {
}
NativeViewHostAura::~NativeViewHostAura() {
if (host_->native_view()) {
+ host_->native_view()->ClearProperty(views::kHostViewKey);
host_->native_view()->RemoveObserver(this);
- host_->native_view()->ClearProperty(views::kHostViewKey);
- host_->native_view()->ClearProperty(aura::client::kHostWindowKey);
- clipping_window_.ClearProperty(views::kHostViewKey);
- if (host_->native_view()->parent() == &clipping_window_)
- clipping_window_.RemoveChild(host_->native_view());
}
}
////////////////////////////////////////////////////////////////////////////////
// NativeViewHostAura, NativeViewHostWrapper implementation:
-void NativeViewHostAura::AttachNativeView() {
+void NativeViewHostAura::NativeViewWillAttach() {
host_->native_view()->AddObserver(this);
host_->native_view()->SetProperty(views::kHostViewKey,
static_cast<View*>(host_));
- AddClippingWindow();
}
void NativeViewHostAura::NativeViewDetaching(bool destroyed) {
- RemoveClippingWindow();
if (!destroyed) {
+ host_->native_view()->ClearProperty(views::kHostViewKey);
host_->native_view()->RemoveObserver(this);
- host_->native_view()->ClearProperty(views::kHostViewKey);
- host_->native_view()->ClearProperty(aura::client::kHostWindowKey);
host_->native_view()->Hide();
if (host_->native_view()->parent())
- host_->native_view()->parent()->RemoveChild(host_->native_view());
+ Widget::ReparentNativeView(host_->native_view(), NULL);
}
}
@@ -61,7 +48,9 @@
if (!host_->native_view())
return;
- AddClippingWindow();
+ aura::Window* widget_window = host_->GetWidget()->GetNativeView();
+ if (host_->native_view()->parent() != widget_window)
+ widget_window->AddChild(host_->native_view());
if (host_->IsDrawn())
host_->native_view()->Show();
else
@@ -72,42 +61,28 @@
void NativeViewHostAura::RemovedFromWidget() {
if (host_->native_view()) {
host_->native_view()->Hide();
- host_->native_view()->ClearProperty(aura::client::kHostWindowKey);
if (host_->native_view()->parent())
host_->native_view()->parent()->RemoveChild(host_->native_view());
- RemoveClippingWindow();
}
}
void NativeViewHostAura::InstallClip(int x, int y, int w, int h) {
- clip_rect_.reset(
- new gfx::Rect(host_->ConvertRectToWidget(gfx::Rect(x, y, w, h))));
+ // Note that this does not pose a problem functionality wise - it might
+ // however pose a speed degradation if not implemented.
+ LOG(WARNING) << "NativeViewHostAura::InstallClip is not implemented yet.";
}
bool NativeViewHostAura::HasInstalledClip() {
- return clip_rect_;
+ return installed_clip_;
}
void NativeViewHostAura::UninstallClip() {
- clip_rect_.reset();
+ installed_clip_ = false;
}
void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) {
- int width = w;
- int height = h;
- if (host_->fast_resize()) {
- gfx::Point origin(x, y);
- views::View::ConvertPointFromWidget(host_, &origin);
- InstallClip(origin.x(), origin.y(), w, h);
- width = host_->native_view()->bounds().width();
- height = host_->native_view()->bounds().height();
- }
- clipping_window_.SetBounds(clip_rect_ ? *clip_rect_
- : gfx::Rect(x, y, w, h));
-
- gfx::Point clip_offset = clipping_window_.bounds().origin();
- host_->native_view()->SetBounds(
- gfx::Rect(x - clip_offset.x(), y - clip_offset.y(), width, height));
+ // TODO: need to support fast resize.
+ host_->native_view()->SetBounds(gfx::Rect(x, y, w, h));
host_->native_view()->Show();
}
@@ -143,40 +118,4 @@
return new NativeViewHostAura(host);
}
-void NativeViewHostAura::AddClippingWindow() {
- RemoveClippingWindow();
-
- gfx::Rect bounds = host_->native_view()->bounds();
- if (host_->GetWidget()->GetNativeView()) {
- Widget::ReparentNativeView(&clipping_window_,
- host_->GetWidget()->GetNativeView());
- }
- host_->native_view()->SetProperty(aura::client::kHostWindowKey,
- host_->GetWidget()->GetNativeView());
- Widget::ReparentNativeView(host_->native_view(),
- &clipping_window_);
- clipping_window_.SetBounds(bounds);
- bounds.set_origin(gfx::Point(0, 0));
- host_->native_view()->SetBounds(bounds);
- clipping_window_.Show();
-}
-
-void NativeViewHostAura::RemoveClippingWindow() {
- if (host_->native_view())
- host_->native_view()->ClearProperty(aura::client::kHostWindowKey);
-
- if (host_->native_view()->parent() == &clipping_window_) {
- if (host_->GetWidget()->GetNativeView()) {
- Widget::ReparentNativeView(host_->native_view(),
- host_->GetWidget()->GetNativeView());
- } else {
- clipping_window_.RemoveChild(host_->native_view());
- }
- host_->native_view()->SetBounds(clipping_window_.bounds());
- }
- clipping_window_.Hide();
- if (clipping_window_.parent())
- clipping_window_.parent()->RemoveChild(&clipping_window_);
-}
-
} // namespace views
« no previous file with comments | « ui/views/controls/native/native_view_host_aura.h ('k') | ui/views/controls/native/native_view_host_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698