2009-06-30 13:39:22 -07:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
|
2012-06-12 15:01:25 -07:00
|
|
|
/* vim: set sw=2 sts=2 ts=8 et tw=80 : */
|
2012-05-21 04:12:37 -07: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-06-30 13:39:22 -07:00
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
#include "TabChild.h"
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "BasicLayers.h"
|
2012-08-01 23:02:29 -07:00
|
|
|
#include "Blob.h"
|
|
|
|
#include "ContentChild.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "IndexedDBChild.h"
|
2012-08-29 08:26:18 -07:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2010-11-24 05:58:21 -08:00
|
|
|
#include "mozilla/IntentionalCrash.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "mozilla/docshell/OfflineCacheUpdateChild.h"
|
2010-07-19 11:33:33 -07:00
|
|
|
#include "mozilla/dom/PContentChild.h"
|
2010-05-17 04:25:22 -07:00
|
|
|
#include "mozilla/dom/PContentDialogChild.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "mozilla/ipc/DocumentRendererChild.h"
|
2013-02-15 14:27:21 -08:00
|
|
|
#include "mozilla/ipc/FileDescriptorUtils.h"
|
2012-09-28 19:18:18 -07:00
|
|
|
#include "mozilla/layers/AsyncPanZoomController.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "mozilla/layers/CompositorChild.h"
|
2013-06-23 22:28:22 -07:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2013-04-24 11:42:40 -07:00
|
|
|
#include "mozilla/layers/PLayerTransactionChild.h"
|
2010-08-20 16:24:41 -07:00
|
|
|
#include "mozilla/layout/RenderFrameChild.h"
|
2012-08-29 08:26:18 -07:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2012-08-08 13:37:57 -07:00
|
|
|
#include "mozilla/unused.h"
|
2012-09-10 21:30:33 -07:00
|
|
|
#include "mozIApplication.h"
|
2009-06-30 13:39:22 -07:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsContentUtils.h"
|
2013-05-22 09:05:27 -07:00
|
|
|
#include "nsCxPusher.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsEmbedCID.h"
|
|
|
|
#include "nsEventListenerManager.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2013-01-07 12:45:10 -08:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2013-01-07 06:42:32 -08:00
|
|
|
#include "nsExceptionHandler.h"
|
2013-01-07 12:45:10 -08:00
|
|
|
#endif
|
2012-11-14 14:10:08 -08:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-09-10 21:30:33 -07:00
|
|
|
#include "nsIAppsService.h"
|
2009-06-30 13:39:22 -07:00
|
|
|
#include "nsIBaseWindow.h"
|
2013-02-15 14:27:21 -08:00
|
|
|
#include "nsICachedFileDescriptorListener.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsIComponentManager.h"
|
2013-01-12 13:53:01 -08:00
|
|
|
#include "nsIDocumentInlines.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsIDOMClassInfo.h"
|
2012-09-28 19:18:18 -07:00
|
|
|
#include "nsIDOMElement.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsIDOMEvent.h"
|
2009-10-29 10:58:31 -07:00
|
|
|
#include "nsIDOMWindow.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsIDOMWindowUtils.h"
|
2010-08-13 01:06:40 -07:00
|
|
|
#include "nsIDocShell.h"
|
2009-10-29 10:58:31 -07:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2009-11-05 10:14:22 -08:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsIJSRuntimeService.h"
|
|
|
|
#include "nsISSLStatusProvider.h"
|
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsISecureBrowserUI.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2009-11-05 10:14:22 -08:00
|
|
|
#include "nsISupportsImpl.h"
|
2010-03-26 11:39:39 -07:00
|
|
|
#include "nsIURI.h"
|
2012-09-28 19:18:18 -07:00
|
|
|
#include "nsIURIFixup.h"
|
|
|
|
#include "nsCDefaultURIFixup.h"
|
2013-01-03 05:23:11 -08:00
|
|
|
#include "nsView.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsIWebBrowser.h"
|
2009-11-05 10:14:22 -08:00
|
|
|
#include "nsIWebBrowserFocus.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsIWebBrowserSetup.h"
|
|
|
|
#include "nsIWebProgress.h"
|
2010-02-20 09:05:20 -08:00
|
|
|
#include "nsIXPCSecurityManager.h"
|
2010-05-17 04:25:22 -07:00
|
|
|
#include "nsInterfaceHashtable.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsPIWindowRoot.h"
|
2012-11-22 17:25:28 -08:00
|
|
|
#include "nsGlobalWindow.h"
|
2010-03-24 03:47:18 -07:00
|
|
|
#include "nsPresContext.h"
|
2012-07-19 23:48:27 -07:00
|
|
|
#include "nsPrintfCString.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsScriptLoader.h"
|
2010-08-13 01:06:40 -07:00
|
|
|
#include "nsSerializationHelper.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsWeakReference.h"
|
2010-09-09 22:00:08 -07:00
|
|
|
#include "PCOMContentPermissionRequestChild.h"
|
2012-08-29 08:26:18 -07:00
|
|
|
#include "PuppetWidget.h"
|
2012-08-01 23:02:29 -07:00
|
|
|
#include "StructuredCloneUtils.h"
|
2011-01-14 14:03:21 -08:00
|
|
|
#include "xpcpublic.h"
|
2012-12-17 13:24:41 -08:00
|
|
|
#include "nsViewportInfo.h"
|
2009-07-07 09:26:49 -07:00
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
#define BROWSER_ELEMENT_CHILD_SCRIPT \
|
|
|
|
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
using namespace mozilla;
|
2009-08-12 09:18:08 -07:00
|
|
|
using namespace mozilla::dom;
|
2012-09-27 22:43:12 -07:00
|
|
|
using namespace mozilla::dom::ipc;
|
2010-10-26 15:20:53 -07:00
|
|
|
using namespace mozilla::ipc;
|
2010-08-20 16:24:41 -07:00
|
|
|
using namespace mozilla::layers;
|
2010-08-20 16:24:41 -07:00
|
|
|
using namespace mozilla::layout;
|
2010-10-20 10:12:32 -07:00
|
|
|
using namespace mozilla::docshell;
|
2012-06-01 10:21:12 -07:00
|
|
|
using namespace mozilla::dom::indexedDB;
|
2012-08-11 18:42:34 -07:00
|
|
|
using namespace mozilla::widget;
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2009-11-17 06:22:23 -08:00
|
|
|
NS_IMPL_ISUPPORTS1(ContentListener, nsIDOMEventListener)
|
|
|
|
|
2013-06-10 06:05:43 -07:00
|
|
|
static const CSSSize kDefaultViewportSize(980, 480);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
|
|
|
static const char CANCEL_DEFAULT_PAN_ZOOM[] = "cancel-default-pan-zoom";
|
|
|
|
static const char BROWSER_ZOOM_TO_RECT[] = "browser-zoom-to-rect";
|
|
|
|
static const char BEFORE_FIRST_PAINT[] = "before-first-paint";
|
2013-01-05 06:53:16 -08:00
|
|
|
static const char DETECT_SCROLLABLE_SUBFRAME[] = "detect-scrollable-subframe";
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2009-11-17 06:22:23 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ContentListener::HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
RemoteDOMEvent remoteEvent;
|
|
|
|
remoteEvent.mEvent = do_QueryInterface(aEvent);
|
|
|
|
NS_ENSURE_STATE(remoteEvent.mEvent);
|
2010-07-19 11:33:33 -07:00
|
|
|
mTabChild->SendEvent(remoteEvent);
|
2009-11-17 06:22:23 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-05-17 04:25:22 -07:00
|
|
|
class ContentDialogChild : public PContentDialogChild
|
|
|
|
{
|
|
|
|
public:
|
2010-11-08 18:49:00 -08:00
|
|
|
virtual bool Recv__delete__(const InfallibleTArray<int>& aIntParams,
|
|
|
|
const InfallibleTArray<nsString>& aStringParams);
|
2010-05-17 04:25:22 -07:00
|
|
|
};
|
|
|
|
|
2013-02-15 14:27:21 -08:00
|
|
|
class TabChild::CachedFileDescriptorInfo
|
|
|
|
{
|
|
|
|
struct PathOnlyComparatorHelper
|
|
|
|
{
|
|
|
|
bool Equals(const nsAutoPtr<CachedFileDescriptorInfo>& a,
|
|
|
|
const CachedFileDescriptorInfo& b) const
|
|
|
|
{
|
|
|
|
return a->mPath == b.mPath;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PathAndCallbackComparatorHelper
|
|
|
|
{
|
|
|
|
bool Equals(const nsAutoPtr<CachedFileDescriptorInfo>& a,
|
|
|
|
const CachedFileDescriptorInfo& b) const
|
|
|
|
{
|
|
|
|
return a->mPath == b.mPath &&
|
|
|
|
a->mCallback == b.mCallback;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
nsString mPath;
|
|
|
|
FileDescriptor mFileDescriptor;
|
|
|
|
nsCOMPtr<nsICachedFileDescriptorListener> mCallback;
|
|
|
|
bool mCanceled;
|
|
|
|
|
|
|
|
CachedFileDescriptorInfo(const nsAString& aPath)
|
|
|
|
: mPath(aPath), mCanceled(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
CachedFileDescriptorInfo(const nsAString& aPath,
|
|
|
|
const FileDescriptor& aFileDescriptor)
|
|
|
|
: mPath(aPath), mFileDescriptor(aFileDescriptor), mCanceled(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
CachedFileDescriptorInfo(const nsAString& aPath,
|
|
|
|
nsICachedFileDescriptorListener* aCallback)
|
|
|
|
: mPath(aPath), mCallback(aCallback), mCanceled(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
PathOnlyComparatorHelper PathOnlyComparator() const
|
|
|
|
{
|
|
|
|
return PathOnlyComparatorHelper();
|
|
|
|
}
|
|
|
|
|
|
|
|
PathAndCallbackComparatorHelper PathAndCallbackComparator() const
|
|
|
|
{
|
|
|
|
return PathAndCallbackComparatorHelper();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FireCallback() const
|
|
|
|
{
|
|
|
|
mCallback->OnCachedFileDescriptor(mPath, mFileDescriptor);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TabChild::CachedFileDescriptorCallbackRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
typedef TabChild::CachedFileDescriptorInfo CachedFileDescriptorInfo;
|
|
|
|
|
|
|
|
nsAutoPtr<CachedFileDescriptorInfo> mInfo;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CachedFileDescriptorCallbackRunnable(CachedFileDescriptorInfo* aInfo)
|
|
|
|
: mInfo(aInfo)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aInfo);
|
|
|
|
MOZ_ASSERT(!aInfo->mPath.IsEmpty());
|
|
|
|
MOZ_ASSERT(aInfo->mCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dispatch()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsresult rv = NS_DispatchToCurrentThread(this);
|
|
|
|
NS_ENSURE_SUCCESS_VOID(rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mInfo);
|
|
|
|
|
|
|
|
mInfo->FireCallback();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
StaticRefPtr<TabChild> sPreallocatedTab;
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
TabChild::PreloadSlowThings()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!sPreallocatedTab);
|
|
|
|
|
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 10:32:37 -08:00
|
|
|
nsRefPtr<TabChild> tab(new TabChild(TabContext(), /* chromeFlags */ 0));
|
2012-08-29 08:26:18 -07:00
|
|
|
if (!NS_SUCCEEDED(tab->Init()) ||
|
|
|
|
!tab->InitTabChildGlobal(DONT_LOAD_SCRIPTS)) {
|
|
|
|
return;
|
|
|
|
}
|
2013-02-05 18:27:52 -08:00
|
|
|
// Just load and compile these scripts, but don't run them.
|
2012-08-29 08:26:18 -07:00
|
|
|
tab->TryCacheLoadAndCompileScript(BROWSER_ELEMENT_CHILD_SCRIPT);
|
2013-02-05 18:27:52 -08:00
|
|
|
// Load, compile, and run these scripts.
|
|
|
|
tab->RecvLoadRemoteScript(
|
|
|
|
NS_LITERAL_STRING("chrome://global/content/preload.js"));
|
2012-08-29 08:26:18 -07:00
|
|
|
|
2013-02-04 22:38:54 -08:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(tab->mWebNav);
|
|
|
|
if (nsIPresShell* presShell = docShell->GetPresShell()) {
|
|
|
|
// Initialize and do an initial reflow of the about:blank
|
|
|
|
// PresShell to let it preload some things for us.
|
|
|
|
presShell->Initialize(0, 0);
|
|
|
|
nsIDocument* doc = presShell->GetDocument();
|
|
|
|
doc->FlushPendingNotifications(Flush_Layout);
|
|
|
|
// ... but after it's done, make sure it doesn't do any more
|
|
|
|
// work.
|
|
|
|
presShell->MakeZombie();
|
|
|
|
}
|
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
sPreallocatedTab = tab;
|
|
|
|
ClearOnShutdown(&sPreallocatedTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ already_AddRefed<TabChild>
|
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 10:32:37 -08:00
|
|
|
TabChild::Create(const TabContext &aContext, uint32_t aChromeFlags)
|
2012-08-29 08:26:18 -07:00
|
|
|
{
|
|
|
|
if (sPreallocatedTab &&
|
|
|
|
sPreallocatedTab->mChromeFlags == 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 10:32:37 -08:00
|
|
|
aContext.IsBrowserOrApp()) {
|
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
nsRefPtr<TabChild> child = sPreallocatedTab.get();
|
|
|
|
sPreallocatedTab = nullptr;
|
|
|
|
|
|
|
|
MOZ_ASSERT(!child->mTriedBrowserInit);
|
|
|
|
|
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 10:32:37 -08:00
|
|
|
child->SetTabContext(aContext);
|
|
|
|
child->NotifyTabContextUpdated();
|
2012-08-29 08:26:18 -07:00
|
|
|
return child.forget();
|
|
|
|
}
|
|
|
|
|
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 10:32:37 -08:00
|
|
|
nsRefPtr<TabChild> iframe = new TabChild(aContext, aChromeFlags);
|
2012-08-29 08:26:18 -07:00
|
|
|
return NS_SUCCEEDED(iframe->Init()) ? iframe.forget() : nullptr;
|
|
|
|
}
|
|
|
|
|
2010-05-17 04:25:22 -07:00
|
|
|
|
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 10:32:37 -08:00
|
|
|
TabChild::TabChild(const TabContext& aContext, uint32_t aChromeFlags)
|
|
|
|
: TabContext(aContext)
|
|
|
|
, mRemoteFrame(nullptr)
|
2012-07-30 07:20:58 -07:00
|
|
|
, mTabChildGlobal(nullptr)
|
2010-07-19 11:33:33 -07:00
|
|
|
, mChromeFlags(aChromeFlags)
|
2011-07-15 14:46:56 -07:00
|
|
|
, mOuterRect(0, 0, 0, 0)
|
2012-09-28 19:18:18 -07:00
|
|
|
, mInnerSize(0, 0)
|
2013-01-05 06:53:16 -08:00
|
|
|
, mActivePointerId(-1)
|
|
|
|
, mTapHoldTimer(nullptr)
|
2013-05-29 17:56:09 -07:00
|
|
|
, mAppPackageFileDescriptorRecved(false)
|
2012-09-28 19:18:18 -07:00
|
|
|
, mOldViewportWidth(0.0f)
|
2011-10-20 15:17:09 -07:00
|
|
|
, mLastBackgroundColor(NS_RGB(255, 255, 255))
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones DONTBUILD
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.
(Re-landing changeset a6a847452dbf, backed out in 5091aa6083c4, because it was originally landed with the incorrect bug number.)
2012-10-30 13:13:21 -07:00
|
|
|
, mDidFakeShow(false)
|
2012-08-06 20:00:41 -07:00
|
|
|
, mNotified(false)
|
2012-09-28 19:18:18 -07:00
|
|
|
, mContentDocumentIsDisplayed(false)
|
2012-08-29 08:26:18 -07:00
|
|
|
, mTriedBrowserInit(false)
|
2012-11-21 18:40:57 -08:00
|
|
|
, mOrientation(eScreenOrientation_PortraitPrimary)
|
2009-06-30 13:39:22 -07:00
|
|
|
{
|
2010-05-17 04:21:55 -07:00
|
|
|
printf("creating %d!\n", NS_IsMainThread());
|
2009-11-05 10:14:22 -08:00
|
|
|
}
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
|
|
|
if (eventType.EqualsLiteral("DOMMetaAdded")) {
|
|
|
|
// This meta data may or may not have been a meta viewport tag. If it was,
|
|
|
|
// we should handle it immediately.
|
2012-10-11 22:46:24 -07:00
|
|
|
HandlePossibleViewportChange();
|
2012-09-28 19:18:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-08 13:37:57 -07:00
|
|
|
TabChild::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
|
|
|
const PRUnichar *aData)
|
|
|
|
{
|
2012-09-28 19:18:18 -07:00
|
|
|
if (!strcmp(aTopic, CANCEL_DEFAULT_PAN_ZOOM)) {
|
2012-08-08 13:38:06 -07:00
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aSubject));
|
|
|
|
nsCOMPtr<nsITabChild> tabChild(GetTabChildFrom(docShell));
|
|
|
|
if (tabChild == this) {
|
|
|
|
mRemoteFrame->CancelDefaultPanZoom();
|
|
|
|
}
|
2012-09-28 19:18:18 -07:00
|
|
|
} else if (!strcmp(aTopic, BROWSER_ZOOM_TO_RECT)) {
|
2012-08-08 21:39:02 -07:00
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aSubject));
|
|
|
|
nsCOMPtr<nsITabChild> tabChild(GetTabChildFrom(docShell));
|
|
|
|
if (tabChild == this) {
|
|
|
|
gfxRect rect;
|
|
|
|
sscanf(NS_ConvertUTF16toUTF8(aData).get(),
|
|
|
|
"{\"x\":%lf,\"y\":%lf,\"w\":%lf,\"h\":%lf}",
|
|
|
|
&rect.x, &rect.y, &rect.width, &rect.height);
|
|
|
|
SendZoomToRect(rect);
|
|
|
|
}
|
2012-09-28 19:18:18 -07:00
|
|
|
} else if (!strcmp(aTopic, BEFORE_FIRST_PAINT)) {
|
|
|
|
if (IsAsyncPanZoomEnabled()) {
|
|
|
|
nsCOMPtr<nsIDocument> subject(do_QueryInterface(aSubject));
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
|
|
|
mWebNav->GetDocument(getter_AddRefs(domDoc));
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
|
|
|
|
|
|
|
if (SameCOMIdentity(subject, doc)) {
|
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
|
|
|
|
|
|
|
|
mContentDocumentIsDisplayed = true;
|
|
|
|
|
2012-10-11 22:46:24 -07:00
|
|
|
// Reset CSS viewport and zoom to default on new page, then
|
|
|
|
// calculate them properly using the actual metadata from the
|
|
|
|
// page.
|
2013-06-10 06:05:43 -07:00
|
|
|
SetCSSViewport(kDefaultViewportSize);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2012-10-11 22:46:24 -07:00
|
|
|
// Calculate a really simple resolution that we probably won't
|
|
|
|
// be keeping, as well as putting the scroll offset back to
|
|
|
|
// the top-left of the page.
|
2013-06-21 14:03:56 -07:00
|
|
|
mLastMetrics.mZoom = ScreenToScreenScale(1.0);
|
2013-06-10 06:05:43 -07:00
|
|
|
mLastMetrics.mViewport = CSSRect(CSSPoint(), kDefaultViewportSize);
|
2013-06-14 13:11:29 -07:00
|
|
|
mLastMetrics.mCompositionBounds = ScreenIntRect(ScreenIntPoint(), mInnerSize);
|
2013-06-26 06:54:14 -07:00
|
|
|
CSSToScreenScale resolution = mLastMetrics.CalculateResolution();
|
2013-06-21 14:03:56 -07:00
|
|
|
// We use ScreenToLayerScale(1) below in order to ask gecko to render
|
|
|
|
// what's currently visible on the screen. This is effectively turning
|
|
|
|
// the async zoom amount into the gecko zoom amount.
|
|
|
|
mLastMetrics.mResolution =
|
|
|
|
resolution / mLastMetrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
|
2013-05-30 18:30:13 -07:00
|
|
|
mLastMetrics.mScrollOffset = CSSPoint(0, 0);
|
2013-06-21 14:03:56 -07:00
|
|
|
utils->SetResolution(mLastMetrics.mResolution.scale,
|
|
|
|
mLastMetrics.mResolution.scale);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2012-10-11 22:46:24 -07:00
|
|
|
HandlePossibleViewportChange();
|
2012-09-28 19:18:18 -07:00
|
|
|
}
|
|
|
|
}
|
2013-01-05 06:53:16 -08:00
|
|
|
} else if (!strcmp(aTopic, DETECT_SCROLLABLE_SUBFRAME)) {
|
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aSubject));
|
|
|
|
nsCOMPtr<nsITabChild> tabChild(GetTabChildFrom(docShell));
|
|
|
|
if (tabChild == this) {
|
|
|
|
mRemoteFrame->DetectScrollableSubframe();
|
|
|
|
}
|
2012-08-08 13:37:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnStateChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
uint32_t aStateFlags,
|
|
|
|
nsresult aStatus)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("not implemented in TabChild");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnProgressChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
int32_t aCurSelfProgress,
|
|
|
|
int32_t aMaxSelfProgress,
|
|
|
|
int32_t aCurTotalProgress,
|
|
|
|
int32_t aMaxTotalProgress)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("not implemented in TabChild");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnLocationChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsIURI *aLocation,
|
|
|
|
uint32_t aFlags)
|
|
|
|
{
|
|
|
|
if (!IsAsyncPanZoomEnabled()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> window;
|
|
|
|
aWebProgress->GetDOMWindow(getter_AddRefs(window));
|
|
|
|
if (!window) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-10 05:50:24 -08:00
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils(do_GetInterface(window));
|
|
|
|
utils->SetIsFirstPaint(true);
|
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
nsCOMPtr<nsIDOMDocument> progressDoc;
|
|
|
|
window->GetDocument(getter_AddRefs(progressDoc));
|
|
|
|
if (!progressDoc) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
|
|
|
mWebNav->GetDocument(getter_AddRefs(domDoc));
|
|
|
|
if (!domDoc || !SameCOMIdentity(domDoc, progressDoc)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURIFixup> urifixup(do_GetService(NS_URIFIXUP_CONTRACTID));
|
|
|
|
if (!urifixup) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> exposableURI;
|
|
|
|
urifixup->CreateExposableURI(aLocation, getter_AddRefs(exposableURI));
|
|
|
|
if (!exposableURI) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(aFlags & nsIWebProgressListener::LOCATION_CHANGE_SAME_DOCUMENT)) {
|
|
|
|
mContentDocumentIsDisplayed = false;
|
|
|
|
} else if (mLastURI != nullptr) {
|
|
|
|
bool exposableEqualsLast, exposableEqualsNew;
|
|
|
|
exposableURI->Equals(mLastURI.get(), &exposableEqualsLast);
|
|
|
|
exposableURI->Equals(aLocation, &exposableEqualsNew);
|
|
|
|
if (exposableEqualsLast && !exposableEqualsNew) {
|
|
|
|
mContentDocumentIsDisplayed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsresult aStatus,
|
|
|
|
const PRUnichar* aMessage)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("not implemented in TabChild");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnSecurityChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
uint32_t aState)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("not implemented in TabChild");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-10 06:05:43 -07:00
|
|
|
TabChild::SetCSSViewport(const CSSSize& aSize)
|
2012-09-28 19:18:18 -07:00
|
|
|
{
|
2013-06-10 06:05:43 -07:00
|
|
|
mOldViewportWidth = aSize.width;
|
2012-09-28 19:18:18 -07:00
|
|
|
|
|
|
|
if (mContentDocumentIsDisplayed) {
|
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
|
2013-06-10 06:05:43 -07:00
|
|
|
utils->SetCSSViewport(aSize.width, aSize.height);
|
2012-09-28 19:18:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-11 22:46:24 -07:00
|
|
|
TabChild::HandlePossibleViewportChange()
|
2012-09-28 19:18:18 -07:00
|
|
|
{
|
|
|
|
if (!IsAsyncPanZoomEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
|
|
|
mWebNav->GetDocument(getter_AddRefs(domDoc));
|
|
|
|
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDoc));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
|
|
|
|
|
2012-12-17 13:24:41 -08:00
|
|
|
nsViewportInfo viewportInfo =
|
2012-09-28 19:18:18 -07:00
|
|
|
nsContentUtils::GetViewportInfo(document, mInnerSize.width, mInnerSize.height);
|
2012-12-17 13:24:41 -08:00
|
|
|
SendUpdateZoomConstraints(viewportInfo.IsZoomAllowed(),
|
|
|
|
viewportInfo.GetMinZoom(),
|
|
|
|
viewportInfo.GetMaxZoom());
|
2012-09-28 19:18:18 -07:00
|
|
|
|
|
|
|
float screenW = mInnerSize.width;
|
|
|
|
float screenH = mInnerSize.height;
|
2013-06-10 06:05:43 -07:00
|
|
|
CSSSize viewport(viewportInfo.GetWidth(), viewportInfo.GetHeight());
|
2012-09-28 19:18:18 -07:00
|
|
|
|
|
|
|
// We're not being displayed in any way; don't bother doing anything because
|
|
|
|
// that will just confuse future adjustments.
|
|
|
|
if (!screenW || !screenH) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the viewport height is not shorter than the window when the page
|
|
|
|
// is zoomed out to show its full width. Note that before we set the viewport
|
|
|
|
// width, the "full width" of the page isn't properly defined, so that's why
|
|
|
|
// we have to call SetCSSViewport twice - once to set the width, and the
|
|
|
|
// second time to figure out the height based on the layout at that width.
|
|
|
|
float oldBrowserWidth = mOldViewportWidth;
|
2013-06-10 06:05:43 -07:00
|
|
|
mLastMetrics.mViewport.SizeTo(viewport);
|
2012-09-28 19:18:18 -07:00
|
|
|
if (!oldBrowserWidth) {
|
|
|
|
oldBrowserWidth = kDefaultViewportSize.width;
|
|
|
|
}
|
2013-06-10 06:05:43 -07:00
|
|
|
SetCSSViewport(viewport);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
|
|
|
// If this page has not been painted yet, then this must be getting run
|
|
|
|
// because a meta-viewport element was added (via the DOMMetaAdded handler).
|
|
|
|
// in this case, we should not do anything that forces a reflow (see bug
|
|
|
|
// 759678) such as requesting the page size or sending a viewport update. this
|
|
|
|
// code will get run again in the before-first-paint handler and that point we
|
|
|
|
// will run though all of it. the reason we even bother executing up to this
|
|
|
|
// point on the DOMMetaAdded handler is so that scripts that use
|
|
|
|
// window.innerWidth before they are painted have a correct value (bug
|
|
|
|
// 771575).
|
|
|
|
if (!mContentDocumentIsDisplayed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float minScale = 1.0f;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> htmlDOMElement = do_QueryInterface(document->GetHtmlElement());
|
2013-01-12 13:53:01 -08:00
|
|
|
HTMLBodyElement* bodyDOMElement = document->GetBodyElement();
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2012-10-01 13:04:09 -07:00
|
|
|
int32_t htmlWidth = 0, htmlHeight = 0;
|
2012-09-28 19:18:18 -07:00
|
|
|
if (htmlDOMElement) {
|
|
|
|
htmlDOMElement->GetScrollWidth(&htmlWidth);
|
|
|
|
htmlDOMElement->GetScrollHeight(&htmlHeight);
|
|
|
|
}
|
2012-10-01 13:04:09 -07:00
|
|
|
int32_t bodyWidth = 0, bodyHeight = 0;
|
2012-09-28 19:18:18 -07:00
|
|
|
if (bodyDOMElement) {
|
2013-01-12 13:53:01 -08:00
|
|
|
bodyWidth = bodyDOMElement->ScrollWidth();
|
|
|
|
bodyHeight = bodyDOMElement->ScrollHeight();
|
2012-09-28 19:18:18 -07:00
|
|
|
}
|
|
|
|
|
2013-06-10 06:05:43 -07:00
|
|
|
CSSSize pageSize;
|
2012-11-15 18:32:24 -08:00
|
|
|
if (htmlDOMElement || bodyDOMElement) {
|
2013-06-10 06:05:43 -07:00
|
|
|
pageSize = CSSSize(std::max(htmlWidth, bodyWidth),
|
|
|
|
std::max(htmlHeight, bodyHeight));
|
2012-11-15 18:32:24 -08:00
|
|
|
} else {
|
|
|
|
// For non-HTML content (e.g. SVG), just assume page size == viewport size.
|
2013-06-10 06:05:43 -07:00
|
|
|
pageSize = viewport;
|
|
|
|
}
|
|
|
|
if (!pageSize.width) {
|
|
|
|
// Return early rather than divide by 0.
|
|
|
|
return;
|
2012-11-15 18:32:24 -08:00
|
|
|
}
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2013-06-10 06:05:43 -07:00
|
|
|
minScale = mInnerSize.width / pageSize.width;
|
2012-12-17 13:24:41 -08:00
|
|
|
minScale = clamped((double)minScale, viewportInfo.GetMinZoom(),
|
|
|
|
viewportInfo.GetMaxZoom());
|
2012-11-15 18:32:24 -08:00
|
|
|
NS_ENSURE_TRUE_VOID(minScale); // (return early rather than divide by 0)
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2013-06-10 06:05:43 -07:00
|
|
|
viewport.height = std::max(viewport.height, screenH / minScale);
|
|
|
|
SetCSSViewport(viewport);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
|
|
|
// This change to the zoom accounts for all types of changes I can conceive:
|
|
|
|
// 1. screen size changes, CSS viewport does not (pages with no meta viewport
|
|
|
|
// or a fixed size viewport)
|
|
|
|
// 2. screen size changes, CSS viewport also does (pages with a device-width
|
|
|
|
// viewport)
|
|
|
|
// 3. screen size remains constant, but CSS viewport changes (meta viewport
|
|
|
|
// tag is added or removed)
|
|
|
|
// 4. neither screen size nor CSS viewport changes
|
|
|
|
//
|
|
|
|
// In all of these cases, we maintain how much actual content is visible
|
|
|
|
// within the screen width. Note that "actual content" may be different with
|
|
|
|
// respect to CSS pixels because of the CSS viewport size changing.
|
|
|
|
int32_t oldScreenWidth = mLastMetrics.mCompositionBounds.width;
|
|
|
|
if (!oldScreenWidth) {
|
|
|
|
oldScreenWidth = mInnerSize.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
FrameMetrics metrics(mLastMetrics);
|
2013-06-10 06:05:43 -07:00
|
|
|
metrics.mViewport = CSSRect(CSSPoint(), viewport);
|
|
|
|
metrics.mScrollableRect = CSSRect(CSSPoint(), pageSize);
|
2013-06-14 13:11:29 -07:00
|
|
|
metrics.mCompositionBounds = ScreenIntRect(ScreenIntPoint(), mInnerSize);
|
2012-10-11 22:46:24 -07:00
|
|
|
|
2012-12-10 05:50:24 -08:00
|
|
|
// Changing the zoom when we're not doing a first paint will get ignored
|
|
|
|
// by AsyncPanZoomController and causes a blurry flash.
|
|
|
|
bool isFirstPaint;
|
|
|
|
nsresult rv = utils->GetIsFirstPaint(&isFirstPaint);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
if (NS_FAILED(rv) || isFirstPaint) {
|
2013-06-26 06:53:51 -07:00
|
|
|
CSSToScreenScale intrinsicScale = metrics.CalculateIntrinsicScale();
|
2012-12-10 05:50:24 -08:00
|
|
|
// FIXME/bug 799585(?): GetViewportInfo() returns a defaultZoom of
|
|
|
|
// 0.0 to mean "did not calculate a zoom". In that case, we default
|
|
|
|
// it to the intrinsic scale.
|
2012-12-17 13:24:41 -08:00
|
|
|
if (viewportInfo.GetDefaultZoom() < 0.01f) {
|
2013-06-21 14:03:56 -07:00
|
|
|
viewportInfo.SetDefaultZoom(intrinsicScale.scale);
|
2012-12-10 05:50:24 -08:00
|
|
|
}
|
2012-12-17 13:24:41 -08:00
|
|
|
|
|
|
|
double defaultZoom = viewportInfo.GetDefaultZoom();
|
|
|
|
MOZ_ASSERT(viewportInfo.GetMinZoom() <= defaultZoom &&
|
|
|
|
defaultZoom <= viewportInfo.GetMaxZoom());
|
2012-12-10 05:50:24 -08:00
|
|
|
// GetViewportInfo() returns a resolution-dependent scale factor.
|
|
|
|
// Convert that to a resolution-indepedent zoom.
|
2013-06-21 14:03:56 -07:00
|
|
|
metrics.mZoom = ScreenToScreenScale(defaultZoom / intrinsicScale.scale);
|
2012-10-11 22:46:24 -07:00
|
|
|
}
|
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
metrics.mDisplayPort = AsyncPanZoomController::CalculatePendingDisplayPort(
|
2012-09-28 21:02:45 -07:00
|
|
|
// The page must have been refreshed in some way such as a new document or
|
|
|
|
// new CSS viewport, so we know that there's no velocity, acceleration, and
|
|
|
|
// we have no idea how long painting will take.
|
|
|
|
metrics, gfx::Point(0.0f, 0.0f), gfx::Point(0.0f, 0.0f), 0.0);
|
2013-06-26 06:54:14 -07:00
|
|
|
CSSToScreenScale resolution = metrics.CalculateResolution();
|
2013-06-21 14:03:56 -07:00
|
|
|
metrics.mResolution = resolution / metrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
|
|
|
|
utils->SetResolution(metrics.mResolution.scale, metrics.mResolution.scale);
|
2012-10-11 22:46:24 -07:00
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
// Force a repaint with these metrics. This, among other things, sets the
|
|
|
|
// displayport, so we start with async painting.
|
2013-05-23 18:43:36 -07:00
|
|
|
ProcessUpdateFrame(metrics);
|
2012-09-28 19:18:18 -07:00
|
|
|
}
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
nsresult
|
|
|
|
TabChild::Init()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWebBrowser> webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
|
|
|
|
if (!webBrowser) {
|
|
|
|
NS_ERROR("Couldn't create a nsWebBrowser?");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
webBrowser->SetContainerWindow(this);
|
|
|
|
mWebNav = do_QueryInterface(webBrowser);
|
|
|
|
NS_ASSERTION(mWebNav, "nsWebBrowser doesn't implement nsIWebNavigation?");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(mWebNav));
|
|
|
|
docShellItem->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
|
2012-08-29 08:26:18 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(mWebNav);
|
|
|
|
if (!baseWindow) {
|
|
|
|
NS_ERROR("mWebNav doesn't QI to nsIBaseWindow");
|
2012-09-07 06:23:23 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-08-29 08:26:18 -07:00
|
|
|
}
|
2012-08-08 13:37:57 -07:00
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
mWidget = nsIWidget::CreatePuppetWidget(this);
|
|
|
|
if (!mWidget) {
|
|
|
|
NS_ERROR("couldn't create fake widget");
|
2012-09-07 06:23:23 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-08-29 08:26:18 -07:00
|
|
|
}
|
|
|
|
mWidget->Create(
|
|
|
|
nullptr, 0, // no parents
|
|
|
|
nsIntRect(nsIntPoint(0, 0), nsIntSize(0, 0)),
|
|
|
|
nullptr, // HandleWidgetEvent
|
|
|
|
nullptr // nsDeviceContext
|
|
|
|
);
|
|
|
|
|
|
|
|
baseWindow->InitWindow(0, mWidget, 0, 0, 0, 0);
|
|
|
|
baseWindow->Create();
|
|
|
|
|
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 10:32:37 -08:00
|
|
|
NotifyTabContextUpdated();
|
2012-08-29 08:26:18 -07:00
|
|
|
|
|
|
|
// IPC uses a WebBrowser object for which DNS prefetching is turned off
|
|
|
|
// by default. But here we really want it, so enable it explicitly
|
|
|
|
nsCOMPtr<nsIWebBrowserSetup> webBrowserSetup =
|
|
|
|
do_QueryInterface(baseWindow);
|
|
|
|
if (webBrowserSetup) {
|
|
|
|
webBrowserSetup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_DNS_PREFETCH,
|
|
|
|
true);
|
|
|
|
} else {
|
|
|
|
NS_WARNING("baseWindow doesn't QI to nsIWebBrowserSetup, skipping "
|
|
|
|
"DNS prefetching enable step.");
|
2012-08-08 13:37:57 -07:00
|
|
|
}
|
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWebNav);
|
|
|
|
MOZ_ASSERT(docShell);
|
2013-05-06 21:10:31 -07:00
|
|
|
|
|
|
|
docShell->SetAffectPrivateSessionLifetime(
|
|
|
|
mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME);
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(mWebNav);
|
|
|
|
MOZ_ASSERT(loadContext);
|
|
|
|
loadContext->SetPrivateBrowsing(
|
|
|
|
mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW);
|
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell);
|
|
|
|
NS_ENSURE_TRUE(webProgress, NS_ERROR_FAILURE);
|
|
|
|
webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_LOCATION);
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
void
|
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 10:32:37 -08:00
|
|
|
TabChild::NotifyTabContextUpdated()
|
2012-08-29 08:26:18 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWebNav);
|
|
|
|
MOZ_ASSERT(docShell);
|
|
|
|
|
|
|
|
if (docShell) {
|
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 10:32:37 -08:00
|
|
|
// nsDocShell will do the right thing if we pass NO_APP_ID or
|
|
|
|
// UNKNOWN_APP_ID for aOwnOrContainingAppId.
|
|
|
|
if (IsBrowserElement()) {
|
|
|
|
docShell->SetIsBrowserInsideApp(BrowserOwnerAppId());
|
|
|
|
} else {
|
|
|
|
docShell->SetIsApp(OwnAppId());
|
2012-08-29 08:26:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-17 04:25:22 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN(TabChild)
|
2011-06-16 11:21:08 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
|
2010-05-17 04:25:22 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome2)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWindowProvider)
|
2012-09-28 19:18:18 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
2010-05-17 04:25:22 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsITabChild)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDialogCreator)
|
2012-09-28 19:18:18 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
2010-09-17 19:11:05 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsSupportsWeakReference)
|
2010-05-17 04:25:22 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(TabChild)
|
|
|
|
NS_IMPL_RELEASE(TabChild)
|
2009-11-05 10:14:22 -08:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::SetStatus(uint32_t aStatusType, const PRUnichar* aStatus)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2011-01-04 08:40:54 -08:00
|
|
|
// FIXME/bug 617804: should the platform support this?
|
|
|
|
return NS_OK;
|
2009-11-05 10:14:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetWebBrowser(nsIWebBrowser** aWebBrowser)
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::GetWebBrowser not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::SetWebBrowser(nsIWebBrowser* aWebBrowser)
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::SetWebBrowser not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::GetChromeFlags(uint32_t* aChromeFlags)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2010-07-19 11:33:33 -07:00
|
|
|
*aChromeFlags = mChromeFlags;
|
|
|
|
return NS_OK;
|
2009-11-05 10:14:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::SetChromeFlags(uint32_t aChromeFlags)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("trying to SetChromeFlags from content process?");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::DestroyBrowserWindow()
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::SetWebBrowser not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::SizeBrowserTo(int32_t aCX, int32_t aCY)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::SizeBrowserTo not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::ShowAsModal()
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::ShowAsModal not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TabChild::IsWindowModal(bool* aRetVal)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
*aRetVal = false;
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::ExitModalEventLoop(nsresult aStatus)
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::ExitModalEventLoop not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::SetStatusWithContext(uint32_t aStatusType,
|
2009-11-05 10:14:22 -08:00
|
|
|
const nsAString& aStatusText,
|
|
|
|
nsISupports* aStatusContext)
|
|
|
|
{
|
2011-07-07 08:11:58 -07:00
|
|
|
// FIXME/bug 617804: should the platform support this?
|
|
|
|
return NS_OK;
|
2009-11-05 10:14:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::SetDimensions(uint32_t aFlags, int32_t aX, int32_t aY,
|
|
|
|
int32_t aCx, int32_t aCy)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::SetDimensions not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::GetDimensions(uint32_t aFlags, int32_t* aX,
|
|
|
|
int32_t* aY, int32_t* aCx, int32_t* aCy)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2011-07-15 14:46:56 -07:00
|
|
|
if (aX) {
|
|
|
|
*aX = mOuterRect.x;
|
|
|
|
}
|
|
|
|
if (aY) {
|
|
|
|
*aY = mOuterRect.y;
|
|
|
|
}
|
|
|
|
if (aCx) {
|
|
|
|
*aCx = mOuterRect.width;
|
|
|
|
}
|
|
|
|
if (aCy) {
|
|
|
|
*aCy = mOuterRect.height;
|
|
|
|
}
|
2010-11-03 06:00:49 -07:00
|
|
|
|
2011-07-15 14:46:56 -07:00
|
|
|
return NS_OK;
|
2009-11-05 10:14:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::SetFocus()
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::SetFocus not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TabChild::GetVisibility(bool* aVisibility)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
*aVisibility = true;
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TabChild::SetVisibility(bool aVisibility)
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
2011-06-22 13:43:05 -07:00
|
|
|
// should the platform support this? Bug 666365
|
|
|
|
return NS_OK;
|
2009-11-05 10:14:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetTitle(PRUnichar** aTitle)
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::GetTitle not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::SetTitle(const PRUnichar* aTitle)
|
|
|
|
{
|
2011-01-04 08:40:54 -08:00
|
|
|
// FIXME/bug 617804: should the platform support this?
|
|
|
|
return NS_OK;
|
2009-11-05 10:14:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetSiteWindow(void** aSiteWindow)
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::GetSiteWindow not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::Blur()
|
|
|
|
{
|
2010-11-03 06:00:49 -07:00
|
|
|
NS_NOTREACHED("TabChild::Blur not supported in TabChild");
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::FocusNextElement()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
SendMoveFocus(true);
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::FocusPrevElement()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
SendMoveFocus(false);
|
2009-11-05 10:14:22 -08:00
|
|
|
return NS_OK;
|
2009-10-28 13:41:46 -07:00
|
|
|
}
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2009-12-31 17:34:06 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetInterface(const nsIID & aIID, void **aSink)
|
|
|
|
{
|
|
|
|
// XXXbz should we restrict the set of interfaces we hand out here?
|
|
|
|
// See bug 537429
|
|
|
|
return QueryInterface(aIID, aSink);
|
|
|
|
}
|
|
|
|
|
2009-12-31 17:35:55 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::ProvideWindow(nsIDOMWindow* aParent, uint32_t aChromeFlags,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCalledFromJS,
|
|
|
|
bool aPositionSpecified, bool aSizeSpecified,
|
2009-12-31 17:35:55 -08:00
|
|
|
nsIURI* aURI, const nsAString& aName,
|
2011-09-28 23:19:26 -07:00
|
|
|
const nsACString& aFeatures, bool* aWindowIsNew,
|
2009-12-31 17:35:55 -08:00
|
|
|
nsIDOMWindow** aReturn)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aReturn = nullptr;
|
2009-12-31 17:35:55 -08:00
|
|
|
|
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 10:32:37 -08:00
|
|
|
// If aParent is inside an <iframe mozbrowser> or <iframe mozapp> and this
|
|
|
|
// isn't a request to open a modal-type window, we're going to create a new
|
|
|
|
// <iframe mozbrowser/mozapp> and return its window here.
|
2012-06-12 15:01:25 -07:00
|
|
|
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
|
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 10:32:37 -08:00
|
|
|
if (docshell && docshell->GetIsInBrowserOrApp() &&
|
2012-06-12 15:01:25 -07:00
|
|
|
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
|
|
|
|
|
|
|
|
// Note that BrowserFrameProvideWindow may return NS_ERROR_ABORT if the
|
|
|
|
// open window call was canceled. It's important that we pass this error
|
|
|
|
// code back to our caller.
|
|
|
|
return BrowserFrameProvideWindow(aParent, aURI, aName, aFeatures,
|
|
|
|
aWindowIsNew, aReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, create a new top-level window.
|
2010-07-19 11:33:33 -07:00
|
|
|
PBrowserChild* newChild;
|
|
|
|
if (!CallCreateWindow(&newChild)) {
|
2009-12-31 17:35:55 -08:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
*aWindowIsNew = true;
|
2009-12-31 17:35:55 -08:00
|
|
|
nsCOMPtr<nsIDOMWindow> win =
|
|
|
|
do_GetInterface(static_cast<TabChild*>(newChild)->mWebNav);
|
|
|
|
win.forget(aReturn);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-12 15:01:25 -07:00
|
|
|
nsresult
|
|
|
|
TabChild::BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
|
|
|
|
nsIURI* aURI,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsACString& aFeatures,
|
|
|
|
bool* aWindowIsNew,
|
|
|
|
nsIDOMWindow** aReturn)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aReturn = nullptr;
|
2012-06-12 15:01:25 -07:00
|
|
|
|
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 10:32:37 -08:00
|
|
|
nsRefPtr<TabChild> newChild =
|
|
|
|
new TabChild(/* TabContext */ *this, /* chromeFlags */ 0);
|
2012-08-08 19:58:06 -07:00
|
|
|
if (!NS_SUCCEEDED(newChild->Init())) {
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
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 10:32:37 -08:00
|
|
|
|
|
|
|
// We must use PopupIPCTabContext here; ContentParent will not accept the
|
|
|
|
// result of this->AsIPCTabContext() (which will be a
|
|
|
|
// BrowserFrameIPCTabContext or an AppFrameIPCTabContext), for security
|
|
|
|
// reasons.
|
|
|
|
PopupIPCTabContext context;
|
|
|
|
context.openerChild() = this;
|
|
|
|
context.isBrowserElement() = IsBrowserElement();
|
|
|
|
|
2012-08-08 19:58:06 -07:00
|
|
|
unused << Manager()->SendPBrowserConstructor(
|
|
|
|
// We release this ref in DeallocPBrowserChild
|
|
|
|
nsRefPtr<TabChild>(newChild).forget().get(),
|
2012-11-27 12:43:52 -08:00
|
|
|
IPCTabContext(context, mScrolling), /* chromeFlags */ 0);
|
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 10:32:37 -08:00
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString spec;
|
2012-07-31 20:12:04 -07:00
|
|
|
if (aURI) {
|
|
|
|
aURI->GetSpec(spec);
|
|
|
|
}
|
2012-06-12 15:01:25 -07:00
|
|
|
|
|
|
|
NS_ConvertUTF8toUTF16 url(spec);
|
|
|
|
nsString name(aName);
|
|
|
|
NS_ConvertUTF8toUTF16 features(aFeatures);
|
|
|
|
newChild->SendBrowserFrameOpenWindow(this, url, name,
|
|
|
|
features, aWindowIsNew);
|
|
|
|
if (!*aWindowIsNew) {
|
|
|
|
PBrowserChild::Send__delete__(newChild);
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unfortunately we don't get a window unless we've shown the frame. That's
|
|
|
|
// pretty bogus; see bug 763602.
|
|
|
|
newChild->DoFakeShow();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(newChild->mWebNav);
|
|
|
|
win.forget(aReturn);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-06-14 14:47:56 -07:00
|
|
|
already_AddRefed<nsIDOMWindowUtils>
|
|
|
|
TabChild::GetDOMWindowUtils()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mWebNav);
|
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window);
|
|
|
|
return utils.forget();
|
|
|
|
}
|
|
|
|
|
2012-03-21 11:07:31 -07:00
|
|
|
static nsInterfaceHashtable<nsPtrHashKey<PContentDialogChild>, nsIDialogParamBlock> gActiveDialogs;
|
2010-05-17 04:25:22 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::OpenDialog(uint32_t aType, const nsACString& aName,
|
2010-05-17 04:25:22 -07:00
|
|
|
const nsACString& aFeatures,
|
|
|
|
nsIDialogParamBlock* aArguments,
|
|
|
|
nsIDOMElement* aFrameElement)
|
|
|
|
{
|
|
|
|
if (!gActiveDialogs.IsInitialized()) {
|
2012-05-18 10:30:49 -07:00
|
|
|
gActiveDialogs.Init();
|
2010-05-17 04:25:22 -07:00
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
InfallibleTArray<int32_t> intParams;
|
2010-11-08 18:49:00 -08:00
|
|
|
InfallibleTArray<nsString> stringParams;
|
2010-05-17 04:25:22 -07:00
|
|
|
ParamsToArrays(aArguments, intParams, stringParams);
|
|
|
|
PContentDialogChild* dialog =
|
|
|
|
SendPContentDialogConstructor(aType, nsCString(aName),
|
|
|
|
nsCString(aFeatures), intParams, stringParams);
|
2012-05-18 10:30:49 -07:00
|
|
|
gActiveDialogs.Put(dialog, aArguments);
|
2010-05-17 04:25:22 -07:00
|
|
|
nsIThread *thread = NS_GetCurrentThread();
|
|
|
|
while (gActiveDialogs.GetWeak(dialog)) {
|
|
|
|
if (!NS_ProcessNextEvent(thread)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-11-08 18:49:00 -08:00
|
|
|
ContentDialogChild::Recv__delete__(const InfallibleTArray<int>& aIntParams,
|
|
|
|
const InfallibleTArray<nsString>& aStringParams)
|
2010-05-17 04:25:22 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDialogParamBlock> params;
|
|
|
|
if (gActiveDialogs.Get(this, getter_AddRefs(params))) {
|
|
|
|
TabChild::ArraysToParams(aIntParams, aStringParams, params);
|
|
|
|
gActiveDialogs.Remove(this);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::ParamsToArrays(nsIDialogParamBlock* aParams,
|
2010-11-08 18:49:00 -08:00
|
|
|
InfallibleTArray<int>& aIntParams,
|
|
|
|
InfallibleTArray<nsString>& aStringParams)
|
2010-05-17 04:25:22 -07:00
|
|
|
{
|
|
|
|
if (aParams) {
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0; i < 8; ++i) {
|
|
|
|
int32_t val = 0;
|
2010-05-17 04:25:22 -07:00
|
|
|
aParams->GetInt(i, &val);
|
|
|
|
aIntParams.AppendElement(val);
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t j = 0;
|
2010-11-03 06:02:33 -07:00
|
|
|
nsXPIDLString strVal;
|
|
|
|
while (NS_SUCCEEDED(aParams->GetString(j, getter_Copies(strVal)))) {
|
2010-05-17 04:25:22 -07:00
|
|
|
aStringParams.AppendElement(strVal);
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-08 18:49:00 -08:00
|
|
|
TabChild::ArraysToParams(const InfallibleTArray<int>& aIntParams,
|
|
|
|
const InfallibleTArray<nsString>& aStringParams,
|
2010-05-17 04:25:22 -07:00
|
|
|
nsIDialogParamBlock* aParams)
|
|
|
|
{
|
|
|
|
if (aParams) {
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0; uint32_t(i) < aIntParams.Length(); ++i) {
|
2010-05-17 04:25:22 -07:00
|
|
|
aParams->SetInt(i, aIntParams[i]);
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t j = 0; uint32_t(j) < aStringParams.Length(); ++j) {
|
2010-05-17 04:25:22 -07:00
|
|
|
aParams->SetString(j, aStringParams[j].get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:40 -07:00
|
|
|
void
|
|
|
|
TabChild::DestroyWindow()
|
2009-10-28 13:41:46 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(mWebNav);
|
|
|
|
if (baseWindow)
|
|
|
|
baseWindow->Destroy();
|
2009-07-07 09:26:49 -07:00
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
// NB: the order of mWidget->Destroy() and mRemoteFrame->Destroy()
|
|
|
|
// is important: we want to kill off remote layers before their
|
|
|
|
// frames
|
|
|
|
if (mWidget) {
|
2010-08-20 16:24:41 -07:00
|
|
|
mWidget->Destroy();
|
2010-03-01 11:05:48 -08:00
|
|
|
}
|
2009-07-07 09:26:49 -07:00
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
if (mRemoteFrame) {
|
|
|
|
mRemoteFrame->Destroy();
|
2012-07-30 07:20:58 -07:00
|
|
|
mRemoteFrame = nullptr;
|
2010-07-26 11:49:09 -07:00
|
|
|
}
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
2009-07-14 00:33:50 -07:00
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
bool
|
|
|
|
TabChild::UseDirectCompositor()
|
|
|
|
{
|
|
|
|
return !!CompositorChild::Get();
|
|
|
|
}
|
|
|
|
|
2010-07-21 16:23:03 -07:00
|
|
|
void
|
|
|
|
TabChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
2011-08-09 12:38:26 -07:00
|
|
|
if (mTabChildGlobal) {
|
|
|
|
// The messageManager relays messages via the TabChild which
|
|
|
|
// no longer exists.
|
|
|
|
static_cast<nsFrameMessageManager*>
|
|
|
|
(mTabChildGlobal->mMessageManager.get())->Disconnect();
|
2012-07-30 07:20:58 -07:00
|
|
|
mTabChildGlobal->mMessageManager = nullptr;
|
2011-08-09 12:38:26 -07:00
|
|
|
}
|
2010-07-21 16:23:03 -07:00
|
|
|
}
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
TabChild::~TabChild()
|
|
|
|
{
|
2012-08-29 08:26:18 -07:00
|
|
|
DestroyWindow();
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
nsCOMPtr<nsIWebBrowser> webBrowser = do_QueryInterface(mWebNav);
|
|
|
|
if (webBrowser) {
|
2012-07-30 07:20:58 -07:00
|
|
|
webBrowser->SetContainerWindow(nullptr);
|
2009-11-05 10:14:22 -08:00
|
|
|
}
|
2010-02-20 09:05:20 -08:00
|
|
|
if (mCx) {
|
2010-08-18 03:02:49 -07:00
|
|
|
DestroyCx();
|
2010-02-20 09:05:20 -08:00
|
|
|
}
|
2010-08-23 01:44:43 -07:00
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
if (mTabChildGlobal) {
|
2011-10-17 07:59:28 -07:00
|
|
|
nsEventListenerManager* elm = mTabChildGlobal->GetListenerManager(false);
|
2011-08-09 12:38:26 -07:00
|
|
|
if (elm) {
|
|
|
|
elm->Disconnect();
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
mTabChildGlobal->mTabChild = nullptr;
|
2010-08-23 01:44:43 -07:00
|
|
|
}
|
2009-06-30 13:39:22 -07:00
|
|
|
}
|
|
|
|
|
2012-09-10 21:30:33 -07:00
|
|
|
void
|
|
|
|
TabChild::SetProcessNameToAppName()
|
|
|
|
{
|
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 10:32:37 -08:00
|
|
|
nsCOMPtr<mozIApplication> app = GetOwnApp();
|
2012-09-10 21:30:33 -07:00
|
|
|
if (!app) {
|
|
|
|
return;
|
|
|
|
}
|
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 10:32:37 -08:00
|
|
|
|
2012-09-10 21:30:33 -07:00
|
|
|
nsAutoString appName;
|
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 10:32:37 -08:00
|
|
|
nsresult rv = app->GetName(appName);
|
2012-09-10 21:30:33 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Failed to retrieve app name");
|
|
|
|
return;
|
|
|
|
}
|
2012-10-05 14:54:54 -07:00
|
|
|
|
|
|
|
ContentChild::GetSingleton()->SetProcessName(appName);
|
2012-09-10 21:30:33 -07:00
|
|
|
}
|
|
|
|
|
2012-09-05 09:23:45 -07:00
|
|
|
bool
|
|
|
|
TabChild::IsRootContentDocument()
|
|
|
|
{
|
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 10:32:37 -08:00
|
|
|
// A TabChild is a "root content document" if it's
|
|
|
|
//
|
|
|
|
// - <iframe mozapp> not inside another <iframe mozapp>,
|
|
|
|
// - <iframe mozbrowser> (not mozapp), or
|
|
|
|
// - a vanilla remote frame (<html:iframe remote=true> or <xul:browser
|
|
|
|
// remote=true>).
|
|
|
|
//
|
|
|
|
// Put another way, an iframe is /not/ a "root content document" iff it's a
|
|
|
|
// mozapp inside a mozapp. (This corresponds exactly to !HasAppOwnerApp.)
|
|
|
|
//
|
|
|
|
// Note that we're lying through our teeth here (thus the scare quotes).
|
|
|
|
// <html:iframe remote=true> or <xul:browser remote=true> inside another
|
|
|
|
// content iframe is not actually a root content document, but we say it is.
|
|
|
|
//
|
|
|
|
// We do this because we make a remote frame opaque iff
|
|
|
|
// IsRootContentDocument(), and making vanilla remote frames transparent
|
|
|
|
// breaks our remote reftests.
|
|
|
|
|
|
|
|
return !HasAppOwnerApp();
|
2012-09-05 09:23:45 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
TabChild::RecvLoadURL(const nsCString& uri)
|
2009-06-30 13:39:22 -07:00
|
|
|
{
|
2009-07-29 14:12:15 -07:00
|
|
|
printf("loading %s, %d\n", uri.get(), NS_IsMainThread());
|
2012-09-10 21:30:33 -07:00
|
|
|
SetProcessNameToAppName();
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2009-10-27 19:01:38 -07:00
|
|
|
nsresult rv = mWebNav->LoadURI(NS_ConvertUTF8toUTF16(uri).get(),
|
2012-10-26 01:46:27 -07:00
|
|
|
nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
|
|
|
|
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_OWNER,
|
2009-10-27 19:01:38 -07:00
|
|
|
NULL, NULL, NULL);
|
2009-10-28 13:41:46 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("mWebNav->LoadURI failed. Eating exception, what else can I do?");
|
|
|
|
}
|
2009-11-06 12:43:39 -08:00
|
|
|
|
2013-01-07 06:42:32 -08:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("URL"), uri);
|
|
|
|
#endif
|
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
return true;
|
2009-06-30 13:39:22 -07:00
|
|
|
}
|
|
|
|
|
2013-02-15 14:27:21 -08:00
|
|
|
bool
|
|
|
|
TabChild::RecvCacheFileDescriptor(const nsString& aPath,
|
|
|
|
const FileDescriptor& aFileDescriptor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(!aPath.IsEmpty());
|
2013-05-29 17:56:09 -07:00
|
|
|
MOZ_ASSERT(!mAppPackageFileDescriptorRecved);
|
|
|
|
|
|
|
|
mAppPackageFileDescriptorRecved = true;
|
2013-02-15 14:27:21 -08:00
|
|
|
|
|
|
|
// aFileDescriptor may be invalid here, but the callback will choose how to
|
|
|
|
// handle it.
|
|
|
|
|
|
|
|
// First see if we already have a request for this path.
|
|
|
|
const CachedFileDescriptorInfo search(aPath);
|
|
|
|
uint32_t index =
|
|
|
|
mCachedFileDescriptorInfos.IndexOf(search, 0,
|
|
|
|
search.PathOnlyComparator());
|
|
|
|
if (index == mCachedFileDescriptorInfos.NoIndex) {
|
|
|
|
// We haven't had any requests for this path yet. Assume that we will
|
|
|
|
// in a little while and save the file descriptor here.
|
|
|
|
mCachedFileDescriptorInfos.AppendElement(
|
|
|
|
new CachedFileDescriptorInfo(aPath, aFileDescriptor));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoPtr<CachedFileDescriptorInfo>& info =
|
|
|
|
mCachedFileDescriptorInfos[index];
|
|
|
|
|
|
|
|
MOZ_ASSERT(info);
|
|
|
|
MOZ_ASSERT(info->mPath == aPath);
|
|
|
|
MOZ_ASSERT(!info->mFileDescriptor.IsValid());
|
|
|
|
MOZ_ASSERT(info->mCallback);
|
|
|
|
|
|
|
|
// If this callback has been canceled then we can simply close the file
|
|
|
|
// descriptor and forget about the callback.
|
|
|
|
if (info->mCanceled) {
|
|
|
|
// Only close if this is a valid file descriptor.
|
|
|
|
if (aFileDescriptor.IsValid()) {
|
|
|
|
nsRefPtr<CloseFileRunnable> runnable =
|
|
|
|
new CloseFileRunnable(aFileDescriptor);
|
|
|
|
runnable->Dispatch();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Not canceled so fire the callback.
|
|
|
|
info->mFileDescriptor = aFileDescriptor;
|
|
|
|
|
|
|
|
// We don't need a runnable here because we should already be at the top
|
|
|
|
// of the event loop. Just fire immediately.
|
|
|
|
info->FireCallback();
|
|
|
|
}
|
|
|
|
|
|
|
|
mCachedFileDescriptorInfos.RemoveElementAt(index);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::GetCachedFileDescriptor(const nsAString& aPath,
|
|
|
|
nsICachedFileDescriptorListener* aCallback)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(!aPath.IsEmpty());
|
|
|
|
MOZ_ASSERT(aCallback);
|
|
|
|
|
|
|
|
// First see if we've already received a cached file descriptor for this
|
|
|
|
// path.
|
|
|
|
const CachedFileDescriptorInfo search(aPath);
|
|
|
|
uint32_t index =
|
|
|
|
mCachedFileDescriptorInfos.IndexOf(search, 0,
|
|
|
|
search.PathOnlyComparator());
|
|
|
|
if (index == mCachedFileDescriptorInfos.NoIndex) {
|
|
|
|
// We haven't received a file descriptor for this path yet. Assume that
|
|
|
|
// we will in a little while and save the request here.
|
2013-05-29 17:56:09 -07:00
|
|
|
if (!mAppPackageFileDescriptorRecved) {
|
|
|
|
mCachedFileDescriptorInfos.AppendElement(
|
|
|
|
new CachedFileDescriptorInfo(aPath, aCallback));
|
|
|
|
}
|
2013-02-15 14:27:21 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoPtr<CachedFileDescriptorInfo>& info =
|
|
|
|
mCachedFileDescriptorInfos[index];
|
|
|
|
|
|
|
|
MOZ_ASSERT(info);
|
|
|
|
MOZ_ASSERT(info->mPath == aPath);
|
|
|
|
|
2013-04-26 14:43:45 -07:00
|
|
|
// If we got a previous request for this file descriptor that was then
|
|
|
|
// canceled, insert the new request ahead of the old in the queue so that
|
|
|
|
// it will be serviced first.
|
|
|
|
if (info->mCanceled) {
|
|
|
|
// This insertion will change the array and invalidate |info|, so
|
|
|
|
// be careful not to touch |info| after this.
|
|
|
|
mCachedFileDescriptorInfos.InsertElementAt(index,
|
|
|
|
new CachedFileDescriptorInfo(aPath, aCallback));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(!info->mCallback);
|
2013-02-15 14:27:21 -08:00
|
|
|
info->mCallback = aCallback;
|
|
|
|
|
|
|
|
nsRefPtr<CachedFileDescriptorCallbackRunnable> runnable =
|
|
|
|
new CachedFileDescriptorCallbackRunnable(info.forget());
|
|
|
|
runnable->Dispatch();
|
|
|
|
|
|
|
|
mCachedFileDescriptorInfos.RemoveElementAt(index);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::CancelCachedFileDescriptorCallback(
|
|
|
|
const nsAString& aPath,
|
|
|
|
nsICachedFileDescriptorListener* aCallback)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(!aPath.IsEmpty());
|
|
|
|
MOZ_ASSERT(aCallback);
|
|
|
|
|
2013-05-29 17:56:09 -07:00
|
|
|
if (mAppPackageFileDescriptorRecved) {
|
|
|
|
// Already received cached file descriptor for the app package. Nothing to do here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-15 14:27:21 -08:00
|
|
|
const CachedFileDescriptorInfo search(aPath, aCallback);
|
|
|
|
uint32_t index =
|
|
|
|
mCachedFileDescriptorInfos.IndexOf(search, 0,
|
|
|
|
search.PathAndCallbackComparator());
|
|
|
|
if (index == mCachedFileDescriptorInfos.NoIndex) {
|
|
|
|
// Nothing to do here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoPtr<CachedFileDescriptorInfo>& info =
|
|
|
|
mCachedFileDescriptorInfos[index];
|
|
|
|
|
|
|
|
MOZ_ASSERT(info);
|
|
|
|
MOZ_ASSERT(info->mPath == aPath);
|
|
|
|
MOZ_ASSERT(!info->mFileDescriptor.IsValid());
|
|
|
|
MOZ_ASSERT(info->mCallback == aCallback);
|
|
|
|
MOZ_ASSERT(!info->mCanceled);
|
|
|
|
|
|
|
|
// Set this flag so that we will close the file descriptor when it arrives.
|
|
|
|
info->mCanceled = true;
|
|
|
|
}
|
|
|
|
|
2012-06-12 15:01:25 -07:00
|
|
|
void
|
|
|
|
TabChild::DoFakeShow()
|
|
|
|
{
|
|
|
|
RecvShow(nsIntSize(0, 0));
|
|
|
|
mDidFakeShow = true;
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2010-08-20 16:24:40 -07:00
|
|
|
TabChild::RecvShow(const nsIntSize& size)
|
2009-06-30 13:39:22 -07:00
|
|
|
{
|
2012-08-29 08:26:18 -07:00
|
|
|
|
2012-06-12 15:01:25 -07:00
|
|
|
if (mDidFakeShow) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:40 -07:00
|
|
|
printf("[TabChild] SHOW (w,h)= (%d, %d)\n", size.width, size.height);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(mWebNav);
|
|
|
|
if (!baseWindow) {
|
|
|
|
NS_ERROR("mWebNav doesn't QI to nsIBaseWindow");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
if (!InitRenderingState()) {
|
2011-08-09 12:38:26 -07:00
|
|
|
// We can fail to initialize our widget if the <browser
|
|
|
|
// remote> has already been destroyed, and we couldn't hook
|
|
|
|
// into the parent-process's layer system. That's not a fatal
|
|
|
|
// error.
|
|
|
|
return true;
|
2010-08-20 16:24:40 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
baseWindow->SetVisibility(true);
|
2010-08-20 16:24:40 -07:00
|
|
|
|
|
|
|
return InitTabChildGlobal();
|
2009-06-30 13:39:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2013-03-04 06:37:43 -08:00
|
|
|
TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const ScreenOrientation& orientation)
|
2009-06-30 13:39:22 -07:00
|
|
|
{
|
2011-08-09 12:38:26 -07:00
|
|
|
if (!mRemoteFrame) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-07-15 14:46:56 -07:00
|
|
|
mOuterRect.x = rect.x;
|
|
|
|
mOuterRect.y = rect.y;
|
|
|
|
mOuterRect.width = rect.width;
|
|
|
|
mOuterRect.height = rect.height;
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2012-11-21 18:40:57 -08:00
|
|
|
mOrientation = orientation;
|
2013-06-14 13:11:29 -07:00
|
|
|
mInnerSize = ScreenIntSize::FromUnknownSize(
|
|
|
|
gfx::IntSize(size.width, size.height));
|
2010-08-20 16:24:40 -07:00
|
|
|
mWidget->Resize(0, 0, size.width, size.height,
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2009-06-30 13:39:22 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(mWebNav);
|
2010-08-20 16:24:40 -07:00
|
|
|
baseWin->SetPositionAndSize(0, 0, size.width, size.height,
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2011-07-15 14:46:56 -07:00
|
|
|
|
2012-10-11 22:46:24 -07:00
|
|
|
HandlePossibleViewportChange();
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-06-30 13:39:22 -07:00
|
|
|
}
|
2009-10-29 10:58:31 -07:00
|
|
|
|
2012-08-08 21:39:02 -07:00
|
|
|
void
|
|
|
|
TabChild::DispatchMessageManagerMessage(const nsAString& aMessageName,
|
|
|
|
const nsACString& aJSONData)
|
2012-07-19 23:48:27 -07:00
|
|
|
{
|
2013-05-22 09:05:27 -07:00
|
|
|
AutoSafeJSContext cx;
|
|
|
|
JS::Rooted<JS::Value> json(cx, JSVAL_NULL);
|
2012-08-01 23:02:29 -07:00
|
|
|
StructuredCloneData cloneData;
|
|
|
|
JSAutoStructuredCloneBuffer buffer;
|
2013-05-22 09:05:27 -07:00
|
|
|
if (JS_ParseJSON(cx,
|
2012-08-08 21:39:02 -07:00
|
|
|
static_cast<const jschar*>(NS_ConvertUTF8toUTF16(aJSONData).get()),
|
|
|
|
aJSONData.Length(),
|
2013-05-29 01:29:39 -07:00
|
|
|
&json)) {
|
2013-05-22 09:05:27 -07:00
|
|
|
WriteStructuredClone(cx, json, buffer, cloneData.mClosure);
|
2012-08-02 08:02:06 -07:00
|
|
|
cloneData.mData = buffer.data();
|
|
|
|
cloneData.mDataLength = buffer.nbytes();
|
2012-08-01 23:02:29 -07:00
|
|
|
}
|
|
|
|
|
2013-05-22 09:05:27 -07:00
|
|
|
nsFrameScriptCx frameScriptCx(static_cast<nsIWebBrowserChrome*>(this), this);
|
2012-07-19 23:48:27 -07:00
|
|
|
// Let the BrowserElementScrolling helper (if it exists) for this
|
|
|
|
// content manipulate the frame state.
|
2012-08-01 23:02:29 -07:00
|
|
|
nsRefPtr<nsFrameMessageManager> mm =
|
|
|
|
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
2013-04-19 15:18:33 -07:00
|
|
|
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal),
|
2013-05-20 05:40:06 -07:00
|
|
|
aMessageName, false, &cloneData, JS::NullPtr(), nullptr);
|
2012-08-08 21:39:02 -07:00
|
|
|
}
|
|
|
|
|
2012-11-22 17:25:28 -08:00
|
|
|
static void
|
2013-05-30 18:30:13 -07:00
|
|
|
ScrollWindowTo(nsIDOMWindow* aWindow, const CSSPoint& aPoint)
|
2012-11-22 17:25:28 -08:00
|
|
|
{
|
|
|
|
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(aWindow);
|
|
|
|
nsIScrollableFrame* sf = window->GetScrollFrame();
|
|
|
|
|
|
|
|
if (sf) {
|
|
|
|
sf->ScrollToCSSPixelsApproximate(aPoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-08 21:39:02 -07:00
|
|
|
bool
|
|
|
|
TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
|
|
|
|
{
|
2013-05-23 18:43:36 -07:00
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
|
|
|
|
|
|
|
|
uint32_t presShellId;
|
|
|
|
nsresult rv = utils->GetPresShellId(&presShellId);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
if (NS_SUCCEEDED(rv) && aFrameMetrics.mPresShellId != presShellId) {
|
2013-06-13 17:33:16 -07:00
|
|
|
// We've recieved a message that is out of date and we want to ignore.
|
|
|
|
// However we can't reply without painting so we reply by painting the
|
|
|
|
// exact same thing as we did before.
|
|
|
|
return ProcessUpdateFrame(mLastMetrics);
|
2013-05-23 18:43:36 -07:00
|
|
|
}
|
|
|
|
return ProcessUpdateFrame(aFrameMetrics);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::ProcessUpdateFrame(const FrameMetrics& aFrameMetrics)
|
|
|
|
{
|
2012-08-08 21:39:02 -07:00
|
|
|
if (!mCx || !mTabChildGlobal) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-03 06:52:44 -07:00
|
|
|
CSSRect cssCompositedRect =
|
2012-11-28 01:18:12 -08:00
|
|
|
AsyncPanZoomController::CalculateCompositedRectInCssPixels(aFrameMetrics);
|
2012-09-28 19:18:18 -07:00
|
|
|
// The BrowserElementScrolling helper must know about these updated metrics
|
|
|
|
// for other functions it performs, such as double tap handling.
|
2012-08-08 21:39:02 -07:00
|
|
|
nsCString data;
|
2012-09-28 19:16:34 -07:00
|
|
|
data += nsPrintfCString("{ \"x\" : %d", NS_lround(aFrameMetrics.mScrollOffset.x));
|
|
|
|
data += nsPrintfCString(", \"y\" : %d", NS_lround(aFrameMetrics.mScrollOffset.y));
|
2012-10-11 22:46:24 -07:00
|
|
|
data += nsPrintfCString(", \"viewport\" : ");
|
|
|
|
data += nsPrintfCString("{ \"width\" : %f", aFrameMetrics.mViewport.width);
|
|
|
|
data += nsPrintfCString(", \"height\" : %f", aFrameMetrics.mViewport.height);
|
|
|
|
data += nsPrintfCString(" }");
|
2012-08-08 21:39:02 -07:00
|
|
|
data += nsPrintfCString(", \"displayPort\" : ");
|
2012-09-28 19:16:34 -07:00
|
|
|
data += nsPrintfCString("{ \"x\" : %f", aFrameMetrics.mDisplayPort.x);
|
|
|
|
data += nsPrintfCString(", \"y\" : %f", aFrameMetrics.mDisplayPort.y);
|
|
|
|
data += nsPrintfCString(", \"width\" : %f", aFrameMetrics.mDisplayPort.width);
|
|
|
|
data += nsPrintfCString(", \"height\" : %f", aFrameMetrics.mDisplayPort.height);
|
2012-08-08 21:39:02 -07:00
|
|
|
data += nsPrintfCString(" }");
|
2012-09-28 19:16:34 -07:00
|
|
|
data += nsPrintfCString(", \"compositionBounds\" : ");
|
|
|
|
data += nsPrintfCString("{ \"x\" : %d", aFrameMetrics.mCompositionBounds.x);
|
|
|
|
data += nsPrintfCString(", \"y\" : %d", aFrameMetrics.mCompositionBounds.y);
|
|
|
|
data += nsPrintfCString(", \"width\" : %d", aFrameMetrics.mCompositionBounds.width);
|
|
|
|
data += nsPrintfCString(", \"height\" : %d", aFrameMetrics.mCompositionBounds.height);
|
2012-08-08 21:39:02 -07:00
|
|
|
data += nsPrintfCString(" }");
|
|
|
|
data += nsPrintfCString(", \"cssPageRect\" : ");
|
2012-09-28 19:16:34 -07:00
|
|
|
data += nsPrintfCString("{ \"x\" : %f", aFrameMetrics.mScrollableRect.x);
|
|
|
|
data += nsPrintfCString(", \"y\" : %f", aFrameMetrics.mScrollableRect.y);
|
|
|
|
data += nsPrintfCString(", \"width\" : %f", aFrameMetrics.mScrollableRect.width);
|
|
|
|
data += nsPrintfCString(", \"height\" : %f", aFrameMetrics.mScrollableRect.height);
|
2012-08-08 21:39:02 -07:00
|
|
|
data += nsPrintfCString(" }");
|
2012-11-28 01:18:12 -08:00
|
|
|
data += nsPrintfCString(", \"cssCompositedRect\" : ");
|
|
|
|
data += nsPrintfCString("{ \"width\" : %f", cssCompositedRect.width);
|
|
|
|
data += nsPrintfCString(", \"height\" : %f", cssCompositedRect.height);
|
|
|
|
data += nsPrintfCString(" }");
|
2012-08-08 21:39:02 -07:00
|
|
|
data += nsPrintfCString(" }");
|
|
|
|
|
|
|
|
DispatchMessageManagerMessage(NS_LITERAL_STRING("Viewport:Change"), data);
|
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
|
|
|
|
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mWebNav);
|
|
|
|
|
|
|
|
utils->SetScrollPositionClampingScrollPortSize(
|
2012-10-11 22:46:24 -07:00
|
|
|
cssCompositedRect.width, cssCompositedRect.height);
|
2012-11-22 17:25:28 -08:00
|
|
|
ScrollWindowTo(window, aFrameMetrics.mScrollOffset);
|
2013-06-26 06:54:14 -07:00
|
|
|
CSSToScreenScale resolution = aFrameMetrics.CalculateResolution();
|
2013-06-14 13:11:44 -07:00
|
|
|
utils->SetResolution(resolution.scale, resolution.scale);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
|
|
|
nsCOMPtr<nsIDOMElement> docElement;
|
|
|
|
mWebNav->GetDocument(getter_AddRefs(domDoc));
|
|
|
|
if (domDoc) {
|
|
|
|
domDoc->GetDocumentElement(getter_AddRefs(docElement));
|
|
|
|
if (docElement) {
|
|
|
|
utils->SetDisplayPortForElement(
|
|
|
|
aFrameMetrics.mDisplayPort.x, aFrameMetrics.mDisplayPort.y,
|
|
|
|
aFrameMetrics.mDisplayPort.width, aFrameMetrics.mDisplayPort.height,
|
|
|
|
docElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mLastMetrics = aFrameMetrics;
|
|
|
|
|
2012-08-08 21:39:02 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-06-10 06:05:44 -07:00
|
|
|
TabChild::RecvHandleDoubleTap(const CSSIntPoint& aPoint)
|
2012-08-08 21:39:02 -07:00
|
|
|
{
|
|
|
|
if (!mCx || !mTabChildGlobal) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCString data;
|
|
|
|
data += nsPrintfCString("{ \"x\" : %d", aPoint.x);
|
|
|
|
data += nsPrintfCString(", \"y\" : %d", aPoint.y);
|
|
|
|
data += nsPrintfCString(" }");
|
|
|
|
|
|
|
|
DispatchMessageManagerMessage(NS_LITERAL_STRING("Gesture:DoubleTap"), data);
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
return true;
|
2012-07-19 23:48:27 -07:00
|
|
|
}
|
|
|
|
|
2012-09-14 18:16:32 -07:00
|
|
|
bool
|
2013-06-10 06:05:44 -07:00
|
|
|
TabChild::RecvHandleSingleTap(const CSSIntPoint& aPoint)
|
2012-09-14 18:16:32 -07:00
|
|
|
{
|
|
|
|
if (!mCx || !mTabChildGlobal) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-05 16:32:19 -08:00
|
|
|
RecvMouseEvent(NS_LITERAL_STRING("mousemove"), aPoint.x, aPoint.y, 0, 1, 0, false);
|
2012-09-14 18:16:32 -07:00
|
|
|
RecvMouseEvent(NS_LITERAL_STRING("mousedown"), aPoint.x, aPoint.y, 0, 1, 0, false);
|
|
|
|
RecvMouseEvent(NS_LITERAL_STRING("mouseup"), aPoint.x, aPoint.y, 0, 1, 0, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-11-08 11:35:02 -08:00
|
|
|
bool
|
2013-06-10 06:05:44 -07:00
|
|
|
TabChild::RecvHandleLongTap(const CSSIntPoint& aPoint)
|
2012-11-08 11:35:02 -08:00
|
|
|
{
|
|
|
|
if (!mCx || !mTabChildGlobal) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
RecvMouseEvent(NS_LITERAL_STRING("contextmenu"), aPoint.x, aPoint.y,
|
|
|
|
2 /* Right button */,
|
|
|
|
1 /* Click count */,
|
|
|
|
0 /* Modifiers */,
|
|
|
|
false /* Ignore root scroll frame */);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-11-05 10:14:22 -08:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
TabChild::RecvActivate()
|
2009-11-05 10:14:22 -08:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWebBrowserFocus> browser = do_QueryInterface(mWebNav);
|
|
|
|
browser->Activate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-17 17:08:32 -07:00
|
|
|
bool TabChild::RecvDeactivate()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWebBrowserFocus> browser = do_QueryInterface(mWebNav);
|
|
|
|
browser->Deactivate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-11-05 10:21:09 -08:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
TabChild::RecvMouseEvent(const nsString& aType,
|
|
|
|
const float& aX,
|
|
|
|
const float& aY,
|
2012-08-22 08:56:38 -07:00
|
|
|
const int32_t& aButton,
|
|
|
|
const int32_t& aClickCount,
|
|
|
|
const int32_t& aModifiers,
|
2010-07-19 11:33:33 -07:00
|
|
|
const bool& aIgnoreRootScrollFrame)
|
2009-11-05 10:21:09 -08:00
|
|
|
{
|
2013-05-23 08:52:06 -07:00
|
|
|
DispatchMouseEvent(aType, aX, aY, aButton, aClickCount, aModifiers,
|
|
|
|
aIgnoreRootScrollFrame);
|
2009-11-05 10:21:09 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-21 17:32:43 -07:00
|
|
|
bool
|
|
|
|
TabChild::RecvRealMouseEvent(const nsMouseEvent& event)
|
|
|
|
{
|
|
|
|
nsMouseEvent localEvent(event);
|
|
|
|
DispatchWidgetEvent(localEvent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-08-11 18:42:34 -07:00
|
|
|
TabChild::RecvMouseWheelEvent(const WheelEvent& event)
|
2011-06-21 17:32:43 -07:00
|
|
|
{
|
2012-08-11 18:42:34 -07:00
|
|
|
WheelEvent localEvent(event);
|
2011-06-21 17:32:43 -07:00
|
|
|
DispatchWidgetEvent(localEvent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-14 18:16:32 -07:00
|
|
|
void
|
2013-01-05 06:53:16 -08:00
|
|
|
TabChild::DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
|
|
|
|
const nsIntPoint& aRefPoint)
|
2012-07-15 19:58:43 -07:00
|
|
|
{
|
2013-01-05 06:53:16 -08:00
|
|
|
MOZ_ASSERT(aMsg == NS_MOUSE_MOVE || aMsg == NS_MOUSE_BUTTON_DOWN ||
|
|
|
|
aMsg == NS_MOUSE_BUTTON_UP);
|
2012-09-14 18:16:32 -07:00
|
|
|
|
2013-01-05 06:53:16 -08:00
|
|
|
nsMouseEvent event(true, aMsg, NULL,
|
2012-09-14 18:16:32 -07:00
|
|
|
nsMouseEvent::eReal, nsMouseEvent::eNormal);
|
2013-01-05 06:53:16 -08:00
|
|
|
event.refPoint = aRefPoint;
|
|
|
|
event.time = aTime;
|
2012-09-14 18:16:32 -07:00
|
|
|
event.button = nsMouseEvent::eLeftButton;
|
2013-01-24 06:53:39 -08:00
|
|
|
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
|
2013-01-05 06:53:16 -08:00
|
|
|
if (aMsg != NS_MOUSE_MOVE) {
|
2012-09-14 18:16:32 -07:00
|
|
|
event.clickCount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DispatchWidgetEvent(event);
|
|
|
|
}
|
|
|
|
|
2013-04-05 01:49:00 -07:00
|
|
|
static Touch*
|
2013-01-05 06:53:16 -08:00
|
|
|
GetTouchForIdentifier(const nsTouchEvent& aEvent, int32_t aId)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < aEvent.touches.Length(); ++i) {
|
2013-04-05 01:49:00 -07:00
|
|
|
Touch* touch = static_cast<Touch*>(aEvent.touches[i].get());
|
2013-01-05 06:53:16 -08:00
|
|
|
if (touch->mIdentifier == aId) {
|
|
|
|
return touch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::UpdateTapState(const nsTouchEvent& aEvent, nsEventStatus aStatus)
|
|
|
|
{
|
|
|
|
static bool sHavePrefs;
|
|
|
|
static bool sClickHoldContextMenusEnabled;
|
|
|
|
static nsIntSize sDragThreshold;
|
|
|
|
static int32_t sContextMenuDelayMs;
|
|
|
|
if (!sHavePrefs) {
|
|
|
|
sHavePrefs = true;
|
|
|
|
Preferences::AddBoolVarCache(&sClickHoldContextMenusEnabled,
|
|
|
|
"ui.click_hold_context_menus", true);
|
|
|
|
Preferences::AddIntVarCache(&sDragThreshold.width,
|
|
|
|
"ui.dragThresholdX", 25);
|
|
|
|
Preferences::AddIntVarCache(&sDragThreshold.height,
|
|
|
|
"ui.dragThresholdY", 25);
|
|
|
|
Preferences::AddIntVarCache(&sContextMenuDelayMs,
|
|
|
|
"ui.click_hold_context_menus.delay", 500);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool currentlyTrackingTouch = (mActivePointerId >= 0);
|
|
|
|
if (aEvent.message == NS_TOUCH_START) {
|
|
|
|
if (currentlyTrackingTouch || aEvent.touches.Length() > 1) {
|
|
|
|
// We're tracking a possible tap for another point, or we saw a
|
|
|
|
// touchstart for a later pointer after we canceled tracking of
|
|
|
|
// the first point. Ignore this one.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (aStatus == nsEventStatus_eConsumeNoDefault ||
|
|
|
|
nsIPresShell::gPreventMouseEvents) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-05 01:49:00 -07:00
|
|
|
Touch* touch = static_cast<Touch*>(aEvent.touches[0].get());
|
2013-01-05 06:53:16 -08:00
|
|
|
mGestureDownPoint = touch->mRefPoint;
|
|
|
|
mActivePointerId = touch->mIdentifier;
|
|
|
|
if (sClickHoldContextMenusEnabled) {
|
|
|
|
MOZ_ASSERT(!mTapHoldTimer);
|
|
|
|
mTapHoldTimer = NewRunnableMethod(this,
|
|
|
|
&TabChild::FireContextMenuEvent);
|
|
|
|
MessageLoop::current()->PostDelayedTask(FROM_HERE, mTapHoldTimer,
|
|
|
|
sContextMenuDelayMs);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we're not tracking a touch or this event doesn't include the
|
|
|
|
// one we care about, bail.
|
|
|
|
if (!currentlyTrackingTouch) {
|
|
|
|
return;
|
|
|
|
}
|
2013-04-05 01:49:00 -07:00
|
|
|
Touch* trackedTouch = GetTouchForIdentifier(aEvent, mActivePointerId);
|
2013-01-05 06:53:16 -08:00
|
|
|
if (!trackedTouch) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntPoint currentPoint = trackedTouch->mRefPoint;
|
|
|
|
int64_t time = aEvent.time;
|
|
|
|
switch (aEvent.message) {
|
|
|
|
case NS_TOUCH_MOVE:
|
|
|
|
if (abs(currentPoint.x - mGestureDownPoint.x) > sDragThreshold.width ||
|
|
|
|
abs(currentPoint.y - mGestureDownPoint.y) > sDragThreshold.height) {
|
|
|
|
CancelTapTracking();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case NS_TOUCH_END:
|
|
|
|
if (!nsIPresShell::gPreventMouseEvents) {
|
|
|
|
DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, currentPoint);
|
|
|
|
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, currentPoint);
|
|
|
|
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_UP, time, currentPoint);
|
|
|
|
}
|
|
|
|
// fall through
|
|
|
|
case NS_TOUCH_CANCEL:
|
|
|
|
CancelTapTracking();
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_WARNING("Unknown touch event type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::FireContextMenuEvent()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mTapHoldTimer && mActivePointerId >= 0);
|
2013-05-23 08:52:06 -07:00
|
|
|
bool defaultPrevented = DispatchMouseEvent(NS_LITERAL_STRING("contextmenu"),
|
|
|
|
mGestureDownPoint.x, mGestureDownPoint.y,
|
|
|
|
2 /* Right button */,
|
|
|
|
1 /* Click count */,
|
|
|
|
0 /* Modifiers */,
|
|
|
|
false /* Ignore root scroll frame */);
|
|
|
|
|
|
|
|
// Fire a click event if someone didn't call preventDefault() on the context
|
|
|
|
// menu event.
|
|
|
|
if (defaultPrevented) {
|
|
|
|
CancelTapTracking();
|
|
|
|
} else if (mTapHoldTimer) {
|
|
|
|
mTapHoldTimer->Cancel();
|
|
|
|
mTapHoldTimer = nullptr;
|
|
|
|
}
|
2013-01-05 06:53:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::CancelTapTracking()
|
|
|
|
{
|
|
|
|
mActivePointerId = -1;
|
|
|
|
if (mTapHoldTimer) {
|
|
|
|
mTapHoldTimer->Cancel();
|
|
|
|
}
|
|
|
|
mTapHoldTimer = nullptr;
|
|
|
|
}
|
|
|
|
|
2012-09-14 18:16:32 -07:00
|
|
|
bool
|
|
|
|
TabChild::RecvRealTouchEvent(const nsTouchEvent& aEvent)
|
|
|
|
{
|
|
|
|
nsTouchEvent localEvent(aEvent);
|
|
|
|
nsEventStatus status = DispatchWidgetEvent(localEvent);
|
|
|
|
|
|
|
|
if (IsAsyncPanZoomEnabled()) {
|
|
|
|
nsCOMPtr<nsPIDOMWindow> outerWindow = do_GetInterface(mWebNav);
|
|
|
|
nsCOMPtr<nsPIDOMWindow> innerWindow = outerWindow->GetCurrentInnerWindow();
|
2012-07-15 19:58:43 -07:00
|
|
|
|
2012-09-14 18:16:32 -07:00
|
|
|
if (innerWindow && innerWindow->HasTouchEventListeners()) {
|
|
|
|
SendContentReceivedTouch(nsIPresShell::gPreventMouseEvents);
|
2012-07-15 19:58:43 -07:00
|
|
|
}
|
2013-01-05 06:53:16 -08:00
|
|
|
} else {
|
|
|
|
UpdateTapState(aEvent, status);
|
2012-09-14 18:16:32 -07:00
|
|
|
}
|
2012-07-15 19:58:43 -07:00
|
|
|
|
2012-09-14 18:16:32 -07:00
|
|
|
return true;
|
2012-07-15 19:58:43 -07:00
|
|
|
}
|
2011-06-21 17:32:43 -07:00
|
|
|
|
2012-08-22 03:54:20 -07:00
|
|
|
bool
|
|
|
|
TabChild::RecvRealTouchMoveEvent(const nsTouchEvent& aEvent)
|
|
|
|
{
|
2012-09-14 18:16:32 -07:00
|
|
|
return RecvRealTouchEvent(aEvent);
|
2012-08-22 03:54:20 -07:00
|
|
|
}
|
|
|
|
|
2011-06-21 17:32:43 -07:00
|
|
|
bool
|
|
|
|
TabChild::RecvRealKeyEvent(const nsKeyEvent& event)
|
|
|
|
{
|
|
|
|
nsKeyEvent localEvent(event);
|
|
|
|
DispatchWidgetEvent(localEvent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-03-18 23:52:18 -07:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
TabChild::RecvKeyEvent(const nsString& aType,
|
2012-08-22 08:56:38 -07:00
|
|
|
const int32_t& aKeyCode,
|
|
|
|
const int32_t& aCharCode,
|
|
|
|
const int32_t& aModifiers,
|
2010-07-19 11:33:33 -07:00
|
|
|
const bool& aPreventDefault)
|
2010-03-18 23:52:18 -07:00
|
|
|
{
|
2012-09-28 19:18:18 -07:00
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
|
2010-03-18 23:52:18 -07:00
|
|
|
NS_ENSURE_TRUE(utils, true);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ignored = false;
|
2010-03-18 23:52:18 -07:00
|
|
|
utils->SendKeyEvent(aType, aKeyCode, aCharCode,
|
|
|
|
aModifiers, aPreventDefault, &ignored);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-17 01:07:42 -07:00
|
|
|
bool
|
|
|
|
TabChild::RecvCompositionEvent(const nsCompositionEvent& event)
|
|
|
|
{
|
|
|
|
nsCompositionEvent localEvent(event);
|
|
|
|
DispatchWidgetEvent(localEvent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::RecvTextEvent(const nsTextEvent& event)
|
|
|
|
{
|
|
|
|
nsTextEvent localEvent(event);
|
|
|
|
DispatchWidgetEvent(localEvent);
|
|
|
|
IPC::ParamTraits<nsTextEvent>::Free(event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::RecvSelectionEvent(const nsSelectionEvent& event)
|
|
|
|
{
|
|
|
|
nsSelectionEvent localEvent(event);
|
|
|
|
DispatchWidgetEvent(localEvent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-15 19:58:43 -07:00
|
|
|
nsEventStatus
|
2010-08-17 01:07:42 -07:00
|
|
|
TabChild::DispatchWidgetEvent(nsGUIEvent& event)
|
|
|
|
{
|
2010-09-23 20:28:15 -07:00
|
|
|
if (!mWidget)
|
2012-07-15 19:58:43 -07:00
|
|
|
return nsEventStatus_eConsumeNoDefault;
|
2010-08-17 01:07:42 -07:00
|
|
|
|
|
|
|
nsEventStatus status;
|
2010-09-23 20:28:15 -07:00
|
|
|
event.widget = mWidget;
|
2012-07-15 19:58:43 -07:00
|
|
|
NS_ENSURE_SUCCESS(mWidget->DispatchEvent(&event, status),
|
|
|
|
nsEventStatus_eConsumeNoDefault);
|
|
|
|
return status;
|
2010-08-17 01:07:42 -07:00
|
|
|
}
|
|
|
|
|
2010-10-26 15:20:53 -07:00
|
|
|
PDocumentRendererChild*
|
|
|
|
TabChild::AllocPDocumentRenderer(const nsRect& documentRect,
|
2010-10-26 15:20:53 -07:00
|
|
|
const gfxMatrix& transform,
|
2010-08-17 01:07:42 -07:00
|
|
|
const nsString& bgcolor,
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint32_t& renderFlags,
|
2010-10-26 15:20:53 -07:00
|
|
|
const bool& flushLayout,
|
|
|
|
const nsIntSize& renderSize)
|
2009-10-29 10:58:31 -07:00
|
|
|
{
|
2010-10-26 15:20:53 -07:00
|
|
|
return new DocumentRendererChild();
|
2009-10-29 10:58:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2009-12-03 00:16:14 -08:00
|
|
|
TabChild::DeallocPDocumentRenderer(PDocumentRendererChild* actor)
|
2009-10-29 10:58:31 -07:00
|
|
|
{
|
2009-12-03 00:16:14 -08:00
|
|
|
delete actor;
|
2009-10-29 10:58:31 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-10-26 15:20:53 -07:00
|
|
|
TabChild::RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
|
|
|
|
const nsRect& documentRect,
|
2010-10-26 15:20:53 -07:00
|
|
|
const gfxMatrix& transform,
|
2010-10-26 15:20:53 -07:00
|
|
|
const nsString& bgcolor,
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint32_t& renderFlags,
|
2010-10-26 15:20:53 -07:00
|
|
|
const bool& flushLayout,
|
|
|
|
const nsIntSize& renderSize)
|
2010-10-26 15:20:53 -07:00
|
|
|
{
|
|
|
|
DocumentRendererChild *render = static_cast<DocumentRendererChild *>(actor);
|
2009-10-29 10:58:31 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWebBrowser> browser = do_QueryInterface(mWebNav);
|
|
|
|
if (!browser)
|
|
|
|
return true; // silently ignore
|
|
|
|
nsCOMPtr<nsIDOMWindow> window;
|
|
|
|
if (NS_FAILED(browser->GetContentDOMWindow(getter_AddRefs(window))) ||
|
|
|
|
!window)
|
|
|
|
{
|
|
|
|
return true; // silently ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCString data;
|
2010-10-26 15:20:53 -07:00
|
|
|
bool ret = render->RenderDocument(window,
|
2010-10-26 15:20:53 -07:00
|
|
|
documentRect, transform,
|
|
|
|
bgcolor,
|
2010-10-26 15:20:53 -07:00
|
|
|
renderFlags, flushLayout,
|
2010-10-26 15:20:53 -07:00
|
|
|
renderSize, data);
|
2009-10-29 10:58:31 -07:00
|
|
|
if (!ret)
|
|
|
|
return true; // silently ignore
|
|
|
|
|
2010-10-26 15:20:53 -07:00
|
|
|
return PDocumentRendererChild::Send__delete__(actor, renderSize, data);
|
2009-10-29 10:58:31 -07:00
|
|
|
}
|
2009-11-17 06:22:23 -08:00
|
|
|
|
2010-05-17 04:25:22 -07:00
|
|
|
PContentDialogChild*
|
2012-08-22 08:56:38 -07:00
|
|
|
TabChild::AllocPContentDialog(const uint32_t&,
|
2010-05-17 04:25:22 -07:00
|
|
|
const nsCString&,
|
|
|
|
const nsCString&,
|
2010-11-08 18:49:00 -08:00
|
|
|
const InfallibleTArray<int>&,
|
|
|
|
const InfallibleTArray<nsString>&)
|
2010-05-17 04:25:22 -07:00
|
|
|
{
|
|
|
|
return new ContentDialogChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::DeallocPContentDialog(PContentDialogChild* aDialog)
|
|
|
|
{
|
|
|
|
delete aDialog;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-09 22:00:08 -07:00
|
|
|
PContentPermissionRequestChild*
|
2012-11-13 16:06:42 -08:00
|
|
|
TabChild::AllocPContentPermissionRequest(const nsCString& aType, const nsCString& aAccess, const IPC::Principal&)
|
2010-05-13 10:44:51 -07:00
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("unused");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-05-13 10:44:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-09 22:00:08 -07:00
|
|
|
TabChild::DeallocPContentPermissionRequest(PContentPermissionRequestChild* actor)
|
2010-05-13 10:44:51 -07:00
|
|
|
{
|
2012-07-18 12:09:28 -07:00
|
|
|
PCOMContentPermissionRequestChild* child =
|
|
|
|
static_cast<PCOMContentPermissionRequestChild*>(actor);
|
|
|
|
#ifdef DEBUG
|
|
|
|
child->mIPCOpen = false;
|
|
|
|
#endif /* DEBUG */
|
|
|
|
child->IPDLRelease();
|
2010-09-09 22:00:08 -07:00
|
|
|
return true;
|
2010-05-13 10:44:51 -07:00
|
|
|
}
|
|
|
|
|
2009-11-17 06:22:23 -08:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
TabChild::RecvActivateFrameEvent(const nsString& aType, const bool& capture)
|
2009-11-17 06:22:23 -08:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mWebNav);
|
|
|
|
NS_ENSURE_TRUE(window, true);
|
2013-04-19 15:18:32 -07:00
|
|
|
nsCOMPtr<EventTarget> chromeHandler =
|
2009-11-17 06:22:23 -08:00
|
|
|
do_QueryInterface(window->GetChromeEventHandler());
|
|
|
|
NS_ENSURE_TRUE(chromeHandler, true);
|
|
|
|
nsRefPtr<ContentListener> listener = new ContentListener(this);
|
|
|
|
chromeHandler->AddEventListener(aType, listener, capture);
|
|
|
|
return true;
|
|
|
|
}
|
2010-02-20 09:05:20 -08:00
|
|
|
|
2010-10-20 10:12:32 -07:00
|
|
|
POfflineCacheUpdateChild*
|
2012-08-23 12:33:46 -07:00
|
|
|
TabChild::AllocPOfflineCacheUpdate(const URIParams& manifestURI,
|
2012-07-30 23:36:00 -07:00
|
|
|
const URIParams& documentURI,
|
|
|
|
const bool& stickDocument)
|
2010-10-20 10:12:32 -07:00
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("unused");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-10-20 10:12:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::DeallocPOfflineCacheUpdate(POfflineCacheUpdateChild* actor)
|
|
|
|
{
|
|
|
|
OfflineCacheUpdateChild* offlineCacheUpdate = static_cast<OfflineCacheUpdateChild*>(actor);
|
|
|
|
delete offlineCacheUpdate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
TabChild::RecvLoadRemoteScript(const nsString& aURL)
|
2010-02-20 09:05:20 -08:00
|
|
|
{
|
2010-08-24 10:01:28 -07:00
|
|
|
if (!mCx && !InitTabChildGlobal())
|
2011-08-09 12:38:26 -07:00
|
|
|
// This can happen if we're half-destroyed. It's not a fatal
|
|
|
|
// error.
|
|
|
|
return true;
|
2010-08-24 10:01:28 -07:00
|
|
|
|
2010-08-18 03:02:49 -07:00
|
|
|
LoadFrameScriptInternal(aURL);
|
2010-02-20 09:05:20 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
TabChild::RecvAsyncMessage(const nsString& aMessage,
|
2012-08-01 23:02:29 -07:00
|
|
|
const ClonedMessageData& aData)
|
2010-02-20 09:05:20 -08:00
|
|
|
{
|
|
|
|
if (mTabChildGlobal) {
|
2011-06-16 11:21:08 -07:00
|
|
|
nsFrameScriptCx cx(static_cast<nsIWebBrowserChrome*>(this), this);
|
2013-01-24 08:24:19 -08:00
|
|
|
StructuredCloneData cloneData = UnpackClonedMessageDataForChild(aData);
|
2011-06-16 11:21:08 -07:00
|
|
|
nsRefPtr<nsFrameMessageManager> mm =
|
|
|
|
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
2013-04-19 15:18:33 -07:00
|
|
|
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal),
|
2013-05-20 05:40:06 -07:00
|
|
|
aMessage, false, &cloneData, JS::NullPtr(), nullptr);
|
2010-02-20 09:05:20 -08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-12 09:47:22 -07:00
|
|
|
class UnloadScriptEvent : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UnloadScriptEvent(TabChild* aTabChild, TabChildGlobal* aTabChildGlobal)
|
|
|
|
: mTabChild(aTabChild), mTabChildGlobal(aTabChildGlobal)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
2013-03-09 03:34:29 -08:00
|
|
|
NS_NewDOMEvent(getter_AddRefs(event), mTabChildGlobal, nullptr, nullptr);
|
2010-08-12 09:47:22 -07:00
|
|
|
if (event) {
|
2011-10-17 07:59:28 -07:00
|
|
|
event->InitEvent(NS_LITERAL_STRING("unload"), false, false);
|
2012-06-10 16:44:50 -07:00
|
|
|
event->SetTrusted(true);
|
2010-08-12 09:47:22 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool dummy;
|
2010-08-12 09:47:22 -07:00
|
|
|
mTabChildGlobal->DispatchEvent(event, &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<TabChild> mTabChild;
|
|
|
|
TabChildGlobal* mTabChildGlobal;
|
|
|
|
};
|
|
|
|
|
2010-08-05 15:11:23 -07:00
|
|
|
bool
|
|
|
|
TabChild::RecvDestroy()
|
|
|
|
{
|
2011-08-09 12:38:26 -07:00
|
|
|
if (mTabChildGlobal) {
|
|
|
|
// Let the frame scripts know the child is being closed
|
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new UnloadScriptEvent(this, mTabChildGlobal)
|
|
|
|
);
|
|
|
|
}
|
2010-08-05 15:11:23 -07:00
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
|
|
|
|
|
|
|
observerService->RemoveObserver(this, CANCEL_DEFAULT_PAN_ZOOM);
|
|
|
|
observerService->RemoveObserver(this, BROWSER_ZOOM_TO_RECT);
|
|
|
|
observerService->RemoveObserver(this, BEFORE_FIRST_PAINT);
|
2013-01-05 06:53:16 -08:00
|
|
|
observerService->RemoveObserver(this, DETECT_SCROLLABLE_SUBFRAME);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2012-11-09 19:29:07 -08:00
|
|
|
const InfallibleTArray<PIndexedDBChild*>& idbActors =
|
|
|
|
ManagedPIndexedDBChild();
|
|
|
|
for (uint32_t i = 0; i < idbActors.Length(); ++i) {
|
|
|
|
static_cast<IndexedDBChild*>(idbActors[i])->Disconnect();
|
|
|
|
}
|
|
|
|
|
2010-08-12 09:47:22 -07:00
|
|
|
// XXX what other code in ~TabChild() should we be running here?
|
2010-08-20 16:24:40 -07:00
|
|
|
DestroyWindow();
|
2010-08-05 15:11:23 -07:00
|
|
|
|
2010-08-12 09:47:22 -07:00
|
|
|
return Send__delete__(this);
|
2010-08-05 15:11:23 -07:00
|
|
|
}
|
2010-02-20 09:05:20 -08:00
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
PRenderFrameChild*
|
2012-07-19 23:48:27 -07:00
|
|
|
TabChild::AllocPRenderFrame(ScrollingBehavior* aScrolling,
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
2012-07-17 16:59:45 -07:00
|
|
|
uint64_t* aLayersId)
|
2010-08-20 16:24:41 -07:00
|
|
|
{
|
|
|
|
return new RenderFrameChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::DeallocPRenderFrame(PRenderFrameChild* aFrame)
|
|
|
|
{
|
|
|
|
delete aFrame;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
bool
|
2012-08-29 08:26:18 -07:00
|
|
|
TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading)
|
2010-02-20 09:05:20 -08:00
|
|
|
{
|
2012-08-29 08:26:18 -07:00
|
|
|
if (!mCx && !mTabChildGlobal) {
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mWebNav);
|
|
|
|
NS_ENSURE_TRUE(window, false);
|
2013-04-19 15:18:32 -07:00
|
|
|
nsCOMPtr<EventTarget> chromeHandler =
|
2012-08-29 08:26:18 -07:00
|
|
|
do_QueryInterface(window->GetChromeEventHandler());
|
|
|
|
NS_ENSURE_TRUE(chromeHandler, false);
|
2010-02-20 09:05:20 -08:00
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
nsRefPtr<TabChildGlobal> scope = new TabChildGlobal(this);
|
|
|
|
mTabChildGlobal = scope;
|
2010-02-20 09:05:20 -08:00
|
|
|
|
2013-04-19 15:18:33 -07:00
|
|
|
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, scope);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
2013-02-20 02:39:59 -08:00
|
|
|
NS_NAMED_LITERAL_CSTRING(globalId, "outOfProcessTabChildGlobal");
|
|
|
|
NS_ENSURE_TRUE(InitTabChildGlobalInternal(scopeSupports, globalId), false);
|
2010-02-20 09:05:20 -08:00
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
scope->Init();
|
2012-04-26 13:56:46 -07:00
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
|
|
|
|
NS_ENSURE_TRUE(root, false);
|
|
|
|
root->SetParentTarget(scope);
|
2012-09-28 19:18:18 -07:00
|
|
|
|
|
|
|
chromeHandler->AddEventListener(NS_LITERAL_STRING("DOMMetaAdded"), this, false);
|
2012-08-29 08:26:18 -07:00
|
|
|
}
|
2012-06-21 18:17:52 -07:00
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
if (aScriptLoading != DONT_LOAD_SCRIPTS && !mTriedBrowserInit) {
|
|
|
|
mTriedBrowserInit = true;
|
|
|
|
// Initialize the child side of the browser element machinery,
|
|
|
|
// if appropriate.
|
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 10:32:37 -08:00
|
|
|
if (IsBrowserOrApp()) {
|
2012-08-29 08:26:18 -07:00
|
|
|
RecvLoadRemoteScript(BROWSER_ELEMENT_CHILD_SCRIPT);
|
|
|
|
}
|
2012-06-21 18:17:52 -07:00
|
|
|
}
|
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
bool
|
2012-08-29 08:26:18 -07:00
|
|
|
TabChild::InitRenderingState()
|
2010-08-20 16:24:41 -07:00
|
|
|
{
|
2012-08-29 08:26:18 -07:00
|
|
|
static_cast<PuppetWidget*>(mWidget.get())->InitIMEState();
|
2010-08-20 16:24:41 -07:00
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
uint64_t id;
|
2010-08-20 16:24:41 -07:00
|
|
|
RenderFrameChild* remoteFrame =
|
2012-07-17 16:59:45 -07:00
|
|
|
static_cast<RenderFrameChild*>(SendPRenderFrameConstructor(
|
2013-04-30 17:42:05 -07:00
|
|
|
&mScrolling, &mTextureFactoryIdentifier, &id));
|
2010-08-20 16:24:41 -07:00
|
|
|
if (!remoteFrame) {
|
|
|
|
NS_WARNING("failed to construct RenderFrame");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-24 11:42:40 -07:00
|
|
|
PLayerTransactionChild* shadowManager = nullptr;
|
2012-07-17 16:59:45 -07:00
|
|
|
if (id != 0) {
|
|
|
|
// Pushing layers transactions directly to a separate
|
|
|
|
// compositor context.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
PCompositorChild* compositorChild = CompositorChild::Get();
|
2013-03-26 15:25:12 -07:00
|
|
|
if (!compositorChild) {
|
|
|
|
NS_WARNING("failed to get CompositorChild instance");
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-17 16:59:45 -07:00
|
|
|
shadowManager =
|
2013-04-30 17:42:05 -07:00
|
|
|
compositorChild->SendPLayerTransactionConstructor(mTextureFactoryIdentifier.mParentBackend,
|
|
|
|
id, &mTextureFactoryIdentifier);
|
2012-07-17 16:59:45 -07:00
|
|
|
} else {
|
|
|
|
// Pushing transactions to the parent content.
|
2013-04-24 11:42:40 -07:00
|
|
|
shadowManager = remoteFrame->SendPLayerTransactionConstructor();
|
2012-07-17 16:59:45 -07:00
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
if (!shadowManager) {
|
|
|
|
NS_WARNING("failed to construct LayersChild");
|
|
|
|
// This results in |remoteFrame| being deleted.
|
|
|
|
PRenderFrameChild::Send__delete__(remoteFrame);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
ShadowLayerForwarder* lf =
|
2013-04-30 17:42:05 -07:00
|
|
|
mWidget->GetLayerManager(shadowManager, mTextureFactoryIdentifier.mParentBackend)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
->AsShadowForwarder();
|
2011-08-09 12:38:26 -07:00
|
|
|
NS_ABORT_IF_FALSE(lf && lf->HasShadowManager(),
|
|
|
|
"PuppetWidget should have shadow manager");
|
2013-04-30 17:42:05 -07:00
|
|
|
lf->IdentifyTextureHost(mTextureFactoryIdentifier);
|
2013-06-23 22:28:22 -07:00
|
|
|
ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
|
2010-08-20 16:24:41 -07:00
|
|
|
|
|
|
|
mRemoteFrame = remoteFrame;
|
2012-08-29 08:26:18 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
|
|
|
|
|
|
|
if (observerService) {
|
|
|
|
observerService->AddObserver(this,
|
2012-09-28 19:18:18 -07:00
|
|
|
CANCEL_DEFAULT_PAN_ZOOM,
|
|
|
|
false);
|
|
|
|
observerService->AddObserver(this,
|
|
|
|
BROWSER_ZOOM_TO_RECT,
|
2012-08-29 08:26:18 -07:00
|
|
|
false);
|
|
|
|
observerService->AddObserver(this,
|
2012-09-28 19:18:18 -07:00
|
|
|
BEFORE_FIRST_PAINT,
|
2012-08-29 08:26:18 -07:00
|
|
|
false);
|
2013-01-05 06:53:16 -08:00
|
|
|
observerService->AddObserver(this,
|
|
|
|
DETECT_SCROLLABLE_SUBFRAME,
|
|
|
|
false);
|
2012-08-29 08:26:18 -07:00
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-20 15:17:09 -07:00
|
|
|
void
|
|
|
|
TabChild::SetBackgroundColor(const nscolor& aColor)
|
|
|
|
{
|
|
|
|
if (mLastBackgroundColor != aColor) {
|
|
|
|
mLastBackgroundColor = aColor;
|
|
|
|
SendSetBackgroundColor(mLastBackgroundColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 08:26:18 -07:00
|
|
|
void
|
|
|
|
TabChild::GetDPI(float* aDPI)
|
|
|
|
{
|
|
|
|
*aDPI = -1.0;
|
|
|
|
if (!mRemoteFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SendGetDPI(aDPI);
|
|
|
|
}
|
|
|
|
|
2013-05-01 16:06:19 -07:00
|
|
|
void
|
|
|
|
TabChild::GetDefaultScale(double* aScale)
|
|
|
|
{
|
|
|
|
*aScale = -1.0;
|
|
|
|
if (!mRemoteFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SendGetDefaultScale(aScale);
|
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
void
|
|
|
|
TabChild::NotifyPainted()
|
|
|
|
{
|
2013-04-30 17:42:05 -07:00
|
|
|
// Normally we only need to notify the content process once, but with BasicCompositor
|
|
|
|
// we need to notify content every change so that it can compute an invalidation
|
|
|
|
// region and send that to the widget.
|
|
|
|
if (UseDirectCompositor() &&
|
|
|
|
(!mNotified || mTextureFactoryIdentifier.mParentBackend == LAYERS_BASIC)) {
|
2012-07-17 16:59:45 -07:00
|
|
|
mRemoteFrame->SendNotifyCompositorTransaction();
|
2012-08-06 20:00:41 -07:00
|
|
|
mNotified = true;
|
2012-07-17 16:59:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 23:48:27 -07:00
|
|
|
bool
|
|
|
|
TabChild::IsAsyncPanZoomEnabled()
|
|
|
|
{
|
|
|
|
return mScrolling == ASYNC_PAN_ZOOM;
|
|
|
|
}
|
|
|
|
|
2013-05-23 08:52:06 -07:00
|
|
|
bool
|
|
|
|
TabChild::DispatchMouseEvent(const nsString& aType,
|
|
|
|
const float& aX,
|
|
|
|
const float& aY,
|
|
|
|
const int32_t& aButton,
|
|
|
|
const int32_t& aClickCount,
|
|
|
|
const int32_t& aModifiers,
|
|
|
|
const bool& aIgnoreRootScrollFrame)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
|
|
|
|
NS_ENSURE_TRUE(utils, true);
|
|
|
|
|
|
|
|
bool defaultPrevented = false;
|
|
|
|
utils->SendMouseEvent(aType, aX, aY, aButton, aClickCount, aModifiers,
|
|
|
|
aIgnoreRootScrollFrame, 0, 0, &defaultPrevented);
|
|
|
|
return defaultPrevented;
|
|
|
|
}
|
|
|
|
|
2012-11-07 19:51:55 -08:00
|
|
|
void
|
|
|
|
TabChild::MakeVisible()
|
|
|
|
{
|
|
|
|
if (mWidget) {
|
|
|
|
mWidget->Show(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::MakeHidden()
|
|
|
|
{
|
|
|
|
if (mWidget) {
|
|
|
|
mWidget->Show(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-28 02:27:25 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetMessageManager(nsIContentFrameMessageManager** aResult)
|
|
|
|
{
|
|
|
|
if (mTabChildGlobal) {
|
|
|
|
NS_ADDREF(*aResult = mTabChildGlobal);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr;
|
2012-05-28 02:27:25 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
PIndexedDBChild*
|
|
|
|
TabChild::AllocPIndexedDB(const nsCString& aASCIIOrigin, bool* /* aAllowed */)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("Should never get here!");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::DeallocPIndexedDB(PIndexedDBChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-27 22:43:12 -07:00
|
|
|
bool
|
|
|
|
TabChild::DoSendSyncMessage(const nsAString& aMessage,
|
|
|
|
const StructuredCloneData& aData,
|
|
|
|
InfallibleTArray<nsString>* aJSONRetVal)
|
2010-02-20 09:05:20 -08:00
|
|
|
{
|
2012-09-27 22:43:12 -07:00
|
|
|
ContentChild* cc = static_cast<ContentChild*>(Manager());
|
2012-08-01 23:02:29 -07:00
|
|
|
ClonedMessageData data;
|
2013-01-23 18:39:27 -08:00
|
|
|
if (!BuildClonedMessageDataForChild(cc, aData, data)) {
|
|
|
|
return false;
|
2012-08-01 23:02:29 -07:00
|
|
|
}
|
2012-09-27 22:43:12 -07:00
|
|
|
return SendSyncMessage(nsString(aMessage), data, aJSONRetVal);
|
2010-02-20 09:05:20 -08:00
|
|
|
}
|
|
|
|
|
2012-09-27 22:43:12 -07:00
|
|
|
bool
|
|
|
|
TabChild::DoSendAsyncMessage(const nsAString& aMessage,
|
|
|
|
const StructuredCloneData& aData)
|
2012-08-01 23:02:29 -07:00
|
|
|
{
|
2012-09-27 22:43:12 -07:00
|
|
|
ContentChild* cc = static_cast<ContentChild*>(Manager());
|
2012-08-01 23:02:29 -07:00
|
|
|
ClonedMessageData data;
|
2013-01-23 18:39:27 -08:00
|
|
|
if (!BuildClonedMessageDataForChild(cc, aData, data)) {
|
|
|
|
return false;
|
2012-08-01 23:02:29 -07:00
|
|
|
}
|
2012-09-27 22:43:12 -07:00
|
|
|
return SendAsyncMessage(nsString(aMessage), data);
|
2010-02-20 09:05:20 -08:00
|
|
|
}
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
TabChildGlobal::TabChildGlobal(TabChild* aTabChild)
|
|
|
|
: mTabChild(aTabChild)
|
|
|
|
{
|
2012-04-26 13:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChildGlobal::Init()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mMessageManager, "Re-initializing?!?");
|
2012-09-27 22:43:12 -07:00
|
|
|
mMessageManager = new nsFrameMessageManager(mTabChild,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr,
|
2012-09-27 22:43:12 -07:00
|
|
|
mTabChild->GetJSContext(),
|
|
|
|
MM_CHILD);
|
2010-02-20 09:05:20 -08:00
|
|
|
}
|
|
|
|
|
2013-05-21 16:23:53 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(TabChildGlobal, nsDOMEventTargetHelper,
|
|
|
|
mMessageManager)
|
2010-02-20 09:05:20 -08:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChildGlobal)
|
2012-08-27 07:13:02 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIMessageListenerManager)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
|
2010-08-31 11:58:35 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISyncMessageSender)
|
2010-02-20 09:05:20 -08:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
2012-02-07 18:53:33 -08:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
2010-02-20 09:05:20 -08:00
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(TabChildGlobal, nsDOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(TabChildGlobal, nsDOMEventTargetHelper)
|
|
|
|
|
2012-08-09 01:33:38 -07:00
|
|
|
/* [notxpcom] boolean markForCC (); */
|
|
|
|
// This method isn't automatically forwarded safely because it's notxpcom, so
|
|
|
|
// the IDL binding doesn't know what value to return.
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
|
|
TabChildGlobal::MarkForCC()
|
|
|
|
{
|
|
|
|
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
|
|
|
}
|
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChildGlobal::GetContent(nsIDOMWindow** aContent)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aContent = nullptr;
|
2010-07-21 16:23:03 -07:00
|
|
|
if (!mTabChild)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2010-02-20 09:05:20 -08:00
|
|
|
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mTabChild->WebNavigation());
|
|
|
|
window.swap(*aContent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-24 05:58:21 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChildGlobal::PrivateNoteIntentionalCrash()
|
|
|
|
{
|
|
|
|
mozilla::NoteIntentionalCrash("tab");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-03 12:30:25 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aDocShell = nullptr;
|
2010-05-12 02:52:15 -07:00
|
|
|
if (!mTabChild)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2010-03-03 12:30:25 -08:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mTabChild->WebNavigation());
|
|
|
|
docShell.swap(*aDocShell);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-25 02:52:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChildGlobal::Btoa(const nsAString& aBinaryData,
|
|
|
|
nsAString& aAsciiBase64String)
|
|
|
|
{
|
|
|
|
return nsContentUtils::Btoa(aBinaryData, aAsciiBase64String);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChildGlobal::Atob(const nsAString& aAsciiString,
|
|
|
|
nsAString& aBinaryData)
|
|
|
|
{
|
|
|
|
return nsContentUtils::Atob(aAsciiString, aBinaryData);
|
|
|
|
}
|
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
JSContext*
|
|
|
|
TabChildGlobal::GetJSContextForEventHandlers()
|
|
|
|
{
|
2010-05-12 02:52:15 -07:00
|
|
|
if (!mTabChild)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-02-20 09:05:20 -08:00
|
|
|
return mTabChild->GetJSContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPrincipal*
|
|
|
|
TabChildGlobal::GetPrincipal()
|
|
|
|
{
|
2010-05-12 02:52:15 -07:00
|
|
|
if (!mTabChild)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-02-20 09:05:20 -08:00
|
|
|
return mTabChild->GetPrincipal();
|
2012-09-12 20:50:40 -07:00
|
|
|
}
|