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

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: 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/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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 SetParent(window, ui::GetHiddenWindow()); 137 SetParent(window, ui::GetHiddenWindow());
138 return TRUE; 138 return TRUE;
139 } 139 }
140 140
141 BOOL CALLBACK ShowWindowsCallback(HWND window, LPARAM param) { 141 BOOL CALLBACK ShowWindowsCallback(HWND window, LPARAM param) {
142 RenderWidgetHostViewAura* widget = 142 RenderWidgetHostViewAura* widget =
143 reinterpret_cast<RenderWidgetHostViewAura*>(param); 143 reinterpret_cast<RenderWidgetHostViewAura*>(param);
144 144
145 if (GetProp(window, kWidgetOwnerProperty) == widget) { 145 if (GetProp(window, kWidgetOwnerProperty) == widget) {
146 HWND parent = 146 HWND parent =
147 widget->GetNativeView()->GetRootWindow()->GetAcceleratedWidget(); 147 widget->GetNativeView()->GetDispatcher()->GetAcceleratedWidget();
148 SetParent(window, parent); 148 SetParent(window, parent);
149 } 149 }
150 return TRUE; 150 return TRUE;
151 } 151 }
152 152
153 struct CutoutRectsParams { 153 struct CutoutRectsParams {
154 RenderWidgetHostViewAura* widget; 154 RenderWidgetHostViewAura* widget;
155 std::vector<gfx::Rect> cutout_rects; 155 std::vector<gfx::Rect> cutout_rects;
156 std::map<HWND, WebPluginGeometry>* geometry; 156 std::map<HWND, WebPluginGeometry>* geometry;
157 }; 157 };
158 158
159 // Used to update the region for the windowed plugin to draw in. We start with 159 // Used to update the region for the windowed plugin to draw in. We start with
160 // the clip rect from the renderer, then remove the cutout rects from the 160 // the clip rect from the renderer, then remove the cutout rects from the
161 // renderer, and then remove the transient windows from the root window and the 161 // renderer, and then remove the transient windows from the root window and the
162 // constrained windows from the parent window. 162 // constrained windows from the parent window.
163 BOOL CALLBACK SetCutoutRectsCallback(HWND window, LPARAM param) { 163 BOOL CALLBACK SetCutoutRectsCallback(HWND window, LPARAM param) {
164 CutoutRectsParams* params = reinterpret_cast<CutoutRectsParams*>(param); 164 CutoutRectsParams* params = reinterpret_cast<CutoutRectsParams*>(param);
165 165
166 if (GetProp(window, kWidgetOwnerProperty) == params->widget) { 166 if (GetProp(window, kWidgetOwnerProperty) == params->widget) {
167 // First calculate the offset of this plugin from the root window, since 167 // First calculate the offset of this plugin from the root window, since
168 // the cutouts are relative to the root window. 168 // the cutouts are relative to the root window.
169 HWND parent = params->widget->GetNativeView()->GetRootWindow()-> 169 HWND parent = params->widget->GetNativeView()->GetDispatcher()->
170 GetAcceleratedWidget(); 170 GetAcceleratedWidget();
171 POINT offset; 171 POINT offset;
172 offset.x = offset.y = 0; 172 offset.x = offset.y = 0;
173 MapWindowPoints(window, parent, &offset, 1); 173 MapWindowPoints(window, parent, &offset, 1);
174 174
175 // Now get the cached clip rect and cutouts for this plugin window that came 175 // Now get the cached clip rect and cutouts for this plugin window that came
176 // from the renderer. 176 // from the renderer.
177 std::map<HWND, WebPluginGeometry>::iterator i = params->geometry->begin(); 177 std::map<HWND, WebPluginGeometry>::iterator i = params->geometry->begin();
178 while (i != params->geometry->end() && 178 while (i != params->geometry->end() &&
179 i->second.window != window && 179 i->second.window != window &&
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } // namespace 362 } // namespace
363 363
364 // We need to watch for mouse events outside a Web Popup or its parent 364 // We need to watch for mouse events outside a Web Popup or its parent
365 // and dismiss the popup for certain events. 365 // and dismiss the popup for certain events.
366 class RenderWidgetHostViewAura::EventFilterForPopupExit : 366 class RenderWidgetHostViewAura::EventFilterForPopupExit :
367 public ui::EventHandler { 367 public ui::EventHandler {
368 public: 368 public:
369 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) 369 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva)
370 : rwhva_(rwhva) { 370 : rwhva_(rwhva) {
371 DCHECK(rwhva_); 371 DCHECK(rwhva_);
372 aura::RootWindow* root_window = rwhva_->window_->GetRootWindow(); 372 aura::Window* root_window = rwhva_->window_->GetRootWindow();
373 DCHECK(root_window); 373 DCHECK(root_window);
374 root_window->AddPreTargetHandler(this); 374 root_window->AddPreTargetHandler(this);
375 } 375 }
376 376
377 virtual ~EventFilterForPopupExit() { 377 virtual ~EventFilterForPopupExit() {
378 aura::RootWindow* root_window = rwhva_->window_->GetRootWindow(); 378 aura::Window* root_window = rwhva_->window_->GetRootWindow();
379 DCHECK(root_window); 379 DCHECK(root_window);
380 root_window->RemovePreTargetHandler(this); 380 root_window->RemovePreTargetHandler(this);
381 } 381 }
382 382
383 // Overridden from ui::EventHandler 383 // Overridden from ui::EventHandler
384 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 384 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
385 rwhva_->ApplyEventFilterForPopupExit(event); 385 rwhva_->ApplyEventFilterForPopupExit(event);
386 } 386 }
387 387
388 private: 388 private:
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // is not known now. 497 // is not known now.
498 } 498 }
499 499
500 virtual void OnRemoveTransientChild(aura::Window* window, 500 virtual void OnRemoveTransientChild(aura::Window* window,
501 aura::Window* transient) OVERRIDE { 501 aura::Window* transient) OVERRIDE {
502 transient->RemoveObserver(this); 502 transient->RemoveObserver(this);
503 SendPluginCutoutRects(); 503 SendPluginCutoutRects();
504 } 504 }
505 505
506 aura::Window* GetToplevelWindow() { 506 aura::Window* GetToplevelWindow() {
507 aura::RootWindow* root = view_->window_->GetRootWindow(); 507 aura::Window* root = view_->window_->GetRootWindow();
508 if (!root) 508 if (!root)
509 return NULL; 509 return NULL;
510 aura::client::ActivationClient* activation_client = 510 aura::client::ActivationClient* activation_client =
511 aura::client::GetActivationClient(root); 511 aura::client::GetActivationClient(root);
512 if (!activation_client) 512 if (!activation_client)
513 return NULL; 513 return NULL;
514 return activation_client->GetToplevelWindow(view_->window_); 514 return activation_client->GetToplevelWindow(view_->window_);
515 } 515 }
516 516
517 void StopObserving() { 517 void StopObserving() {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 // similar mechanism to ensure a second popup doesn't cause the first one 612 // similar mechanism to ensure a second popup doesn't cause the first one
613 // to never get a chance to filter events. See crbug.com/160589. 613 // to never get a chance to filter events. See crbug.com/160589.
614 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); 614 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_);
615 old_child->popup_parent_host_view_ = NULL; 615 old_child->popup_parent_host_view_ = NULL;
616 } 616 }
617 popup_parent_host_view_->popup_child_host_view_ = this; 617 popup_parent_host_view_->popup_child_host_view_ = this;
618 window_->SetType(aura::client::WINDOW_TYPE_MENU); 618 window_->SetType(aura::client::WINDOW_TYPE_MENU);
619 window_->Init(ui::LAYER_TEXTURED); 619 window_->Init(ui::LAYER_TEXTURED);
620 window_->SetName("RenderWidgetHostViewAura"); 620 window_->SetName("RenderWidgetHostViewAura");
621 621
622 aura::RootWindow* root = popup_parent_host_view_->window_->GetRootWindow(); 622 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow();
623 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); 623 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen);
624 624
625 // TODO(erg): While I could make sure details of the WindowTreeClient are 625 // TODO(erg): While I could make sure details of the WindowTreeClient are
626 // hidden behind aura, hiding the details of the ScreenPositionClient will 626 // hidden behind aura, hiding the details of the ScreenPositionClient will
627 // take another effort. 627 // take another effort.
628 aura::client::ScreenPositionClient* screen_position_client = 628 aura::client::ScreenPositionClient* screen_position_client =
629 aura::client::GetScreenPositionClient(root); 629 aura::client::GetScreenPositionClient(root);
630 gfx::Point origin_in_parent(bounds_in_screen.origin()); 630 gfx::Point origin_in_parent(bounds_in_screen.origin());
631 if (screen_position_client) { 631 if (screen_position_client) {
632 screen_position_client->ConvertPointFromScreen( 632 screen_position_client->ConvertPointFromScreen(
633 window_->parent(), &origin_in_parent); 633 window_->parent(), &origin_in_parent);
634 } 634 }
635 SetBounds(gfx::Rect(origin_in_parent, bounds_in_screen.size())); 635 SetBounds(gfx::Rect(origin_in_parent, bounds_in_screen.size()));
636 Show(); 636 Show();
637 } 637 }
638 638
639 void RenderWidgetHostViewAura::InitAsFullscreen( 639 void RenderWidgetHostViewAura::InitAsFullscreen(
640 RenderWidgetHostView* reference_host_view) { 640 RenderWidgetHostView* reference_host_view) {
641 is_fullscreen_ = true; 641 is_fullscreen_ = true;
642 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); 642 window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
643 window_->Init(ui::LAYER_TEXTURED); 643 window_->Init(ui::LAYER_TEXTURED);
644 window_->SetName("RenderWidgetHostViewAura"); 644 window_->SetName("RenderWidgetHostViewAura");
645 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 645 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
646 646
647 aura::RootWindow* parent = NULL; 647 aura::Window* parent = NULL;
648 gfx::Rect bounds; 648 gfx::Rect bounds;
649 if (reference_host_view) { 649 if (reference_host_view) {
650 aura::Window* reference_window = 650 aura::Window* reference_window =
651 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; 651 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_;
652 if (reference_window) { 652 if (reference_window) {
653 host_tracker_.reset(new aura::WindowTracker); 653 host_tracker_.reset(new aura::WindowTracker);
654 host_tracker_->Add(reference_window); 654 host_tracker_->Add(reference_window);
655 } 655 }
656 gfx::Display display = gfx::Screen::GetScreenFor(window_)-> 656 gfx::Display display = gfx::Screen::GetScreenFor(window_)->
657 GetDisplayNearestWindow(reference_window); 657 GetDisplayNearestWindow(reference_window);
658 parent = reference_window->GetRootWindow(); 658 parent = reference_window->GetRootWindow();
659 bounds = display.bounds(); 659 bounds = display.bounds();
660 } 660 }
661 aura::client::ParentWindowWithContext(window_, parent, bounds); 661 aura::client::ParentWindowWithContext(window_, parent, bounds);
662 Show(); 662 Show();
663 Focus(); 663 Focus();
664 } 664 }
665 665
666 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 666 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
667 return host_; 667 return host_;
668 } 668 }
669 669
670 void RenderWidgetHostViewAura::WasShown() { 670 void RenderWidgetHostViewAura::WasShown() {
671 DCHECK(host_); 671 DCHECK(host_);
672 if (!host_->is_hidden()) 672 if (!host_->is_hidden())
673 return; 673 return;
674 host_->WasShown(); 674 host_->WasShown();
675 software_frame_manager_->SetVisibility(true); 675 software_frame_manager_->SetVisibility(true);
676 676
677 aura::RootWindow* root = window_->GetRootWindow(); 677 aura::Window* root = window_->GetRootWindow();
678 if (root) { 678 if (root) {
679 aura::client::CursorClient* cursor_client = 679 aura::client::CursorClient* cursor_client =
680 aura::client::GetCursorClient(root); 680 aura::client::GetCursorClient(root);
681 if (cursor_client) 681 if (cursor_client)
682 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 682 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
683 } 683 }
684 684
685 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && 685 if (!current_surface_.get() && host_->is_accelerated_compositing_active() &&
686 !released_front_lock_.get()) { 686 !released_front_lock_.get()) {
687 ui::Compositor* compositor = GetCompositor(); 687 ui::Compositor* compositor = GetCompositor();
688 if (compositor) 688 if (compositor)
689 released_front_lock_ = compositor->GetCompositorLock(); 689 released_front_lock_ = compositor->GetCompositorLock();
690 } 690 }
691 691
692 #if defined(OS_WIN) 692 #if defined(OS_WIN)
693 LPARAM lparam = reinterpret_cast<LPARAM>(this); 693 LPARAM lparam = reinterpret_cast<LPARAM>(this);
694 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); 694 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam);
695 transient_observer_->SendPluginCutoutRects(); 695 transient_observer_->SendPluginCutoutRects();
696 #endif 696 #endif
697 } 697 }
698 698
699 void RenderWidgetHostViewAura::WasHidden() { 699 void RenderWidgetHostViewAura::WasHidden() {
700 if (!host_ || host_->is_hidden()) 700 if (!host_ || host_->is_hidden())
701 return; 701 return;
702 host_->WasHidden(); 702 host_->WasHidden();
703 software_frame_manager_->SetVisibility(false); 703 software_frame_manager_->SetVisibility(false);
704 released_front_lock_ = NULL; 704 released_front_lock_ = NULL;
705 705
706 #if defined(OS_WIN) 706 #if defined(OS_WIN)
707 aura::RootWindow* root_window = window_->GetRootWindow(); 707 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
708 if (root_window) { 708 if (dispatcher) {
709 HWND parent = root_window->GetAcceleratedWidget(); 709 HWND parent = dispatcher->GetAcceleratedWidget();
710 LPARAM lparam = reinterpret_cast<LPARAM>(this); 710 LPARAM lparam = reinterpret_cast<LPARAM>(this);
711 711
712 EnumChildWindows(parent, HideWindowsCallback, lparam); 712 EnumChildWindows(parent, HideWindowsCallback, lparam);
713 } 713 }
714 #endif 714 #endif
715 } 715 }
716 716
717 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 717 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
718 SetBounds(gfx::Rect(window_->bounds().origin(), size)); 718 SetBounds(gfx::Rect(window_->bounds().origin(), size));
719 } 719 }
720 720
721 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 721 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
722 if (HasDisplayPropertyChanged(window_)) 722 if (HasDisplayPropertyChanged(window_))
723 host_->InvalidateScreenInfo(); 723 host_->InvalidateScreenInfo();
724 724
725 window_->SetBounds(rect); 725 window_->SetBounds(rect);
726 host_->WasResized(); 726 host_->WasResized();
727 MaybeCreateResizeLock(); 727 MaybeCreateResizeLock();
728 if (touch_editing_client_) { 728 if (touch_editing_client_) {
729 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 729 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_,
730 selection_focus_rect_); 730 selection_focus_rect_);
731 } 731 }
732 } 732 }
733 733
734 void RenderWidgetHostViewAura::MaybeCreateResizeLock() { 734 void RenderWidgetHostViewAura::MaybeCreateResizeLock() {
735 if (!ShouldCreateResizeLock()) 735 if (!ShouldCreateResizeLock())
736 return; 736 return;
737 DCHECK(window_->GetRootWindow()); 737 DCHECK(window_->GetDispatcher());
738 DCHECK(window_->GetRootWindow()->compositor()); 738 DCHECK(window_->GetDispatcher()->compositor());
739 739
740 // Listen to changes in the compositor lock state. 740 // Listen to changes in the compositor lock state.
741 ui::Compositor* compositor = window_->GetRootWindow()->compositor(); 741 ui::Compositor* compositor = window_->GetDispatcher()->compositor();
742 if (!compositor->HasObserver(this)) 742 if (!compositor->HasObserver(this))
743 compositor->AddObserver(this); 743 compositor->AddObserver(this);
744 744
745 bool defer_compositor_lock = 745 bool defer_compositor_lock =
746 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || 746 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME ||
747 can_lock_compositor_ == NO_PENDING_COMMIT; 747 can_lock_compositor_ == NO_PENDING_COMMIT;
748 748
749 if (can_lock_compositor_ == YES) 749 if (can_lock_compositor_ == YES)
750 can_lock_compositor_ = YES_DID_LOCK; 750 can_lock_compositor_ = YES_DID_LOCK;
751 751
(...skipping 17 matching lines...) Expand all
769 769
770 if (host_->should_auto_resize()) 770 if (host_->should_auto_resize())
771 return false; 771 return false;
772 if (!host_->is_accelerated_compositing_active()) 772 if (!host_->is_accelerated_compositing_active())
773 return false; 773 return false;
774 774
775 gfx::Size desired_size = window_->bounds().size(); 775 gfx::Size desired_size = window_->bounds().size();
776 if (desired_size == current_frame_size_) 776 if (desired_size == current_frame_size_)
777 return false; 777 return false;
778 778
779 aura::RootWindow* root_window = window_->GetRootWindow(); 779 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
780 if (!root_window) 780 if (!dispatcher)
781 return false; 781 return false;
782 782
783 ui::Compositor* compositor = root_window->compositor(); 783 ui::Compositor* compositor = dispatcher->compositor();
784 if (!compositor) 784 if (!compositor)
785 return false; 785 return false;
786 786
787 return true; 787 return true;
788 } 788 }
789 789
790 scoped_ptr<ResizeLock> RenderWidgetHostViewAura::CreateResizeLock( 790 scoped_ptr<ResizeLock> RenderWidgetHostViewAura::CreateResizeLock(
791 bool defer_compositor_lock) { 791 bool defer_compositor_lock) {
792 gfx::Size desired_size = window_->bounds().size(); 792 gfx::Size desired_size = window_->bounds().size();
793 return scoped_ptr<ResizeLock>(new CompositorResizeLock( 793 return scoped_ptr<ResizeLock>(new CompositorResizeLock(
794 window_->GetRootWindow(), 794 window_->GetDispatcher(),
795 desired_size, 795 desired_size,
796 defer_compositor_lock, 796 defer_compositor_lock,
797 base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs))); 797 base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs)));
798 } 798 }
799 799
800 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { 800 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const {
801 return window_; 801 return window_;
802 } 802 }
803 803
804 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { 804 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const {
805 #if defined(OS_WIN) 805 #if defined(OS_WIN)
806 aura::RootWindow* root_window = window_->GetRootWindow(); 806 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
807 if (root_window) { 807 if (dispatcher) {
808 HWND window = root_window->GetAcceleratedWidget(); 808 HWND window = dispatcher->GetAcceleratedWidget();
809 return reinterpret_cast<gfx::NativeViewId>(window); 809 return reinterpret_cast<gfx::NativeViewId>(window);
810 } 810 }
811 #endif 811 #endif
812 return static_cast<gfx::NativeViewId>(NULL); 812 return static_cast<gfx::NativeViewId>(NULL);
813 } 813 }
814 814
815 gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() { 815 gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() {
816 #if defined(OS_WIN) 816 #if defined(OS_WIN)
817 aura::RootWindow* root_window = window_->GetRootWindow(); 817 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
818 if (!root_window) 818 if (!dispatcher)
819 return static_cast<gfx::NativeViewAccessible>(NULL); 819 return static_cast<gfx::NativeViewAccessible>(NULL);
820 HWND hwnd = root_window->GetAcceleratedWidget(); 820 HWND hwnd = dispatcher->GetAcceleratedWidget();
821 821
822 BrowserAccessibilityManager* manager = 822 BrowserAccessibilityManager* manager =
823 GetOrCreateBrowserAccessibilityManager(); 823 GetOrCreateBrowserAccessibilityManager();
824 if (manager) 824 if (manager)
825 return manager->GetRoot()->ToBrowserAccessibilityWin(); 825 return manager->GetRoot()->ToBrowserAccessibilityWin();
826 #endif 826 #endif
827 827
828 NOTIMPLEMENTED(); 828 NOTIMPLEMENTED();
829 return static_cast<gfx::NativeViewAccessible>(NULL); 829 return static_cast<gfx::NativeViewAccessible>(NULL);
830 } 830 }
831 831
832 BrowserAccessibilityManager* 832 BrowserAccessibilityManager*
833 RenderWidgetHostViewAura::GetOrCreateBrowserAccessibilityManager() { 833 RenderWidgetHostViewAura::GetOrCreateBrowserAccessibilityManager() {
834 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager(); 834 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager();
835 if (manager) 835 if (manager)
836 return manager; 836 return manager;
837 837
838 #if defined(OS_WIN) 838 #if defined(OS_WIN)
839 aura::RootWindow* root_window = window_->GetRootWindow(); 839 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
840 if (!root_window) 840 if (!dispatcher)
841 return NULL; 841 return NULL;
842 HWND hwnd = root_window->GetAcceleratedWidget(); 842 HWND hwnd = dispatcher->GetAcceleratedWidget();
843 843
844 // The accessible_parent may be NULL at this point. The WebContents will pass 844 // The accessible_parent may be NULL at this point. The WebContents will pass
845 // it down to this instance (by way of the RenderViewHost and 845 // it down to this instance (by way of the RenderViewHost and
846 // RenderWidgetHost) when it is known. This instance will then set it on its 846 // RenderWidgetHost) when it is known. This instance will then set it on its
847 // BrowserAccessibilityManager. 847 // BrowserAccessibilityManager.
848 gfx::NativeViewAccessible accessible_parent = 848 gfx::NativeViewAccessible accessible_parent =
849 host_->GetParentNativeViewAccessible(); 849 host_->GetParentNativeViewAccessible();
850 850
851 manager = new BrowserAccessibilityManagerWin( 851 manager = new BrowserAccessibilityManagerWin(
852 hwnd, accessible_parent, 852 hwnd, accessible_parent,
(...skipping 10 matching lines...) Expand all
863 void RenderWidgetHostViewAura::MovePluginWindows( 863 void RenderWidgetHostViewAura::MovePluginWindows(
864 const gfx::Vector2d& scroll_offset, 864 const gfx::Vector2d& scroll_offset,
865 const std::vector<WebPluginGeometry>& plugin_window_moves) { 865 const std::vector<WebPluginGeometry>& plugin_window_moves) {
866 #if defined(OS_WIN) 866 #if defined(OS_WIN)
867 // We need to clip the rectangle to the tab's viewport, otherwise we will draw 867 // We need to clip the rectangle to the tab's viewport, otherwise we will draw
868 // over the browser UI. 868 // over the browser UI.
869 if (!window_->GetRootWindow()) { 869 if (!window_->GetRootWindow()) {
870 DCHECK(plugin_window_moves.empty()); 870 DCHECK(plugin_window_moves.empty());
871 return; 871 return;
872 } 872 }
873 HWND parent = window_->GetRootWindow()->GetAcceleratedWidget(); 873 HWND parent = window_->GetDispatcher()->GetAcceleratedWidget();
874 gfx::Rect view_bounds = window_->GetBoundsInRootWindow(); 874 gfx::Rect view_bounds = window_->GetBoundsInRootWindow();
875 std::vector<WebPluginGeometry> moves = plugin_window_moves; 875 std::vector<WebPluginGeometry> moves = plugin_window_moves;
876 876
877 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(), 877 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(),
878 view_bounds.height()); 878 view_bounds.height());
879 879
880 for (size_t i = 0; i < moves.size(); ++i) { 880 for (size_t i = 0; i < moves.size(); ++i) {
881 gfx::Rect clip(moves[i].clip_rect); 881 gfx::Rect clip(moves[i].clip_rect);
882 gfx::Vector2d view_port_offset( 882 gfx::Vector2d view_port_offset(
883 moves[i].window_rect.OffsetFromOrigin() + scroll_offset); 883 moves[i].window_rect.OffsetFromOrigin() + scroll_offset);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 if (paint_canvas_) { 1038 if (paint_canvas_) {
1039 SkRect sk_clip_rect; 1039 SkRect sk_clip_rect;
1040 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect)) 1040 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect))
1041 clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect)); 1041 clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect));
1042 } 1042 }
1043 1043
1044 if (!scroll_rect.IsEmpty()) 1044 if (!scroll_rect.IsEmpty())
1045 SchedulePaintIfNotInClip(scroll_rect, clip_rect); 1045 SchedulePaintIfNotInClip(scroll_rect, clip_rect);
1046 1046
1047 #if defined(OS_WIN) 1047 #if defined(OS_WIN)
1048 aura::RootWindow* root_window = window_->GetRootWindow(); 1048 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
1049 #endif 1049 #endif
1050 for (size_t i = 0; i < copy_rects.size(); ++i) { 1050 for (size_t i = 0; i < copy_rects.size(); ++i) {
1051 gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect); 1051 gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect);
1052 if (rect.IsEmpty()) 1052 if (rect.IsEmpty())
1053 continue; 1053 continue;
1054 1054
1055 SchedulePaintIfNotInClip(rect, clip_rect); 1055 SchedulePaintIfNotInClip(rect, clip_rect);
1056 1056
1057 #if defined(OS_WIN) 1057 #if defined(OS_WIN)
1058 if (root_window) { 1058 if (dispatcher) {
1059 // Send the invalid rect in screen coordinates. 1059 // Send the invalid rect in screen coordinates.
1060 gfx::Rect screen_rect = GetViewBounds(); 1060 gfx::Rect screen_rect = GetViewBounds();
1061 gfx::Rect invalid_screen_rect(rect); 1061 gfx::Rect invalid_screen_rect(rect);
1062 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); 1062 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y());
1063 HWND hwnd = root_window->GetAcceleratedWidget(); 1063 HWND hwnd = dispatcher->GetAcceleratedWidget();
1064 PaintPluginWindowsHelper(hwnd, invalid_screen_rect); 1064 PaintPluginWindowsHelper(hwnd, invalid_screen_rect);
1065 } 1065 }
1066 #endif // defined(OS_WIN) 1066 #endif // defined(OS_WIN)
1067 } 1067 }
1068 } 1068 }
1069 1069
1070 void RenderWidgetHostViewAura::RenderProcessGone(base::TerminationStatus status, 1070 void RenderWidgetHostViewAura::RenderProcessGone(base::TerminationStatus status,
1071 int error_code) { 1071 int error_code) {
1072 UpdateCursorIfOverSelf(); 1072 UpdateCursorIfOverSelf();
1073 Destroy(); 1073 Destroy();
1074 } 1074 }
1075 1075
1076 void RenderWidgetHostViewAura::Destroy() { 1076 void RenderWidgetHostViewAura::Destroy() {
1077 // Beware, this function is not called on all destruction paths. It will 1077 // Beware, this function is not called on all destruction paths. It will
1078 // implicitly end up calling ~RenderWidgetHostViewAura though, so all 1078 // implicitly end up calling ~RenderWidgetHostViewAura though, so all
1079 // destruction/cleanup code should happen there, not here. 1079 // destruction/cleanup code should happen there, not here.
1080 in_shutdown_ = true; 1080 in_shutdown_ = true;
1081 delete window_; 1081 delete window_;
1082 } 1082 }
1083 1083
1084 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { 1084 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) {
1085 tooltip_ = tooltip_text; 1085 tooltip_ = tooltip_text;
1086 aura::RootWindow* root_window = window_->GetRootWindow(); 1086 aura::Window* root_window = window_->GetRootWindow();
1087 aura::client::TooltipClient* tooltip_client = 1087 aura::client::TooltipClient* tooltip_client =
1088 aura::client::GetTooltipClient(root_window); 1088 aura::client::GetTooltipClient(root_window);
1089 if (tooltip_client) { 1089 if (tooltip_client) {
1090 tooltip_client->UpdateTooltip(window_); 1090 tooltip_client->UpdateTooltip(window_);
1091 // Content tooltips should be visible indefinitely. 1091 // Content tooltips should be visible indefinitely.
1092 tooltip_client->SetTooltipShownTimeout(window_, 0); 1092 tooltip_client->SetTooltipShownTimeout(window_, 0);
1093 } 1093 }
1094 } 1094 }
1095 1095
1096 void RenderWidgetHostViewAura::SelectionChanged(const string16& text, 1096 void RenderWidgetHostViewAura::SelectionChanged(const string16& text,
(...skipping 25 matching lines...) Expand all
1122 if (GetInputMethod()) 1122 if (GetInputMethod())
1123 GetInputMethod()->OnCaretBoundsChanged(this); 1123 GetInputMethod()->OnCaretBoundsChanged(this);
1124 1124
1125 if (touch_editing_client_) { 1125 if (touch_editing_client_) {
1126 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 1126 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_,
1127 selection_focus_rect_); 1127 selection_focus_rect_);
1128 } 1128 }
1129 } 1129 }
1130 1130
1131 void RenderWidgetHostViewAura::ScrollOffsetChanged() { 1131 void RenderWidgetHostViewAura::ScrollOffsetChanged() {
1132 aura::RootWindow* root = window_->GetRootWindow(); 1132 aura::Window* root = window_->GetRootWindow();
1133 if (!root) 1133 if (!root)
1134 return; 1134 return;
1135 aura::client::CursorClient* cursor_client = 1135 aura::client::CursorClient* cursor_client =
1136 aura::client::GetCursorClient(root); 1136 aura::client::GetCursorClient(root);
1137 if (cursor_client && !cursor_client->IsCursorVisible()) 1137 if (cursor_client && !cursor_client->IsCursorVisible())
1138 cursor_client->DisableMouseEvents(); 1138 cursor_client->DisableMouseEvents();
1139 } 1139 }
1140 1140
1141 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( 1141 BackingStore* RenderWidgetHostViewAura::AllocBackingStore(
1142 const gfx::Size& size) { 1142 const gfx::Size& size) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 1356
1357 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( 1357 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects(
1358 const std::vector<gfx::Rect>& rects) { 1358 const std::vector<gfx::Rect>& rects) {
1359 constrained_rects_ = rects; 1359 constrained_rects_ = rects;
1360 UpdateCutoutRects(); 1360 UpdateCutoutRects();
1361 } 1361 }
1362 1362
1363 void RenderWidgetHostViewAura::UpdateCutoutRects() { 1363 void RenderWidgetHostViewAura::UpdateCutoutRects() {
1364 if (!window_->GetRootWindow()) 1364 if (!window_->GetRootWindow())
1365 return; 1365 return;
1366 HWND parent = window_->GetRootWindow()->GetAcceleratedWidget(); 1366 HWND parent = window_->GetDispatcher()->GetAcceleratedWidget();
1367 CutoutRectsParams params; 1367 CutoutRectsParams params;
1368 params.widget = this; 1368 params.widget = this;
1369 params.cutout_rects.assign(transient_rects_.begin(), transient_rects_.end()); 1369 params.cutout_rects.assign(transient_rects_.begin(), transient_rects_.end());
1370 params.cutout_rects.insert(params.cutout_rects.end(), 1370 params.cutout_rects.insert(params.cutout_rects.end(),
1371 constrained_rects_.begin(), 1371 constrained_rects_.begin(),
1372 constrained_rects_.end()); 1372 constrained_rects_.end());
1373 params.geometry = &plugin_window_moves_; 1373 params.geometry = &plugin_window_moves_;
1374 LPARAM lparam = reinterpret_cast<LPARAM>(&params); 1374 LPARAM lparam = reinterpret_cast<LPARAM>(&params);
1375 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); 1375 EnumChildWindows(parent, SetCutoutRectsCallback, lparam);
1376 } 1376 }
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); 2053 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL);
2054 } 2054 }
2055 2055
2056 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { 2056 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
2057 #if defined(OS_WIN) 2057 #if defined(OS_WIN)
2058 // aura::Window::GetBoundsInScreen doesn't take non-client area into 2058 // aura::Window::GetBoundsInScreen doesn't take non-client area into
2059 // account. 2059 // account.
2060 RECT window_rect = {0}; 2060 RECT window_rect = {0};
2061 2061
2062 aura::Window* top_level = window_->GetToplevelWindow(); 2062 aura::Window* top_level = window_->GetToplevelWindow();
2063 aura::RootWindow* root_window = top_level->GetRootWindow(); 2063 aura::WindowEventDispatcher* dispatcher = top_level->GetDispatcher();
2064 if (!root_window) 2064 if (!dispatcher)
2065 return top_level->GetBoundsInScreen(); 2065 return top_level->GetBoundsInScreen();
2066 HWND hwnd = root_window->GetAcceleratedWidget(); 2066 HWND hwnd = dispatcher->GetAcceleratedWidget();
2067 ::GetWindowRect(hwnd, &window_rect); 2067 ::GetWindowRect(hwnd, &window_rect);
2068 gfx::Rect rect(window_rect); 2068 gfx::Rect rect(window_rect);
2069 2069
2070 // Maximized windows are outdented from the work area by the frame thickness 2070 // Maximized windows are outdented from the work area by the frame thickness
2071 // even though this "frame" is not painted. This confuses code (and people) 2071 // even though this "frame" is not painted. This confuses code (and people)
2072 // that think of a maximized window as corresponding exactly to the work area. 2072 // that think of a maximized window as corresponding exactly to the work area.
2073 // Correct for this by subtracting the frame thickness back off. 2073 // Correct for this by subtracting the frame thickness back off.
2074 if (::IsZoomed(hwnd)) { 2074 if (::IsZoomed(hwnd)) {
2075 rect.Inset(GetSystemMetrics(SM_CXSIZEFRAME), 2075 rect.Inset(GetSystemMetrics(SM_CXSIZEFRAME),
2076 GetSystemMetrics(SM_CYSIZEFRAME)); 2076 GetSystemMetrics(SM_CYSIZEFRAME));
(...skipping 11 matching lines...) Expand all
2088 touch_editing_client_->GestureEventAck(gesture_event_type); 2088 touch_editing_client_->GestureEventAck(gesture_event_type);
2089 } 2089 }
2090 2090
2091 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( 2091 void RenderWidgetHostViewAura::ProcessAckedTouchEvent(
2092 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { 2092 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) {
2093 ScopedVector<ui::TouchEvent> events; 2093 ScopedVector<ui::TouchEvent> events;
2094 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, 2094 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events,
2095 SCREEN_COORDINATES)) 2095 SCREEN_COORDINATES))
2096 return; 2096 return;
2097 2097
2098 aura::RootWindow* root = window_->GetRootWindow(); 2098 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
2099 // |root| is NULL during tests. 2099 // |dispatcher| is NULL during tests.
2100 if (!root) 2100 if (!dispatcher)
2101 return; 2101 return;
2102 2102
2103 ui::EventResult result = (ack_result == 2103 ui::EventResult result = (ack_result ==
2104 INPUT_EVENT_ACK_STATE_CONSUMED) ? ui::ER_HANDLED : ui::ER_UNHANDLED; 2104 INPUT_EVENT_ACK_STATE_CONSUMED) ? ui::ER_HANDLED : ui::ER_UNHANDLED;
2105 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), 2105 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
2106 end = events.end(); iter != end; ++iter) { 2106 end = events.end(); iter != end; ++iter) {
2107 root->ProcessedTouchEvent((*iter), window_, result); 2107 dispatcher->ProcessedTouchEvent((*iter), window_, result);
2108 } 2108 }
2109 } 2109 }
2110 2110
2111 SyntheticGesture* RenderWidgetHostViewAura::CreateSmoothScrollGesture( 2111 SyntheticGesture* RenderWidgetHostViewAura::CreateSmoothScrollGesture(
2112 bool scroll_down, 2112 bool scroll_down,
2113 int pixels_to_scroll, 2113 int pixels_to_scroll,
2114 int mouse_event_x, 2114 int mouse_event_x,
2115 int mouse_event_y) { 2115 int mouse_event_y) {
2116 return new TouchSmoothScrollGestureAura(scroll_down, 2116 return new TouchSmoothScrollGestureAura(scroll_down,
2117 pixels_to_scroll, 2117 pixels_to_scroll,
(...skipping 24 matching lines...) Expand all
2142 if (shared_surface_handle_.is_null()) { 2142 if (shared_surface_handle_.is_null()) {
2143 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 2143 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
2144 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(); 2144 shared_surface_handle_ = factory->CreateSharedSurfaceHandle();
2145 if (!shared_surface_handle_.is_null()) 2145 if (!shared_surface_handle_.is_null())
2146 factory->AddObserver(this); 2146 factory->AddObserver(this);
2147 } 2147 }
2148 return shared_surface_handle_; 2148 return shared_surface_handle_;
2149 } 2149 }
2150 2150
2151 bool RenderWidgetHostViewAura::LockMouse() { 2151 bool RenderWidgetHostViewAura::LockMouse() {
2152 aura::RootWindow* root_window = window_->GetRootWindow(); 2152 aura::Window* root_window = window_->GetRootWindow();
2153 if (!root_window) 2153 if (!root_window)
2154 return false; 2154 return false;
2155 2155
2156 if (mouse_locked_) 2156 if (mouse_locked_)
2157 return true; 2157 return true;
2158 2158
2159 mouse_locked_ = true; 2159 mouse_locked_ = true;
2160 #if !defined(OS_WIN) 2160 #if !defined(OS_WIN)
2161 window_->SetCapture(); 2161 window_->SetCapture();
2162 #endif 2162 #endif
2163 aura::client::CursorClient* cursor_client = 2163 aura::client::CursorClient* cursor_client =
2164 aura::client::GetCursorClient(root_window); 2164 aura::client::GetCursorClient(root_window);
2165 if (cursor_client) { 2165 if (cursor_client) {
2166 cursor_client->HideCursor(); 2166 cursor_client->HideCursor();
2167 cursor_client->LockCursor(); 2167 cursor_client->LockCursor();
2168 } 2168 }
2169 2169
2170 if (ShouldMoveToCenter()) { 2170 if (ShouldMoveToCenter()) {
2171 synthetic_move_sent_ = true; 2171 synthetic_move_sent_ = true;
2172 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint()); 2172 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint());
2173 } 2173 }
2174 if (aura::client::GetTooltipClient(root_window)) 2174 if (aura::client::GetTooltipClient(root_window))
2175 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false); 2175 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false);
2176 return true; 2176 return true;
2177 } 2177 }
2178 2178
2179 void RenderWidgetHostViewAura::UnlockMouse() { 2179 void RenderWidgetHostViewAura::UnlockMouse() {
2180 aura::RootWindow* root_window = window_->GetRootWindow(); 2180 aura::Window* root_window = window_->GetRootWindow();
2181 if (!mouse_locked_ || !root_window) 2181 if (!mouse_locked_ || !root_window)
2182 return; 2182 return;
2183 2183
2184 mouse_locked_ = false; 2184 mouse_locked_ = false;
2185 2185
2186 #if !defined(OS_WIN) 2186 #if !defined(OS_WIN)
2187 window_->ReleaseCapture(); 2187 window_->ReleaseCapture();
2188 #endif 2188 #endif
2189 window_->MoveCursorTo(unlocked_mouse_position_); 2189 window_->MoveCursorTo(unlocked_mouse_position_);
2190 aura::client::CursorClient* cursor_client = 2190 aura::client::CursorClient* cursor_client =
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 2279
2280 bool RenderWidgetHostViewAura::CanComposeInline() const { 2280 bool RenderWidgetHostViewAura::CanComposeInline() const {
2281 return can_compose_inline_; 2281 return can_compose_inline_;
2282 } 2282 }
2283 2283
2284 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( 2284 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(
2285 const gfx::Rect& rect) const { 2285 const gfx::Rect& rect) const {
2286 gfx::Point origin = rect.origin(); 2286 gfx::Point origin = rect.origin();
2287 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 2287 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
2288 2288
2289 aura::RootWindow* root_window = window_->GetRootWindow(); 2289 aura::Window* root_window = window_->GetRootWindow();
2290 if (!root_window) 2290 if (!root_window)
2291 return rect; 2291 return rect;
2292 aura::client::ScreenPositionClient* screen_position_client = 2292 aura::client::ScreenPositionClient* screen_position_client =
2293 aura::client::GetScreenPositionClient(root_window); 2293 aura::client::GetScreenPositionClient(root_window);
2294 if (!screen_position_client) 2294 if (!screen_position_client)
2295 return rect; 2295 return rect;
2296 screen_position_client->ConvertPointToScreen(window_, &origin); 2296 screen_position_client->ConvertPointToScreen(window_, &origin);
2297 screen_position_client->ConvertPointToScreen(window_, &end); 2297 screen_position_client->ConvertPointToScreen(window_, &end);
2298 return gfx::Rect(origin.x(), 2298 return gfx::Rect(origin.x(),
2299 origin.y(), 2299 origin.y(),
2300 end.x() - origin.x(), 2300 end.x() - origin.x(),
2301 end.y() - origin.y()); 2301 end.y() - origin.y());
2302 } 2302 }
2303 2303
2304 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen( 2304 gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
2305 const gfx::Rect& rect) const { 2305 const gfx::Rect& rect) const {
2306 gfx::Point origin = rect.origin(); 2306 gfx::Point origin = rect.origin();
2307 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 2307 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
2308 2308
2309 aura::RootWindow* root_window = window_->GetRootWindow(); 2309 aura::Window* root_window = window_->GetRootWindow();
2310 if (root_window) { 2310 if (root_window) {
2311 aura::client::ScreenPositionClient* screen_position_client = 2311 aura::client::ScreenPositionClient* screen_position_client =
2312 aura::client::GetScreenPositionClient(root_window); 2312 aura::client::GetScreenPositionClient(root_window);
2313 screen_position_client->ConvertPointFromScreen(window_, &origin); 2313 screen_position_client->ConvertPointFromScreen(window_, &origin);
2314 screen_position_client->ConvertPointFromScreen(window_, &end); 2314 screen_position_client->ConvertPointFromScreen(window_, &end);
2315 return gfx::Rect(origin.x(), 2315 return gfx::Rect(origin.x(),
2316 origin.y(), 2316 origin.y(),
2317 end.x() - origin.x(), 2317 end.x() - origin.x(),
2318 end.y() - origin.y()); 2318 end.y() - origin.y());
2319 } 2319 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2545 } 2545 }
2546 2546
2547 void RenderWidgetHostViewAura::OnWindowDestroying() { 2547 void RenderWidgetHostViewAura::OnWindowDestroying() {
2548 #if defined(OS_WIN) 2548 #if defined(OS_WIN)
2549 HWND parent = NULL; 2549 HWND parent = NULL;
2550 // If the tab was hidden and it's closed, host_->is_hidden would have been 2550 // If the tab was hidden and it's closed, host_->is_hidden would have been
2551 // reset to false in RenderWidgetHostImpl::RendererExited. 2551 // reset to false in RenderWidgetHostImpl::RendererExited.
2552 if (!window_->GetRootWindow() || host_->is_hidden()) { 2552 if (!window_->GetRootWindow() || host_->is_hidden()) {
2553 parent = ui::GetHiddenWindow(); 2553 parent = ui::GetHiddenWindow();
2554 } else { 2554 } else {
2555 parent = window_->GetRootWindow()->GetAcceleratedWidget(); 2555 parent = window_->GetDispatcher()->GetAcceleratedWidget();
2556 } 2556 }
2557 LPARAM lparam = reinterpret_cast<LPARAM>(this); 2557 LPARAM lparam = reinterpret_cast<LPARAM>(this);
2558 EnumChildWindows(parent, WindowDestroyingCallback, lparam); 2558 EnumChildWindows(parent, WindowDestroyingCallback, lparam);
2559 #endif 2559 #endif
2560 2560
2561 // Make sure that the input method no longer references to this object before 2561 // Make sure that the input method no longer references to this object before
2562 // this object is removed from the root window (i.e. this object loses access 2562 // this object is removed from the root window (i.e. this object loses access
2563 // to the input method). 2563 // to the input method).
2564 ui::InputMethod* input_method = GetInputMethod(); 2564 ui::InputMethod* input_method = GetInputMethod();
2565 if (input_method) 2565 if (input_method)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2749 event->type() == ui::ET_MOUSE_MOVED)) { 2749 event->type() == ui::ET_MOUSE_MOVED)) {
2750 event->StopPropagation(); 2750 event->StopPropagation();
2751 return; 2751 return;
2752 } 2752 }
2753 2753
2754 if (event->type() == ui::ET_MOUSEWHEEL) { 2754 if (event->type() == ui::ET_MOUSEWHEEL) {
2755 #if defined(OS_WIN) 2755 #if defined(OS_WIN)
2756 // We get mouse wheel/scroll messages even if we are not in the foreground. 2756 // We get mouse wheel/scroll messages even if we are not in the foreground.
2757 // So here we check if we have any owned popup windows in the foreground and 2757 // So here we check if we have any owned popup windows in the foreground and
2758 // dismiss them. 2758 // dismiss them.
2759 aura::RootWindow* root_window = window_->GetRootWindow(); 2759 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
2760 if (root_window) { 2760 if (dispatcher) {
2761 HWND parent = root_window->GetAcceleratedWidget(); 2761 HWND parent = dispatcher->GetAcceleratedWidget();
2762 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT); 2762 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT);
2763 EnumThreadWindows(GetCurrentThreadId(), 2763 EnumThreadWindows(GetCurrentThreadId(),
2764 DismissOwnedPopups, 2764 DismissOwnedPopups,
2765 reinterpret_cast<LPARAM>(toplevel_hwnd)); 2765 reinterpret_cast<LPARAM>(toplevel_hwnd));
2766 } 2766 }
2767 #endif 2767 #endif
2768 WebKit::WebMouseWheelEvent mouse_wheel_event = 2768 WebKit::WebMouseWheelEvent mouse_wheel_event =
2769 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); 2769 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event));
2770 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 2770 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0)
2771 host_->ForwardWheelEvent(mouse_wheel_event); 2771 host_->ForwardWheelEvent(mouse_wheel_event);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 2906
2907 // If a gesture is not processed by the webpage, then WebKit processes it 2907 // If a gesture is not processed by the webpage, then WebKit processes it
2908 // (e.g. generates synthetic mouse events). 2908 // (e.g. generates synthetic mouse events).
2909 event->SetHandled(); 2909 event->SetHandled();
2910 } 2910 }
2911 2911
2912 //////////////////////////////////////////////////////////////////////////////// 2912 ////////////////////////////////////////////////////////////////////////////////
2913 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: 2913 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation:
2914 2914
2915 bool RenderWidgetHostViewAura::ShouldActivate() const { 2915 bool RenderWidgetHostViewAura::ShouldActivate() const {
2916 aura::RootWindow* root_window = window_->GetRootWindow(); 2916 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
2917 if (!root_window) 2917 if (!dispatcher)
2918 return true; 2918 return true;
2919 const ui::Event* event = root_window->current_event(); 2919 const ui::Event* event = dispatcher->current_event();
2920 if (!event) 2920 if (!event)
2921 return true; 2921 return true;
2922 return is_fullscreen_; 2922 return is_fullscreen_;
2923 } 2923 }
2924 2924
2925 //////////////////////////////////////////////////////////////////////////////// 2925 ////////////////////////////////////////////////////////////////////////////////
2926 // RenderWidgetHostViewAura, 2926 // RenderWidgetHostViewAura,
2927 // aura::client::ActivationChangeObserver implementation: 2927 // aura::client::ActivationChangeObserver implementation:
2928 2928
2929 void RenderWidgetHostViewAura::OnWindowActivated(aura::Window* gained_active, 2929 void RenderWidgetHostViewAura::OnWindowActivated(aura::Window* gained_active,
2930 aura::Window* lost_active) { 2930 aura::Window* lost_active) {
2931 DCHECK(window_ == gained_active || window_ == lost_active); 2931 DCHECK(window_ == gained_active || window_ == lost_active);
2932 if (window_ == gained_active) { 2932 if (window_ == gained_active) {
2933 const ui::Event* event = window_->GetRootWindow()->current_event(); 2933 const ui::Event* event = window_->GetDispatcher()->current_event();
2934 if (event && PointerEventActivates(*event)) 2934 if (event && PointerEventActivates(*event))
2935 host_->OnPointerEventActivate(); 2935 host_->OnPointerEventActivate();
2936 } 2936 }
2937 } 2937 }
2938 2938
2939 //////////////////////////////////////////////////////////////////////////////// 2939 ////////////////////////////////////////////////////////////////////////////////
2940 // RenderWidgetHostViewAura, aura::client::CursorClientObserver implementation: 2940 // RenderWidgetHostViewAura, aura::client::CursorClientObserver implementation:
2941 2941
2942 void RenderWidgetHostViewAura::OnCursorVisibilityChanged(bool is_visible) { 2942 void RenderWidgetHostViewAura::OnCursorVisibilityChanged(bool is_visible) {
2943 NotifyRendererOfCursorVisibilityState(is_visible); 2943 NotifyRendererOfCursorVisibilityState(is_visible);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 touch_editing_client_->OnViewDestroyed(); 3168 touch_editing_client_->OnViewDestroyed();
3169 if (!shared_surface_handle_.is_null()) { 3169 if (!shared_surface_handle_.is_null()) {
3170 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 3170 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
3171 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 3171 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
3172 factory->RemoveObserver(this); 3172 factory->RemoveObserver(this);
3173 } 3173 }
3174 window_observer_.reset(); 3174 window_observer_.reset();
3175 #if defined(OS_WIN) 3175 #if defined(OS_WIN)
3176 transient_observer_.reset(); 3176 transient_observer_.reset();
3177 #endif 3177 #endif
3178 if (window_->GetRootWindow()) 3178 if (window_->GetDispatcher())
3179 window_->GetRootWindow()->RemoveRootWindowObserver(this); 3179 window_->GetDispatcher()->RemoveRootWindowObserver(this);
3180 UnlockMouse(); 3180 UnlockMouse();
3181 if (popup_type_ != WebKit::WebPopupTypeNone && popup_parent_host_view_) { 3181 if (popup_type_ != WebKit::WebPopupTypeNone && popup_parent_host_view_) {
3182 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || 3182 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
3183 popup_parent_host_view_->popup_child_host_view_ == this); 3183 popup_parent_host_view_->popup_child_host_view_ == this);
3184 popup_parent_host_view_->popup_child_host_view_ = NULL; 3184 popup_parent_host_view_->popup_child_host_view_ = NULL;
3185 } 3185 }
3186 if (popup_child_host_view_) { 3186 if (popup_child_host_view_) {
3187 DCHECK(popup_child_host_view_->popup_parent_host_view_ == NULL || 3187 DCHECK(popup_child_host_view_->popup_parent_host_view_ == NULL ||
3188 popup_child_host_view_->popup_parent_host_view_ == this); 3188 popup_child_host_view_->popup_parent_host_view_ == this);
3189 popup_child_host_view_->popup_parent_host_view_ = NULL; 3189 popup_child_host_view_->popup_parent_host_view_ = NULL;
3190 } 3190 }
3191 aura::client::SetTooltipText(window_, NULL); 3191 aura::client::SetTooltipText(window_, NULL);
3192 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); 3192 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this);
3193 3193
3194 // This call is usually no-op since |this| object is already removed from the 3194 // This call is usually no-op since |this| object is already removed from the
3195 // Aura root window and we don't have a way to get an input method object 3195 // Aura root window and we don't have a way to get an input method object
3196 // associated with the window, but just in case. 3196 // associated with the window, but just in case.
3197 DetachFromInputMethod(); 3197 DetachFromInputMethod();
3198 3198
3199 if (resource_collection_.get()) 3199 if (resource_collection_.get())
3200 resource_collection_->SetClient(NULL); 3200 resource_collection_->SetClient(NULL);
3201 } 3201 }
3202 3202
3203 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 3203 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
3204 const gfx::Point screen_point = 3204 const gfx::Point screen_point =
3205 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); 3205 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
3206 aura::RootWindow* root_window = window_->GetRootWindow(); 3206 aura::Window* root_window = window_->GetRootWindow();
3207 if (!root_window) 3207 if (!root_window)
3208 return; 3208 return;
3209 3209
3210 gfx::Rect screen_rect = GetViewBounds(); 3210 gfx::Rect screen_rect = GetViewBounds();
3211 gfx::Point local_point = screen_point; 3211 gfx::Point local_point = screen_point;
3212 local_point.Offset(-screen_rect.x(), -screen_rect.y()); 3212 local_point.Offset(-screen_rect.x(), -screen_rect.y());
3213 3213
3214 #if defined(OS_WIN) 3214 #if defined(OS_WIN)
3215 // If there's another toplevel window above us at this point (for example a 3215 // If there's another toplevel window above us at this point (for example a
3216 // menu), we don't want to update the cursor. 3216 // menu), we don't want to update the cursor.
3217 POINT windows_point = { screen_point.x(), screen_point.y() }; 3217 POINT windows_point = { screen_point.x(), screen_point.y() };
3218 if (root_window->GetAcceleratedWidget() != ::WindowFromPoint(windows_point)) 3218 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher();
3219 if (dispatcher->GetAcceleratedWidget() != ::WindowFromPoint(windows_point))
3219 return; 3220 return;
3220 #endif 3221 #endif
3221 if (root_window->GetEventHandlerForPoint(local_point) != window_) 3222 if (root_window->GetEventHandlerForPoint(local_point) != window_)
3222 return; 3223 return;
3223 3224
3224 gfx::NativeCursor cursor = current_cursor_.GetNativeCursor(); 3225 gfx::NativeCursor cursor = current_cursor_.GetNativeCursor();
3225 // Do not show loading cursor when the cursor is currently hidden. 3226 // Do not show loading cursor when the cursor is currently hidden.
3226 if (is_loading_ && cursor != ui::kCursorNone) 3227 if (is_loading_ && cursor != ui::kCursorNone)
3227 cursor = ui::kCursorPointer; 3228 cursor = ui::kCursorPointer;
3228 3229
3229 aura::client::CursorClient* cursor_client = 3230 aura::client::CursorClient* cursor_client =
3230 aura::client::GetCursorClient(root_window); 3231 aura::client::GetCursorClient(root_window);
3231 if (cursor_client) { 3232 if (cursor_client) {
3232 cursor_client->SetCursor(cursor); 3233 cursor_client->SetCursor(cursor);
3233 } 3234 }
3234 } 3235 }
3235 3236
3236 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { 3237 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const {
3237 aura::RootWindow* root_window = window_->GetRootWindow(); 3238 aura::Window* root_window = window_->GetRootWindow();
3238 if (!root_window) 3239 if (!root_window)
3239 return NULL; 3240 return NULL;
3240 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 3241 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
3241 } 3242 }
3242 3243
3243 bool RenderWidgetHostViewAura::NeedsInputGrab() { 3244 bool RenderWidgetHostViewAura::NeedsInputGrab() {
3244 return popup_type_ == WebKit::WebPopupTypeSelect; 3245 return popup_type_ == WebKit::WebPopupTypeSelect;
3245 } 3246 }
3246 3247
3247 void RenderWidgetHostViewAura::FinishImeCompositionSession() { 3248 void RenderWidgetHostViewAura::FinishImeCompositionSession() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 DCHECK(compositor); 3337 DCHECK(compositor);
3337 3338
3338 if (!compositor->HasObserver(this)) 3339 if (!compositor->HasObserver(this))
3339 compositor->AddObserver(this); 3340 compositor->AddObserver(this);
3340 3341
3341 can_lock_compositor_ = NO_PENDING_COMMIT; 3342 can_lock_compositor_ = NO_PENDING_COMMIT;
3342 on_compositing_did_commit_callbacks_.push_back(callback); 3343 on_compositing_did_commit_callbacks_.push_back(callback);
3343 } 3344 }
3344 3345
3345 void RenderWidgetHostViewAura::AddedToRootWindow() { 3346 void RenderWidgetHostViewAura::AddedToRootWindow() {
3346 window_->GetRootWindow()->AddRootWindowObserver(this); 3347 window_->GetDispatcher()->AddRootWindowObserver(this);
3347 host_->ParentChanged(GetNativeViewId()); 3348 host_->ParentChanged(GetNativeViewId());
3348 UpdateScreenInfo(window_); 3349 UpdateScreenInfo(window_);
3349 if (popup_type_ != WebKit::WebPopupTypeNone) 3350 if (popup_type_ != WebKit::WebPopupTypeNone)
3350 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); 3351 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this));
3351 3352
3352 aura::client::CursorClient* cursor_client = 3353 aura::client::CursorClient* cursor_client =
3353 aura::client::GetCursorClient(window_->GetRootWindow()); 3354 aura::client::GetCursorClient(window_->GetRootWindow());
3354 if (cursor_client) { 3355 if (cursor_client) {
3355 cursor_client->AddObserver(this); 3356 cursor_client->AddObserver(this);
3356 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 3357 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
3357 } 3358 }
3358 if (current_surface_.get()) 3359 if (current_surface_.get())
3359 UpdateExternalTexture(); 3360 UpdateExternalTexture();
3360 } 3361 }
3361 3362
3362 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 3363 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
3363 aura::client::CursorClient* cursor_client = 3364 aura::client::CursorClient* cursor_client =
3364 aura::client::GetCursorClient(window_->GetRootWindow()); 3365 aura::client::GetCursorClient(window_->GetRootWindow());
3365 if (cursor_client) 3366 if (cursor_client)
3366 cursor_client->RemoveObserver(this); 3367 cursor_client->RemoveObserver(this);
3367 3368
3368 event_filter_for_popup_exit_.reset(); 3369 event_filter_for_popup_exit_.reset();
3369 window_->GetRootWindow()->RemoveRootWindowObserver(this); 3370 window_->GetDispatcher()->RemoveRootWindowObserver(this);
3370 host_->ParentChanged(0); 3371 host_->ParentChanged(0);
3371 ui::Compositor* compositor = GetCompositor(); 3372 ui::Compositor* compositor = GetCompositor();
3372 if (current_surface_.get()) { 3373 if (current_surface_.get()) {
3373 // We can't get notification for commits after this point, which would 3374 // We can't get notification for commits after this point, which would
3374 // guarantee that the compositor isn't using an old texture any more, so 3375 // guarantee that the compositor isn't using an old texture any more, so
3375 // instead we force the layer to stop using any external resources which 3376 // instead we force the layer to stop using any external resources which
3376 // synchronizes with the compositor thread, and makes it safe to run the 3377 // synchronizes with the compositor thread, and makes it safe to run the
3377 // callback. 3378 // callback.
3378 window_->layer()->SetShowPaintedContent(); 3379 window_->layer()->SetShowPaintedContent();
3379 } 3380 }
3380 RunOnCommitCallbacks(); 3381 RunOnCommitCallbacks();
3381 resize_lock_.reset(); 3382 resize_lock_.reset();
3382 host_->WasResized(); 3383 host_->WasResized();
3383 if (compositor && compositor->HasObserver(this)) 3384 if (compositor && compositor->HasObserver(this))
3384 compositor->RemoveObserver(this); 3385 compositor->RemoveObserver(this);
3385 } 3386 }
3386 3387
3387 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { 3388 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const {
3388 aura::RootWindow* root_window = window_->GetRootWindow(); 3389 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
3389 return root_window ? root_window->compositor() : NULL; 3390 return dispatcher ? dispatcher->compositor() : NULL;
3390 } 3391 }
3391 3392
3392 void RenderWidgetHostViewAura::DetachFromInputMethod() { 3393 void RenderWidgetHostViewAura::DetachFromInputMethod() {
3393 ui::InputMethod* input_method = GetInputMethod(); 3394 ui::InputMethod* input_method = GetInputMethod();
3394 if (input_method && input_method->GetTextInputClient() == this) 3395 if (input_method && input_method->GetTextInputClient() == this)
3395 input_method->SetFocusedTextInputClient(NULL); 3396 input_method->SetFocusedTextInputClient(NULL);
3396 } 3397 }
3397 3398
3398 //////////////////////////////////////////////////////////////////////////////// 3399 ////////////////////////////////////////////////////////////////////////////////
3399 // RenderWidgetHostView, public: 3400 // RenderWidgetHostView, public:
3400 3401
3401 // static 3402 // static
3402 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 3403 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
3403 RenderWidgetHost* widget) { 3404 RenderWidgetHost* widget) {
3404 return new RenderWidgetHostViewAura(widget); 3405 return new RenderWidgetHostViewAura(widget);
3405 } 3406 }
3406 3407
3407 // static 3408 // static
3408 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3409 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3409 GetScreenInfoForWindow(results, NULL); 3410 GetScreenInfoForWindow(results, NULL);
3410 } 3411 }
3411 3412
3412 } // namespace content 3413 } // namespace content
OLDNEW
« no previous file with comments | « chrome/test/base/interactive_test_utils_win.cc ('k') | content/browser/renderer_host/render_widget_host_view_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698