2014-04-22 00:40:09 +04:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- */
|
2012-06-13 02:01:25 +04:00
|
|
|
/* vim: set sw=2 sts=2 ts=8 et tw=80 : */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2012-08-02 10:02:29 +04:00
|
|
|
#include "TabChild.h"
|
|
|
|
|
2013-09-02 02:20:45 +04:00
|
|
|
#include "Layers.h"
|
2012-08-02 10:02:29 +04:00
|
|
|
#include "ContentChild.h"
|
2014-08-08 08:34:00 +04:00
|
|
|
#include "TabParent.h"
|
2013-09-04 16:14:52 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-08-29 19:26:18 +04:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2014-03-17 10:56:53 +04:00
|
|
|
#include "mozilla/EventListenerManager.h"
|
2015-02-11 14:53:00 +03:00
|
|
|
#include "mozilla/dom/workers/ServiceWorkerManager.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
|
2014-11-12 23:59:19 +03:00
|
|
|
#include "mozilla/plugins/PluginWidgetChild.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "mozilla/ipc/DocumentRendererChild.h"
|
2013-02-16 02:27:21 +04:00
|
|
|
#include "mozilla/ipc/FileDescriptorUtils.h"
|
2014-04-17 15:54:25 +04:00
|
|
|
#include "mozilla/layers/APZCCallbackHelper.h"
|
2014-10-16 17:23:52 +04:00
|
|
|
#include "mozilla/layers/APZCTreeManager.h"
|
2015-02-09 22:05:18 +03:00
|
|
|
#include "mozilla/layers/APZEventState.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "mozilla/layers/CompositorChild.h"
|
2013-06-24 09:28:22 +04:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2013-08-12 03:15:10 +04:00
|
|
|
#include "mozilla/layers/ShadowLayers.h"
|
2010-08-21 03:24:41 +04:00
|
|
|
#include "mozilla/layout/RenderFrameChild.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2013-10-21 16:58:12 +04:00
|
|
|
#include "mozilla/Services.h"
|
2012-08-29 19:26:18 +04:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2013-09-25 15:21:19 +04:00
|
|
|
#include "mozilla/TextEvents.h"
|
2013-09-25 15:21:16 +04:00
|
|
|
#include "mozilla/TouchEvents.h"
|
2012-08-09 00:37:57 +04:00
|
|
|
#include "mozilla/unused.h"
|
2012-09-11 08:30:33 +04:00
|
|
|
#include "mozIApplication.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsContentUtils.h"
|
2014-08-22 12:32:00 +04:00
|
|
|
#include "nsDocShell.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsEmbedCID.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2013-01-08 00:45:10 +04:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2013-01-07 18:42:32 +04:00
|
|
|
#include "nsExceptionHandler.h"
|
2013-01-08 00:45:10 +04:00
|
|
|
#endif
|
2014-02-18 04:30:06 +04:00
|
|
|
#include "nsFilePickerProxy.h"
|
2012-11-15 02:10:08 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2009-07-01 00:39:22 +04:00
|
|
|
#include "nsIBaseWindow.h"
|
2014-06-20 22:07:47 +04:00
|
|
|
#include "nsIBrowserDOMWindow.h"
|
2013-02-16 02:27:21 +04:00
|
|
|
#include "nsICachedFileDescriptorListener.h"
|
2013-01-13 01:53:01 +04:00
|
|
|
#include "nsIDocumentInlines.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIDocShellTreeOwner.h"
|
2014-06-20 22:07:47 +04:00
|
|
|
#include "nsIDOMChromeWindow.h"
|
2014-11-13 03:31:00 +03:00
|
|
|
#include "nsIDOMDocument.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsIDOMEvent.h"
|
2009-10-29 20:58:31 +03:00
|
|
|
#include "nsIDOMWindow.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsIDOMWindowUtils.h"
|
2014-11-27 16:28:26 +03:00
|
|
|
#include "nsFocusManager.h"
|
2010-08-13 12:06:40 +04:00
|
|
|
#include "nsIDocShell.h"
|
2014-11-22 06:10:18 +03:00
|
|
|
#include "nsIFrame.h"
|
2010-03-26 21:39:39 +03:00
|
|
|
#include "nsIURI.h"
|
2012-09-29 06:18:18 +04:00
|
|
|
#include "nsIURIFixup.h"
|
|
|
|
#include "nsCDefaultURIFixup.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsIWebBrowser.h"
|
2009-11-05 21:14:22 +03:00
|
|
|
#include "nsIWebBrowserFocus.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsIWebBrowserSetup.h"
|
|
|
|
#include "nsIWebProgress.h"
|
2013-12-13 02:13:20 +04:00
|
|
|
#include "nsIXULRuntime.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsPIWindowRoot.h"
|
2013-07-10 03:26:07 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsPrintfCString.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsWeakReference.h"
|
2014-06-20 22:07:47 +04:00
|
|
|
#include "nsWindowWatcher.h"
|
2013-11-06 21:21:15 +04:00
|
|
|
#include "PermissionMessageUtils.h"
|
2012-08-29 19:26:18 +04:00
|
|
|
#include "PuppetWidget.h"
|
2012-08-02 10:02:29 +04:00
|
|
|
#include "StructuredCloneUtils.h"
|
2012-12-18 01:24:41 +04:00
|
|
|
#include "nsViewportInfo.h"
|
2013-10-08 06:21:07 +04:00
|
|
|
#include "nsILoadContext.h"
|
2013-10-19 00:57:55 +04:00
|
|
|
#include "ipc/nsGUIEventIPC.h"
|
2013-12-26 22:06:53 +04:00
|
|
|
#include "mozilla/gfx/Matrix.h"
|
2014-03-11 01:56:59 +04:00
|
|
|
#include "UnitTransforms.h"
|
2014-03-07 07:24:32 +04:00
|
|
|
#include "ClientLayerManager.h"
|
2014-08-06 20:41:05 +04:00
|
|
|
#include "LayersLogging.h"
|
2014-08-23 03:17:18 +04:00
|
|
|
#include "nsIOService.h"
|
2014-10-22 19:40:49 +04:00
|
|
|
#include "nsDOMClassInfoID.h"
|
2014-02-24 00:19:43 +04:00
|
|
|
#include "nsColorPickerProxy.h"
|
2014-11-03 10:05:38 +03:00
|
|
|
#include "nsPresShell.h"
|
2014-10-31 20:54:02 +03:00
|
|
|
#include "nsIAppsService.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "nsIPermissionManager.h"
|
2014-11-24 22:05:35 +03:00
|
|
|
#include "nsIScriptError.h"
|
2014-02-24 00:19:43 +04:00
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
#define BROWSER_ELEMENT_CHILD_SCRIPT \
|
|
|
|
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
|
|
|
|
|
2014-08-06 20:41:05 +04:00
|
|
|
#define TABC_LOG(...)
|
|
|
|
// #define TABC_LOG(...) printf_stderr("TABC: " __VA_ARGS__)
|
|
|
|
|
2012-08-02 10:02:29 +04:00
|
|
|
using namespace mozilla;
|
2009-08-12 20:18:08 +04:00
|
|
|
using namespace mozilla::dom;
|
2012-09-28 09:43:12 +04:00
|
|
|
using namespace mozilla::dom::ipc;
|
2015-02-11 14:53:00 +03:00
|
|
|
using namespace mozilla::dom::workers;
|
2010-10-27 02:20:53 +04:00
|
|
|
using namespace mozilla::ipc;
|
2010-08-21 03:24:41 +04:00
|
|
|
using namespace mozilla::layers;
|
2010-08-21 03:24:41 +04:00
|
|
|
using namespace mozilla::layout;
|
2010-10-20 21:12:32 +04:00
|
|
|
using namespace mozilla::docshell;
|
2012-08-12 05:42:34 +04:00
|
|
|
using namespace mozilla::widget;
|
2013-07-11 02:05:39 +04:00
|
|
|
using namespace mozilla::jsipc;
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ContentListener, nsIDOMEventListener)
|
2009-11-17 17:22:23 +03:00
|
|
|
|
2013-06-10 17:05:43 +04:00
|
|
|
static const CSSSize kDefaultViewportSize(980, 480);
|
2012-09-29 06:18:18 +04:00
|
|
|
|
|
|
|
static const char BROWSER_ZOOM_TO_RECT[] = "browser-zoom-to-rect";
|
|
|
|
static const char BEFORE_FIRST_PAINT[] = "before-first-paint";
|
|
|
|
|
2014-03-07 07:24:32 +04:00
|
|
|
typedef nsDataHashtable<nsUint64HashKey, TabChild*> TabChildMap;
|
|
|
|
static TabChildMap* sTabChildren;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class TabChild::DelayedFireContextMenuEvent final : public nsITimerCallback
|
2014-08-24 11:16:32 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit DelayedFireContextMenuEvent(TabChild* tabChild)
|
2014-08-24 11:16:32 +04:00
|
|
|
: mTabChild(tabChild)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHODIMP Notify(nsITimer*) override
|
2014-08-24 11:16:32 +04:00
|
|
|
{
|
|
|
|
mTabChild->FireContextMenuEvent();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
~DelayedFireContextMenuEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Raw pointer is safe here because this object is held by a Timer, which is
|
|
|
|
// held by TabChild, we won't stay alive if TabChild dies.
|
|
|
|
TabChild *mTabChild;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(TabChild::DelayedFireContextMenuEvent,
|
|
|
|
nsITimerCallback)
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
TabChildBase::TabChildBase()
|
2014-05-29 21:20:02 +04:00
|
|
|
: mContentDocumentIsDisplayed(false)
|
2014-03-25 06:28:46 +04:00
|
|
|
, mTabChildGlobal(nullptr)
|
|
|
|
, mInnerSize(0, 0)
|
|
|
|
{
|
2014-06-13 21:56:38 +04:00
|
|
|
mozilla::HoldJSObjects(this);
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
|
2014-06-13 21:56:38 +04:00
|
|
|
TabChildBase::~TabChildBase()
|
|
|
|
{
|
|
|
|
mAnonymousGlobalScopes.Clear();
|
|
|
|
mozilla::DropJSObjects(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(TabChildBase)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(TabChildBase)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTabChildGlobal)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAnonymousGlobalScopes)
|
2014-09-03 01:43:08 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWebBrowserChrome)
|
2014-06-13 21:56:38 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TabChildBase)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTabChildGlobal)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
2014-09-03 01:43:08 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWebBrowserChrome)
|
2014-06-13 21:56:38 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(TabChildBase)
|
|
|
|
for (uint32_t i = 0; i < tmp->mAnonymousGlobalScopes.Length(); ++i) {
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mAnonymousGlobalScopes[i])
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2014-04-23 01:26:45 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildBase)
|
2014-05-07 04:11:20 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2014-04-23 01:26:45 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-06-13 21:56:38 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(TabChildBase)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(TabChildBase)
|
2014-04-23 01:26:45 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
void
|
|
|
|
TabChildBase::InitializeRootMetrics()
|
|
|
|
{
|
|
|
|
// 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.
|
2014-08-23 07:18:56 +04:00
|
|
|
mLastRootMetrics.SetViewport(CSSRect(CSSPoint(), kDefaultViewportSize));
|
2014-07-04 16:12:41 +04:00
|
|
|
mLastRootMetrics.mCompositionBounds = ParentLayerRect(
|
|
|
|
ParentLayerPoint(),
|
2014-11-10 22:35:11 +03:00
|
|
|
ParentLayerSize(ViewAs<ParentLayerPixel>(mInnerSize, PixelCastJustification::ScreenIsParentLayerForRoot)));
|
2015-03-06 21:54:10 +03:00
|
|
|
mLastRootMetrics.SetZoom(CSSToParentLayerScale2D(mLastRootMetrics.CalculateIntrinsicScale()));
|
2014-12-18 01:14:05 +03:00
|
|
|
mLastRootMetrics.SetDevPixelsPerCSSPixel(WebWidget()->GetDefaultScale());
|
2014-11-10 22:35:11 +03:00
|
|
|
// We use ParentLayerToLayerScale(1) below in order to turn the
|
2014-03-25 06:28:46 +04:00
|
|
|
// async zoom amount into the gecko zoom amount.
|
2014-12-19 03:33:18 +03:00
|
|
|
mLastRootMetrics.SetCumulativeResolution(mLastRootMetrics.GetZoom() / mLastRootMetrics.GetDevPixelsPerCSSPixel() * ParentLayerToLayerScale(1));
|
2014-03-25 06:28:46 +04:00
|
|
|
// This is the root layer, so the cumulative resolution is the same
|
|
|
|
// as the resolution.
|
2015-03-06 21:54:10 +03:00
|
|
|
mLastRootMetrics.SetPresShellResolution(mLastRootMetrics.GetCumulativeResolution().ToScaleFactor().scale);
|
2014-03-25 06:28:46 +04:00
|
|
|
mLastRootMetrics.SetScrollOffset(CSSPoint(0, 0));
|
2014-08-06 20:41:05 +04:00
|
|
|
|
|
|
|
TABC_LOG("After InitializeRootMetrics, mLastRootMetrics is %s\n",
|
|
|
|
Stringify(mLastRootMetrics).c_str());
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChildBase::SetCSSViewport(const CSSSize& aSize)
|
|
|
|
{
|
2014-05-29 21:20:02 +04:00
|
|
|
mOldViewportSize = aSize;
|
2014-08-06 20:41:05 +04:00
|
|
|
TABC_LOG("Setting CSS viewport to %s\n", Stringify(aSize).c_str());
|
2014-03-25 06:28:46 +04:00
|
|
|
|
|
|
|
if (mContentDocumentIsDisplayed) {
|
2015-04-14 23:44:59 +03:00
|
|
|
if (nsCOMPtr<nsIPresShell> shell = GetPresShell()) {
|
|
|
|
nsLayoutUtils::SetCSSViewport(shell, aSize);
|
|
|
|
}
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CSSSize
|
|
|
|
TabChildBase::GetPageSize(nsCOMPtr<nsIDocument> aDocument, const CSSSize& aViewport)
|
|
|
|
{
|
|
|
|
nsCOMPtr<Element> htmlDOMElement = aDocument->GetHtmlElement();
|
|
|
|
HTMLBodyElement* bodyDOMElement = aDocument->GetBodyElement();
|
|
|
|
|
|
|
|
if (!htmlDOMElement && !bodyDOMElement) {
|
|
|
|
// For non-HTML content (e.g. SVG), just assume page size == viewport size.
|
|
|
|
return aViewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t htmlWidth = 0, htmlHeight = 0;
|
|
|
|
if (htmlDOMElement) {
|
|
|
|
htmlWidth = htmlDOMElement->ScrollWidth();
|
|
|
|
htmlHeight = htmlDOMElement->ScrollHeight();
|
|
|
|
}
|
|
|
|
int32_t bodyWidth = 0, bodyHeight = 0;
|
|
|
|
if (bodyDOMElement) {
|
|
|
|
bodyWidth = bodyDOMElement->ScrollWidth();
|
|
|
|
bodyHeight = bodyDOMElement->ScrollHeight();
|
|
|
|
}
|
|
|
|
return CSSSize(std::max(htmlWidth, bodyWidth),
|
|
|
|
std::max(htmlHeight, bodyHeight));
|
|
|
|
}
|
|
|
|
|
2014-11-10 22:35:11 +03:00
|
|
|
// For the root frame, Screen and ParentLayer pixels are interchangeable.
|
|
|
|
// nsViewportInfo stores zoom values as CSSToScreenScale (because it's a
|
|
|
|
// data structure specific to the root frame), while FrameMetrics and
|
|
|
|
// ZoomConstraints store zoom values as CSSToParentLayerScale (because they
|
|
|
|
// are not specific to the root frame). We define convenience functions for
|
|
|
|
// converting between the two. As the name suggests, they should only be used
|
|
|
|
// when dealing with the root frame!
|
|
|
|
CSSToScreenScale ConvertScaleForRoot(CSSToParentLayerScale aScale) {
|
|
|
|
return ViewTargetAs<ScreenPixel>(aScale, PixelCastJustification::ScreenIsParentLayerForRoot);
|
|
|
|
}
|
|
|
|
CSSToParentLayerScale ConvertScaleForRoot(CSSToScreenScale aScale) {
|
|
|
|
return ViewTargetAs<ParentLayerPixel>(aScale, PixelCastJustification::ScreenIsParentLayerForRoot);
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
bool
|
2014-08-06 20:41:05 +04:00
|
|
|
TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize)
|
2014-03-25 06:28:46 +04:00
|
|
|
{
|
2015-02-26 16:47:01 +03:00
|
|
|
if (!gfxPrefs::AsyncPanZoomEnabled()) {
|
2014-03-25 06:28:46 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-06 20:41:05 +04:00
|
|
|
TABC_LOG("HandlePossibleViewportChange aOldScreenSize=%s mInnerSize=%s\n",
|
|
|
|
Stringify(aOldScreenSize).c_str(), Stringify(mInnerSize).c_str());
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDocument> document(GetDocument());
|
2015-04-20 18:16:55 +03:00
|
|
|
if (!document) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-03-25 06:28:46 +04:00
|
|
|
|
|
|
|
nsViewportInfo viewportInfo = nsContentUtils::GetViewportInfo(document, mInnerSize);
|
2014-10-28 15:06:00 +03:00
|
|
|
uint32_t presShellId = 0;
|
|
|
|
mozilla::layers::FrameMetrics::ViewID viewId = FrameMetrics::NULL_SCROLL_ID;
|
2014-05-05 23:06:28 +04:00
|
|
|
bool scrollIdentifiersValid = APZCCallbackHelper::GetOrCreateScrollIdentifiers(
|
2014-03-25 06:28:46 +04:00
|
|
|
document->GetDocumentElement(), &presShellId, &viewId);
|
|
|
|
if (scrollIdentifiersValid) {
|
|
|
|
ZoomConstraints constraints(
|
|
|
|
viewportInfo.IsZoomAllowed(),
|
|
|
|
viewportInfo.IsDoubleTapZoomAllowed(),
|
2014-11-10 22:35:11 +03:00
|
|
|
ConvertScaleForRoot(viewportInfo.GetMinZoom()),
|
|
|
|
ConvertScaleForRoot(viewportInfo.GetMaxZoom()));
|
2014-03-25 06:28:46 +04:00
|
|
|
DoUpdateZoomConstraints(presShellId,
|
|
|
|
viewId,
|
|
|
|
/* isRoot = */ true,
|
|
|
|
constraints);
|
|
|
|
}
|
|
|
|
|
|
|
|
float screenW = mInnerSize.width;
|
|
|
|
float screenH = mInnerSize.height;
|
|
|
|
CSSSize viewport(viewportInfo.GetSize());
|
|
|
|
|
|
|
|
// We're not being displayed in any way; don't bother doing anything because
|
|
|
|
// that will just confuse future adjustments.
|
|
|
|
if (!screenW || !screenH) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-06 20:41:05 +04:00
|
|
|
TABC_LOG("HandlePossibleViewportChange mOldViewportSize=%s viewport=%s\n",
|
|
|
|
Stringify(mOldViewportSize).c_str(), Stringify(viewport).c_str());
|
2014-05-29 21:20:02 +04:00
|
|
|
CSSSize oldBrowserSize = mOldViewportSize;
|
2014-08-23 07:18:56 +04:00
|
|
|
mLastRootMetrics.SetViewport(CSSRect(
|
|
|
|
mLastRootMetrics.GetViewport().TopLeft(), viewport));
|
2014-05-29 21:20:02 +04:00
|
|
|
if (oldBrowserSize == CSSSize()) {
|
|
|
|
oldBrowserSize = kDefaultViewportSize;
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
SetCSSViewport(viewport);
|
|
|
|
|
|
|
|
// 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 false;
|
|
|
|
}
|
|
|
|
|
2014-08-06 20:41:05 +04:00
|
|
|
ScreenIntSize oldScreenSize = aOldScreenSize;
|
2014-05-29 21:20:02 +04:00
|
|
|
if (oldScreenSize == ScreenIntSize()) {
|
|
|
|
oldScreenSize = mInnerSize;
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
FrameMetrics metrics(mLastRootMetrics);
|
2014-08-23 07:18:56 +04:00
|
|
|
metrics.SetViewport(CSSRect(CSSPoint(), viewport));
|
2014-07-04 16:12:41 +04:00
|
|
|
metrics.mCompositionBounds = ParentLayerRect(
|
|
|
|
ParentLayerPoint(),
|
2014-11-10 22:35:11 +03:00
|
|
|
ParentLayerSize(ViewAs<ParentLayerPixel>(mInnerSize, PixelCastJustification::ScreenIsParentLayerForRoot)));
|
2014-03-27 03:24:25 +04:00
|
|
|
metrics.SetRootCompositionSize(
|
2014-12-18 01:14:05 +03:00
|
|
|
ScreenSize(mInnerSize) * ScreenToLayoutDeviceScale(1.0f) / metrics.GetDevPixelsPerCSSPixel());
|
2014-03-25 06:28:46 +04: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.
|
2014-05-29 21:20:02 +04:00
|
|
|
float oldIntrinsicScale =
|
|
|
|
std::max(oldScreenSize.width / oldBrowserSize.width,
|
|
|
|
oldScreenSize.height / oldBrowserSize.height);
|
2014-03-25 06:28:46 +04:00
|
|
|
metrics.ZoomBy(metrics.CalculateIntrinsicScale().scale / oldIntrinsicScale);
|
|
|
|
|
|
|
|
// Changing the zoom when we're not doing a first paint will get ignored
|
|
|
|
// by AsyncPanZoomController and causes a blurry flash.
|
2015-04-14 23:44:59 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell = GetPresShell();
|
|
|
|
bool isFirstPaint = true;
|
|
|
|
if (shell) {
|
|
|
|
isFirstPaint = shell->GetIsFirstPaint();
|
|
|
|
}
|
|
|
|
if (isFirstPaint) {
|
2014-03-25 06:28:46 +04: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.
|
|
|
|
if (viewportInfo.GetDefaultZoom().scale < 0.01f) {
|
2014-11-10 22:35:11 +03:00
|
|
|
viewportInfo.SetDefaultZoom(ConvertScaleForRoot(metrics.CalculateIntrinsicScale()));
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CSSToScreenScale defaultZoom = viewportInfo.GetDefaultZoom();
|
|
|
|
MOZ_ASSERT(viewportInfo.GetMinZoom() <= defaultZoom &&
|
|
|
|
defaultZoom <= viewportInfo.GetMaxZoom());
|
2015-03-06 21:54:10 +03:00
|
|
|
metrics.SetZoom(CSSToParentLayerScale2D(ConvertScaleForRoot(defaultZoom)));
|
2014-03-25 06:28:46 +04:00
|
|
|
|
|
|
|
metrics.SetScrollId(viewId);
|
|
|
|
}
|
|
|
|
|
2015-04-14 20:19:10 +03:00
|
|
|
if (shell) {
|
2014-08-22 03:37:00 +04:00
|
|
|
if (nsPresContext* context = shell->GetPresContext()) {
|
2014-12-18 01:14:05 +03:00
|
|
|
metrics.SetDevPixelsPerCSSPixel(CSSToLayoutDeviceScale(
|
|
|
|
(float)nsPresContext::AppUnitsPerCSSPixel() / context->AppUnitsPerDevPixel()));
|
2014-08-22 03:37:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-19 03:33:18 +03:00
|
|
|
metrics.SetCumulativeResolution(metrics.GetZoom()
|
2014-12-18 01:14:05 +03:00
|
|
|
/ metrics.GetDevPixelsPerCSSPixel()
|
2014-12-19 03:33:18 +03:00
|
|
|
* ParentLayerToLayerScale(1));
|
2014-03-25 06:28:46 +04:00
|
|
|
// This is the root layer, so the cumulative resolution is the same
|
|
|
|
// as the resolution.
|
2015-03-06 21:54:10 +03:00
|
|
|
metrics.SetPresShellResolution(metrics.GetCumulativeResolution().ToScaleFactor().scale);
|
2015-04-14 20:19:10 +03:00
|
|
|
if (shell) {
|
|
|
|
nsLayoutUtils::SetResolutionAndScaleTo(shell, metrics.GetPresShellResolution());
|
2015-04-14 23:44:59 +03:00
|
|
|
nsLayoutUtils::SetScrollPositionClampingScrollPortSize(shell,
|
|
|
|
metrics.CalculateCompositedSizeInCssPixels());
|
2015-04-14 20:19:10 +03:00
|
|
|
}
|
2014-03-25 06:28:46 +04:00
|
|
|
|
|
|
|
// The call to GetPageSize forces a resize event to content, so we need to
|
|
|
|
// make sure that we have the right CSS viewport and
|
|
|
|
// scrollPositionClampingScrollPortSize set up before that happens.
|
|
|
|
|
|
|
|
CSSSize pageSize = GetPageSize(document, viewport);
|
|
|
|
if (!pageSize.width) {
|
|
|
|
// Return early rather than divide by 0.
|
|
|
|
return false;
|
|
|
|
}
|
2014-12-27 20:48:27 +03:00
|
|
|
metrics.SetScrollableRect(CSSRect(CSSPoint(), pageSize));
|
2014-03-25 06:28:46 +04:00
|
|
|
|
|
|
|
// Calculate a display port _after_ having a scrollable rect because the
|
|
|
|
// display port is clamped to the scrollable rect.
|
2014-10-16 17:23:52 +04:00
|
|
|
metrics.SetDisplayPortMargins(APZCTreeManager::CalculatePendingDisplayPort(
|
2014-03-25 06:28:46 +04: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.
|
2014-11-10 22:35:11 +03:00
|
|
|
metrics, ParentLayerPoint(0.0f, 0.0f), 0.0));
|
2014-03-27 05:46:24 +04:00
|
|
|
metrics.SetUseDisplayPortMargins();
|
2014-03-25 06:28:46 +04:00
|
|
|
|
|
|
|
// Force a repaint with these metrics. This, among other things, sets the
|
|
|
|
// displayport, so we start with async painting.
|
|
|
|
mLastRootMetrics = ProcessUpdateFrame(metrics);
|
|
|
|
|
|
|
|
if (viewportInfo.IsZoomAllowed() && scrollIdentifiersValid) {
|
|
|
|
// If the CSS viewport is narrower than the screen (i.e. width <= device-width)
|
|
|
|
// then we disable double-tap-to-zoom behaviour.
|
2014-12-18 01:14:05 +03:00
|
|
|
bool allowDoubleTapZoom = (viewport.width > screenW / metrics.GetDevPixelsPerCSSPixel().scale);
|
2014-03-25 06:28:46 +04:00
|
|
|
if (allowDoubleTapZoom != viewportInfo.IsDoubleTapZoomAllowed()) {
|
|
|
|
viewportInfo.SetAllowDoubleTapZoom(allowDoubleTapZoom);
|
|
|
|
|
|
|
|
ZoomConstraints constraints(
|
|
|
|
viewportInfo.IsZoomAllowed(),
|
|
|
|
viewportInfo.IsDoubleTapZoomAllowed(),
|
2014-11-10 22:35:11 +03:00
|
|
|
ConvertScaleForRoot(viewportInfo.GetMinZoom()),
|
|
|
|
ConvertScaleForRoot(viewportInfo.GetMaxZoom()));
|
2014-03-25 06:28:46 +04:00
|
|
|
DoUpdateZoomConstraints(presShellId,
|
|
|
|
viewId,
|
|
|
|
/* isRoot = */ true,
|
|
|
|
constraints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIDOMWindowUtils>
|
|
|
|
TabChildBase::GetDOMWindowUtils()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(WebNavigation());
|
|
|
|
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window);
|
|
|
|
return utils.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIDocument>
|
2015-01-16 21:48:33 +03:00
|
|
|
TabChildBase::GetDocument() const
|
2014-03-25 06:28:46 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
|
|
|
WebNavigation()->GetDocument(getter_AddRefs(domDoc));
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
|
|
|
return doc.forget();
|
|
|
|
}
|
|
|
|
|
2015-04-14 23:44:59 +03:00
|
|
|
already_AddRefed<nsIPresShell>
|
|
|
|
TabChildBase::GetPresShell() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresShell> result;
|
|
|
|
if (nsCOMPtr<nsIDocument> doc = GetDocument()) {
|
|
|
|
result = doc->GetShell();
|
|
|
|
}
|
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
void
|
|
|
|
TabChildBase::DispatchMessageManagerMessage(const nsAString& aMessageName,
|
|
|
|
const nsAString& aJSONData)
|
|
|
|
{
|
|
|
|
AutoSafeJSContext cx;
|
|
|
|
JS::Rooted<JS::Value> json(cx, JSVAL_NULL);
|
|
|
|
StructuredCloneData cloneData;
|
|
|
|
JSAutoStructuredCloneBuffer buffer;
|
|
|
|
if (JS_ParseJSON(cx,
|
2014-07-22 08:43:21 +04:00
|
|
|
static_cast<const char16_t*>(aJSONData.BeginReading()),
|
2014-03-25 06:28:46 +04:00
|
|
|
aJSONData.Length(),
|
|
|
|
&json)) {
|
|
|
|
WriteStructuredClone(cx, json, buffer, cloneData.mClosure);
|
|
|
|
cloneData.mData = buffer.data();
|
|
|
|
cloneData.mDataLength = buffer.nbytes();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> kungFuDeathGrip(GetGlobal());
|
|
|
|
// Let the BrowserElementScrolling helper (if it exists) for this
|
|
|
|
// content manipulate the frame state.
|
|
|
|
nsRefPtr<nsFrameMessageManager> mm =
|
|
|
|
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
2015-04-16 18:17:54 +03:00
|
|
|
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
|
2014-03-25 06:28:46 +04:00
|
|
|
aMessageName, false, &cloneData, nullptr, nullptr, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChildBase::UpdateFrameHandler(const FrameMetrics& aFrameMetrics)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFrameMetrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID);
|
|
|
|
|
2014-08-24 03:09:10 +04:00
|
|
|
if (aFrameMetrics.GetIsRoot()) {
|
2015-04-14 23:44:59 +03:00
|
|
|
if (nsCOMPtr<nsIPresShell> shell = GetPresShell()) {
|
|
|
|
// Guard against stale updates (updates meant for a pres shell which
|
|
|
|
// has since been torn down and destroyed).
|
|
|
|
if (aFrameMetrics.GetPresShellId() == shell->GetPresShellId()) {
|
|
|
|
mLastRootMetrics = ProcessUpdateFrame(aFrameMetrics);
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// aFrameMetrics.mIsRoot is false, so we are trying to update a subframe.
|
|
|
|
// This requires special handling.
|
|
|
|
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(
|
|
|
|
aFrameMetrics.GetScrollId());
|
|
|
|
if (content) {
|
|
|
|
FrameMetrics newSubFrameMetrics(aFrameMetrics);
|
|
|
|
APZCCallbackHelper::UpdateSubFrame(content, newSubFrameMetrics);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
FrameMetrics
|
|
|
|
TabChildBase::ProcessUpdateFrame(const FrameMetrics& aFrameMetrics)
|
|
|
|
{
|
|
|
|
if (!mGlobal || !mTabChildGlobal) {
|
|
|
|
return aFrameMetrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
FrameMetrics newMetrics = aFrameMetrics;
|
2015-04-14 23:44:59 +03:00
|
|
|
if (nsCOMPtr<nsIPresShell> presShell = GetPresShell()) {
|
|
|
|
APZCCallbackHelper::UpdateRootFrame(presShell, newMetrics);
|
2015-04-11 02:34:23 +03:00
|
|
|
}
|
2014-03-25 06:28:46 +04:00
|
|
|
|
2014-03-28 18:36:47 +04:00
|
|
|
CSSSize cssCompositedSize = newMetrics.CalculateCompositedSizeInCssPixels();
|
2014-03-25 06:28:46 +04:00
|
|
|
// The BrowserElementScrolling helper must know about these updated metrics
|
|
|
|
// for other functions it performs, such as double tap handling.
|
|
|
|
// Note, %f must not be used because it is locale specific!
|
|
|
|
nsString data;
|
|
|
|
data.AppendPrintf("{ \"x\" : %d", NS_lround(newMetrics.GetScrollOffset().x));
|
|
|
|
data.AppendPrintf(", \"y\" : %d", NS_lround(newMetrics.GetScrollOffset().y));
|
|
|
|
data.AppendLiteral(", \"viewport\" : ");
|
|
|
|
data.AppendLiteral("{ \"width\" : ");
|
2014-08-23 07:18:56 +04:00
|
|
|
data.AppendFloat(newMetrics.GetViewport().width);
|
2014-03-25 06:28:46 +04:00
|
|
|
data.AppendLiteral(", \"height\" : ");
|
2014-08-23 07:18:56 +04:00
|
|
|
data.AppendFloat(newMetrics.GetViewport().height);
|
2014-03-25 06:28:46 +04:00
|
|
|
data.AppendLiteral(" }");
|
|
|
|
data.AppendLiteral(", \"cssPageRect\" : ");
|
|
|
|
data.AppendLiteral("{ \"x\" : ");
|
2014-12-27 20:48:27 +03:00
|
|
|
data.AppendFloat(newMetrics.GetScrollableRect().x);
|
2014-03-25 06:28:46 +04:00
|
|
|
data.AppendLiteral(", \"y\" : ");
|
2014-12-27 20:48:27 +03:00
|
|
|
data.AppendFloat(newMetrics.GetScrollableRect().y);
|
2014-03-25 06:28:46 +04:00
|
|
|
data.AppendLiteral(", \"width\" : ");
|
2014-12-27 20:48:27 +03:00
|
|
|
data.AppendFloat(newMetrics.GetScrollableRect().width);
|
2014-03-25 06:28:46 +04:00
|
|
|
data.AppendLiteral(", \"height\" : ");
|
2014-12-27 20:48:27 +03:00
|
|
|
data.AppendFloat(newMetrics.GetScrollableRect().height);
|
2014-03-25 06:28:46 +04:00
|
|
|
data.AppendLiteral(" }");
|
|
|
|
data.AppendLiteral(", \"cssCompositedRect\" : ");
|
|
|
|
data.AppendLiteral("{ \"width\" : ");
|
2014-03-28 18:36:47 +04:00
|
|
|
data.AppendFloat(cssCompositedSize.width);
|
2014-03-25 06:28:46 +04:00
|
|
|
data.AppendLiteral(", \"height\" : ");
|
2014-03-28 18:36:47 +04:00
|
|
|
data.AppendFloat(cssCompositedSize.height);
|
2014-03-25 06:28:46 +04:00
|
|
|
data.AppendLiteral(" }");
|
|
|
|
data.AppendLiteral(" }");
|
|
|
|
|
|
|
|
DispatchMessageManagerMessage(NS_LITERAL_STRING("Viewport:Change"), data);
|
|
|
|
return newMetrics;
|
|
|
|
}
|
|
|
|
|
2009-11-17 17:22:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ContentListener::HandleEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
RemoteDOMEvent remoteEvent;
|
|
|
|
remoteEvent.mEvent = do_QueryInterface(aEvent);
|
|
|
|
NS_ENSURE_STATE(remoteEvent.mEvent);
|
2010-07-19 22:33:33 +04:00
|
|
|
mTabChild->SendEvent(remoteEvent);
|
2009-11-17 17:22:23 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-02-16 02:27:21 +04: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;
|
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit CachedFileDescriptorInfo(const nsAString& aPath)
|
2013-02-16 02:27:21 +04:00
|
|
|
: 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:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit CachedFileDescriptorCallbackRunnable(CachedFileDescriptorInfo* aInfo)
|
2013-02-16 02:27:21 +04:00
|
|
|
: 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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class TabChild::DelayedDeleteRunnable final
|
2014-07-11 22:15:10 +04:00
|
|
|
: public nsRunnable
|
|
|
|
{
|
|
|
|
nsRefPtr<TabChild> mTabChild;
|
|
|
|
|
|
|
|
public:
|
2014-12-11 01:49:09 +03:00
|
|
|
explicit DelayedDeleteRunnable(TabChild* aTabChild)
|
2014-07-11 22:15:10 +04:00
|
|
|
: mTabChild(aTabChild)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aTabChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
~DelayedDeleteRunnable()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(!mTabChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
Run()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mTabChild);
|
|
|
|
|
2015-01-07 08:42:00 +03:00
|
|
|
// Check in case ActorDestroy was called after RecvDestroy message.
|
|
|
|
if (mTabChild->IPCOpen()) {
|
|
|
|
unused << PBrowserChild::Send__delete__(mTabChild);
|
|
|
|
}
|
2014-07-11 22:15:10 +04:00
|
|
|
|
|
|
|
mTabChild = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-01-30 12:07:12 +03:00
|
|
|
namespace {
|
2012-08-29 19:26:18 +04:00
|
|
|
StaticRefPtr<TabChild> sPreallocatedTab;
|
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
std::map<TabId, nsRefPtr<TabChild>>&
|
2015-01-30 12:07:12 +03:00
|
|
|
NestedTabChildMap()
|
2014-06-11 09:44:36 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2014-10-29 21:11:00 +03:00
|
|
|
static std::map<TabId, nsRefPtr<TabChild>> sNestedTabChildMap;
|
2014-06-11 09:44:36 +04:00
|
|
|
return sNestedTabChildMap;
|
|
|
|
}
|
2015-01-30 12:07:12 +03:00
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
already_AddRefed<TabChild>
|
|
|
|
TabChild::FindTabChild(const TabId& aTabId)
|
|
|
|
{
|
|
|
|
auto iter = NestedTabChildMap().find(aTabId);
|
|
|
|
if (iter == NestedTabChildMap().end()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
nsRefPtr<TabChild> tabChild = iter->second;
|
|
|
|
return tabChild.forget();
|
|
|
|
}
|
2014-06-11 09:44:36 +04:00
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
/*static*/ void
|
|
|
|
TabChild::PreloadSlowThings()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!sPreallocatedTab);
|
|
|
|
|
2014-09-09 12:57:54 +04:00
|
|
|
// Pass nullptr to aManager since at this point the TabChild is
|
|
|
|
// not connected to any manager. Any attempt to use the TabChild
|
|
|
|
// in IPC will crash.
|
|
|
|
nsRefPtr<TabChild> tab(new TabChild(nullptr,
|
2014-10-29 21:11:00 +03:00
|
|
|
TabId(0),
|
2013-07-10 21:07:51 +04:00
|
|
|
TabContext(), /* chromeFlags */ 0));
|
2012-08-29 19:26:18 +04:00
|
|
|
if (!NS_SUCCEEDED(tab->Init()) ||
|
|
|
|
!tab->InitTabChildGlobal(DONT_LOAD_SCRIPTS)) {
|
|
|
|
return;
|
|
|
|
}
|
2013-02-06 06:27:52 +04:00
|
|
|
// Just load and compile these scripts, but don't run them.
|
2013-11-24 09:32:45 +04:00
|
|
|
tab->TryCacheLoadAndCompileScript(BROWSER_ELEMENT_CHILD_SCRIPT, true);
|
2013-02-06 06:27:52 +04:00
|
|
|
// Load, compile, and run these scripts.
|
|
|
|
tab->RecvLoadRemoteScript(
|
2013-11-24 09:32:45 +04:00
|
|
|
NS_LITERAL_STRING("chrome://global/content/preload.js"),
|
|
|
|
true);
|
2012-08-29 19:26:18 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(tab->WebNavigation());
|
2013-02-05 10:38:54 +04:00
|
|
|
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 19:26:18 +04:00
|
|
|
sPreallocatedTab = tab;
|
|
|
|
ClearOnShutdown(&sPreallocatedTab);
|
|
|
|
}
|
|
|
|
|
2014-12-18 12:01:33 +03:00
|
|
|
/*static*/ void
|
|
|
|
TabChild::PostForkPreload()
|
|
|
|
{
|
|
|
|
// Preallocated Tab can be null if we are forked directly from b2g. In such
|
|
|
|
// case we don't need to preload anything, just return.
|
|
|
|
if (!sPreallocatedTab) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rebuild connections to parent.
|
|
|
|
sPreallocatedTab->RecvLoadRemoteScript(
|
|
|
|
NS_LITERAL_STRING("chrome://global/content/post-fork-preload.js"),
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
/*static*/ already_AddRefed<TabChild>
|
2014-09-09 12:57:54 +04:00
|
|
|
TabChild::Create(nsIContentChild* aManager,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2014-09-09 12:57:54 +04:00
|
|
|
const TabContext &aContext,
|
|
|
|
uint32_t aChromeFlags)
|
2012-08-29 19:26:18 +04: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 22:32:37 +04:00
|
|
|
aContext.IsBrowserOrApp()) {
|
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
nsRefPtr<TabChild> child = sPreallocatedTab.get();
|
|
|
|
sPreallocatedTab = nullptr;
|
|
|
|
|
|
|
|
MOZ_ASSERT(!child->mTriedBrowserInit);
|
|
|
|
|
2014-09-09 12:57:54 +04:00
|
|
|
child->mManager = aManager;
|
2014-10-29 21:11:00 +03:00
|
|
|
child->SetTabId(aTabId);
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
child->SetTabContext(aContext);
|
|
|
|
child->NotifyTabContextUpdated();
|
2012-08-29 19:26:18 +04:00
|
|
|
return child.forget();
|
|
|
|
}
|
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
nsRefPtr<TabChild> iframe = new TabChild(aManager, aTabId,
|
2013-07-10 21:07:51 +04:00
|
|
|
aContext, aChromeFlags);
|
2012-08-29 19:26:18 +04:00
|
|
|
return NS_SUCCEEDED(iframe->Init()) ? iframe.forget() : nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-19 13:33:33 +03:00
|
|
|
class TabChildSetAllowedTouchBehaviorCallback : public SetAllowedTouchBehaviorCallback {
|
|
|
|
public:
|
|
|
|
explicit TabChildSetAllowedTouchBehaviorCallback(TabChild* aTabChild)
|
|
|
|
: mTabChild(do_GetWeakReference(static_cast<nsITabChild*>(aTabChild)))
|
|
|
|
{}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Run(uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aFlags) const override {
|
2015-03-19 13:33:33 +03:00
|
|
|
if (nsCOMPtr<nsITabChild> tabChild = do_QueryReferent(mTabChild)) {
|
|
|
|
static_cast<TabChild*>(tabChild.get())->SendSetAllowedTouchBehavior(aInputBlockId, aFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsWeakPtr mTabChild;
|
|
|
|
};
|
|
|
|
|
2015-02-09 22:05:18 +03:00
|
|
|
class TabChildContentReceivedInputBlockCallback : public ContentReceivedInputBlockCallback {
|
|
|
|
public:
|
|
|
|
explicit TabChildContentReceivedInputBlockCallback(TabChild* aTabChild)
|
|
|
|
: mTabChild(do_GetWeakReference(static_cast<nsITabChild*>(aTabChild)))
|
|
|
|
{}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void Run(const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId, bool aPreventDefault) const override {
|
2015-02-09 22:05:18 +03:00
|
|
|
if (nsCOMPtr<nsITabChild> tabChild = do_QueryReferent(mTabChild)) {
|
|
|
|
static_cast<TabChild*>(tabChild.get())->SendContentReceivedInputBlock(aGuid, aInputBlockId, aPreventDefault);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsWeakPtr mTabChild;
|
|
|
|
};
|
2010-05-17 15:25:22 +04:00
|
|
|
|
2014-09-09 12:57:54 +04:00
|
|
|
TabChild::TabChild(nsIContentChild* aManager,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2014-09-09 12:57:54 +04:00
|
|
|
const TabContext& aContext,
|
|
|
|
uint32_t aChromeFlags)
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
: TabContext(aContext)
|
|
|
|
, mRemoteFrame(nullptr)
|
2013-07-10 21:07:51 +04:00
|
|
|
, mManager(aManager)
|
2010-07-19 22:33:33 +04:00
|
|
|
, mChromeFlags(aChromeFlags)
|
2014-03-07 07:24:32 +04:00
|
|
|
, mLayersId(0)
|
2011-07-16 01:46:56 +04:00
|
|
|
, mOuterRect(0, 0, 0, 0)
|
2013-01-05 18:53:16 +04:00
|
|
|
, mActivePointerId(-1)
|
2013-05-30 04:56:09 +04:00
|
|
|
, mAppPackageFileDescriptorRecved(false)
|
2011-10-21 02:17:09 +04: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-31 00:13:21 +04:00
|
|
|
, mDidFakeShow(false)
|
2012-08-07 07:00:41 +04:00
|
|
|
, mNotified(false)
|
2012-08-29 19:26:18 +04:00
|
|
|
, mTriedBrowserInit(false)
|
2012-11-22 06:40:57 +04:00
|
|
|
, mOrientation(eScreenOrientation_PortraitPrimary)
|
2013-08-13 11:56:57 +04:00
|
|
|
, mUpdateHitRegion(false)
|
2014-03-12 07:13:38 +04:00
|
|
|
, mIgnoreKeyPressEvent(false)
|
2015-03-19 13:33:33 +03:00
|
|
|
, mSetAllowedTouchBehaviorCallback(new TabChildSetAllowedTouchBehaviorCallback(this))
|
2014-04-25 19:40:23 +04:00
|
|
|
, mHasValidInnerSize(false)
|
2014-08-24 11:16:32 +04:00
|
|
|
, mDestroyed(false)
|
2014-10-29 21:11:00 +03:00
|
|
|
, mUniqueId(aTabId)
|
2014-12-12 20:50:46 +03:00
|
|
|
, mDPI(0)
|
|
|
|
, mDefaultScale(0)
|
2015-01-07 08:42:00 +03:00
|
|
|
, mIPCOpen(true)
|
2015-02-06 19:26:29 +03:00
|
|
|
, mParentIsActive(false)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
2014-10-29 21:11:00 +03:00
|
|
|
// preloaded TabChild should not be added to child map
|
|
|
|
if (mUniqueId) {
|
|
|
|
MOZ_ASSERT(NestedTabChildMap().find(mUniqueId) == NestedTabChildMap().end());
|
|
|
|
NestedTabChildMap()[mUniqueId] = this;
|
|
|
|
}
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2012-09-29 06:18:18 +04: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.
|
2014-08-06 20:41:05 +04:00
|
|
|
HandlePossibleViewportChange(mInnerSize);
|
2014-08-22 03:37:00 +04:00
|
|
|
} else if (eventType.EqualsLiteral("FullZoomChange")) {
|
|
|
|
HandlePossibleViewportChange(mInnerSize);
|
2012-09-29 06:18:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-09 00:37:57 +04:00
|
|
|
TabChild::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aData)
|
2012-08-09 00:37:57 +04:00
|
|
|
{
|
2013-10-31 01:06:15 +04:00
|
|
|
if (!strcmp(aTopic, BROWSER_ZOOM_TO_RECT)) {
|
2012-08-09 08:39:02 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aSubject));
|
2013-09-12 23:24:11 +04:00
|
|
|
nsCOMPtr<nsITabChild> tabChild(TabChild::GetFrom(docShell));
|
2012-08-09 08:39:02 +04:00
|
|
|
if (tabChild == this) {
|
2013-11-13 22:20:30 +04:00
|
|
|
nsCOMPtr<nsIDocument> doc(GetDocument());
|
|
|
|
uint32_t presShellId;
|
|
|
|
ViewID viewId;
|
2014-05-05 23:06:28 +04:00
|
|
|
if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(doc->GetDocumentElement(),
|
|
|
|
&presShellId, &viewId)) {
|
2013-11-13 22:20:30 +04:00
|
|
|
CSSRect rect;
|
|
|
|
sscanf(NS_ConvertUTF16toUTF8(aData).get(),
|
|
|
|
"{\"x\":%f,\"y\":%f,\"w\":%f,\"h\":%f}",
|
|
|
|
&rect.x, &rect.y, &rect.width, &rect.height);
|
|
|
|
SendZoomToRect(presShellId, viewId, rect);
|
|
|
|
}
|
2012-08-09 08:39:02 +04:00
|
|
|
}
|
2012-09-29 06:18:18 +04:00
|
|
|
} else if (!strcmp(aTopic, BEFORE_FIRST_PAINT)) {
|
2015-02-26 16:47:01 +03:00
|
|
|
if (gfxPrefs::AsyncPanZoomEnabled()) {
|
2012-09-29 06:18:18 +04:00
|
|
|
nsCOMPtr<nsIDocument> subject(do_QueryInterface(aSubject));
|
2013-11-13 22:20:30 +04:00
|
|
|
nsCOMPtr<nsIDocument> doc(GetDocument());
|
2012-09-29 06:18:18 +04:00
|
|
|
|
|
|
|
if (SameCOMIdentity(subject, doc)) {
|
2015-04-14 23:44:59 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell(doc->GetShell());
|
|
|
|
if (shell) {
|
|
|
|
shell->SetIsFirstPaint(true);
|
|
|
|
}
|
2012-09-29 06:18:18 +04:00
|
|
|
|
|
|
|
mContentDocumentIsDisplayed = true;
|
|
|
|
|
2014-02-22 03:12:43 +04:00
|
|
|
// In some cases before-first-paint gets called before
|
|
|
|
// RecvUpdateDimensions is called and therefore before we have an
|
|
|
|
// mInnerSize value set. In such cases defer initializing the viewport
|
|
|
|
// until we we get an inner size.
|
|
|
|
if (HasValidInnerSize()) {
|
|
|
|
InitializeRootMetrics();
|
2015-04-14 23:44:59 +03:00
|
|
|
if (shell) {
|
2015-04-14 20:19:10 +03:00
|
|
|
nsLayoutUtils::SetResolutionAndScaleTo(shell, mLastRootMetrics.GetPresShellResolution());
|
|
|
|
}
|
2014-08-06 20:41:05 +04:00
|
|
|
HandlePossibleViewportChange(mInnerSize);
|
2014-02-22 03:12:43 +04:00
|
|
|
}
|
2012-09-29 06:18:18 +04:00
|
|
|
}
|
|
|
|
}
|
2012-08-09 00:37:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-29 06:18:18 +04: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,
|
2014-03-25 06:28:46 +04:00
|
|
|
nsIURI *aLocation,
|
|
|
|
uint32_t aFlags)
|
|
|
|
{
|
2015-02-26 16:47:01 +03:00
|
|
|
if (!gfxPrefs::AsyncPanZoomEnabled()) {
|
2014-03-25 06:28:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-10-12 09:46:24 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDOMWindow> window;
|
|
|
|
aWebProgress->GetDOMWindow(getter_AddRefs(window));
|
|
|
|
if (!window) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-12-18 01:24:41 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDOMDocument> progressDoc;
|
|
|
|
window->GetDocument(getter_AddRefs(progressDoc));
|
|
|
|
if (!progressDoc) {
|
|
|
|
return NS_OK;
|
2012-10-12 09:46:24 +04:00
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
|
|
|
WebNavigation()->GetDocument(getter_AddRefs(domDoc));
|
|
|
|
if (!domDoc || !SameCOMIdentity(domDoc, progressDoc)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-10-12 09:46:24 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIURIFixup> urifixup(do_GetService(NS_URIFIXUP_CONTRACTID));
|
|
|
|
if (!urifixup) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-12-16 19:05:23 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIURI> exposableURI;
|
|
|
|
urifixup->CreateExposableURI(aLocation, getter_AddRefs(exposableURI));
|
|
|
|
if (!exposableURI) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-12-16 19:05:23 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
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;
|
|
|
|
}
|
2013-12-16 19:05:23 +04:00
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-03-05 04:02:37 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsresult aStatus,
|
|
|
|
const char16_t* aMessage)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("not implemented in TabChild");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-02-25 04:22:45 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnSecurityChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
uint32_t aState)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("not implemented in TabChild");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-02-25 04:22:45 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
bool
|
|
|
|
TabChild::DoUpdateZoomConstraints(const uint32_t& aPresShellId,
|
|
|
|
const ViewID& aViewId,
|
|
|
|
const bool& aIsRoot,
|
|
|
|
const ZoomConstraints& aConstraints)
|
|
|
|
{
|
|
|
|
return SendUpdateZoomConstraints(aPresShellId,
|
|
|
|
aViewId,
|
|
|
|
aIsRoot,
|
|
|
|
aConstraints);
|
2012-09-29 06:18:18 +04:00
|
|
|
}
|
|
|
|
|
2009-11-05 21:14:22 +03: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?");
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(WebNavigation()));
|
2009-11-05 21:14:22 +03:00
|
|
|
docShellItem->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
|
2012-08-29 19:26:18 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(WebNavigation());
|
2012-08-29 19:26:18 +04:00
|
|
|
if (!baseWindow) {
|
|
|
|
NS_ERROR("mWebNav doesn't QI to nsIBaseWindow");
|
2012-09-07 17:23:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-08-29 19:26:18 +04:00
|
|
|
}
|
2012-08-09 00:37:57 +04:00
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
mWidget = nsIWidget::CreatePuppetWidget(this);
|
|
|
|
if (!mWidget) {
|
|
|
|
NS_ERROR("couldn't create fake widget");
|
2012-09-07 17:23:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-08-29 19:26:18 +04:00
|
|
|
}
|
|
|
|
mWidget->Create(
|
|
|
|
nullptr, 0, // no parents
|
2015-04-21 18:04:57 +03:00
|
|
|
gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)),
|
2015-02-05 10:35:25 +03:00
|
|
|
nullptr // HandleWidgetEvent
|
2012-08-29 19:26:18 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
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 22:32:37 +04:00
|
|
|
NotifyTabContextUpdated();
|
2012-08-29 19:26:18 +04: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-09 00:37:57 +04:00
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
2012-09-29 06:18:18 +04:00
|
|
|
MOZ_ASSERT(docShell);
|
2013-05-07 08:10:31 +04:00
|
|
|
|
|
|
|
docShell->SetAffectPrivateSessionLifetime(
|
|
|
|
mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME);
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(WebNavigation());
|
2013-05-07 08:10:31 +04:00
|
|
|
MOZ_ASSERT(loadContext);
|
|
|
|
loadContext->SetPrivateBrowsing(
|
|
|
|
mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW);
|
2014-02-11 21:00:54 +04:00
|
|
|
loadContext->SetRemoteTabs(
|
|
|
|
mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW);
|
2013-05-07 08:10:31 +04:00
|
|
|
|
2012-09-29 06:18:18 +04:00
|
|
|
nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell);
|
|
|
|
NS_ENSURE_TRUE(webProgress, NS_ERROR_FAILURE);
|
|
|
|
webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_LOCATION);
|
|
|
|
|
2014-04-09 09:15:00 +04:00
|
|
|
// Few lines before, baseWindow->Create() will end up creating a new
|
|
|
|
// window root in nsGlobalWindow::SetDocShell.
|
|
|
|
// Then this chrome event handler, will be inherited to inner windows.
|
|
|
|
// We want to also set it to the docshell so that inner windows
|
|
|
|
// and any code that has access to the docshell
|
|
|
|
// can all listen to the same chrome event handler.
|
|
|
|
// XXX: ideally, we would set a chrome event handler earlier,
|
|
|
|
// and all windows, even the root one, will use the docshell one.
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(WebNavigation());
|
|
|
|
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
|
|
|
nsCOMPtr<EventTarget> chromeHandler =
|
|
|
|
do_QueryInterface(window->GetChromeEventHandler());
|
|
|
|
docShell->SetChromeEventHandler(chromeHandler);
|
|
|
|
|
2015-02-09 22:05:18 +03:00
|
|
|
mAPZEventState = new APZEventState(mWidget,
|
|
|
|
new TabChildContentReceivedInputBlockCallback(this));
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-29 19:26:18 +04: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 22:32:37 +04:00
|
|
|
TabChild::NotifyTabContextUpdated()
|
2012-08-29 19:26:18 +04:00
|
|
|
{
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
2012-08-29 19:26:18 +04:00
|
|
|
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 22:32:37 +04: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 19:26:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-07 04:11:20 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChild)
|
2010-05-17 15:25:22 +04: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-29 06:18:18 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
2010-05-17 15:25:22 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsITabChild)
|
2012-09-29 06:18:18 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
2014-03-28 12:40:13 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2014-01-23 00:27:23 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
|
2014-05-07 04:11:20 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(TabChildBase)
|
2010-05-17 15:25:22 +04:00
|
|
|
|
2014-05-07 04:11:20 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(TabChild, TabChildBase);
|
|
|
|
NS_IMPL_RELEASE_INHERITED(TabChild, TabChildBase);
|
2009-11-05 21:14:22 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
TabChild::SetStatus(uint32_t aStatusType, const char16_t* aStatus)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2013-07-25 23:45:31 +04:00
|
|
|
return SetStatusWithContext(aStatusType,
|
|
|
|
aStatus ? static_cast<const nsString &>(nsDependentString(aStatus))
|
|
|
|
: EmptyString(),
|
|
|
|
nullptr);
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetWebBrowser(nsIWebBrowser** aWebBrowser)
|
|
|
|
{
|
2010-11-03 16:00:49 +03:00
|
|
|
NS_NOTREACHED("TabChild::GetWebBrowser not supported in TabChild");
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::SetWebBrowser(nsIWebBrowser* aWebBrowser)
|
|
|
|
{
|
2010-11-03 16:00:49 +03:00
|
|
|
NS_NOTREACHED("TabChild::SetWebBrowser not supported in TabChild");
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabChild::GetChromeFlags(uint32_t* aChromeFlags)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2010-07-19 22:33:33 +04:00
|
|
|
*aChromeFlags = mChromeFlags;
|
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabChild::SetChromeFlags(uint32_t aChromeFlags)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2010-11-03 16:00:49 +03:00
|
|
|
NS_NOTREACHED("trying to SetChromeFlags from content process?");
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::DestroyBrowserWindow()
|
|
|
|
{
|
2014-03-12 12:36:04 +04:00
|
|
|
NS_NOTREACHED("TabChild::DestroyBrowserWindow not supported in TabChild");
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabChild::SizeBrowserTo(int32_t aCX, int32_t aCY)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2010-11-03 16:00:49 +03:00
|
|
|
NS_NOTREACHED("TabChild::SizeBrowserTo not supported in TabChild");
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::ShowAsModal()
|
|
|
|
{
|
2010-11-03 16:00:49 +03:00
|
|
|
NS_NOTREACHED("TabChild::ShowAsModal not supported in TabChild");
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
TabChild::IsWindowModal(bool* aRetVal)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
*aRetVal = false;
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::ExitModalEventLoop(nsresult aStatus)
|
|
|
|
{
|
2010-11-03 16:00:49 +03:00
|
|
|
NS_NOTREACHED("TabChild::ExitModalEventLoop not supported in TabChild");
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabChild::SetStatusWithContext(uint32_t aStatusType,
|
2013-07-25 23:45:31 +04:00
|
|
|
const nsAString& aStatusText,
|
|
|
|
nsISupports* aStatusContext)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2013-07-25 23:45:31 +04:00
|
|
|
// We can only send the status after the ipc machinery is set up,
|
|
|
|
// mRemoteFrame is a good indicator.
|
|
|
|
if (mRemoteFrame)
|
|
|
|
SendSetStatus(aStatusType, nsString(aStatusText));
|
2011-07-07 19:11:58 +04:00
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabChild::SetDimensions(uint32_t aFlags, int32_t aX, int32_t aY,
|
|
|
|
int32_t aCx, int32_t aCy)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2015-01-13 03:41:53 +03:00
|
|
|
unused << PBrowserChild::SendSetDimensions(aFlags, aX, aY, aCx, aCy);
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2015-01-13 03:41:53 +03:00
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabChild::GetDimensions(uint32_t aFlags, int32_t* aX,
|
|
|
|
int32_t* aY, int32_t* aCx, int32_t* aCy)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2011-07-16 01:46:56 +04:00
|
|
|
if (aX) {
|
|
|
|
*aX = mOuterRect.x;
|
|
|
|
}
|
|
|
|
if (aY) {
|
|
|
|
*aY = mOuterRect.y;
|
|
|
|
}
|
|
|
|
if (aCx) {
|
|
|
|
*aCx = mOuterRect.width;
|
|
|
|
}
|
|
|
|
if (aCy) {
|
|
|
|
*aCy = mOuterRect.height;
|
|
|
|
}
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2011-07-16 01:46:56 +04:00
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::SetFocus()
|
|
|
|
{
|
2013-10-25 00:57:19 +04:00
|
|
|
NS_WARNING("TabChild::SetFocus not supported in TabChild");
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
TabChild::GetVisibility(bool* aVisibility)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
*aVisibility = true;
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
TabChild::SetVisibility(bool aVisibility)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2011-06-23 00:43:05 +04:00
|
|
|
// should the platform support this? Bug 666365
|
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
TabChild::GetTitle(char16_t** aTitle)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2010-11-03 16:00:49 +03:00
|
|
|
NS_NOTREACHED("TabChild::GetTitle not supported in TabChild");
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
TabChild::SetTitle(const char16_t* aTitle)
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2013-08-06 20:35:39 +04:00
|
|
|
// JavaScript sends the "DOMTitleChanged" event to the parent
|
|
|
|
// via the message manager.
|
2011-01-04 19:40:54 +03:00
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetSiteWindow(void** aSiteWindow)
|
|
|
|
{
|
2010-11-03 16:00:49 +03:00
|
|
|
NS_NOTREACHED("TabChild::GetSiteWindow not supported in TabChild");
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::Blur()
|
|
|
|
{
|
2013-10-25 00:57:19 +04:00
|
|
|
NS_WARNING("TabChild::Blur not supported in TabChild");
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::FocusNextElement()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
SendMoveFocus(true);
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::FocusPrevElement()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
SendMoveFocus(false);
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
2009-10-28 23:41:46 +03:00
|
|
|
}
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2010-01-01 04:34:06 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetInterface(const nsIID & aIID, void **aSink)
|
|
|
|
{
|
2014-09-03 01:43:08 +04:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIWebBrowserChrome3))) {
|
|
|
|
NS_IF_ADDREF(((nsISupports *) (*aSink = mWebBrowserChrome)));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-01 04:34:06 +03:00
|
|
|
// XXXbz should we restrict the set of interfaces we hand out here?
|
|
|
|
// See bug 537429
|
|
|
|
return QueryInterface(aIID, aSink);
|
|
|
|
}
|
|
|
|
|
2010-01-01 04:35:55 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
TabChild::ProvideWindow(nsIDOMWindow* aParent, uint32_t aChromeFlags,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCalledFromJS,
|
|
|
|
bool aPositionSpecified, bool aSizeSpecified,
|
2010-01-01 04:35:55 +03:00
|
|
|
nsIURI* aURI, const nsAString& aName,
|
2011-09-29 10:19:26 +04:00
|
|
|
const nsACString& aFeatures, bool* aWindowIsNew,
|
2010-01-01 04:35:55 +03:00
|
|
|
nsIDOMWindow** aReturn)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*aReturn = nullptr;
|
2010-01-01 04:35:55 +03: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 22:32:37 +04: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-13 02:01:25 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
|
2015-01-16 21:07:50 +03:00
|
|
|
bool iframeMoz = (docshell && docshell->GetIsInBrowserOrApp() &&
|
|
|
|
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_CHROME)));
|
|
|
|
|
|
|
|
if (!iframeMoz) {
|
|
|
|
int32_t openLocation =
|
|
|
|
nsWindowWatcher::GetWindowOpenLocation(aParent, aChromeFlags, aCalledFromJS,
|
|
|
|
aPositionSpecified, aSizeSpecified);
|
|
|
|
|
|
|
|
// If it turns out we're opening in the current browser, just hand over the
|
|
|
|
// current browser's docshell.
|
|
|
|
if (openLocation == nsIBrowserDOMWindow::OPEN_CURRENTWINDOW) {
|
|
|
|
nsCOMPtr<nsIWebBrowser> browser = do_GetInterface(WebNavigation());
|
|
|
|
*aWindowIsNew = false;
|
|
|
|
return browser->GetContentDOMWindow(aReturn);
|
|
|
|
}
|
2010-01-01 04:35:55 +03:00
|
|
|
}
|
|
|
|
|
2015-01-16 21:07:50 +03:00
|
|
|
// Note that ProvideWindowCommon 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 ProvideWindowCommon(aParent,
|
|
|
|
iframeMoz,
|
|
|
|
aChromeFlags,
|
|
|
|
aCalledFromJS,
|
|
|
|
aPositionSpecified,
|
|
|
|
aSizeSpecified,
|
|
|
|
aURI,
|
|
|
|
aName,
|
|
|
|
aFeatures,
|
|
|
|
aWindowIsNew,
|
|
|
|
aReturn);
|
2010-01-01 04:35:55 +03:00
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
nsresult
|
2015-01-16 21:06:56 +03:00
|
|
|
TabChild::ProvideWindowCommon(nsIDOMWindow* aOpener,
|
2015-01-16 21:07:50 +03:00
|
|
|
bool aIframeMoz,
|
2015-01-16 21:06:56 +03:00
|
|
|
uint32_t aChromeFlags,
|
|
|
|
bool aCalledFromJS,
|
|
|
|
bool aPositionSpecified,
|
|
|
|
bool aSizeSpecified,
|
|
|
|
nsIURI* aURI,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsACString& aFeatures,
|
|
|
|
bool* aWindowIsNew,
|
|
|
|
nsIDOMWindow** aReturn)
|
2012-06-13 02:01:25 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*aReturn = nullptr;
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
ContentChild* cc = ContentChild::GetSingleton();
|
|
|
|
const TabId openerTabId = GetTabId();
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
|
|
|
|
// 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;
|
2014-10-29 21:11:00 +03:00
|
|
|
context.opener() = openerTabId;
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
context.isBrowserElement() = IsBrowserElement();
|
|
|
|
|
2015-02-26 16:47:01 +03:00
|
|
|
IPCTabContext ipcContext(context);
|
2014-10-29 21:11:00 +03:00
|
|
|
|
|
|
|
TabId tabId;
|
|
|
|
cc->SendAllocateTabId(openerTabId,
|
|
|
|
ipcContext,
|
|
|
|
cc->GetID(),
|
|
|
|
&tabId);
|
|
|
|
|
|
|
|
nsRefPtr<TabChild> newChild = new TabChild(ContentChild::GetSingleton(), tabId,
|
2015-01-16 21:06:56 +03:00
|
|
|
/* TabContext */ *this, aChromeFlags);
|
2014-10-29 21:11:00 +03:00
|
|
|
if (NS_FAILED(newChild->Init())) {
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
context.opener() = this;
|
2012-08-09 06:58:06 +04:00
|
|
|
unused << Manager()->SendPBrowserConstructor(
|
|
|
|
// We release this ref in DeallocPBrowserChild
|
2014-03-15 23:00:15 +04:00
|
|
|
nsRefPtr<TabChild>(newChild).forget().take(),
|
2015-02-26 16:47:01 +03:00
|
|
|
tabId, IPCTabContext(context), aChromeFlags,
|
2014-06-04 01:15:27 +04:00
|
|
|
cc->GetID(), cc->IsForApp(), cc->IsForBrowser());
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec;
|
2012-08-01 07:12:04 +04:00
|
|
|
if (aURI) {
|
|
|
|
aURI->GetSpec(spec);
|
|
|
|
}
|
2012-06-13 02:01:25 +04:00
|
|
|
|
|
|
|
NS_ConvertUTF8toUTF16 url(spec);
|
|
|
|
nsString name(aName);
|
2015-01-16 21:07:50 +03:00
|
|
|
nsAutoCString features(aFeatures);
|
|
|
|
nsTArray<FrameScriptInfo> frameScripts;
|
2015-01-23 07:00:18 +03:00
|
|
|
nsCString urlToLoad;
|
2015-01-16 21:07:50 +03:00
|
|
|
|
|
|
|
if (aIframeMoz) {
|
|
|
|
newChild->SendBrowserFrameOpenWindow(this, url, name,
|
|
|
|
NS_ConvertUTF8toUTF16(features),
|
|
|
|
aWindowIsNew);
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
|
|
|
aOpener->GetDocument(getter_AddRefs(domDoc));
|
|
|
|
if (!domDoc) {
|
|
|
|
NS_ERROR("Could retrieve document from nsIBaseWindow");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
doc = do_QueryInterface(domDoc);
|
|
|
|
if (!doc) {
|
|
|
|
NS_ERROR("Document from nsIBaseWindow didn't QI to nsIDocument");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> baseURI = doc->GetDocBaseURI();
|
|
|
|
if (!baseURI) {
|
|
|
|
NS_ERROR("nsIDocument didn't return a base URI");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString baseURIString;
|
|
|
|
baseURI->GetSpec(baseURIString);
|
|
|
|
|
|
|
|
// We can assume that if content is requesting to open a window from a remote
|
|
|
|
// tab, then we want to enforce that the new window is also a remote tab.
|
|
|
|
features.AppendLiteral(",remote");
|
|
|
|
|
|
|
|
if (!SendCreateWindow(newChild,
|
|
|
|
aChromeFlags, aCalledFromJS, aPositionSpecified,
|
|
|
|
aSizeSpecified, url,
|
|
|
|
name, NS_ConvertUTF8toUTF16(features),
|
|
|
|
NS_ConvertUTF8toUTF16(baseURIString),
|
|
|
|
aWindowIsNew,
|
2015-01-23 07:00:18 +03:00
|
|
|
&frameScripts,
|
|
|
|
&urlToLoad)) {
|
2015-01-16 21:07:50 +03:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
}
|
2012-06-13 02:01:25 +04:00
|
|
|
if (!*aWindowIsNew) {
|
|
|
|
PBrowserChild::Send__delete__(newChild);
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
2014-11-16 21:23:22 +03:00
|
|
|
TextureFactoryIdentifier textureFactoryIdentifier;
|
|
|
|
uint64_t layersId = 0;
|
|
|
|
PRenderFrameChild* renderFrame = newChild->SendPRenderFrameConstructor();
|
|
|
|
newChild->SendGetRenderFrameInfo(renderFrame,
|
|
|
|
&textureFactoryIdentifier,
|
|
|
|
&layersId);
|
|
|
|
if (layersId == 0) { // if renderFrame is invalid.
|
|
|
|
PRenderFrameChild::Send__delete__(renderFrame);
|
|
|
|
renderFrame = nullptr;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
// Unfortunately we don't get a window unless we've shown the frame. That's
|
|
|
|
// pretty bogus; see bug 763602.
|
2015-02-26 16:47:01 +03:00
|
|
|
newChild->DoFakeShow(textureFactoryIdentifier, layersId, renderFrame);
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2015-01-16 21:07:50 +03:00
|
|
|
for (size_t i = 0; i < frameScripts.Length(); i++) {
|
|
|
|
FrameScriptInfo& info = frameScripts[i];
|
|
|
|
if (!newChild->RecvLoadRemoteScript(info.url(), info.runInGlobalScope())) {
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-23 07:00:18 +03:00
|
|
|
if (!urlToLoad.IsEmpty()) {
|
2015-02-11 14:53:00 +03:00
|
|
|
newChild->RecvLoadURL(urlToLoad, BrowserConfiguration());
|
2015-01-23 07:00:18 +03:00
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(newChild->WebNavigation());
|
2012-06-13 02:01:25 +04:00
|
|
|
win.forget(aReturn);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-25 19:40:23 +04:00
|
|
|
bool
|
|
|
|
TabChild::HasValidInnerSize()
|
|
|
|
{
|
|
|
|
return mHasValidInnerSize;
|
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:40 +04:00
|
|
|
void
|
|
|
|
TabChild::DestroyWindow()
|
2009-10-28 23:41:46 +03:00
|
|
|
{
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(WebNavigation());
|
2009-10-28 23:41:46 +03:00
|
|
|
if (baseWindow)
|
|
|
|
baseWindow->Destroy();
|
2009-07-07 20:26:49 +04:00
|
|
|
|
2010-08-21 03:24:41 +04: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-21 03:24:41 +04:00
|
|
|
mWidget->Destroy();
|
2010-03-01 22:05:48 +03:00
|
|
|
}
|
2009-07-07 20:26:49 +04:00
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
if (mRemoteFrame) {
|
|
|
|
mRemoteFrame->Destroy();
|
2012-07-30 18:20:58 +04:00
|
|
|
mRemoteFrame = nullptr;
|
2010-07-26 22:49:09 +04:00
|
|
|
}
|
2014-03-07 07:24:32 +04:00
|
|
|
|
|
|
|
|
|
|
|
if (mLayersId != 0) {
|
|
|
|
MOZ_ASSERT(sTabChildren);
|
|
|
|
sTabChildren->Remove(mLayersId);
|
|
|
|
if (!sTabChildren->Count()) {
|
|
|
|
delete sTabChildren;
|
|
|
|
sTabChildren = nullptr;
|
|
|
|
}
|
|
|
|
mLayersId = 0;
|
|
|
|
}
|
2014-05-07 23:03:48 +04:00
|
|
|
|
|
|
|
for (uint32_t index = 0, count = mCachedFileDescriptorInfos.Length();
|
|
|
|
index < count;
|
|
|
|
index++) {
|
|
|
|
nsAutoPtr<CachedFileDescriptorInfo>& info =
|
|
|
|
mCachedFileDescriptorInfos[index];
|
|
|
|
|
|
|
|
MOZ_ASSERT(!info->mCallback);
|
|
|
|
|
|
|
|
if (info->mFileDescriptor.IsValid()) {
|
2014-05-08 03:09:37 +04:00
|
|
|
MOZ_ASSERT(!info->mCanceled);
|
|
|
|
|
2014-05-07 23:03:48 +04:00
|
|
|
nsRefPtr<CloseFileRunnable> runnable =
|
|
|
|
new CloseFileRunnable(info->mFileDescriptor);
|
|
|
|
runnable->Dispatch();
|
|
|
|
}
|
|
|
|
}
|
2014-08-27 23:15:30 +04:00
|
|
|
|
|
|
|
mCachedFileDescriptorInfos.Clear();
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
2009-07-14 11:33:50 +04:00
|
|
|
|
2010-07-22 03:23:03 +04:00
|
|
|
void
|
|
|
|
TabChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
2015-01-07 08:42:00 +03:00
|
|
|
mIPCOpen = false;
|
|
|
|
|
2014-09-26 00:01:33 +04:00
|
|
|
DestroyWindow();
|
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
if (mTabChildGlobal) {
|
|
|
|
// The messageManager relays messages via the TabChild which
|
|
|
|
// no longer exists.
|
|
|
|
static_cast<nsFrameMessageManager*>
|
|
|
|
(mTabChildGlobal->mMessageManager.get())->Disconnect();
|
2012-07-30 18:20:58 +04:00
|
|
|
mTabChildGlobal->mMessageManager = nullptr;
|
2011-08-09 23:38:26 +04:00
|
|
|
}
|
2014-08-22 03:37:00 +04:00
|
|
|
|
2014-09-04 16:20:45 +04:00
|
|
|
CompositorChild* compositorChild = static_cast<CompositorChild*>(CompositorChild::Get());
|
|
|
|
compositorChild->CancelNotifyAfterRemotePaint(this);
|
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
if (GetTabId() != 0) {
|
|
|
|
NestedTabChildMap().erase(GetTabId());
|
2014-06-11 09:44:36 +04:00
|
|
|
}
|
2010-07-22 03:23:03 +04:00
|
|
|
}
|
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
TabChild::~TabChild()
|
|
|
|
{
|
2012-08-29 19:26:18 +04:00
|
|
|
DestroyWindow();
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIWebBrowser> webBrowser = do_QueryInterface(WebNavigation());
|
2009-11-05 21:14:22 +03:00
|
|
|
if (webBrowser) {
|
2012-07-30 18:20:58 +04:00
|
|
|
webBrowser->SetContainerWindow(nullptr);
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
|
2012-09-11 08:30:33 +04: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 22:32:37 +04:00
|
|
|
nsCOMPtr<mozIApplication> app = GetOwnApp();
|
2012-09-11 08:30:33 +04: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 22:32:37 +04:00
|
|
|
|
2012-09-11 08:30:33 +04: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 22:32:37 +04:00
|
|
|
nsresult rv = app->GetName(appName);
|
2012-09-11 08:30:33 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Failed to retrieve app name");
|
|
|
|
return;
|
|
|
|
}
|
2012-10-06 01:54:54 +04:00
|
|
|
|
2014-03-26 08:56:35 +04:00
|
|
|
ContentChild::GetSingleton()->SetProcessName(appName, true);
|
2012-09-11 08:30:33 +04:00
|
|
|
}
|
|
|
|
|
2012-09-05 20:23:45 +04: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 22:32:37 +04: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 20:23:45 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2015-02-11 14:53:00 +03:00
|
|
|
TabChild::RecvLoadURL(const nsCString& aURI,
|
|
|
|
const BrowserConfiguration& aConfiguration)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
2015-04-07 05:56:10 +03:00
|
|
|
if (!InitTabChildGlobal()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-11 08:30:33 +04:00
|
|
|
SetProcessNameToAppName();
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2015-04-24 01:44:24 +03:00
|
|
|
nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
|
|
|
MOZ_ASSERT(swm);
|
|
|
|
swm->LoadRegistrations(aConfiguration.serviceWorkerRegistrations());
|
|
|
|
|
2015-02-11 14:53:00 +03:00
|
|
|
nsresult rv = WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(aURI).get(),
|
2014-03-25 06:28:46 +04:00
|
|
|
nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
|
|
|
|
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_OWNER,
|
|
|
|
nullptr, nullptr, nullptr);
|
2009-10-28 23:41:46 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2014-03-25 06:28:46 +04:00
|
|
|
NS_WARNING("WebNavigation()->LoadURI failed. Eating exception, what else can I do?");
|
2009-10-28 23:41:46 +03:00
|
|
|
}
|
2009-11-06 23:43:39 +03:00
|
|
|
|
2013-01-07 18:42:32 +04:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2015-02-11 14:53:00 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("URL"), aURI);
|
2013-01-07 18:42:32 +04:00
|
|
|
#endif
|
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
return true;
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
|
2013-02-16 02:27:21 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvCacheFileDescriptor(const nsString& aPath,
|
|
|
|
const FileDescriptor& aFileDescriptor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(!aPath.IsEmpty());
|
2013-05-30 04:56:09 +04:00
|
|
|
MOZ_ASSERT(!mAppPackageFileDescriptorRecved);
|
|
|
|
|
|
|
|
mAppPackageFileDescriptorRecved = true;
|
2013-02-16 02:27:21 +04: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);
|
2014-05-09 05:03:35 +04:00
|
|
|
size_t index =
|
2013-02-16 02:27:21 +04:00
|
|
|
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);
|
2014-05-09 05:03:35 +04:00
|
|
|
size_t index =
|
2013-02-16 02:27:21 +04:00
|
|
|
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-30 04:56:09 +04:00
|
|
|
if (!mAppPackageFileDescriptorRecved) {
|
|
|
|
mCachedFileDescriptorInfos.AppendElement(
|
|
|
|
new CachedFileDescriptorInfo(aPath, aCallback));
|
|
|
|
}
|
2013-02-16 02:27:21 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoPtr<CachedFileDescriptorInfo>& info =
|
|
|
|
mCachedFileDescriptorInfos[index];
|
|
|
|
|
|
|
|
MOZ_ASSERT(info);
|
|
|
|
MOZ_ASSERT(info->mPath == aPath);
|
|
|
|
|
2013-04-27 01:43:45 +04: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-16 02:27:21 +04: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-30 04:56:09 +04:00
|
|
|
if (mAppPackageFileDescriptorRecved) {
|
|
|
|
// Already received cached file descriptor for the app package. Nothing to do here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-16 02:27:21 +04:00
|
|
|
const CachedFileDescriptorInfo search(aPath, aCallback);
|
2014-05-09 05:03:35 +04:00
|
|
|
size_t index =
|
2013-02-16 02:27:21 +04:00
|
|
|
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);
|
|
|
|
|
2014-05-08 03:09:37 +04:00
|
|
|
// No need to hold the callback any longer.
|
|
|
|
info->mCallback = nullptr;
|
|
|
|
|
2013-02-16 02:27:21 +04:00
|
|
|
// Set this flag so that we will close the file descriptor when it arrives.
|
|
|
|
info->mCanceled = true;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
void
|
2015-02-26 16:47:01 +03:00
|
|
|
TabChild::DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
2014-11-16 21:23:22 +03:00
|
|
|
const uint64_t& aLayersId,
|
|
|
|
PRenderFrameChild* aRenderFrame)
|
2012-06-13 02:01:25 +04:00
|
|
|
{
|
2014-12-12 20:50:46 +03:00
|
|
|
ShowInfo info(EmptyString(), false, false, 0, 0);
|
2015-03-05 12:13:05 +03:00
|
|
|
RecvShow(ScreenIntSize(0, 0), info, aTextureFactoryIdentifier,
|
2015-02-06 19:26:29 +03:00
|
|
|
aLayersId, aRenderFrame, mParentIsActive);
|
2012-06-13 02:01:25 +04:00
|
|
|
mDidFakeShow = true;
|
|
|
|
}
|
|
|
|
|
2014-11-24 22:05:35 +03:00
|
|
|
void
|
|
|
|
TabChild::ApplyShowInfo(const ShowInfo& aInfo)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
|
|
|
if (docShell) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> item = do_GetInterface(docShell);
|
2015-01-16 21:07:50 +03:00
|
|
|
if (IsBrowserOrApp()) {
|
|
|
|
// B2G allows window.name to be set by changing the name attribute on the
|
|
|
|
// <iframe mozbrowser> element. window.open calls cause this attribute to
|
|
|
|
// be set to the correct value. A normal <xul:browser> element has no such
|
|
|
|
// attribute. The data we get here comes from reading the attribute, so we
|
|
|
|
// shouldn't trust it for <xul:browser> elements.
|
|
|
|
item->SetName(aInfo.name());
|
|
|
|
}
|
2014-11-24 22:05:35 +03:00
|
|
|
docShell->SetFullscreenAllowed(aInfo.fullscreenAllowed());
|
|
|
|
if (aInfo.isPrivate()) {
|
|
|
|
bool nonBlank;
|
|
|
|
docShell->GetHasLoadedNonBlankURI(&nonBlank);
|
|
|
|
if (nonBlank) {
|
|
|
|
nsContentUtils::ReportToConsoleNonLocalized(
|
|
|
|
NS_LITERAL_STRING("We should not switch to Private Browsing after loading a document."),
|
|
|
|
nsIScriptError::warningFlag,
|
|
|
|
NS_LITERAL_CSTRING("mozprivatebrowsing"),
|
|
|
|
nullptr);
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsILoadContext> context = do_GetInterface(docShell);
|
|
|
|
context->SetUsePrivateBrowsing(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-12 20:50:46 +03:00
|
|
|
mDPI = aInfo.dpi();
|
|
|
|
mDefaultScale = aInfo.defaultScale();
|
2014-11-24 22:05:35 +03:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:54:02 +03:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
void
|
|
|
|
TabChild::MaybeRequestPreinitCamera()
|
|
|
|
{
|
|
|
|
// Check if this tab will use the `camera` permission.
|
|
|
|
nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
|
|
|
|
if (NS_WARN_IF(!appsService)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString manifestUrl = EmptyString();
|
|
|
|
appsService->GetManifestURLByLocalId(OwnAppId(), manifestUrl);
|
|
|
|
nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
|
|
|
|
if (NS_WARN_IF(!secMan)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsresult rv = NS_NewURI(getter_AddRefs(uri), manifestUrl);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
rv = secMan->GetAppCodebasePrincipal(uri, OwnAppId(), false,
|
|
|
|
getter_AddRefs(principal));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t status = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
|
|
|
|
principal->GetAppStatus(&status);
|
|
|
|
bool isCertified = status == nsIPrincipal::APP_STATUS_CERTIFIED;
|
|
|
|
if (!isCertified) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
|
|
|
|
if (NS_WARN_IF(!permMgr)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
|
|
|
permMgr->TestPermissionFromPrincipal(principal, "camera", &permission);
|
|
|
|
bool hasPermission = permission == nsIPermissionManager::ALLOW_ACTION;
|
|
|
|
if (!hasPermission) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
|
|
|
|
if (NS_WARN_IF(!observerService)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
observerService->NotifyObservers(nullptr, "init-camera-hw", nullptr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2015-03-05 12:13:05 +03:00
|
|
|
TabChild::RecvShow(const ScreenIntSize& aSize,
|
2014-11-24 22:05:35 +03:00
|
|
|
const ShowInfo& aInfo,
|
2014-11-16 21:23:22 +03:00
|
|
|
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
|
|
|
const uint64_t& aLayersId,
|
2015-02-06 19:26:29 +03:00
|
|
|
PRenderFrameChild* aRenderFrame,
|
|
|
|
const bool& aParentIsActive)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
2014-11-16 21:23:22 +03:00
|
|
|
MOZ_ASSERT((!mDidFakeShow && aRenderFrame) || (mDidFakeShow && !aRenderFrame));
|
2012-08-29 19:26:18 +04:00
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
if (mDidFakeShow) {
|
2014-11-24 22:05:35 +03:00
|
|
|
ApplyShowInfo(aInfo);
|
2015-02-06 19:26:29 +03:00
|
|
|
RecvParentActivated(aParentIsActive);
|
2012-06-13 02:01:25 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(WebNavigation());
|
2010-08-21 03:24:40 +04:00
|
|
|
if (!baseWindow) {
|
2014-03-25 06:28:46 +04:00
|
|
|
NS_ERROR("WebNavigation() doesn't QI to nsIBaseWindow");
|
2010-08-21 03:24:40 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-26 16:47:01 +03:00
|
|
|
if (!InitRenderingState(aTextureFactoryIdentifier, aLayersId, aRenderFrame)) {
|
2011-08-09 23:38:26 +04: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-21 03:24:40 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
baseWindow->SetVisibility(true);
|
2010-08-21 03:24:40 +04:00
|
|
|
|
2014-10-31 20:54:02 +03:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
MaybeRequestPreinitCamera();
|
|
|
|
#endif
|
|
|
|
|
2014-11-24 22:05:35 +03:00
|
|
|
bool res = InitTabChildGlobal();
|
|
|
|
ApplyShowInfo(aInfo);
|
2015-02-06 19:26:29 +03:00
|
|
|
RecvParentActivated(aParentIsActive);
|
2014-11-24 22:05:35 +03:00
|
|
|
return res;
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2015-03-05 12:13:05 +03:00
|
|
|
TabChild::RecvUpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size,
|
2015-04-21 17:33:56 +03:00
|
|
|
const ScreenOrientation& orientation, const LayoutDeviceIntPoint& chromeDisp)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
2011-08-09 23:38:26 +04:00
|
|
|
if (!mRemoteFrame) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-08 21:23:50 +04:00
|
|
|
mOuterRect = rect;
|
2014-12-11 17:44:07 +03:00
|
|
|
mChromeDisp = chromeDisp;
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2014-02-22 03:12:43 +04:00
|
|
|
bool initialSizing = !HasValidInnerSize()
|
|
|
|
&& (size.width != 0 && size.height != 0);
|
2014-04-25 19:40:23 +04:00
|
|
|
if (initialSizing) {
|
|
|
|
mHasValidInnerSize = true;
|
|
|
|
}
|
2014-02-22 03:12:43 +04:00
|
|
|
|
2012-11-22 06:40:57 +04:00
|
|
|
mOrientation = orientation;
|
2014-08-06 20:41:05 +04:00
|
|
|
ScreenIntSize oldScreenSize = mInnerSize;
|
2015-03-05 12:13:05 +03:00
|
|
|
mInnerSize = size;
|
2015-03-31 23:39:02 +03:00
|
|
|
mWidget->Resize(rect.x + chromeDisp.x, rect.y + chromeDisp.y, size.width, size.height,
|
|
|
|
true);
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
2010-08-21 03:24:40 +04:00
|
|
|
baseWin->SetPositionAndSize(0, 0, size.width, size.height,
|
2011-10-17 18:59:28 +04:00
|
|
|
true);
|
2011-07-16 01:46:56 +04:00
|
|
|
|
2014-02-22 03:12:43 +04:00
|
|
|
if (initialSizing && mContentDocumentIsDisplayed) {
|
|
|
|
// If this is the first time we're getting a valid mInnerSize, and the
|
|
|
|
// before-first-paint event has already been handled, then we need to set
|
|
|
|
// up our default viewport here. See the corresponding call to
|
|
|
|
// InitializeRootMetrics in the before-first-paint handler.
|
|
|
|
InitializeRootMetrics();
|
|
|
|
}
|
|
|
|
|
2014-08-06 20:41:05 +04:00
|
|
|
HandlePossibleViewportChange(oldScreenSize);
|
2012-09-29 06:18:18 +04:00
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
2009-10-29 20:58:31 +03:00
|
|
|
|
2012-08-09 08:39:02 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
|
|
|
|
{
|
2014-03-25 06:28:46 +04:00
|
|
|
return TabChildBase::UpdateFrameHandler(aFrameMetrics);
|
2013-05-24 05:43:36 +04:00
|
|
|
}
|
|
|
|
|
2015-02-20 02:53:30 +03:00
|
|
|
bool
|
|
|
|
TabChild::RecvRequestFlingSnap(const FrameMetrics::ViewID& aScrollId,
|
|
|
|
const mozilla::CSSPoint& aDestination)
|
|
|
|
{
|
|
|
|
APZCCallbackHelper::RequestFlingSnap(aScrollId, aDestination);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-06 02:43:20 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvAcknowledgeScrollUpdate(const ViewID& aScrollId,
|
|
|
|
const uint32_t& aScrollGeneration)
|
|
|
|
{
|
|
|
|
APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-09 08:39:02 +04:00
|
|
|
bool
|
2015-03-03 00:41:02 +03:00
|
|
|
TabChild::RecvHandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid)
|
2012-08-09 08:39:02 +04:00
|
|
|
{
|
2014-09-12 01:25:27 +04:00
|
|
|
TABC_LOG("Handling double tap at %s with %p %p\n",
|
|
|
|
Stringify(aPoint).c_str(), mGlobal.get(), mTabChildGlobal.get());
|
|
|
|
|
2013-06-30 19:00:19 +04:00
|
|
|
if (!mGlobal || !mTabChildGlobal) {
|
2012-08-09 08:39:02 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-03 00:41:02 +03:00
|
|
|
// Note: there is nothing to do with the modifiers here, as we are not
|
|
|
|
// synthesizing any sort of mouse event.
|
2015-01-16 21:48:33 +03:00
|
|
|
CSSPoint point = APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid,
|
|
|
|
GetPresShellResolution());
|
2014-03-25 06:28:46 +04:00
|
|
|
nsString data;
|
|
|
|
data.AppendLiteral("{ \"x\" : ");
|
|
|
|
data.AppendFloat(point.x);
|
|
|
|
data.AppendLiteral(", \"y\" : ");
|
|
|
|
data.AppendFloat(point.y);
|
|
|
|
data.AppendLiteral(" }");
|
2012-08-09 08:39:02 +04:00
|
|
|
|
|
|
|
DispatchMessageManagerMessage(NS_LITERAL_STRING("Gesture:DoubleTap"), data);
|
|
|
|
|
2012-08-02 10:02:29 +04:00
|
|
|
return true;
|
2012-07-20 10:48:27 +04:00
|
|
|
}
|
|
|
|
|
2012-09-15 05:16:32 +04:00
|
|
|
bool
|
2015-03-03 00:41:02 +03:00
|
|
|
TabChild::RecvHandleSingleTap(const CSSPoint& aPoint, const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid)
|
2012-09-15 05:16:32 +04:00
|
|
|
{
|
2015-02-09 22:05:18 +03:00
|
|
|
if (mGlobal && mTabChildGlobal) {
|
2015-03-03 00:41:02 +03:00
|
|
|
mAPZEventState->ProcessSingleTap(aPoint, aModifiers, aGuid, GetPresShellResolution());
|
2014-08-24 11:16:32 +04:00
|
|
|
}
|
2012-09-15 05:16:32 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-11-08 23:35:02 +04:00
|
|
|
bool
|
2015-03-03 00:41:02 +03:00
|
|
|
TabChild::RecvHandleLongTap(const CSSPoint& aPoint, const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId)
|
2012-11-08 23:35:02 +04:00
|
|
|
{
|
2015-02-09 22:05:18 +03:00
|
|
|
if (mGlobal && mTabChildGlobal) {
|
2015-04-15 10:09:46 +03:00
|
|
|
mAPZEventState->ProcessLongTap(GetPresShell(), aPoint, aModifiers, aGuid,
|
2015-02-09 22:05:18 +03:00
|
|
|
aInputBlockId, GetPresShellResolution());
|
2012-11-08 23:35:02 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-10 07:14:55 +04:00
|
|
|
bool
|
2014-04-15 21:39:20 +04:00
|
|
|
TabChild::RecvNotifyAPZStateChange(const ViewID& aViewId,
|
|
|
|
const APZStateChange& aChange,
|
|
|
|
const int& aArg)
|
|
|
|
{
|
2015-02-09 22:05:18 +03:00
|
|
|
mAPZEventState->ProcessAPZStateChange(GetDocument(), aViewId, aChange, aArg);
|
2013-12-10 07:14:55 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
TabChild::RecvActivate()
|
2009-11-05 21:14:22 +03:00
|
|
|
{
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIWebBrowserFocus> browser = do_QueryInterface(WebNavigation());
|
2009-11-05 21:14:22 +03:00
|
|
|
browser->Activate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-18 04:08:32 +04:00
|
|
|
bool TabChild::RecvDeactivate()
|
|
|
|
{
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIWebBrowserFocus> browser = do_QueryInterface(WebNavigation());
|
2011-06-18 04:08:32 +04:00
|
|
|
browser->Deactivate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-27 16:28:26 +03:00
|
|
|
bool TabChild::RecvParentActivated(const bool& aActivated)
|
|
|
|
{
|
2015-02-06 19:26:29 +03:00
|
|
|
mParentIsActive = aActivated;
|
|
|
|
|
2014-11-27 16:28:26 +03:00
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
|
|
NS_ENSURE_TRUE(fm, true);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(WebNavigation());
|
|
|
|
fm->ParentActivated(window, aActivated);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-11-05 21:21:09 +03:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
TabChild::RecvMouseEvent(const nsString& aType,
|
|
|
|
const float& aX,
|
|
|
|
const float& aY,
|
2012-08-22 19:56:38 +04:00
|
|
|
const int32_t& aButton,
|
|
|
|
const int32_t& aClickCount,
|
|
|
|
const int32_t& aModifiers,
|
2010-07-19 22:33:33 +04:00
|
|
|
const bool& aIgnoreRootScrollFrame)
|
2009-11-05 21:21:09 +03:00
|
|
|
{
|
2015-04-15 10:09:46 +03:00
|
|
|
APZCCallbackHelper::DispatchMouseEvent(GetPresShell(), aType, CSSPoint(aX, aY),
|
2015-02-09 22:05:18 +03:00
|
|
|
aButton, aClickCount, aModifiers, aIgnoreRootScrollFrame, nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN);
|
2009-11-05 21:21:09 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-22 04:32:43 +04:00
|
|
|
bool
|
2015-02-14 02:34:04 +03:00
|
|
|
TabChild::RecvRealMouseMoveEvent(const WidgetMouseEvent& event)
|
|
|
|
{
|
|
|
|
return RecvRealMouseButtonEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::RecvRealMouseButtonEvent(const WidgetMouseEvent& event)
|
2011-06-22 04:32:43 +04:00
|
|
|
{
|
2013-10-02 10:38:27 +04:00
|
|
|
WidgetMouseEvent localEvent(event);
|
2014-03-25 06:28:46 +04:00
|
|
|
localEvent.widget = mWidget;
|
2015-01-22 03:46:27 +03:00
|
|
|
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
2011-06-22 04:32:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-12-09 13:40:26 +03:00
|
|
|
TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& aEvent,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId)
|
|
|
|
{
|
2015-02-26 16:47:01 +03:00
|
|
|
if (gfxPrefs::AsyncPanZoomEnabled()) {
|
2014-12-09 13:40:26 +03:00
|
|
|
nsCOMPtr<nsIDocument> document(GetDocument());
|
2015-02-07 02:11:19 +03:00
|
|
|
APZCCallbackHelper::SendSetTargetAPZCNotification(WebWidget(), document, aEvent, aGuid,
|
2015-04-14 19:24:32 +03:00
|
|
|
aInputBlockId);
|
2014-12-09 13:40:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WidgetWheelEvent event(aEvent);
|
|
|
|
event.widget = mWidget;
|
2015-01-22 03:46:27 +03:00
|
|
|
APZCCallbackHelper::DispatchWidgetEvent(event);
|
2014-12-09 13:40:26 +03:00
|
|
|
|
2015-02-26 16:47:01 +03:00
|
|
|
if (gfxPrefs::AsyncPanZoomEnabled()) {
|
2015-02-09 22:05:18 +03:00
|
|
|
mAPZEventState->ProcessWheelEvent(event, aGuid, aInputBlockId);
|
2014-12-09 13:40:26 +03:00
|
|
|
}
|
2011-06-22 04:32:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-22 10:42:26 +03:00
|
|
|
bool
|
|
|
|
TabChild::RecvMouseScrollTestEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent)
|
|
|
|
{
|
|
|
|
APZCCallbackHelper::NotifyMozMouseScrollEvent(aScrollId, aEvent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-05 12:49:00 +04:00
|
|
|
static Touch*
|
2013-09-27 10:20:57 +04:00
|
|
|
GetTouchForIdentifier(const WidgetTouchEvent& aEvent, int32_t aId)
|
2013-01-05 18:53:16 +04:00
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < aEvent.touches.Length(); ++i) {
|
2013-04-05 12:49:00 +04:00
|
|
|
Touch* touch = static_cast<Touch*>(aEvent.touches[i].get());
|
2013-01-05 18:53:16 +04:00
|
|
|
if (touch->mIdentifier == aId) {
|
|
|
|
return touch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-27 10:20:57 +04:00
|
|
|
TabChild::UpdateTapState(const WidgetTouchEvent& aEvent, nsEventStatus aStatus)
|
2013-01-05 18:53:16 +04:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-01-14 18:29:15 +04:00
|
|
|
if (aEvent.touches.Length() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-05 18:53:16 +04:00
|
|
|
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 ||
|
2015-02-25 06:20:00 +03:00
|
|
|
TouchManager::gPreventMouseEvents ||
|
2013-12-19 04:12:47 +04:00
|
|
|
aEvent.mFlags.mMultipleActionsPrevented) {
|
2013-01-05 18:53:16 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-06 21:25:56 +04:00
|
|
|
Touch* touch = aEvent.touches[0];
|
2013-07-16 23:54:59 +04:00
|
|
|
mGestureDownPoint = LayoutDevicePoint(touch->mRefPoint.x, touch->mRefPoint.y);
|
2013-01-05 18:53:16 +04:00
|
|
|
mActivePointerId = touch->mIdentifier;
|
|
|
|
if (sClickHoldContextMenusEnabled) {
|
|
|
|
MOZ_ASSERT(!mTapHoldTimer);
|
2014-08-24 11:16:32 +04:00
|
|
|
mTapHoldTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
|
|
|
nsRefPtr<DelayedFireContextMenuEvent> callback =
|
|
|
|
new DelayedFireContextMenuEvent(this);
|
|
|
|
mTapHoldTimer->InitWithCallback(callback,
|
|
|
|
sContextMenuDelayMs,
|
|
|
|
nsITimer::TYPE_ONE_SHOT);
|
2013-01-05 18:53:16 +04:00
|
|
|
}
|
|
|
|
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 12:49:00 +04:00
|
|
|
Touch* trackedTouch = GetTouchForIdentifier(aEvent, mActivePointerId);
|
2013-01-05 18:53:16 +04:00
|
|
|
if (!trackedTouch) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-16 23:54:59 +04:00
|
|
|
LayoutDevicePoint currentPoint = LayoutDevicePoint(trackedTouch->mRefPoint.x, trackedTouch->mRefPoint.y);
|
2013-01-05 18:53:16 +04:00
|
|
|
int64_t time = aEvent.time;
|
|
|
|
switch (aEvent.message) {
|
|
|
|
case NS_TOUCH_MOVE:
|
2014-09-28 20:59:46 +04:00
|
|
|
if (std::abs(currentPoint.x - mGestureDownPoint.x) > sDragThreshold.width ||
|
|
|
|
std::abs(currentPoint.y - mGestureDownPoint.y) > sDragThreshold.height) {
|
2013-01-05 18:53:16 +04:00
|
|
|
CancelTapTracking();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case NS_TOUCH_END:
|
2015-03-03 01:03:07 +03:00
|
|
|
if (!TouchManager::gPreventMouseEvents) {
|
2015-03-03 00:41:02 +03:00
|
|
|
APZCCallbackHelper::DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, currentPoint, 0, mWidget);
|
|
|
|
APZCCallbackHelper::DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, currentPoint, 0, mWidget);
|
|
|
|
APZCCallbackHelper::DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_UP, time, currentPoint, 0, mWidget);
|
2013-01-05 18:53:16 +04:00
|
|
|
}
|
|
|
|
// fall through
|
|
|
|
case NS_TOUCH_CANCEL:
|
|
|
|
CancelTapTracking();
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_WARNING("Unknown touch event type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::FireContextMenuEvent()
|
|
|
|
{
|
2014-08-24 11:16:32 +04:00
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-16 23:54:59 +04:00
|
|
|
double scale;
|
|
|
|
GetDefaultScale(&scale);
|
|
|
|
if (scale < 0) {
|
|
|
|
scale = 1;
|
|
|
|
}
|
|
|
|
|
2013-01-05 18:53:16 +04:00
|
|
|
MOZ_ASSERT(mTapHoldTimer && mActivePointerId >= 0);
|
2015-02-09 22:05:18 +03:00
|
|
|
bool defaultPrevented = APZCCallbackHelper::DispatchMouseEvent(
|
2015-04-15 10:09:46 +03:00
|
|
|
GetPresShell(),
|
2015-02-09 22:05:18 +03:00
|
|
|
NS_LITERAL_STRING("contextmenu"),
|
|
|
|
mGestureDownPoint / CSSToLayoutDeviceScale(scale),
|
|
|
|
2 /* Right button */,
|
|
|
|
1 /* Click count */,
|
|
|
|
0 /* Modifiers */,
|
|
|
|
true /* Ignore root scroll frame */,
|
|
|
|
nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);
|
2013-05-23 19:52:06 +04:00
|
|
|
|
|
|
|
// 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 18:53:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::CancelTapTracking()
|
|
|
|
{
|
|
|
|
mActivePointerId = -1;
|
|
|
|
if (mTapHoldTimer) {
|
|
|
|
mTapHoldTimer->Cancel();
|
|
|
|
}
|
|
|
|
mTapHoldTimer = nullptr;
|
|
|
|
}
|
|
|
|
|
2015-01-16 21:48:33 +03:00
|
|
|
float
|
|
|
|
TabChild::GetPresShellResolution() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocument> document(GetDocument());
|
|
|
|
nsIPresShell* shell = document->GetShell();
|
|
|
|
if (!shell) {
|
|
|
|
return 1.0f;
|
|
|
|
}
|
2015-03-07 02:07:59 +03:00
|
|
|
return shell->GetResolution();
|
2015-01-16 21:48:33 +03:00
|
|
|
}
|
|
|
|
|
2012-09-15 05:16:32 +04:00
|
|
|
bool
|
2013-11-13 22:20:31 +04:00
|
|
|
TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
|
2014-10-24 21:29:30 +04:00
|
|
|
const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId)
|
2012-09-15 05:16:32 +04:00
|
|
|
{
|
2014-09-12 01:25:27 +04:00
|
|
|
TABC_LOG("Receiving touch event of type %d\n", aEvent.message);
|
|
|
|
|
2015-02-06 02:02:27 +03:00
|
|
|
WidgetTouchEvent localEvent(aEvent);
|
|
|
|
localEvent.widget = mWidget;
|
|
|
|
|
|
|
|
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
|
|
|
|
mWidget->GetDefaultScale(), GetPresShellResolution());
|
2014-03-12 23:27:45 +04:00
|
|
|
|
2015-02-26 16:47:01 +03:00
|
|
|
if (localEvent.message == NS_TOUCH_START && gfxPrefs::AsyncPanZoomEnabled()) {
|
2015-03-19 13:33:33 +03:00
|
|
|
if (gfxPrefs::TouchActionEnabled()) {
|
|
|
|
APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(WebWidget(),
|
|
|
|
localEvent, aInputBlockId, mSetAllowedTouchBehaviorCallback);
|
|
|
|
}
|
2015-02-07 02:11:19 +03:00
|
|
|
nsCOMPtr<nsIDocument> document = GetDocument();
|
|
|
|
APZCCallbackHelper::SendSetTargetAPZCNotification(WebWidget(), document,
|
2015-04-14 19:24:32 +03:00
|
|
|
localEvent, aGuid, aInputBlockId);
|
2014-11-22 05:36:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dispatch event to content (potentially a long-running operation)
|
2015-01-22 03:46:27 +03:00
|
|
|
nsEventStatus status = APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
2012-09-15 05:16:32 +04:00
|
|
|
|
2015-02-26 16:47:01 +03:00
|
|
|
if (!gfxPrefs::AsyncPanZoomEnabled()) {
|
2013-12-20 13:11:01 +04:00
|
|
|
UpdateTapState(localEvent, status);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:20:20 +03:00
|
|
|
mAPZEventState->ProcessTouchEvent(localEvent, aGuid, aInputBlockId,
|
|
|
|
nsEventStatus_eIgnore);
|
2012-09-15 05:16:32 +04:00
|
|
|
return true;
|
2012-07-16 06:58:43 +04:00
|
|
|
}
|
2011-06-22 04:32:43 +04:00
|
|
|
|
2012-08-22 14:54:20 +04:00
|
|
|
bool
|
2013-11-13 22:20:31 +04:00
|
|
|
TabChild::RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent,
|
2014-10-24 21:29:30 +04:00
|
|
|
const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId)
|
2012-08-22 14:54:20 +04:00
|
|
|
{
|
2014-10-24 21:29:30 +04:00
|
|
|
return RecvRealTouchEvent(aEvent, aGuid, aInputBlockId);
|
2012-08-22 14:54:20 +04:00
|
|
|
}
|
|
|
|
|
2015-04-08 21:48:11 +03:00
|
|
|
bool
|
|
|
|
TabChild::RecvRealDragEvent(const WidgetDragEvent& aEvent,
|
|
|
|
const uint32_t& aDragAction,
|
|
|
|
const uint32_t& aDropEffect)
|
|
|
|
{
|
|
|
|
WidgetDragEvent localEvent(aEvent);
|
|
|
|
localEvent.widget = mWidget;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
|
|
|
|
if (dragSession) {
|
|
|
|
dragSession->SetDragAction(aDragAction);
|
|
|
|
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
|
|
|
|
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
|
|
|
|
if (initialDataTransfer) {
|
|
|
|
initialDataTransfer->SetDropEffectInt(aDropEffect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aEvent.message == NS_DRAGDROP_DROP) {
|
|
|
|
bool canDrop = true;
|
|
|
|
if (!dragSession || NS_FAILED(dragSession->GetCanDrop(&canDrop)) ||
|
|
|
|
!canDrop) {
|
|
|
|
localEvent.message = NS_DRAGDROP_EXIT;
|
|
|
|
}
|
|
|
|
} else if (aEvent.message == NS_DRAGDROP_OVER) {
|
|
|
|
nsCOMPtr<nsIDragService> dragService =
|
|
|
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
|
|
|
if (dragService) {
|
|
|
|
// This will dispatch 'drag' event at the source if the
|
|
|
|
// drag transaction started in this process.
|
|
|
|
dragService->FireDragEventAtSource(NS_DRAGDROP_DRAG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-22 00:40:09 +04:00
|
|
|
void
|
|
|
|
TabChild::RequestNativeKeyBindings(AutoCacheNativeKeyCommands* aAutoCache,
|
|
|
|
WidgetKeyboardEvent* aEvent)
|
|
|
|
{
|
|
|
|
MaybeNativeKeyBinding maybeBindings;
|
|
|
|
if (!SendRequestNativeKeyBindings(*aEvent, &maybeBindings)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maybeBindings.type() == MaybeNativeKeyBinding::TNativeKeyBinding) {
|
|
|
|
const NativeKeyBinding& bindings = maybeBindings;
|
|
|
|
aAutoCache->Cache(bindings.singleLineCommands(),
|
|
|
|
bindings.multiLineCommands(),
|
|
|
|
bindings.richTextCommands());
|
|
|
|
} else {
|
|
|
|
aAutoCache->CacheNoCommands();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-14 18:36:36 +03:00
|
|
|
bool
|
|
|
|
TabChild::RecvNativeSynthesisResponse(const uint64_t& aObserverId,
|
|
|
|
const nsCString& aResponse)
|
|
|
|
{
|
|
|
|
mozilla::widget::AutoObserverNotifier::NotifySavedObserver(aObserverId, aResponse.get());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-22 04:32:43 +04:00
|
|
|
bool
|
2014-03-20 19:46:29 +04:00
|
|
|
TabChild::RecvRealKeyEvent(const WidgetKeyboardEvent& event,
|
|
|
|
const MaybeNativeKeyBinding& aBindings)
|
2014-04-22 00:40:09 +04:00
|
|
|
{
|
|
|
|
PuppetWidget* widget = static_cast<PuppetWidget*>(mWidget.get());
|
|
|
|
AutoCacheNativeKeyCommands autoCache(widget);
|
|
|
|
|
2014-03-20 19:46:29 +04:00
|
|
|
if (event.message == NS_KEY_PRESS) {
|
2015-04-14 09:01:05 +03:00
|
|
|
// If content code called preventDefault() on a keydown event, then we don't
|
|
|
|
// want to process any following keypress events.
|
|
|
|
if (mIgnoreKeyPressEvent) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-20 19:46:29 +04:00
|
|
|
if (aBindings.type() == MaybeNativeKeyBinding::TNativeKeyBinding) {
|
|
|
|
const NativeKeyBinding& bindings = aBindings;
|
2014-04-22 00:40:09 +04:00
|
|
|
autoCache.Cache(bindings.singleLineCommands(),
|
|
|
|
bindings.multiLineCommands(),
|
|
|
|
bindings.richTextCommands());
|
2014-03-20 19:46:29 +04:00
|
|
|
} else {
|
2014-04-22 00:40:09 +04:00
|
|
|
autoCache.CacheNoCommands();
|
2014-03-20 19:46:29 +04:00
|
|
|
}
|
|
|
|
}
|
2014-03-12 07:13:38 +04:00
|
|
|
|
2013-10-01 11:22:58 +04:00
|
|
|
WidgetKeyboardEvent localEvent(event);
|
2014-03-25 06:28:46 +04:00
|
|
|
localEvent.widget = mWidget;
|
2015-01-22 03:46:27 +03:00
|
|
|
nsEventStatus status = APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
2014-03-12 07:13:38 +04:00
|
|
|
|
|
|
|
if (event.message == NS_KEY_DOWN) {
|
|
|
|
mIgnoreKeyPressEvent = status == nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
|
|
|
|
2014-03-18 19:16:47 +04:00
|
|
|
if (localEvent.mFlags.mWantReplyFromContentProcess) {
|
|
|
|
SendReplyKeyEvent(localEvent);
|
|
|
|
}
|
|
|
|
|
2014-11-03 10:05:38 +03:00
|
|
|
if (PresShell::BeforeAfterKeyboardEventEnabled()) {
|
|
|
|
SendDispatchAfterKeyboardEvent(localEvent);
|
|
|
|
}
|
|
|
|
|
2011-06-22 04:32:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-03-19 09:52:18 +03:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
TabChild::RecvKeyEvent(const nsString& aType,
|
2012-08-22 19:56:38 +04:00
|
|
|
const int32_t& aKeyCode,
|
|
|
|
const int32_t& aCharCode,
|
|
|
|
const int32_t& aModifiers,
|
2010-07-19 22:33:33 +04:00
|
|
|
const bool& aPreventDefault)
|
2010-03-19 09:52:18 +03:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ignored = false;
|
2015-04-15 10:09:46 +03:00
|
|
|
nsContentUtils::SendKeyEvent(mWidget, aType, aKeyCode, aCharCode,
|
|
|
|
aModifiers, aPreventDefault, &ignored);
|
2010-03-19 09:52:18 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-17 12:07:42 +04:00
|
|
|
bool
|
2013-10-01 11:23:00 +04:00
|
|
|
TabChild::RecvCompositionEvent(const WidgetCompositionEvent& event)
|
2010-08-17 12:07:42 +04:00
|
|
|
{
|
2014-10-07 14:01:48 +04:00
|
|
|
WidgetCompositionEvent localEvent(event);
|
2014-03-25 06:28:46 +04:00
|
|
|
localEvent.widget = mWidget;
|
2015-01-22 03:46:27 +03:00
|
|
|
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
2010-08-17 12:07:42 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-10-01 11:23:01 +04:00
|
|
|
TabChild::RecvSelectionEvent(const WidgetSelectionEvent& event)
|
2010-08-17 12:07:42 +04:00
|
|
|
{
|
2013-10-01 11:23:01 +04:00
|
|
|
WidgetSelectionEvent localEvent(event);
|
2014-03-25 06:28:46 +04:00
|
|
|
localEvent.widget = mWidget;
|
2015-01-22 03:46:27 +03:00
|
|
|
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
2010-08-17 12:07:42 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-27 02:20:53 +04:00
|
|
|
PDocumentRendererChild*
|
2013-07-08 19:48:39 +04:00
|
|
|
TabChild::AllocPDocumentRendererChild(const nsRect& documentRect,
|
2013-12-26 22:06:53 +04:00
|
|
|
const mozilla::gfx::Matrix& transform,
|
2013-07-08 19:48:39 +04:00
|
|
|
const nsString& bgcolor,
|
|
|
|
const uint32_t& renderFlags,
|
|
|
|
const bool& flushLayout,
|
|
|
|
const nsIntSize& renderSize)
|
2009-10-29 20:58:31 +03:00
|
|
|
{
|
2010-10-27 02:20:53 +04:00
|
|
|
return new DocumentRendererChild();
|
2009-10-29 20:58:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
TabChild::DeallocPDocumentRendererChild(PDocumentRendererChild* actor)
|
2009-10-29 20:58:31 +03:00
|
|
|
{
|
2009-12-03 11:16:14 +03:00
|
|
|
delete actor;
|
2009-10-29 20:58:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-10-27 02:20:53 +04:00
|
|
|
TabChild::RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
|
|
|
|
const nsRect& documentRect,
|
2013-12-26 22:06:53 +04:00
|
|
|
const mozilla::gfx::Matrix& transform,
|
2010-10-27 02:20:53 +04:00
|
|
|
const nsString& bgcolor,
|
2012-08-22 19:56:38 +04:00
|
|
|
const uint32_t& renderFlags,
|
2010-10-27 02:20:53 +04:00
|
|
|
const bool& flushLayout,
|
|
|
|
const nsIntSize& renderSize)
|
2010-10-27 02:20:53 +04:00
|
|
|
{
|
|
|
|
DocumentRendererChild *render = static_cast<DocumentRendererChild *>(actor);
|
2009-10-29 20:58:31 +03:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIWebBrowser> browser = do_QueryInterface(WebNavigation());
|
2009-10-29 20:58:31 +03:00
|
|
|
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-27 02:20:53 +04:00
|
|
|
bool ret = render->RenderDocument(window,
|
2010-10-27 02:20:53 +04:00
|
|
|
documentRect, transform,
|
|
|
|
bgcolor,
|
2010-10-27 02:20:53 +04:00
|
|
|
renderFlags, flushLayout,
|
2010-10-27 02:20:53 +04:00
|
|
|
renderSize, data);
|
2009-10-29 20:58:31 +03:00
|
|
|
if (!ret)
|
|
|
|
return true; // silently ignore
|
|
|
|
|
2010-10-27 02:20:53 +04:00
|
|
|
return PDocumentRendererChild::Send__delete__(actor, renderSize, data);
|
2009-10-29 20:58:31 +03:00
|
|
|
}
|
2009-11-17 17:22:23 +03:00
|
|
|
|
2014-02-24 00:19:43 +04:00
|
|
|
PColorPickerChild*
|
|
|
|
TabChild::AllocPColorPickerChild(const nsString&, const nsString&)
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("unused");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::DeallocPColorPickerChild(PColorPickerChild* aColorPicker)
|
|
|
|
{
|
|
|
|
nsColorPickerProxy* picker = static_cast<nsColorPickerProxy*>(aColorPicker);
|
|
|
|
NS_RELEASE(picker);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-18 04:30:06 +04:00
|
|
|
PFilePickerChild*
|
|
|
|
TabChild::AllocPFilePickerChild(const nsString&, const int16_t&)
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("unused");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::DeallocPFilePickerChild(PFilePickerChild* actor)
|
|
|
|
{
|
|
|
|
nsFilePickerProxy* filePicker = static_cast<nsFilePickerProxy*>(actor);
|
|
|
|
NS_RELEASE(filePicker);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
auto
|
|
|
|
TabChild::AllocPIndexedDBPermissionRequestChild(const Principal& aPrincipal)
|
|
|
|
-> PIndexedDBPermissionRequestChild*
|
|
|
|
{
|
|
|
|
MOZ_CRASH("PIndexedDBPermissionRequestChild actors should always be created "
|
|
|
|
"manually!");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::DeallocPIndexedDBPermissionRequestChild(
|
|
|
|
PIndexedDBPermissionRequestChild* aActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-11-17 17:22:23 +03:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
TabChild::RecvActivateFrameEvent(const nsString& aType, const bool& capture)
|
2009-11-17 17:22:23 +03:00
|
|
|
{
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(WebNavigation());
|
2009-11-17 17:22:23 +03:00
|
|
|
NS_ENSURE_TRUE(window, true);
|
2013-04-20 02:18:32 +04:00
|
|
|
nsCOMPtr<EventTarget> chromeHandler =
|
2009-11-17 17:22:23 +03: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 20:05:20 +03:00
|
|
|
|
|
|
|
bool
|
2013-11-24 09:32:45 +04:00
|
|
|
TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalScope)
|
2010-02-20 20:05:20 +03:00
|
|
|
{
|
2013-06-30 19:00:19 +04:00
|
|
|
if (!mGlobal && !InitTabChildGlobal())
|
2011-08-09 23:38:26 +04:00
|
|
|
// This can happen if we're half-destroyed. It's not a fatal
|
|
|
|
// error.
|
|
|
|
return true;
|
2010-08-24 21:01:28 +04:00
|
|
|
|
2015-02-20 04:10:44 +03:00
|
|
|
LoadScriptInternal(aURL, aRunInGlobalScope);
|
2010-02-20 20:05:20 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
TabChild::RecvAsyncMessage(const nsString& aMessage,
|
2013-07-11 02:05:39 +04:00
|
|
|
const ClonedMessageData& aData,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<CpowEntry>&& aCpows,
|
2013-11-06 21:21:15 +04:00
|
|
|
const IPC::Principal& aPrincipal)
|
2010-02-20 20:05:20 +03:00
|
|
|
{
|
|
|
|
if (mTabChildGlobal) {
|
2013-06-30 19:00:18 +04:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> kungFuDeathGrip(GetGlobal());
|
2013-01-24 20:24:19 +04:00
|
|
|
StructuredCloneData cloneData = UnpackClonedMessageDataForChild(aData);
|
2011-06-16 22:21:08 +04:00
|
|
|
nsRefPtr<nsFrameMessageManager> mm =
|
|
|
|
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
2015-01-27 00:32:31 +03:00
|
|
|
CrossProcessCpowHolder cpows(Manager(), aCpows);
|
2015-04-16 18:17:54 +03:00
|
|
|
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
|
2013-11-06 21:21:15 +04:00
|
|
|
aMessage, false, &cloneData, &cpows, aPrincipal, nullptr);
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-23 03:17:18 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvAppOfflineStatus(const uint32_t& aId, const bool& aOffline)
|
|
|
|
{
|
|
|
|
// Instantiate the service to make sure gIOService is initialized
|
|
|
|
nsCOMPtr<nsIIOService> ioService = mozilla::services::GetIOService();
|
|
|
|
if (gIOService && ioService) {
|
|
|
|
gIOService->SetAppOfflineInternal(aId, aOffline ?
|
|
|
|
nsIAppOfflineInfo::OFFLINE : nsIAppOfflineInfo::ONLINE);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-06 02:11:23 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvDestroy()
|
|
|
|
{
|
2014-08-24 11:16:32 +04:00
|
|
|
MOZ_ASSERT(mDestroyed == false);
|
|
|
|
mDestroyed = true;
|
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
if (mTabChildGlobal) {
|
2015-02-27 08:35:26 +03:00
|
|
|
// Message handlers are called from the event loop, so it better be safe to
|
|
|
|
// run script.
|
|
|
|
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
|
|
|
|
mTabChildGlobal->DispatchTrustedEvent(NS_LITERAL_STRING("unload"));
|
2011-08-09 23:38:26 +04:00
|
|
|
}
|
2010-08-06 02:11:23 +04:00
|
|
|
|
2012-09-29 06:18:18 +04:00
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
2013-10-21 16:58:12 +04:00
|
|
|
mozilla::services::GetObserverService();
|
2012-09-29 06:18:18 +04:00
|
|
|
|
|
|
|
observerService->RemoveObserver(this, BROWSER_ZOOM_TO_RECT);
|
|
|
|
observerService->RemoveObserver(this, BEFORE_FIRST_PAINT);
|
|
|
|
|
2010-08-12 20:47:22 +04:00
|
|
|
// XXX what other code in ~TabChild() should we be running here?
|
2010-08-21 03:24:40 +04:00
|
|
|
DestroyWindow();
|
2010-08-06 02:11:23 +04:00
|
|
|
|
2014-07-11 22:15:10 +04:00
|
|
|
// Bounce through the event loop once to allow any delayed teardown runnables
|
|
|
|
// that were just generated to have a chance to run.
|
|
|
|
nsCOMPtr<nsIRunnable> deleteRunnable = new DelayedDeleteRunnable(this);
|
|
|
|
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToCurrentThread(deleteRunnable)));
|
|
|
|
|
|
|
|
return true;
|
2010-08-06 02:11:23 +04:00
|
|
|
}
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2013-08-13 11:56:57 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvSetUpdateHitRegion(const bool& aEnabled)
|
|
|
|
{
|
|
|
|
mUpdateHitRegion = aEnabled;
|
2015-01-09 11:55:18 +03:00
|
|
|
|
|
|
|
// We need to trigger a repaint of the child frame to ensure that it
|
|
|
|
// recomputes and sends its region.
|
|
|
|
if (!mUpdateHitRegion) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> document(GetDocument());
|
|
|
|
NS_ENSURE_TRUE(document, true);
|
|
|
|
nsCOMPtr<nsIPresShell> presShell = document->GetShell();
|
|
|
|
NS_ENSURE_TRUE(presShell, true);
|
|
|
|
nsRefPtr<nsPresContext> presContext = presShell->GetPresContext();
|
|
|
|
NS_ENSURE_TRUE(presContext, true);
|
|
|
|
presContext->InvalidatePaintedLayers();
|
|
|
|
|
2013-08-13 11:56:57 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-20 15:26:13 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvSetIsDocShellActive(const bool& aIsActive)
|
|
|
|
{
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
2014-02-20 15:26:13 +04:00
|
|
|
if (docShell) {
|
|
|
|
docShell->SetIsActive(aIsActive);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
PRenderFrameChild*
|
2014-11-16 21:23:22 +03:00
|
|
|
TabChild::AllocPRenderFrameChild()
|
2010-08-21 03:24:41 +04:00
|
|
|
{
|
|
|
|
return new RenderFrameChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
TabChild::DeallocPRenderFrameChild(PRenderFrameChild* aFrame)
|
2010-08-21 03:24:41 +04:00
|
|
|
{
|
|
|
|
delete aFrame;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-20 20:05:20 +03:00
|
|
|
bool
|
2012-08-29 19:26:18 +04:00
|
|
|
TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading)
|
2010-02-20 20:05:20 +03:00
|
|
|
{
|
2013-06-30 19:00:19 +04:00
|
|
|
if (!mGlobal && !mTabChildGlobal) {
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(WebNavigation());
|
2012-08-29 19:26:18 +04:00
|
|
|
NS_ENSURE_TRUE(window, false);
|
2013-04-20 02:18:32 +04:00
|
|
|
nsCOMPtr<EventTarget> chromeHandler =
|
2012-08-29 19:26:18 +04:00
|
|
|
do_QueryInterface(window->GetChromeEventHandler());
|
|
|
|
NS_ENSURE_TRUE(chromeHandler, false);
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
nsRefPtr<TabChildGlobal> scope = new TabChildGlobal(this);
|
|
|
|
mTabChildGlobal = scope;
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2013-04-20 02:18:33 +04:00
|
|
|
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, scope);
|
2012-09-29 06:18:18 +04:00
|
|
|
|
2013-02-20 14:39:59 +04:00
|
|
|
NS_NAMED_LITERAL_CSTRING(globalId, "outOfProcessTabChildGlobal");
|
2015-02-20 04:10:44 +03:00
|
|
|
NS_ENSURE_TRUE(InitChildGlobalInternal(scopeSupports, globalId), false);
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
scope->Init();
|
2012-04-27 00:56:46 +04:00
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
|
|
|
|
NS_ENSURE_TRUE(root, false);
|
|
|
|
root->SetParentTarget(scope);
|
2012-09-29 06:18:18 +04:00
|
|
|
|
|
|
|
chromeHandler->AddEventListener(NS_LITERAL_STRING("DOMMetaAdded"), this, false);
|
2014-08-22 03:37:00 +04:00
|
|
|
chromeHandler->AddEventListener(NS_LITERAL_STRING("FullZoomChange"), this, false);
|
2012-08-29 19:26:18 +04:00
|
|
|
}
|
2012-06-22 05:17:52 +04:00
|
|
|
|
2012-08-29 19:26:18 +04: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 22:32:37 +04:00
|
|
|
if (IsBrowserOrApp()) {
|
2013-11-24 09:32:45 +04:00
|
|
|
RecvLoadRemoteScript(BROWSER_ELEMENT_CHILD_SCRIPT, true);
|
2012-08-29 19:26:18 +04:00
|
|
|
}
|
2012-06-22 05:17:52 +04:00
|
|
|
}
|
|
|
|
|
2010-02-20 20:05:20 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
bool
|
2015-02-26 16:47:01 +03:00
|
|
|
TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
2014-11-16 21:23:22 +03:00
|
|
|
const uint64_t& aLayersId,
|
|
|
|
PRenderFrameChild* aRenderFrame)
|
2010-08-21 03:24:41 +04:00
|
|
|
{
|
2012-08-29 19:26:18 +04:00
|
|
|
static_cast<PuppetWidget*>(mWidget.get())->InitIMEState();
|
2010-08-21 03:24:41 +04:00
|
|
|
|
2014-11-16 21:23:22 +03:00
|
|
|
RenderFrameChild* remoteFrame = static_cast<RenderFrameChild*>(aRenderFrame);
|
2010-08-21 03:24:41 +04:00
|
|
|
if (!remoteFrame) {
|
2014-01-16 01:10:39 +04:00
|
|
|
NS_WARNING("failed to construct RenderFrame");
|
|
|
|
return false;
|
|
|
|
}
|
2010-08-21 03:24:41 +04:00
|
|
|
|
2014-11-16 21:23:22 +03:00
|
|
|
MOZ_ASSERT(aLayersId != 0);
|
|
|
|
mTextureFactoryIdentifier = aTextureFactoryIdentifier;
|
2014-08-22 04:16:44 +04:00
|
|
|
|
|
|
|
// Pushing layers transactions directly to a separate
|
|
|
|
// compositor context.
|
|
|
|
PCompositorChild* compositorChild = CompositorChild::Get();
|
|
|
|
if (!compositorChild) {
|
|
|
|
NS_WARNING("failed to get CompositorChild instance");
|
2014-11-16 21:23:22 +03:00
|
|
|
PRenderFrameChild::Send__delete__(remoteFrame);
|
2014-08-22 04:16:44 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsTArray<LayersBackend> backends;
|
|
|
|
backends.AppendElement(mTextureFactoryIdentifier.mParentBackend);
|
2014-11-16 21:23:22 +03:00
|
|
|
bool success;
|
2014-08-22 04:16:44 +04:00
|
|
|
PLayerTransactionChild* shadowManager =
|
|
|
|
compositorChild->SendPLayerTransactionConstructor(backends,
|
2014-11-16 21:23:22 +03:00
|
|
|
aLayersId, &mTextureFactoryIdentifier, &success);
|
2014-08-22 04:16:44 +04:00
|
|
|
if (!success) {
|
|
|
|
NS_WARNING("failed to properly allocate layer transaction");
|
2014-11-16 21:23:22 +03:00
|
|
|
PRenderFrameChild::Send__delete__(remoteFrame);
|
2014-08-22 04:16:44 +04:00
|
|
|
return false;
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
if (!shadowManager) {
|
|
|
|
NS_WARNING("failed to construct LayersChild");
|
|
|
|
// This results in |remoteFrame| being deleted.
|
|
|
|
PRenderFrameChild::Send__delete__(remoteFrame);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
ShadowLayerForwarder* lf =
|
2013-05-01 04:42:05 +04: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 13:20:52 +04:00
|
|
|
->AsShadowForwarder();
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(lf && lf->HasShadowManager(),
|
|
|
|
"PuppetWidget should have shadow manager");
|
2013-05-01 04:42:05 +04:00
|
|
|
lf->IdentifyTextureHost(mTextureFactoryIdentifier);
|
2013-06-24 09:28:22 +04:00
|
|
|
ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
|
2010-08-21 03:24:41 +04:00
|
|
|
|
|
|
|
mRemoteFrame = remoteFrame;
|
2014-11-16 21:23:22 +03:00
|
|
|
if (aLayersId != 0) {
|
2014-03-07 07:24:32 +04:00
|
|
|
if (!sTabChildren) {
|
|
|
|
sTabChildren = new TabChildMap;
|
|
|
|
}
|
2014-11-16 21:23:22 +03:00
|
|
|
MOZ_ASSERT(!sTabChildren->Get(aLayersId));
|
|
|
|
sTabChildren->Put(aLayersId, this);
|
|
|
|
mLayersId = aLayersId;
|
2014-03-07 07:24:32 +04:00
|
|
|
}
|
2012-08-29 19:26:18 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
2013-10-21 16:58:12 +04:00
|
|
|
mozilla::services::GetObserverService();
|
2012-08-29 19:26:18 +04:00
|
|
|
|
|
|
|
if (observerService) {
|
2012-09-29 06:18:18 +04:00
|
|
|
observerService->AddObserver(this,
|
|
|
|
BROWSER_ZOOM_TO_RECT,
|
2012-08-29 19:26:18 +04:00
|
|
|
false);
|
|
|
|
observerService->AddObserver(this,
|
2012-09-29 06:18:18 +04:00
|
|
|
BEFORE_FIRST_PAINT,
|
2012-08-29 19:26:18 +04:00
|
|
|
false);
|
|
|
|
}
|
2010-08-21 03:24:41 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-21 02:17:09 +04:00
|
|
|
void
|
|
|
|
TabChild::SetBackgroundColor(const nscolor& aColor)
|
|
|
|
{
|
|
|
|
if (mLastBackgroundColor != aColor) {
|
|
|
|
mLastBackgroundColor = aColor;
|
|
|
|
SendSetBackgroundColor(mLastBackgroundColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
void
|
|
|
|
TabChild::GetDPI(float* aDPI)
|
|
|
|
{
|
|
|
|
*aDPI = -1.0;
|
|
|
|
if (!mRemoteFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-12 20:50:46 +03:00
|
|
|
if (mDPI > 0) {
|
|
|
|
*aDPI = mDPI;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fallback to a sync call if needed.
|
2012-08-29 19:26:18 +04:00
|
|
|
SendGetDPI(aDPI);
|
|
|
|
}
|
|
|
|
|
2013-05-02 03:06:19 +04:00
|
|
|
void
|
|
|
|
TabChild::GetDefaultScale(double* aScale)
|
|
|
|
{
|
|
|
|
*aScale = -1.0;
|
|
|
|
if (!mRemoteFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-12 20:50:46 +03:00
|
|
|
if (mDefaultScale > 0) {
|
|
|
|
*aScale = mDefaultScale;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fallback to a sync call if needed.
|
2013-05-02 03:06:19 +04:00
|
|
|
SendGetDefaultScale(aScale);
|
|
|
|
}
|
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
void
|
|
|
|
TabChild::NotifyPainted()
|
|
|
|
{
|
2014-08-22 04:16:44 +04:00
|
|
|
if (!mNotified) {
|
2012-07-18 03:59:45 +04:00
|
|
|
mRemoteFrame->SendNotifyCompositorTransaction();
|
2012-08-07 07:00:41 +04:00
|
|
|
mNotified = true;
|
2012-07-18 03:59:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-08 07:51:55 +04:00
|
|
|
void
|
|
|
|
TabChild::MakeVisible()
|
|
|
|
{
|
|
|
|
if (mWidget) {
|
|
|
|
mWidget->Show(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TabChild::MakeHidden()
|
|
|
|
{
|
|
|
|
if (mWidget) {
|
|
|
|
mWidget->Show(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-13 11:56:57 +04:00
|
|
|
void
|
|
|
|
TabChild::UpdateHitRegion(const nsRegion& aRegion)
|
|
|
|
{
|
|
|
|
mRemoteFrame->SendUpdateHitRegion(aRegion);
|
|
|
|
}
|
|
|
|
|
2012-05-28 13:27:25 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetMessageManager(nsIContentFrameMessageManager** aResult)
|
|
|
|
{
|
|
|
|
if (mTabChildGlobal) {
|
|
|
|
NS_ADDREF(*aResult = mTabChildGlobal);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
*aResult = nullptr;
|
2012-05-28 13:27:25 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-09-03 01:43:08 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetWebBrowserChrome(nsIWebBrowserChrome3** aWebBrowserChrome)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(*aWebBrowserChrome = mWebBrowserChrome);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::SetWebBrowserChrome(nsIWebBrowserChrome3* aWebBrowserChrome)
|
|
|
|
{
|
|
|
|
mWebBrowserChrome = aWebBrowserChrome;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-05 18:16:25 +04:00
|
|
|
void
|
|
|
|
TabChild::SendRequestFocus(bool aCanFocus)
|
|
|
|
{
|
|
|
|
PBrowserChild::SendRequestFocus(aCanFocus);
|
|
|
|
}
|
|
|
|
|
2014-12-09 18:48:27 +03:00
|
|
|
void
|
|
|
|
TabChild::EnableDisableCommands(const nsAString& aAction,
|
|
|
|
nsTArray<nsCString>& aEnabledCommands,
|
|
|
|
nsTArray<nsCString>& aDisabledCommands)
|
|
|
|
{
|
|
|
|
PBrowserChild::SendEnableDisableCommands(PromiseFlatString(aAction),
|
|
|
|
aEnabledCommands, aDisabledCommands);
|
|
|
|
}
|
|
|
|
|
2015-01-22 12:40:17 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::GetTabId(uint64_t* aId)
|
|
|
|
{
|
|
|
|
*aId = GetTabId();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-01-30 12:07:12 +03:00
|
|
|
void
|
|
|
|
TabChild::SetTabId(const TabId& aTabId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mUniqueId == 0);
|
|
|
|
|
|
|
|
mUniqueId = aTabId;
|
|
|
|
NestedTabChildMap()[mUniqueId] = this;
|
|
|
|
}
|
|
|
|
|
2012-09-28 09:43:12 +04:00
|
|
|
bool
|
2013-10-01 20:15:06 +04:00
|
|
|
TabChild::DoSendBlockingMessage(JSContext* aCx,
|
|
|
|
const nsAString& aMessage,
|
|
|
|
const StructuredCloneData& aData,
|
|
|
|
JS::Handle<JSObject *> aCpows,
|
2013-11-06 21:21:15 +04:00
|
|
|
nsIPrincipal* aPrincipal,
|
2013-10-01 20:15:06 +04:00
|
|
|
InfallibleTArray<nsString>* aJSONRetVal,
|
|
|
|
bool aIsSync)
|
2010-02-20 20:05:20 +03:00
|
|
|
{
|
2012-08-02 10:02:29 +04:00
|
|
|
ClonedMessageData data;
|
2014-06-11 09:44:06 +04:00
|
|
|
if (!BuildClonedMessageDataForChild(Manager(), aData, data)) {
|
2013-01-24 06:39:27 +04:00
|
|
|
return false;
|
2012-08-02 10:02:29 +04:00
|
|
|
}
|
2013-07-11 02:05:39 +04:00
|
|
|
InfallibleTArray<CpowEntry> cpows;
|
2014-10-07 02:45:42 +04:00
|
|
|
if (aCpows && !Manager()->GetCPOWManager()->Wrap(aCx, aCpows, &cpows)) {
|
2014-09-30 01:11:08 +04:00
|
|
|
return false;
|
2013-07-11 02:05:39 +04:00
|
|
|
}
|
2013-11-06 21:21:15 +04:00
|
|
|
if (aIsSync) {
|
2014-02-25 06:14:22 +04:00
|
|
|
return SendSyncMessage(PromiseFlatString(aMessage), data, cpows,
|
2014-08-05 17:19:51 +04:00
|
|
|
Principal(aPrincipal), aJSONRetVal);
|
2013-11-06 21:21:15 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
return SendRpcMessage(PromiseFlatString(aMessage), data, cpows,
|
2014-08-05 17:19:51 +04:00
|
|
|
Principal(aPrincipal), aJSONRetVal);
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2012-09-28 09:43:12 +04:00
|
|
|
bool
|
2013-07-11 02:05:39 +04:00
|
|
|
TabChild::DoSendAsyncMessage(JSContext* aCx,
|
|
|
|
const nsAString& aMessage,
|
|
|
|
const StructuredCloneData& aData,
|
2013-11-06 21:21:15 +04:00
|
|
|
JS::Handle<JSObject *> aCpows,
|
|
|
|
nsIPrincipal* aPrincipal)
|
2012-08-02 10:02:29 +04:00
|
|
|
{
|
|
|
|
ClonedMessageData data;
|
2014-06-11 09:44:06 +04:00
|
|
|
if (!BuildClonedMessageDataForChild(Manager(), aData, data)) {
|
2013-01-24 06:39:27 +04:00
|
|
|
return false;
|
2012-08-02 10:02:29 +04:00
|
|
|
}
|
2013-07-11 02:05:39 +04:00
|
|
|
InfallibleTArray<CpowEntry> cpows;
|
2014-10-07 02:45:42 +04:00
|
|
|
if (aCpows && !Manager()->GetCPOWManager()->Wrap(aCx, aCpows, &cpows)) {
|
2014-09-30 01:11:08 +04:00
|
|
|
return false;
|
2013-07-11 02:05:39 +04:00
|
|
|
}
|
2014-02-25 06:14:22 +04:00
|
|
|
return SendAsyncMessage(PromiseFlatString(aMessage), data, cpows,
|
2014-08-05 17:19:51 +04:00
|
|
|
Principal(aPrincipal));
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2013-10-03 00:08:30 +04:00
|
|
|
TabChild*
|
|
|
|
TabChild::GetFrom(nsIPresShell* aPresShell)
|
|
|
|
{
|
|
|
|
nsIDocument* doc = aPresShell->GetDocument();
|
|
|
|
if (!doc) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-11-15 20:32:12 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell(doc->GetDocShell());
|
2013-10-03 00:08:30 +04:00
|
|
|
return GetFrom(docShell);
|
|
|
|
}
|
|
|
|
|
2014-03-07 07:24:32 +04:00
|
|
|
TabChild*
|
|
|
|
TabChild::GetFrom(uint64_t aLayersId)
|
|
|
|
{
|
|
|
|
if (!sTabChildren) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return sTabChildren->Get(aLayersId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-29 01:42:14 +04:00
|
|
|
TabChild::DidComposite(uint64_t aTransactionId)
|
2014-03-07 07:24:32 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWidget);
|
|
|
|
MOZ_ASSERT(mWidget->GetLayerManager());
|
|
|
|
MOZ_ASSERT(mWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT);
|
|
|
|
|
|
|
|
ClientLayerManager *manager = static_cast<ClientLayerManager*>(mWidget->GetLayerManager());
|
2014-05-29 01:42:14 +04:00
|
|
|
manager->DidComposite(aTransactionId);
|
2014-03-07 07:24:32 +04:00
|
|
|
}
|
|
|
|
|
2014-01-23 00:27:23 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnShowTooltip(int32_t aXCoords, int32_t aYCoords, const char16_t *aTipText)
|
|
|
|
{
|
|
|
|
nsString str(aTipText);
|
|
|
|
SendShowTooltip(aXCoords, aYCoords, str);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChild::OnHideTooltip()
|
|
|
|
{
|
|
|
|
SendHideTooltip();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-08-02 10:02:29 +04:00
|
|
|
|
2014-05-23 22:19:00 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvRequestNotifyAfterRemotePaint()
|
|
|
|
{
|
|
|
|
// Get the CompositorChild instance for this content thread.
|
|
|
|
CompositorChild* compositor = CompositorChild::Get();
|
|
|
|
|
|
|
|
// Tell the CompositorChild that, when it gets a RemotePaintIsReady
|
|
|
|
// message that it should forward it us so that we can bounce it to our
|
|
|
|
// RenderFrameParent.
|
|
|
|
compositor->RequestNotifyAfterRemotePaint(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-23 18:36:50 +04:00
|
|
|
bool
|
|
|
|
TabChild::RecvUIResolutionChanged()
|
|
|
|
{
|
2014-12-16 19:25:15 +03:00
|
|
|
mDPI = 0;
|
|
|
|
mDefaultScale = 0;
|
2014-05-23 18:36:50 +04:00
|
|
|
static_cast<PuppetWidget*>(mWidget.get())->ClearBackingScaleCache();
|
|
|
|
nsCOMPtr<nsIDocument> document(GetDocument());
|
|
|
|
nsCOMPtr<nsIPresShell> presShell = document->GetShell();
|
2015-04-22 17:58:33 +03:00
|
|
|
if (presShell) {
|
|
|
|
nsRefPtr<nsPresContext> presContext = presShell->GetPresContext();
|
|
|
|
if (presContext) {
|
|
|
|
presContext->UIResolutionChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::RecvThemeChanged(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache)
|
|
|
|
{
|
|
|
|
LookAndFeel::SetIntCache(aLookAndFeelIntCache);
|
|
|
|
nsCOMPtr<nsIDocument> document(GetDocument());
|
|
|
|
nsCOMPtr<nsIPresShell> presShell = document->GetShell();
|
|
|
|
if (presShell) {
|
|
|
|
nsRefPtr<nsPresContext> presContext = presShell->GetPresContext();
|
|
|
|
if (presContext) {
|
|
|
|
presContext->ThemeChanged();
|
|
|
|
}
|
|
|
|
}
|
2014-05-23 18:36:50 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-12 23:59:19 +03:00
|
|
|
mozilla::plugins::PPluginWidgetChild*
|
|
|
|
TabChild::AllocPPluginWidgetChild()
|
|
|
|
{
|
|
|
|
return new mozilla::plugins::PluginWidgetChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::DeallocPPluginWidgetChild(mozilla::plugins::PPluginWidgetChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-06 00:48:44 +03:00
|
|
|
nsresult
|
|
|
|
TabChild::CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut)
|
2014-11-12 23:59:19 +03:00
|
|
|
{
|
2015-02-06 00:48:44 +03:00
|
|
|
*aOut = nullptr;
|
2014-11-12 23:59:19 +03:00
|
|
|
mozilla::plugins::PluginWidgetChild* child =
|
|
|
|
static_cast<mozilla::plugins::PluginWidgetChild*>(SendPPluginWidgetConstructor());
|
|
|
|
if (!child) {
|
|
|
|
NS_ERROR("couldn't create PluginWidgetChild");
|
2015-02-06 00:48:44 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
|
|
|
nsCOMPtr<nsIWidget> pluginWidget = nsIWidget::CreatePluginProxyWidget(this, child);
|
|
|
|
if (!pluginWidget) {
|
|
|
|
NS_ERROR("couldn't create PluginWidgetProxy");
|
2015-02-06 00:48:44 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
|
|
|
|
2014-11-12 23:59:20 +03:00
|
|
|
nsWidgetInitData initData;
|
|
|
|
initData.mWindowType = eWindowType_plugin_ipc_content;
|
|
|
|
initData.mUnicode = false;
|
|
|
|
initData.clipChildren = true;
|
|
|
|
initData.clipSiblings = true;
|
2015-04-21 18:04:57 +03:00
|
|
|
nsresult rv = pluginWidget->Create(aParent, nullptr, gfx::IntRect(gfx::IntPoint(0, 0),
|
2015-02-05 10:35:25 +03:00
|
|
|
nsIntSize(0, 0)), &initData);
|
2014-11-12 23:59:19 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Creating native plugin widget on the chrome side failed.");
|
|
|
|
}
|
2015-02-06 00:48:44 +03:00
|
|
|
pluginWidget.forget(aOut);
|
|
|
|
return rv;
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
TabChildGlobal::TabChildGlobal(TabChildBase* aTabChild)
|
2010-02-20 20:05:20 +03:00
|
|
|
: mTabChild(aTabChild)
|
|
|
|
{
|
2014-10-15 13:43:25 +04:00
|
|
|
SetIsNotDOMBinding();
|
2012-04-27 00:56:46 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 01:23:17 +04:00
|
|
|
TabChildGlobal::~TabChildGlobal()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-04-27 00:56:46 +04:00
|
|
|
void
|
|
|
|
TabChildGlobal::Init()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mMessageManager, "Re-initializing?!?");
|
2012-09-28 09:43:12 +04:00
|
|
|
mMessageManager = new nsFrameMessageManager(mTabChild,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr,
|
2012-09-28 09:43:12 +04:00
|
|
|
MM_CHILD);
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(TabChildGlobal, DOMEventTargetHelper,
|
|
|
|
mMessageManager, mTabChild)
|
2010-02-20 20:05:20 +03:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChildGlobal)
|
2012-08-27 18:13:02 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIMessageListenerManager)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
|
2010-08-31 22:58:35 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISyncMessageSender)
|
2010-02-20 20:05:20 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
2013-12-12 05:51:56 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
2015-01-18 06:17:06 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2010-02-20 20:05:20 +03:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2012-08-09 12:33:38 +04: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()
|
|
|
|
{
|
2015-02-25 01:23:53 +03:00
|
|
|
if (mTabChild) {
|
|
|
|
mTabChild->MarkScopesForCC();
|
|
|
|
}
|
2012-08-09 12:33:38 +04:00
|
|
|
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
|
|
|
}
|
|
|
|
|
2010-02-20 20:05:20 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChildGlobal::GetContent(nsIDOMWindow** aContent)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*aContent = nullptr;
|
2010-07-22 03:23:03 +04:00
|
|
|
if (!mTabChild)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2010-02-20 20:05:20 +03:00
|
|
|
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mTabChild->WebNavigation());
|
|
|
|
window.swap(*aContent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-03 23:30:25 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
TabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*aDocShell = nullptr;
|
2010-05-12 13:52:15 +04:00
|
|
|
if (!mTabChild)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2010-03-03 23:30:25 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mTabChild->WebNavigation());
|
|
|
|
docShell.swap(*aDocShell);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-20 20:05:20 +03:00
|
|
|
JSContext*
|
|
|
|
TabChildGlobal::GetJSContextForEventHandlers()
|
|
|
|
{
|
2013-06-30 19:00:19 +04:00
|
|
|
return nsContentUtils::GetSafeJSContext();
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2013-12-12 05:51:56 +04:00
|
|
|
nsIPrincipal*
|
2010-02-20 20:05:20 +03:00
|
|
|
TabChildGlobal::GetPrincipal()
|
|
|
|
{
|
2010-05-12 13:52:15 +04:00
|
|
|
if (!mTabChild)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-02-20 20:05:20 +03:00
|
|
|
return mTabChild->GetPrincipal();
|
2012-09-13 07:50:40 +04:00
|
|
|
}
|
2013-12-12 05:51:56 +04:00
|
|
|
|
|
|
|
JSObject*
|
|
|
|
TabChildGlobal::GetGlobalJSObject()
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mTabChild, nullptr);
|
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> ref = mTabChild->GetGlobal();
|
|
|
|
NS_ENSURE_TRUE(ref, nullptr);
|
|
|
|
return ref->GetJSObject();
|
|
|
|
}
|
|
|
|
|