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

Unified Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 387353004: Create only a single LegacyRenderWidgetHostHWND per WebContentsViewAura. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render_frame_ax_3
Patch Set: Fix Win 8 Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_view_aura.cc
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index ecbe02ca04e5d4dd798d5a9a6599dbc6e03229c1..e2ff3c732bae31613844b8dbd442347114f36e63 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -66,10 +66,17 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_png_rep.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen.h"
#include "ui/wm/public/drag_drop_client.h"
#include "ui/wm/public/drag_drop_delegate.h"
+#if defined(OS_WIN)
+#include "content/browser/accessibility/browser_accessibility_manager.h"
+#include "content/browser/accessibility/browser_accessibility_win.h"
+#include "ui/base/win/hidden_window.h"
+#endif
+
namespace content {
WebContentsView* CreateWebContentsView(
WebContentsImpl* web_contents,
@@ -641,6 +648,10 @@ class WebContentsViewAura::WindowObserver
#if defined(OS_WIN)
if (!window->GetRootWindow()->HasObserver(this))
window->GetRootWindow()->AddObserver(this);
+ if (view_->legacy_hwnd_) {
+ view_->legacy_hwnd_->UpdateParent(
+ window->GetHost()->GetAcceleratedWidget());
+ }
#endif
}
}
@@ -660,6 +671,11 @@ class WebContentsViewAura::WindowObserver
root_children[i]->RemoveObserver(this);
}
}
+
+ // Update the legacy window's parent temporarily to the desktop window.
+ // It will eventually get reparented to the right root.
+ if (view_->legacy_hwnd_)
+ view_->legacy_hwnd_->UpdateParent(::GetDesktopWindow());
ananta 2014/09/23 20:14:06 I know that this is a copy of the existing code in
dmazzoni 2014/09/24 22:57:52 Makes sense, done.
#endif
}
}
@@ -1013,6 +1029,8 @@ void WebContentsViewAura::SizeContents(const gfx::Size& size) {
if (bounds.size() != size) {
bounds.set_size(size);
window_->SetBounds(bounds);
+ if (legacy_hwnd_)
+ legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow());
} else {
// Our size matches what we want but the renderers size may not match.
// Pretend we were resized so that the renderers size is updated too.
@@ -1106,6 +1124,15 @@ void WebContentsViewAura::CreateView(
// platforms as well.
if (delegate_)
drag_dest_delegate_ = delegate_->GetDragDestDelegate();
+
+#if defined(OS_WIN)
+ HWND parent_hwnd;
+ if (context && context->GetHost())
+ parent_hwnd = context->GetHost()->GetAcceleratedWidget();
+ else
+ parent_hwnd = ::GetDesktopWindow();
ananta 2014/09/23 20:14:06 It would be good to know when context is going to
dmazzoni 2014/09/24 22:57:52 The comment above says that sometimes object hiera
+ legacy_hwnd_.reset(LegacyRenderWidgetHostHWND::Create(parent_hwnd, this));
+#endif
}
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
@@ -1146,12 +1173,22 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
}
AttachTouchEditableToRenderView();
+
+#if defined(OS_WIN)
+ view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get());
+#endif
+
return view;
}
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
- return new RenderWidgetHostViewAura(render_widget_host);
+ RenderWidgetHostViewAura* view =
+ new RenderWidgetHostViewAura(render_widget_host);
+#if defined(OS_WIN)
+ view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get());
+#endif
+ return view;
}
void WebContentsViewAura::SetPageTitle(const base::string16& title) {
@@ -1621,6 +1658,35 @@ void WebContentsViewAura::UpdateWebContentsVisibility(bool visible) {
if (web_contents_->should_normally_be_visible())
web_contents_->WasHidden();
}
+
+#if defined(OS_WIN)
+ if (!legacy_hwnd_)
+ return;
+
+ if (visible) {
+ legacy_hwnd_->UpdateParent(
+ GetNativeView()->GetHost()->GetAcceleratedWidget());
+ legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow());
+ legacy_hwnd_->Show();
+ } else {
+ // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global
+ // hidden window on the same lines as Windowed plugin windows.
+ legacy_hwnd_->UpdateParent(ui::GetHiddenWindow());
+ legacy_hwnd_->Hide();
+ }
+#endif
+}
+
+#if defined(OS_WIN)
+gfx::NativeViewAccessible
+WebContentsViewAura::GetNativeViewAccessible() {
+ BrowserAccessibilityManager* manager =
+ web_contents_->GetRootBrowserAccessibilityManager();
+ if (!manager)
+ return NULL;
+
+ return manager->GetRoot()->ToBrowserAccessibilityWin();
}
+#endif
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698