Bug 761927: Fix focus for <iframe mozbrowser remote>. r=jlebar,Enn

This commit is contained in:
Chris Jones 2012-06-22 18:27:30 -07:00
parent 8d82366ec1
commit 4670001039
4 changed files with 12 additions and 43 deletions

View File

@ -6250,6 +6250,12 @@ nsContentUtils::IsSubDocumentTabbable(nsIContent* aContent)
return false;
}
// If the subdocument lives in another process, the frame is
// tabbable.
if (nsEventStateManager::IsRemoteTarget(aContent)) {
return true;
}
// XXXbz should this use OwnerDoc() for GetSubDocumentFor?
// sXBL/XBL2 issue!
nsIDocument* subDoc = doc->GetSubDocumentFor(aContent);

View File

@ -1678,10 +1678,10 @@ nsEventStateManager::IsRemoteTarget(nsIContent* target) {
// <frame/iframe mozbrowser>
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(target);
if (browserFrame) {
bool isRemote = false;
browserFrame->GetReallyIsBrowser(&isRemote);
if (isRemote) {
return true;
bool isBrowser = false;
browserFrame->GetReallyIsBrowser(&isBrowser);
if (isBrowser) {
return !!TabParent::GetFrom(target);
}
}

View File

@ -1570,8 +1570,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
}
// if the object being blurred is a remote browser, deactivate remote content
TabParent* remote = GetRemoteForContent(content);
if (remote) {
if (TabParent* remote = TabParent::GetFrom(content)) {
remote->Deactivate();
#ifdef DEBUG_FOCUS
printf("*Remote browser deactivated\n");
@ -1782,8 +1781,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
objectFrameWidget->SetFocus(false);
// if the object being focused is a remote browser, activate remote content
TabParent* remote = GetRemoteForContent(aContent);
if (remote) {
if (TabParent* remote = TabParent::GetFrom(aContent)) {
remote->Activate();
#ifdef DEBUG_FOCUS
printf("*Remote browser activated\n");
@ -3013,29 +3011,6 @@ nsFocusManager::GetRootForFocus(nsPIDOMWindow* aWindow,
return rootElement;
}
TabParent*
nsFocusManager::GetRemoteForContent(nsIContent* aContent) {
if (!aContent ||
(aContent->Tag() != nsGkAtoms::browser &&
aContent->Tag() != nsGkAtoms::iframe) ||
!aContent->IsXUL() ||
!aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::Remote,
nsGkAtoms::_true, eIgnoreCase))
return nsnull;
nsCOMPtr<nsIFrameLoaderOwner> loaderOwner = do_QueryInterface(aContent);
if (!loaderOwner)
return nsnull;
nsRefPtr<nsFrameLoader> frameLoader = loaderOwner->GetFrameLoader();
if (!frameLoader)
return nsnull;
PBrowserParent* remoteBrowser = frameLoader->GetRemoteBrowser();
TabParent* remote = static_cast<TabParent*>(remoteBrowser);
return remote;
}
void
nsFocusManager::GetLastDocShell(nsIDocShellTreeItem* aItem,
nsIDocShellTreeItem** aResult)

View File

@ -21,12 +21,6 @@
class nsIDocShellTreeItem;
class nsPIDOMWindow;
namespace mozilla {
namespace dom {
class TabParent;
}
}
struct nsDelayedBlurOrFocusEvent;
/**
@ -414,12 +408,6 @@ protected:
bool aIsForDocNavigation,
bool aCheckVisibility);
/**
* Get the TabParent associated with aContent if it is a remote browser,
* or null in all other cases.
*/
mozilla::dom::TabParent* GetRemoteForContent(nsIContent* aContent);
/**
* Get the last docshell child of aItem and return it in aResult.
*/