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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 : public aura::WindowObserver, public aura::RootWindowObserver { 652 : public aura::WindowObserver, public aura::RootWindowObserver {
653 public: 653 public:
654 explicit WindowObserver(WebContentsViewAura* view) 654 explicit WindowObserver(WebContentsViewAura* view)
655 : view_(view), 655 : view_(view),
656 parent_(NULL) { 656 parent_(NULL) {
657 view_->window_->AddObserver(this); 657 view_->window_->AddObserver(this);
658 } 658 }
659 659
660 virtual ~WindowObserver() { 660 virtual ~WindowObserver() {
661 view_->window_->RemoveObserver(this); 661 view_->window_->RemoveObserver(this);
662 if (view_->window_->GetRootWindow()) 662 if (view_->window_->GetDispatcher())
663 view_->window_->GetRootWindow()->RemoveRootWindowObserver(this); 663 view_->window_->GetDispatcher()->RemoveRootWindowObserver(this);
664 if (parent_) 664 if (parent_)
665 parent_->RemoveObserver(this); 665 parent_->RemoveObserver(this);
666 } 666 }
667 667
668 // Overridden from aura::WindowObserver: 668 // Overridden from aura::WindowObserver:
669 virtual void OnWindowParentChanged(aura::Window* window, 669 virtual void OnWindowParentChanged(aura::Window* window,
670 aura::Window* parent) OVERRIDE { 670 aura::Window* parent) OVERRIDE {
671 if (window == parent_) 671 if (window == parent_)
672 return; 672 return;
673 if (parent_) 673 if (parent_)
674 parent_->RemoveObserver(this); 674 parent_->RemoveObserver(this);
675 parent_ = parent; 675 parent_ = parent;
676 if (parent) 676 if (parent)
677 parent->AddObserver(this); 677 parent->AddObserver(this);
678 } 678 }
679 679
680 virtual void OnWindowBoundsChanged(aura::Window* window, 680 virtual void OnWindowBoundsChanged(aura::Window* window,
681 const gfx::Rect& old_bounds, 681 const gfx::Rect& old_bounds,
682 const gfx::Rect& new_bounds) OVERRIDE { 682 const gfx::Rect& new_bounds) OVERRIDE {
683 SendScreenRects(); 683 SendScreenRects();
684 if (view_->touch_editable_) 684 if (view_->touch_editable_)
685 view_->touch_editable_->UpdateEditingController(); 685 view_->touch_editable_->UpdateEditingController();
686 } 686 }
687 687
688 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE { 688 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE {
689 if (window != parent_) 689 if (window != parent_)
690 window->GetRootWindow()->AddRootWindowObserver(this); 690 window->GetDispatcher()->AddRootWindowObserver(this);
691 } 691 }
692 692
693 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { 693 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE {
694 if (window != parent_) 694 if (window != parent_)
695 window->GetRootWindow()->RemoveRootWindowObserver(this); 695 window->GetDispatcher()->RemoveRootWindowObserver(this);
696 } 696 }
697 697
698 // Overridden RootWindowObserver: 698 // Overridden RootWindowObserver:
699 virtual void OnRootWindowHostMoved(const aura::RootWindow* root, 699 virtual void OnRootWindowHostMoved(const aura::RootWindow* root,
700 const gfx::Point& new_origin) OVERRIDE { 700 const gfx::Point& new_origin) OVERRIDE {
701 // This is for the desktop case (i.e. Aura desktop). 701 // This is for the desktop case (i.e. Aura desktop).
702 SendScreenRects(); 702 SendScreenRects();
703 } 703 }
704 704
705 private: 705 private:
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { 854 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) {
855 if (web_contents_->GetInterstitialPage()) 855 if (web_contents_->GetInterstitialPage())
856 web_contents_->GetInterstitialPage()->SetSize(size); 856 web_contents_->GetInterstitialPage()->SetSize(size);
857 RenderWidgetHostView* rwhv = 857 RenderWidgetHostView* rwhv =
858 web_contents_->GetRenderWidgetHostView(); 858 web_contents_->GetRenderWidgetHostView();
859 if (rwhv) 859 if (rwhv)
860 rwhv->SetSize(size); 860 rwhv->SetSize(size);
861 } 861 }
862 862
863 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { 863 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) {
864 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 864 aura::Window* root_window = GetNativeView()->GetRootWindow();
865 gfx::Point screen_loc = 865 gfx::Point screen_loc =
866 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); 866 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
867 gfx::Point client_loc = screen_loc; 867 gfx::Point client_loc = screen_loc;
868 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 868 RenderViewHost* rvh = web_contents_->GetRenderViewHost();
869 aura::Window* window = rvh->GetView()->GetNativeView(); 869 aura::Window* window = rvh->GetView()->GetNativeView();
870 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); 870 aura::Window::ConvertPointToTarget(root_window, window, &client_loc);
871 if (!web_contents_) 871 if (!web_contents_)
872 return; 872 return;
873 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), 873 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(),
874 screen_loc.x(), screen_loc.y(), ops); 874 screen_loc.x(), screen_loc.y(), ops);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as 1139 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as
1140 // if the bookmark bar is not shown and you create a new tab). The right 1140 // if the bookmark bar is not shown and you create a new tab). The right
1141 // value is set shortly after this, so its safe to ignore. 1141 // value is set shortly after this, so its safe to ignore.
1142 1142
1143 aura::Env::CreateInstance(); 1143 aura::Env::CreateInstance();
1144 window_.reset(new aura::Window(this)); 1144 window_.reset(new aura::Window(this));
1145 window_->set_owned_by_parent(false); 1145 window_->set_owned_by_parent(false);
1146 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); 1146 window_->SetType(aura::client::WINDOW_TYPE_CONTROL);
1147 window_->SetTransparent(false); 1147 window_->SetTransparent(false);
1148 window_->Init(ui::LAYER_NOT_DRAWN); 1148 window_->Init(ui::LAYER_NOT_DRAWN);
1149 aura::RootWindow* root_window = context ? context->GetRootWindow() : NULL; 1149 aura::Window* root_window = context ? context->GetRootWindow() : NULL;
1150 if (root_window) { 1150 if (root_window) {
1151 // There are places where there is no context currently because object 1151 // There are places where there is no context currently because object
1152 // hierarchies are built before they're attached to a Widget. (See 1152 // hierarchies are built before they're attached to a Widget. (See
1153 // views::WebView as an example; GetWidget() returns NULL at the point 1153 // views::WebView as an example; GetWidget() returns NULL at the point
1154 // where we are created.) 1154 // where we are created.)
1155 // 1155 //
1156 // It should be OK to not set a default parent since such users will 1156 // It should be OK to not set a default parent since such users will
1157 // explicitly add this WebContentsViewAura to their tree after they create 1157 // explicitly add this WebContentsViewAura to their tree after they create
1158 // us. 1158 // us.
1159 if (root_window) { 1159 if (root_window) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 // External popup menus are only used on Mac and Android. 1275 // External popup menus are only used on Mac and Android.
1276 NOTIMPLEMENTED(); 1276 NOTIMPLEMENTED();
1277 } 1277 }
1278 1278
1279 void WebContentsViewAura::StartDragging( 1279 void WebContentsViewAura::StartDragging(
1280 const DropData& drop_data, 1280 const DropData& drop_data,
1281 WebKit::WebDragOperationsMask operations, 1281 WebKit::WebDragOperationsMask operations,
1282 const gfx::ImageSkia& image, 1282 const gfx::ImageSkia& image,
1283 const gfx::Vector2d& image_offset, 1283 const gfx::Vector2d& image_offset,
1284 const DragEventSourceInfo& event_info) { 1284 const DragEventSourceInfo& event_info) {
1285 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 1285 aura::Window* root_window = GetNativeView()->GetRootWindow();
1286 if (!aura::client::GetDragDropClient(root_window)) { 1286 if (!aura::client::GetDragDropClient(root_window)) {
1287 web_contents_->SystemDragEnded(); 1287 web_contents_->SystemDragEnded();
1288 return; 1288 return;
1289 } 1289 }
1290 1290
1291 if (touch_editable_) 1291 if (touch_editable_)
1292 touch_editable_->EndTouchEditing(); 1292 touch_editable_->EndTouchEditing();
1293 1293
1294 ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider(); 1294 ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider();
1295 PrepareDragData(drop_data, provider); 1295 PrepareDragData(drop_data, provider);
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 event.location(), 1646 event.location(),
1647 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), 1647 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(),
1648 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 1648 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
1649 if (drag_dest_delegate_) 1649 if (drag_dest_delegate_)
1650 drag_dest_delegate_->OnDrop(); 1650 drag_dest_delegate_->OnDrop();
1651 current_drop_data_.reset(); 1651 current_drop_data_.reset();
1652 return current_drag_op_; 1652 return current_drag_op_;
1653 } 1653 }
1654 1654
1655 } // namespace content 1655 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698