Bug 1152300 - When focus shifts from a native plugin window to content, content needs to forward the request for focus change to chrome. r=enn

This commit is contained in:
Jim Mathies 2015-07-09 09:48:57 -05:00
parent ae4dea3e65
commit a12ea823a0
4 changed files with 52 additions and 16 deletions

View File

@ -1629,14 +1629,24 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
nsIFrame* contentFrame = content->GetPrimaryFrame();
nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
if (aAdjustWidgets && objectFrame && !sTestMode) {
// note that the presshell's widget is being retrieved here, not the one
// for the object frame.
nsViewManager* vm = presShell->GetViewManager();
if (vm) {
nsCOMPtr<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
if (widget)
widget->SetFocus(false);
if (XRE_IsContentProcess()) {
// set focus to the top level window via the chrome process.
nsCOMPtr<nsITabChild> tabChild = do_GetInterface(docShell);
if (tabChild) {
static_cast<TabChild*>(tabChild.get())->SendDispatchFocusToTopLevelWindow();
}
} else {
// note that the presshell's widget is being retrieved here, not the one
// for the object frame.
nsViewManager* vm = presShell->GetViewManager();
if (vm) {
nsCOMPtr<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
if (widget) {
// set focus to the top level window but don't raise it.
widget->SetFocus(false);
}
}
}
}
}

View File

@ -140,6 +140,13 @@ parent:
*/
sync GetWidgetNativeData() returns (WindowsHandle value);
/**
* When content moves focus from a native plugin window that's a child
* of the native browser window we need to move native focus to the
* browser. Otherwise the plugin window will never relinquish focus.
*/
sync DispatchFocusToTopLevelWindow();
parent:
/**
* When child sends this message, parent should move focus to

View File

@ -2473,10 +2473,9 @@ TabParent::RecvGetMaxTouchPoints(uint32_t* aTouchPoints)
return true;
}
bool
TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue)
already_AddRefed<nsIWidget>
TabParent::GetTopLevelWidget()
{
*aValue = 0;
nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement);
if (content) {
nsIPresShell* shell = content->OwnerDoc()->GetShell();
@ -2484,12 +2483,31 @@ TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue)
nsViewManager* vm = shell->GetViewManager();
nsCOMPtr<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
if (widget) {
*aValue = reinterpret_cast<WindowsHandle>(
widget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW));
}
return widget.forget();
}
}
return nullptr;
}
bool
TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue)
{
*aValue = 0;
nsCOMPtr<nsIWidget> widget = GetTopLevelWidget();
if (widget) {
*aValue = reinterpret_cast<WindowsHandle>(
widget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW));
}
return true;
}
bool
TabParent::RecvDispatchFocusToTopLevelWindow()
{
nsCOMPtr<nsIWidget> widget = GetTopLevelWidget();
if (widget) {
widget->SetFocus(false);
}
return true;
}

View File

@ -116,7 +116,7 @@ public:
}
already_AddRefed<nsILoadContext> GetLoadContext();
already_AddRefed<nsIWidget> GetTopLevelWidget();
nsIXULBrowserWindow* GetXULBrowserWindow();
void Destroy();
@ -218,6 +218,7 @@ public:
virtual bool RecvGetDefaultScale(double* aValue) override;
virtual bool RecvGetMaxTouchPoints(uint32_t* aTouchPoints) override;
virtual bool RecvGetWidgetNativeData(WindowsHandle* aValue) override;
virtual bool RecvDispatchFocusToTopLevelWindow() override;
virtual bool RecvZoomToRect(const uint32_t& aPresShellId,
const ViewID& aViewId,
const CSSRect& aRect) override;