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

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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 host_->SetView(this); 494 host_->SetView(this);
494 window_observer_.reset(new WindowObserver(this)); 495 window_observer_.reset(new WindowObserver(this));
495 aura::client::SetTooltipText(window_, &tooltip_); 496 aura::client::SetTooltipText(window_, &tooltip_);
496 aura::client::SetActivationDelegate(window_, this); 497 aura::client::SetActivationDelegate(window_, this);
497 aura::client::SetActivationChangeObserver(window_, this); 498 aura::client::SetActivationChangeObserver(window_, this);
498 aura::client::SetFocusChangeObserver(window_, this); 499 aura::client::SetFocusChangeObserver(window_, this);
499 gfx::Screen::GetScreenFor(window_)->AddObserver(this); 500 gfx::Screen::GetScreenFor(window_)->AddObserver(this);
500 software_frame_manager_.reset(new SoftwareFrameManager( 501 software_frame_manager_.reset(new SoftwareFrameManager(
501 weak_ptr_factory_.GetWeakPtr())); 502 weak_ptr_factory_.GetWeakPtr()));
502 #if defined(OS_WIN) 503 #if defined(OS_WIN)
503 plugin_parent_window_ = NULL; 504 legacy_render_widget_host_HWND_ = NULL;
504 #endif 505 #endif
505 ImageTransportFactory::GetInstance()->AddObserver(this); 506 ImageTransportFactory::GetInstance()->AddObserver(this);
506 } 507 }
507 508
508 //////////////////////////////////////////////////////////////////////////////// 509 ////////////////////////////////////////////////////////////////////////////////
509 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 510 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
510 511
511 bool RenderWidgetHostViewAura::OnMessageReceived( 512 bool RenderWidgetHostViewAura::OnMessageReceived(
512 const IPC::Message& message) { 513 const IPC::Message& message) {
513 bool handled = true; 514 bool handled = true;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 !released_front_lock_.get()) { 628 !released_front_lock_.get()) {
628 ui::Compositor* compositor = GetCompositor(); 629 ui::Compositor* compositor = GetCompositor();
629 if (compositor) 630 if (compositor)
630 released_front_lock_ = compositor->GetCompositorLock(); 631 released_front_lock_ = compositor->GetCompositorLock();
631 } 632 }
632 633
633 #if defined(OS_WIN) 634 #if defined(OS_WIN)
634 LPARAM lparam = reinterpret_cast<LPARAM>(this); 635 LPARAM lparam = reinterpret_cast<LPARAM>(this);
635 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); 636 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam);
636 637
637 if (::IsWindow(plugin_parent_window_)) { 638 if (legacy_render_widget_host_HWND_ &&
639 ::IsWindow(legacy_render_widget_host_HWND_->hwnd())) {
638 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); 640 gfx::Rect window_bounds = window_->GetBoundsInRootWindow();
639 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), 641 ::SetWindowPos(legacy_render_widget_host_HWND_->hwnd(), NULL,
640 window_bounds.y(), window_bounds.width(), 642 window_bounds.x(), window_bounds.y(), window_bounds.width(),
641 window_bounds.height(), 0); 643 window_bounds.height(), 0);
642 } 644 }
643 #endif 645 #endif
644 } 646 }
645 647
646 void RenderWidgetHostViewAura::WasHidden() { 648 void RenderWidgetHostViewAura::WasHidden() {
647 if (!host_ || host_->is_hidden()) 649 if (!host_ || host_->is_hidden())
648 return; 650 return;
649 host_->WasHidden(); 651 host_->WasHidden();
650 software_frame_manager_->SetVisibility(false); 652 software_frame_manager_->SetVisibility(false);
651 delegated_frame_evictor_->SetVisible(false); 653 delegated_frame_evictor_->SetVisible(false);
652 released_front_lock_ = NULL; 654 released_front_lock_ = NULL;
653 655
654 #if defined(OS_WIN) 656 #if defined(OS_WIN)
655 constrained_rects_.clear(); 657 constrained_rects_.clear();
656 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); 658 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
657 if (dispatcher) { 659 if (dispatcher) {
658 HWND parent = dispatcher->host()->GetAcceleratedWidget(); 660 HWND parent = dispatcher->host()->GetAcceleratedWidget();
659 LPARAM lparam = reinterpret_cast<LPARAM>(this); 661 LPARAM lparam = reinterpret_cast<LPARAM>(this);
660 662
661 EnumChildWindows(parent, HideWindowsCallback, lparam); 663 EnumChildWindows(parent, HideWindowsCallback, lparam);
662 } 664 }
663 if (::IsWindow(plugin_parent_window_))
664 ::SetWindowPos(plugin_parent_window_, NULL, 0, 0, 0, 0, 0);
665 #endif 665 #endif
666 } 666 }
667 667
668 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 668 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
669 // For a SetSize operation, we don't care what coordinate system the origin 669 // For a SetSize operation, we don't care what coordinate system the origin
670 // of the window is in, it's only important to make sure that the origin 670 // of the window is in, it's only important to make sure that the origin
671 // remains constant after the operation. 671 // remains constant after the operation.
672 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); 672 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size));
673 } 673 }
674 674
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 return window_->HasFocus(); 873 return window_->HasFocus();
874 } 874 }
875 875
876 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { 876 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const {
877 return CanCopyToBitmap() || !!host_->GetBackingStore(false); 877 return CanCopyToBitmap() || !!host_->GetBackingStore(false);
878 } 878 }
879 879
880 void RenderWidgetHostViewAura::Show() { 880 void RenderWidgetHostViewAura::Show() {
881 window_->Show(); 881 window_->Show();
882 WasShown(); 882 WasShown();
883 #if defined(OS_WIN)
884 if (legacy_render_widget_host_HWND_)
885 legacy_render_widget_host_HWND_->Show();
886 #endif
883 } 887 }
884 888
885 void RenderWidgetHostViewAura::Hide() { 889 void RenderWidgetHostViewAura::Hide() {
886 window_->Hide(); 890 window_->Hide();
887 WasHidden(); 891 WasHidden();
892 #if defined(OS_WIN)
893 if (legacy_render_widget_host_HWND_)
894 legacy_render_widget_host_HWND_->Hide();
895 #endif
888 } 896 }
889 897
890 bool RenderWidgetHostViewAura::IsShowing() { 898 bool RenderWidgetHostViewAura::IsShowing() {
891 return window_->IsVisible(); 899 return window_->IsVisible();
892 } 900 }
893 901
894 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { 902 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const {
895 // This is the size that we want the renderer to produce. While we're waiting 903 // This is the size that we want the renderer to produce. While we're waiting
896 // for the correct frame (i.e. during a resize), don't change the size so that 904 // for the correct frame (i.e. during a resize), don't change the size so that
897 // we don't pipeline more resizes than we can handle. 905 // we don't pipeline more resizes than we can handle.
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 // a Window::SetBoundsInternal call. 1229 // a Window::SetBoundsInternal call.
1222 if (!in_bounds_changed_) 1230 if (!in_bounds_changed_)
1223 window_->SetBounds(rect); 1231 window_->SetBounds(rect);
1224 host_->WasResized(); 1232 host_->WasResized();
1225 MaybeCreateResizeLock(); 1233 MaybeCreateResizeLock();
1226 if (touch_editing_client_) { 1234 if (touch_editing_client_) {
1227 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 1235 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_,
1228 selection_focus_rect_); 1236 selection_focus_rect_);
1229 } 1237 }
1230 #if defined(OS_WIN) 1238 #if defined(OS_WIN)
1231 // Create the dummy plugin parent window which will be passed as the 1239 // Create the legacy dummy window which corresponds to the bounds of the
1232 // container window to windowless plugins. 1240 // webcontents. This will be passed as the container window for windowless
1241 // plugins.
1233 // Plugins like Flash assume the container window which is returned via the 1242 // Plugins like Flash assume the container window which is returned via the
1234 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. 1243 // NPNVnetscapeWindow property corresponds to the bounds of the webpage.
1235 // This is not true in Aura where we have only HWND which is the main Aura 1244 // This is not true in Aura where we have only HWND which is the main Aura
1236 // window. If we return this window to plugins like Flash then it causes the 1245 // window. If we return this window to plugins like Flash then it causes the
1237 // coordinate translations done by these plugins to break. 1246 // coordinate translations done by these plugins to break.
1238 if (!plugin_parent_window_ && GetNativeViewId()) { 1247 // Additonally the legacy dummy window is needed for accessibility and for
1239 plugin_parent_window_ = ::CreateWindowEx( 1248 // scrolling to work in legacy drivers for trackpoints/trackpads, etc.
1240 0, L"Static", NULL, WS_CHILDWINDOW, 0, 0, 0, 0, 1249 if (GetNativeViewId()) {
1241 reinterpret_cast<HWND>(GetNativeViewId()), NULL, NULL, NULL); 1250 if (!legacy_render_widget_host_HWND_) {
1242 if (::IsWindow(plugin_parent_window_)) 1251 legacy_render_widget_host_HWND_ = new LegacyRenderWidgetHostHWND(
1243 ::SetProp(plugin_parent_window_, content::kPluginDummyParentProperty, 1252 reinterpret_cast<HWND>(GetNativeViewId()));
1244 reinterpret_cast<HANDLE>(true)); 1253 }
1245 } 1254 if (::IsWindow(legacy_render_widget_host_HWND_->hwnd())) {
1246 if (::IsWindow(plugin_parent_window_)) { 1255 gfx::Rect window_bounds = window_->GetBoundsInRootWindow();
1247 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); 1256 ::SetWindowPos(legacy_render_widget_host_HWND_->hwnd(), NULL,
1248 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), 1257 window_bounds.x(), window_bounds.y(),
1249 window_bounds.y(), window_bounds.width(), 1258 window_bounds.width(), window_bounds.height(), 0);
1250 window_bounds.height(), 0); 1259 }
1251 } 1260 }
1252 #endif 1261 #endif
1253 } 1262 }
1254 1263
1255 void RenderWidgetHostViewAura::CheckResizeLock() { 1264 void RenderWidgetHostViewAura::CheckResizeLock() {
1256 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_) 1265 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_)
1257 return; 1266 return;
1258 1267
1259 // Since we got the size we were looking for, unlock the compositor. But delay 1268 // Since we got the size we were looking for, unlock the compositor. But delay
1260 // the release of the lock until we've kicked a frame with the new texture, to 1269 // the release of the lock until we've kicked a frame with the new texture, to
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1719 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1711 gfx::NativeViewAccessible accessible_parent) { 1720 gfx::NativeViewAccessible accessible_parent) {
1712 if (GetBrowserAccessibilityManager()) { 1721 if (GetBrowserAccessibilityManager()) {
1713 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() 1722 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin()
1714 ->set_parent_iaccessible(accessible_parent); 1723 ->set_parent_iaccessible(accessible_parent);
1715 } 1724 }
1716 } 1725 }
1717 1726
1718 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1727 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1719 const { 1728 const {
1720 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); 1729 if (legacy_render_widget_host_HWND_) {
1730 return reinterpret_cast<gfx::NativeViewId>(
1731 legacy_render_widget_host_HWND_->hwnd());
1732 }
1733 return NULL;
1721 } 1734 }
1722 #endif 1735 #endif
1723 1736
1724 void RenderWidgetHostViewAura::BuffersSwapped( 1737 void RenderWidgetHostViewAura::BuffersSwapped(
1725 const gfx::Size& surface_size, 1738 const gfx::Size& surface_size,
1726 const gfx::Rect& damage_rect, 1739 const gfx::Rect& damage_rect,
1727 float surface_scale_factor, 1740 float surface_scale_factor,
1728 const std::string& mailbox_name, 1741 const std::string& mailbox_name,
1729 const std::vector<ui::LatencyInfo>& latency_info, 1742 const std::vector<ui::LatencyInfo>& latency_info,
1730 const BufferPresentedCallback& ack_callback) { 1743 const BufferPresentedCallback& ack_callback) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 return; 2224 return;
2212 HWND hwnd = dispatcher->host()->GetAcceleratedWidget(); 2225 HWND hwnd = dispatcher->host()->GetAcceleratedWidget();
2213 2226
2214 // The accessible_parent may be NULL at this point. The WebContents will pass 2227 // The accessible_parent may be NULL at this point. The WebContents will pass
2215 // it down to this instance (by way of the RenderViewHost and 2228 // it down to this instance (by way of the RenderViewHost and
2216 // RenderWidgetHost) when it is known. This instance will then set it on its 2229 // RenderWidgetHost) when it is known. This instance will then set it on its
2217 // BrowserAccessibilityManager. 2230 // BrowserAccessibilityManager.
2218 gfx::NativeViewAccessible accessible_parent = 2231 gfx::NativeViewAccessible accessible_parent =
2219 host_->GetParentNativeViewAccessible(); 2232 host_->GetParentNativeViewAccessible();
2220 2233
2221 BrowserAccessibilityManager* manager = new BrowserAccessibilityManagerWin( 2234 BrowserAccessibilityManager* manager = new BrowserAccessibilityManagerWin(
2222 hwnd, accessible_parent, 2235 legacy_render_widget_host_HWND_, accessible_parent,
2223 BrowserAccessibilityManagerWin::GetEmptyDocument(), this); 2236 BrowserAccessibilityManagerWin::GetEmptyDocument(), this);
2224 #else 2237 #else
2225 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( 2238 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create(
2226 BrowserAccessibilityManager::GetEmptyDocument(), this); 2239 BrowserAccessibilityManager::GetEmptyDocument(), this);
2227 #endif 2240 #endif
2228 2241
2229 SetBrowserAccessibilityManager(manager); 2242 SetBrowserAccessibilityManager(manager);
2230 } 2243 }
2231 2244
2232 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { 2245 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() {
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 // destroyed, as it may then outlive the GLHelper. 3361 // destroyed, as it may then outlive the GLHelper.
3349 for (std::set<OwnedMailbox*>::iterator it = 3362 for (std::set<OwnedMailbox*>::iterator it =
3350 active_frame_subscriber_textures_.begin(); 3363 active_frame_subscriber_textures_.begin();
3351 it != active_frame_subscriber_textures_.end(); 3364 it != active_frame_subscriber_textures_.end();
3352 ++it) { 3365 ++it) {
3353 (*it)->Destroy(); 3366 (*it)->Destroy();
3354 } 3367 }
3355 active_frame_subscriber_textures_.clear(); 3368 active_frame_subscriber_textures_.clear();
3356 3369
3357 #if defined(OS_WIN) 3370 #if defined(OS_WIN)
3358 if (::IsWindow(plugin_parent_window_)) 3371 legacy_render_widget_host_HWND_ = NULL;
3359 ::DestroyWindow(plugin_parent_window_);
3360 #endif 3372 #endif
3361 } 3373 }
3362 3374
3363 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 3375 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
3364 const gfx::Point screen_point = 3376 const gfx::Point screen_point =
3365 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); 3377 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
3366 aura::Window* root_window = window_->GetRootWindow(); 3378 aura::Window* root_window = window_->GetRootWindow();
3367 if (!root_window) 3379 if (!root_window)
3368 return; 3380 return;
3369 3381
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 cursor_client->AddObserver(this); 3524 cursor_client->AddObserver(this);
3513 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 3525 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
3514 } 3526 }
3515 if (current_surface_.get()) 3527 if (current_surface_.get())
3516 UpdateExternalTexture(); 3528 UpdateExternalTexture();
3517 if (HasFocus()) { 3529 if (HasFocus()) {
3518 ui::InputMethod* input_method = GetInputMethod(); 3530 ui::InputMethod* input_method = GetInputMethod();
3519 if (input_method) 3531 if (input_method)
3520 input_method->SetFocusedTextInputClient(this); 3532 input_method->SetFocusedTextInputClient(this);
3521 } 3533 }
3534 #if defined(OS_WIN)
3535 if (legacy_render_widget_host_HWND_ && GetNativeViewId()) {
3536 // The parent may have changed here. Ensure that the legacy window is
3537 // reparented accordingly.
3538 legacy_render_widget_host_HWND_->SetParentWindow(
3539 reinterpret_cast<HWND>(GetNativeViewId()));
3540 }
3541 #endif
3522 } 3542 }
3523 3543
3524 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 3544 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
3525 aura::client::CursorClient* cursor_client = 3545 aura::client::CursorClient* cursor_client =
3526 aura::client::GetCursorClient(window_->GetRootWindow()); 3546 aura::client::GetCursorClient(window_->GetRootWindow());
3527 if (cursor_client) 3547 if (cursor_client)
3528 cursor_client->RemoveObserver(this); 3548 cursor_client->RemoveObserver(this);
3529 3549
3530 DetachFromInputMethod(); 3550 DetachFromInputMethod();
3531 3551
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3576 RenderWidgetHost* widget) { 3596 RenderWidgetHost* widget) {
3577 return new RenderWidgetHostViewAura(widget); 3597 return new RenderWidgetHostViewAura(widget);
3578 } 3598 }
3579 3599
3580 // static 3600 // static
3581 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3601 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3582 GetScreenInfoForWindow(results, NULL); 3602 GetScreenInfoForWindow(results, NULL);
3583 } 3603 }
3584 3604
3585 } // namespace content 3605 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698