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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 151083002: Create a visible window with class name Chrome_RenderWidgetHostHWND which corresponds to the bounds… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 10 months 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/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 #include "ui/gfx/rect_conversions.h" 76 #include "ui/gfx/rect_conversions.h"
77 #include "ui/gfx/screen.h" 77 #include "ui/gfx/screen.h"
78 #include "ui/gfx/size_conversions.h" 78 #include "ui/gfx/size_conversions.h"
79 #include "ui/gfx/skia_util.h" 79 #include "ui/gfx/skia_util.h"
80 #include "ui/wm/public/window_types.h" 80 #include "ui/wm/public/window_types.h"
81 81
82 #if defined(OS_WIN) 82 #if defined(OS_WIN)
83 #include "base/win/windows_version.h" 83 #include "base/win/windows_version.h"
84 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 84 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
85 #include "content/browser/accessibility/browser_accessibility_win.h" 85 #include "content/browser/accessibility/browser_accessibility_win.h"
86 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
86 #include "content/common/plugin_constants_win.h" 87 #include "content/common/plugin_constants_win.h"
87 #include "ui/base/win/hidden_window.h" 88 #include "ui/base/win/hidden_window.h"
88 #include "ui/gfx/gdi_util.h" 89 #include "ui/gfx/gdi_util.h"
89 #include "ui/gfx/win/dpi.h" 90 #include "ui/gfx/win/dpi.h"
90 #endif 91 #endif
91 92
92 using gfx::RectToSkIRect; 93 using gfx::RectToSkIRect;
93 using gfx::SkIRectToRect; 94 using gfx::SkIRectToRect;
94 95
95 using blink::WebScreenInfo; 96 using blink::WebScreenInfo;
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 host_->SetView(this); 491 host_->SetView(this);
491 window_observer_.reset(new WindowObserver(this)); 492 window_observer_.reset(new WindowObserver(this));
492 aura::client::SetTooltipText(window_, &tooltip_); 493 aura::client::SetTooltipText(window_, &tooltip_);
493 aura::client::SetActivationDelegate(window_, this); 494 aura::client::SetActivationDelegate(window_, this);
494 aura::client::SetActivationChangeObserver(window_, this); 495 aura::client::SetActivationChangeObserver(window_, this);
495 aura::client::SetFocusChangeObserver(window_, this); 496 aura::client::SetFocusChangeObserver(window_, this);
496 gfx::Screen::GetScreenFor(window_)->AddObserver(this); 497 gfx::Screen::GetScreenFor(window_)->AddObserver(this);
497 software_frame_manager_.reset(new SoftwareFrameManager( 498 software_frame_manager_.reset(new SoftwareFrameManager(
498 weak_ptr_factory_.GetWeakPtr())); 499 weak_ptr_factory_.GetWeakPtr()));
499 #if defined(OS_WIN) 500 #if defined(OS_WIN)
500 plugin_parent_window_ = NULL; 501 legacy_render_widget_host_HWND_ = NULL;
501 #endif 502 #endif
502 ImageTransportFactory::GetInstance()->AddObserver(this); 503 ImageTransportFactory::GetInstance()->AddObserver(this);
503 } 504 }
504 505
505 //////////////////////////////////////////////////////////////////////////////// 506 ////////////////////////////////////////////////////////////////////////////////
506 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 507 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
507 508
508 bool RenderWidgetHostViewAura::OnMessageReceived( 509 bool RenderWidgetHostViewAura::OnMessageReceived(
509 const IPC::Message& message) { 510 const IPC::Message& message) {
510 bool handled = true; 511 bool handled = true;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 !released_front_lock_.get()) { 623 !released_front_lock_.get()) {
623 ui::Compositor* compositor = GetCompositor(); 624 ui::Compositor* compositor = GetCompositor();
624 if (compositor) 625 if (compositor)
625 released_front_lock_ = compositor->GetCompositorLock(); 626 released_front_lock_ = compositor->GetCompositorLock();
626 } 627 }
627 628
628 #if defined(OS_WIN) 629 #if defined(OS_WIN)
629 LPARAM lparam = reinterpret_cast<LPARAM>(this); 630 LPARAM lparam = reinterpret_cast<LPARAM>(this);
630 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); 631 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam);
631 632
632 if (::IsWindow(plugin_parent_window_)) { 633 DCHECK(legacy_render_widget_host_HWND_);
634 if (::IsWindow(legacy_render_widget_host_HWND_->hwnd())) {
633 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); 635 gfx::Rect window_bounds = window_->GetBoundsInRootWindow();
634 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), 636 ::SetWindowPos(legacy_render_widget_host_HWND_->hwnd(), NULL,
635 window_bounds.y(), window_bounds.width(), 637 window_bounds.x(), window_bounds.y(), window_bounds.width(),
636 window_bounds.height(), 0); 638 window_bounds.height(), 0);
637 } 639 }
638 #endif 640 #endif
639 } 641 }
640 642
641 void RenderWidgetHostViewAura::WasHidden() { 643 void RenderWidgetHostViewAura::WasHidden() {
642 if (!host_ || host_->is_hidden()) 644 if (!host_ || host_->is_hidden())
643 return; 645 return;
644 host_->WasHidden(); 646 host_->WasHidden();
645 software_frame_manager_->SetVisibility(false); 647 software_frame_manager_->SetVisibility(false);
646 delegated_frame_evictor_->SetVisible(false); 648 delegated_frame_evictor_->SetVisible(false);
647 released_front_lock_ = NULL; 649 released_front_lock_ = NULL;
648 650
649 #if defined(OS_WIN) 651 #if defined(OS_WIN)
650 constrained_rects_.clear(); 652 constrained_rects_.clear();
651 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); 653 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
652 if (dispatcher) { 654 if (dispatcher) {
653 HWND parent = dispatcher->host()->GetAcceleratedWidget(); 655 HWND parent = dispatcher->host()->GetAcceleratedWidget();
654 LPARAM lparam = reinterpret_cast<LPARAM>(this); 656 LPARAM lparam = reinterpret_cast<LPARAM>(this);
655 657
656 EnumChildWindows(parent, HideWindowsCallback, lparam); 658 EnumChildWindows(parent, HideWindowsCallback, lparam);
657 } 659 }
658 if (::IsWindow(plugin_parent_window_))
659 ::SetWindowPos(plugin_parent_window_, NULL, 0, 0, 0, 0, 0);
660 #endif 660 #endif
661 } 661 }
662 662
663 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 663 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
664 // For a SetSize operation, we don't care what coordinate system the origin 664 // For a SetSize operation, we don't care what coordinate system the origin
665 // of the window is in, it's only important to make sure that the origin 665 // of the window is in, it's only important to make sure that the origin
666 // remains constant after the operation. 666 // remains constant after the operation.
667 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); 667 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size));
668 } 668 }
669 669
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 return window_->HasFocus(); 868 return window_->HasFocus();
869 } 869 }
870 870
871 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { 871 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const {
872 return CanCopyToBitmap() || !!host_->GetBackingStore(false); 872 return CanCopyToBitmap() || !!host_->GetBackingStore(false);
873 } 873 }
874 874
875 void RenderWidgetHostViewAura::Show() { 875 void RenderWidgetHostViewAura::Show() {
876 window_->Show(); 876 window_->Show();
877 WasShown(); 877 WasShown();
878 #if defined(OS_WIN)
879 if (legacy_render_widget_host_HWND_)
880 legacy_render_widget_host_HWND_->Show();
881 #endif
878 } 882 }
879 883
880 void RenderWidgetHostViewAura::Hide() { 884 void RenderWidgetHostViewAura::Hide() {
881 window_->Hide(); 885 window_->Hide();
882 WasHidden(); 886 WasHidden();
887 #if defined(OS_WIN)
888 if (legacy_render_widget_host_HWND_)
889 legacy_render_widget_host_HWND_->Hide();
890 #endif
883 } 891 }
884 892
885 bool RenderWidgetHostViewAura::IsShowing() { 893 bool RenderWidgetHostViewAura::IsShowing() {
886 return window_->IsVisible(); 894 return window_->IsVisible();
887 } 895 }
888 896
889 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { 897 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const {
890 // This is the size that we want the renderer to produce. While we're waiting 898 // This is the size that we want the renderer to produce. While we're waiting
891 // for the correct frame (i.e. during a resize), don't change the size so that 899 // for the correct frame (i.e. during a resize), don't change the size so that
892 // we don't pipeline more resizes than we can handle. 900 // we don't pipeline more resizes than we can handle.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 // a Window::SetBoundsInternal call. 1222 // a Window::SetBoundsInternal call.
1215 if (!in_bounds_changed_) 1223 if (!in_bounds_changed_)
1216 window_->SetBounds(rect); 1224 window_->SetBounds(rect);
1217 host_->WasResized(); 1225 host_->WasResized();
1218 MaybeCreateResizeLock(); 1226 MaybeCreateResizeLock();
1219 if (touch_editing_client_) { 1227 if (touch_editing_client_) {
1220 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 1228 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_,
1221 selection_focus_rect_); 1229 selection_focus_rect_);
1222 } 1230 }
1223 #if defined(OS_WIN) 1231 #if defined(OS_WIN)
1224 // Create the dummy plugin parent window which will be passed as the 1232 // Create the legacy dummy window which corresponds to the bounds of the
1225 // container window to windowless plugins. 1233 // webcontents. This will be passed as the container window for windowless
1234 // plugins.
1226 // Plugins like Flash assume the container window which is returned via the 1235 // Plugins like Flash assume the container window which is returned via the
1227 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. 1236 // NPNVnetscapeWindow property corresponds to the bounds of the webpage.
1228 // This is not true in Aura where we have only HWND which is the main Aura 1237 // This is not true in Aura where we have only HWND which is the main Aura
1229 // window. If we return this window to plugins like Flash then it causes the 1238 // window. If we return this window to plugins like Flash then it causes the
1230 // coordinate translations done by these plugins to break. 1239 // coordinate translations done by these plugins to break.
1231 if (!plugin_parent_window_ && GetNativeViewId()) { 1240 // Additonally the legacy dummy window is needed for accessibility and for
1232 plugin_parent_window_ = ::CreateWindowEx( 1241 // scrolling to work in legacy drivers for trackpoints/trackpads, etc.
1233 0, L"Static", NULL, WS_CHILDWINDOW, 0, 0, 0, 0, 1242 if (GetNativeViewId()) {
1234 reinterpret_cast<HWND>(GetNativeViewId()), NULL, NULL, NULL); 1243 if (!legacy_render_widget_host_HWND_) {
1235 if (::IsWindow(plugin_parent_window_)) 1244 legacy_render_widget_host_HWND_ = new LegacyRenderWidgetHostHWND(
1236 ::SetProp(plugin_parent_window_, content::kPluginDummyParentProperty, 1245 reinterpret_cast<HWND>(GetNativeViewId()));
1237 reinterpret_cast<HANDLE>(true)); 1246 }
1238 } 1247 if (::IsWindow(legacy_render_widget_host_HWND_->hwnd())) {
1239 if (::IsWindow(plugin_parent_window_)) { 1248 gfx::Rect window_bounds = window_->GetBoundsInRootWindow();
1240 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); 1249 ::SetWindowPos(legacy_render_widget_host_HWND_->hwnd(), NULL,
1241 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), 1250 window_bounds.x(), window_bounds.y(),
1242 window_bounds.y(), window_bounds.width(), 1251 window_bounds.width(), window_bounds.height(), 0);
1243 window_bounds.height(), 0); 1252 }
1244 } 1253 }
1245 #endif 1254 #endif
1246 } 1255 }
1247 1256
1248 void RenderWidgetHostViewAura::CheckResizeLock() { 1257 void RenderWidgetHostViewAura::CheckResizeLock() {
1249 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_) 1258 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_)
1250 return; 1259 return;
1251 1260
1252 // Since we got the size we were looking for, unlock the compositor. But delay 1261 // Since we got the size we were looking for, unlock the compositor. But delay
1253 // the release of the lock until we've kicked a frame with the new texture, to 1262 // the release of the lock until we've kicked a frame with the new texture, to
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1711 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1703 gfx::NativeViewAccessible accessible_parent) { 1712 gfx::NativeViewAccessible accessible_parent) {
1704 if (GetBrowserAccessibilityManager()) { 1713 if (GetBrowserAccessibilityManager()) {
1705 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() 1714 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin()
1706 ->set_parent_iaccessible(accessible_parent); 1715 ->set_parent_iaccessible(accessible_parent);
1707 } 1716 }
1708 } 1717 }
1709 1718
1710 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1719 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1711 const { 1720 const {
1712 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); 1721 if (legacy_render_widget_host_HWND_) {
1722 return reinterpret_cast<gfx::NativeViewId>(
1723 legacy_render_widget_host_HWND_->hwnd());
1724 }
1725 return NULL;
1713 } 1726 }
1714 #endif 1727 #endif
1715 1728
1716 void RenderWidgetHostViewAura::BuffersSwapped( 1729 void RenderWidgetHostViewAura::BuffersSwapped(
1717 const gfx::Size& surface_size, 1730 const gfx::Size& surface_size,
1718 const gfx::Rect& damage_rect, 1731 const gfx::Rect& damage_rect,
1719 float surface_scale_factor, 1732 float surface_scale_factor,
1720 const std::string& mailbox_name, 1733 const std::string& mailbox_name,
1721 const std::vector<ui::LatencyInfo>& latency_info, 1734 const std::vector<ui::LatencyInfo>& latency_info,
1722 const BufferPresentedCallback& ack_callback) { 1735 const BufferPresentedCallback& ack_callback) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 return; 2216 return;
2204 HWND hwnd = dispatcher->host()->GetAcceleratedWidget(); 2217 HWND hwnd = dispatcher->host()->GetAcceleratedWidget();
2205 2218
2206 // The accessible_parent may be NULL at this point. The WebContents will pass 2219 // The accessible_parent may be NULL at this point. The WebContents will pass
2207 // it down to this instance (by way of the RenderViewHost and 2220 // it down to this instance (by way of the RenderViewHost and
2208 // RenderWidgetHost) when it is known. This instance will then set it on its 2221 // RenderWidgetHost) when it is known. This instance will then set it on its
2209 // BrowserAccessibilityManager. 2222 // BrowserAccessibilityManager.
2210 gfx::NativeViewAccessible accessible_parent = 2223 gfx::NativeViewAccessible accessible_parent =
2211 host_->GetParentNativeViewAccessible(); 2224 host_->GetParentNativeViewAccessible();
2212 2225
2213 BrowserAccessibilityManager* manager = new BrowserAccessibilityManagerWin( 2226 BrowserAccessibilityManager* manager = new BrowserAccessibilityManagerWin(
2214 hwnd, accessible_parent, 2227 legacy_render_widget_host_HWND_, accessible_parent,
2215 BrowserAccessibilityManagerWin::GetEmptyDocument(), this); 2228 BrowserAccessibilityManagerWin::GetEmptyDocument(), this);
2216 #else 2229 #else
2217 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( 2230 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create(
2218 BrowserAccessibilityManager::GetEmptyDocument(), this); 2231 BrowserAccessibilityManager::GetEmptyDocument(), this);
2219 #endif 2232 #endif
2220 2233
2221 SetBrowserAccessibilityManager(manager); 2234 SetBrowserAccessibilityManager(manager);
2222 } 2235 }
2223 2236
2224 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { 2237 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() {
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3335 // destroyed, as it may then outlive the GLHelper. 3348 // destroyed, as it may then outlive the GLHelper.
3336 for (std::set<OwnedMailbox*>::iterator it = 3349 for (std::set<OwnedMailbox*>::iterator it =
3337 active_frame_subscriber_textures_.begin(); 3350 active_frame_subscriber_textures_.begin();
3338 it != active_frame_subscriber_textures_.end(); 3351 it != active_frame_subscriber_textures_.end();
3339 ++it) { 3352 ++it) {
3340 (*it)->Destroy(); 3353 (*it)->Destroy();
3341 } 3354 }
3342 active_frame_subscriber_textures_.clear(); 3355 active_frame_subscriber_textures_.clear();
3343 3356
3344 #if defined(OS_WIN) 3357 #if defined(OS_WIN)
3345 if (::IsWindow(plugin_parent_window_)) 3358 legacy_render_widget_host_HWND_ = NULL;
3346 ::DestroyWindow(plugin_parent_window_);
3347 #endif 3359 #endif
3348 } 3360 }
3349 3361
3350 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 3362 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
3351 const gfx::Point screen_point = 3363 const gfx::Point screen_point =
3352 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); 3364 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
3353 aura::Window* root_window = window_->GetRootWindow(); 3365 aura::Window* root_window = window_->GetRootWindow();
3354 if (!root_window) 3366 if (!root_window)
3355 return; 3367 return;
3356 3368
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 RenderWidgetHost* widget) { 3578 RenderWidgetHost* widget) {
3567 return new RenderWidgetHostViewAura(widget); 3579 return new RenderWidgetHostViewAura(widget);
3568 } 3580 }
3569 3581
3570 // static 3582 // static
3571 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3583 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3572 GetScreenInfoForWindow(results, NULL); 3584 GetScreenInfoForWindow(results, NULL);
3573 } 3585 }
3574 3586
3575 } // namespace content 3587 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698