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

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_) {
638 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); 639 legacy_render_widget_host_HWND_->SetBounds(
639 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), 640 window_->GetBoundsInRootWindow());
640 window_bounds.y(), window_bounds.width(),
641 window_bounds.height(), 0);
642 } 641 }
643 #endif 642 #endif
644 } 643 }
645 644
646 void RenderWidgetHostViewAura::WasHidden() { 645 void RenderWidgetHostViewAura::WasHidden() {
647 if (!host_ || host_->is_hidden()) 646 if (!host_ || host_->is_hidden())
648 return; 647 return;
649 host_->WasHidden(); 648 host_->WasHidden();
650 software_frame_manager_->SetVisibility(false); 649 software_frame_manager_->SetVisibility(false);
651 delegated_frame_evictor_->SetVisible(false); 650 delegated_frame_evictor_->SetVisible(false);
652 released_front_lock_ = NULL; 651 released_front_lock_ = NULL;
653 652
654 #if defined(OS_WIN) 653 #if defined(OS_WIN)
655 constrained_rects_.clear(); 654 constrained_rects_.clear();
656 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); 655 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
657 if (dispatcher) { 656 if (dispatcher) {
658 HWND parent = dispatcher->host()->GetAcceleratedWidget(); 657 HWND parent = dispatcher->host()->GetAcceleratedWidget();
659 LPARAM lparam = reinterpret_cast<LPARAM>(this); 658 LPARAM lparam = reinterpret_cast<LPARAM>(this);
660 659
661 EnumChildWindows(parent, HideWindowsCallback, lparam); 660 EnumChildWindows(parent, HideWindowsCallback, lparam);
662 } 661 }
663 if (::IsWindow(plugin_parent_window_))
664 ::SetWindowPos(plugin_parent_window_, NULL, 0, 0, 0, 0, 0);
665 #endif 662 #endif
666 } 663 }
667 664
668 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 665 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
669 // For a SetSize operation, we don't care what coordinate system the origin 666 // 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 667 // of the window is in, it's only important to make sure that the origin
671 // remains constant after the operation. 668 // remains constant after the operation.
672 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size)); 669 InternalSetBounds(gfx::Rect(window_->bounds().origin(), size));
673 } 670 }
674 671
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 return window_->HasFocus(); 870 return window_->HasFocus();
874 } 871 }
875 872
876 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { 873 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const {
877 return CanCopyToBitmap() || !!host_->GetBackingStore(false); 874 return CanCopyToBitmap() || !!host_->GetBackingStore(false);
878 } 875 }
879 876
880 void RenderWidgetHostViewAura::Show() { 877 void RenderWidgetHostViewAura::Show() {
881 window_->Show(); 878 window_->Show();
882 WasShown(); 879 WasShown();
880 #if defined(OS_WIN)
881 if (legacy_render_widget_host_HWND_)
882 legacy_render_widget_host_HWND_->Show();
883 #endif
883 } 884 }
884 885
885 void RenderWidgetHostViewAura::Hide() { 886 void RenderWidgetHostViewAura::Hide() {
886 window_->Hide(); 887 window_->Hide();
887 WasHidden(); 888 WasHidden();
889 #if defined(OS_WIN)
890 if (legacy_render_widget_host_HWND_)
891 legacy_render_widget_host_HWND_->Hide();
892 #endif
888 } 893 }
889 894
890 bool RenderWidgetHostViewAura::IsShowing() { 895 bool RenderWidgetHostViewAura::IsShowing() {
891 return window_->IsVisible(); 896 return window_->IsVisible();
892 } 897 }
893 898
894 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { 899 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const {
895 // This is the size that we want the renderer to produce. While we're waiting 900 // 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 901 // 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. 902 // 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. 1226 // a Window::SetBoundsInternal call.
1222 if (!in_bounds_changed_) 1227 if (!in_bounds_changed_)
1223 window_->SetBounds(rect); 1228 window_->SetBounds(rect);
1224 host_->WasResized(); 1229 host_->WasResized();
1225 MaybeCreateResizeLock(); 1230 MaybeCreateResizeLock();
1226 if (touch_editing_client_) { 1231 if (touch_editing_client_) {
1227 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 1232 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_,
1228 selection_focus_rect_); 1233 selection_focus_rect_);
1229 } 1234 }
1230 #if defined(OS_WIN) 1235 #if defined(OS_WIN)
1231 // Create the dummy plugin parent window which will be passed as the 1236 // Create the legacy dummy window which corresponds to the bounds of the
1232 // container window to windowless plugins. 1237 // webcontents. This will be passed as the container window for windowless
1238 // plugins.
1233 // Plugins like Flash assume the container window which is returned via the 1239 // Plugins like Flash assume the container window which is returned via the
1234 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. 1240 // 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 1241 // 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 1242 // window. If we return this window to plugins like Flash then it causes the
1237 // coordinate translations done by these plugins to break. 1243 // coordinate translations done by these plugins to break.
1238 if (!plugin_parent_window_ && GetNativeViewId()) { 1244 // Additonally the legacy dummy window is needed for accessibility and for
1239 plugin_parent_window_ = ::CreateWindowEx( 1245 // scrolling to work in legacy drivers for trackpoints/trackpads, etc.
1240 0, L"Static", NULL, WS_CHILDWINDOW, 0, 0, 0, 0, 1246 if (GetNativeViewId()) {
1241 reinterpret_cast<HWND>(GetNativeViewId()), NULL, NULL, NULL); 1247 if (!legacy_render_widget_host_HWND_) {
1242 if (::IsWindow(plugin_parent_window_)) 1248 legacy_render_widget_host_HWND_ = new LegacyRenderWidgetHostHWND(
1243 ::SetProp(plugin_parent_window_, content::kPluginDummyParentProperty, 1249 reinterpret_cast<HWND>(GetNativeViewId()));
1244 reinterpret_cast<HANDLE>(true)); 1250 }
1245 } 1251 legacy_render_widget_host_HWND_->SetBounds(
1246 if (::IsWindow(plugin_parent_window_)) { 1252 window_->GetBoundsInRootWindow());
1247 gfx::Rect window_bounds = window_->GetBoundsInRootWindow();
1248 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(),
1249 window_bounds.y(), window_bounds.width(),
1250 window_bounds.height(), 0);
1251 } 1253 }
1252 #endif 1254 #endif
1253 } 1255 }
1254 1256
1255 void RenderWidgetHostViewAura::CheckResizeLock() { 1257 void RenderWidgetHostViewAura::CheckResizeLock() {
1256 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_) 1258 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_)
1257 return; 1259 return;
1258 1260
1259 // 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
1260 // 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1712 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1711 gfx::NativeViewAccessible accessible_parent) { 1713 gfx::NativeViewAccessible accessible_parent) {
1712 if (GetBrowserAccessibilityManager()) { 1714 if (GetBrowserAccessibilityManager()) {
1713 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() 1715 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin()
1714 ->set_parent_iaccessible(accessible_parent); 1716 ->set_parent_iaccessible(accessible_parent);
1715 } 1717 }
1716 } 1718 }
1717 1719
1718 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1720 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1719 const { 1721 const {
1720 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); 1722 if (legacy_render_widget_host_HWND_) {
1723 return reinterpret_cast<gfx::NativeViewId>(
1724 legacy_render_widget_host_HWND_->hwnd());
1725 }
1726 return NULL;
1721 } 1727 }
1722 #endif 1728 #endif
1723 1729
1724 void RenderWidgetHostViewAura::BuffersSwapped( 1730 void RenderWidgetHostViewAura::BuffersSwapped(
1725 const gfx::Size& surface_size, 1731 const gfx::Size& surface_size,
1726 const gfx::Rect& damage_rect, 1732 const gfx::Rect& damage_rect,
1727 float surface_scale_factor, 1733 float surface_scale_factor,
1728 const std::string& mailbox_name, 1734 const std::string& mailbox_name,
1729 const std::vector<ui::LatencyInfo>& latency_info, 1735 const std::vector<ui::LatencyInfo>& latency_info,
1730 const BufferPresentedCallback& ack_callback) { 1736 const BufferPresentedCallback& ack_callback) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 return; 2217 return;
2212 HWND hwnd = dispatcher->host()->GetAcceleratedWidget(); 2218 HWND hwnd = dispatcher->host()->GetAcceleratedWidget();
2213 2219
2214 // The accessible_parent may be NULL at this point. The WebContents will pass 2220 // 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 2221 // 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 2222 // RenderWidgetHost) when it is known. This instance will then set it on its
2217 // BrowserAccessibilityManager. 2223 // BrowserAccessibilityManager.
2218 gfx::NativeViewAccessible accessible_parent = 2224 gfx::NativeViewAccessible accessible_parent =
2219 host_->GetParentNativeViewAccessible(); 2225 host_->GetParentNativeViewAccessible();
2220 2226
2221 BrowserAccessibilityManager* manager = new BrowserAccessibilityManagerWin( 2227 BrowserAccessibilityManager* manager = new BrowserAccessibilityManagerWin(
2222 hwnd, accessible_parent, 2228 legacy_render_widget_host_HWND_, accessible_parent,
2223 BrowserAccessibilityManagerWin::GetEmptyDocument(), this); 2229 BrowserAccessibilityManagerWin::GetEmptyDocument(), this);
2224 #else 2230 #else
2225 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( 2231 BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create(
2226 BrowserAccessibilityManager::GetEmptyDocument(), this); 2232 BrowserAccessibilityManager::GetEmptyDocument(), this);
2227 #endif 2233 #endif
2228 2234
2229 SetBrowserAccessibilityManager(manager); 2235 SetBrowserAccessibilityManager(manager);
2230 } 2236 }
2231 2237
2232 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { 2238 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. 3354 // destroyed, as it may then outlive the GLHelper.
3349 for (std::set<OwnedMailbox*>::iterator it = 3355 for (std::set<OwnedMailbox*>::iterator it =
3350 active_frame_subscriber_textures_.begin(); 3356 active_frame_subscriber_textures_.begin();
3351 it != active_frame_subscriber_textures_.end(); 3357 it != active_frame_subscriber_textures_.end();
3352 ++it) { 3358 ++it) {
3353 (*it)->Destroy(); 3359 (*it)->Destroy();
3354 } 3360 }
3355 active_frame_subscriber_textures_.clear(); 3361 active_frame_subscriber_textures_.clear();
3356 3362
3357 #if defined(OS_WIN) 3363 #if defined(OS_WIN)
3358 if (::IsWindow(plugin_parent_window_)) 3364 if (legacy_render_widget_host_HWND_)
sky 2014/02/05 18:16:47 nit: no need for if.
ananta 2014/02/05 19:52:36 Code has been changed to call legacy_render_widget
3359 ::DestroyWindow(plugin_parent_window_); 3365 delete legacy_render_widget_host_HWND_;
3360 #endif 3366 #endif
3361 } 3367 }
3362 3368
3363 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 3369 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
3364 const gfx::Point screen_point = 3370 const gfx::Point screen_point =
3365 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); 3371 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
3366 aura::Window* root_window = window_->GetRootWindow(); 3372 aura::Window* root_window = window_->GetRootWindow();
3367 if (!root_window) 3373 if (!root_window)
3368 return; 3374 return;
3369 3375
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 cursor_client->AddObserver(this); 3518 cursor_client->AddObserver(this);
3513 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 3519 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
3514 } 3520 }
3515 if (current_surface_.get()) 3521 if (current_surface_.get())
3516 UpdateExternalTexture(); 3522 UpdateExternalTexture();
3517 if (HasFocus()) { 3523 if (HasFocus()) {
3518 ui::InputMethod* input_method = GetInputMethod(); 3524 ui::InputMethod* input_method = GetInputMethod();
3519 if (input_method) 3525 if (input_method)
3520 input_method->SetFocusedTextInputClient(this); 3526 input_method->SetFocusedTextInputClient(this);
3521 } 3527 }
3528 #if defined(OS_WIN)
3529 if (legacy_render_widget_host_HWND_ && GetNativeViewId()) {
sky 2014/02/05 18:16:47 Can you instead destroy in RemoveFromRootWindow an
ananta 2014/02/05 19:52:36 I don't think destroying and creating would work g
sky 2014/02/05 21:56:15 My worry is that I don't know if you are guarantee
3530 // The parent may have changed here. Ensure that the legacy window is
3531 // reparented accordingly.
3532 legacy_render_widget_host_HWND_->SetParentWindow(
3533 reinterpret_cast<HWND>(GetNativeViewId()));
3534 }
3535 #endif
3522 } 3536 }
3523 3537
3524 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 3538 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
3525 aura::client::CursorClient* cursor_client = 3539 aura::client::CursorClient* cursor_client =
3526 aura::client::GetCursorClient(window_->GetRootWindow()); 3540 aura::client::GetCursorClient(window_->GetRootWindow());
3527 if (cursor_client) 3541 if (cursor_client)
3528 cursor_client->RemoveObserver(this); 3542 cursor_client->RemoveObserver(this);
3529 3543
3530 DetachFromInputMethod(); 3544 DetachFromInputMethod();
3531 3545
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3576 RenderWidgetHost* widget) { 3590 RenderWidgetHost* widget) {
3577 return new RenderWidgetHostViewAura(widget); 3591 return new RenderWidgetHostViewAura(widget);
3578 } 3592 }
3579 3593
3580 // static 3594 // static
3581 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3595 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3582 GetScreenInfoForWindow(results, NULL); 3596 GetScreenInfoForWindow(results, NULL);
3583 } 3597 }
3584 3598
3585 } // namespace content 3599 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698