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/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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 old_child->popup_parent_host_view_ = NULL; | 670 old_child->popup_parent_host_view_ = NULL; |
671 } | 671 } |
672 popup_parent_host_view_->popup_child_host_view_ = this; | 672 popup_parent_host_view_->popup_child_host_view_ = this; |
673 window_->SetType(aura::client::WINDOW_TYPE_MENU); | 673 window_->SetType(aura::client::WINDOW_TYPE_MENU); |
674 window_->Init(ui::LAYER_TEXTURED); | 674 window_->Init(ui::LAYER_TEXTURED); |
675 window_->SetName("RenderWidgetHostViewAura"); | 675 window_->SetName("RenderWidgetHostViewAura"); |
676 | 676 |
677 aura::RootWindow* root = popup_parent_host_view_->window_->GetRootWindow(); | 677 aura::RootWindow* root = popup_parent_host_view_->window_->GetRootWindow(); |
678 window_->SetDefaultParentByRootWindow(root, bounds_in_screen); | 678 window_->SetDefaultParentByRootWindow(root, bounds_in_screen); |
679 | 679 |
680 // TODO(erg): While I could make sure details of the StackingClient are | 680 SetBounds(bounds_in_screen); |
681 // hidden behind aura, hiding the details of the ScreenPositionClient will | |
682 // take another effort. | |
683 aura::client::ScreenPositionClient* screen_position_client = | |
684 aura::client::GetScreenPositionClient(root); | |
685 gfx::Point origin_in_parent(bounds_in_screen.origin()); | |
686 if (screen_position_client) { | |
687 screen_position_client->ConvertPointFromScreen( | |
688 window_->parent(), &origin_in_parent); | |
689 } | |
690 SetBounds(gfx::Rect(origin_in_parent, bounds_in_screen.size())); | |
691 Show(); | 681 Show(); |
692 } | 682 } |
693 | 683 |
694 void RenderWidgetHostViewAura::InitAsFullscreen( | 684 void RenderWidgetHostViewAura::InitAsFullscreen( |
695 RenderWidgetHostView* reference_host_view) { | 685 RenderWidgetHostView* reference_host_view) { |
696 is_fullscreen_ = true; | 686 is_fullscreen_ = true; |
697 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); | 687 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); |
698 window_->Init(ui::LAYER_TEXTURED); | 688 window_->Init(ui::LAYER_TEXTURED); |
699 window_->SetName("RenderWidgetHostViewAura"); | 689 window_->SetName("RenderWidgetHostViewAura"); |
700 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 690 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
701 | 691 |
702 aura::RootWindow* parent = NULL; | 692 aura::RootWindow* parent = NULL; |
703 gfx::Rect bounds; | 693 gfx::Rect bounds; |
704 if (reference_host_view) { | 694 if (reference_host_view) { |
705 aura::Window* reference_window = | 695 aura::Window* reference_window = |
706 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; | 696 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; |
707 if (reference_window) { | 697 if (reference_window) { |
708 host_tracker_.reset(new aura::WindowTracker); | 698 host_tracker_.reset(new aura::WindowTracker); |
709 host_tracker_->Add(reference_window); | 699 host_tracker_->Add(reference_window); |
710 } | 700 } |
711 gfx::Display display = gfx::Screen::GetScreenFor(window_)-> | 701 gfx::Display display = gfx::Screen::GetScreenFor(window_)-> |
712 GetDisplayNearestWindow(reference_window); | 702 GetDisplayNearestWindow(reference_window); |
713 parent = reference_window->GetRootWindow(); | 703 parent = reference_window->GetRootWindow(); |
714 bounds = display.bounds(); | 704 bounds = display.bounds(); |
715 } | 705 } |
706 | |
716 window_->SetDefaultParentByRootWindow(parent, bounds); | 707 window_->SetDefaultParentByRootWindow(parent, bounds); |
717 Show(); | 708 Show(); |
718 Focus(); | 709 Focus(); |
719 } | 710 } |
720 | 711 |
721 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 712 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
722 return host_; | 713 return host_; |
723 } | 714 } |
724 | 715 |
725 void RenderWidgetHostViewAura::WasShown() { | 716 void RenderWidgetHostViewAura::WasShown() { |
(...skipping 30 matching lines...) Expand all Loading... | |
756 if (root_window) { | 747 if (root_window) { |
757 HWND parent = root_window->GetAcceleratedWidget(); | 748 HWND parent = root_window->GetAcceleratedWidget(); |
758 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 749 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
759 | 750 |
760 EnumChildWindows(parent, HideWindowsCallback, lparam); | 751 EnumChildWindows(parent, HideWindowsCallback, lparam); |
761 } | 752 } |
762 #endif | 753 #endif |
763 } | 754 } |
764 | 755 |
765 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { | 756 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { |
766 SetBounds(gfx::Rect(window_->bounds().origin(), size)); | 757 // For a set size operation, we don't care what coordinate system the origin |
758 // of the window is stored in, it's only important to make sure the origin | |
759 // remains constant after the operation. | |
760 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); | |
767 } | 761 } |
768 | 762 |
769 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { | 763 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { |
764 // RenderWidgetHostViewAura::SetBounds() takes screen coordinates, but | |
765 // Window::SetBounds() takes parent coordinates, so we do the conversion here. | |
766 aura::RootWindow* root = window_->GetRootWindow(); | |
767 aura::client::ScreenPositionClient* screen_position_client = | |
768 aura::client::GetScreenPositionClient(root); | |
sky
2013/07/25 14:55:31
nit: indent 2 more.
| |
769 gfx::Point origin_in_parent(rect.origin()); | |
770 if (screen_position_client) { | |
771 screen_position_client->ConvertPointFromScreen( | |
772 window_->parent(), &origin_in_parent); | |
773 } | |
774 | |
775 InternalSetBounds(gfx::Rect(origin_in_parent, rect.size())); | |
776 } | |
777 | |
778 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { | |
sky
2013/07/25 14:55:31
Make position match that of header.
zturner
2013/07/25 17:41:08
Ahh, I actually thought I had, but I positioned it
| |
770 if (HasDisplayPropertyChanged(window_)) | 779 if (HasDisplayPropertyChanged(window_)) |
771 host_->InvalidateScreenInfo(); | 780 host_->InvalidateScreenInfo(); |
772 | 781 |
773 window_->SetBounds(rect); | 782 window_->SetBounds(rect); |
774 host_->WasResized(); | 783 host_->WasResized(); |
775 MaybeCreateResizeLock(); | 784 MaybeCreateResizeLock(); |
776 if (touch_editing_client_) { | 785 if (touch_editing_client_) { |
777 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, | 786 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, |
778 selection_focus_rect_); | 787 selection_focus_rect_); |
779 } | 788 } |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1173 void RenderWidgetHostViewAura::CopyFromCompositingSurface( | 1182 void RenderWidgetHostViewAura::CopyFromCompositingSurface( |
1174 const gfx::Rect& src_subrect, | 1183 const gfx::Rect& src_subrect, |
1175 const gfx::Size& dst_size, | 1184 const gfx::Size& dst_size, |
1176 const base::Callback<void(bool, const SkBitmap&)>& callback) { | 1185 const base::Callback<void(bool, const SkBitmap&)>& callback) { |
1177 if (!window_->layer()->has_external_content()) { | 1186 if (!window_->layer()->has_external_content()) { |
1178 callback.Run(false, SkBitmap()); | 1187 callback.Run(false, SkBitmap()); |
1179 return; | 1188 return; |
1180 } | 1189 } |
1181 | 1190 |
1182 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size); | 1191 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size); |
1192 | |
1183 scoped_ptr<cc::CopyOutputRequest> request = | 1193 scoped_ptr<cc::CopyOutputRequest> request = |
1184 cc::CopyOutputRequest::CreateRequest(base::Bind( | 1194 cc::CopyOutputRequest::CreateRequest(base::Bind( |
1185 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult, | 1195 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult, |
1186 dst_size_in_pixel, | 1196 dst_size_in_pixel, |
1187 callback)); | 1197 callback)); |
1188 request->set_area(src_subrect); | 1198 request->set_area(src_subrect); |
1189 window_->layer()->RequestCopyOfOutput(request.Pass()); | 1199 window_->layer()->RequestCopyOfOutput(request.Pass()); |
1190 } | 1200 } |
1191 | 1201 |
1192 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( | 1202 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( |
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3142 RenderWidgetHost* widget) { | 3152 RenderWidgetHost* widget) { |
3143 return new RenderWidgetHostViewAura(widget); | 3153 return new RenderWidgetHostViewAura(widget); |
3144 } | 3154 } |
3145 | 3155 |
3146 // static | 3156 // static |
3147 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3157 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3148 GetScreenInfoForWindow(results, NULL); | 3158 GetScreenInfoForWindow(results, NULL); |
3149 } | 3159 } |
3150 | 3160 |
3151 } // namespace content | 3161 } // namespace content |
OLD | NEW |