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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 view_->web_contents_->GetRenderWidgetHostView()); | 747 view_->web_contents_->GetRenderWidgetHostView()); |
748 if (view) | 748 if (view) |
749 view->UpdateConstrainedWindowRects(std::vector<gfx::Rect>()); | 749 view->UpdateConstrainedWindowRects(std::vector<gfx::Rect>()); |
750 } | 750 } |
751 | 751 |
752 // When we get parented to the root window, the code below will watch the | 752 // When we get parented to the root window, the code below will watch the |
753 // parent, aka root window. Since we already watch the root window on | 753 // parent, aka root window. Since we already watch the root window on |
754 // Windows, unregister first so that the debug check doesn't fire. | 754 // Windows, unregister first so that the debug check doesn't fire. |
755 if (parent && parent == window->GetRootWindow()) | 755 if (parent && parent == window->GetRootWindow()) |
756 parent->RemoveObserver(this); | 756 parent->RemoveObserver(this); |
| 757 |
| 758 // We need to undo the above if we were parented to the root window and then |
| 759 // got parented to another window. At that point, the code before the ifdef |
| 760 // would have stopped watching the root window. |
| 761 if (window->GetRootWindow() && |
| 762 parent != window->GetRootWindow() && |
| 763 !window->GetRootWindow()->HasObserver(this)) { |
| 764 window->GetRootWindow()->AddObserver(this); |
| 765 } |
757 #endif | 766 #endif |
758 | 767 |
759 parent_ = parent; | 768 parent_ = parent; |
760 if (parent) { | 769 if (parent) { |
761 parent->AddObserver(this); | 770 parent->AddObserver(this); |
762 #if defined(OS_WIN) | 771 #if defined(OS_WIN) |
763 if (parent != window->GetRootWindow()) { | 772 if (parent != window->GetRootWindow()) { |
764 const aura::Window::Windows& children = parent->children(); | 773 const aura::Window::Windows& children = parent->children(); |
765 for (size_t i = 0; i < children.size(); ++i) { | 774 for (size_t i = 0; i < children.size(); ++i) { |
766 if (children[i] != view_->window_) | 775 if (children[i] != view_->window_) |
(...skipping 15 matching lines...) Expand all Loading... |
782 } else { | 791 } else { |
783 UpdateConstrainedWindows(NULL); | 792 UpdateConstrainedWindows(NULL); |
784 #endif | 793 #endif |
785 } | 794 } |
786 } | 795 } |
787 | 796 |
788 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE { | 797 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE { |
789 if (window == view_->window_) { | 798 if (window == view_->window_) { |
790 window->GetDispatcher()->AddRootWindowObserver(this); | 799 window->GetDispatcher()->AddRootWindowObserver(this); |
791 #if defined(OS_WIN) | 800 #if defined(OS_WIN) |
792 window->GetRootWindow()->AddObserver(this); | 801 if (!window->GetRootWindow()->HasObserver(this)) |
| 802 window->GetRootWindow()->AddObserver(this); |
793 #endif | 803 #endif |
794 } | 804 } |
795 } | 805 } |
796 | 806 |
797 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { | 807 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { |
798 if (window == view_->window_) { | 808 if (window == view_->window_) { |
799 window->GetDispatcher()->RemoveRootWindowObserver(this); | 809 window->GetDispatcher()->RemoveRootWindowObserver(this); |
800 #if defined(OS_WIN) | 810 #if defined(OS_WIN) |
801 window->GetRootWindow()->RemoveObserver(this); | 811 window->GetRootWindow()->RemoveObserver(this); |
802 | 812 |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 event.location(), | 1715 event.location(), |
1706 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1716 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1707 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1717 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1708 if (drag_dest_delegate_) | 1718 if (drag_dest_delegate_) |
1709 drag_dest_delegate_->OnDrop(); | 1719 drag_dest_delegate_->OnDrop(); |
1710 current_drop_data_.reset(); | 1720 current_drop_data_.reset(); |
1711 return current_drag_op_; | 1721 return current_drag_op_; |
1712 } | 1722 } |
1713 | 1723 |
1714 } // namespace content | 1724 } // namespace content |
OLD | NEW |