Bug 1176239, do tab navigation in the child when moving between the parent and child process, r=smaug

This commit is contained in:
Neil Deakin 2015-07-23 10:04:15 -04:00
parent a5596f5a1e
commit ec562250fa
6 changed files with 38 additions and 24 deletions

View File

@ -2983,20 +2983,20 @@ nsFocusManager::GetNextTabbableContent(nsIPresShell* aPresShell,
return NS_OK;
}
// If this is a remote child browser, call NavigateDocument to have
// the child process continue the navigation. Return a special error
// code to have the caller return early. If the child ends up not
// being focusable in some way, the child process will call back
// into document navigation again by calling MoveFocus.
TabParent* remote = TabParent::GetFrom(currentContent);
if (remote) {
remote->NavigateByKey(aForward, aForDocumentNavigation);
return NS_SUCCESS_DOM_NO_OPERATION;
}
// Next, for document navigation, check if this a non-remote child document.
bool checkSubDocument = true;
if (aForDocumentNavigation) {
// If this is a remote child browser, call NavigateDocument to have
// the child process continue the navigation. Return a special error
// code to have the caller return early. If the child ends up not
// being focusable in some way, the child process will call back
// into document navigation again by calling MoveFocus.
TabParent* remote = TabParent::GetFrom(currentContent);
if (remote) {
remote->NavigateDocument(aForward);
return NS_SUCCESS_DOM_NO_OPERATION;
}
// Next, check if this a non-remote child document.
nsIContent* docRoot = GetRootForChildDocument(currentContent);
if (docRoot) {
// If GetRootForChildDocument returned something then call

View File

@ -5,7 +5,7 @@
#include "domstubs.idl"
[scriptable, uuid(A10D887D-7FC2-48A2-ABC6-A2027423860C)]
[scriptable, uuid(CE6F563B-BD77-4EF2-9D7C-A94C587353E4)]
interface nsITabParent : nsISupports
{
void injectTouchEvent(in AString aType,
@ -28,10 +28,13 @@ interface nsITabParent : nsISupports
readonly attribute uint64_t tabId;
/**
* If aForward is true, navigate to the first focusable document.
* If aForward is false, navigate to the last focusable document.
* Navigate by key. If aForDocumentNavigation is true, navigate by document.
* If aForDocumentNavigation is false, navigate by element.
*
* If aForward is true, navigate to the first focusable element or document.
* If aForward is false, navigate to the last focusable element or document.
*/
void navigateDocument(in bool aForward);
void navigateByKey(in bool aForward, in bool aForDocumentNavigation);
readonly attribute boolean hasContentOpener;
};

View File

@ -698,9 +698,9 @@ child:
SetIsDocShellActive(bool aIsActive);
/**
* Navigate by document.
* Navigate by key (Tab/Shift+Tab/F6/Shift+f6).
*/
NavigateDocument(bool aForward);
NavigateByKey(bool aForward, bool aForDocumentNavigation);
/**
* The parent (chrome thread) requests that the child inform it when

View File

@ -2512,7 +2512,7 @@ TabChild::RecvSetIsDocShellActive(const bool& aIsActive)
}
bool
TabChild::RecvNavigateDocument(const bool& aForward)
TabChild::RecvNavigateByKey(const bool& aForward, const bool& aForDocumentNavigation)
{
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
@ -2520,9 +2520,20 @@ TabChild::RecvNavigateDocument(const bool& aForward)
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(WebNavigation());
// Move to the first or last document.
fm->MoveFocus(window, nullptr, aForward ? nsIFocusManager::MOVEFOCUS_FIRSTDOC :
nsIFocusManager::MOVEFOCUS_LASTDOC,
uint32_t type = aForward ?
(aForDocumentNavigation ? static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_FIRSTDOC) :
static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_ROOT)) :
(aForDocumentNavigation ? static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_LASTDOC) :
static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_LAST));
fm->MoveFocus(window, nullptr, type,
nsIFocusManager::FLAG_BYKEY, getter_AddRefs(result));
// No valid root element was found, so move to the first focusable element.
if (!result && aForward && !aForDocumentNavigation) {
fm->MoveFocus(window, nullptr, nsIFocusManager::MOVEFOCUS_FIRST,
nsIFocusManager::FLAG_BYKEY, getter_AddRefs(result));
}
SendRequestFocus(false);
}

View File

@ -502,7 +502,7 @@ protected:
virtual bool RecvDestroy() override;
virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) override;
virtual bool RecvSetIsDocShellActive(const bool& aIsActive) override;
virtual bool RecvNavigateDocument(const bool& aForward) override;
virtual bool RecvNavigateByKey(const bool& aForward, const bool& aForDocumentNavigation) override;
virtual bool RecvRequestNotifyAfterRemotePaint() override;

View File

@ -2950,9 +2950,9 @@ TabParent::SetHasContentOpener(bool aHasContentOpener)
}
NS_IMETHODIMP
TabParent::NavigateDocument(bool aForward)
TabParent::NavigateByKey(bool aForward, bool aForDocumentNavigation)
{
unused << SendNavigateDocument(aForward);
unused << SendNavigateByKey(aForward, aForDocumentNavigation);
return NS_OK;
}