2015-05-03 22:32:37 +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: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2009-09-10 02:00:14 +04:00
|
|
|
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "base/basictypes.h"
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2012-08-02 10:02:29 +04:00
|
|
|
#include "TabParent.h"
|
|
|
|
|
2015-05-21 20:04:58 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "mozilla/a11y/DocAccessibleParent.h"
|
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#endif
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "mozilla/BrowserElementParent.h"
|
2015-10-23 00:10:14 +03:00
|
|
|
#include "mozilla/dom/ContentBridgeParent.h"
|
2010-08-21 03:24:41 +04:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
2015-04-08 21:48:11 +03:00
|
|
|
#include "mozilla/dom/DataTransfer.h"
|
2015-10-23 00:10:14 +03:00
|
|
|
#include "mozilla/dom/Event.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/dom/indexedDB/ActorsParent.h"
|
2017-04-24 13:16:50 +03:00
|
|
|
#include "mozilla/dom/IPCBlobUtils.h"
|
2017-05-25 20:50:32 +03:00
|
|
|
#include "mozilla/dom/PaymentRequestParent.h"
|
2014-04-01 08:09:23 +04:00
|
|
|
#include "mozilla/EventStateManager.h"
|
2015-04-08 21:48:11 +03:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2016-05-09 01:33:00 +03:00
|
|
|
#include "mozilla/gfx/DataSurfaceHelpers.h"
|
2016-05-23 10:28:03 +03:00
|
|
|
#include "mozilla/gfx/GPUProcessManager.h"
|
2012-12-23 17:48:07 +04:00
|
|
|
#include "mozilla/Hal.h"
|
2015-06-27 03:23:31 +03:00
|
|
|
#include "mozilla/IMEStateManager.h"
|
2009-10-29 20:58:31 +03:00
|
|
|
#include "mozilla/ipc/DocumentRendererParent.h"
|
2015-01-27 00:32:18 +03:00
|
|
|
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
2015-09-29 00:00:25 +03:00
|
|
|
#include "mozilla/layers/AsyncDragMetrics.h"
|
2014-12-16 10:31:12 +03:00
|
|
|
#include "mozilla/layers/InputAPZContext.h"
|
2010-08-21 03:24:41 +04:00
|
|
|
#include "mozilla/layout/RenderFrameParent.h"
|
2017-02-09 19:53:50 +03:00
|
|
|
#include "mozilla/plugins/PPluginWidgetParent.h"
|
2015-04-22 17:58:33 +03:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2014-06-11 09:44:36 +04:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2016-11-30 06:14:28 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
2013-09-25 15:21:19 +04:00
|
|
|
#include "mozilla/TextEvents.h"
|
2013-09-25 15:21:16 +04:00
|
|
|
#include "mozilla/TouchEvents.h"
|
2015-11-03 21:29:19 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2009-11-05 21:14:22 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2015-04-08 21:48:11 +03:00
|
|
|
#include "nsContentAreaDragDrop.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsFocusManager.h"
|
2010-01-01 04:35:55 +03:00
|
|
|
#include "nsFrameLoader.h"
|
2017-07-14 01:33:25 +03:00
|
|
|
#include "nsFrameManager.h"
|
2015-01-13 03:41:53 +03:00
|
|
|
#include "nsIBaseWindow.h"
|
2015-11-11 01:35:12 +03:00
|
|
|
#include "nsIBrowser.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsIContent.h"
|
2013-03-28 09:12:03 +04:00
|
|
|
#include "nsIDocShell.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIDocShellTreeOwner.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDOMEvent.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
2014-04-05 01:50:42 +04:00
|
|
|
#include "nsIDOMWindowUtils.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2014-07-10 10:56:36 +04:00
|
|
|
#include "nsILoadInfo.h"
|
2010-06-25 02:20:42 +04:00
|
|
|
#include "nsIPromptFactory.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsIURI.h"
|
2016-08-02 15:54:00 +03:00
|
|
|
#include "nsIWindowWatcher.h"
|
2013-07-25 23:45:31 +04:00
|
|
|
#include "nsIWebBrowserChrome.h"
|
|
|
|
#include "nsIXULBrowserWindow.h"
|
|
|
|
#include "nsIXULWindow.h"
|
2014-12-09 18:48:27 +03:00
|
|
|
#include "nsIRemoteBrowser.h"
|
2013-01-05 07:12:24 +04:00
|
|
|
#include "nsViewManager.h"
|
2015-10-07 18:17:42 +03:00
|
|
|
#include "nsVariant.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsIWidget.h"
|
2017-03-22 13:39:31 +03:00
|
|
|
#include "nsNetUtil.h"
|
2015-08-17 05:25:59 +03:00
|
|
|
#ifndef XP_WIN
|
|
|
|
#include "nsJARProtocolHandler.h"
|
|
|
|
#endif
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2012-04-25 20:35:58 +04:00
|
|
|
#include "nsPrintfCString.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2013-11-06 21:21:15 +04:00
|
|
|
#include "PermissionMessageUtils.h"
|
2015-09-10 23:50:58 +03:00
|
|
|
#include "StructuredCloneData.h"
|
2014-02-24 00:19:43 +04:00
|
|
|
#include "ColorPickerParent.h"
|
2014-02-18 04:30:06 +04:00
|
|
|
#include "FilePickerParent.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "TabChild.h"
|
2014-01-11 05:10:57 +04:00
|
|
|
#include "LoadContext.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsNetCID.h"
|
2014-06-11 09:44:36 +04:00
|
|
|
#include "nsIAuthInformation.h"
|
|
|
|
#include "nsIAuthPromptCallback.h"
|
|
|
|
#include "nsAuthInformationHolder.h"
|
|
|
|
#include "nsICancelable.h"
|
2014-06-03 17:39:44 +04:00
|
|
|
#include "gfxPrefs.h"
|
2014-11-04 22:51:06 +03:00
|
|
|
#include "nsILoginManagerPrompter.h"
|
2015-03-31 23:39:02 +03:00
|
|
|
#include "nsPIWindowRoot.h"
|
2015-07-07 05:17:00 +03:00
|
|
|
#include "nsIAuthPrompt2.h"
|
2015-05-20 04:28:57 +03:00
|
|
|
#include "gfxDrawable.h"
|
|
|
|
#include "ImageOps.h"
|
2015-06-08 08:39:28 +03:00
|
|
|
#include "UnitTransforms.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2015-08-06 00:25:39 +03:00
|
|
|
#include "mozilla/WebBrowserPersistDocumentParent.h"
|
2016-10-14 10:31:02 +03:00
|
|
|
#include "nsIGroupedSHistory.h"
|
|
|
|
#include "PartialSHistory.h"
|
2017-06-07 10:59:00 +03:00
|
|
|
#include "ProcessPriorityManager.h"
|
2017-03-30 00:43:21 +03:00
|
|
|
#include "nsString.h"
|
2010-07-19 22:33:33 +04:00
|
|
|
|
2017-02-09 19:53:50 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include "mozilla/plugins/PluginWidgetParent.h"
|
|
|
|
#endif
|
|
|
|
|
2016-10-27 22:16:24 +03:00
|
|
|
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
|
|
|
#include "mozilla/a11y/AccessibleWrap.h"
|
2016-09-29 23:00:50 +03:00
|
|
|
#include "mozilla/a11y/nsWinUtils.h"
|
2016-10-27 22:16:24 +03:00
|
|
|
#endif
|
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
using namespace mozilla::ipc;
|
2012-07-20 10:48:27 +04:00
|
|
|
using namespace mozilla::layers;
|
2010-08-21 03:24:41 +04:00
|
|
|
using namespace mozilla::layout;
|
2012-08-09 06:58:06 +04:00
|
|
|
using namespace mozilla::services;
|
2011-11-27 15:51:52 +04:00
|
|
|
using namespace mozilla::widget;
|
2013-07-11 02:05:39 +04:00
|
|
|
using namespace mozilla::jsipc;
|
2016-05-23 10:28:03 +03:00
|
|
|
using namespace mozilla::gfx;
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2016-08-02 15:54:00 +03:00
|
|
|
using mozilla::Unused;
|
|
|
|
|
2010-03-26 21:39:39 +03:00
|
|
|
// The flags passed by the webProgress notifications are 16 bits shifted
|
|
|
|
// from the ones registered by webProgressListeners.
|
|
|
|
#define NOTIFY_FLAG_SHIFT 16
|
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
namespace mozilla {
|
2009-08-12 20:18:08 +04:00
|
|
|
namespace dom {
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2014-12-19 02:23:39 +03:00
|
|
|
TabParent::LayerToTabParentTable* TabParent::sLayerToTabParentTable = nullptr;
|
2010-09-24 07:28:15 +04:00
|
|
|
|
2014-06-06 06:49:43 +04:00
|
|
|
NS_IMPL_ISUPPORTS(TabParent,
|
|
|
|
nsITabParent,
|
|
|
|
nsIAuthPromptProvider,
|
|
|
|
nsISecureBrowserUI,
|
2015-08-06 00:25:39 +03:00
|
|
|
nsISupportsWeakReference,
|
|
|
|
nsIWebBrowserPersistable)
|
2010-03-26 21:39:39 +03:00
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
TabParent::TabParent(nsIContentParent* aManager,
|
|
|
|
const TabId& aTabId,
|
|
|
|
const TabContext& aContext,
|
|
|
|
uint32_t aChromeFlags)
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
: TabContext(aContext)
|
2013-10-28 18:04:12 +04:00
|
|
|
, mFrameElement(nullptr)
|
2017-07-05 18:47:40 +03:00
|
|
|
, mContentCache(*this)
|
2013-01-29 11:49:38 +04:00
|
|
|
, mRect(0, 0, 0, 0)
|
2012-09-29 06:16:36 +04:00
|
|
|
, mDimensions(0, 0)
|
2013-01-29 11:49:38 +04:00
|
|
|
, mOrientation(0)
|
2010-12-09 21:57:05 +03:00
|
|
|
, mDPI(0)
|
2016-09-27 09:37:07 +03:00
|
|
|
, mRounding(0)
|
2013-05-02 03:06:19 +04:00
|
|
|
, mDefaultScale(0)
|
2013-01-29 11:49:38 +04:00
|
|
|
, mUpdatedDimensions(false)
|
2016-02-23 19:10:00 +03:00
|
|
|
, mSizeMode(nsSizeMode_Normal)
|
2013-07-10 21:07:51 +04:00
|
|
|
, mManager(aManager)
|
2015-09-04 16:42:01 +03:00
|
|
|
, mDocShellIsActive(false)
|
2013-01-10 17:22:14 +04:00
|
|
|
, mMarkedDestroying(false)
|
2012-11-10 10:09:24 +04:00
|
|
|
, mIsDestroyed(false)
|
2014-01-11 05:10:57 +04:00
|
|
|
, mChromeFlags(aChromeFlags)
|
2016-10-19 22:01:39 +03:00
|
|
|
, mDragValid(false)
|
2014-11-16 21:23:22 +03:00
|
|
|
, mInitedByParent(false)
|
2014-10-29 21:11:00 +03:00
|
|
|
, mTabId(aTabId)
|
2015-01-23 07:00:18 +03:00
|
|
|
, mCreatingWindow(false)
|
2015-04-15 02:29:10 +03:00
|
|
|
, mCursor(nsCursor(-1))
|
|
|
|
, mTabSetsCursor(false)
|
2015-05-13 23:44:39 +03:00
|
|
|
, mHasContentOpener(false)
|
2016-02-26 18:52:06 +03:00
|
|
|
#ifdef DEBUG
|
2015-08-20 00:08:41 +03:00
|
|
|
, mActiveSupressDisplayportCount(0)
|
2016-02-26 18:52:06 +03:00
|
|
|
#endif
|
2016-07-23 02:36:45 +03:00
|
|
|
, mLayerTreeEpoch(0)
|
|
|
|
, mPreserveLayers(false)
|
2017-03-04 22:12:38 +03:00
|
|
|
, mHasPresented(false)
|
2017-04-14 00:54:07 +03:00
|
|
|
, mHasBeforeUnload(false)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
2014-06-11 09:44:03 +04:00
|
|
|
MOZ_ASSERT(aManager);
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
TabParent::~TabParent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-19 02:23:39 +03:00
|
|
|
TabParent*
|
|
|
|
TabParent::GetTabParentFromLayersId(uint64_t aLayersId)
|
|
|
|
{
|
|
|
|
if (!sLayerToTabParentTable) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return sLayerToTabParentTable->Get(aLayersId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabParent::AddTabParentToTable(uint64_t aLayersId, TabParent* aTabParent)
|
|
|
|
{
|
|
|
|
if (!sLayerToTabParentTable) {
|
|
|
|
sLayerToTabParentTable = new LayerToTabParentTable();
|
|
|
|
}
|
|
|
|
sLayerToTabParentTable->Put(aLayersId, aTabParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabParent::RemoveTabParentFromTable(uint64_t aLayersId)
|
|
|
|
{
|
|
|
|
if (!sLayerToTabParentTable) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sLayerToTabParentTable->Remove(aLayersId);
|
|
|
|
if (sLayerToTabParentTable->Count() == 0) {
|
|
|
|
delete sLayerToTabParentTable;
|
|
|
|
sLayerToTabParentTable = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-27 08:35:26 +03:00
|
|
|
void
|
|
|
|
TabParent::CacheFrameLoader(nsFrameLoader* aFrameLoader)
|
|
|
|
{
|
|
|
|
mFrameLoader = aFrameLoader;
|
|
|
|
}
|
|
|
|
|
2016-04-27 22:40:36 +03:00
|
|
|
/**
|
|
|
|
* Will return nullptr if there is no outer window available for the
|
|
|
|
* document hosting the owner element of this TabParent. Also will return
|
|
|
|
* nullptr if that outer window is in the process of closing.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsPIDOMWindowOuter>
|
|
|
|
TabParent::GetParentWindowOuter()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> frame = do_QueryInterface(GetOwnerElement());
|
|
|
|
if (!frame) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> parent = frame->OwnerDoc()->GetWindow();
|
|
|
|
if (!parent || parent->Closed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent.forget();
|
|
|
|
}
|
|
|
|
|
2010-12-09 21:57:05 +03:00
|
|
|
void
|
2013-07-24 03:39:17 +04:00
|
|
|
TabParent::SetOwnerElement(Element* aElement)
|
2010-12-09 21:57:05 +03:00
|
|
|
{
|
2015-03-31 23:39:02 +03:00
|
|
|
// If we held previous content then unregister for its events.
|
|
|
|
RemoveWindowListeners();
|
|
|
|
|
2015-06-08 08:39:39 +03:00
|
|
|
// If we change top-level documents then we need to change our
|
|
|
|
// registration with them.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPIWindowRoot> curTopLevelWin, newTopLevelWin;
|
2015-06-08 08:39:39 +03:00
|
|
|
if (mFrameElement) {
|
|
|
|
curTopLevelWin = nsContentUtils::GetWindowRoot(mFrameElement->OwnerDoc());
|
|
|
|
}
|
|
|
|
if (aElement) {
|
|
|
|
newTopLevelWin = nsContentUtils::GetWindowRoot(aElement->OwnerDoc());
|
|
|
|
}
|
|
|
|
bool isSameTopLevelWin = curTopLevelWin == newTopLevelWin;
|
|
|
|
if (curTopLevelWin && !isSameTopLevelWin) {
|
|
|
|
curTopLevelWin->RemoveBrowser(this);
|
|
|
|
}
|
|
|
|
|
2015-03-31 23:39:02 +03:00
|
|
|
// Update to the new content, and register to listen for events from it.
|
2010-12-09 21:57:05 +03:00
|
|
|
mFrameElement = aElement;
|
2015-03-31 23:39:02 +03:00
|
|
|
|
2015-06-08 08:39:39 +03:00
|
|
|
if (newTopLevelWin && !isSameTopLevelWin) {
|
|
|
|
newTopLevelWin->AddBrowser(this);
|
|
|
|
}
|
|
|
|
|
2016-03-23 21:39:28 +03:00
|
|
|
if (mFrameElement) {
|
|
|
|
bool useGlobalHistory =
|
|
|
|
!mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::disableglobalhistory);
|
|
|
|
Unused << SendSetUseGlobalHistory(useGlobalHistory);
|
|
|
|
}
|
|
|
|
|
2016-09-15 22:37:04 +03:00
|
|
|
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
|
|
|
if (!mIsDestroyed) {
|
|
|
|
uintptr_t newWindowHandle = 0;
|
|
|
|
if (nsCOMPtr<nsIWidget> widget = GetWidget()) {
|
|
|
|
newWindowHandle =
|
|
|
|
reinterpret_cast<uintptr_t>(widget->GetNativeData(NS_NATIVE_WINDOW));
|
|
|
|
}
|
|
|
|
Unused << SendUpdateNativeWindowHandle(newWindowHandle);
|
2016-09-29 23:00:50 +03:00
|
|
|
a11y::DocAccessibleParent* doc = GetTopLevelDocAccessible();
|
|
|
|
if (doc) {
|
|
|
|
HWND hWnd = reinterpret_cast<HWND>(doc->GetEmulatedWindowHandle());
|
|
|
|
if (hWnd) {
|
|
|
|
HWND parentHwnd = reinterpret_cast<HWND>(newWindowHandle);
|
|
|
|
if (parentHwnd != ::GetParent(hWnd)) {
|
|
|
|
::SetParent(hWnd, parentHwnd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-15 22:37:04 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-21 17:33:56 +03:00
|
|
|
AddWindowListeners();
|
2013-05-02 03:06:19 +04:00
|
|
|
TryCacheDPIAndScale();
|
2017-06-13 20:37:31 +03:00
|
|
|
|
|
|
|
// Try to send down WidgetNativeData, now that this TabParent is associated
|
|
|
|
// with a widget.
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetTopLevelWidget();
|
|
|
|
if (widget) {
|
|
|
|
WindowsHandle widgetNativeData = reinterpret_cast<WindowsHandle>(
|
|
|
|
widget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW));
|
|
|
|
if (widgetNativeData) {
|
|
|
|
Unused << SendSetWidgetNativeData(widgetNativeData);
|
|
|
|
}
|
|
|
|
}
|
2010-12-09 21:57:05 +03:00
|
|
|
}
|
|
|
|
|
2015-04-21 17:33:56 +03:00
|
|
|
void
|
|
|
|
TabParent::AddWindowListeners()
|
|
|
|
{
|
|
|
|
if (mFrameElement && mFrameElement->OwnerDoc()) {
|
2016-01-30 20:05:36 +03:00
|
|
|
if (nsCOMPtr<nsPIDOMWindowOuter> window = mFrameElement->OwnerDoc()->GetWindow()) {
|
2015-04-21 17:33:56 +03:00
|
|
|
nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
|
|
|
|
if (eventTarget) {
|
|
|
|
eventTarget->AddEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"),
|
|
|
|
this, false, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-31 23:39:02 +03:00
|
|
|
void
|
|
|
|
TabParent::RemoveWindowListeners()
|
|
|
|
{
|
|
|
|
if (mFrameElement && mFrameElement->OwnerDoc()->GetWindow()) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = mFrameElement->OwnerDoc()->GetWindow();
|
2015-03-31 23:39:02 +03:00
|
|
|
nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
|
|
|
|
if (eventTarget) {
|
|
|
|
eventTarget->RemoveEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"),
|
|
|
|
this, false);
|
|
|
|
}
|
|
|
|
}
|
2015-04-21 17:33:56 +03:00
|
|
|
}
|
|
|
|
|
2011-01-06 07:54:47 +03:00
|
|
|
void
|
2015-08-28 10:18:00 +03:00
|
|
|
TabParent::DestroyInternal()
|
2011-01-06 07:54:47 +03:00
|
|
|
{
|
2015-08-18 20:27:07 +03:00
|
|
|
IMEStateManager::OnTabParentDestroying(this);
|
|
|
|
|
2015-04-21 17:33:56 +03:00
|
|
|
RemoveWindowListeners();
|
|
|
|
|
2017-01-13 19:45:07 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
2017-01-10 02:55:32 +03:00
|
|
|
if (a11y::DocAccessibleParent* tabDoc = GetTopLevelDocAccessible()) {
|
|
|
|
tabDoc->Destroy();
|
|
|
|
}
|
2017-01-13 19:45:07 +03:00
|
|
|
#endif
|
2017-01-10 02:55:32 +03:00
|
|
|
|
2011-01-06 07:54:47 +03:00
|
|
|
// If this fails, it's most likely due to a content-process crash,
|
|
|
|
// and auto-cleanup will kick in. Otherwise, the child side will
|
|
|
|
// destroy itself and send back __delete__().
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendDestroy();
|
2011-01-06 07:54:47 +03:00
|
|
|
|
2012-07-20 10:48:27 +04:00
|
|
|
if (RenderFrameParent* frame = GetRenderFrame()) {
|
2014-12-19 02:23:39 +03:00
|
|
|
RemoveTabParentFromTable(frame->GetLayersId());
|
2012-07-20 10:48:27 +04:00
|
|
|
frame->Destroy();
|
2011-01-06 07:54:47 +03:00
|
|
|
}
|
2015-01-29 22:41:56 +03:00
|
|
|
|
2017-02-09 19:53:50 +03:00
|
|
|
#ifdef XP_WIN
|
2015-01-29 22:41:56 +03:00
|
|
|
// Let all PluginWidgets know we are tearing down. Prevents
|
|
|
|
// these objects from sending async events after the child side
|
|
|
|
// is shut down.
|
2015-10-07 21:30:33 +03:00
|
|
|
const ManagedContainer<PPluginWidgetParent>& kids =
|
|
|
|
ManagedPPluginWidgetParent();
|
|
|
|
for (auto iter = kids.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
static_cast<mozilla::plugins::PluginWidgetParent*>(
|
|
|
|
iter.Get()->GetKey())->ParentDestroy();
|
2015-01-29 22:41:56 +03:00
|
|
|
}
|
2017-02-09 19:53:50 +03:00
|
|
|
#endif
|
2015-08-28 10:18:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabParent::Destroy()
|
|
|
|
{
|
2016-04-05 00:08:17 +03:00
|
|
|
// Aggressively release the window to avoid leaking the world in shutdown
|
|
|
|
// corner cases.
|
|
|
|
mBrowserDOMWindow = nullptr;
|
|
|
|
|
2015-08-28 10:18:00 +03:00
|
|
|
if (mIsDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyInternal();
|
|
|
|
|
|
|
|
mIsDestroyed = true;
|
|
|
|
|
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
ContentParent::NotifyTabDestroying(this->GetTabId(), Manager()->AsContentParent()->ChildID());
|
|
|
|
} else {
|
|
|
|
ContentParent::NotifyTabDestroying(this->GetTabId(), Manager()->ChildID());
|
|
|
|
}
|
2015-01-29 22:41:56 +03:00
|
|
|
|
2013-01-10 17:22:14 +04:00
|
|
|
mMarkedDestroying = true;
|
2011-01-06 07:54:47 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-04-10 00:31:24 +03:00
|
|
|
TabParent::RecvEnsureLayersConnected(CompositorOptions* aCompositorOptions)
|
2016-09-20 11:19:32 +03:00
|
|
|
{
|
|
|
|
if (RenderFrameParent* frame = GetRenderFrame()) {
|
2017-04-10 00:31:24 +03:00
|
|
|
frame->EnsureLayersConnected(aCompositorOptions);
|
2016-09-20 11:19:32 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-09-20 11:19:32 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-07-17 22:27:27 +04:00
|
|
|
TabParent::Recv__delete__()
|
|
|
|
{
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
2017-04-05 13:42:00 +03:00
|
|
|
ContentParent::UnregisterRemoteFrame(mTabId,
|
|
|
|
Manager()->AsContentParent()->ChildID(),
|
|
|
|
mMarkedDestroying);
|
2014-06-11 09:44:03 +04:00
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
else {
|
2015-08-28 10:18:00 +03:00
|
|
|
Manager()->AsContentBridgeParent()->NotifyTabDestroyed();
|
2017-04-05 13:42:00 +03:00
|
|
|
ContentParent::UnregisterRemoteFrame(mTabId,
|
|
|
|
Manager()->ChildID(),
|
|
|
|
mMarkedDestroying);
|
2014-10-29 21:11:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-07-17 22:27:27 +04:00
|
|
|
}
|
|
|
|
|
2010-04-12 04:34:02 +04:00
|
|
|
void
|
|
|
|
TabParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
2015-08-18 20:27:07 +03:00
|
|
|
// Even though TabParent::Destroy calls this, we need to do it here too in
|
|
|
|
// case of a crash.
|
2015-07-01 16:19:11 +03:00
|
|
|
IMEStateManager::OnTabParentDestroying(this);
|
|
|
|
|
2015-08-28 10:18:00 +03:00
|
|
|
// Prevent executing ContentParent::NotifyTabDestroying in
|
|
|
|
// TabParent::Destroy() called by frameLoader->DestroyComplete() below
|
|
|
|
// when tab crashes in contentprocess because ContentParent::ActorDestroy()
|
|
|
|
// in main process will be triggered before this function
|
|
|
|
// and remove the process information that
|
|
|
|
// ContentParent::NotifyTabDestroying need from mContentParentMap.
|
|
|
|
|
|
|
|
// When tab crashes in content process,
|
|
|
|
// there is no need to call ContentParent::NotifyTabDestroying
|
|
|
|
// because the jobs in ContentParent::NotifyTabDestroying
|
|
|
|
// will be done by ContentParent::ActorDestroy.
|
|
|
|
if (XRE_IsContentProcess() && why == AbnormalShutdown && !mIsDestroyed) {
|
|
|
|
DestroyInternal();
|
|
|
|
mIsDestroyed = true;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader(true);
|
2014-09-19 04:07:56 +04:00
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
2010-08-06 02:11:23 +04:00
|
|
|
if (frameLoader) {
|
2013-09-04 02:11:22 +04:00
|
|
|
nsCOMPtr<Element> frameElement(mFrameElement);
|
2013-11-06 21:21:15 +04:00
|
|
|
ReceiveMessage(CHILD_PROCESS_SHUTDOWN_MESSAGE, false, nullptr, nullptr,
|
|
|
|
nullptr);
|
2015-02-27 08:35:26 +03:00
|
|
|
frameLoader->DestroyComplete();
|
2012-08-02 18:26:57 +04:00
|
|
|
|
2014-09-19 04:07:56 +04:00
|
|
|
if (why == AbnormalShutdown && os) {
|
2013-04-26 04:53:26 +04:00
|
|
|
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, frameLoader),
|
|
|
|
"oop-frameloader-crashed", nullptr);
|
Bug 1298219 - Don't fire oop-browser-crashed event if the browser has already flipped remoteness and moved on. r=billm
We currently make the initial browser in a window remote by default. If early
on in the session, that one remote browser goes away (and the content process
was still booting), there's about 5 seconds before the shutdown kill timer
will take that content process out for not quitting fast enough.
There are some cases during startup where the content process is waiting
on information from the parent, so it cannot respond to the request to
quit in time. The parents shutdown kill timer goes off, and the shutdown
kill occurs.
In this bug, what's happening is that the initial browser flips remoteness
from remote to non-remote when it goes to about:sessionrestore. This starts
the shutdown kill timer. The content process runs out of time, and the
shutdown kill timer fires, killing the content process. The TabParent::ActorDestroy
method (which still exists, even though the browser is no longer remote),
interprets this as an abnormal shutdown, and bubbles the oop-browser-crashed
event to the associated <xul:browser>, which causes the page to browser to
about:tabcrashed, when it had already loaded about:sessionrestore.
This patch makes it so that the TabParent::ActorDestroy method first checks
to ensure that the associated remote frameloader is still the one that the
frameloader owner cares about. If not (because, say, the remoteness has
flipped and a new non-remote frameloader has been created), then the
event is not fired, since the user has moved on.
MozReview-Commit-ID: G4jmR6lMMFl
--HG--
extra : rebase_source : 7e752d9854d6c17b2b346cc986c0fbad00292848
2016-09-01 01:23:40 +03:00
|
|
|
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(frameElement);
|
|
|
|
if (owner) {
|
|
|
|
RefPtr<nsFrameLoader> currentFrameLoader = owner->GetFrameLoader();
|
|
|
|
// It's possible that the frameloader owner has already moved on
|
|
|
|
// and created a new frameloader. If so, we don't fire the event,
|
|
|
|
// since the frameloader owner has clearly moved on.
|
|
|
|
if (currentFrameLoader == frameLoader) {
|
|
|
|
nsContentUtils::DispatchTrustedEvent(frameElement->OwnerDoc(), frameElement,
|
|
|
|
NS_LITERAL_STRING("oop-browser-crashed"),
|
|
|
|
true, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-08-02 18:26:57 +04:00
|
|
|
}
|
2015-02-27 08:35:26 +03:00
|
|
|
|
|
|
|
mFrameLoader = nullptr;
|
2010-04-12 04:34:02 +04:00
|
|
|
}
|
2013-04-26 04:53:26 +04:00
|
|
|
|
2014-09-19 04:07:56 +04:00
|
|
|
if (os) {
|
|
|
|
os->NotifyObservers(NS_ISUPPORTS_CAST(nsITabParent*, this), "ipc:browser-destroyed", nullptr);
|
|
|
|
}
|
2010-04-12 04:34:02 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-07-13 13:07:49 +03:00
|
|
|
TabParent::RecvMoveFocus(const bool& aForward, const bool& aForDocumentNavigation)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
|
|
|
|
if (fm) {
|
|
|
|
nsCOMPtr<nsIDOMElement> dummy;
|
2015-07-13 13:07:49 +03:00
|
|
|
|
|
|
|
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));
|
2013-07-24 03:39:17 +04:00
|
|
|
nsCOMPtr<nsIDOMElement> frame = do_QueryInterface(mFrameElement);
|
|
|
|
fm->MoveFocus(nullptr, frame, type, nsIFocusManager::FLAG_BYKEY,
|
2009-11-05 21:14:22 +03:00
|
|
|
getter_AddRefs(dummy));
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-05-11 12:44:57 +03:00
|
|
|
TabParent::RecvSizeShellTo(const uint32_t& aFlags, const int32_t& aWidth, const int32_t& aHeight,
|
|
|
|
const int32_t& aShellItemWidth, const int32_t& aShellItemHeight)
|
|
|
|
{
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mFrameElement, IPC_OK());
|
2016-05-11 12:44:57 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(docShell, IPC_OK());
|
2016-05-11 12:44:57 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
nsresult rv = docShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
2016-05-11 12:44:57 +03:00
|
|
|
|
|
|
|
int32_t width = aWidth;
|
|
|
|
int32_t height = aHeight;
|
|
|
|
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_CX) {
|
|
|
|
width = mDimensions.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_CY) {
|
|
|
|
height = mDimensions.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(treeOwner));
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(xulWin, IPC_OK());
|
2016-05-11 12:44:57 +03:00
|
|
|
xulWin->SizeShellToWithLimit(width, height, aShellItemWidth, aShellItemHeight);
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-05-11 12:44:57 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-06-07 15:25:46 +03:00
|
|
|
TabParent::RecvDropLinks(nsTArray<nsString>&& aLinks)
|
2015-11-11 01:35:12 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIBrowser> browser = do_QueryInterface(mFrameElement);
|
|
|
|
if (browser) {
|
|
|
|
UniquePtr<const char16_t*[]> links;
|
|
|
|
links = MakeUnique<const char16_t*[]>(aLinks.Length());
|
|
|
|
for (uint32_t i = 0; i < aLinks.Length(); i++) {
|
|
|
|
links[i] = aLinks[i].get();
|
|
|
|
}
|
2017-06-07 15:25:46 +03:00
|
|
|
browser->DropLinks(aLinks.Length(), links.get());
|
2015-11-11 01:35:12 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-11-11 01:35:12 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2010-07-19 22:33:33 +04:00
|
|
|
TabParent::RecvEvent(const RemoteDOMEvent& aEvent)
|
2009-11-17 17:22:23 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMEvent> event = do_QueryInterface(aEvent.mEvent);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(event, IPC_OK());
|
2009-11-17 17:22:23 +03:00
|
|
|
|
2013-03-09 15:34:29 +04:00
|
|
|
nsCOMPtr<mozilla::dom::EventTarget> target = do_QueryInterface(mFrameElement);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(target, IPC_OK());
|
2009-11-17 17:22:23 +03:00
|
|
|
|
2013-03-09 15:34:29 +04:00
|
|
|
event->SetOwner(target);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool dummy;
|
2009-11-17 17:22:23 +03:00
|
|
|
target->DispatchEvent(event, &dummy);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2009-11-17 17:22:23 +03:00
|
|
|
}
|
|
|
|
|
2015-01-16 21:07:50 +03:00
|
|
|
bool
|
|
|
|
TabParent::SendLoadRemoteScript(const nsString& aURL,
|
|
|
|
const bool& aRunInGlobalScope)
|
|
|
|
{
|
2015-01-23 07:00:18 +03:00
|
|
|
if (mCreatingWindow) {
|
2015-01-16 21:07:50 +03:00
|
|
|
mDelayedFrameScripts.AppendElement(FrameScriptInfo(aURL, aRunInGlobalScope));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(mDelayedFrameScripts.IsEmpty());
|
|
|
|
return PBrowserParent::SendLoadRemoteScript(aURL, aRunInGlobalScope);
|
|
|
|
}
|
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
void
|
|
|
|
TabParent::LoadURL(nsIURI* aURI)
|
|
|
|
{
|
2013-02-16 02:27:21 +04:00
|
|
|
MOZ_ASSERT(aURI);
|
|
|
|
|
2012-11-10 10:09:24 +04:00
|
|
|
if (mIsDestroyed) {
|
2013-02-16 02:27:21 +04:00
|
|
|
return;
|
2012-04-25 20:35:58 +04:00
|
|
|
}
|
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
nsCString spec;
|
|
|
|
aURI->GetSpec(spec);
|
|
|
|
|
2015-01-23 07:00:18 +03:00
|
|
|
if (mCreatingWindow) {
|
|
|
|
// Don't send the message if the child wants to load its own URL.
|
|
|
|
MOZ_ASSERT(mDelayedURL.IsEmpty());
|
|
|
|
mDelayedURL = spec;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-11 01:28:13 +03:00
|
|
|
Unused << SendLoadURL(spec, GetShowInfo());
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
|
2017-01-17 23:52:45 +03:00
|
|
|
void
|
|
|
|
TabParent::InitRenderFrame()
|
|
|
|
{
|
|
|
|
if (IsInitedByParent()) {
|
|
|
|
// If TabParent is initialized by parent side then the RenderFrame must also
|
|
|
|
// be created here. If TabParent is initialized by child side,
|
|
|
|
// child side will create RenderFrame.
|
|
|
|
MOZ_ASSERT(!GetRenderFrame());
|
|
|
|
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
2017-01-17 23:52:45 +03:00
|
|
|
MOZ_ASSERT(frameLoader);
|
2017-01-17 23:52:45 +03:00
|
|
|
if (frameLoader) {
|
2017-03-31 18:43:21 +03:00
|
|
|
RenderFrameParent* renderFrame = new RenderFrameParent(frameLoader);
|
|
|
|
MOZ_ASSERT(renderFrame->IsInitted());
|
2017-01-17 23:52:45 +03:00
|
|
|
uint64_t layersId = renderFrame->GetLayersId();
|
|
|
|
AddTabParentToTable(layersId, this);
|
2017-03-15 22:30:10 +03:00
|
|
|
if (!SendPRenderFrameConstructor(renderFrame)) {
|
|
|
|
return;
|
|
|
|
}
|
2017-01-17 23:52:45 +03:00
|
|
|
|
|
|
|
TextureFactoryIdentifier textureFactoryIdentifier;
|
|
|
|
renderFrame->GetTextureFactoryIdentifier(&textureFactoryIdentifier);
|
2017-03-31 18:43:21 +03:00
|
|
|
Unused << SendInitRendering(textureFactoryIdentifier, layersId,
|
2017-04-10 00:30:27 +03:00
|
|
|
renderFrame->GetCompositorOptions(),
|
2017-03-31 18:43:21 +03:00
|
|
|
renderFrame->IsLayersConnected(), renderFrame);
|
2017-01-17 23:52:45 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Otherwise, the child should have constructed the RenderFrame,
|
|
|
|
// and we should already know about it.
|
|
|
|
MOZ_ASSERT(GetRenderFrame());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
void
|
2015-03-05 12:13:05 +03:00
|
|
|
TabParent::Show(const ScreenIntSize& size, bool aParentIsActive)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
2012-09-29 06:16:36 +04:00
|
|
|
mDimensions = size;
|
2014-11-16 21:23:22 +03:00
|
|
|
if (mIsDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-17 23:52:45 +03:00
|
|
|
MOZ_ASSERT(GetRenderFrame());
|
2014-11-24 22:05:35 +03:00
|
|
|
|
2016-02-23 19:10:00 +03:00
|
|
|
nsCOMPtr<nsISupports> container = mFrameElement->OwnerDoc()->GetContainer();
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
|
|
|
|
nsCOMPtr<nsIWidget> mainWidget;
|
|
|
|
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
|
|
|
|
mSizeMode = mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
|
|
|
|
|
2017-01-17 23:52:45 +03:00
|
|
|
Unused << SendShow(size, GetShowInfo(), aParentIsActive, mSizeMode);
|
2010-08-21 03:24:40 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-01-13 03:41:53 +03:00
|
|
|
TabParent::RecvSetDimensions(const uint32_t& aFlags,
|
|
|
|
const int32_t& aX, const int32_t& aY,
|
|
|
|
const int32_t& aCx, const int32_t& aCy)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!(aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER),
|
|
|
|
"We should never see DIM_FLAGS_SIZE_INNER here!");
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mFrameElement, IPC_OK());
|
2015-01-13 03:41:53 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(docShell, IPC_OK());
|
2015-01-13 03:41:53 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = do_QueryInterface(treeOwner);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, IPC_OK());
|
2015-01-13 03:41:53 +03:00
|
|
|
|
2016-05-11 12:44:57 +03:00
|
|
|
// We only care about the parameters that actually changed, see more
|
|
|
|
// details in TabChild::SetDimensions.
|
|
|
|
int32_t unused;
|
|
|
|
int32_t x = aX;
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_X) {
|
|
|
|
treeOwnerAsWin->GetPosition(&x, &unused);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t y = aY;
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_Y) {
|
|
|
|
treeOwnerAsWin->GetPosition(&unused, &y);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t cx = aCx;
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_CX) {
|
|
|
|
treeOwnerAsWin->GetSize(&cx, &unused);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t cy = aCy;
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_CY) {
|
|
|
|
treeOwnerAsWin->GetSize(&unused, &cy);
|
|
|
|
}
|
|
|
|
|
2015-01-13 03:41:53 +03:00
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
|
|
|
|
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) {
|
2016-05-12 03:07:45 +03:00
|
|
|
treeOwnerAsWin->SetPositionAndSize(x, y, cx, cy,
|
|
|
|
nsIBaseWindow::eRepaint);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-13 03:41:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
|
2016-05-11 12:44:57 +03:00
|
|
|
treeOwnerAsWin->SetPosition(x, y);
|
|
|
|
mUpdatedDimensions = false;
|
|
|
|
UpdatePosition();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-13 03:41:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) {
|
2016-05-11 12:44:57 +03:00
|
|
|
treeOwnerAsWin->SetSize(cx, cy, true);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-13 03:41:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(false, "Unknown flags!");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2015-01-13 03:41:53 +03:00
|
|
|
}
|
|
|
|
|
2015-04-21 17:33:56 +03:00
|
|
|
nsresult
|
|
|
|
TabParent::UpdatePosition()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
2015-04-21 17:33:56 +03:00
|
|
|
if (!frameLoader) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsIntRect windowDims;
|
|
|
|
NS_ENSURE_SUCCESS(frameLoader->GetWindowDimensions(windowDims), NS_ERROR_FAILURE);
|
|
|
|
UpdateDimensions(windowDims, mDimensions);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:40 +04:00
|
|
|
void
|
2015-03-31 23:39:02 +03:00
|
|
|
TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size)
|
2010-08-21 03:24:40 +04:00
|
|
|
{
|
2012-11-10 10:09:24 +04:00
|
|
|
if (mIsDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
2015-04-21 17:33:56 +03:00
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
2015-06-14 19:19:55 +03:00
|
|
|
if (!widget) {
|
|
|
|
NS_WARNING("No widget found in TabParent::UpdateDimensions");
|
|
|
|
return;
|
2015-04-21 17:33:56 +03:00
|
|
|
}
|
2016-03-08 22:14:43 +03:00
|
|
|
|
|
|
|
hal::ScreenConfiguration config;
|
|
|
|
hal::GetCurrentScreenConfiguration(&config);
|
|
|
|
ScreenOrientationInternal orientation = config.orientation();
|
2017-07-14 01:31:55 +03:00
|
|
|
LayoutDeviceIntPoint clientOffset = GetClientOffset();
|
2016-03-08 22:14:43 +03:00
|
|
|
LayoutDeviceIntPoint chromeOffset = -GetChildProcessOffset();
|
2015-04-21 17:33:56 +03:00
|
|
|
|
2013-01-29 11:49:38 +04:00
|
|
|
if (!mUpdatedDimensions || mOrientation != orientation ||
|
2016-03-08 22:14:43 +03:00
|
|
|
mDimensions != size || !mRect.IsEqualEdges(rect) ||
|
|
|
|
clientOffset != mClientOffset ||
|
2015-03-31 23:39:02 +03:00
|
|
|
chromeOffset != mChromeOffset) {
|
|
|
|
|
2013-01-29 11:49:38 +04:00
|
|
|
mUpdatedDimensions = true;
|
2016-03-08 22:14:43 +03:00
|
|
|
mRect = rect;
|
2013-01-29 11:49:38 +04:00
|
|
|
mDimensions = size;
|
|
|
|
mOrientation = orientation;
|
2016-03-08 22:14:43 +03:00
|
|
|
mClientOffset = clientOffset;
|
2015-03-31 23:39:02 +03:00
|
|
|
mChromeOffset = chromeOffset;
|
2013-01-29 11:49:38 +04:00
|
|
|
|
2017-06-07 21:36:46 +03:00
|
|
|
Unused << SendUpdateDimensions(GetDimensionInfo());
|
2012-07-20 10:48:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-07 21:36:46 +03:00
|
|
|
DimensionInfo
|
|
|
|
TabParent::GetDimensionInfo()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
MOZ_ASSERT(widget);
|
|
|
|
CSSToLayoutDeviceScale widgetScale = widget->GetDefaultScale();
|
|
|
|
|
|
|
|
LayoutDeviceIntRect devicePixelRect =
|
|
|
|
ViewAs<LayoutDevicePixel>(mRect,
|
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
|
|
|
LayoutDeviceIntSize devicePixelSize =
|
|
|
|
ViewAs<LayoutDevicePixel>(mDimensions,
|
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
|
|
|
|
|
|
|
CSSRect unscaledRect = devicePixelRect / widgetScale;
|
|
|
|
CSSSize unscaledSize = devicePixelSize / widgetScale;
|
|
|
|
DimensionInfo di(unscaledRect, unscaledSize, mOrientation,
|
|
|
|
mClientOffset, mChromeOffset);
|
|
|
|
return di;
|
|
|
|
}
|
|
|
|
|
2016-02-23 19:10:00 +03:00
|
|
|
void
|
|
|
|
TabParent::SizeModeChanged(const nsSizeMode& aSizeMode)
|
|
|
|
{
|
|
|
|
if (!mIsDestroyed && aSizeMode != mSizeMode) {
|
|
|
|
mSizeMode = aSizeMode;
|
|
|
|
Unused << SendSizeModeChanged(aSizeMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-23 18:36:50 +04:00
|
|
|
void
|
|
|
|
TabParent::UIResolutionChanged()
|
|
|
|
{
|
|
|
|
if (!mIsDestroyed) {
|
|
|
|
// TryCacheDPIAndScale()'s cache is keyed off of
|
|
|
|
// mDPI being greater than 0, so this invalidates it.
|
|
|
|
mDPI = -1;
|
2015-06-08 08:39:39 +03:00
|
|
|
TryCacheDPIAndScale();
|
2015-08-13 17:42:19 +03:00
|
|
|
// If mDPI was set to -1 to invalidate it and then TryCacheDPIAndScale
|
|
|
|
// fails to cache the values, then mDefaultScale.scale might be invalid.
|
|
|
|
// We don't want to send that value to content. Just send -1 for it too in
|
|
|
|
// that case.
|
2016-09-27 09:37:07 +03:00
|
|
|
Unused << SendUIResolutionChanged(mDPI, mRounding,
|
|
|
|
mDPI < 0 ? -1.0 : mDefaultScale.scale);
|
2014-05-23 18:36:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-22 17:58:33 +03:00
|
|
|
void
|
|
|
|
TabParent::ThemeChanged()
|
|
|
|
{
|
|
|
|
if (!mIsDestroyed) {
|
|
|
|
// The theme has changed, and any cached values we had sent down
|
|
|
|
// to the child have been invalidated. When this method is called,
|
|
|
|
// LookAndFeel should have the up-to-date values, which we now
|
|
|
|
// send down to the child. We do this for every remote tab for now,
|
|
|
|
// but bug 1156934 has been filed to do it once per content process.
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendThemeChanged(LookAndFeel::GetIntCache());
|
2015-04-22 17:58:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-18 15:19:13 +03:00
|
|
|
void
|
2016-05-11 15:56:42 +03:00
|
|
|
TabParent::HandleAccessKey(const WidgetKeyboardEvent& aEvent,
|
2017-07-06 11:36:19 +03:00
|
|
|
nsTArray<uint32_t>& aCharCodes)
|
2015-09-18 15:19:13 +03:00
|
|
|
{
|
|
|
|
if (!mIsDestroyed) {
|
2017-07-05 12:59:44 +03:00
|
|
|
// Note that we don't need to mark aEvent is posted to a remote process
|
|
|
|
// because the event may be dispatched to it as normal keyboard event.
|
|
|
|
// Therefore, we should use local copy to send it.
|
|
|
|
WidgetKeyboardEvent localEvent(aEvent);
|
2017-07-06 11:36:19 +03:00
|
|
|
Unused << SendHandleAccessKey(localEvent, aCharCodes);
|
2015-09-18 15:19:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
void
|
|
|
|
TabParent::Activate()
|
|
|
|
{
|
2012-11-10 10:09:24 +04:00
|
|
|
if (!mIsDestroyed) {
|
2017-03-15 04:00:00 +03:00
|
|
|
Unused << Manager()->SendActivate(this);
|
2012-11-10 10:09:24 +04:00
|
|
|
}
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
2011-06-18 04:08:32 +04:00
|
|
|
void
|
|
|
|
TabParent::Deactivate()
|
|
|
|
{
|
2012-11-10 10:09:24 +04:00
|
|
|
if (!mIsDestroyed) {
|
2017-03-15 04:00:00 +03:00
|
|
|
Unused << Manager()->SendDeactivate(this);
|
2012-11-10 10:09:24 +04:00
|
|
|
}
|
2011-06-18 04:08:32 +04:00
|
|
|
}
|
|
|
|
|
2010-08-13 12:06:40 +04:00
|
|
|
NS_IMETHODIMP
|
2016-01-30 20:05:36 +03:00
|
|
|
TabParent::Init(mozIDOMWindowProxy *window)
|
2010-08-13 12:06:40 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabParent::GetState(uint32_t *aState)
|
2010-08-13 12:06:40 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aState);
|
2010-09-18 06:11:05 +04:00
|
|
|
NS_WARNING("SecurityState not valid here");
|
2010-11-21 22:21:56 +03:00
|
|
|
*aState = 0;
|
2010-08-13 12:06:40 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-28 09:12:03 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::SetDocShell(nsIDocShell *aDocShell)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aDocShell);
|
|
|
|
NS_WARNING("No mDocShell member in TabParent so there is no docShell to set");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-21 20:04:58 +03:00
|
|
|
a11y::PDocAccessibleParent*
|
|
|
|
TabParent::AllocPDocAccessibleParent(PDocAccessibleParent* aParent,
|
2016-12-02 02:28:54 +03:00
|
|
|
const uint64_t&, const uint32_t&,
|
|
|
|
const IAccessibleHolder&)
|
2015-05-21 20:04:58 +03:00
|
|
|
{
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
return new a11y::DocAccessibleParent();
|
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabParent::DeallocPDocAccessibleParent(PDocAccessibleParent* aParent)
|
|
|
|
{
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
delete static_cast<a11y::DocAccessibleParent*>(aParent);
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-05-21 20:04:58 +03:00
|
|
|
TabParent::RecvPDocAccessibleConstructor(PDocAccessibleParent* aDoc,
|
|
|
|
PDocAccessibleParent* aParentDoc,
|
2016-10-27 22:16:24 +03:00
|
|
|
const uint64_t& aParentID,
|
2016-12-02 02:28:54 +03:00
|
|
|
const uint32_t& aMsaaID,
|
|
|
|
const IAccessibleHolder& aDocCOMProxy)
|
2015-05-21 20:04:58 +03:00
|
|
|
{
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
auto doc = static_cast<a11y::DocAccessibleParent*>(aDoc);
|
2017-01-26 00:44:09 +03:00
|
|
|
|
|
|
|
// If this tab is already shutting down just mark the new actor as shutdown
|
|
|
|
// and ignore it. When the tab actor is destroyed it will be too.
|
|
|
|
if (mIsDestroyed) {
|
|
|
|
doc->MarkAsShutdown();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2015-05-21 20:04:58 +03:00
|
|
|
if (aParentDoc) {
|
2015-07-20 20:46:35 +03:00
|
|
|
// A document should never directly be the parent of another document.
|
|
|
|
// There should always be an outer doc accessible child of the outer
|
|
|
|
// document containing the child.
|
2015-05-21 20:04:58 +03:00
|
|
|
MOZ_ASSERT(aParentID);
|
2015-07-20 20:46:35 +03:00
|
|
|
if (!aParentID) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2015-07-20 20:46:35 +03:00
|
|
|
}
|
|
|
|
|
2015-05-21 20:04:58 +03:00
|
|
|
auto parentDoc = static_cast<a11y::DocAccessibleParent*>(aParentDoc);
|
2017-01-18 23:30:00 +03:00
|
|
|
mozilla::ipc::IPCResult added = parentDoc->AddChildDoc(doc, aParentID);
|
2017-02-22 23:20:45 +03:00
|
|
|
if (!added) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
return added;
|
|
|
|
#else
|
|
|
|
return IPC_OK();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-10-27 22:16:24 +03:00
|
|
|
#ifdef XP_WIN
|
2016-12-02 02:28:54 +03:00
|
|
|
MOZ_ASSERT(aDocCOMProxy.IsNull());
|
2017-02-22 23:20:45 +03:00
|
|
|
a11y::WrapperFor(doc)->SetID(aMsaaID);
|
|
|
|
if (a11y::nsWinUtils::IsWindowEmulationStarted()) {
|
|
|
|
doc->SetEmulatedWindowHandle(parentDoc->GetEmulatedWindowHandle());
|
2016-11-02 01:07:58 +03:00
|
|
|
}
|
2016-10-27 22:16:24 +03:00
|
|
|
#endif
|
2017-02-22 23:20:45 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-21 20:04:58 +03:00
|
|
|
} else {
|
2015-07-20 20:46:35 +03:00
|
|
|
// null aParentDoc means this document is at the top level in the child
|
|
|
|
// process. That means it makes no sense to get an id for an accessible
|
|
|
|
// that is its parent.
|
2015-05-21 20:04:58 +03:00
|
|
|
MOZ_ASSERT(!aParentID);
|
2015-07-20 20:46:35 +03:00
|
|
|
if (aParentID) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2015-07-20 20:46:35 +03:00
|
|
|
}
|
|
|
|
|
2015-06-10 21:11:34 +03:00
|
|
|
doc->SetTopLevel();
|
2015-05-21 20:04:58 +03:00
|
|
|
a11y::DocManager::RemoteDocAdded(doc);
|
2016-10-27 22:16:24 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
a11y::WrapperFor(doc)->SetID(aMsaaID);
|
2016-12-02 02:28:54 +03:00
|
|
|
MOZ_ASSERT(!aDocCOMProxy.IsNull());
|
2017-04-29 03:37:22 +03:00
|
|
|
if (aDocCOMProxy.IsNull()) {
|
|
|
|
return IPC_FAIL(this, "Constructing a top-level PDocAccessible with null COM proxy");
|
|
|
|
}
|
|
|
|
|
2016-12-02 02:28:54 +03:00
|
|
|
RefPtr<IAccessible> proxy(aDocCOMProxy.Get());
|
2017-02-15 22:17:59 +03:00
|
|
|
doc->SetCOMInterface(proxy);
|
|
|
|
doc->MaybeInitWindowEmulation();
|
|
|
|
doc->SendParentCOMProxy();
|
2016-10-27 22:16:24 +03:00
|
|
|
#endif
|
2015-05-21 20:04:58 +03:00
|
|
|
}
|
|
|
|
#endif
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-21 20:04:58 +03:00
|
|
|
}
|
|
|
|
|
2015-10-06 20:10:47 +03:00
|
|
|
a11y::DocAccessibleParent*
|
|
|
|
TabParent::GetTopLevelDocAccessible() const
|
|
|
|
{
|
2015-10-08 17:51:31 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
2015-10-06 20:10:47 +03:00
|
|
|
// XXX Consider managing non top level PDocAccessibles with their parent
|
|
|
|
// document accessible.
|
2015-10-07 21:30:33 +03:00
|
|
|
const ManagedContainer<PDocAccessibleParent>& docs = ManagedPDocAccessibleParent();
|
|
|
|
for (auto iter = docs.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
auto doc = static_cast<a11y::DocAccessibleParent*>(iter.Get()->GetKey());
|
2017-01-30 10:24:37 +03:00
|
|
|
if (doc->IsTopLevel()) {
|
2015-10-06 20:10:47 +03:00
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
}
|
2015-10-13 22:00:35 +03:00
|
|
|
|
2015-10-07 21:30:33 +03:00
|
|
|
MOZ_ASSERT(docs.Count() == 0, "If there isn't a top level accessible doc "
|
|
|
|
"there shouldn't be an accessible doc at all!");
|
2015-10-08 17:51:31 +03:00
|
|
|
#endif
|
2015-10-06 20:10:47 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2010-10-27 02:20:53 +04:00
|
|
|
PDocumentRendererParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
TabParent::AllocPDocumentRendererParent(const nsRect& documentRect,
|
2013-12-26 22:06:53 +04:00
|
|
|
const gfx::Matrix& transform,
|
2013-07-08 19:48:39 +04:00
|
|
|
const nsString& bgcolor,
|
|
|
|
const uint32_t& renderFlags,
|
|
|
|
const bool& flushLayout,
|
|
|
|
const nsIntSize& renderSize)
|
2009-10-29 20:58:31 +03:00
|
|
|
{
|
|
|
|
return new DocumentRendererParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
TabParent::DeallocPDocumentRendererParent(PDocumentRendererParent* actor)
|
2009-10-29 20:58:31 +03:00
|
|
|
{
|
2009-12-03 11:16:14 +03:00
|
|
|
delete actor;
|
2009-10-29 20:58:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-18 04:30:06 +04:00
|
|
|
PFilePickerParent*
|
|
|
|
TabParent::AllocPFilePickerParent(const nsString& aTitle, const int16_t& aMode)
|
|
|
|
{
|
|
|
|
return new FilePickerParent(aTitle, aMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabParent::DeallocPFilePickerParent(PFilePickerParent* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
auto
|
|
|
|
TabParent::AllocPIndexedDBPermissionRequestParent(const Principal& aPrincipal)
|
|
|
|
-> PIndexedDBPermissionRequestParent*
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal(aPrincipal);
|
|
|
|
if (!principal) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContentParent> manager = Manager();
|
2016-10-22 23:50:47 +03:00
|
|
|
if (!manager->IsContentParent()) {
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_CRASH("Figure out security checks for bridged content!");
|
|
|
|
}
|
|
|
|
|
2015-04-10 19:10:00 +03:00
|
|
|
if (NS_WARN_IF(!mFrameElement)) {
|
2014-09-27 03:21:57 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
2015-04-10 19:10:00 +03:00
|
|
|
mozilla::dom::indexedDB::AllocPIndexedDBPermissionRequestParent(mFrameElement,
|
2014-09-27 03:21:57 +04:00
|
|
|
principal);
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-09-27 03:21:57 +04:00
|
|
|
TabParent::RecvPIndexedDBPermissionRequestConstructor(
|
|
|
|
PIndexedDBPermissionRequestParent* aActor,
|
|
|
|
const Principal& aPrincipal)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!mozilla::dom::indexedDB::RecvPIndexedDBPermissionRequestConstructor(aActor)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabParent::DeallocPIndexedDBPermissionRequestParent(
|
|
|
|
PIndexedDBPermissionRequestParent* aActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
|
|
|
|
return
|
|
|
|
mozilla::dom::indexedDB::DeallocPIndexedDBPermissionRequestParent(aActor);
|
|
|
|
}
|
|
|
|
|
2009-11-05 21:21:09 +03:00
|
|
|
void
|
|
|
|
TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aButton, int32_t aClickCount,
|
|
|
|
int32_t aModifiers, bool aIgnoreRootScrollFrame)
|
2009-11-05 21:21:09 +03:00
|
|
|
{
|
2012-11-10 10:09:24 +04:00
|
|
|
if (!mIsDestroyed) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << PBrowserParent::SendMouseEvent(nsString(aType), aX, aY,
|
2012-11-10 10:09:24 +04:00
|
|
|
aButton, aClickCount,
|
2017-01-19 11:57:20 +03:00
|
|
|
aModifiers,
|
|
|
|
aIgnoreRootScrollFrame);
|
2012-11-10 10:09:24 +04:00
|
|
|
}
|
2009-11-05 21:21:09 +03:00
|
|
|
}
|
|
|
|
|
2010-03-19 09:52:18 +03:00
|
|
|
void
|
|
|
|
TabParent::SendKeyEvent(const nsAString& aType,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aKeyCode,
|
|
|
|
int32_t aCharCode,
|
|
|
|
int32_t aModifiers,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aPreventDefault)
|
2010-03-19 09:52:18 +03:00
|
|
|
{
|
2017-07-28 10:20:27 +03:00
|
|
|
if (mIsDestroyed) {
|
2017-01-19 11:57:20 +03:00
|
|
|
return;
|
2012-11-10 10:09:24 +04:00
|
|
|
}
|
2017-01-19 11:57:20 +03:00
|
|
|
Unused << PBrowserParent::SendKeyEvent(nsString(aType), aKeyCode, aCharCode,
|
|
|
|
aModifiers, aPreventDefault);
|
2010-03-19 09:52:18 +03:00
|
|
|
}
|
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
void
|
2017-01-19 11:27:15 +03:00
|
|
|
TabParent::SendRealMouseEvent(WidgetMouseEvent& aEvent)
|
2011-06-22 04:32:43 +04:00
|
|
|
{
|
2017-07-28 10:20:27 +03:00
|
|
|
if (mIsDestroyed) {
|
2017-07-05 12:59:44 +03:00
|
|
|
return;
|
2012-11-10 10:09:24 +04:00
|
|
|
}
|
2017-01-19 11:27:15 +03:00
|
|
|
aEvent.mRefPoint += GetChildProcessOffset();
|
2015-04-15 02:29:10 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
2015-05-22 09:00:00 +03:00
|
|
|
// When we mouseenter the tab, the tab's cursor should
|
|
|
|
// become the current cursor. When we mouseexit, we stop.
|
2017-01-19 11:27:15 +03:00
|
|
|
if (eMouseEnterIntoWidget == aEvent.mMessage) {
|
2015-04-15 02:29:10 +03:00
|
|
|
mTabSetsCursor = true;
|
2015-05-20 04:28:57 +03:00
|
|
|
if (mCustomCursor) {
|
2017-01-19 11:57:20 +03:00
|
|
|
widget->SetCursor(mCustomCursor,
|
|
|
|
mCustomCursorHotspotX, mCustomCursorHotspotY);
|
2015-05-20 04:28:57 +03:00
|
|
|
} else if (mCursor != nsCursor(-1)) {
|
2015-04-15 02:29:10 +03:00
|
|
|
widget->SetCursor(mCursor);
|
|
|
|
}
|
2017-01-19 11:27:15 +03:00
|
|
|
} else if (eMouseExitFromWidget == aEvent.mMessage) {
|
2015-04-15 02:29:10 +03:00
|
|
|
mTabSetsCursor = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-28 21:44:37 +03:00
|
|
|
ScrollableLayerGuid guid;
|
|
|
|
uint64_t blockId;
|
|
|
|
ApzAwareEventRoutingToChild(&guid, &blockId, nullptr);
|
|
|
|
|
2017-01-19 11:27:15 +03:00
|
|
|
if (eMouseMove == aEvent.mMessage) {
|
|
|
|
if (aEvent.mReason == WidgetMouseEvent::eSynthesized) {
|
2017-07-05 12:59:44 +03:00
|
|
|
DebugOnly<bool> ret = SendSynthMouseMoveEvent(aEvent, guid, blockId);
|
|
|
|
NS_WARNING_ASSERTION(ret, "SendSynthMouseMoveEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
|
|
|
return;
|
2015-07-28 01:35:51 +03:00
|
|
|
}
|
2017-07-05 12:59:44 +03:00
|
|
|
DebugOnly<bool> ret = SendRealMouseMoveEvent(aEvent, guid, blockId);
|
|
|
|
NS_WARNING_ASSERTION(ret, "SendRealMouseMoveEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
|
|
|
return;
|
2015-02-14 02:34:04 +03:00
|
|
|
}
|
2015-09-28 21:44:37 +03:00
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
DebugOnly<bool> ret = SendRealMouseButtonEvent(aEvent, guid, blockId);
|
|
|
|
NS_WARNING_ASSERTION(ret, "SendRealMouseButtonEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
2011-06-22 04:32:43 +04:00
|
|
|
}
|
|
|
|
|
2015-02-17 05:41:48 +03:00
|
|
|
LayoutDeviceToCSSScale
|
|
|
|
TabParent::GetLayoutDeviceToCSSScale()
|
2013-12-06 03:17:37 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement);
|
2015-02-17 05:41:48 +03:00
|
|
|
nsIDocument* doc = (content ? content->OwnerDoc() : nullptr);
|
|
|
|
nsIPresShell* shell = (doc ? doc->GetShell() : nullptr);
|
|
|
|
nsPresContext* ctx = (shell ? shell->GetPresContext() : nullptr);
|
|
|
|
return LayoutDeviceToCSSScale(ctx
|
|
|
|
? (float)ctx->AppUnitsPerDevPixel() / nsPresContext::AppUnitsPerCSSPixel()
|
|
|
|
: 0.0f);
|
|
|
|
}
|
2013-12-06 03:17:37 +04:00
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
void
|
2017-01-19 11:27:15 +03:00
|
|
|
TabParent::SendRealDragEvent(WidgetDragEvent& aEvent, uint32_t aDragAction,
|
2015-04-08 21:48:11 +03:00
|
|
|
uint32_t aDropEffect)
|
|
|
|
{
|
2017-07-28 10:20:27 +03:00
|
|
|
if (mIsDestroyed) {
|
2017-07-05 12:59:44 +03:00
|
|
|
return;
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
2017-01-19 11:27:15 +03:00
|
|
|
aEvent.mRefPoint += GetChildProcessOffset();
|
2017-07-05 12:59:44 +03:00
|
|
|
DebugOnly<bool> ret =
|
|
|
|
PBrowserParent::SendRealDragEvent(aEvent, aDragAction, aDropEffect);
|
|
|
|
NS_WARNING_ASSERTION(ret, "PBrowserParent::SendRealDragEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
|
|
|
|
2017-01-19 11:27:15 +03:00
|
|
|
LayoutDevicePoint
|
|
|
|
TabParent::AdjustTapToChildWidget(const LayoutDevicePoint& aPoint)
|
2015-02-17 05:41:48 +03:00
|
|
|
{
|
2016-07-29 21:44:29 +03:00
|
|
|
return aPoint + LayoutDevicePoint(GetChildProcessOffset());
|
2013-12-06 03:17:37 +04:00
|
|
|
}
|
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
void
|
2017-01-19 11:27:15 +03:00
|
|
|
TabParent::SendMouseWheelEvent(WidgetWheelEvent& aEvent)
|
2012-08-12 05:42:34 +04:00
|
|
|
{
|
2017-07-28 10:20:27 +03:00
|
|
|
if (mIsDestroyed) {
|
2017-07-05 12:59:44 +03:00
|
|
|
return;
|
2012-11-10 10:09:24 +04:00
|
|
|
}
|
2014-12-09 13:40:26 +03:00
|
|
|
|
|
|
|
ScrollableLayerGuid guid;
|
|
|
|
uint64_t blockId;
|
2015-05-14 15:16:00 +03:00
|
|
|
ApzAwareEventRoutingToChild(&guid, &blockId, nullptr);
|
2017-01-19 11:27:15 +03:00
|
|
|
aEvent.mRefPoint += GetChildProcessOffset();
|
2017-07-05 12:59:44 +03:00
|
|
|
DebugOnly<bool> ret =
|
|
|
|
PBrowserParent::SendMouseWheelEvent(aEvent, guid, blockId);
|
|
|
|
NS_WARNING_ASSERTION(ret, "PBrowserParent::SendMouseWheelEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
2012-08-12 05:42:34 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
TabParent::RecvDispatchWheelEvent(const mozilla::WidgetWheelEvent& aEvent)
|
2015-03-07 01:26:59 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-07 01:26:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WidgetWheelEvent localEvent(aEvent);
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = widget;
|
2016-04-18 17:09:02 +03:00
|
|
|
localEvent.mRefPoint -= GetChildProcessOffset();
|
2015-03-07 01:26:59 +03:00
|
|
|
|
2016-03-11 02:25:48 +03:00
|
|
|
widget->DispatchInputEvent(&localEvent);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-07 01:26:59 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-03-25 01:00:52 +03:00
|
|
|
TabParent::RecvDispatchMouseEvent(const mozilla::WidgetMouseEvent& aEvent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-25 01:00:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WidgetMouseEvent localEvent(aEvent);
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = widget;
|
2016-04-18 17:09:02 +03:00
|
|
|
localEvent.mRefPoint -= GetChildProcessOffset();
|
2015-03-25 01:00:52 +03:00
|
|
|
|
|
|
|
widget->DispatchInputEvent(&localEvent);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-25 01:00:52 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-03-25 01:00:52 +03:00
|
|
|
TabParent::RecvDispatchKeyboardEvent(const mozilla::WidgetKeyboardEvent& aEvent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-25 01:00:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WidgetKeyboardEvent localEvent(aEvent);
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = widget;
|
2016-04-18 17:09:02 +03:00
|
|
|
localEvent.mRefPoint -= GetChildProcessOffset();
|
2015-03-25 01:00:52 +03:00
|
|
|
|
|
|
|
widget->DispatchInputEvent(&localEvent);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-25 01:00:52 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-05-19 12:46:02 +03:00
|
|
|
TabParent::RecvRequestNativeKeyBindings(const uint32_t& aType,
|
|
|
|
const WidgetKeyboardEvent& aEvent,
|
|
|
|
nsTArray<CommandInt>* aCommands)
|
2014-04-22 00:40:09 +04:00
|
|
|
{
|
2017-05-19 12:46:02 +03:00
|
|
|
MOZ_ASSERT(aCommands);
|
|
|
|
MOZ_ASSERT(aCommands->IsEmpty());
|
|
|
|
|
|
|
|
nsIWidget::NativeKeyBindingsType keyBindingsType =
|
|
|
|
static_cast<nsIWidget::NativeKeyBindingsType>(aType);
|
|
|
|
switch (keyBindingsType) {
|
|
|
|
case nsIWidget::NativeKeyBindingsForSingleLineEditor:
|
|
|
|
case nsIWidget::NativeKeyBindingsForMultiLineEditor:
|
|
|
|
case nsIWidget::NativeKeyBindingsForRichTextEditor:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return IPC_FAIL(this, "Invalid aType value");
|
|
|
|
}
|
2014-04-22 00:40:09 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-04-22 00:40:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WidgetKeyboardEvent localEvent(aEvent);
|
2017-05-19 11:49:41 +03:00
|
|
|
localEvent.mWidget = widget;
|
2014-04-22 00:40:09 +04:00
|
|
|
|
|
|
|
if (NS_FAILED(widget->AttachNativeKeyEvent(localEvent))) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-04-22 00:40:09 +04:00
|
|
|
}
|
|
|
|
|
2017-05-19 12:46:02 +03:00
|
|
|
localEvent.InitEditCommandsFor(keyBindingsType);
|
|
|
|
*aCommands = localEvent.EditCommandsConstRef(keyBindingsType);
|
2014-04-22 00:40:09 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-04-22 00:40:09 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 18:36:36 +03:00
|
|
|
class SynthesizedEventObserver : public nsIObserver
|
|
|
|
{
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
public:
|
|
|
|
SynthesizedEventObserver(TabParent* aTabParent, const uint64_t& aObserverId)
|
|
|
|
: mTabParent(aTabParent)
|
|
|
|
, mObserverId(aObserverId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mTabParent);
|
|
|
|
}
|
|
|
|
|
2016-08-08 03:54:47 +03:00
|
|
|
NS_IMETHOD Observe(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
|
|
|
const char16_t* aData) override
|
2015-04-14 18:36:36 +03:00
|
|
|
{
|
2016-12-19 09:29:48 +03:00
|
|
|
if (!mTabParent || !mObserverId) {
|
|
|
|
// We already sent the notification, or we don't actually need to
|
|
|
|
// send any notification at all.
|
2015-04-14 18:36:36 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-01-19 11:57:20 +03:00
|
|
|
if (!mTabParent->SendNativeSynthesisResponse(mObserverId,
|
|
|
|
nsCString(aTopic))) {
|
2015-04-14 18:36:36 +03:00
|
|
|
NS_WARNING("Unable to send native event synthesization response!");
|
|
|
|
}
|
|
|
|
// Null out tabparent to indicate we already sent the response
|
|
|
|
mTabParent = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~SynthesizedEventObserver() { }
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent> mTabParent;
|
2015-04-14 18:36:36 +03:00
|
|
|
uint64_t mObserverId;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(SynthesizedEventObserver, nsIObserver)
|
|
|
|
|
|
|
|
class MOZ_STACK_CLASS AutoSynthesizedEventResponder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoSynthesizedEventResponder(TabParent* aTabParent,
|
|
|
|
const uint64_t& aObserverId,
|
|
|
|
const char* aTopic)
|
|
|
|
: mObserver(new SynthesizedEventObserver(aTabParent, aObserverId))
|
|
|
|
, mTopic(aTopic)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~AutoSynthesizedEventResponder()
|
|
|
|
{
|
|
|
|
// This may be a no-op if the observer already sent a response.
|
|
|
|
mObserver->Observe(nullptr, mTopic, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIObserver* GetObserver()
|
|
|
|
{
|
|
|
|
return mObserver;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIObserver> mObserver;
|
|
|
|
const char* mTopic;
|
|
|
|
};
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-04-14 18:36:36 +03:00
|
|
|
TabParent::RecvSynthesizeNativeKeyEvent(const int32_t& aNativeKeyboardLayout,
|
|
|
|
const int32_t& aNativeKeyCode,
|
|
|
|
const uint32_t& aModifierFlags,
|
|
|
|
const nsString& aCharacters,
|
|
|
|
const nsString& aUnmodifiedCharacters,
|
|
|
|
const uint64_t& aObserverId)
|
|
|
|
{
|
|
|
|
AutoSynthesizedEventResponder responder(this, aObserverId, "keyevent");
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
widget->SynthesizeNativeKeyEvent(aNativeKeyboardLayout, aNativeKeyCode,
|
2017-01-19 11:57:20 +03:00
|
|
|
aModifierFlags, aCharacters,
|
|
|
|
aUnmodifiedCharacters,
|
|
|
|
responder.GetObserver());
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-04-14 18:36:36 +03:00
|
|
|
TabParent::RecvSynthesizeNativeMouseEvent(const LayoutDeviceIntPoint& aPoint,
|
|
|
|
const uint32_t& aNativeMessage,
|
|
|
|
const uint32_t& aModifierFlags,
|
|
|
|
const uint64_t& aObserverId)
|
|
|
|
{
|
|
|
|
AutoSynthesizedEventResponder responder(this, aObserverId, "mouseevent");
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
widget->SynthesizeNativeMouseEvent(aPoint, aNativeMessage, aModifierFlags,
|
2017-01-19 11:57:20 +03:00
|
|
|
responder.GetObserver());
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-04-14 18:36:36 +03:00
|
|
|
TabParent::RecvSynthesizeNativeMouseMove(const LayoutDeviceIntPoint& aPoint,
|
|
|
|
const uint64_t& aObserverId)
|
|
|
|
{
|
|
|
|
AutoSynthesizedEventResponder responder(this, aObserverId, "mousemove");
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
widget->SynthesizeNativeMouseMove(aPoint, responder.GetObserver());
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-01-19 11:57:20 +03:00
|
|
|
TabParent::RecvSynthesizeNativeMouseScrollEvent(
|
|
|
|
const LayoutDeviceIntPoint& aPoint,
|
|
|
|
const uint32_t& aNativeMessage,
|
|
|
|
const double& aDeltaX,
|
|
|
|
const double& aDeltaY,
|
|
|
|
const double& aDeltaZ,
|
|
|
|
const uint32_t& aModifierFlags,
|
|
|
|
const uint32_t& aAdditionalFlags,
|
|
|
|
const uint64_t& aObserverId)
|
2015-04-14 18:36:36 +03:00
|
|
|
{
|
|
|
|
AutoSynthesizedEventResponder responder(this, aObserverId, "mousescrollevent");
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
widget->SynthesizeNativeMouseScrollEvent(aPoint, aNativeMessage,
|
2017-01-19 11:57:20 +03:00
|
|
|
aDeltaX, aDeltaY, aDeltaZ,
|
|
|
|
aModifierFlags, aAdditionalFlags,
|
|
|
|
responder.GetObserver());
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-01-19 11:57:20 +03:00
|
|
|
TabParent::RecvSynthesizeNativeTouchPoint(
|
|
|
|
const uint32_t& aPointerId,
|
|
|
|
const TouchPointerState& aPointerState,
|
|
|
|
const LayoutDeviceIntPoint& aPoint,
|
|
|
|
const double& aPointerPressure,
|
|
|
|
const uint32_t& aPointerOrientation,
|
|
|
|
const uint64_t& aObserverId)
|
2015-04-14 18:36:36 +03:00
|
|
|
{
|
|
|
|
AutoSynthesizedEventResponder responder(this, aObserverId, "touchpoint");
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
2016-04-15 13:39:36 +03:00
|
|
|
widget->SynthesizeNativeTouchPoint(aPointerId, aPointerState, aPoint,
|
2017-01-19 11:57:20 +03:00
|
|
|
aPointerPressure, aPointerOrientation,
|
|
|
|
responder.GetObserver());
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-04-15 13:39:36 +03:00
|
|
|
TabParent::RecvSynthesizeNativeTouchTap(const LayoutDeviceIntPoint& aPoint,
|
2015-04-14 18:36:36 +03:00
|
|
|
const bool& aLongTap,
|
|
|
|
const uint64_t& aObserverId)
|
|
|
|
{
|
|
|
|
AutoSynthesizedEventResponder responder(this, aObserverId, "touchtap");
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
2016-04-15 13:39:36 +03:00
|
|
|
widget->SynthesizeNativeTouchTap(aPoint, aLongTap, responder.GetObserver());
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-04-14 18:36:36 +03:00
|
|
|
TabParent::RecvClearNativeTouchSequence(const uint64_t& aObserverId)
|
|
|
|
{
|
|
|
|
AutoSynthesizedEventResponder responder(this, aObserverId, "cleartouch");
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
widget->ClearNativeTouchSequence(responder.GetObserver());
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
void
|
2017-01-19 11:27:15 +03:00
|
|
|
TabParent::SendRealKeyEvent(WidgetKeyboardEvent& aEvent)
|
2011-06-22 04:32:43 +04:00
|
|
|
{
|
2017-07-28 10:20:27 +03:00
|
|
|
if (mIsDestroyed) {
|
2017-07-05 12:59:44 +03:00
|
|
|
return;
|
2012-11-10 10:09:24 +04:00
|
|
|
}
|
2017-01-19 11:27:15 +03:00
|
|
|
aEvent.mRefPoint += GetChildProcessOffset();
|
2014-03-20 19:46:29 +04:00
|
|
|
|
2017-01-19 11:27:15 +03:00
|
|
|
if (aEvent.mMessage == eKeyPress) {
|
2017-05-19 11:24:20 +03:00
|
|
|
// XXX Should we do this only when input context indicates an editor having
|
|
|
|
// focus and the key event won't cause inputting text?
|
|
|
|
aEvent.InitAllEditCommands();
|
|
|
|
} else {
|
|
|
|
aEvent.PreventNativeKeyBindings();
|
2014-03-20 19:46:29 +04:00
|
|
|
}
|
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
DebugOnly<bool> ret = PBrowserParent::SendRealKeyEvent(aEvent);
|
|
|
|
NS_WARNING_ASSERTION(ret, "PBrowserParent::SendRealKeyEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
2011-06-22 04:32:43 +04:00
|
|
|
}
|
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
void
|
2017-01-19 11:27:15 +03:00
|
|
|
TabParent::SendRealTouchEvent(WidgetTouchEvent& aEvent)
|
2012-07-16 06:58:43 +04:00
|
|
|
{
|
2017-07-28 10:20:27 +03:00
|
|
|
if (mIsDestroyed) {
|
2017-07-05 12:59:44 +03:00
|
|
|
return;
|
2012-11-10 10:09:24 +04:00
|
|
|
}
|
2012-09-12 00:05:52 +04:00
|
|
|
|
2014-01-27 21:41:12 +04:00
|
|
|
// PresShell::HandleEventInternal adds touches on touch end/cancel. This
|
|
|
|
// confuses remote content and the panning and zooming logic into thinking
|
|
|
|
// that the added touches are part of the touchend/cancel, when actually
|
|
|
|
// they're not.
|
2017-01-19 11:27:15 +03:00
|
|
|
if (aEvent.mMessage == eTouchEnd || aEvent.mMessage == eTouchCancel) {
|
|
|
|
for (int i = aEvent.mTouches.Length() - 1; i >= 0; i--) {
|
|
|
|
if (!aEvent.mTouches[i]->mChanged) {
|
|
|
|
aEvent.mTouches.RemoveElementAt(i);
|
2012-12-20 23:54:00 +04:00
|
|
|
}
|
2012-08-29 20:06:11 +04:00
|
|
|
}
|
|
|
|
}
|
2012-09-12 00:05:52 +04:00
|
|
|
|
2013-11-13 22:20:31 +04:00
|
|
|
ScrollableLayerGuid guid;
|
2014-10-24 21:29:30 +04:00
|
|
|
uint64_t blockId;
|
2015-05-14 15:16:00 +03:00
|
|
|
nsEventStatus apzResponse;
|
|
|
|
ApzAwareEventRoutingToChild(&guid, &blockId, &apzResponse);
|
2013-08-14 18:15:27 +04:00
|
|
|
|
2015-02-07 00:46:46 +03:00
|
|
|
if (mIsDestroyed) {
|
2017-07-05 12:59:44 +03:00
|
|
|
return;
|
2014-01-16 03:07:18 +04:00
|
|
|
}
|
|
|
|
|
2015-02-17 05:35:03 +03:00
|
|
|
LayoutDeviceIntPoint offset = GetChildProcessOffset();
|
2017-01-19 11:27:15 +03:00
|
|
|
for (uint32_t i = 0; i < aEvent.mTouches.Length(); i++) {
|
|
|
|
aEvent.mTouches[i]->mRefPoint += offset;
|
2015-02-17 05:35:03 +03:00
|
|
|
}
|
2013-08-14 18:15:27 +04:00
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
if (aEvent.mMessage == eTouchMove) {
|
|
|
|
DebugOnly<bool> ret =
|
|
|
|
PBrowserParent::SendRealTouchMoveEvent(aEvent, guid, blockId,
|
|
|
|
apzResponse);
|
|
|
|
NS_WARNING_ASSERTION(ret,
|
|
|
|
"PBrowserParent::SendRealTouchMoveEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugOnly<bool> ret =
|
2017-01-19 11:27:15 +03:00
|
|
|
PBrowserParent::SendRealTouchEvent(aEvent, guid, blockId, apzResponse);
|
2017-07-05 12:59:44 +03:00
|
|
|
NS_WARNING_ASSERTION(ret, "PBrowserParent::SendRealTouchEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabParent::SendPluginEvent(WidgetPluginEvent& aEvent)
|
|
|
|
{
|
|
|
|
DebugOnly<bool> ret = PBrowserParent::SendPluginEvent(aEvent);
|
|
|
|
NS_WARNING_ASSERTION(ret, "PBrowserParent::SendPluginEvent() failed");
|
|
|
|
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
|
2012-07-16 06:58:43 +04:00
|
|
|
}
|
|
|
|
|
2016-09-21 17:26:33 +03:00
|
|
|
bool
|
|
|
|
TabParent::SendHandleTap(TapType aType,
|
|
|
|
const LayoutDevicePoint& aPoint,
|
|
|
|
Modifiers aModifiers,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
|
|
|
uint64_t aInputBlockId)
|
|
|
|
{
|
2017-07-28 10:20:27 +03:00
|
|
|
if (mIsDestroyed) {
|
2016-09-21 17:26:33 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-09-30 22:03:42 +03:00
|
|
|
if ((aType == TapType::eSingleTap || aType == TapType::eSecondTap) &&
|
|
|
|
GetRenderFrame()) {
|
|
|
|
GetRenderFrame()->TakeFocusForClickFromTap();
|
|
|
|
}
|
2016-09-21 17:26:33 +03:00
|
|
|
LayoutDeviceIntPoint offset = GetChildProcessOffset();
|
2017-01-19 11:57:20 +03:00
|
|
|
return PBrowserParent::SendHandleTap(aType, aPoint + offset, aModifiers,
|
|
|
|
aGuid, aInputBlockId);
|
2016-09-21 17:26:33 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2010-07-19 22:33:33 +04:00
|
|
|
TabParent::RecvSyncMessage(const nsString& aMessage,
|
2012-08-02 10:02:29 +04:00
|
|
|
const ClonedMessageData& aData,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<CpowEntry>&& aCpows,
|
2013-11-06 21:21:15 +04:00
|
|
|
const IPC::Principal& aPrincipal,
|
2015-09-10 23:50:58 +03:00
|
|
|
nsTArray<StructuredCloneData>* aRetVal)
|
2010-02-20 20:05:20 +03:00
|
|
|
{
|
2017-03-30 00:43:21 +03:00
|
|
|
NS_LossyConvertUTF16toASCII messageNameCStr(aMessage);
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL_DYNAMIC("TabParent::RecvSyncMessage", EVENTS,
|
|
|
|
messageNameCStr.get());
|
2017-03-30 00:43:21 +03:00
|
|
|
|
2015-09-10 23:50:58 +03:00
|
|
|
StructuredCloneData data;
|
|
|
|
ipc::UnpackClonedMessageDataForParent(aData, data);
|
2015-09-02 19:20:30 +03:00
|
|
|
|
2015-01-27 00:32:31 +03:00
|
|
|
CrossProcessCpowHolder cpows(Manager(), aCpows);
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!ReceiveMessage(aMessage, true, &data, &cpows, aPrincipal, aRetVal)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-10-08 08:32:45 +04:00
|
|
|
TabParent::RecvRpcMessage(const nsString& aMessage,
|
|
|
|
const ClonedMessageData& aData,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<CpowEntry>&& aCpows,
|
2014-10-08 08:32:45 +04:00
|
|
|
const IPC::Principal& aPrincipal,
|
2015-09-10 23:50:58 +03:00
|
|
|
nsTArray<StructuredCloneData>* aRetVal)
|
2013-10-01 20:15:06 +04:00
|
|
|
{
|
2017-03-30 00:43:21 +03:00
|
|
|
NS_LossyConvertUTF16toASCII messageNameCStr(aMessage);
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL_DYNAMIC("TabParent::RecvRpcMessage", EVENTS,
|
|
|
|
messageNameCStr.get());
|
2017-03-30 00:43:21 +03:00
|
|
|
|
2015-09-10 23:50:58 +03:00
|
|
|
StructuredCloneData data;
|
|
|
|
ipc::UnpackClonedMessageDataForParent(aData, data);
|
2015-09-02 19:20:30 +03:00
|
|
|
|
2015-01-27 00:32:31 +03:00
|
|
|
CrossProcessCpowHolder cpows(Manager(), aCpows);
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!ReceiveMessage(aMessage, true, &data, &cpows, aPrincipal, aRetVal)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2013-10-01 20:15:06 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2010-07-19 22:33:33 +04:00
|
|
|
TabParent::RecvAsyncMessage(const nsString& aMessage,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<CpowEntry>&& aCpows,
|
2016-04-09 16:50:59 +03:00
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const ClonedMessageData& aData)
|
2012-08-02 10:02:29 +04:00
|
|
|
{
|
2017-03-30 00:43:21 +03:00
|
|
|
NS_LossyConvertUTF16toASCII messageNameCStr(aMessage);
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL_DYNAMIC("TabParent::RecvAsyncMessage", EVENTS,
|
|
|
|
messageNameCStr.get());
|
2017-03-30 00:43:21 +03:00
|
|
|
|
2015-09-10 23:50:58 +03:00
|
|
|
StructuredCloneData data;
|
|
|
|
ipc::UnpackClonedMessageDataForParent(aData, data);
|
2015-09-02 19:20:30 +03:00
|
|
|
|
2015-01-27 00:32:31 +03:00
|
|
|
CrossProcessCpowHolder cpows(Manager(), aCpows);
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!ReceiveMessage(aMessage, false, &data, &cpows, aPrincipal, nullptr)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2010-03-30 00:29:45 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-05-28 05:12:29 +04:00
|
|
|
TabParent::RecvSetCursor(const uint32_t& aCursor, const bool& aForce)
|
2011-06-22 04:32:43 +04:00
|
|
|
{
|
2015-04-15 02:29:10 +03:00
|
|
|
mCursor = static_cast<nsCursor>(aCursor);
|
2015-05-20 04:28:57 +03:00
|
|
|
mCustomCursor = nullptr;
|
2015-04-15 02:29:10 +03:00
|
|
|
|
2011-06-22 04:32:43 +04:00
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
2014-05-28 05:12:29 +04:00
|
|
|
if (aForce) {
|
|
|
|
widget->ClearCachedCursor();
|
|
|
|
}
|
2015-04-15 02:29:10 +03:00
|
|
|
if (mTabSetsCursor) {
|
|
|
|
widget->SetCursor(mCursor);
|
|
|
|
}
|
2011-06-22 04:32:43 +04:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-06-22 04:32:43 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-05-20 04:28:57 +03:00
|
|
|
TabParent::RecvSetCustomCursor(const nsCString& aCursorData,
|
|
|
|
const uint32_t& aWidth,
|
|
|
|
const uint32_t& aHeight,
|
|
|
|
const uint32_t& aStride,
|
|
|
|
const uint8_t& aFormat,
|
|
|
|
const uint32_t& aHotspotX,
|
|
|
|
const uint32_t& aHotspotY,
|
|
|
|
const bool& aForce)
|
|
|
|
{
|
|
|
|
mCursor = nsCursor(-1);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
if (aForce) {
|
|
|
|
widget->ClearCachedCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mTabSetsCursor) {
|
2015-09-23 21:49:05 +03:00
|
|
|
const gfx::IntSize size(aWidth, aHeight);
|
2015-05-20 04:28:57 +03:00
|
|
|
|
2016-05-09 01:33:00 +03:00
|
|
|
RefPtr<gfx::DataSourceSurface> customCursor =
|
|
|
|
gfx::CreateDataSourceSurfaceFromData(size,
|
|
|
|
static_cast<gfx::SurfaceFormat>(aFormat),
|
|
|
|
reinterpret_cast<const uint8_t*>(aCursorData.BeginReading()),
|
|
|
|
aStride);
|
2015-05-20 04:28:57 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxDrawable> drawable = new gfxSurfaceDrawable(customCursor, size);
|
2015-05-20 04:28:57 +03:00
|
|
|
nsCOMPtr<imgIContainer> cursorImage(image::ImageOps::CreateFromDrawable(drawable));
|
|
|
|
widget->SetCursor(cursorImage, aHotspotX, aHotspotY);
|
|
|
|
mCustomCursor = cursorImage;
|
|
|
|
mCustomCursorHotspotX = aHotspotX;
|
|
|
|
mCustomCursorHotspotY = aHotspotY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-20 04:28:57 +03:00
|
|
|
}
|
|
|
|
|
2014-01-23 00:27:23 +04:00
|
|
|
nsIXULBrowserWindow*
|
|
|
|
TabParent::GetXULBrowserWindow()
|
|
|
|
{
|
2016-08-16 04:04:04 +03:00
|
|
|
if (!mFrameElement) {
|
2014-01-23 00:27:23 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-08-16 04:04:04 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
|
2014-01-23 00:27:23 +04:00
|
|
|
if (!docShell) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
if (!treeOwner) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULWindow> window = do_GetInterface(treeOwner);
|
|
|
|
if (!window) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
|
|
|
|
window->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
|
|
|
return xulBrowserWindow;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-07-25 23:45:31 +04:00
|
|
|
TabParent::RecvSetStatus(const uint32_t& aType, const nsString& aStatus)
|
|
|
|
{
|
2014-01-23 00:27:23 +04:00
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow = GetXULBrowserWindow();
|
|
|
|
if (!xulBrowserWindow) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-07-25 23:45:31 +04:00
|
|
|
}
|
2014-01-23 00:27:23 +04:00
|
|
|
|
|
|
|
switch (aType) {
|
|
|
|
case nsIWebBrowserChrome::STATUS_SCRIPT:
|
|
|
|
xulBrowserWindow->SetJSStatus(aStatus);
|
|
|
|
break;
|
|
|
|
case nsIWebBrowserChrome::STATUS_LINK:
|
|
|
|
xulBrowserWindow->SetOverLink(aStatus, nullptr);
|
|
|
|
break;
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-01-23 00:27:23 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-04-12 23:47:25 +03:00
|
|
|
TabParent::RecvShowTooltip(const uint32_t& aX, const uint32_t& aY, const nsString& aTooltip,
|
|
|
|
const nsString& aDirection)
|
2014-01-23 00:27:23 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow = GetXULBrowserWindow();
|
|
|
|
if (!xulBrowserWindow) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-01-23 00:27:23 +04:00
|
|
|
}
|
|
|
|
|
2017-08-02 01:01:06 +03:00
|
|
|
nsCOMPtr<nsIFrameLoaderOwner> frame = do_QueryInterface(mFrameElement);
|
|
|
|
if (!frame)
|
|
|
|
return IPC_OK();
|
|
|
|
|
|
|
|
xulBrowserWindow->ShowTooltip(aX, aY, aTooltip, aDirection, frame);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-01-23 00:27:23 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-01-23 00:27:23 +04:00
|
|
|
TabParent::RecvHideTooltip()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow = GetXULBrowserWindow();
|
|
|
|
if (!xulBrowserWindow) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-01-23 00:27:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
xulBrowserWindow->HideTooltip();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-07-25 23:45:31 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-07-17 07:30:01 +03:00
|
|
|
TabParent::RecvNotifyIMEFocus(const ContentCache& aContentCache,
|
|
|
|
const IMENotification& aIMENotification,
|
2017-04-11 15:24:55 +03:00
|
|
|
IMENotificationRequests* aRequests)
|
2010-09-24 07:28:15 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
2012-11-13 17:04:44 +04:00
|
|
|
if (!widget) {
|
2017-04-11 15:24:55 +03:00
|
|
|
*aRequests = IMENotificationRequests();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-11-13 17:04:44 +04:00
|
|
|
}
|
2010-09-24 07:28:15 +04:00
|
|
|
|
2016-06-14 15:06:34 +03:00
|
|
|
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
|
2017-07-05 18:47:40 +03:00
|
|
|
IMEStateManager::NotifyIME(aIMENotification, widget, this);
|
2010-09-24 07:28:15 +04:00
|
|
|
|
2015-07-17 07:30:01 +03:00
|
|
|
if (aIMENotification.mMessage == NOTIFY_IME_OF_FOCUS) {
|
Bug 1217700 part.1 nsIWidget should return reference to IMENotificationRequests r=m_kato
IMEContentObserver may need to change notifications to send when TextInputProcessor begins input transaction. In current design, IMEContentObserver needs to retrieve IMENotificationRequests at every change. However, if nsIWidget returns a reference to its IMENotificationRequests, IMEContentObserver can call it only once.
For that purpose, this patch changes nsIWidget::GetIMENotificationRequests() to nsIWidget::IMENotificationRequestsRef() and make it return |const IMENotificationRequests&|. However, if the lifetime of the instance of IMENotificationRequest is shorter than the widget instance's, it's dangerous. Therefore, it always returns TextEventDispatcher::mIMENotificationRequests. TextEventDispatcher's lifetime is longer than the widget. Therefore, this guarantees the lifetime.
On the other hand, widget needs to update TextEventDispatcher::mIMENotificationRequests before calls of nsIWidget::IMENotificationRequestsRef(). Therefore, this patch makes TextEventDispatcher update proper IMENotificationRequests when it gets focus or starts new input transaction and clear mIMENotificationRequests when it loses focus.
Note that TextEventDispatcher gets proper requests both from native text event dispatcher listener (typically, implemented by native IME handler class) and TextInputProcessor when TextInputProcessor has input transaction because even if TextInputProcessor overrides native IME, native IME still needs to know the content changes since they may get new input transaction after that.
However, there may not be native IME handler in content process. If it runs in Android, PuppetWidget may have native IME handler because widget directly handles IME in e10s mode for Android. Otherwise, native IME handler is in its parent process. So, if TextInputHandler has input transaction in content process, PuppetWidget needs to behave as native event handler. Therefore, this patch makes PuppetWidget inherit TextEventDispatcherListener and implements PuppetWidget::IMENotificationRequestsRef().
MozReview-Commit-ID: 2SW3moONTOX
--HG--
extra : rebase_source : d2634ada6c33dbf7a966fadb68608411ee24bfab
2017-04-14 19:35:58 +03:00
|
|
|
*aRequests = widget->IMENotificationRequestsRef();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-06-05 12:28:20 +03:00
|
|
|
TabParent::RecvNotifyIMETextChange(const ContentCache& aContentCache,
|
2015-07-17 07:30:01 +03:00
|
|
|
const IMENotification& aIMENotification)
|
2010-09-24 07:28:15 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
2017-01-19 11:57:20 +03:00
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2017-01-19 11:57:20 +03:00
|
|
|
}
|
2010-09-24 07:28:15 +04:00
|
|
|
|
2014-02-26 04:48:02 +04:00
|
|
|
#ifdef DEBUG
|
Bug 1217700 part.1 nsIWidget should return reference to IMENotificationRequests r=m_kato
IMEContentObserver may need to change notifications to send when TextInputProcessor begins input transaction. In current design, IMEContentObserver needs to retrieve IMENotificationRequests at every change. However, if nsIWidget returns a reference to its IMENotificationRequests, IMEContentObserver can call it only once.
For that purpose, this patch changes nsIWidget::GetIMENotificationRequests() to nsIWidget::IMENotificationRequestsRef() and make it return |const IMENotificationRequests&|. However, if the lifetime of the instance of IMENotificationRequest is shorter than the widget instance's, it's dangerous. Therefore, it always returns TextEventDispatcher::mIMENotificationRequests. TextEventDispatcher's lifetime is longer than the widget. Therefore, this guarantees the lifetime.
On the other hand, widget needs to update TextEventDispatcher::mIMENotificationRequests before calls of nsIWidget::IMENotificationRequestsRef(). Therefore, this patch makes TextEventDispatcher update proper IMENotificationRequests when it gets focus or starts new input transaction and clear mIMENotificationRequests when it loses focus.
Note that TextEventDispatcher gets proper requests both from native text event dispatcher listener (typically, implemented by native IME handler class) and TextInputProcessor when TextInputProcessor has input transaction because even if TextInputProcessor overrides native IME, native IME still needs to know the content changes since they may get new input transaction after that.
However, there may not be native IME handler in content process. If it runs in Android, PuppetWidget may have native IME handler because widget directly handles IME in e10s mode for Android. Otherwise, native IME handler is in its parent process. So, if TextInputHandler has input transaction in content process, PuppetWidget needs to behave as native event handler. Therefore, this patch makes PuppetWidget inherit TextEventDispatcherListener and implements PuppetWidget::IMENotificationRequestsRef().
MozReview-Commit-ID: 2SW3moONTOX
--HG--
extra : rebase_source : d2634ada6c33dbf7a966fadb68608411ee24bfab
2017-04-14 19:35:58 +03:00
|
|
|
const IMENotificationRequests& requests =
|
|
|
|
widget->IMENotificationRequestsRef();
|
2017-04-11 15:24:55 +03:00
|
|
|
NS_ASSERTION(requests.WantTextChange(),
|
2017-01-19 11:57:20 +03:00
|
|
|
"Don't call Send/RecvNotifyIMETextChange without NOTIFY_TEXT_CHANGE");
|
2014-02-26 04:48:02 +04:00
|
|
|
#endif
|
2014-01-29 13:32:39 +04:00
|
|
|
|
2016-06-14 15:06:34 +03:00
|
|
|
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
|
2015-07-17 07:30:01 +03:00
|
|
|
mContentCache.MaybeNotifyIME(widget, aIMENotification);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-07-17 07:30:01 +03:00
|
|
|
TabParent::RecvNotifyIMECompositionUpdate(
|
|
|
|
const ContentCache& aContentCache,
|
|
|
|
const IMENotification& aIMENotification)
|
2013-11-07 04:11:11 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-11-07 04:11:11 +04:00
|
|
|
}
|
2016-06-14 15:06:34 +03:00
|
|
|
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
|
2015-07-17 07:30:01 +03:00
|
|
|
mContentCache.MaybeNotifyIME(widget, aIMENotification);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-11-07 04:11:11 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-06-05 12:28:20 +03:00
|
|
|
TabParent::RecvNotifyIMESelection(const ContentCache& aContentCache,
|
2015-07-17 07:30:01 +03:00
|
|
|
const IMENotification& aIMENotification)
|
2010-09-24 07:28:15 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
2017-01-19 11:57:20 +03:00
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2017-01-19 11:57:20 +03:00
|
|
|
}
|
2016-06-14 15:06:34 +03:00
|
|
|
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
|
2015-10-10 04:21:01 +03:00
|
|
|
mContentCache.MaybeNotifyIME(widget, aIMENotification);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-06-05 12:28:20 +03:00
|
|
|
TabParent::RecvUpdateContentCache(const ContentCache& aContentCache)
|
2010-09-24 07:28:15 +04:00
|
|
|
{
|
2015-06-05 12:28:20 +03:00
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-05 12:28:20 +03:00
|
|
|
}
|
|
|
|
|
2016-06-14 15:06:34 +03:00
|
|
|
mContentCache.AssignContent(aContentCache, widget);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-09-11 17:46:17 +04:00
|
|
|
TabParent::RecvNotifyIMEMouseButtonEvent(
|
|
|
|
const IMENotification& aIMENotification,
|
|
|
|
bool* aConsumedByIME)
|
|
|
|
{
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
|
|
|
*aConsumedByIME = false;
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-09-11 17:46:17 +04:00
|
|
|
}
|
2017-07-05 18:47:40 +03:00
|
|
|
nsresult rv = IMEStateManager::NotifyIME(aIMENotification, widget, this);
|
2014-09-11 17:46:17 +04:00
|
|
|
*aConsumedByIME = rv == NS_SUCCESS_EVENT_CONSUMED;
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-09-11 17:46:17 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-07-17 07:30:01 +03:00
|
|
|
TabParent::RecvNotifyIMEPositionChange(const ContentCache& aContentCache,
|
|
|
|
const IMENotification& aIMENotification)
|
2014-12-15 12:37:00 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-12-15 12:37:00 +03:00
|
|
|
}
|
2016-06-14 15:06:34 +03:00
|
|
|
mContentCache.AssignContent(aContentCache, widget, &aIMENotification);
|
2015-10-10 04:21:01 +03:00
|
|
|
mContentCache.MaybeNotifyIME(widget, aIMENotification);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-12-15 12:37:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-08-26 15:56:59 +03:00
|
|
|
TabParent::RecvOnEventNeedingAckHandled(const EventMessage& aMessage)
|
2015-07-11 04:53:55 +03:00
|
|
|
{
|
|
|
|
// This is called when the child process receives WidgetCompositionEvent or
|
|
|
|
// WidgetSelectionEvent.
|
2017-06-27 17:41:12 +03:00
|
|
|
// FYI: Don't check if widget is nullptr here because it's more important to
|
|
|
|
// notify mContentCahce of this than handling something in it.
|
2015-07-11 04:53:55 +03:00
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
|
2015-07-22 08:51:36 +03:00
|
|
|
// While calling OnEventNeedingAckHandled(), TabParent *might* be destroyed
|
2015-07-11 04:53:55 +03:00
|
|
|
// since it may send notifications to IME.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent> kungFuDeathGrip(this);
|
2015-07-22 08:51:36 +03:00
|
|
|
mContentCache.OnEventNeedingAckHandled(widget, aMessage);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-07-11 04:53:55 +03:00
|
|
|
}
|
|
|
|
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
void
|
|
|
|
TabParent::HandledWindowedPluginKeyEvent(const NativeEventData& aKeyEventData,
|
|
|
|
bool aIsConsumed)
|
|
|
|
{
|
2016-09-02 10:12:24 +03:00
|
|
|
DebugOnly<bool> ok =
|
|
|
|
SendHandledWindowedPluginKeyEvent(aKeyEventData, aIsConsumed);
|
|
|
|
NS_WARNING_ASSERTION(ok, "SendHandledWindowedPluginKeyEvent failed");
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
TabParent::RecvOnWindowedPluginKeyEvent(const NativeEventData& aKeyEventData)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (NS_WARN_IF(!widget)) {
|
|
|
|
// Notifies the plugin process of the key event being not consumed by us.
|
|
|
|
HandledWindowedPluginKeyEvent(aKeyEventData, false);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
}
|
|
|
|
nsresult rv = widget->OnWindowedPluginKeyEvent(aKeyEventData, this);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
// Notifies the plugin process of the key event being not consumed by us.
|
|
|
|
HandledWindowedPluginKeyEvent(aKeyEventData, false);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the key event is posted to another process, we need to wait a call
|
|
|
|
// of HandledWindowedPluginKeyEvent(). So, nothing to do here in this case.
|
|
|
|
if (rv == NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, the key event is handled synchronously. Let's notify the
|
|
|
|
// plugin process of the key event's result.
|
|
|
|
bool consumed = (rv == NS_SUCCESS_EVENT_CONSUMED);
|
|
|
|
HandledWindowedPluginKeyEvent(aKeyEventData, consumed);
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-09-21 02:07:51 +04:00
|
|
|
TabParent::RecvRequestFocus(const bool& aCanRaise)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFocusManager> fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (!fm) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-09-21 02:07:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement);
|
|
|
|
if (!content || !content->OwnerDoc()) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-09-21 02:07:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t flags = nsIFocusManager::FLAG_NOSCROLL;
|
|
|
|
if (aCanRaise)
|
|
|
|
flags |= nsIFocusManager::FLAG_RAISE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> node = do_QueryInterface(mFrameElement);
|
|
|
|
fm->SetFocus(node, flags);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-09-21 02:07:51 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-12-09 18:48:27 +03:00
|
|
|
TabParent::RecvEnableDisableCommands(const nsString& aAction,
|
2015-01-16 22:58:52 +03:00
|
|
|
nsTArray<nsCString>&& aEnabledCommands,
|
|
|
|
nsTArray<nsCString>&& aDisabledCommands)
|
2014-12-09 18:48:27 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIRemoteBrowser> remoteBrowser = do_QueryInterface(mFrameElement);
|
|
|
|
if (remoteBrowser) {
|
2015-11-03 21:29:19 +03:00
|
|
|
UniquePtr<const char*[]> enabledCommands, disabledCommands;
|
2014-12-09 18:48:27 +03:00
|
|
|
|
|
|
|
if (aEnabledCommands.Length()) {
|
2015-11-03 21:29:19 +03:00
|
|
|
enabledCommands = MakeUnique<const char*[]>(aEnabledCommands.Length());
|
2014-12-09 18:48:27 +03:00
|
|
|
for (uint32_t c = 0; c < aEnabledCommands.Length(); c++) {
|
|
|
|
enabledCommands[c] = aEnabledCommands[c].get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDisabledCommands.Length()) {
|
2015-11-03 21:29:19 +03:00
|
|
|
disabledCommands = MakeUnique<const char*[]>(aDisabledCommands.Length());
|
2014-12-09 18:48:27 +03:00
|
|
|
for (uint32_t c = 0; c < aDisabledCommands.Length(); c++) {
|
|
|
|
disabledCommands[c] = aDisabledCommands[c].get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
remoteBrowser->EnableDisableCommands(aAction,
|
2015-11-03 21:29:19 +03:00
|
|
|
aEnabledCommands.Length(), enabledCommands.get(),
|
|
|
|
aDisabledCommands.Length(), disabledCommands.get());
|
2014-12-09 18:48:27 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-12-09 18:48:27 +03:00
|
|
|
}
|
|
|
|
|
2015-02-17 05:41:49 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetChildProcessOffset(int32_t* aOutCssX, int32_t* aOutCssY)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aOutCssX);
|
|
|
|
NS_ENSURE_ARG(aOutCssY);
|
|
|
|
CSSPoint offset = LayoutDevicePoint(GetChildProcessOffset())
|
|
|
|
* GetLayoutDeviceToCSSScale();
|
|
|
|
*aOutCssX = offset.x;
|
|
|
|
*aOutCssY = offset.y;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-15 21:52:28 +03:00
|
|
|
LayoutDeviceIntPoint
|
2013-11-22 06:58:20 +04:00
|
|
|
TabParent::GetChildProcessOffset()
|
|
|
|
{
|
|
|
|
// The "toplevel widget" in child processes is always at position
|
|
|
|
// 0,0. Map the event coordinates to match that.
|
|
|
|
|
2015-02-15 21:52:28 +03:00
|
|
|
LayoutDeviceIntPoint offset(0, 0);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
2013-11-22 06:58:20 +04:00
|
|
|
if (!frameLoader) {
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
nsIFrame* targetFrame = frameLoader->GetPrimaryFrameOfOwningContent();
|
|
|
|
if (!targetFrame) {
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2017-07-14 01:33:25 +03:00
|
|
|
nsPresContext* presContext = targetFrame->PresContext();
|
|
|
|
nsIFrame* rootFrame = presContext->PresShell()->FrameManager()->GetRootFrame();
|
|
|
|
nsView* rootView = rootFrame ? rootFrame->GetView() : nullptr;
|
|
|
|
if (!rootView) {
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note that we don't want to take into account transforms here:
|
|
|
|
#if 0
|
|
|
|
nsPoint pt(0, 0);
|
|
|
|
nsLayoutUtils::TransformPoint(targetFrame, rootFrame, pt);
|
|
|
|
#endif
|
|
|
|
// In practice, when transforms are applied to this frameLoader, we currently
|
|
|
|
// get the wrong results whether we take transforms into account here or not.
|
|
|
|
// But applying transforms here gives us the wrong results in all
|
|
|
|
// circumstances when transforms are applied, unless they're purely
|
|
|
|
// translational. It also gives us the wrong results whenever CSS transitions
|
|
|
|
// are used to apply transforms, since the offeets aren't updated as the
|
|
|
|
// transition is animated.
|
|
|
|
//
|
|
|
|
// What we actually need to do is apply the transforms to the coordinates of
|
|
|
|
// any events we send to the child, and reverse them for any screen
|
|
|
|
// coordinates that we retrieve from the child.
|
|
|
|
|
|
|
|
nsPoint pt = targetFrame->GetOffsetTo(rootFrame);
|
|
|
|
return -nsLayoutUtils::TranslateViewToWidget(presContext, rootView, pt, widget);
|
2013-11-22 06:58:20 +04:00
|
|
|
}
|
|
|
|
|
2017-07-14 01:31:55 +03:00
|
|
|
LayoutDeviceIntPoint
|
|
|
|
TabParent::GetClientOffset()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
nsCOMPtr<nsIWidget> docWidget = GetDocWidget();
|
|
|
|
|
|
|
|
if (widget == docWidget) {
|
|
|
|
return widget->GetClientOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (docWidget->GetClientOffset() +
|
|
|
|
nsLayoutUtils::WidgetToWidgetOffset(widget, docWidget));
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-01-19 11:27:15 +03:00
|
|
|
TabParent::RecvReplyKeyEvent(const WidgetKeyboardEvent& aEvent)
|
2014-03-18 19:16:47 +04:00
|
|
|
{
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mFrameElement, IPC_OK());
|
2014-03-18 19:16:47 +04:00
|
|
|
|
2017-01-19 11:27:15 +03:00
|
|
|
WidgetKeyboardEvent localEvent(aEvent);
|
2017-07-05 07:58:41 +03:00
|
|
|
localEvent.MarkAsHandledInRemoteProcess();
|
2014-03-18 19:16:47 +04:00
|
|
|
|
|
|
|
// Here we convert the WidgetEvent that we received to an nsIDOMEvent
|
|
|
|
// to be able to dispatch it to the <browser> element as the target element.
|
|
|
|
nsIDocument* doc = mFrameElement->OwnerDoc();
|
|
|
|
nsIPresShell* presShell = doc->GetShell();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(presShell, IPC_OK());
|
2014-03-18 19:16:47 +04:00
|
|
|
nsPresContext* presContext = presShell->GetPresContext();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(presContext, IPC_OK());
|
2014-03-18 19:16:47 +04:00
|
|
|
|
2016-07-25 16:08:49 +03:00
|
|
|
AutoHandlingUserInputStatePusher userInpStatePusher(localEvent.IsTrusted(),
|
|
|
|
&localEvent, doc);
|
|
|
|
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
|
|
|
|
// Handle access key in this process before dispatching reply event because
|
|
|
|
// ESM handles it before dispatching the event to the DOM tree.
|
|
|
|
if (localEvent.mMessage == eKeyPress &&
|
|
|
|
(localEvent.ModifiersMatchWithAccessKey(AccessKeyType::eChrome) ||
|
|
|
|
localEvent.ModifiersMatchWithAccessKey(AccessKeyType::eContent))) {
|
|
|
|
RefPtr<EventStateManager> esm = presContext->EventStateManager();
|
|
|
|
AutoTArray<uint32_t, 10> accessCharCodes;
|
|
|
|
localEvent.GetAccessKeyCandidates(accessCharCodes);
|
|
|
|
if (esm->HandleAccessKey(&localEvent, presContext, accessCharCodes)) {
|
|
|
|
status = nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EventDispatcher::Dispatch(mFrameElement, presContext, &localEvent, nullptr,
|
|
|
|
&status);
|
2017-05-16 05:59:35 +03:00
|
|
|
|
|
|
|
if (!localEvent.DefaultPrevented() &&
|
|
|
|
!localEvent.mFlags.mIsSynthesizedForTests) {
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
widget->PostHandleKeyEvent(&localEvent);
|
|
|
|
localEvent.StopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-03-18 19:16:47 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-05-11 15:56:42 +03:00
|
|
|
TabParent::RecvAccessKeyNotHandled(const WidgetKeyboardEvent& aEvent)
|
|
|
|
{
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mFrameElement, IPC_OK());
|
2016-05-11 15:56:42 +03:00
|
|
|
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
// This is called only when this process had focus and HandleAccessKey
|
|
|
|
// message was posted to all remote process and each remote process didn't
|
|
|
|
// execute any content access keys.
|
|
|
|
// XXX If there were two or more remote processes, this may be called
|
|
|
|
// twice or more for a keyboard event, that must be a bug. But how to
|
|
|
|
// detect if received event has already been handled?
|
|
|
|
|
2016-05-11 15:56:42 +03:00
|
|
|
WidgetKeyboardEvent localEvent(aEvent);
|
2017-07-05 07:58:41 +03:00
|
|
|
localEvent.MarkAsHandledInRemoteProcess();
|
2016-05-11 15:56:42 +03:00
|
|
|
localEvent.mMessage = eAccessKeyNotFound;
|
|
|
|
|
|
|
|
// Here we convert the WidgetEvent that we received to an nsIDOMEvent
|
|
|
|
// to be able to dispatch it to the <browser> element as the target element.
|
|
|
|
nsIDocument* doc = mFrameElement->OwnerDoc();
|
|
|
|
nsIPresShell* presShell = doc->GetShell();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(presShell, IPC_OK());
|
2016-05-11 15:56:42 +03:00
|
|
|
|
|
|
|
if (presShell->CanDispatchEvent()) {
|
|
|
|
nsPresContext* presContext = presShell->GetPresContext();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(presContext, IPC_OK());
|
2016-05-11 15:56:42 +03:00
|
|
|
|
|
|
|
EventDispatcher::Dispatch(mFrameElement, presContext, &localEvent);
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-05-11 15:56:42 +03:00
|
|
|
}
|
|
|
|
|
2017-04-14 00:54:07 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
TabParent::RecvSetHasBeforeUnload(const bool& aHasBeforeUnload)
|
|
|
|
{
|
|
|
|
mHasBeforeUnload = aHasBeforeUnload;
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2010-09-24 07:28:15 +04:00
|
|
|
bool
|
2013-10-01 11:23:00 +04:00
|
|
|
TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent)
|
2010-09-24 07:28:15 +04:00
|
|
|
{
|
2015-06-05 12:28:19 +03:00
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (NS_WARN_IF(!mContentCache.HandleQueryContentEvent(aEvent, widget)) ||
|
|
|
|
NS_WARN_IF(!aEvent.mSucceeded)) {
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (aEvent.mMessage) {
|
2015-09-11 15:21:26 +03:00
|
|
|
case eQueryTextRect:
|
2015-09-10 04:40:06 +03:00
|
|
|
case eQueryCaretRect:
|
2015-09-10 04:40:06 +03:00
|
|
|
case eQueryEditorRect:
|
2015-06-05 12:28:19 +03:00
|
|
|
aEvent.mReply.mRect -= GetChildProcessOffset();
|
2015-06-05 12:28:19 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-24 07:34:26 +04:00
|
|
|
bool
|
2017-01-19 11:27:15 +03:00
|
|
|
TabParent::SendCompositionEvent(WidgetCompositionEvent& aEvent)
|
2010-09-24 07:34:26 +04:00
|
|
|
{
|
2012-11-10 10:09:24 +04:00
|
|
|
if (mIsDestroyed) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-10-07 14:01:50 +04:00
|
|
|
|
2017-01-19 11:27:15 +03:00
|
|
|
if (!mContentCache.OnCompositionEvent(aEvent)) {
|
2010-09-24 07:34:26 +04:00
|
|
|
return true;
|
2015-02-17 05:30:55 +03:00
|
|
|
}
|
2017-07-05 12:59:44 +03:00
|
|
|
if (NS_WARN_IF(!PBrowserParent::SendCompositionEvent(aEvent))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(aEvent.HasBeenPostedToRemoteProcess());
|
|
|
|
return true;
|
2010-09-24 07:34:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-01-19 11:27:15 +03:00
|
|
|
TabParent::SendSelectionEvent(WidgetSelectionEvent& aEvent)
|
2010-09-24 07:34:26 +04:00
|
|
|
{
|
2012-11-10 10:09:24 +04:00
|
|
|
if (mIsDestroyed) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-05 12:28:20 +03:00
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
|
|
|
return true;
|
|
|
|
}
|
2017-01-19 11:27:15 +03:00
|
|
|
mContentCache.OnSelectionEvent(aEvent);
|
|
|
|
if (NS_WARN_IF(!PBrowserParent::SendSelectionEvent(aEvent))) {
|
2015-07-17 05:25:00 +03:00
|
|
|
return false;
|
|
|
|
}
|
2017-07-05 12:59:44 +03:00
|
|
|
MOZ_ASSERT(aEvent.HasBeenPostedToRemoteProcess());
|
2017-01-19 11:27:15 +03:00
|
|
|
aEvent.mSucceeded = true;
|
2015-07-17 05:25:00 +03:00
|
|
|
return true;
|
2010-09-24 07:34:26 +04:00
|
|
|
}
|
|
|
|
|
2016-08-31 04:30:45 +03:00
|
|
|
bool
|
|
|
|
TabParent::SendPasteTransferable(const IPCDataTransfer& aDataTransfer,
|
|
|
|
const bool& aIsPrivateData,
|
|
|
|
const IPC::Principal& aRequestingPrincipal)
|
|
|
|
{
|
|
|
|
return PBrowserParent::SendPasteTransferable(aDataTransfer,
|
|
|
|
aIsPrivateData,
|
|
|
|
aRequestingPrincipal);
|
|
|
|
}
|
|
|
|
|
2012-06-23 05:27:30 +04:00
|
|
|
/*static*/ TabParent*
|
|
|
|
TabParent::GetFrom(nsFrameLoader* aFrameLoader)
|
|
|
|
{
|
|
|
|
if (!aFrameLoader) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-06-23 05:27:30 +04:00
|
|
|
}
|
|
|
|
PBrowserParent* remoteBrowser = aFrameLoader->GetRemoteBrowser();
|
|
|
|
return static_cast<TabParent*>(remoteBrowser);
|
|
|
|
}
|
|
|
|
|
2015-02-06 00:47:32 +03:00
|
|
|
/*static*/ TabParent*
|
|
|
|
TabParent::GetFrom(nsIFrameLoader* aFrameLoader)
|
|
|
|
{
|
|
|
|
if (!aFrameLoader)
|
|
|
|
return nullptr;
|
|
|
|
return GetFrom(static_cast<nsFrameLoader*>(aFrameLoader));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ TabParent*
|
|
|
|
TabParent::GetFrom(nsITabParent* aTabParent)
|
|
|
|
{
|
|
|
|
return static_cast<TabParent*>(aTabParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ TabParent*
|
|
|
|
TabParent::GetFrom(PBrowserParent* aTabParent)
|
|
|
|
{
|
|
|
|
return static_cast<TabParent*>(aTabParent);
|
|
|
|
}
|
|
|
|
|
2012-06-23 05:27:30 +04:00
|
|
|
/*static*/ TabParent*
|
|
|
|
TabParent::GetFrom(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFrameLoaderOwner> loaderOwner = do_QueryInterface(aContent);
|
|
|
|
if (!loaderOwner) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-06-23 05:27:30 +04:00
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameLoader> frameLoader = loaderOwner->GetFrameLoader();
|
2012-06-23 05:27:30 +04:00
|
|
|
return GetFrom(frameLoader);
|
|
|
|
}
|
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
/*static*/ TabId
|
|
|
|
TabParent::GetTabIdFrom(nsIDocShell *docShell)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsITabChild> tabChild(TabChild::GetFrom(docShell));
|
|
|
|
if (tabChild) {
|
|
|
|
return static_cast<TabChild*>(tabChild.get())->GetTabId();
|
|
|
|
}
|
|
|
|
return TabId(0);
|
|
|
|
}
|
|
|
|
|
2012-07-20 10:48:27 +04:00
|
|
|
RenderFrameParent*
|
|
|
|
TabParent::GetRenderFrame()
|
|
|
|
{
|
2016-08-23 02:00:34 +03:00
|
|
|
PRenderFrameParent* p = LoneManagedOrNullAsserts(ManagedPRenderFrameParent());
|
2016-07-23 02:36:45 +03:00
|
|
|
RenderFrameParent* frame = static_cast<RenderFrameParent*>(p);
|
|
|
|
|
|
|
|
return frame;
|
2012-07-20 10:48:27 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-12-11 09:15:58 +03:00
|
|
|
TabParent::RecvRequestIMEToCommitComposition(const bool& aCancel,
|
|
|
|
bool* aIsCommitted,
|
|
|
|
nsString* aCommittedString)
|
2010-09-24 07:28:15 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
2015-06-05 12:28:19 +03:00
|
|
|
if (!widget) {
|
2015-12-11 09:15:58 +03:00
|
|
|
*aIsCommitted = false;
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-05 12:28:19 +03:00
|
|
|
}
|
2015-12-11 09:15:58 +03:00
|
|
|
|
|
|
|
*aIsCommitted =
|
|
|
|
mContentCache.RequestIMEToCommitComposition(widget, aCancel,
|
|
|
|
*aCommittedString);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-02-20 19:37:02 +03:00
|
|
|
TabParent::RecvStartPluginIME(const WidgetKeyboardEvent& aKeyboardEvent,
|
|
|
|
const int32_t& aPanelX, const int32_t& aPanelY,
|
|
|
|
nsString* aCommitted)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-02-20 19:37:02 +03:00
|
|
|
}
|
2016-12-16 02:55:18 +03:00
|
|
|
Unused << widget->StartPluginIME(aKeyboardEvent,
|
|
|
|
(int32_t&)aPanelX,
|
|
|
|
(int32_t&)aPanelY,
|
|
|
|
*aCommitted);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-02-20 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-02-20 19:37:02 +03:00
|
|
|
TabParent::RecvSetPluginFocused(const bool& aFocused)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-02-20 19:37:02 +03:00
|
|
|
}
|
|
|
|
widget->SetPluginFocused((bool&)aFocused);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-02-20 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-02-02 11:05:56 +03:00
|
|
|
TabParent::RecvSetCandidateWindowForPlugin(
|
|
|
|
const CandidateWindowPosition& aPosition)
|
2015-12-29 16:57:38 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-12-29 16:57:38 +03:00
|
|
|
}
|
|
|
|
|
2016-02-02 11:05:56 +03:00
|
|
|
widget->SetCandidateWindowForPlugin(aPosition);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-12-29 16:57:38 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-12-29 16:57:38 +03:00
|
|
|
TabParent::RecvDefaultProcOfPluginEvent(const WidgetPluginEvent& aEvent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-12-29 16:57:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
widget->DefaultProcOfPluginEvent(aEvent);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-12-29 16:57:38 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-08-22 19:56:38 +04:00
|
|
|
TabParent::RecvGetInputContext(int32_t* aIMEEnabled,
|
2015-12-11 09:15:57 +03:00
|
|
|
int32_t* aIMEOpen)
|
2010-09-24 07:28:15 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
2011-06-30 01:24:47 +04:00
|
|
|
if (!widget) {
|
2011-11-27 15:51:53 +04:00
|
|
|
*aIMEEnabled = IMEState::DISABLED;
|
|
|
|
*aIMEOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-06-30 01:24:47 +04:00
|
|
|
}
|
2010-11-23 09:48:45 +03:00
|
|
|
|
2011-11-27 15:51:52 +04:00
|
|
|
InputContext context = widget->GetInputContext();
|
2012-08-22 19:56:38 +04:00
|
|
|
*aIMEEnabled = static_cast<int32_t>(context.mIMEState.mEnabled);
|
|
|
|
*aIMEOpen = static_cast<int32_t>(context.mIMEState.mOpen);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-08-22 19:56:38 +04:00
|
|
|
TabParent::RecvSetInputContext(const int32_t& aIMEEnabled,
|
|
|
|
const int32_t& aIMEOpen,
|
2011-11-27 15:51:52 +04:00
|
|
|
const nsString& aType,
|
2012-08-27 06:16:22 +04:00
|
|
|
const nsString& aInputmode,
|
2011-11-27 15:51:52 +04:00
|
|
|
const nsString& aActionHint,
|
2012-08-22 19:56:38 +04:00
|
|
|
const int32_t& aCause,
|
|
|
|
const int32_t& aFocusChange)
|
2010-09-24 07:28:15 +04:00
|
|
|
{
|
2011-11-27 15:51:52 +04:00
|
|
|
InputContext context;
|
2011-11-27 15:51:53 +04:00
|
|
|
context.mIMEState.mEnabled = static_cast<IMEState::Enabled>(aIMEEnabled);
|
|
|
|
context.mIMEState.mOpen = static_cast<IMEState::Open>(aIMEOpen);
|
2010-11-23 09:48:03 +03:00
|
|
|
context.mHTMLInputType.Assign(aType);
|
2012-08-27 06:16:22 +04:00
|
|
|
context.mHTMLInputInputmode.Assign(aInputmode);
|
2011-11-27 15:51:52 +04:00
|
|
|
context.mActionHint.Assign(aActionHint);
|
2014-08-28 09:06:41 +04:00
|
|
|
context.mOrigin = InputContext::ORIGIN_CONTENT;
|
|
|
|
|
2011-11-27 15:51:52 +04:00
|
|
|
InputContextAction action(
|
|
|
|
static_cast<InputContextAction::Cause>(aCause),
|
|
|
|
static_cast<InputContextAction::FocusChange>(aFocusChange));
|
2010-11-23 09:48:03 +03:00
|
|
|
|
2015-07-01 16:19:11 +03:00
|
|
|
IMEStateManager::SetInputContextForChildProcess(this, context, action);
|
2010-10-18 20:37:00 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-04-05 01:50:42 +04:00
|
|
|
TabParent::RecvIsParentWindowMainWidgetVisible(bool* aIsVisible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> frame = do_QueryInterface(mFrameElement);
|
|
|
|
if (!frame)
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-04-05 01:50:42 +04:00
|
|
|
nsCOMPtr<nsIDOMWindowUtils> windowUtils =
|
|
|
|
do_QueryInterface(frame->OwnerDoc()->GetWindow());
|
|
|
|
nsresult rv = windowUtils->GetIsParentWindowMainWidgetVisible(aIsVisible);
|
2016-11-15 06:26:00 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2014-04-05 01:50:42 +04:00
|
|
|
}
|
|
|
|
|
2015-07-09 17:48:57 +03:00
|
|
|
already_AddRefed<nsIWidget>
|
|
|
|
TabParent::GetTopLevelWidget()
|
2011-07-22 04:49:35 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement);
|
|
|
|
if (content) {
|
2011-10-18 15:19:44 +04:00
|
|
|
nsIPresShell* shell = content->OwnerDoc()->GetShell();
|
|
|
|
if (shell) {
|
2013-01-05 07:12:24 +04:00
|
|
|
nsViewManager* vm = shell->GetViewManager();
|
2011-10-18 15:19:44 +04:00
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
vm->GetRootWidget(getter_AddRefs(widget));
|
2015-07-09 17:48:57 +03:00
|
|
|
return widget.forget();
|
2011-07-22 04:49:35 +04:00
|
|
|
}
|
|
|
|
}
|
2015-07-09 17:48:57 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-08-12 18:00:26 +03:00
|
|
|
TabParent::RecvSetNativeChildOfShareableWindow(const uintptr_t& aChildWindow)
|
|
|
|
{
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetTopLevelWidget();
|
|
|
|
if (widget) {
|
|
|
|
// Note that this call will probably cause a sync native message to the
|
|
|
|
// process that owns the child window.
|
|
|
|
widget->SetNativeData(NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW, aChildWindow);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-08-12 18:00:26 +03:00
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
|
|
|
"TabParent::RecvSetNativeChildOfShareableWindow not implemented!");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2015-08-12 18:00:26 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-07-09 17:48:57 +03:00
|
|
|
TabParent::RecvDispatchFocusToTopLevelWindow()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetTopLevelWidget();
|
|
|
|
if (widget) {
|
|
|
|
widget->SetFocus(false);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-07-22 04:49:35 +04:00
|
|
|
}
|
|
|
|
|
2010-03-30 00:29:45 +04:00
|
|
|
bool
|
|
|
|
TabParent::ReceiveMessage(const nsString& aMessage,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aSync,
|
2015-09-10 23:50:58 +03:00
|
|
|
StructuredCloneData* aData,
|
2013-07-11 02:05:39 +04:00
|
|
|
CpowHolder* aCpows,
|
2013-11-06 21:21:15 +04:00
|
|
|
nsIPrincipal* aPrincipal,
|
2015-09-10 23:50:58 +03:00
|
|
|
nsTArray<StructuredCloneData>* aRetVal)
|
2010-02-20 20:05:20 +03:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader(true);
|
2010-08-06 02:11:23 +04:00
|
|
|
if (frameLoader && frameLoader->GetFrameMessageManager()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameMessageManager> manager =
|
2011-06-16 22:21:08 +04:00
|
|
|
frameLoader->GetFrameMessageManager();
|
2010-08-06 02:11:23 +04:00
|
|
|
|
|
|
|
manager->ReceiveMessage(mFrameElement,
|
2015-04-16 18:17:54 +03:00
|
|
|
frameLoader,
|
2010-08-06 02:11:23 +04:00
|
|
|
aMessage,
|
|
|
|
aSync,
|
2015-09-10 23:50:58 +03:00
|
|
|
aData,
|
2013-07-11 02:05:39 +04:00
|
|
|
aCpows,
|
2013-11-06 21:21:15 +04:00
|
|
|
aPrincipal,
|
2015-04-30 06:39:59 +03:00
|
|
|
aRetVal);
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:20:42 +04:00
|
|
|
// nsIAuthPromptProvider
|
|
|
|
|
|
|
|
// This method is largely copied from nsDocShell::GetAuthPrompt
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabParent::GetAuthPrompt(uint32_t aPromptReason, const nsIID& iid,
|
2010-06-25 02:20:42 +04:00
|
|
|
void** aResult)
|
|
|
|
{
|
|
|
|
// we're either allowing auth, or it's a proxy request
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIPromptFactory> wwatch =
|
|
|
|
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window;
|
2010-06-25 02:20:42 +04:00
|
|
|
nsCOMPtr<nsIContent> frame = do_QueryInterface(mFrameElement);
|
|
|
|
if (frame)
|
2016-01-30 20:05:36 +03:00
|
|
|
window = frame->OwnerDoc()->GetWindow();
|
2010-06-25 02:20:42 +04:00
|
|
|
|
|
|
|
// Get an auth prompter for our window so that the parenting
|
|
|
|
// of the dialogs works as it should when using tabs.
|
2014-11-04 22:51:06 +03:00
|
|
|
nsCOMPtr<nsISupports> prompt;
|
|
|
|
rv = wwatch->GetPrompt(window, iid, getter_AddRefs(prompt));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsILoginManagerPrompter> prompter = do_QueryInterface(prompt);
|
|
|
|
if (prompter) {
|
|
|
|
nsCOMPtr<nsIDOMElement> browser = do_QueryInterface(mFrameElement);
|
2016-08-30 16:47:38 +03:00
|
|
|
prompter->SetBrowser(browser);
|
2014-11-04 22:51:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = prompt.forget().take();
|
|
|
|
return NS_OK;
|
2010-06-25 02:20:42 +04:00
|
|
|
}
|
|
|
|
|
2014-02-24 00:19:43 +04:00
|
|
|
PColorPickerParent*
|
|
|
|
TabParent::AllocPColorPickerParent(const nsString& aTitle,
|
|
|
|
const nsString& aInitialColor)
|
|
|
|
{
|
|
|
|
return new ColorPickerParent(aTitle, aInitialColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabParent::DeallocPColorPickerParent(PColorPickerParent* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
2016-06-20 16:55:00 +03:00
|
|
|
}
|
|
|
|
|
2014-01-16 01:10:39 +04:00
|
|
|
PRenderFrameParent*
|
2014-11-16 21:23:22 +03:00
|
|
|
TabParent::AllocPRenderFrameParent()
|
2014-01-16 01:10:39 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(ManagedPRenderFrameParent().IsEmpty());
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
2015-07-22 00:34:36 +03:00
|
|
|
|
2017-03-31 18:43:21 +03:00
|
|
|
RenderFrameParent* rfp = new RenderFrameParent(frameLoader);
|
|
|
|
if (rfp->IsInitted()) {
|
2017-03-31 18:43:21 +03:00
|
|
|
uint64_t layersId = rfp->GetLayersId();
|
2014-12-19 02:23:39 +03:00
|
|
|
AddTabParentToTable(layersId, this);
|
2014-11-16 21:23:22 +03:00
|
|
|
}
|
2017-03-31 18:43:21 +03:00
|
|
|
return rfp;
|
2010-08-21 03:24:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
TabParent::DeallocPRenderFrameParent(PRenderFrameParent* aFrame)
|
2010-08-21 03:24:41 +04:00
|
|
|
{
|
|
|
|
delete aFrame;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-16 21:23:22 +03:00
|
|
|
bool
|
2016-03-29 21:32:41 +03:00
|
|
|
TabParent::SetRenderFrame(PRenderFrameParent* aRFParent)
|
2014-11-16 21:23:22 +03:00
|
|
|
{
|
2016-03-29 21:32:41 +03:00
|
|
|
if (IsInitedByParent()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
|
|
|
|
|
|
|
if (!frameLoader) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
RenderFrameParent* renderFrame = static_cast<RenderFrameParent*>(aRFParent);
|
|
|
|
bool success = renderFrame->Init(frameLoader);
|
|
|
|
if (!success) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-21 00:24:40 +03:00
|
|
|
frameLoader->MaybeShowFrame();
|
|
|
|
|
2016-03-29 21:32:41 +03:00
|
|
|
uint64_t layersId = renderFrame->GetLayersId();
|
|
|
|
AddTabParentToTable(layersId, this);
|
2015-03-11 01:21:02 +03:00
|
|
|
|
2015-07-10 19:38:44 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-29 21:32:41 +03:00
|
|
|
bool
|
|
|
|
TabParent::GetRenderFrameInfo(TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
|
|
|
uint64_t* aLayersId)
|
|
|
|
{
|
|
|
|
RenderFrameParent* rfp = GetRenderFrame();
|
|
|
|
if (!rfp) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aLayersId = rfp->GetLayersId();
|
|
|
|
rfp->GetTextureFactoryIdentifier(aTextureFactoryIdentifier);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-06 02:11:23 +04:00
|
|
|
already_AddRefed<nsFrameLoader>
|
2015-02-27 08:35:26 +03:00
|
|
|
TabParent::GetFrameLoader(bool aUseCachedFrameLoaderAfterDestroy) const
|
2010-08-06 02:11:23 +04:00
|
|
|
{
|
2015-02-27 08:35:26 +03:00
|
|
|
if (mIsDestroyed && !aUseCachedFrameLoaderAfterDestroy) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mFrameLoader) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameLoader> fl = mFrameLoader;
|
2015-02-27 08:35:26 +03:00
|
|
|
return fl.forget();
|
|
|
|
}
|
2010-08-06 02:11:23 +04:00
|
|
|
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(mFrameElement);
|
2012-07-30 18:20:58 +04:00
|
|
|
return frameLoaderOwner ? frameLoaderOwner->GetFrameLoader() : nullptr;
|
2010-08-06 02:11:23 +04:00
|
|
|
}
|
|
|
|
|
2012-04-25 20:35:58 +04:00
|
|
|
void
|
2013-05-02 03:06:19 +04:00
|
|
|
TabParent::TryCacheDPIAndScale()
|
2012-04-25 20:35:58 +04:00
|
|
|
{
|
|
|
|
if (mDPI > 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
2012-05-08 20:20:35 +04:00
|
|
|
|
2012-04-25 20:35:58 +04:00
|
|
|
if (widget) {
|
|
|
|
mDPI = widget->GetDPI();
|
2016-09-27 09:37:07 +03:00
|
|
|
mRounding = widget->RoundsWidgetCoordinatesTo();
|
2013-05-02 03:06:19 +04:00
|
|
|
mDefaultScale = widget->GetDefaultScale();
|
2012-04-25 20:35:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-24 07:28:15 +04:00
|
|
|
already_AddRefed<nsIWidget>
|
|
|
|
TabParent::GetWidget() const
|
|
|
|
{
|
2015-06-18 16:19:31 +03:00
|
|
|
if (!mFrameElement) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2015-06-18 16:19:31 +03:00
|
|
|
}
|
2017-04-18 07:41:18 +03:00
|
|
|
nsCOMPtr<nsIWidget> widget = nsContentUtils::WidgetForContent(mFrameElement);
|
2017-05-29 23:16:23 +03:00
|
|
|
if (!widget) {
|
|
|
|
widget = nsContentUtils::WidgetForDocument(mFrameElement->OwnerDoc());
|
|
|
|
}
|
2012-04-25 20:35:58 +04:00
|
|
|
return widget.forget();
|
2010-09-24 07:28:15 +04:00
|
|
|
}
|
|
|
|
|
2017-07-14 01:31:55 +03:00
|
|
|
already_AddRefed<nsIWidget>
|
|
|
|
TabParent::GetDocWidget() const
|
|
|
|
{
|
|
|
|
if (!mFrameElement) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return do_AddRef(nsContentUtils::WidgetForDocument(mFrameElement->OwnerDoc()));
|
|
|
|
}
|
|
|
|
|
2015-02-07 00:46:46 +03:00
|
|
|
void
|
|
|
|
TabParent::ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid,
|
2015-05-14 15:16:00 +03:00
|
|
|
uint64_t* aOutInputBlockId,
|
|
|
|
nsEventStatus* aOutApzResponse)
|
2012-07-20 10:48:27 +04:00
|
|
|
{
|
2015-11-27 19:33:50 +03:00
|
|
|
// Let the widget know that the event will be sent to the child process,
|
|
|
|
// which will (hopefully) send a confirmation notice back to APZ.
|
|
|
|
// Do this even if APZ is off since we need it for swipe gesture support on
|
|
|
|
// OS X without APZ.
|
|
|
|
InputAPZContext::SetRoutedToChildProcess();
|
|
|
|
|
2015-06-04 23:51:10 +03:00
|
|
|
if (AsyncPanZoomEnabled()) {
|
2014-12-16 10:31:12 +03:00
|
|
|
if (aOutTargetGuid) {
|
|
|
|
*aOutTargetGuid = InputAPZContext::GetTargetLayerGuid();
|
2015-02-06 17:26:44 +03:00
|
|
|
|
|
|
|
// There may be cases where the APZ hit-testing code came to a different
|
|
|
|
// conclusion than the main-thread hit-testing code as to where the event
|
|
|
|
// is destined. In such cases the layersId of the APZ result may not match
|
|
|
|
// the layersId of this renderframe. In such cases the main-thread hit-
|
|
|
|
// testing code "wins" so we need to update the guid to reflect this.
|
|
|
|
if (RenderFrameParent* rfp = GetRenderFrame()) {
|
|
|
|
if (aOutTargetGuid->mLayersId != rfp->GetLayersId()) {
|
|
|
|
*aOutTargetGuid = ScrollableLayerGuid(rfp->GetLayersId(), 0, FrameMetrics::NULL_SCROLL_ID);
|
|
|
|
}
|
|
|
|
}
|
2014-12-16 10:31:12 +03:00
|
|
|
}
|
|
|
|
if (aOutInputBlockId) {
|
|
|
|
*aOutInputBlockId = InputAPZContext::GetInputBlockId();
|
|
|
|
}
|
2015-05-14 15:16:00 +03:00
|
|
|
if (aOutApzResponse) {
|
|
|
|
*aOutApzResponse = InputAPZContext::GetApzResponse();
|
|
|
|
}
|
2015-06-15 19:18:50 +03:00
|
|
|
} else {
|
|
|
|
if (aOutInputBlockId) {
|
|
|
|
*aOutInputBlockId = 0;
|
|
|
|
}
|
|
|
|
if (aOutApzResponse) {
|
|
|
|
*aOutApzResponse = nsEventStatus_eIgnore;
|
|
|
|
}
|
2012-07-20 10:48:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-06-13 02:01:25 +04:00
|
|
|
TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
|
2016-03-31 07:58:05 +03:00
|
|
|
PRenderFrameParent* aRenderFrame,
|
2012-06-13 02:01:25 +04:00
|
|
|
const nsString& aURL,
|
|
|
|
const nsString& aName,
|
|
|
|
const nsString& aFeatures,
|
2017-06-15 20:28:11 +03:00
|
|
|
BrowserFrameOpenWindowResolver&& aResolve)
|
2012-06-13 02:01:25 +04:00
|
|
|
{
|
2017-06-15 20:28:11 +03:00
|
|
|
CreatedWindowInfo cwi;
|
|
|
|
cwi.rv() = NS_OK;
|
|
|
|
cwi.layersId() = 0;
|
|
|
|
cwi.maxTouchPoints() = 0;
|
|
|
|
|
2013-09-10 08:18:46 +04:00
|
|
|
BrowserElementParent::OpenWindowResult opened =
|
2015-02-06 00:47:32 +03:00
|
|
|
BrowserElementParent::OpenWindowOOP(TabParent::GetFrom(aOpener),
|
2016-03-31 07:58:05 +03:00
|
|
|
this, aRenderFrame, aURL, aName, aFeatures,
|
2017-06-15 20:28:11 +03:00
|
|
|
&cwi.textureFactoryIdentifier(),
|
|
|
|
&cwi.layersId());
|
|
|
|
cwi.compositorOptions() =
|
|
|
|
static_cast<RenderFrameParent*>(aRenderFrame)->GetCompositorOptions();
|
|
|
|
cwi.windowOpened() = (opened == BrowserElementParent::OPEN_WINDOW_ADDED);
|
2017-03-15 02:48:41 +03:00
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
2017-06-15 20:28:11 +03:00
|
|
|
if (widget) {
|
|
|
|
cwi.maxTouchPoints() = widget->GetMaxTouchPoints();
|
|
|
|
cwi.dimensions() = GetDimensionInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resolve the request with the information we collected.
|
|
|
|
aResolve(cwi);
|
|
|
|
|
|
|
|
if (!cwi.windowOpened()) {
|
2016-09-02 11:03:19 +03:00
|
|
|
Destroy();
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-06-13 02:01:25 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-08-28 08:10:48 +03:00
|
|
|
TabParent::RecvRespondStartSwipeEvent(const uint64_t& aInputBlockId,
|
|
|
|
const bool& aStartSwipe)
|
|
|
|
{
|
|
|
|
if (nsCOMPtr<nsIWidget> widget = GetWidget()) {
|
|
|
|
widget->ReportSwipeStarted(aInputBlockId, aStartSwipe);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-08-28 08:10:48 +03:00
|
|
|
}
|
|
|
|
|
2014-01-11 05:10:57 +04:00
|
|
|
already_AddRefed<nsILoadContext>
|
|
|
|
TabParent::GetLoadContext()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext;
|
|
|
|
if (mLoadContext) {
|
|
|
|
loadContext = mLoadContext;
|
|
|
|
} else {
|
2016-06-03 00:02:29 +03:00
|
|
|
bool isPrivate = mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
|
|
|
|
SetPrivateBrowsingAttributes(isPrivate);
|
2017-02-14 17:53:21 +03:00
|
|
|
bool useTrackingProtection = false;
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
|
|
|
|
if (docShell) {
|
|
|
|
docShell->GetUseTrackingProtection(&useTrackingProtection);
|
|
|
|
}
|
2014-01-11 05:10:57 +04:00
|
|
|
loadContext = new LoadContext(GetOwnerElement(),
|
|
|
|
true /* aIsContent */,
|
2016-06-03 00:02:29 +03:00
|
|
|
isPrivate,
|
2014-02-11 21:00:54 +04:00
|
|
|
mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW,
|
2017-02-14 17:53:21 +03:00
|
|
|
useTrackingProtection,
|
2015-11-03 13:53:41 +03:00
|
|
|
OriginAttributesRef());
|
2014-01-11 05:10:57 +04:00
|
|
|
mLoadContext = loadContext;
|
|
|
|
}
|
|
|
|
return loadContext.forget();
|
|
|
|
}
|
|
|
|
|
2014-01-24 13:02:23 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetUseAsyncPanZoom(bool* useAsyncPanZoom)
|
|
|
|
{
|
2015-06-04 23:51:10 +03:00
|
|
|
*useAsyncPanZoom = AsyncPanZoomEnabled();
|
2014-01-24 13:02:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-04 16:42:01 +03:00
|
|
|
// defined in nsITabParent
|
2014-02-20 15:26:13 +04:00
|
|
|
NS_IMETHODIMP
|
2015-09-04 16:42:01 +03:00
|
|
|
TabParent::SetDocShellIsActive(bool isActive)
|
2014-02-20 15:26:13 +04:00
|
|
|
{
|
2016-07-23 02:36:45 +03:00
|
|
|
// Increment the epoch so that layer tree updates from previous
|
|
|
|
// SetDocShellIsActive requests are ignored.
|
|
|
|
mLayerTreeEpoch++;
|
|
|
|
|
2016-05-20 06:36:27 +03:00
|
|
|
// docshell is consider prerendered only if not active yet
|
|
|
|
mIsPrerendered &= !isActive;
|
2015-09-04 16:42:01 +03:00
|
|
|
mDocShellIsActive = isActive;
|
2016-07-23 02:36:45 +03:00
|
|
|
Unused << SendSetDocShellIsActive(isActive, mPreserveLayers, mLayerTreeEpoch);
|
|
|
|
|
2017-06-07 10:59:00 +03:00
|
|
|
// Let's inform the priority manager. This operation can end up with the
|
|
|
|
// changing of the process priority.
|
|
|
|
ProcessPriorityManager::TabActivityChanged(this, isActive);
|
|
|
|
|
2016-07-23 02:36:45 +03:00
|
|
|
// Ask the child to repaint using the PHangMonitor channel/thread (which may
|
|
|
|
// be less congested).
|
|
|
|
if (isActive) {
|
2016-12-22 00:09:09 +03:00
|
|
|
ContentParent* cp = Manager()->AsContentParent();
|
|
|
|
cp->ForceTabPaint(this, mLayerTreeEpoch);
|
2016-07-23 02:36:45 +03:00
|
|
|
}
|
|
|
|
|
2015-09-04 16:42:01 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetDocShellIsActive(bool* aIsActive)
|
|
|
|
{
|
|
|
|
*aIsActive = mDocShellIsActive;
|
2014-02-20 15:26:13 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-05-20 06:36:27 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetIsPrerendered(bool* aIsPrerendered)
|
|
|
|
{
|
|
|
|
*aIsPrerendered = mIsPrerendered;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-11-10 05:38:21 +03:00
|
|
|
NS_IMETHODIMP
|
2016-07-23 02:36:45 +03:00
|
|
|
TabParent::PreserveLayers(bool aPreserveLayers)
|
2015-11-10 05:38:21 +03:00
|
|
|
{
|
2016-07-23 02:36:45 +03:00
|
|
|
mPreserveLayers = aPreserveLayers;
|
2015-11-10 05:38:21 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-08-20 00:08:41 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::SuppressDisplayport(bool aEnabled)
|
|
|
|
{
|
|
|
|
if (IsDestroyed()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-02-26 18:52:06 +03:00
|
|
|
#ifdef DEBUG
|
2015-08-20 00:08:41 +03:00
|
|
|
if (aEnabled) {
|
|
|
|
mActiveSupressDisplayportCount++;
|
|
|
|
} else {
|
|
|
|
mActiveSupressDisplayportCount--;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mActiveSupressDisplayportCount >= 0);
|
2016-02-26 18:52:06 +03:00
|
|
|
#endif
|
2015-08-20 00:08:41 +03:00
|
|
|
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendSuppressDisplayport(aEnabled);
|
2015-08-20 00:08:41 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-01-22 12:40:17 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetTabId(uint64_t* aId)
|
|
|
|
{
|
|
|
|
*aId = GetTabId();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-08-01 13:26:48 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetOsPid(int32_t* aId)
|
|
|
|
{
|
|
|
|
*aId = Manager()->Pid();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-13 23:44:39 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetHasContentOpener(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mHasContentOpener;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabParent::SetHasContentOpener(bool aHasContentOpener)
|
|
|
|
{
|
|
|
|
mHasContentOpener = aHasContentOpener;
|
|
|
|
}
|
|
|
|
|
2017-03-04 22:19:22 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetHasPresented(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mHasPresented;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-13 13:07:49 +03:00
|
|
|
NS_IMETHODIMP
|
2015-07-23 17:04:15 +03:00
|
|
|
TabParent::NavigateByKey(bool aForward, bool aForDocumentNavigation)
|
2015-07-13 13:07:49 +03:00
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNavigateByKey(aForward, aForDocumentNavigation);
|
2015-07-13 13:07:49 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-18 00:04:44 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::TransmitPermissionsForPrincipal(nsIPrincipal* aPrincipal)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContentParent> manager = Manager();
|
|
|
|
if (!manager->IsContentParent()) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return manager->AsContentParent()
|
|
|
|
->TransmitPermissionsForPrincipal(aPrincipal);
|
|
|
|
}
|
|
|
|
|
2017-04-14 00:54:07 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::GetHasBeforeUnload(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mHasBeforeUnload;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class LayerTreeUpdateRunnable final
|
2016-04-26 03:23:21 +03:00
|
|
|
: public mozilla::Runnable
|
2015-02-27 08:30:44 +03:00
|
|
|
{
|
2016-07-23 02:36:45 +03:00
|
|
|
uint64_t mLayersId;
|
|
|
|
uint64_t mEpoch;
|
2015-02-27 08:30:44 +03:00
|
|
|
bool mActive;
|
|
|
|
|
|
|
|
public:
|
2017-06-12 22:34:10 +03:00
|
|
|
explicit LayerTreeUpdateRunnable(uint64_t aLayersId,
|
|
|
|
uint64_t aEpoch,
|
|
|
|
bool aActive)
|
|
|
|
: Runnable("dom::LayerTreeUpdateRunnable")
|
|
|
|
, mLayersId(aLayersId)
|
|
|
|
, mEpoch(aEpoch)
|
|
|
|
, mActive(aActive)
|
2016-05-11 04:16:41 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(!NS_IsMainThread());
|
|
|
|
}
|
2015-02-27 08:30:44 +03:00
|
|
|
|
|
|
|
private:
|
2016-08-08 05:18:10 +03:00
|
|
|
NS_IMETHOD Run() override {
|
2015-02-27 08:30:44 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2016-07-23 02:36:45 +03:00
|
|
|
if (RefPtr<TabParent> tabParent = TabParent::GetTabParentFromLayersId(mLayersId)) {
|
|
|
|
tabParent->LayerTreeUpdate(mEpoch, mActive);
|
2015-02-27 08:30:44 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-07-23 02:36:45 +03:00
|
|
|
void
|
|
|
|
TabParent::LayerTreeUpdate(uint64_t aEpoch, bool aActive)
|
2016-08-23 02:00:34 +03:00
|
|
|
{
|
2016-07-23 02:36:45 +03:00
|
|
|
// Ignore updates from old epochs. They might tell us that layers are
|
|
|
|
// available when we've already sent a message to clear them. We can't trust
|
|
|
|
// the update in that case since layers could disappear anytime after that.
|
|
|
|
if (aEpoch != mLayerTreeEpoch || mIsDestroyed) {
|
|
|
|
return;
|
2016-08-23 02:00:34 +03:00
|
|
|
}
|
|
|
|
|
2015-02-27 08:30:44 +03:00
|
|
|
nsCOMPtr<mozilla::dom::EventTarget> target = do_QueryInterface(mFrameElement);
|
|
|
|
if (!target) {
|
|
|
|
NS_WARNING("Could not locate target for layer tree message.");
|
2016-07-23 02:36:45 +03:00
|
|
|
return;
|
2015-02-27 08:30:44 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Event> event = NS_NewDOMEvent(mFrameElement, nullptr, nullptr);
|
2015-02-27 08:30:44 +03:00
|
|
|
if (aActive) {
|
2017-03-04 22:12:38 +03:00
|
|
|
mHasPresented = true;
|
2015-02-27 08:30:44 +03:00
|
|
|
event->InitEvent(NS_LITERAL_STRING("MozLayerTreeReady"), true, false);
|
|
|
|
} else {
|
|
|
|
event->InitEvent(NS_LITERAL_STRING("MozLayerTreeCleared"), true, false);
|
|
|
|
}
|
|
|
|
event->SetTrusted(true);
|
2016-02-12 18:40:07 +03:00
|
|
|
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
|
2015-02-27 08:30:44 +03:00
|
|
|
bool dummy;
|
|
|
|
mFrameElement->DispatchEvent(event, &dummy);
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-07-23 02:36:45 +03:00
|
|
|
TabParent::RecvForcePaintNoOp(const uint64_t& aLayerObserverEpoch)
|
2015-04-14 03:06:03 +03:00
|
|
|
{
|
2016-07-23 02:36:45 +03:00
|
|
|
// We sent a ForcePaint message when layers were already visible. In this
|
|
|
|
// case, we should act as if an update occurred even though we already have
|
|
|
|
// the layers.
|
|
|
|
LayerTreeUpdate(aLayerObserverEpoch, true);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 03:06:03 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-05-23 22:19:00 +04:00
|
|
|
TabParent::RecvRemotePaintIsReady()
|
|
|
|
{
|
|
|
|
nsCOMPtr<mozilla::dom::EventTarget> target = do_QueryInterface(mFrameElement);
|
|
|
|
if (!target) {
|
|
|
|
NS_WARNING("Could not locate target for MozAfterRemotePaint message.");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-05-23 22:19:00 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Event> event = NS_NewDOMEvent(mFrameElement, nullptr, nullptr);
|
2014-05-23 22:19:00 +04:00
|
|
|
event->InitEvent(NS_LITERAL_STRING("MozAfterRemotePaint"), false, false);
|
|
|
|
event->SetTrusted(true);
|
2016-02-12 18:40:07 +03:00
|
|
|
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
|
2014-05-23 22:19:00 +04:00
|
|
|
bool dummy;
|
|
|
|
mFrameElement->DispatchEvent(event, &dummy);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-05-23 22:19:00 +04:00
|
|
|
}
|
|
|
|
|
2014-11-12 23:59:19 +03:00
|
|
|
mozilla::plugins::PPluginWidgetParent*
|
|
|
|
TabParent::AllocPPluginWidgetParent()
|
|
|
|
{
|
2017-02-09 19:53:50 +03:00
|
|
|
#ifdef XP_WIN
|
2014-11-12 23:59:19 +03:00
|
|
|
return new mozilla::plugins::PluginWidgetParent();
|
2017-02-09 19:53:50 +03:00
|
|
|
#else
|
|
|
|
MOZ_ASSERT_UNREACHABLE();
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabParent::DeallocPPluginWidgetParent(mozilla::plugins::PPluginWidgetParent* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-05-25 20:50:32 +03:00
|
|
|
PPaymentRequestParent*
|
|
|
|
TabParent::AllocPPaymentRequestParent()
|
|
|
|
{
|
|
|
|
RefPtr<PaymentRequestParent> actor = new PaymentRequestParent(GetTabId());
|
|
|
|
return actor.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabParent::DeallocPPaymentRequestParent(PPaymentRequestParent* aActor)
|
|
|
|
{
|
|
|
|
RefPtr<PaymentRequestParent> actor =
|
|
|
|
dont_AddRef(static_cast<PaymentRequestParent*>(aActor));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-31 23:39:02 +03:00
|
|
|
nsresult
|
|
|
|
TabParent::HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
|
|
|
|
|
|
|
if (eventType.EqualsLiteral("MozUpdateWindowPos") && !mIsDestroyed) {
|
|
|
|
// This event is sent when the widget moved. Therefore we only update
|
|
|
|
// the position.
|
2015-04-21 17:33:56 +03:00
|
|
|
return UpdatePosition();
|
2015-03-31 23:39:02 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class FakeChannel final : public nsIChannel,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIAuthPromptCallback,
|
|
|
|
public nsIInterfaceRequestor,
|
|
|
|
public nsILoadContext
|
2014-06-11 09:44:36 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FakeChannel(const nsCString& aUri, uint64_t aCallbackId, Element* aElement)
|
|
|
|
: mCallbackId(aCallbackId)
|
|
|
|
, mElement(aElement)
|
|
|
|
{
|
|
|
|
NS_NewURI(getter_AddRefs(mUri), aUri);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2015-03-21 19:28:04 +03:00
|
|
|
#define NO_IMPL override { return NS_ERROR_NOT_IMPLEMENTED; }
|
2014-06-11 09:44:36 +04:00
|
|
|
NS_IMETHOD GetName(nsACString&) NO_IMPL
|
|
|
|
NS_IMETHOD IsPending(bool*) NO_IMPL
|
|
|
|
NS_IMETHOD GetStatus(nsresult*) NO_IMPL
|
|
|
|
NS_IMETHOD Cancel(nsresult) NO_IMPL
|
|
|
|
NS_IMETHOD Suspend() NO_IMPL
|
|
|
|
NS_IMETHOD Resume() NO_IMPL
|
|
|
|
NS_IMETHOD GetLoadGroup(nsILoadGroup**) NO_IMPL
|
|
|
|
NS_IMETHOD SetLoadGroup(nsILoadGroup*) NO_IMPL
|
|
|
|
NS_IMETHOD SetLoadFlags(nsLoadFlags) NO_IMPL
|
|
|
|
NS_IMETHOD GetLoadFlags(nsLoadFlags*) NO_IMPL
|
2017-04-20 05:15:06 +03:00
|
|
|
NS_IMETHOD GetIsDocument(bool *) NO_IMPL
|
2014-06-11 09:44:36 +04:00
|
|
|
NS_IMETHOD GetOriginalURI(nsIURI**) NO_IMPL
|
|
|
|
NS_IMETHOD SetOriginalURI(nsIURI*) NO_IMPL
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetURI(nsIURI** aUri) override
|
2014-06-11 09:44:36 +04:00
|
|
|
{
|
2015-04-19 20:22:35 +03:00
|
|
|
nsCOMPtr<nsIURI> copy = mUri;
|
|
|
|
copy.forget(aUri);
|
2014-06-11 09:44:36 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHOD GetOwner(nsISupports**) NO_IMPL
|
|
|
|
NS_IMETHOD SetOwner(nsISupports*) NO_IMPL
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetLoadInfo(nsILoadInfo** aLoadInfo) override
|
2014-07-10 10:56:36 +04:00
|
|
|
{
|
2015-04-19 20:22:35 +03:00
|
|
|
nsCOMPtr<nsILoadInfo> copy = mLoadInfo;
|
|
|
|
copy.forget(aLoadInfo);
|
2014-07-10 10:56:36 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetLoadInfo(nsILoadInfo* aLoadInfo) override
|
2014-07-10 10:56:36 +04:00
|
|
|
{
|
|
|
|
mLoadInfo = aLoadInfo;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor** aRequestor) override
|
2014-06-11 09:44:36 +04:00
|
|
|
{
|
|
|
|
NS_ADDREF(*aRequestor = this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor*) NO_IMPL
|
|
|
|
NS_IMETHOD GetSecurityInfo(nsISupports**) NO_IMPL
|
|
|
|
NS_IMETHOD GetContentType(nsACString&) NO_IMPL
|
|
|
|
NS_IMETHOD SetContentType(const nsACString&) NO_IMPL
|
|
|
|
NS_IMETHOD GetContentCharset(nsACString&) NO_IMPL
|
|
|
|
NS_IMETHOD SetContentCharset(const nsACString&) NO_IMPL
|
|
|
|
NS_IMETHOD GetContentLength(int64_t*) NO_IMPL
|
|
|
|
NS_IMETHOD SetContentLength(int64_t) NO_IMPL
|
|
|
|
NS_IMETHOD Open(nsIInputStream**) NO_IMPL
|
2015-05-15 23:21:20 +03:00
|
|
|
NS_IMETHOD Open2(nsIInputStream**) NO_IMPL
|
2014-06-11 09:44:36 +04:00
|
|
|
NS_IMETHOD AsyncOpen(nsIStreamListener*, nsISupports*) NO_IMPL
|
2015-05-15 23:21:20 +03:00
|
|
|
NS_IMETHOD AsyncOpen2(nsIStreamListener*) NO_IMPL
|
2014-06-11 09:44:36 +04:00
|
|
|
NS_IMETHOD GetContentDisposition(uint32_t*) NO_IMPL
|
|
|
|
NS_IMETHOD SetContentDisposition(uint32_t) NO_IMPL
|
|
|
|
NS_IMETHOD GetContentDispositionFilename(nsAString&) NO_IMPL
|
|
|
|
NS_IMETHOD SetContentDispositionFilename(const nsAString&) NO_IMPL
|
|
|
|
NS_IMETHOD GetContentDispositionHeader(nsACString&) NO_IMPL
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo) override;
|
|
|
|
NS_IMETHOD OnAuthCancelled(nsISupports *aContext, bool userCancel) override;
|
|
|
|
NS_IMETHOD GetInterface(const nsIID & uuid, void **result) override
|
2014-06-11 09:44:36 +04:00
|
|
|
{
|
|
|
|
return QueryInterface(uuid, result);
|
|
|
|
}
|
2016-01-30 20:05:36 +03:00
|
|
|
NS_IMETHOD GetAssociatedWindow(mozIDOMWindowProxy**) NO_IMPL
|
|
|
|
NS_IMETHOD GetTopWindow(mozIDOMWindowProxy**) NO_IMPL
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetTopFrameElement(nsIDOMElement** aElement) override
|
2014-06-11 09:44:36 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(mElement);
|
|
|
|
elem.forget(aElement);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHOD GetNestedFrameId(uint64_t*) NO_IMPL
|
|
|
|
NS_IMETHOD GetIsContent(bool*) NO_IMPL
|
|
|
|
NS_IMETHOD GetUsePrivateBrowsing(bool*) NO_IMPL
|
|
|
|
NS_IMETHOD SetUsePrivateBrowsing(bool) NO_IMPL
|
|
|
|
NS_IMETHOD SetPrivateBrowsing(bool) NO_IMPL
|
2016-02-18 05:55:57 +03:00
|
|
|
NS_IMETHOD GetIsInIsolatedMozBrowserElement(bool*) NO_IMPL
|
2017-03-18 23:08:12 +03:00
|
|
|
NS_IMETHOD GetScriptableOriginAttributes(JS::MutableHandleValue) NO_IMPL
|
|
|
|
NS_IMETHOD_(void) GetOriginAttributes(mozilla::OriginAttributes& aAttrs) override {}
|
2014-06-11 09:44:36 +04:00
|
|
|
NS_IMETHOD GetUseRemoteTabs(bool*) NO_IMPL
|
|
|
|
NS_IMETHOD SetRemoteTabs(bool) NO_IMPL
|
2017-02-14 17:53:21 +03:00
|
|
|
NS_IMETHOD GetUseTrackingProtection(bool*) NO_IMPL
|
|
|
|
NS_IMETHOD SetUseTrackingProtection(bool) NO_IMPL
|
2014-06-11 09:44:36 +04:00
|
|
|
#undef NO_IMPL
|
|
|
|
|
|
|
|
protected:
|
2014-06-23 23:56:07 +04:00
|
|
|
~FakeChannel() {}
|
|
|
|
|
2014-06-11 09:44:36 +04:00
|
|
|
nsCOMPtr<nsIURI> mUri;
|
|
|
|
uint64_t mCallbackId;
|
|
|
|
nsCOMPtr<Element> mElement;
|
2014-07-10 10:56:36 +04:00
|
|
|
nsCOMPtr<nsILoadInfo> mLoadInfo;
|
2014-06-11 09:44:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(FakeChannel, nsIChannel, nsIAuthPromptCallback,
|
|
|
|
nsIRequest, nsIInterfaceRequestor, nsILoadContext);
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-06-11 09:44:36 +04:00
|
|
|
TabParent::RecvAsyncAuthPrompt(const nsCString& aUri,
|
|
|
|
const nsString& aRealm,
|
|
|
|
const uint64_t& aCallbackId)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAuthPrompt2> authPrompt;
|
|
|
|
GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL,
|
|
|
|
NS_GET_IID(nsIAuthPrompt2),
|
|
|
|
getter_AddRefs(authPrompt));
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<FakeChannel> channel = new FakeChannel(aUri, aCallbackId, mFrameElement);
|
2014-06-11 09:44:36 +04:00
|
|
|
uint32_t promptFlags = nsIAuthInformation::AUTH_HOST;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsAuthInformationHolder> holder =
|
2014-06-11 09:44:36 +04:00
|
|
|
new nsAuthInformationHolder(promptFlags, aRealm,
|
|
|
|
EmptyCString());
|
|
|
|
|
|
|
|
uint32_t level = nsIAuthPrompt2::LEVEL_NONE;
|
|
|
|
nsCOMPtr<nsICancelable> dummy;
|
|
|
|
nsresult rv =
|
|
|
|
authPrompt->AsyncPromptAuth(channel, channel, nullptr,
|
|
|
|
level, holder, getter_AddRefs(dummy));
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2014-06-11 09:44:36 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-04-08 21:48:11 +03:00
|
|
|
TabParent::RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers,
|
|
|
|
const uint32_t& aAction,
|
2016-06-15 15:49:13 +03:00
|
|
|
const OptionalShmem& aVisualDnDData,
|
2015-04-08 21:48:11 +03:00
|
|
|
const uint32_t& aStride, const uint8_t& aFormat,
|
2016-10-19 22:01:39 +03:00
|
|
|
const LayoutDeviceIntRect& aDragRect)
|
2015-04-08 21:48:11 +03:00
|
|
|
{
|
|
|
|
mInitialDataTransferItems.Clear();
|
2015-08-01 03:03:37 +03:00
|
|
|
nsIPresShell* shell = mFrameElement->OwnerDoc()->GetShell();
|
|
|
|
if (!shell) {
|
|
|
|
if (Manager()->IsContentParent()) {
|
2016-05-19 00:17:34 +03:00
|
|
|
Unused << Manager()->AsContentParent()->SendEndDragSession(true, true,
|
2017-02-17 06:29:42 +03:00
|
|
|
LayoutDeviceIntPoint(),
|
|
|
|
0);
|
2015-08-01 03:03:37 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-08-01 03:03:37 +03:00
|
|
|
}
|
2015-04-08 21:48:11 +03:00
|
|
|
|
2015-08-01 03:03:37 +03:00
|
|
|
EventStateManager* esm = shell->GetPresContext()->EventStateManager();
|
2015-04-08 21:48:11 +03:00
|
|
|
for (uint32_t i = 0; i < aTransfers.Length(); ++i) {
|
2016-02-24 03:31:29 +03:00
|
|
|
mInitialDataTransferItems.AppendElement(mozilla::Move(aTransfers[i].items()));
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
|
|
|
if (Manager()->IsContentParent()) {
|
|
|
|
nsCOMPtr<nsIDragService> dragService =
|
|
|
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
|
|
|
if (dragService) {
|
|
|
|
dragService->MaybeAddChildProcess(Manager()->AsContentParent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-15 15:49:13 +03:00
|
|
|
if (aVisualDnDData.type() == OptionalShmem::Tvoid_t ||
|
|
|
|
!aVisualDnDData.get_Shmem().IsReadable() ||
|
2016-10-19 22:01:39 +03:00
|
|
|
aVisualDnDData.get_Shmem().Size<char>() < aDragRect.height * aStride) {
|
2015-04-08 21:48:11 +03:00
|
|
|
mDnDVisualization = nullptr;
|
|
|
|
} else {
|
|
|
|
mDnDVisualization =
|
2016-10-19 22:01:39 +03:00
|
|
|
gfx::CreateDataSourceSurfaceFromData(gfx::IntSize(aDragRect.width, aDragRect.height),
|
2016-05-09 01:33:00 +03:00
|
|
|
static_cast<gfx::SurfaceFormat>(aFormat),
|
2016-06-15 15:49:13 +03:00
|
|
|
aVisualDnDData.get_Shmem().get<uint8_t>(),
|
2016-05-09 01:33:00 +03:00
|
|
|
aStride);
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
2016-10-19 22:01:39 +03:00
|
|
|
|
|
|
|
mDragValid = true;
|
|
|
|
mDragRect = aDragRect;
|
2015-10-07 18:17:42 +03:00
|
|
|
|
2015-04-08 21:48:11 +03:00
|
|
|
esm->BeginTrackingRemoteDragGesture(mFrameElement);
|
|
|
|
|
2016-06-15 15:49:13 +03:00
|
|
|
if (aVisualDnDData.type() == OptionalShmem::TShmem) {
|
|
|
|
Unused << DeallocShmem(aVisualDnDData);
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabParent::AddInitialDnDDataTo(DataTransfer* aDataTransfer)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mInitialDataTransferItems.Length(); ++i) {
|
2016-02-24 03:31:29 +03:00
|
|
|
nsTArray<IPCDataTransferItem>& itemArray = mInitialDataTransferItems[i];
|
|
|
|
for (auto& item : itemArray) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsVariantCC> variant = new nsVariantCC();
|
2015-04-08 21:48:11 +03:00
|
|
|
// Special case kFilePromiseMime so that we get the right
|
|
|
|
// nsIFlavorDataProvider for it.
|
2016-02-24 03:31:29 +03:00
|
|
|
if (item.flavor().EqualsLiteral(kFilePromiseMime)) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsISupports> flavorDataProvider =
|
2015-04-08 21:48:11 +03:00
|
|
|
new nsContentAreaDragDropDataProvider();
|
|
|
|
variant->SetAsISupports(flavorDataProvider);
|
2016-02-24 03:31:29 +03:00
|
|
|
} else if (item.data().type() == IPCDataTransferData::TnsString) {
|
|
|
|
variant->SetAsAString(item.data().get_nsString());
|
2017-04-24 13:16:50 +03:00
|
|
|
} else if (item.data().type() == IPCDataTransferData::TIPCBlob) {
|
|
|
|
RefPtr<BlobImpl> impl =
|
|
|
|
IPCBlobUtils::Deserialize(item.data().get_IPCBlob());
|
2016-02-24 03:31:29 +03:00
|
|
|
variant->SetAsISupports(impl);
|
2016-06-15 19:57:46 +03:00
|
|
|
} else if (item.data().type() == IPCDataTransferData::TShmem) {
|
2016-04-21 21:11:14 +03:00
|
|
|
if (nsContentUtils::IsFlavorImage(item.flavor())) {
|
|
|
|
// An image! Get the imgIContainer for it and set it in the variant.
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
|
|
|
nsresult rv =
|
|
|
|
nsContentUtils::DataTransferItemToImage(item,
|
|
|
|
getter_AddRefs(imageContainer));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
variant->SetAsISupports(imageContainer);
|
|
|
|
} else {
|
2016-06-15 19:57:46 +03:00
|
|
|
Shmem data = item.data().get_Shmem();
|
|
|
|
variant->SetAsACString(nsDependentCString(data.get<char>(), data.Size<char>()));
|
2016-02-24 03:31:29 +03:00
|
|
|
}
|
2016-06-15 19:57:46 +03:00
|
|
|
|
|
|
|
mozilla::Unused << DeallocShmem(item.data().get_Shmem());
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
2016-02-24 03:31:29 +03:00
|
|
|
|
2015-04-08 21:48:11 +03:00
|
|
|
// Using system principal here, since once the data is on parent process
|
|
|
|
// side, it can be handled as being from browser chrome or OS.
|
2016-06-21 20:07:17 +03:00
|
|
|
|
|
|
|
// We set aHidden to false, as we don't need to worry about hiding data
|
|
|
|
// from content in the parent process where there is no content.
|
|
|
|
// XXX: Nested Content Processes may change this
|
2016-04-21 21:11:14 +03:00
|
|
|
aDataTransfer->SetDataWithPrincipalFromOtherProcess(NS_ConvertUTF8toUTF16(item.flavor()),
|
|
|
|
variant, i,
|
2016-06-21 20:07:17 +03:00
|
|
|
nsContentUtils::GetSystemPrincipal(),
|
|
|
|
/* aHidden = */ false);
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mInitialDataTransferItems.Clear();
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:01:39 +03:00
|
|
|
bool
|
2015-10-18 08:24:48 +03:00
|
|
|
TabParent::TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface,
|
2016-10-19 22:01:39 +03:00
|
|
|
LayoutDeviceIntRect* aDragRect)
|
2015-04-08 21:48:11 +03:00
|
|
|
{
|
2016-10-19 22:01:39 +03:00
|
|
|
if (!mDragValid)
|
|
|
|
return false;
|
|
|
|
|
2015-04-08 21:48:11 +03:00
|
|
|
aSurface = mDnDVisualization.forget();
|
2016-10-19 22:01:39 +03:00
|
|
|
*aDragRect = mDragRect;
|
|
|
|
mDragValid = false;
|
|
|
|
return true;
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:51:10 +03:00
|
|
|
bool
|
|
|
|
TabParent::AsyncPanZoomEnabled() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
return widget && widget->AsyncPanZoomEnabled();
|
|
|
|
}
|
|
|
|
|
2015-08-06 00:25:39 +03:00
|
|
|
NS_IMETHODIMP
|
2015-08-06 17:44:16 +03:00
|
|
|
TabParent::StartPersistence(uint64_t aOuterWindowID,
|
|
|
|
nsIWebBrowserPersistDocumentReceiver* aRecv)
|
2015-08-06 00:25:39 +03:00
|
|
|
{
|
2015-09-21 15:54:00 +03:00
|
|
|
nsCOMPtr<nsIContentParent> manager = Manager();
|
|
|
|
if (!manager->IsContentParent()) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2015-08-06 00:25:39 +03:00
|
|
|
auto* actor = new WebBrowserPersistDocumentParent();
|
|
|
|
actor->SetOnReady(aRecv);
|
2015-09-21 15:54:00 +03:00
|
|
|
return manager->AsContentParent()
|
|
|
|
->SendPWebBrowserPersistDocumentConstructor(actor, this, aOuterWindowID)
|
2015-08-06 00:25:39 +03:00
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
// (The actor will be destroyed on constructor failure.)
|
|
|
|
}
|
|
|
|
|
2017-07-27 02:33:02 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::StartApzAutoscroll(float aAnchorX, float aAnchorY,
|
|
|
|
nsViewID aScrollId, uint32_t aPresShellId)
|
|
|
|
{
|
|
|
|
if (!AsyncPanZoomEnabled()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RenderFrameParent* renderFrame = GetRenderFrame()) {
|
|
|
|
uint64_t layersId = renderFrame->GetLayersId();
|
|
|
|
if (nsCOMPtr<nsIWidget> widget = GetWidget()) {
|
|
|
|
ScrollableLayerGuid guid{layersId, aPresShellId, aScrollId};
|
|
|
|
|
|
|
|
// The anchor coordinates that are passed in are relative to the origin
|
|
|
|
// of the screen, but we are sending them to APZ which only knows about
|
|
|
|
// coordinates relative to the widget, so convert them accordingly.
|
2017-08-03 03:11:07 +03:00
|
|
|
CSSPoint anchorCss{aAnchorX, aAnchorY};
|
|
|
|
LayoutDeviceIntPoint anchor = RoundedToInt(anchorCss * widget->GetDefaultScale());
|
2017-07-27 02:33:02 +03:00
|
|
|
anchor -= widget->WidgetToScreenOffset();
|
|
|
|
|
|
|
|
widget->StartAsyncAutoscroll(
|
|
|
|
ViewAs<ScreenPixel>(anchor, PixelCastJustification::LayoutDeviceIsScreenForBounds),
|
|
|
|
guid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabParent::StopApzAutoscroll(nsViewID aScrollId, uint32_t aPresShellId)
|
|
|
|
{
|
|
|
|
if (!AsyncPanZoomEnabled()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RenderFrameParent* renderFrame = GetRenderFrame()) {
|
|
|
|
uint64_t layersId = renderFrame->GetLayersId();
|
|
|
|
if (nsCOMPtr<nsIWidget> widget = GetWidget()) {
|
|
|
|
ScrollableLayerGuid guid{layersId, aPresShellId, aScrollId};
|
|
|
|
widget->StopAsyncAutoscroll(guid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-30 16:24:57 +03:00
|
|
|
ShowInfo
|
|
|
|
TabParent::GetShowInfo()
|
|
|
|
{
|
|
|
|
TryCacheDPIAndScale();
|
|
|
|
if (mFrameElement) {
|
|
|
|
nsAutoString name;
|
|
|
|
mFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
|
|
|
bool allowFullscreen =
|
|
|
|
mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
|
|
|
|
mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen);
|
|
|
|
bool isPrivate = mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing);
|
2016-05-16 05:56:09 +03:00
|
|
|
bool isTransparent =
|
|
|
|
nsContentUtils::IsChromeDoc(mFrameElement->OwnerDoc()) &&
|
|
|
|
mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::transparent);
|
2015-10-30 16:24:57 +03:00
|
|
|
return ShowInfo(name, allowFullscreen, isPrivate, false,
|
2016-09-27 09:37:07 +03:00
|
|
|
isTransparent, mDPI, mRounding, mDefaultScale.scale);
|
2015-10-30 16:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return ShowInfo(EmptyString(), false, false, false,
|
2016-09-27 09:37:07 +03:00
|
|
|
false, mDPI, mRounding, mDefaultScale.scale);
|
2015-10-30 16:24:57 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-04-14 21:03:00 +03:00
|
|
|
TabParent::RecvGetTabCount(uint32_t* aValue)
|
|
|
|
{
|
2016-04-25 16:33:00 +03:00
|
|
|
*aValue = 0;
|
|
|
|
|
2016-04-14 21:03:00 +03:00
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow = GetXULBrowserWindow();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(xulBrowserWindow, IPC_OK());
|
2016-04-14 21:03:00 +03:00
|
|
|
|
|
|
|
uint32_t tabCount;
|
|
|
|
nsresult rv = xulBrowserWindow->GetTabCount(&tabCount);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
2016-04-14 21:03:00 +03:00
|
|
|
|
|
|
|
*aValue = tabCount;
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-04-14 21:03:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-04-26 11:18:04 +03:00
|
|
|
TabParent::RecvLookUpDictionary(const nsString& aText,
|
|
|
|
nsTArray<FontRange>&& aFontRangeArray,
|
|
|
|
const bool& aIsVertical,
|
|
|
|
const LayoutDeviceIntPoint& aPoint)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
|
|
|
if (!widget) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-04-26 11:18:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
widget->LookUpDictionary(aText, aFontRangeArray, aIsVertical,
|
|
|
|
aPoint - GetChildProcessOffset());
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-04-26 11:18:04 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-12-15 08:28:40 +03:00
|
|
|
TabParent::RecvSHistoryUpdate(const uint32_t& aCount, const uint32_t& aLocalIndex, const bool& aTruncate)
|
2016-10-14 10:31:02 +03:00
|
|
|
{
|
|
|
|
RefPtr<nsFrameLoader> frameLoader(GetFrameLoader());
|
|
|
|
if (!frameLoader) {
|
|
|
|
// FrameLoader can be nullptr if the it is destroying.
|
|
|
|
// In this case session history change can simply be ignored.
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-10-14 10:31:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPartialSHistory> partialHistory;
|
2016-12-22 11:06:50 +03:00
|
|
|
frameLoader->GetPartialSHistory(getter_AddRefs(partialHistory));
|
2016-10-14 10:31:02 +03:00
|
|
|
if (!partialHistory) {
|
|
|
|
// PartialSHistory is not enabled
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-10-14 10:31:02 +03:00
|
|
|
}
|
|
|
|
|
2016-12-15 08:28:40 +03:00
|
|
|
partialHistory->HandleSHistoryUpdate(aCount, aLocalIndex, aTruncate);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-10-14 10:31:02 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-10-14 10:31:02 +03:00
|
|
|
TabParent::RecvRequestCrossBrowserNavigation(const uint32_t& aGlobalIndex)
|
|
|
|
{
|
|
|
|
RefPtr<nsFrameLoader> frameLoader(GetFrameLoader());
|
|
|
|
if (!frameLoader) {
|
|
|
|
// FrameLoader can be nullptr if the it is destroying.
|
|
|
|
// In this case we can ignore the request.
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-10-14 10:31:02 +03:00
|
|
|
}
|
|
|
|
|
2016-11-09 22:51:02 +03:00
|
|
|
nsCOMPtr<nsISupports> promise;
|
|
|
|
if (NS_FAILED(frameLoader->RequestGroupedHistoryNavigation(aGlobalIndex,
|
|
|
|
getter_AddRefs(promise)))) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2016-10-14 10:31:02 +03:00
|
|
|
}
|
|
|
|
|
2017-02-01 18:38:16 +03:00
|
|
|
void
|
|
|
|
TabParent::LiveResizeStarted()
|
|
|
|
{
|
|
|
|
SuppressDisplayport(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabParent::LiveResizeStopped()
|
|
|
|
{
|
|
|
|
SuppressDisplayport(false);
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:36 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
FakeChannel::OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo)
|
|
|
|
{
|
|
|
|
nsAuthInformationHolder* holder =
|
|
|
|
static_cast<nsAuthInformationHolder*>(aAuthInfo);
|
|
|
|
|
|
|
|
if (!net::gNeckoChild->SendOnAuthAvailable(mCallbackId,
|
|
|
|
holder->User(),
|
|
|
|
holder->Password(),
|
|
|
|
holder->Domain())) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
FakeChannel::OnAuthCancelled(nsISupports *aContext, bool userCancel)
|
|
|
|
{
|
|
|
|
if (!net::gNeckoChild->SendOnAuthCancelled(mCallbackId, userCancel)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2009-07-01 00:39:22 +04:00
|
|
|
} // namespace mozilla
|