2019-01-23 19:38:09 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2019-05-24 21:49:31 +03:00
|
|
|
#if defined(ACCESSIBILITY) && defined(XP_WIN)
|
|
|
|
# include "mozilla/a11y/ProxyAccessible.h"
|
|
|
|
# include "mozilla/a11y/ProxyWrappers.h"
|
|
|
|
#endif
|
2019-03-05 05:15:58 +03:00
|
|
|
#include "mozilla/dom/BrowserBridgeChild.h"
|
2019-03-14 21:50:47 +03:00
|
|
|
#include "mozilla/dom/BrowsingContext.h"
|
2019-03-14 19:20:51 +03:00
|
|
|
#include "nsFocusManager.h"
|
2019-03-05 05:15:58 +03:00
|
|
|
#include "nsFrameLoader.h"
|
2019-03-05 22:33:09 +03:00
|
|
|
#include "nsFrameLoaderOwner.h"
|
2019-03-05 05:15:58 +03:00
|
|
|
#include "nsQueryObject.h"
|
2019-04-09 00:22:58 +03:00
|
|
|
#include "nsIDocShellTreeOwner.h"
|
2019-03-05 22:33:09 +03:00
|
|
|
|
2019-01-23 19:38:09 +03:00
|
|
|
using namespace mozilla::ipc;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2019-03-14 21:50:47 +03:00
|
|
|
BrowserBridgeChild::BrowserBridgeChild(nsFrameLoader* aFrameLoader,
|
|
|
|
BrowsingContext* aBrowsingContext)
|
|
|
|
: mLayersId{0},
|
|
|
|
mIPCOpen(true),
|
|
|
|
mFrameLoader(aFrameLoader),
|
|
|
|
mBrowsingContext(aBrowsingContext) {}
|
2019-01-23 19:38:09 +03:00
|
|
|
|
2019-05-24 21:49:31 +03:00
|
|
|
BrowserBridgeChild::~BrowserBridgeChild() {
|
|
|
|
#if defined(ACCESSIBILITY) && defined(XP_WIN)
|
|
|
|
if (mEmbeddedDocAccessible) {
|
|
|
|
mEmbeddedDocAccessible->Shutdown();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2019-01-23 19:38:09 +03:00
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
void BrowserBridgeChild::NavigateByKey(bool aForward,
|
|
|
|
bool aForDocumentNavigation) {
|
2019-03-05 22:33:09 +03:00
|
|
|
Unused << SendNavigateByKey(aForward, aForDocumentNavigation);
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
void BrowserBridgeChild::Activate() { Unused << SendActivate(); }
|
2019-03-05 22:33:52 +03:00
|
|
|
|
2019-05-27 18:09:53 +03:00
|
|
|
void BrowserBridgeChild::Deactivate() { Unused << SendDeactivate(); }
|
2019-03-14 19:00:32 +03:00
|
|
|
|
2019-05-13 04:49:07 +03:00
|
|
|
void BrowserBridgeChild::SetIsUnderHiddenEmbedderElement(
|
|
|
|
bool aIsUnderHiddenEmbedderElement) {
|
|
|
|
Unused << SendSetIsUnderHiddenEmbedderElement(aIsUnderHiddenEmbedderElement);
|
|
|
|
}
|
|
|
|
|
2019-03-05 22:33:09 +03:00
|
|
|
/*static*/
|
2019-03-05 05:15:58 +03:00
|
|
|
BrowserBridgeChild* BrowserBridgeChild::GetFrom(nsFrameLoader* aFrameLoader) {
|
2019-03-05 22:33:09 +03:00
|
|
|
if (!aFrameLoader) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-03-05 05:15:58 +03:00
|
|
|
return aFrameLoader->GetBrowserBridgeChild();
|
2019-03-05 22:33:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/
|
2019-03-05 05:15:58 +03:00
|
|
|
BrowserBridgeChild* BrowserBridgeChild::GetFrom(nsIContent* aContent) {
|
2019-03-05 22:33:09 +03:00
|
|
|
RefPtr<nsFrameLoaderOwner> loaderOwner = do_QueryObject(aContent);
|
|
|
|
if (!loaderOwner) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
RefPtr<nsFrameLoader> frameLoader = loaderOwner->GetFrameLoader();
|
|
|
|
return GetFrom(frameLoader);
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeChild::RecvSetLayersId(
|
2019-01-23 20:04:26 +03:00
|
|
|
const mozilla::layers::LayersId& aLayersId) {
|
|
|
|
MOZ_ASSERT(!mLayersId.IsValid() && aLayersId.IsValid());
|
|
|
|
mLayersId = aLayersId;
|
2019-04-26 21:21:01 +03:00
|
|
|
|
|
|
|
// Invalidate the nsSubdocumentFrame now that we have a layers ID for the
|
|
|
|
// child browser
|
|
|
|
if (RefPtr<Element> owner = mFrameLoader->GetOwnerContent()) {
|
|
|
|
if (nsIFrame* frame = owner->GetPrimaryFrame()) {
|
|
|
|
frame->InvalidateFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-14 19:20:51 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserBridgeChild::RecvRequestFocus(
|
|
|
|
const bool& aCanRaise) {
|
2019-04-10 00:38:15 +03:00
|
|
|
// Adapted from BrowserParent
|
2019-03-14 19:20:51 +03:00
|
|
|
RefPtr<Element> owner = mFrameLoader->GetOwnerContent();
|
2019-05-21 17:10:04 +03:00
|
|
|
if (!owner) {
|
2019-03-14 19:20:51 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
2019-05-22 20:21:29 +03:00
|
|
|
nsContentUtils::RequestFrameFocus(*owner, aCanRaise);
|
2019-03-14 19:20:51 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-14 19:25:33 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserBridgeChild::RecvMoveFocus(
|
|
|
|
const bool& aForward, const bool& aForDocumentNavigation) {
|
2019-04-10 00:38:15 +03:00
|
|
|
// Adapted from BrowserParent
|
2019-03-14 19:25:33 +03:00
|
|
|
nsCOMPtr<nsIFocusManager> fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (!fm) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Element> owner = mFrameLoader->GetOwnerContent();
|
2019-05-22 20:21:29 +03:00
|
|
|
if (!owner) {
|
2019-03-14 19:25:33 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Element> dummy;
|
|
|
|
|
|
|
|
uint32_t type =
|
|
|
|
aForward
|
|
|
|
? (aForDocumentNavigation
|
|
|
|
? static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_FORWARDDOC)
|
|
|
|
: static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_FORWARD))
|
|
|
|
: (aForDocumentNavigation
|
|
|
|
? static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_BACKWARDDOC)
|
|
|
|
: static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_BACKWARD));
|
|
|
|
fm->MoveFocus(nullptr, owner, type, nsIFocusManager::FLAG_BYKEY,
|
|
|
|
getter_AddRefs(dummy));
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-24 21:49:31 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
BrowserBridgeChild::RecvSetEmbeddedDocAccessibleCOMProxy(
|
|
|
|
const a11y::IDispatchHolder& aCOMProxy) {
|
|
|
|
#if defined(ACCESSIBILITY) && defined(XP_WIN)
|
|
|
|
MOZ_ASSERT(!aCOMProxy.IsNull());
|
|
|
|
if (mEmbeddedDocAccessible) {
|
|
|
|
mEmbeddedDocAccessible->Shutdown();
|
|
|
|
}
|
|
|
|
RefPtr<IDispatch> comProxy(aCOMProxy.Get());
|
|
|
|
mEmbeddedDocAccessible =
|
|
|
|
new a11y::RemoteIframeDocProxyAccessibleWrap(comProxy);
|
|
|
|
#endif
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
void BrowserBridgeChild::ActorDestroy(ActorDestroyReason aWhy) {
|
2019-01-23 19:38:09 +03:00
|
|
|
mIPCOpen = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|