Commit 872e268d authored by Dominic Mazzoni's avatar Dominic Mazzoni

Revert "Create only a single LegacyRenderWidgetHostHWND per WebContentsViewAura."

This reverts these three changes - the original one, plus two fixes that landed on top of it.
It's too late to try to fix bug 393665. Let's revert, merge the revert to M40, then try again
when we have a proper fix for bug 393665.

4f8a4bca #301810 https://codereview.chromium.org/387353004
ffd2bdde #307160 https://codereview.chromium.org/771353004
5a1a4d91 #307167 https://codereview.chromium.org/784553002

BUG=437701,393665
TBR=ananta

Review URL: https://codereview.chromium.org/796333009

Cr-Commit-Position: refs/heads/master@{#309549}
parent 1216c607
......@@ -11,6 +11,7 @@
#include "content/browser/accessibility/browser_accessibility_manager_win.h"
#include "content/browser/accessibility/browser_accessibility_state_impl.h"
#include "content/browser/accessibility/browser_accessibility_win.h"
#include "content/browser/renderer_host/legacy_render_widget_host_win.h"
#include "content/common/accessibility_messages.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/win/atl_module.h"
......
......@@ -7,7 +7,8 @@
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "base/win/windows_version.h"
#include "content/browser/renderer_host/legacy_render_widget_host_win_delegate.h"
#include "content/browser/accessibility/browser_accessibility_manager_win.h"
#include "content/browser/accessibility/browser_accessibility_win.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
#include "content/public/browser/browser_accessibility_state.h"
......@@ -21,44 +22,40 @@
namespace content {
namespace {
// A custom MSAA object id used to determine if a screen reader or some
// other client is listening on MSAA events - if so, we enable full web
// accessibility support.
const int kIdScreenReaderHoneyPot = 1;
} // namespace
LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() {
if (::IsWindow(hwnd()))
::DestroyWindow(hwnd());
}
// static
LegacyRenderWidgetHostHWND* LegacyRenderWidgetHostHWND::Create(
HWND parent,
LegacyRenderWidgetHostHWNDDelegate* delegate) {
HWND parent) {
// content_unittests passes in the desktop window as the parent. We allow
// the LegacyRenderWidgetHostHWND instance to be created in this case for
// these tests to pass.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableLegacyIntermediateWindow)) {
switches::kDisableLegacyIntermediateWindow) ||
(!GetWindowEventTarget(parent) && parent != ::GetDesktopWindow()))
return nullptr;
}
LegacyRenderWidgetHostHWND* legacy_window_instance =
new LegacyRenderWidgetHostHWND(parent, delegate);
// If we failed to create the child, return NULL.
new LegacyRenderWidgetHostHWND(parent);
// If we failed to create the child, or if the switch to disable the legacy
// window is passed in, then return NULL.
if (!::IsWindow(legacy_window_instance->hwnd())) {
delete legacy_window_instance;
return nullptr;
return NULL;
}
legacy_window_instance->Init();
return legacy_window_instance;
}
void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) {
if (!::IsWindow(hwnd()))
return;
void LegacyRenderWidgetHostHWND::Destroy() {
if (::IsWindow(hwnd()))
::DestroyWindow(hwnd());
}
void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) {
::SetParent(hwnd(), parent);
// If the new parent is the desktop Window, then we disable the child window
// to ensure that it does not receive any input events. It should not because
......@@ -71,49 +68,49 @@ void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) {
}
HWND LegacyRenderWidgetHostHWND::GetParent() {
if (!::IsWindow(hwnd()))
return NULL;
return ::GetParent(hwnd());
}
void LegacyRenderWidgetHostHWND::Show() {
if (::IsWindow(hwnd()))
::ShowWindow(hwnd(), SW_SHOW);
::ShowWindow(hwnd(), SW_SHOW);
}
void LegacyRenderWidgetHostHWND::Hide() {
if (::IsWindow(hwnd()))
::ShowWindow(hwnd(), SW_HIDE);
::ShowWindow(hwnd(), SW_HIDE);
}
void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) {
if (!::IsWindow(hwnd()))
return;
gfx::Rect bounds_in_pixel = gfx::win::DIPToScreenRect(bounds);
::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(),
bounds_in_pixel.width(), bounds_in_pixel.height(),
SWP_NOREDRAW);
}
LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(
HWND parent,
LegacyRenderWidgetHostHWNDDelegate* delegate)
void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) {
if (host_) {
host_->OnLegacyWindowDestroyed();
host_ = NULL;
}
delete this;
}
LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent)
: mouse_tracking_enabled_(false),
delegate_(delegate) {
DCHECK(delegate_);
host_(NULL) {
RECT rect = {0};
Base::Create(parent, rect, L"Chrome Legacy Window",
WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
WS_EX_TRANSPARENT);
}
LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() {
DCHECK(!::IsWindow(hwnd()));
}
bool LegacyRenderWidgetHostHWND::Init() {
if (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
ui::AreTouchEventsEnabled()) {
ui::AreTouchEventsEnabled())
RegisterTouchWindow(hwnd(), TWF_WANTPALM);
}
HRESULT hr = ::CreateStdAccessibleObject(
hwnd(), OBJID_WINDOW, IID_IAccessible,
......@@ -157,16 +154,24 @@ LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message,
return static_cast<LRESULT>(0L);
}
if (OBJID_CLIENT != obj_id)
if (OBJID_CLIENT != obj_id || !host_)
return static_cast<LRESULT>(0L);
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(
host_->GetRenderWidgetHost());
if (!rwhi)
return static_cast<LRESULT>(0L);
base::win::ScopedComPtr<IAccessible> native_accessible(
delegate_->GetNativeViewAccessible());
if (!native_accessible.get())
BrowserAccessibilityManagerWin* manager =
static_cast<BrowserAccessibilityManagerWin*>(
rwhi->GetRootBrowserAccessibilityManager());
if (!manager)
return static_cast<LRESULT>(0L);
base::win::ScopedComPtr<IAccessible> root(
manager->GetRoot()->ToBrowserAccessibilityWin());
return LresultFromObject(IID_IAccessible, w_param,
static_cast<IAccessible*>(native_accessible.Detach()));
static_cast<IAccessible*>(root.Detach()));
}
// We send keyboard/mouse/touch messages to the parent window via SendMessage.
......
......@@ -13,7 +13,6 @@
#include "base/basictypes.h"
#include "base/win/scoped_comptr.h"
#include "content/common/content_export.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
namespace ui {
......@@ -21,6 +20,8 @@ class WindowEventTarget;
}
namespace content {
class RenderWidgetHostViewAura;
// Reasons for the existence of this class outlined below:-
// 1. Some screen readers expect every tab / every unique web content container
// to be in its own HWND with class name Chrome_RenderWidgetHostHWND.
......@@ -38,11 +39,12 @@ namespace content {
// fail.
// We should look to get rid of this code when all of the above are fixed.
class LegacyRenderWidgetHostHWNDDelegate;
// This class implements a child HWND with the same size as the content area,
// and delegates its accessibility implementation to the
// gfx::NativeViewAccessible provided by the owner class.
// that delegates its accessibility implementation to the root of the
// BrowserAccessibilityManager tree. This HWND is hooked up as the parent of
// the root object in the BrowserAccessibilityManager tree, so when any
// accessibility client calls ::WindowFromAccessibleObject, they get this
// HWND instead of the DesktopWindowTreeHostWin.
class CONTENT_EXPORT LegacyRenderWidgetHostHWND
: public ATL::CWindowImpl<LegacyRenderWidgetHostHWND,
NON_EXPORTED_BASE(ATL::CWindow),
......@@ -54,14 +56,13 @@ class CONTENT_EXPORT LegacyRenderWidgetHostHWND
NON_EXPORTED_BASE(ATL::CWindow),
ATL::CWinTraits<WS_CHILD> > Base;
virtual ~LegacyRenderWidgetHostHWND();
// Creates and returns an instance of the LegacyRenderWidgetHostHWND class on
// successful creation of a child window parented to the parent window passed
// in.
static LegacyRenderWidgetHostHWND* Create(
HWND parent,
LegacyRenderWidgetHostHWNDDelegate* delegate);
static LegacyRenderWidgetHostHWND* Create(HWND parent);
// Destroys the HWND managed by this class.
void Destroy();
BEGIN_MSG_MAP_EX(LegacyRenderWidgetHostHWND)
MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
......@@ -83,8 +84,6 @@ class CONTENT_EXPORT LegacyRenderWidgetHostHWND
MESSAGE_HANDLER_EX(WM_SIZE, OnSize)
END_MSG_MAP()
// May be deleted at any time by Windows! Other classes should never store
// this value.
HWND hwnd() { return m_hWnd; }
// Called when the child window is to be reparented to a new window.
......@@ -101,9 +100,18 @@ class CONTENT_EXPORT LegacyRenderWidgetHostHWND
// Resizes the window to the bounds passed in.
void SetBounds(const gfx::Rect& bounds);
// The pointer to the containing RenderWidgetHostViewAura instance is passed
// here.
void set_host(RenderWidgetHostViewAura* host) {
host_ = host;
}
protected:
virtual void OnFinalMessage(HWND hwnd) override;
private:
LegacyRenderWidgetHostHWND(HWND parent,
LegacyRenderWidgetHostHWNDDelegate* delegate);
LegacyRenderWidgetHostHWND(HWND parent);
~LegacyRenderWidgetHostHWND();
bool Init();
......@@ -128,16 +136,17 @@ class CONTENT_EXPORT LegacyRenderWidgetHostHWND
LRESULT OnNCCalcSize(UINT message, WPARAM w_param, LPARAM l_param);
LRESULT OnSize(UINT message, WPARAM w_param, LPARAM l_param);
LegacyRenderWidgetHostHWNDDelegate* delegate_;
base::win::ScopedComPtr<IAccessible> window_accessible_;
// Set to true if we turned on mouse tracking.
bool mouse_tracking_enabled_;
RenderWidgetHostViewAura* host_;
DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND);
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_DELEGATE_H_
#define CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_DELEGATE_H_
#include "content/common/content_export.h"
#include "ui/gfx/native_widget_types.h"
namespace content {
// A delegate interface for LegacyRenderWidgetHostHWND to query the
// native view accessible from the owner class.
class CONTENT_EXPORT LegacyRenderWidgetHostHWNDDelegate {
public:
// Get the native view accessible for the web contents.
// Once initialized, this should always return a valid object, but the
// object may change as the user navigates.
virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0;
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_DELEGATE_H_
......@@ -448,6 +448,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host,
cursor_visibility_state_in_renderer_(UNKNOWN),
#if defined(OS_WIN)
legacy_render_widget_host_HWND_(NULL),
legacy_window_destroyed_(false),
#endif
has_snapped_to_boundary_(false),
touch_editing_client_(NULL),
......@@ -601,6 +602,16 @@ void RenderWidgetHostViewAura::WasShown() {
delegated_frame_host_->WasShown(browser_latency_info);
#if defined(OS_WIN)
if (legacy_render_widget_host_HWND_) {
// Reparent the legacy Chrome_RenderWidgetHostHWND window to the parent
// window before reparenting any plugins. This ensures that the plugin
// windows stay on top of the child Zorder in the parent and receive
// mouse events, etc.
legacy_render_widget_host_HWND_->UpdateParent(
GetNativeView()->GetHost()->GetAcceleratedWidget());
legacy_render_widget_host_HWND_->SetBounds(
window_->GetBoundsInRootWindow());
}
LPARAM lparam = reinterpret_cast<LPARAM>(this);
EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam);
#endif
......@@ -619,6 +630,10 @@ void RenderWidgetHostViewAura::WasHidden() {
HWND parent = host->GetAcceleratedWidget();
LPARAM lparam = reinterpret_cast<LPARAM>(this);
EnumChildWindows(parent, HideWindowsCallback, lparam);
// We reparent the legacy Chrome_RenderWidgetHostHWND window to the global
// hidden window on the same lines as Windowed plugin windows.
if (legacy_render_widget_host_HWND_)
legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow());
}
#endif
}
......@@ -782,11 +797,19 @@ bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const {
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() {
......@@ -1038,7 +1061,12 @@ void RenderWidgetHostViewAura::UpdateMouseLockRegion() {
::ClipCursor(&window_rect);
}
}
#endif // defined(OS_WIN)
void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() {
legacy_render_widget_host_HWND_ = NULL;
legacy_window_destroyed_ = true;
}
#endif
void RenderWidgetHostViewAura::OnSwapCompositorFrame(
uint32 output_surface_id,
......@@ -1070,11 +1098,6 @@ void RenderWidgetHostViewAura::DidStopFlinging() {
}
#if defined(OS_WIN)
void RenderWidgetHostViewAura::SetLegacyRenderWidgetHostHWND(
LegacyRenderWidgetHostHWND* legacy_hwnd) {
legacy_render_widget_host_HWND_ = legacy_hwnd;
}
void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
gfx::NativeViewAccessible accessible_parent) {
}
......@@ -1082,9 +1105,8 @@ void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
const {
if (legacy_render_widget_host_HWND_) {
HWND hwnd = legacy_render_widget_host_HWND_->hwnd();
if (::IsWindow(hwnd))
return reinterpret_cast<gfx::NativeViewId>(hwnd);
return reinterpret_cast<gfx::NativeViewId>(
legacy_render_widget_host_HWND_->hwnd());
}
return NULL;
}
......@@ -1227,11 +1249,8 @@ RenderWidgetHostViewAura::CreateBrowserAccessibilityManager(
gfx::AcceleratedWidget
RenderWidgetHostViewAura::AccessibilityGetAcceleratedWidget() {
#if defined(OS_WIN)
if (legacy_render_widget_host_HWND_) {
HWND hwnd = legacy_render_widget_host_HWND_->hwnd();
if (::IsWindow(hwnd))
return hwnd;
}
if (legacy_render_widget_host_HWND_)
return legacy_render_widget_host_HWND_->hwnd();
#endif
return gfx::kNullAcceleratedWidget;
}
......@@ -1763,7 +1782,20 @@ void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) {
}
LPARAM lparam = reinterpret_cast<LPARAM>(this);
EnumChildWindows(parent, WindowDestroyingCallback, lparam);
legacy_render_widget_host_HWND_ = NULL;
// The LegacyRenderWidgetHostHWND instance is destroyed when its window is
// destroyed. Normally we control when that happens via the Destroy call
// in the dtor. However there may be cases where the window is destroyed
// by Windows, i.e. the parent window is destroyed before the
// RenderWidgetHostViewAura instance goes away etc. To avoid that we
// destroy the LegacyRenderWidgetHostHWND instance here.
if (legacy_render_widget_host_HWND_) {
legacy_render_widget_host_HWND_->set_host(NULL);
legacy_render_widget_host_HWND_->Destroy();
// The Destroy call above will delete the LegacyRenderWidgetHostHWND
// instance.
legacy_render_widget_host_HWND_ = NULL;
}
#endif
// Make sure that the input method no longer references to this object before
......@@ -2264,6 +2296,13 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
// Aura root window and we don't have a way to get an input method object
// associated with the window, but just in case.
DetachFromInputMethod();
#if defined(OS_WIN)
// The LegacyRenderWidgetHostHWND window should have been destroyed in
// RenderWidgetHostViewAura::OnWindowDestroying and the pointer should
// be set to NULL.
DCHECK(!legacy_render_widget_host_HWND_);
#endif
}
void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
......@@ -2420,6 +2459,34 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
selection_focus_);
}
#if defined(OS_WIN)
// 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.
// Additonally the legacy dummy window is needed for accessibility and for
// scrolling to work in legacy drivers for trackpoints/trackpads, etc.
if (!legacy_window_destroyed_ && GetNativeViewId()) {
if (!legacy_render_widget_host_HWND_) {
legacy_render_widget_host_HWND_ = LegacyRenderWidgetHostHWND::Create(
reinterpret_cast<HWND>(GetNativeViewId()));
}
if (legacy_render_widget_host_HWND_) {
legacy_render_widget_host_HWND_->set_host(this);
legacy_render_widget_host_HWND_->SetBounds(
window_->GetBoundsInRootWindow());
// There are cases where the parent window is created, made visible and
// the associated RenderWidget is also visible before the
// LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown
// here.
if (!host_->is_hidden())
legacy_render_widget_host_HWND_->Show();
}
}
if (mouse_locked_)
UpdateMouseLockRegion();
#endif
......@@ -2465,6 +2532,14 @@ void RenderWidgetHostViewAura::AddedToRootWindow() {
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
delegated_frame_host_->AddedToWindow();
}
......@@ -2478,6 +2553,13 @@ void RenderWidgetHostViewAura::RemovingFromRootWindow() {
window_->GetHost()->RemoveObserver(this);
delegated_frame_host_->RemovingFromWindow();
#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());
#endif
}
void RenderWidgetHostViewAura::DetachFromInputMethod() {
......
......@@ -228,7 +228,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
void DidStopFlinging() override;
#if defined(OS_WIN)
void SetLegacyRenderWidgetHostHWND(LegacyRenderWidgetHostHWND* legacy_hwnd);
virtual void SetParentNativeViewAccessible(
gfx::NativeViewAccessible accessible_parent) override;
virtual gfx::NativeViewId GetParentForWindowlessPlugin() const override;
......@@ -328,6 +327,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
// Updates the cursor clip region. Used for mouse locking.
void UpdateMouseLockRegion();
// Notification that the LegacyRenderWidgetHostHWND was destroyed.
void OnLegacyWindowDestroyed();
#endif
void DisambiguationPopupRendered(const SkBitmap& result,
......@@ -596,7 +598,17 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
// for accessibility, as the container for windowless plugins like
// Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads,
// etc.
// The LegacyRenderWidgetHostHWND instance is created during the first call
// to RenderWidgetHostViewAura::InternalSetBounds. The instance is destroyed
// when the LegacyRenderWidgetHostHWND hwnd is destroyed.
content::LegacyRenderWidgetHostHWND* legacy_render_widget_host_HWND_;
// Set to true if the legacy_render_widget_host_HWND_ instance was destroyed
// by Windows. This could happen if the browser window was destroyed by
// DestroyWindow for e.g. This flag helps ensure that we don't try to create
// the LegacyRenderWidgetHostHWND instance again as that would be a futile
// exercise.
bool legacy_window_destroyed_;
#endif
bool has_snapped_to_boundary_;
......
......@@ -67,17 +67,10 @@
#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,
......@@ -647,10 +640,6 @@ 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
}
}
......@@ -670,9 +659,6 @@ class WebContentsViewAura::WindowObserver
root_children[i]->RemoveObserver(this);
}
}
if (view_->legacy_hwnd_)
view_->legacy_hwnd_->UpdateParent(ui::GetHiddenWindow());
#endif
}
}
......@@ -744,8 +730,7 @@ class WebContentsViewAura::WindowObserver
WebContentsViewAura::WebContentsViewAura(
WebContentsImpl* web_contents,
WebContentsViewDelegate* delegate)
: WebContentsObserver(web_contents),
web_contents_(web_contents),
: web_contents_(web_contents),
delegate_(delegate),
current_drag_op_(blink::WebDragOperationNone),
drag_dest_delegate_(NULL),
......@@ -1031,10 +1016,6 @@ void WebContentsViewAura::SizeContents(const gfx::Size& size) {
if (bounds.size() != size) {
bounds.set_size(size);
window_->SetBounds(bounds);
#if defined(OS_WIN)
if (legacy_hwnd_)
legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow());
#endif
} 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.
......@@ -1131,14 +1112,6 @@ void WebContentsViewAura::CreateView(
// platforms as well.
if (delegate_)
drag_dest_delegate_ = delegate_->GetDragDestDelegate();
#if defined(OS_WIN)
if (context && context->GetHost()) {
HWND parent_hwnd = context->GetHost()->GetAcceleratedWidget();
CHECK(parent_hwnd);
legacy_hwnd_.reset(LegacyRenderWidgetHostHWND::Create(parent_hwnd, this));
}
#endif
}
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
......@@ -1179,24 +1152,12 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
}
AttachTouchEditableToRenderView();
#if defined(OS_WIN)
if (legacy_hwnd_)
view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get());
#endif
return view;
}
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
RenderWidgetHostViewAura* view =
new RenderWidgetHostViewAura(render_widget_host, false);
#if defined(OS_WIN)
if (legacy_hwnd_)
view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get());
#endif
return view;
return new RenderWidgetHostViewAura(render_widget_host, false);
}
void WebContentsViewAura::SetPageTitle(const base::string16& title) {
......@@ -1472,17 +1433,6 @@ void WebContentsViewAura::OnBoundsChanged(const gfx::Rect& old_bounds,
window_->children()[i]->SetBounds(bounds);
}
}
#if defined(OS_WIN)
if (!legacy_hwnd_ && window_ && window_->GetHost()) {
HWND parent_hwnd = window_->GetHost()->GetAcceleratedWidget();
CHECK(parent_hwnd);
legacy_hwnd_.reset(LegacyRenderWidgetHostHWND::Create(parent_hwnd, this));
}
if (legacy_hwnd_)
legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow());
#endif
}
gfx::NativeCursor WebContentsViewAura::GetCursor(const gfx::Point& point) {
......@@ -1657,12 +1607,6 @@ int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) {
return ConvertFromWeb(current_drag_op_);
}
void WebContentsViewAura::RenderProcessGone(base::TerminationStatus status) {
#if defined(OS_WIN)
UpdateLegacyHwndVisibility();
#endif
}
void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window,
bool visible) {
// Ignore any visibility changes in the hierarchy below.
......@@ -1693,42 +1637,6 @@ void WebContentsViewAura::UpdateWebContentsVisibility(bool visible) {
if (web_contents_->should_normally_be_visible())
web_contents_->WasHidden();
}
#if defined(OS_WIN)
UpdateLegacyHwndVisibility();
#endif
}
#if defined(OS_WIN)
void WebContentsViewAura::UpdateLegacyHwndVisibility() {
if (!legacy_hwnd_)
return;
bool visible = (window_->IsVisible() &&
web_contents_->GetRenderWidgetHostView());
if (visible && GetNativeView() && GetNativeView()->GetHost()) {
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();
}
}
gfx::NativeViewAccessible
WebContentsViewAura::GetNativeViewAccessible() {
BrowserAccessibilityManager* manager =
web_contents_->GetRootBrowserAccessibilityManager();
if (!manager)
return nullptr;
return manager->GetRoot()->ToBrowserAccessibilityWin();
}
#endif
} // namespace content
......@@ -13,17 +13,11 @@
#include "content/browser/renderer_host/render_view_host_delegate_view.h"
#include "content/browser/web_contents/web_contents_view.h"
#include "content/common/content_export.h"
#include "content/public/browser/web_contents_observer.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/wm/public/drag_drop_delegate.h"
#if defined(OS_WIN)
#include "content/browser/renderer_host/legacy_render_widget_host_win.h"
#include "content/browser/renderer_host/legacy_render_widget_host_win_delegate.h"
#endif
namespace aura {
class Window;
}
......@@ -43,22 +37,14 @@ class WebContentsViewDelegate;
class WebContentsImpl;
class WebDragDestDelegate;
#if defined(OS_WIN)
class LegacyRenderWidgetHostHWND;
#endif
class WebContentsViewAura
: public WebContentsView,
#if defined(OS_WIN)
public LegacyRenderWidgetHostHWNDDelegate,
#endif
public RenderViewHostDelegateView,
public OverscrollControllerDelegate,
public ui::ImplicitAnimationObserver,
public aura::WindowDelegate,
public aura::client::DragDropDelegate,
public aura::WindowObserver,
public WebContentsObserver {
public aura::WindowObserver {
public:
WebContentsViewAura(WebContentsImpl* web_contents,
WebContentsViewDelegate* delegate);
......@@ -198,22 +184,12 @@ class WebContentsViewAura
void OnDragExited() override;
int OnPerformDrop(const ui::DropTargetEvent& event) override;
// Overridden from WebContentsObserver:
void RenderProcessGone(base::TerminationStatus status) override;
// Overridden from aura::WindowObserver:
void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
// Update the web contents visiblity.
void UpdateWebContentsVisibility(bool visible);
#if defined(OS_WIN)
// Overridden from LegacyRenderWidgetHostHWNDDelegate:
virtual gfx::NativeViewAccessible GetNativeViewAccessible() override;
void UpdateLegacyHwndVisibility();
#endif
scoped_ptr<aura::Window> window_;
// The window that shows the screenshot of the history page during an
......@@ -257,14 +233,6 @@ class WebContentsViewAura
scoped_ptr<TouchEditableImplAura> touch_editable_;
scoped_ptr<GestureNavSimple> gesture_nav_simple_;
#if defined(OS_WIN)
// The LegacyRenderWidgetHostHWND class provides a dummy HWND which is used
// for accessibility, as the container for windowless plugins like
// Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads,
// etc.
scoped_ptr<LegacyRenderWidgetHostHWND> legacy_hwnd_;
#endif
// On Windows we can run into problems if resources get released within the
// initialization phase while the content (and its dimensions) are not known.
bool is_or_was_visible_;
......
......@@ -15,10 +15,6 @@
#include "ui/views/test/webview_test_helper.h"
#include "ui/views/test/widget_test.h"
#if defined(OS_WIN)
#include "ui/gfx/win/dpi.h"
#endif
namespace {
class WebViewInteractiveUiTest : public views::test::WidgetTest {
......@@ -29,9 +25,6 @@ class WebViewInteractiveUiTest : public views::test::WidgetTest {
void SetUp() override {
gfx::GLSurface::InitializeOneOffForTests();
WidgetTest::SetUp();
#if defined(OS_WIN)
gfx::InitDeviceScaleFactor(1.0f);
#endif
}
protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment