OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
646 bool need_paint_update_; | 646 bool need_paint_update_; |
647 | 647 |
648 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); | 648 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); |
649 }; | 649 }; |
650 | 650 |
651 class WebContentsViewAura::WindowObserver | 651 class WebContentsViewAura::WindowObserver |
652 : public aura::WindowObserver, public aura::RootWindowObserver { | 652 : public aura::WindowObserver, public aura::RootWindowObserver { |
653 public: | 653 public: |
654 explicit WindowObserver(WebContentsViewAura* view) | 654 explicit WindowObserver(WebContentsViewAura* view) |
655 : view_(view), | 655 : view_(view), |
656 parent_(NULL) { | 656 top_level_(NULL) { |
657 view_->window_->AddObserver(this); | 657 view_->window_->AddObserver(this); |
658 } | 658 } |
659 | 659 |
660 virtual ~WindowObserver() { | 660 virtual ~WindowObserver() { |
661 view_->window_->RemoveObserver(this); | 661 view_->window_->RemoveObserver(this); |
662 if (view_->window_->GetDispatcher()) | 662 if (view_->window_->GetDispatcher()) |
663 view_->window_->GetDispatcher()->RemoveRootWindowObserver(this); | 663 view_->window_->GetDispatcher()->RemoveRootWindowObserver(this); |
664 if (parent_) | 664 if (top_level_) |
665 parent_->RemoveObserver(this); | 665 top_level_->RemoveObserver(this); |
666 } | 666 } |
667 | 667 |
668 // Overridden from aura::WindowObserver: | 668 // Overridden from aura::WindowObserver: |
669 virtual void OnWindowParentChanged(aura::Window* window, | 669 virtual void OnWindowParentChanged(aura::Window* window, |
670 aura::Window* parent) OVERRIDE { | 670 aura::Window* parent) OVERRIDE { |
671 if (window == parent_) | 671 if (window == top_level_) |
672 return; | 672 return; |
673 if (parent_) | 673 |
674 parent_->RemoveObserver(this); | 674 if (top_level_) { |
675 parent_ = parent; | 675 top_level_->RemoveObserver(this); |
676 if (parent) | 676 top_level_ = NULL; |
677 parent->AddObserver(this); | 677 } |
678 | |
679 if (window && window != window->GetToplevelWindow()) | |
680 top_level_ = window->GetToplevelWindow(); | |
681 if (top_level_) | |
682 top_level_->AddObserver(this); | |
678 } | 683 } |
679 | 684 |
680 virtual void OnWindowBoundsChanged(aura::Window* window, | 685 virtual void OnWindowBoundsChanged(aura::Window* window, |
681 const gfx::Rect& old_bounds, | 686 const gfx::Rect& old_bounds, |
682 const gfx::Rect& new_bounds) OVERRIDE { | 687 const gfx::Rect& new_bounds) OVERRIDE { |
683 SendScreenRects(); | 688 SendScreenRects(); |
sadrul
2013/10/31 20:27:05
As I think about it, this needs to be invoked when
sky
2013/10/31 21:55:30
I think you're right. We have something like this
| |
684 if (view_->touch_editable_) | 689 if (view_->touch_editable_) |
685 view_->touch_editable_->UpdateEditingController(); | 690 view_->touch_editable_->UpdateEditingController(); |
686 } | 691 } |
687 | 692 |
688 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE { | 693 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE { |
689 if (window != parent_) | 694 if (window != top_level_) |
690 window->GetDispatcher()->AddRootWindowObserver(this); | 695 window->GetDispatcher()->AddRootWindowObserver(this); |
691 } | 696 } |
692 | 697 |
693 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { | 698 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { |
694 if (window != parent_) | 699 if (window != top_level_) |
695 window->GetDispatcher()->RemoveRootWindowObserver(this); | 700 window->GetDispatcher()->RemoveRootWindowObserver(this); |
696 } | 701 } |
697 | 702 |
698 // Overridden RootWindowObserver: | 703 // Overridden RootWindowObserver: |
699 virtual void OnRootWindowHostMoved(const aura::RootWindow* root, | 704 virtual void OnRootWindowHostMoved(const aura::RootWindow* root, |
700 const gfx::Point& new_origin) OVERRIDE { | 705 const gfx::Point& new_origin) OVERRIDE { |
701 // This is for the desktop case (i.e. Aura desktop). | 706 // This is for the desktop case (i.e. Aura desktop). |
702 SendScreenRects(); | 707 SendScreenRects(); |
703 } | 708 } |
704 | 709 |
705 private: | 710 private: |
706 void SendScreenRects() { | 711 void SendScreenRects() { |
707 RenderWidgetHostImpl::From(view_->web_contents_->GetRenderViewHost())-> | 712 RenderWidgetHostImpl::From(view_->web_contents_->GetRenderViewHost())-> |
708 SendScreenRects(); | 713 SendScreenRects(); |
709 } | 714 } |
710 | 715 |
711 WebContentsViewAura* view_; | 716 WebContentsViewAura* view_; |
712 | 717 |
713 // We cache the old parent so that we can unregister when it's not the parent | 718 // We cache the old value so that we can unregister the observer when it |
714 // anymore. | 719 // changes. This also allows for filtering the events seen by the observer. |
715 aura::Window* parent_; | 720 aura::Window* top_level_; |
716 | 721 |
717 DISALLOW_COPY_AND_ASSIGN(WindowObserver); | 722 DISALLOW_COPY_AND_ASSIGN(WindowObserver); |
718 }; | 723 }; |
719 | 724 |
720 #if defined(OS_WIN) | 725 #if defined(OS_WIN) |
721 // Constrained windows are added as children of the WebContent's view which may | 726 // Constrained windows are added as children of the WebContent's view which may |
722 // overlap with windowed NPAPI plugins. In that case, tell the RWHV so that it | 727 // overlap with windowed NPAPI plugins. In that case, tell the RWHV so that it |
723 // can update the plugins' cutout rects accordingly. | 728 // can update the plugins' cutout rects accordingly. |
724 class WebContentsViewAura::ChildWindowObserver : public aura::WindowObserver, | 729 class WebContentsViewAura::ChildWindowObserver : public aura::WindowObserver, |
725 public WebContentsObserver { | 730 public WebContentsObserver { |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1646 event.location(), | 1651 event.location(), |
1647 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1652 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1648 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1653 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1649 if (drag_dest_delegate_) | 1654 if (drag_dest_delegate_) |
1650 drag_dest_delegate_->OnDrop(); | 1655 drag_dest_delegate_->OnDrop(); |
1651 current_drop_data_.reset(); | 1656 current_drop_data_.reset(); |
1652 return current_drag_op_; | 1657 return current_drag_op_; |
1653 } | 1658 } |
1654 | 1659 |
1655 } // namespace content | 1660 } // namespace content |
OLD | NEW |