Chromium Code Reviews| Index: content/browser/web_contents/web_contents_view_aura.cc |
| diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc |
| index a6ad7f5167f5f59eb050cb48016fbd4fa478818e..3c08dd6065480c121f75ac707cdc7793ad970acb 100644 |
| --- a/content/browser/web_contents/web_contents_view_aura.cc |
| +++ b/content/browser/web_contents/web_contents_view_aura.cc |
| @@ -43,9 +43,7 @@ |
| #include "ui/aura/client/window_tree_client.h" |
| #include "ui/aura/env.h" |
| #include "ui/aura/root_window.h" |
| -#include "ui/aura/root_window_observer.h" |
| #include "ui/aura/window.h" |
| -#include "ui/aura/window_observer.h" |
| #include "ui/base/clipboard/clipboard.h" |
| #include "ui/base/clipboard/custom_data_helper.h" |
| #include "ui/base/dragdrop/drag_drop_types.h" |
| @@ -648,165 +646,6 @@ class OverscrollNavigationOverlay : |
| DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); |
| }; |
| -class WebContentsViewAura::WindowObserver |
| - : public aura::WindowObserver, public aura::RootWindowObserver { |
| - public: |
| - explicit WindowObserver(WebContentsViewAura* view) |
| - : view_(view), |
| - parent_(NULL) { |
| - view_->window_->AddObserver(this); |
| - } |
| - |
| - virtual ~WindowObserver() { |
| - view_->window_->RemoveObserver(this); |
| - if (view_->window_->GetDispatcher()) |
| - view_->window_->GetDispatcher()->RemoveRootWindowObserver(this); |
| - if (parent_) |
| - parent_->RemoveObserver(this); |
| - |
| -#if defined(OS_WIN) |
| - if (parent_) { |
| - const aura::Window::Windows& children = parent_->children(); |
| - for (size_t i = 0; i < children.size(); ++i) |
| - children[i]->RemoveObserver(this); |
| - } |
| -#endif |
| - } |
| - |
| - // Overridden from aura::WindowObserver: |
| -#if defined(OS_WIN) |
| - // Constrained windows are added as children of the parent's parent's view |
|
rharrison
2013/11/20 16:40:55
jam, are the views that are of concern here being
|
| - // which may overlap with windowed NPAPI plugins. In that case, tell the RWHV |
| - // so that it can update the plugins' cutout rects accordingly. |
| - // Note: this is hard coding how Chrome layer adds its dialogs. Since NPAPI is |
| - // going to be deprecated in a year, this is ok for now. The test for this is |
| - // PrintPreviewTest.WindowedNPAPIPluginHidden. |
| - virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE { |
| - if (new_window->parent() != parent_) |
| - return; |
| - |
| - new_window->AddObserver(this); |
| - UpdateConstrainedWindows(NULL); |
| - } |
| - |
| - virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE { |
| - if (window->parent() == parent_ && window != view_->window_) { |
| - window->RemoveObserver(this); |
| - UpdateConstrainedWindows(window); |
| - } |
| - } |
| - |
| - virtual void OnWindowVisibilityChanged(aura::Window* window, |
| - bool visible) OVERRIDE { |
| - if (window->parent() == parent_ && window != view_->window_) |
| - UpdateConstrainedWindows(NULL); |
| - } |
| -#endif |
| - |
| - virtual void OnWindowParentChanged(aura::Window* window, |
| - aura::Window* parent) OVERRIDE { |
| - if (window != view_->window_) |
| - return; |
| - if (parent_) |
| - parent_->RemoveObserver(this); |
| - |
| -#if defined(OS_WIN) |
| - if (parent_) { |
| - const aura::Window::Windows& children = parent_->children(); |
| - for (size_t i = 0; i < children.size(); ++i) |
| - children[i]->RemoveObserver(this); |
| - |
| - RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura( |
| - view_->web_contents_->GetRenderWidgetHostView()); |
| - if (view) |
| - view->UpdateConstrainedWindowRects(std::vector<gfx::Rect>()); |
| - } |
| -#endif |
| - |
| - parent_ = parent; |
| - if (parent) { |
| - parent->AddObserver(this); |
| -#if defined(OS_WIN) |
| - const aura::Window::Windows& children = parent_->children(); |
| - for (size_t i = 0; i < children.size(); ++i) { |
| - if (children[i] != view_->window_) |
| - children[i]->AddObserver(this); |
| - } |
| -#endif |
| - } |
| - } |
| - |
| - virtual void OnWindowBoundsChanged(aura::Window* window, |
| - const gfx::Rect& old_bounds, |
| - const gfx::Rect& new_bounds) OVERRIDE { |
| - if (window == parent_ || window == view_->window_) { |
| - SendScreenRects(); |
| - if (view_->touch_editable_) |
| - view_->touch_editable_->UpdateEditingController(); |
| -#if defined(OS_WIN) |
| - } else { |
| - UpdateConstrainedWindows(NULL); |
| -#endif |
| - } |
| - } |
| - |
| - virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE { |
| - if (window == view_->window_) |
| - window->GetDispatcher()->AddRootWindowObserver(this); |
| - } |
| - |
| - virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { |
| - if (window == view_->window_) |
| - window->GetDispatcher()->RemoveRootWindowObserver(this); |
| - } |
| - |
| - // Overridden RootWindowObserver: |
| - virtual void OnRootWindowHostMoved(const aura::RootWindow* root, |
| - const gfx::Point& new_origin) OVERRIDE { |
| - TRACE_EVENT1("ui", |
| - "WebContentsViewAura::WindowObserver::OnRootWindowHostMoved", |
| - "new_origin", new_origin.ToString()); |
| - |
| - // This is for the desktop case (i.e. Aura desktop). |
| - SendScreenRects(); |
| - } |
| - |
| - private: |
| - void SendScreenRects() { |
| - RenderWidgetHostImpl::From(view_->web_contents_->GetRenderViewHost())-> |
| - SendScreenRects(); |
| - } |
| - |
| -#if defined(OS_WIN) |
| - void UpdateConstrainedWindows(aura::Window* exclude) { |
| - RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura( |
| - view_->web_contents_->GetRenderWidgetHostView()); |
| - if (!view) |
| - return; |
| - |
| - std::vector<gfx::Rect> constrained_windows; |
| - const aura::Window::Windows& children = parent_->children(); |
| - for (size_t i = 0; i < children.size(); ++i) { |
| - if (children[i] != view_->window_ && |
| - children[i] != exclude && |
| - children[i]->IsVisible()) { |
| - constrained_windows.push_back(children[i]->GetBoundsInRootWindow()); |
| - } |
| - } |
| - |
| - view->UpdateConstrainedWindowRects(constrained_windows); |
| - } |
| -#endif |
| - |
| - WebContentsViewAura* view_; |
| - |
| - // We cache the old parent so that we can unregister when it's not the parent |
| - // anymore. |
| - aura::Window* parent_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(WindowObserver); |
| -}; |
| - |
| //////////////////////////////////////////////////////////////////////////////// |
| // WebContentsViewAura, public: |
| @@ -831,7 +670,7 @@ WebContentsViewAura::~WebContentsViewAura() { |
| if (!window_) |
| return; |
| - window_observer_.reset(); |
| + bounds_observer_.reset(); |
| // Window needs a valid delegate during its destructor, so we explicitly |
| // delete it here. |
| @@ -1162,7 +1001,12 @@ void WebContentsViewAura::CreateView( |
| window_->layer()->SetMasksToBounds(true); |
| window_->SetName("WebContentsViewAura"); |
| - window_observer_.reset(new WindowObserver(this)); |
| + bounds_observer_.reset(new NativeViewScreenBoundsObserver(this, |
| + window_.get())); |
| + |
| +#if defined(OS_WIN) |
| + constrained_observer_.reset(new ConstrainedWindowsObserver(this)); |
| +#endif |
| // delegate_->GetDragDestDelegate() creates a new delegate on every call. |
| // Hence, we save a reference to it locally. Similar model is used on other |
| @@ -1647,4 +1491,19 @@ int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| return current_drag_op_; |
| } |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// WebContentsViewAura, NativeViewScreenBoundsObserverDelegate implementation: |
| + |
| +void WebContentsViewAura::OnScreenPositionChanged() { |
| + RenderWidgetHostImpl::From(web_contents_->GetRenderViewHost())-> |
| + SendScreenRects(); |
| +} |
| + |
| +void WebContentsViewAura::OnScreenBoundsChanged() { |
| + RenderWidgetHostImpl::From(web_contents_->GetRenderViewHost())-> |
| + SendScreenRects(); |
| + if (touch_editable_) |
| + touch_editable_->UpdateEditingController(); |
| +} |
| + |
| } // namespace content |