Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
=================================================================== |
--- content/browser/renderer_host/render_widget_host_view_aura.cc (revision 248647) |
+++ content/browser/renderer_host/render_widget_host_view_aura.cc (working copy) |
@@ -83,6 +83,7 @@ |
#include "base/win/windows_version.h" |
#include "content/browser/accessibility/browser_accessibility_manager_win.h" |
#include "content/browser/accessibility/browser_accessibility_win.h" |
+#include "content/browser/renderer_host/legacy_render_widget_host_win.h" |
#include "content/common/plugin_constants_win.h" |
#include "ui/base/win/hidden_window.h" |
#include "ui/gfx/gdi_util.h" |
@@ -499,9 +500,6 @@ |
gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
software_frame_manager_.reset(new SoftwareFrameManager( |
weak_ptr_factory_.GetWeakPtr())); |
-#if defined(OS_WIN) |
- plugin_parent_window_ = NULL; |
-#endif |
ImageTransportFactory::GetInstance()->AddObserver(this); |
} |
@@ -634,11 +632,9 @@ |
LPARAM lparam = reinterpret_cast<LPARAM>(this); |
EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); |
- if (::IsWindow(plugin_parent_window_)) { |
- gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); |
- ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), |
- window_bounds.y(), window_bounds.width(), |
- window_bounds.height(), 0); |
+ if (legacy_render_widget_host_HWND_) { |
+ legacy_render_widget_host_HWND_->SetBounds( |
+ window_->GetBoundsInRootWindow()); |
} |
#endif |
} |
@@ -660,8 +656,6 @@ |
EnumChildWindows(parent, HideWindowsCallback, lparam); |
} |
- if (::IsWindow(plugin_parent_window_)) |
- ::SetWindowPos(plugin_parent_window_, NULL, 0, 0, 0, 0, 0); |
#endif |
} |
@@ -880,11 +874,19 @@ |
void RenderWidgetHostViewAura::Show() { |
window_->Show(); |
WasShown(); |
+#if defined(OS_WIN) |
+ if (legacy_render_widget_host_HWND_) |
+ legacy_render_widget_host_HWND_->Show(); |
+#endif |
} |
void RenderWidgetHostViewAura::Hide() { |
window_->Hide(); |
WasHidden(); |
+#if defined(OS_WIN) |
+ if (legacy_render_widget_host_HWND_) |
+ legacy_render_widget_host_HWND_->Hide(); |
+#endif |
} |
bool RenderWidgetHostViewAura::IsShowing() { |
@@ -1228,27 +1230,26 @@ |
selection_focus_rect_); |
} |
#if defined(OS_WIN) |
- // Create the dummy plugin parent window which will be passed as the |
- // container window to windowless plugins. |
+ // Create the legacy dummy window which corresponds to the bounds of the |
+ // webcontents. This will be passed as the container window for windowless |
+ // plugins. |
// Plugins like Flash assume the container window which is returned via the |
// NPNVnetscapeWindow property corresponds to the bounds of the webpage. |
// This is not true in Aura where we have only HWND which is the main Aura |
// window. If we return this window to plugins like Flash then it causes the |
// coordinate translations done by these plugins to break. |
- if (!plugin_parent_window_ && GetNativeViewId()) { |
- plugin_parent_window_ = ::CreateWindowEx( |
- 0, L"Static", NULL, WS_CHILDWINDOW, 0, 0, 0, 0, |
- reinterpret_cast<HWND>(GetNativeViewId()), NULL, NULL, NULL); |
- if (::IsWindow(plugin_parent_window_)) |
- ::SetProp(plugin_parent_window_, content::kPluginDummyParentProperty, |
- reinterpret_cast<HANDLE>(true)); |
+ // Additonally the legacy dummy window is needed for accessibility and for |
+ // scrolling to work in legacy drivers for trackpoints/trackpads, etc. |
+ if (GetNativeViewId()) { |
+ if (!legacy_render_widget_host_HWND_) { |
+ legacy_render_widget_host_HWND_.reset(LegacyRenderWidgetHostHWND::Create( |
+ reinterpret_cast<HWND>(GetNativeViewId()))); |
+ } |
+ if (legacy_render_widget_host_HWND_) { |
+ legacy_render_widget_host_HWND_->SetBounds( |
+ window_->GetBoundsInRootWindow()); |
+ } |
} |
- if (::IsWindow(plugin_parent_window_)) { |
- gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); |
- ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), |
- window_bounds.y(), window_bounds.width(), |
- window_bounds.height(), 0); |
- } |
#endif |
} |
@@ -1717,7 +1718,11 @@ |
gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
const { |
- return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); |
+ if (legacy_render_widget_host_HWND_) { |
+ return reinterpret_cast<gfx::NativeViewId>( |
+ legacy_render_widget_host_HWND_->hwnd()); |
+ } |
+ return NULL; |
} |
#endif |
@@ -2205,6 +2210,7 @@ |
if (GetBrowserAccessibilityManager()) |
return; |
+ BrowserAccessibilityManager* manager = NULL; |
#if defined(OS_WIN) |
aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
if (!dispatcher) |
@@ -2218,14 +2224,15 @@ |
gfx::NativeViewAccessible accessible_parent = |
host_->GetParentNativeViewAccessible(); |
- BrowserAccessibilityManager* manager = new BrowserAccessibilityManagerWin( |
- hwnd, accessible_parent, |
- BrowserAccessibilityManagerWin::GetEmptyDocument(), this); |
+ if (legacy_render_widget_host_HWND_) { |
+ manager = new BrowserAccessibilityManagerWin( |
+ legacy_render_widget_host_HWND_.get(), accessible_parent, |
+ BrowserAccessibilityManagerWin::GetEmptyDocument(), this); |
+ } |
#else |
- BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create( |
+ manager = BrowserAccessibilityManager::Create( |
BrowserAccessibilityManager::GetEmptyDocument(), this); |
#endif |
- |
SetBrowserAccessibilityManager(manager); |
} |
@@ -3355,8 +3362,7 @@ |
active_frame_subscriber_textures_.clear(); |
#if defined(OS_WIN) |
- if (::IsWindow(plugin_parent_window_)) |
- ::DestroyWindow(plugin_parent_window_); |
+ legacy_render_widget_host_HWND_.reset(NULL); |
#endif |
} |
@@ -3503,7 +3509,6 @@ |
void RenderWidgetHostViewAura::AddedToRootWindow() { |
window_->GetDispatcher()->AddRootWindowObserver(this); |
- host_->ParentChanged(GetNativeViewId()); |
UpdateScreenInfo(window_); |
aura::client::CursorClient* cursor_client = |
@@ -3519,6 +3524,14 @@ |
if (input_method) |
input_method->SetFocusedTextInputClient(this); |
} |
+ |
+#if defined(OS_WIN) |
+ // The parent may have changed here. Ensure that the legacy window is |
+ // reparented accordingly. |
+ if (legacy_render_widget_host_HWND_) |
+ legacy_render_widget_host_HWND_->UpdateParent( |
+ reinterpret_cast<HWND>(GetNativeViewId())); |
+#endif |
} |
void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
@@ -3530,7 +3543,6 @@ |
DetachFromInputMethod(); |
window_->GetDispatcher()->RemoveRootWindowObserver(this); |
- host_->ParentChanged(0); |
ui::Compositor* compositor = GetCompositor(); |
if (current_surface_.get()) { |
// We can't get notification for commits after this point, which would |
@@ -3545,6 +3557,13 @@ |
host_->WasResized(); |
if (compositor && compositor->HasObserver(this)) |
compositor->RemoveObserver(this); |
+ |
+#if defined(OS_WIN) |
+ // Update the legacy window's parent temporarily to the desktop window. It |
+ // will eventually get reparented to the right root. |
+ if (legacy_render_widget_host_HWND_) |
+ legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
sky
2014/02/05 23:56:41
When you do this should you disable the window or
ananta
2014/02/06 00:42:04
It should not because of WS_EX_TRANSPARENT. Added
|
+#endif |
} |
ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { |