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

Side by Side Diff: content/browser/renderer_host/render_widget_host_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: First cut for review/trybots 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/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 SetParent(window, ui::GetHiddenWindow()); 166 SetParent(window, ui::GetHiddenWindow());
167 return TRUE; 167 return TRUE;
168 } 168 }
169 169
170 BOOL CALLBACK ShowWindowsCallback(HWND window, LPARAM param) { 170 BOOL CALLBACK ShowWindowsCallback(HWND window, LPARAM param) {
171 RenderWidgetHostViewAura* widget = 171 RenderWidgetHostViewAura* widget =
172 reinterpret_cast<RenderWidgetHostViewAura*>(param); 172 reinterpret_cast<RenderWidgetHostViewAura*>(param);
173 173
174 if (GetProp(window, kWidgetOwnerProperty) == widget) { 174 if (GetProp(window, kWidgetOwnerProperty) == widget) {
175 HWND parent = 175 HWND parent =
176 widget->GetNativeView()->GetRootWindow()->GetAcceleratedWidget(); 176 widget->GetNativeView()->GetDispatcher()->GetAcceleratedWidget();
177 SetParent(window, parent); 177 SetParent(window, parent);
178 } 178 }
179 return TRUE; 179 return TRUE;
180 } 180 }
181 181
182 struct CutoutRectsParams { 182 struct CutoutRectsParams {
183 RenderWidgetHostViewAura* widget; 183 RenderWidgetHostViewAura* widget;
184 std::vector<gfx::Rect> cutout_rects; 184 std::vector<gfx::Rect> cutout_rects;
185 std::map<HWND, WebPluginGeometry>* geometry; 185 std::map<HWND, WebPluginGeometry>* geometry;
186 }; 186 };
187 187
188 // Used to update the region for the windowed plugin to draw in. We start with 188 // Used to update the region for the windowed plugin to draw in. We start with
189 // the clip rect from the renderer, then remove the cutout rects from the 189 // the clip rect from the renderer, then remove the cutout rects from the
190 // renderer, and then remove the transient windows from the root window and the 190 // renderer, and then remove the transient windows from the root window and the
191 // constrained windows from the parent window. 191 // constrained windows from the parent window.
192 BOOL CALLBACK SetCutoutRectsCallback(HWND window, LPARAM param) { 192 BOOL CALLBACK SetCutoutRectsCallback(HWND window, LPARAM param) {
193 CutoutRectsParams* params = reinterpret_cast<CutoutRectsParams*>(param); 193 CutoutRectsParams* params = reinterpret_cast<CutoutRectsParams*>(param);
194 194
195 if (GetProp(window, kWidgetOwnerProperty) == params->widget) { 195 if (GetProp(window, kWidgetOwnerProperty) == params->widget) {
196 // First calculate the offset of this plugin from the root window, since 196 // First calculate the offset of this plugin from the root window, since
197 // the cutouts are relative to the root window. 197 // the cutouts are relative to the root window.
198 HWND parent = params->widget->GetNativeView()->GetRootWindow()-> 198 HWND parent = params->widget->GetNativeView()->GetDispatcher()->
199 GetAcceleratedWidget(); 199 GetAcceleratedWidget();
200 POINT offset; 200 POINT offset;
201 offset.x = offset.y = 0; 201 offset.x = offset.y = 0;
202 MapWindowPoints(window, parent, &offset, 1); 202 MapWindowPoints(window, parent, &offset, 1);
203 203
204 // Now get the cached clip rect and cutouts for this plugin window that came 204 // Now get the cached clip rect and cutouts for this plugin window that came
205 // from the renderer. 205 // from the renderer.
206 std::map<HWND, WebPluginGeometry>::iterator i = params->geometry->begin(); 206 std::map<HWND, WebPluginGeometry>::iterator i = params->geometry->begin();
207 while (i != params->geometry->end() && 207 while (i != params->geometry->end() &&
208 i->second.window != window && 208 i->second.window != window &&
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } // namespace 391 } // namespace
392 392
393 // We need to watch for mouse events outside a Web Popup or its parent 393 // We need to watch for mouse events outside a Web Popup or its parent
394 // and dismiss the popup for certain events. 394 // and dismiss the popup for certain events.
395 class RenderWidgetHostViewAura::EventFilterForPopupExit : 395 class RenderWidgetHostViewAura::EventFilterForPopupExit :
396 public ui::EventHandler { 396 public ui::EventHandler {
397 public: 397 public:
398 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) 398 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva)
399 : rwhva_(rwhva) { 399 : rwhva_(rwhva) {
400 DCHECK(rwhva_); 400 DCHECK(rwhva_);
401 aura::RootWindow* root_window = rwhva_->window_->GetRootWindow(); 401 aura::Window* root_window = rwhva_->window_->GetRootWindow();
402 DCHECK(root_window); 402 DCHECK(root_window);
403 root_window->AddPreTargetHandler(this); 403 root_window->AddPreTargetHandler(this);
404 } 404 }
405 405
406 virtual ~EventFilterForPopupExit() { 406 virtual ~EventFilterForPopupExit() {
407 aura::RootWindow* root_window = rwhva_->window_->GetRootWindow(); 407 aura::Window* root_window = rwhva_->window_->GetRootWindow();
408 DCHECK(root_window); 408 DCHECK(root_window);
409 root_window->RemovePreTargetHandler(this); 409 root_window->RemovePreTargetHandler(this);
410 } 410 }
411 411
412 // Overridden from ui::EventHandler 412 // Overridden from ui::EventHandler
413 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 413 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
414 rwhva_->ApplyEventFilterForPopupExit(event); 414 rwhva_->ApplyEventFilterForPopupExit(event);
415 } 415 }
416 416
417 private: 417 private:
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // is not known now. 526 // is not known now.
527 } 527 }
528 528
529 virtual void OnRemoveTransientChild(aura::Window* window, 529 virtual void OnRemoveTransientChild(aura::Window* window,
530 aura::Window* transient) OVERRIDE { 530 aura::Window* transient) OVERRIDE {
531 transient->RemoveObserver(this); 531 transient->RemoveObserver(this);
532 SendPluginCutoutRects(); 532 SendPluginCutoutRects();
533 } 533 }
534 534
535 aura::Window* GetToplevelWindow() { 535 aura::Window* GetToplevelWindow() {
536 aura::RootWindow* root = view_->window_->GetRootWindow(); 536 aura::Window* root = view_->window_->GetRootWindow();
537 if (!root) 537 if (!root)
538 return NULL; 538 return NULL;
539 aura::client::ActivationClient* activation_client = 539 aura::client::ActivationClient* activation_client =
540 aura::client::GetActivationClient(root); 540 aura::client::GetActivationClient(root);
541 if (!activation_client) 541 if (!activation_client)
542 return NULL; 542 return NULL;
543 return activation_client->GetToplevelWindow(view_->window_); 543 return activation_client->GetToplevelWindow(view_->window_);
544 } 544 }
545 545
546 void StopObserving() { 546 void StopObserving() {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 // similar mechanism to ensure a second popup doesn't cause the first one 638 // similar mechanism to ensure a second popup doesn't cause the first one
639 // to never get a chance to filter events. See crbug.com/160589. 639 // to never get a chance to filter events. See crbug.com/160589.
640 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); 640 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_);
641 old_child->popup_parent_host_view_ = NULL; 641 old_child->popup_parent_host_view_ = NULL;
642 } 642 }
643 popup_parent_host_view_->popup_child_host_view_ = this; 643 popup_parent_host_view_->popup_child_host_view_ = this;
644 window_->SetType(aura::client::WINDOW_TYPE_MENU); 644 window_->SetType(aura::client::WINDOW_TYPE_MENU);
645 window_->Init(ui::LAYER_TEXTURED); 645 window_->Init(ui::LAYER_TEXTURED);
646 window_->SetName("RenderWidgetHostViewAura"); 646 window_->SetName("RenderWidgetHostViewAura");
647 647
648 aura::RootWindow* root = popup_parent_host_view_->window_->GetRootWindow(); 648 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow();
649 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); 649 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen);
650 650
651 // TODO(erg): While I could make sure details of the WindowTreeClient are 651 // TODO(erg): While I could make sure details of the WindowTreeClient are
652 // hidden behind aura, hiding the details of the ScreenPositionClient will 652 // hidden behind aura, hiding the details of the ScreenPositionClient will
653 // take another effort. 653 // take another effort.
654 aura::client::ScreenPositionClient* screen_position_client = 654 aura::client::ScreenPositionClient* screen_position_client =
655 aura::client::GetScreenPositionClient(root); 655 aura::client::GetScreenPositionClient(root);
656 gfx::Point origin_in_parent(bounds_in_screen.origin()); 656 gfx::Point origin_in_parent(bounds_in_screen.origin());
657 if (screen_position_client) { 657 if (screen_position_client) {
658 screen_position_client->ConvertPointFromScreen( 658 screen_position_client->ConvertPointFromScreen(
659 window_->parent(), &origin_in_parent); 659 window_->parent(), &origin_in_parent);
660 } 660 }
661 SetBounds(gfx::Rect(origin_in_parent, bounds_in_screen.size())); 661 SetBounds(gfx::Rect(origin_in_parent, bounds_in_screen.size()));
662 Show(); 662 Show();
663 } 663 }
664 664
665 void RenderWidgetHostViewAura::InitAsFullscreen( 665 void RenderWidgetHostViewAura::InitAsFullscreen(
666 RenderWidgetHostView* reference_host_view) { 666 RenderWidgetHostView* reference_host_view) {
667 is_fullscreen_ = true; 667 is_fullscreen_ = true;
668 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); 668 window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
669 window_->Init(ui::LAYER_TEXTURED); 669 window_->Init(ui::LAYER_TEXTURED);
670 window_->SetName("RenderWidgetHostViewAura"); 670 window_->SetName("RenderWidgetHostViewAura");
671 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 671 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
672 672
673 aura::RootWindow* parent = NULL; 673 aura::Window* parent = NULL;
674 gfx::Rect bounds; 674 gfx::Rect bounds;
675 if (reference_host_view) { 675 if (reference_host_view) {
676 aura::Window* reference_window = 676 aura::Window* reference_window =
677 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; 677 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_;
678 if (reference_window) { 678 if (reference_window) {
679 host_tracker_.reset(new aura::WindowTracker); 679 host_tracker_.reset(new aura::WindowTracker);
680 host_tracker_->Add(reference_window); 680 host_tracker_->Add(reference_window);
681 } 681 }
682 gfx::Display display = gfx::Screen::GetScreenFor(window_)-> 682 gfx::Display display = gfx::Screen::GetScreenFor(window_)->
683 GetDisplayNearestWindow(reference_window); 683 GetDisplayNearestWindow(reference_window);
(...skipping 10 matching lines...) Expand all
694 } 694 }
695 695
696 void RenderWidgetHostViewAura::WasShown() { 696 void RenderWidgetHostViewAura::WasShown() {
697 DCHECK(host_); 697 DCHECK(host_);
698 if (!host_->is_hidden()) 698 if (!host_->is_hidden())
699 return; 699 return;
700 host_->WasShown(); 700 host_->WasShown();
701 if (framebuffer_holder_) 701 if (framebuffer_holder_)
702 FrameMemoryManager::GetInstance()->SetFrameVisibility(this, true); 702 FrameMemoryManager::GetInstance()->SetFrameVisibility(this, true);
703 703
704 aura::RootWindow* root = window_->GetRootWindow(); 704 aura::Window* root = window_->GetRootWindow();
705 if (root) { 705 if (root) {
706 aura::client::CursorClient* cursor_client = 706 aura::client::CursorClient* cursor_client =
707 aura::client::GetCursorClient(root); 707 aura::client::GetCursorClient(root);
708 if (cursor_client) 708 if (cursor_client)
709 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 709 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
710 } 710 }
711 711
712 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && 712 if (!current_surface_.get() && host_->is_accelerated_compositing_active() &&
713 !released_front_lock_.get()) { 713 !released_front_lock_.get()) {
714 ui::Compositor* compositor = GetCompositor(); 714 ui::Compositor* compositor = GetCompositor();
(...skipping 11 matching lines...) Expand all
726 void RenderWidgetHostViewAura::WasHidden() { 726 void RenderWidgetHostViewAura::WasHidden() {
727 if (!host_ || host_->is_hidden()) 727 if (!host_ || host_->is_hidden())
728 return; 728 return;
729 host_->WasHidden(); 729 host_->WasHidden();
730 if (framebuffer_holder_) 730 if (framebuffer_holder_)
731 FrameMemoryManager::GetInstance()->SetFrameVisibility(this, false); 731 FrameMemoryManager::GetInstance()->SetFrameVisibility(this, false);
732 732
733 released_front_lock_ = NULL; 733 released_front_lock_ = NULL;
734 734
735 #if defined(OS_WIN) 735 #if defined(OS_WIN)
736 aura::RootWindow* root_window = window_->GetRootWindow(); 736 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
737 if (root_window) { 737 if (dispatcher) {
738 HWND parent = root_window->GetAcceleratedWidget(); 738 HWND parent = dispatcher->GetAcceleratedWidget();
739 LPARAM lparam = reinterpret_cast<LPARAM>(this); 739 LPARAM lparam = reinterpret_cast<LPARAM>(this);
740 740
741 EnumChildWindows(parent, HideWindowsCallback, lparam); 741 EnumChildWindows(parent, HideWindowsCallback, lparam);
742 } 742 }
743 #endif 743 #endif
744 } 744 }
745 745
746 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 746 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
747 SetBounds(gfx::Rect(window_->bounds().origin(), size)); 747 SetBounds(gfx::Rect(window_->bounds().origin(), size));
748 } 748 }
749 749
750 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 750 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
751 if (HasDisplayPropertyChanged(window_)) 751 if (HasDisplayPropertyChanged(window_))
752 host_->InvalidateScreenInfo(); 752 host_->InvalidateScreenInfo();
753 753
754 window_->SetBounds(rect); 754 window_->SetBounds(rect);
755 host_->WasResized(); 755 host_->WasResized();
756 MaybeCreateResizeLock(); 756 MaybeCreateResizeLock();
757 if (touch_editing_client_) { 757 if (touch_editing_client_) {
758 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 758 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_,
759 selection_focus_rect_); 759 selection_focus_rect_);
760 } 760 }
761 } 761 }
762 762
763 void RenderWidgetHostViewAura::MaybeCreateResizeLock() { 763 void RenderWidgetHostViewAura::MaybeCreateResizeLock() {
764 if (!ShouldCreateResizeLock()) 764 if (!ShouldCreateResizeLock())
765 return; 765 return;
766 DCHECK(window_->GetRootWindow()); 766 DCHECK(window_->GetDispatcher());
767 DCHECK(window_->GetRootWindow()->compositor()); 767 DCHECK(window_->GetDispatcher()->compositor());
768 768
769 // Listen to changes in the compositor lock state. 769 // Listen to changes in the compositor lock state.
770 ui::Compositor* compositor = window_->GetRootWindow()->compositor(); 770 ui::Compositor* compositor = window_->GetDispatcher()->compositor();
771 if (!compositor->HasObserver(this)) 771 if (!compositor->HasObserver(this))
772 compositor->AddObserver(this); 772 compositor->AddObserver(this);
773 773
774 bool defer_compositor_lock = 774 bool defer_compositor_lock =
775 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || 775 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME ||
776 can_lock_compositor_ == NO_PENDING_COMMIT; 776 can_lock_compositor_ == NO_PENDING_COMMIT;
777 777
778 if (can_lock_compositor_ == YES) 778 if (can_lock_compositor_ == YES)
779 can_lock_compositor_ = YES_DID_LOCK; 779 can_lock_compositor_ = YES_DID_LOCK;
780 780
(...skipping 17 matching lines...) Expand all
798 798
799 if (host_->should_auto_resize()) 799 if (host_->should_auto_resize())
800 return false; 800 return false;
801 if (!host_->is_accelerated_compositing_active()) 801 if (!host_->is_accelerated_compositing_active())
802 return false; 802 return false;
803 803
804 gfx::Size desired_size = window_->bounds().size(); 804 gfx::Size desired_size = window_->bounds().size();
805 if (desired_size == current_frame_size_) 805 if (desired_size == current_frame_size_)
806 return false; 806 return false;
807 807
808 aura::RootWindow* root_window = window_->GetRootWindow(); 808 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
809 if (!root_window) 809 if (!dispatcher)
810 return false; 810 return false;
811 811
812 ui::Compositor* compositor = root_window->compositor(); 812 ui::Compositor* compositor = dispatcher->compositor();
813 if (!compositor) 813 if (!compositor)
814 return false; 814 return false;
815 815
816 return true; 816 return true;
817 } 817 }
818 818
819 scoped_ptr<ResizeLock> RenderWidgetHostViewAura::CreateResizeLock( 819 scoped_ptr<ResizeLock> RenderWidgetHostViewAura::CreateResizeLock(
820 bool defer_compositor_lock) { 820 bool defer_compositor_lock) {
821 gfx::Size desired_size = window_->bounds().size(); 821 gfx::Size desired_size = window_->bounds().size();
822 return scoped_ptr<ResizeLock>(new CompositorResizeLock( 822 return scoped_ptr<ResizeLock>(new CompositorResizeLock(
823 window_->GetRootWindow(), 823 window_->GetDispatcher(),
824 desired_size, 824 desired_size,
825 defer_compositor_lock, 825 defer_compositor_lock,
826 base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs))); 826 base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs)));
827 } 827 }
828 828
829 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { 829 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const {
830 return window_; 830 return window_;
831 } 831 }
832 832
833 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { 833 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const {
834 #if defined(OS_WIN) 834 #if defined(OS_WIN)
835 aura::RootWindow* root_window = window_->GetRootWindow(); 835 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
836 if (root_window) { 836 if (dispatcher) {
837 HWND window = root_window->GetAcceleratedWidget(); 837 HWND window = dispatcher->GetAcceleratedWidget();
838 return reinterpret_cast<gfx::NativeViewId>(window); 838 return reinterpret_cast<gfx::NativeViewId>(window);
839 } 839 }
840 #endif 840 #endif
841 return static_cast<gfx::NativeViewId>(NULL); 841 return static_cast<gfx::NativeViewId>(NULL);
842 } 842 }
843 843
844 gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() { 844 gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() {
845 #if defined(OS_WIN) 845 #if defined(OS_WIN)
846 aura::RootWindow* root_window = window_->GetRootWindow(); 846 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
847 if (!root_window) 847 if (!dispatcher)
848 return static_cast<gfx::NativeViewAccessible>(NULL); 848 return static_cast<gfx::NativeViewAccessible>(NULL);
849 HWND hwnd = root_window->GetAcceleratedWidget(); 849 HWND hwnd = dispatcher->GetAcceleratedWidget();
850 850
851 BrowserAccessibilityManager* manager = 851 BrowserAccessibilityManager* manager =
852 GetOrCreateBrowserAccessibilityManager(); 852 GetOrCreateBrowserAccessibilityManager();
853 if (manager) 853 if (manager)
854 return manager->GetRoot()->ToBrowserAccessibilityWin(); 854 return manager->GetRoot()->ToBrowserAccessibilityWin();
855 #endif 855 #endif
856 856
857 NOTIMPLEMENTED(); 857 NOTIMPLEMENTED();
858 return static_cast<gfx::NativeViewAccessible>(NULL); 858 return static_cast<gfx::NativeViewAccessible>(NULL);
859 } 859 }
860 860
861 BrowserAccessibilityManager* 861 BrowserAccessibilityManager*
862 RenderWidgetHostViewAura::GetOrCreateBrowserAccessibilityManager() { 862 RenderWidgetHostViewAura::GetOrCreateBrowserAccessibilityManager() {
863 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager(); 863 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager();
864 if (manager) 864 if (manager)
865 return manager; 865 return manager;
866 866
867 #if defined(OS_WIN) 867 #if defined(OS_WIN)
868 aura::RootWindow* root_window = window_->GetRootWindow(); 868 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
869 if (!root_window) 869 if (!dispatcher)
870 return NULL; 870 return NULL;
871 HWND hwnd = root_window->GetAcceleratedWidget(); 871 HWND hwnd = dispatcher->GetAcceleratedWidget();
872 872
873 // The accessible_parent may be NULL at this point. The WebContents will pass 873 // The accessible_parent may be NULL at this point. The WebContents will pass
874 // it down to this instance (by way of the RenderViewHost and 874 // it down to this instance (by way of the RenderViewHost and
875 // RenderWidgetHost) when it is known. This instance will then set it on its 875 // RenderWidgetHost) when it is known. This instance will then set it on its
876 // BrowserAccessibilityManager. 876 // BrowserAccessibilityManager.
877 gfx::NativeViewAccessible accessible_parent = 877 gfx::NativeViewAccessible accessible_parent =
878 host_->GetParentNativeViewAccessible(); 878 host_->GetParentNativeViewAccessible();
879 879
880 manager = new BrowserAccessibilityManagerWin( 880 manager = new BrowserAccessibilityManagerWin(
881 hwnd, accessible_parent, 881 hwnd, accessible_parent,
(...skipping 10 matching lines...) Expand all
892 void RenderWidgetHostViewAura::MovePluginWindows( 892 void RenderWidgetHostViewAura::MovePluginWindows(
893 const gfx::Vector2d& scroll_offset, 893 const gfx::Vector2d& scroll_offset,
894 const std::vector<WebPluginGeometry>& plugin_window_moves) { 894 const std::vector<WebPluginGeometry>& plugin_window_moves) {
895 #if defined(OS_WIN) 895 #if defined(OS_WIN)
896 // We need to clip the rectangle to the tab's viewport, otherwise we will draw 896 // We need to clip the rectangle to the tab's viewport, otherwise we will draw
897 // over the browser UI. 897 // over the browser UI.
898 if (!window_->GetRootWindow()) { 898 if (!window_->GetRootWindow()) {
899 DCHECK(plugin_window_moves.empty()); 899 DCHECK(plugin_window_moves.empty());
900 return; 900 return;
901 } 901 }
902 HWND parent = window_->GetRootWindow()->GetAcceleratedWidget(); 902 HWND parent = window_->GetDispatcher()->GetAcceleratedWidget();
903 gfx::Rect view_bounds = window_->GetBoundsInRootWindow(); 903 gfx::Rect view_bounds = window_->GetBoundsInRootWindow();
904 std::vector<WebPluginGeometry> moves = plugin_window_moves; 904 std::vector<WebPluginGeometry> moves = plugin_window_moves;
905 905
906 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(), 906 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(),
907 view_bounds.height()); 907 view_bounds.height());
908 908
909 for (size_t i = 0; i < moves.size(); ++i) { 909 for (size_t i = 0; i < moves.size(); ++i) {
910 gfx::Rect clip(moves[i].clip_rect); 910 gfx::Rect clip(moves[i].clip_rect);
911 gfx::Vector2d view_port_offset( 911 gfx::Vector2d view_port_offset(
912 moves[i].window_rect.OffsetFromOrigin() + scroll_offset); 912 moves[i].window_rect.OffsetFromOrigin() + scroll_offset);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 if (paint_canvas_) { 1067 if (paint_canvas_) {
1068 SkRect sk_clip_rect; 1068 SkRect sk_clip_rect;
1069 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect)) 1069 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect))
1070 clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect)); 1070 clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect));
1071 } 1071 }
1072 1072
1073 if (!scroll_rect.IsEmpty()) 1073 if (!scroll_rect.IsEmpty())
1074 SchedulePaintIfNotInClip(scroll_rect, clip_rect); 1074 SchedulePaintIfNotInClip(scroll_rect, clip_rect);
1075 1075
1076 #if defined(OS_WIN) 1076 #if defined(OS_WIN)
1077 aura::RootWindow* root_window = window_->GetRootWindow(); 1077 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
1078 #endif 1078 #endif
1079 for (size_t i = 0; i < copy_rects.size(); ++i) { 1079 for (size_t i = 0; i < copy_rects.size(); ++i) {
1080 gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect); 1080 gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect);
1081 if (rect.IsEmpty()) 1081 if (rect.IsEmpty())
1082 continue; 1082 continue;
1083 1083
1084 SchedulePaintIfNotInClip(rect, clip_rect); 1084 SchedulePaintIfNotInClip(rect, clip_rect);
1085 1085
1086 #if defined(OS_WIN) 1086 #if defined(OS_WIN)
1087 if (root_window) { 1087 if (dispatcher) {
1088 // Send the invalid rect in screen coordinates. 1088 // Send the invalid rect in screen coordinates.
1089 gfx::Rect screen_rect = GetViewBounds(); 1089 gfx::Rect screen_rect = GetViewBounds();
1090 gfx::Rect invalid_screen_rect(rect); 1090 gfx::Rect invalid_screen_rect(rect);
1091 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); 1091 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y());
1092 HWND hwnd = root_window->GetAcceleratedWidget(); 1092 HWND hwnd = dispatcher->GetAcceleratedWidget();
1093 PaintPluginWindowsHelper(hwnd, invalid_screen_rect); 1093 PaintPluginWindowsHelper(hwnd, invalid_screen_rect);
1094 } 1094 }
1095 #endif // defined(OS_WIN) 1095 #endif // defined(OS_WIN)
1096 } 1096 }
1097 } 1097 }
1098 1098
1099 void RenderWidgetHostViewAura::RenderProcessGone(base::TerminationStatus status, 1099 void RenderWidgetHostViewAura::RenderProcessGone(base::TerminationStatus status,
1100 int error_code) { 1100 int error_code) {
1101 UpdateCursorIfOverSelf(); 1101 UpdateCursorIfOverSelf();
1102 Destroy(); 1102 Destroy();
1103 } 1103 }
1104 1104
1105 void RenderWidgetHostViewAura::Destroy() { 1105 void RenderWidgetHostViewAura::Destroy() {
1106 // Beware, this function is not called on all destruction paths. It will 1106 // Beware, this function is not called on all destruction paths. It will
1107 // implicitly end up calling ~RenderWidgetHostViewAura though, so all 1107 // implicitly end up calling ~RenderWidgetHostViewAura though, so all
1108 // destruction/cleanup code should happen there, not here. 1108 // destruction/cleanup code should happen there, not here.
1109 in_shutdown_ = true; 1109 in_shutdown_ = true;
1110 delete window_; 1110 delete window_;
1111 } 1111 }
1112 1112
1113 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { 1113 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) {
1114 tooltip_ = tooltip_text; 1114 tooltip_ = tooltip_text;
1115 aura::RootWindow* root_window = window_->GetRootWindow(); 1115 aura::Window* root_window = window_->GetRootWindow();
1116 aura::client::TooltipClient* tooltip_client = 1116 aura::client::TooltipClient* tooltip_client =
1117 aura::client::GetTooltipClient(root_window); 1117 aura::client::GetTooltipClient(root_window);
1118 if (tooltip_client) { 1118 if (tooltip_client) {
1119 tooltip_client->UpdateTooltip(window_); 1119 tooltip_client->UpdateTooltip(window_);
1120 // Content tooltips should be visible indefinitely. 1120 // Content tooltips should be visible indefinitely.
1121 tooltip_client->SetTooltipShownTimeout(window_, 0); 1121 tooltip_client->SetTooltipShownTimeout(window_, 0);
1122 } 1122 }
1123 } 1123 }
1124 1124
1125 void RenderWidgetHostViewAura::SelectionChanged(const string16& text, 1125 void RenderWidgetHostViewAura::SelectionChanged(const string16& text,
(...skipping 25 matching lines...) Expand all
1151 if (GetInputMethod()) 1151 if (GetInputMethod())
1152 GetInputMethod()->OnCaretBoundsChanged(this); 1152 GetInputMethod()->OnCaretBoundsChanged(this);
1153 1153
1154 if (touch_editing_client_) { 1154 if (touch_editing_client_) {
1155 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 1155 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_,
1156 selection_focus_rect_); 1156 selection_focus_rect_);
1157 } 1157 }
1158 } 1158 }
1159 1159
1160 void RenderWidgetHostViewAura::ScrollOffsetChanged() { 1160 void RenderWidgetHostViewAura::ScrollOffsetChanged() {
1161 aura::RootWindow* root = window_->GetRootWindow(); 1161 aura::Window* root = window_->GetRootWindow();
1162 if (!root) 1162 if (!root)
1163 return; 1163 return;
1164 aura::client::CursorClient* cursor_client = 1164 aura::client::CursorClient* cursor_client =
1165 aura::client::GetCursorClient(root); 1165 aura::client::GetCursorClient(root);
1166 if (cursor_client && !cursor_client->IsCursorVisible()) 1166 if (cursor_client && !cursor_client->IsCursorVisible())
1167 cursor_client->DisableMouseEvents(); 1167 cursor_client->DisableMouseEvents();
1168 } 1168 }
1169 1169
1170 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( 1170 BackingStore* RenderWidgetHostViewAura::AllocBackingStore(
1171 const gfx::Size& size) { 1171 const gfx::Size& size) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1386
1387 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( 1387 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects(
1388 const std::vector<gfx::Rect>& rects) { 1388 const std::vector<gfx::Rect>& rects) {
1389 constrained_rects_ = rects; 1389 constrained_rects_ = rects;
1390 UpdateCutoutRects(); 1390 UpdateCutoutRects();
1391 } 1391 }
1392 1392
1393 void RenderWidgetHostViewAura::UpdateCutoutRects() { 1393 void RenderWidgetHostViewAura::UpdateCutoutRects() {
1394 if (!window_->GetRootWindow()) 1394 if (!window_->GetRootWindow())
1395 return; 1395 return;
1396 HWND parent = window_->GetRootWindow()->GetAcceleratedWidget(); 1396 HWND parent = window_->GetDispatcher()->GetAcceleratedWidget();
1397 CutoutRectsParams params; 1397 CutoutRectsParams params;
1398 params.widget = this; 1398 params.widget = this;
1399 params.cutout_rects.assign(transient_rects_.begin(), transient_rects_.end()); 1399 params.cutout_rects.assign(transient_rects_.begin(), transient_rects_.end());
1400 params.cutout_rects.insert(params.cutout_rects.end(), 1400 params.cutout_rects.insert(params.cutout_rects.end(),
1401 constrained_rects_.begin(), 1401 constrained_rects_.begin(),
1402 constrained_rects_.end()); 1402 constrained_rects_.end());
1403 params.geometry = &plugin_window_moves_; 1403 params.geometry = &plugin_window_moves_;
1404 LPARAM lparam = reinterpret_cast<LPARAM>(&params); 1404 LPARAM lparam = reinterpret_cast<LPARAM>(&params);
1405 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); 1405 EnumChildWindows(parent, SetCutoutRectsCallback, lparam);
1406 } 1406 }
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); 2116 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL);
2117 } 2117 }
2118 2118
2119 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { 2119 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
2120 #if defined(OS_WIN) 2120 #if defined(OS_WIN)
2121 // aura::Window::GetBoundsInScreen doesn't take non-client area into 2121 // aura::Window::GetBoundsInScreen doesn't take non-client area into
2122 // account. 2122 // account.
2123 RECT window_rect = {0}; 2123 RECT window_rect = {0};
2124 2124
2125 aura::Window* top_level = window_->GetToplevelWindow(); 2125 aura::Window* top_level = window_->GetToplevelWindow();
2126 aura::RootWindow* root_window = top_level->GetRootWindow(); 2126 aura::WindowEventDispatcher* dispatcher = top_level->GetDispatcher();
2127 if (!root_window) 2127 if (!dispatcher)
2128 return top_level->GetBoundsInScreen(); 2128 return top_level->GetBoundsInScreen();
2129 HWND hwnd = root_window->GetAcceleratedWidget(); 2129 HWND hwnd = dispatcher->GetAcceleratedWidget();
2130 ::GetWindowRect(hwnd, &window_rect); 2130 ::GetWindowRect(hwnd, &window_rect);
2131 gfx::Rect rect(window_rect); 2131 gfx::Rect rect(window_rect);
2132 2132
2133 // Maximized windows are outdented from the work area by the frame thickness 2133 // Maximized windows are outdented from the work area by the frame thickness
2134 // even though this "frame" is not painted. This confuses code (and people) 2134 // even though this "frame" is not painted. This confuses code (and people)
2135 // that think of a maximized window as corresponding exactly to the work area. 2135 // that think of a maximized window as corresponding exactly to the work area.
2136 // Correct for this by subtracting the frame thickness back off. 2136 // Correct for this by subtracting the frame thickness back off.
2137 if (::IsZoomed(hwnd)) { 2137 if (::IsZoomed(hwnd)) {
2138 rect.Inset(GetSystemMetrics(SM_CXSIZEFRAME), 2138 rect.Inset(GetSystemMetrics(SM_CXSIZEFRAME),
2139 GetSystemMetrics(SM_CYSIZEFRAME)); 2139 GetSystemMetrics(SM_CYSIZEFRAME));
(...skipping 11 matching lines...) Expand all
2151 touch_editing_client_->GestureEventAck(gesture_event_type); 2151 touch_editing_client_->GestureEventAck(gesture_event_type);
2152 } 2152 }
2153 2153
2154 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( 2154 void RenderWidgetHostViewAura::ProcessAckedTouchEvent(
2155 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { 2155 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) {
2156 ScopedVector<ui::TouchEvent> events; 2156 ScopedVector<ui::TouchEvent> events;
2157 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, 2157 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events,
2158 SCREEN_COORDINATES)) 2158 SCREEN_COORDINATES))
2159 return; 2159 return;
2160 2160
2161 aura::RootWindow* root = window_->GetRootWindow(); 2161 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
2162 // |root| is NULL during tests. 2162 // |dispatcher| is NULL during tests.
2163 if (!root) 2163 if (!dispatcher)
2164 return; 2164 return;
2165 2165
2166 ui::EventResult result = (ack_result == 2166 ui::EventResult result = (ack_result ==
2167 INPUT_EVENT_ACK_STATE_CONSUMED) ? ui::ER_HANDLED : ui::ER_UNHANDLED; 2167 INPUT_EVENT_ACK_STATE_CONSUMED) ? ui::ER_HANDLED : ui::ER_UNHANDLED;
2168 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), 2168 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
2169 end = events.end(); iter != end; ++iter) { 2169 end = events.end(); iter != end; ++iter) {
2170 root->ProcessedTouchEvent((*iter), window_, result); 2170 dispatcher->ProcessedTouchEvent((*iter), window_, result);
2171 } 2171 }
2172 } 2172 }
2173 2173
2174 SyntheticGesture* RenderWidgetHostViewAura::CreateSmoothScrollGesture( 2174 SyntheticGesture* RenderWidgetHostViewAura::CreateSmoothScrollGesture(
2175 bool scroll_down, 2175 bool scroll_down,
2176 int pixels_to_scroll, 2176 int pixels_to_scroll,
2177 int mouse_event_x, 2177 int mouse_event_x,
2178 int mouse_event_y) { 2178 int mouse_event_y) {
2179 return new TouchSmoothScrollGestureAura(scroll_down, 2179 return new TouchSmoothScrollGestureAura(scroll_down,
2180 pixels_to_scroll, 2180 pixels_to_scroll,
(...skipping 24 matching lines...) Expand all
2205 if (shared_surface_handle_.is_null()) { 2205 if (shared_surface_handle_.is_null()) {
2206 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 2206 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
2207 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(); 2207 shared_surface_handle_ = factory->CreateSharedSurfaceHandle();
2208 if (!shared_surface_handle_.is_null()) 2208 if (!shared_surface_handle_.is_null())
2209 factory->AddObserver(this); 2209 factory->AddObserver(this);
2210 } 2210 }
2211 return shared_surface_handle_; 2211 return shared_surface_handle_;
2212 } 2212 }
2213 2213
2214 bool RenderWidgetHostViewAura::LockMouse() { 2214 bool RenderWidgetHostViewAura::LockMouse() {
2215 aura::RootWindow* root_window = window_->GetRootWindow(); 2215 aura::Window* root_window = window_->GetRootWindow();
2216 if (!root_window) 2216 if (!root_window)
2217 return false; 2217 return false;
2218 2218
2219 if (mouse_locked_) 2219 if (mouse_locked_)
2220 return true; 2220 return true;
2221 2221
2222 mouse_locked_ = true; 2222 mouse_locked_ = true;
2223 #if !defined(OS_WIN) 2223 #if !defined(OS_WIN)
2224 window_->SetCapture(); 2224 window_->SetCapture();
2225 #endif 2225 #endif
2226 aura::client::CursorClient* cursor_client = 2226 aura::client::CursorClient* cursor_client =
2227 aura::client::GetCursorClient(root_window); 2227 aura::client::GetCursorClient(root_window);
2228 if (cursor_client) { 2228 if (cursor_client) {
2229 cursor_client->HideCursor(); 2229 cursor_client->HideCursor();
2230 cursor_client->LockCursor(); 2230 cursor_client->LockCursor();
2231 } 2231 }
2232 2232
2233 if (ShouldMoveToCenter()) { 2233 if (ShouldMoveToCenter()) {
2234 synthetic_move_sent_ = true; 2234 synthetic_move_sent_ = true;
2235 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint()); 2235 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint());
2236 } 2236 }
2237 if (aura::client::GetTooltipClient(root_window)) 2237 if (aura::client::GetTooltipClient(root_window))
2238 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false); 2238 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false);
2239 return true; 2239 return true;
2240 } 2240 }
2241 2241
2242 void RenderWidgetHostViewAura::UnlockMouse() { 2242 void RenderWidgetHostViewAura::UnlockMouse() {
2243 aura::RootWindow* root_window = window_->GetRootWindow(); 2243 aura::Window* root_window = window_->GetRootWindow();
2244 if (!mouse_locked_ || !root_window) 2244 if (!mouse_locked_ || !root_window)
2245 return; 2245 return;
2246 2246
2247 mouse_locked_ = false; 2247 mouse_locked_ = false;
2248 2248
2249 #if !defined(OS_WIN) 2249 #if !defined(OS_WIN)
2250 window_->ReleaseCapture(); 2250 window_->ReleaseCapture();
2251 #endif 2251 #endif
2252 window_->MoveCursorTo(unlocked_mouse_position_); 2252 window_->MoveCursorTo(unlocked_mouse_position_);
2253 aura::client::CursorClient* cursor_client = 2253 aura::client::CursorClient* cursor_client =
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 2342
2343 bool RenderWidgetHostViewAura::CanComposeInline() const { 2343 bool RenderWidgetHostViewAura::CanComposeInline() const {
2344 return can_compose_inline_; 2344 return can_compose_inline_;
2345 } 2345 }
2346 2346
2347 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( 2347 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(
2348 const gfx::Rect& rect) const { 2348 const gfx::Rect& rect) const {
2349 gfx::Point origin = rect.origin(); 2349 gfx::Point origin = rect.origin();
2350 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 2350 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
2351 2351
2352 aura::RootWindow* root_window = window_->GetRootWindow(); 2352 aura::Window* root_window = window_->GetRootWindow();
2353 if (!root_window) 2353 if (!root_window)
2354 return rect; 2354 return rect;
2355 aura::client::ScreenPositionClient* screen_position_client = 2355 aura::client::ScreenPositionClient* screen_position_client =
2356 aura::client::GetScreenPositionClient(root_window); 2356 aura::client::GetScreenPositionClient(root_window);
2357 if (!screen_position_client) 2357 if (!screen_position_client)
2358 return rect; 2358 return rect;
2359 screen_position_client->ConvertPointToScreen(window_, &origin); 2359 screen_position_client->ConvertPointToScreen(window_, &origin);
2360 screen_position_client->ConvertPointToScreen(window_, &end); 2360 screen_position_client->ConvertPointToScreen(window_, &end);
2361 return gfx::Rect(origin.x(), 2361 return gfx::Rect(origin.x(),
2362 origin.y(), 2362 origin.y(),
2363 end.x() - origin.x(), 2363 end.x() - origin.x(),
2364 end.y() - origin.y()); 2364 end.y() - origin.y());
2365 } 2365 }
2366 2366
2367 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen( 2367 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
2368 const gfx::Rect& rect) const { 2368 const gfx::Rect& rect) const {
2369 gfx::Point origin = rect.origin(); 2369 gfx::Point origin = rect.origin();
2370 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 2370 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
2371 2371
2372 aura::RootWindow* root_window = window_->GetRootWindow(); 2372 aura::Window* root_window = window_->GetRootWindow();
2373 if (root_window) { 2373 if (root_window) {
2374 aura::client::ScreenPositionClient* screen_position_client = 2374 aura::client::ScreenPositionClient* screen_position_client =
2375 aura::client::GetScreenPositionClient(root_window); 2375 aura::client::GetScreenPositionClient(root_window);
2376 screen_position_client->ConvertPointFromScreen(window_, &origin); 2376 screen_position_client->ConvertPointFromScreen(window_, &origin);
2377 screen_position_client->ConvertPointFromScreen(window_, &end); 2377 screen_position_client->ConvertPointFromScreen(window_, &end);
2378 return gfx::Rect(origin.x(), 2378 return gfx::Rect(origin.x(),
2379 origin.y(), 2379 origin.y(),
2380 end.x() - origin.x(), 2380 end.x() - origin.x(),
2381 end.y() - origin.y()); 2381 end.y() - origin.y());
2382 } 2382 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2608 } 2608 }
2609 2609
2610 void RenderWidgetHostViewAura::OnWindowDestroying() { 2610 void RenderWidgetHostViewAura::OnWindowDestroying() {
2611 #if defined(OS_WIN) 2611 #if defined(OS_WIN)
2612 HWND parent = NULL; 2612 HWND parent = NULL;
2613 // If the tab was hidden and it's closed, host_->is_hidden would have been 2613 // If the tab was hidden and it's closed, host_->is_hidden would have been
2614 // reset to false in RenderWidgetHostImpl::RendererExited. 2614 // reset to false in RenderWidgetHostImpl::RendererExited.
2615 if (!window_->GetRootWindow() || host_->is_hidden()) { 2615 if (!window_->GetRootWindow() || host_->is_hidden()) {
2616 parent = ui::GetHiddenWindow(); 2616 parent = ui::GetHiddenWindow();
2617 } else { 2617 } else {
2618 parent = window_->GetRootWindow()->GetAcceleratedWidget(); 2618 parent = window_->GetDispatcher()->GetAcceleratedWidget();
2619 } 2619 }
2620 LPARAM lparam = reinterpret_cast<LPARAM>(this); 2620 LPARAM lparam = reinterpret_cast<LPARAM>(this);
2621 EnumChildWindows(parent, WindowDestroyingCallback, lparam); 2621 EnumChildWindows(parent, WindowDestroyingCallback, lparam);
2622 #endif 2622 #endif
2623 2623
2624 // Make sure that the input method no longer references to this object before 2624 // Make sure that the input method no longer references to this object before
2625 // this object is removed from the root window (i.e. this object loses access 2625 // this object is removed from the root window (i.e. this object loses access
2626 // to the input method). 2626 // to the input method).
2627 ui::InputMethod* input_method = GetInputMethod(); 2627 ui::InputMethod* input_method = GetInputMethod();
2628 if (input_method) 2628 if (input_method)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2812 event->type() == ui::ET_MOUSE_MOVED)) { 2812 event->type() == ui::ET_MOUSE_MOVED)) {
2813 event->StopPropagation(); 2813 event->StopPropagation();
2814 return; 2814 return;
2815 } 2815 }
2816 2816
2817 if (event->type() == ui::ET_MOUSEWHEEL) { 2817 if (event->type() == ui::ET_MOUSEWHEEL) {
2818 #if defined(OS_WIN) 2818 #if defined(OS_WIN)
2819 // We get mouse wheel/scroll messages even if we are not in the foreground. 2819 // We get mouse wheel/scroll messages even if we are not in the foreground.
2820 // So here we check if we have any owned popup windows in the foreground and 2820 // So here we check if we have any owned popup windows in the foreground and
2821 // dismiss them. 2821 // dismiss them.
2822 aura::RootWindow* root_window = window_->GetRootWindow(); 2822 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
2823 if (root_window) { 2823 if (dispatcher) {
2824 HWND parent = root_window->GetAcceleratedWidget(); 2824 HWND parent = dispatcher->GetAcceleratedWidget();
2825 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT); 2825 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT);
2826 EnumThreadWindows(GetCurrentThreadId(), 2826 EnumThreadWindows(GetCurrentThreadId(),
2827 DismissOwnedPopups, 2827 DismissOwnedPopups,
2828 reinterpret_cast<LPARAM>(toplevel_hwnd)); 2828 reinterpret_cast<LPARAM>(toplevel_hwnd));
2829 } 2829 }
2830 #endif 2830 #endif
2831 WebKit::WebMouseWheelEvent mouse_wheel_event = 2831 WebKit::WebMouseWheelEvent mouse_wheel_event =
2832 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); 2832 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event));
2833 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 2833 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0)
2834 host_->ForwardWheelEvent(mouse_wheel_event); 2834 host_->ForwardWheelEvent(mouse_wheel_event);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2969 2969
2970 // If a gesture is not processed by the webpage, then WebKit processes it 2970 // If a gesture is not processed by the webpage, then WebKit processes it
2971 // (e.g. generates synthetic mouse events). 2971 // (e.g. generates synthetic mouse events).
2972 event->SetHandled(); 2972 event->SetHandled();
2973 } 2973 }
2974 2974
2975 //////////////////////////////////////////////////////////////////////////////// 2975 ////////////////////////////////////////////////////////////////////////////////
2976 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: 2976 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation:
2977 2977
2978 bool RenderWidgetHostViewAura::ShouldActivate() const { 2978 bool RenderWidgetHostViewAura::ShouldActivate() const {
2979 aura::RootWindow* root_window = window_->GetRootWindow(); 2979 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
2980 if (!root_window) 2980 if (!dispatcher)
2981 return true; 2981 return true;
2982 const ui::Event* event = root_window->current_event(); 2982 const ui::Event* event = dispatcher->current_event();
2983 if (!event) 2983 if (!event)
2984 return true; 2984 return true;
2985 return is_fullscreen_; 2985 return is_fullscreen_;
2986 } 2986 }
2987 2987
2988 //////////////////////////////////////////////////////////////////////////////// 2988 ////////////////////////////////////////////////////////////////////////////////
2989 // RenderWidgetHostViewAura, 2989 // RenderWidgetHostViewAura,
2990 // aura::client::ActivationChangeObserver implementation: 2990 // aura::client::ActivationChangeObserver implementation:
2991 2991
2992 void RenderWidgetHostViewAura::OnWindowActivated(aura::Window* gained_active, 2992 void RenderWidgetHostViewAura::OnWindowActivated(aura::Window* gained_active,
2993 aura::Window* lost_active) { 2993 aura::Window* lost_active) {
2994 DCHECK(window_ == gained_active || window_ == lost_active); 2994 DCHECK(window_ == gained_active || window_ == lost_active);
2995 if (window_ == gained_active) { 2995 if (window_ == gained_active) {
2996 const ui::Event* event = window_->GetRootWindow()->current_event(); 2996 const ui::Event* event = window_->GetDispatcher()->current_event();
2997 if (event && PointerEventActivates(*event)) 2997 if (event && PointerEventActivates(*event))
2998 host_->OnPointerEventActivate(); 2998 host_->OnPointerEventActivate();
2999 } 2999 }
3000 } 3000 }
3001 3001
3002 //////////////////////////////////////////////////////////////////////////////// 3002 ////////////////////////////////////////////////////////////////////////////////
3003 // RenderWidgetHostViewAura, aura::client::CursorClientObserver implementation: 3003 // RenderWidgetHostViewAura, aura::client::CursorClientObserver implementation:
3004 3004
3005 void RenderWidgetHostViewAura::OnCursorVisibilityChanged(bool is_visible) { 3005 void RenderWidgetHostViewAura::OnCursorVisibilityChanged(bool is_visible) {
3006 NotifyRendererOfCursorVisibilityState(is_visible); 3006 NotifyRendererOfCursorVisibilityState(is_visible);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
3226 touch_editing_client_->OnViewDestroyed(); 3226 touch_editing_client_->OnViewDestroyed();
3227 if (!shared_surface_handle_.is_null()) { 3227 if (!shared_surface_handle_.is_null()) {
3228 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 3228 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
3229 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 3229 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
3230 factory->RemoveObserver(this); 3230 factory->RemoveObserver(this);
3231 } 3231 }
3232 window_observer_.reset(); 3232 window_observer_.reset();
3233 #if defined(OS_WIN) 3233 #if defined(OS_WIN)
3234 transient_observer_.reset(); 3234 transient_observer_.reset();
3235 #endif 3235 #endif
3236 if (window_->GetRootWindow()) 3236 if (window_->GetDispatcher())
3237 window_->GetRootWindow()->RemoveRootWindowObserver(this); 3237 window_->GetDispatcher()->RemoveRootWindowObserver(this);
3238 UnlockMouse(); 3238 UnlockMouse();
3239 if (popup_type_ != WebKit::WebPopupTypeNone && popup_parent_host_view_) { 3239 if (popup_type_ != WebKit::WebPopupTypeNone && popup_parent_host_view_) {
3240 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || 3240 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
3241 popup_parent_host_view_->popup_child_host_view_ == this); 3241 popup_parent_host_view_->popup_child_host_view_ == this);
3242 popup_parent_host_view_->popup_child_host_view_ = NULL; 3242 popup_parent_host_view_->popup_child_host_view_ = NULL;
3243 } 3243 }
3244 if (popup_child_host_view_) { 3244 if (popup_child_host_view_) {
3245 DCHECK(popup_child_host_view_->popup_parent_host_view_ == NULL || 3245 DCHECK(popup_child_host_view_->popup_parent_host_view_ == NULL ||
3246 popup_child_host_view_->popup_parent_host_view_ == this); 3246 popup_child_host_view_->popup_parent_host_view_ == this);
3247 popup_child_host_view_->popup_parent_host_view_ = NULL; 3247 popup_child_host_view_->popup_parent_host_view_ = NULL;
(...skipping 10 matching lines...) Expand all
3258 // early. 3258 // early.
3259 framebuffer_holder_ = NULL; 3259 framebuffer_holder_ = NULL;
3260 3260
3261 if (resource_collection_.get()) 3261 if (resource_collection_.get())
3262 resource_collection_->SetClient(NULL); 3262 resource_collection_->SetClient(NULL);
3263 } 3263 }
3264 3264
3265 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 3265 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
3266 const gfx::Point screen_point = 3266 const gfx::Point screen_point =
3267 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); 3267 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
3268 aura::RootWindow* root_window = window_->GetRootWindow(); 3268 aura::Window* root_window = window_->GetRootWindow();
3269 if (!root_window) 3269 if (!root_window)
3270 return; 3270 return;
3271 3271
3272 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher();
3273
3272 gfx::Rect screen_rect = GetViewBounds(); 3274 gfx::Rect screen_rect = GetViewBounds();
3273 gfx::Point local_point = screen_point; 3275 gfx::Point local_point = screen_point;
3274 local_point.Offset(-screen_rect.x(), -screen_rect.y()); 3276 local_point.Offset(-screen_rect.x(), -screen_rect.y());
3275 3277
3276 #if defined(OS_WIN) 3278 #if defined(OS_WIN)
3277 // If there's another toplevel window above us at this point (for example a 3279 // If there's another toplevel window above us at this point (for example a
3278 // menu), we don't want to update the cursor. 3280 // menu), we don't want to update the cursor.
3279 POINT windows_point = { screen_point.x(), screen_point.y() }; 3281 POINT windows_point = { screen_point.x(), screen_point.y() };
3280 if (root_window->GetAcceleratedWidget() != ::WindowFromPoint(windows_point)) 3282 if (dispatcher->GetAcceleratedWidget() != ::WindowFromPoint(windows_point))
3281 return; 3283 return;
3282 #endif 3284 #endif
3283 if (root_window->GetEventHandlerForPoint(local_point) != window_) 3285 if (root_window->GetEventHandlerForPoint(local_point) != window_)
3284 return; 3286 return;
3285 3287
3286 gfx::NativeCursor cursor = current_cursor_.GetNativeCursor(); 3288 gfx::NativeCursor cursor = current_cursor_.GetNativeCursor();
3287 // Do not show loading cursor when the cursor is currently hidden. 3289 // Do not show loading cursor when the cursor is currently hidden.
3288 if (is_loading_ && cursor != ui::kCursorNone) 3290 if (is_loading_ && cursor != ui::kCursorNone)
3289 cursor = ui::kCursorPointer; 3291 cursor = ui::kCursorPointer;
3290 3292
3291 aura::client::CursorClient* cursor_client = 3293 aura::client::CursorClient* cursor_client =
3292 aura::client::GetCursorClient(root_window); 3294 aura::client::GetCursorClient(root_window);
3293 if (cursor_client) { 3295 if (cursor_client) {
3294 cursor_client->SetCursor(cursor); 3296 cursor_client->SetCursor(cursor);
3295 } 3297 }
3296 } 3298 }
3297 3299
3298 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { 3300 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const {
3299 aura::RootWindow* root_window = window_->GetRootWindow(); 3301 aura::Window* root_window = window_->GetRootWindow();
3300 if (!root_window) 3302 if (!root_window)
3301 return NULL; 3303 return NULL;
3302 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 3304 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
3303 } 3305 }
3304 3306
3305 bool RenderWidgetHostViewAura::NeedsInputGrab() { 3307 bool RenderWidgetHostViewAura::NeedsInputGrab() {
3306 return popup_type_ == WebKit::WebPopupTypeSelect; 3308 return popup_type_ == WebKit::WebPopupTypeSelect;
3307 } 3309 }
3308 3310
3309 void RenderWidgetHostViewAura::FinishImeCompositionSession() { 3311 void RenderWidgetHostViewAura::FinishImeCompositionSession() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 DCHECK(compositor); 3400 DCHECK(compositor);
3399 3401
3400 if (!compositor->HasObserver(this)) 3402 if (!compositor->HasObserver(this))
3401 compositor->AddObserver(this); 3403 compositor->AddObserver(this);
3402 3404
3403 can_lock_compositor_ = NO_PENDING_COMMIT; 3405 can_lock_compositor_ = NO_PENDING_COMMIT;
3404 on_compositing_did_commit_callbacks_.push_back(callback); 3406 on_compositing_did_commit_callbacks_.push_back(callback);
3405 } 3407 }
3406 3408
3407 void RenderWidgetHostViewAura::AddedToRootWindow() { 3409 void RenderWidgetHostViewAura::AddedToRootWindow() {
3408 window_->GetRootWindow()->AddRootWindowObserver(this); 3410 window_->GetDispatcher()->AddRootWindowObserver(this);
3409 host_->ParentChanged(GetNativeViewId()); 3411 host_->ParentChanged(GetNativeViewId());
3410 UpdateScreenInfo(window_); 3412 UpdateScreenInfo(window_);
3411 if (popup_type_ != WebKit::WebPopupTypeNone) 3413 if (popup_type_ != WebKit::WebPopupTypeNone)
3412 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); 3414 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this));
3413 3415
3414 aura::client::CursorClient* cursor_client = 3416 aura::client::CursorClient* cursor_client =
3415 aura::client::GetCursorClient(window_->GetRootWindow()); 3417 aura::client::GetCursorClient(window_->GetRootWindow());
3416 if (cursor_client) { 3418 if (cursor_client) {
3417 cursor_client->AddObserver(this); 3419 cursor_client->AddObserver(this);
3418 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 3420 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
3419 } 3421 }
3420 if (current_surface_.get()) 3422 if (current_surface_.get())
3421 UpdateExternalTexture(); 3423 UpdateExternalTexture();
3422 } 3424 }
3423 3425
3424 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 3426 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
3425 aura::client::CursorClient* cursor_client = 3427 aura::client::CursorClient* cursor_client =
3426 aura::client::GetCursorClient(window_->GetRootWindow()); 3428 aura::client::GetCursorClient(window_->GetRootWindow());
3427 if (cursor_client) 3429 if (cursor_client)
3428 cursor_client->RemoveObserver(this); 3430 cursor_client->RemoveObserver(this);
3429 3431
3430 event_filter_for_popup_exit_.reset(); 3432 event_filter_for_popup_exit_.reset();
3431 window_->GetRootWindow()->RemoveRootWindowObserver(this); 3433 window_->GetDispatcher()->RemoveRootWindowObserver(this);
3432 host_->ParentChanged(0); 3434 host_->ParentChanged(0);
3433 ui::Compositor* compositor = GetCompositor(); 3435 ui::Compositor* compositor = GetCompositor();
3434 if (current_surface_.get()) { 3436 if (current_surface_.get()) {
3435 // We can't get notification for commits after this point, which would 3437 // We can't get notification for commits after this point, which would
3436 // guarantee that the compositor isn't using an old texture any more, so 3438 // guarantee that the compositor isn't using an old texture any more, so
3437 // instead we force the layer to stop using any external resources which 3439 // instead we force the layer to stop using any external resources which
3438 // synchronizes with the compositor thread, and makes it safe to run the 3440 // synchronizes with the compositor thread, and makes it safe to run the
3439 // callback. 3441 // callback.
3440 window_->layer()->SetShowPaintedContent(); 3442 window_->layer()->SetShowPaintedContent();
3441 } 3443 }
3442 RunOnCommitCallbacks(); 3444 RunOnCommitCallbacks();
3443 resize_lock_.reset(); 3445 resize_lock_.reset();
3444 host_->WasResized(); 3446 host_->WasResized();
3445 if (compositor && compositor->HasObserver(this)) 3447 if (compositor && compositor->HasObserver(this))
3446 compositor->RemoveObserver(this); 3448 compositor->RemoveObserver(this);
3447 } 3449 }
3448 3450
3449 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { 3451 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const {
3450 aura::RootWindow* root_window = window_->GetRootWindow(); 3452 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
3451 return root_window ? root_window->compositor() : NULL; 3453 return dispatcher ? dispatcher->compositor() : NULL;
3452 } 3454 }
3453 3455
3454 void RenderWidgetHostViewAura::DetachFromInputMethod() { 3456 void RenderWidgetHostViewAura::DetachFromInputMethod() {
3455 ui::InputMethod* input_method = GetInputMethod(); 3457 ui::InputMethod* input_method = GetInputMethod();
3456 if (input_method && input_method->GetTextInputClient() == this) 3458 if (input_method && input_method->GetTextInputClient() == this)
3457 input_method->SetFocusedTextInputClient(NULL); 3459 input_method->SetFocusedTextInputClient(NULL);
3458 } 3460 }
3459 3461
3460 //////////////////////////////////////////////////////////////////////////////// 3462 ////////////////////////////////////////////////////////////////////////////////
3461 // RenderWidgetHostView, public: 3463 // RenderWidgetHostView, public:
3462 3464
3463 // static 3465 // static
3464 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 3466 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
3465 RenderWidgetHost* widget) { 3467 RenderWidgetHost* widget) {
3466 return new RenderWidgetHostViewAura(widget); 3468 return new RenderWidgetHostViewAura(widget);
3467 } 3469 }
3468 3470
3469 // static 3471 // static
3470 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3472 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3471 GetScreenInfoForWindow(results, NULL); 3473 GetScreenInfoForWindow(results, NULL);
3472 } 3474 }
3473 3475
3474 } // namespace content 3476 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698