2010-08-20 16:24:41 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-20 16:24:41 -07:00
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "base/basictypes.h"
|
2010-08-20 16:24:41 -07:00
|
|
|
|
|
|
|
#include "BasicLayers.h"
|
2011-07-04 06:15:05 -07:00
|
|
|
#ifdef MOZ_ENABLE_D3D9_LAYER
|
2012-07-17 16:59:45 -07:00
|
|
|
# include "LayerManagerD3D9.h"
|
2011-07-04 06:15:05 -07:00
|
|
|
#endif //MOZ_ENABLE_D3D9_LAYER
|
2012-12-24 22:09:34 -08:00
|
|
|
#include "mozilla/BrowserElementParent.h"
|
2014-06-10 22:44:39 -07:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2012-07-19 23:48:27 -07:00
|
|
|
#include "mozilla/dom/TabParent.h"
|
2013-07-30 11:03:40 -07:00
|
|
|
#include "mozilla/layers/APZCTreeManager.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2013-04-24 11:42:40 -07:00
|
|
|
#include "mozilla/layers/LayerTransactionParent.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsContentUtils.h"
|
2010-08-20 16:24:41 -07:00
|
|
|
#include "nsFrameLoader.h"
|
2011-05-19 03:53:02 -07:00
|
|
|
#include "nsIObserver.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2013-06-10 14:00:00 -07:00
|
|
|
#include "nsView.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "nsViewportFrame.h"
|
|
|
|
#include "RenderFrameParent.h"
|
2013-04-27 23:46:30 -07:00
|
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
2013-07-11 19:32:09 -07:00
|
|
|
#include "mozilla/layers/CompositorChild.h"
|
|
|
|
#include "ClientLayerManager.h"
|
2014-08-05 22:19:25 -07:00
|
|
|
#include "FrameLayerBuilder.h"
|
2010-08-20 16:24:41 -07:00
|
|
|
|
2012-07-19 23:48:27 -07:00
|
|
|
using namespace mozilla::dom;
|
2014-08-01 05:31:47 -07:00
|
|
|
using namespace mozilla::gfx;
|
2010-08-20 16:24:41 -07:00
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layout {
|
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
2011-01-13 09:45:14 -08:00
|
|
|
|
2012-11-04 22:11:25 -08:00
|
|
|
/**
|
|
|
|
* Gets the layer-pixel offset of aContainerFrame's content rect top-left
|
|
|
|
* from the nearest display item reference frame (which we assume will be inducing
|
|
|
|
* a ContainerLayer).
|
|
|
|
*/
|
2011-01-13 09:45:14 -08:00
|
|
|
static nsIntPoint
|
2012-11-04 22:11:25 -08:00
|
|
|
GetContentRectLayerOffset(nsIFrame* aContainerFrame, nsDisplayListBuilder* aBuilder)
|
2011-01-13 09:45:14 -08:00
|
|
|
{
|
|
|
|
nscoord auPerDevPixel = aContainerFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
|
|
|
|
// Offset to the content rect in case we have borders or padding
|
2012-11-04 22:11:25 -08:00
|
|
|
// Note that aContainerFrame could be a reference frame itself, so
|
|
|
|
// we need to be careful here to ensure that we call ToReferenceFrame
|
|
|
|
// on aContainerFrame and not its parent.
|
|
|
|
nsPoint frameOffset = aBuilder->ToReferenceFrame(aContainerFrame) +
|
2014-09-11 14:29:59 -07:00
|
|
|
aContainerFrame->GetContentRectRelativeToSelf().TopLeft();
|
2011-01-13 09:45:14 -08:00
|
|
|
|
|
|
|
return frameOffset.ToNearestPixels(auPerDevPixel);
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
// Return true iff |aManager| is a "temporary layer manager". They're
|
|
|
|
// used for small software rendering tasks, like drawWindow. That's
|
|
|
|
// currently implemented by a BasicLayerManager without a backing
|
|
|
|
// widget, and hence in non-retained mode.
|
2012-07-26 21:02:05 -07:00
|
|
|
inline static bool
|
2010-08-20 16:24:41 -07:00
|
|
|
IsTempLayerManager(LayerManager* aManager)
|
|
|
|
{
|
2014-01-23 10:26:41 -08:00
|
|
|
return (mozilla::layers::LayersBackend::LAYERS_BASIC == aManager->GetBackendType() &&
|
2010-08-20 16:24:41 -07:00
|
|
|
!static_cast<BasicLayerManager*>(aManager)->IsRetained());
|
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
already_AddRefed<LayerManager>
|
|
|
|
GetFrom(nsFrameLoader* aFrameLoader)
|
|
|
|
{
|
|
|
|
nsIDocument* doc = aFrameLoader->GetOwnerDoc();
|
|
|
|
return nsContentUtils::LayerManagerForDocument(doc);
|
|
|
|
}
|
|
|
|
|
2012-07-19 23:48:27 -07:00
|
|
|
class RemoteContentController : public GeckoContentController {
|
|
|
|
public:
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit RemoteContentController(RenderFrameParent* aRenderFrame)
|
2012-07-19 23:48:27 -07:00
|
|
|
: mUILoop(MessageLoop::current())
|
|
|
|
, mRenderFrame(aRenderFrame)
|
2013-09-13 07:18:33 -07:00
|
|
|
, mHaveZoomConstraints(false)
|
2012-07-19 23:48:27 -07:00
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE
|
|
|
|
{
|
2014-10-03 10:39:37 -07:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
if (mRenderFrame) {
|
|
|
|
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
|
|
|
browser->UpdateFrame(aFrameMetrics);
|
|
|
|
}
|
2012-07-19 23:48:27 -07:00
|
|
|
}
|
|
|
|
|
2014-02-05 14:43:20 -08:00
|
|
|
virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
|
|
|
|
const uint32_t& aScrollGeneration) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (MessageLoop::current() != mUILoop) {
|
|
|
|
// We have to send this message from the "UI thread" (main
|
|
|
|
// thread).
|
|
|
|
mUILoop->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &RemoteContentController::AcknowledgeScrollUpdate,
|
|
|
|
aScrollId, aScrollGeneration));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mRenderFrame) {
|
|
|
|
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
|
|
|
browser->AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-12 12:27:45 -07:00
|
|
|
virtual void HandleDoubleTap(const CSSPoint& aPoint,
|
2014-02-07 09:13:50 -08:00
|
|
|
int32_t aModifiers,
|
|
|
|
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE
|
2012-08-08 21:39:02 -07:00
|
|
|
{
|
|
|
|
if (MessageLoop::current() != mUILoop) {
|
|
|
|
// We have to send this message from the "UI thread" (main
|
|
|
|
// thread).
|
|
|
|
mUILoop->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &RemoteContentController::HandleDoubleTap,
|
2014-02-07 09:13:50 -08:00
|
|
|
aPoint, aModifiers, aGuid));
|
2012-08-08 21:39:02 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mRenderFrame) {
|
|
|
|
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
2014-02-07 09:13:50 -08:00
|
|
|
browser->HandleDoubleTap(aPoint, aModifiers, aGuid);
|
2012-08-08 21:39:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-12 12:27:45 -07:00
|
|
|
virtual void HandleSingleTap(const CSSPoint& aPoint,
|
2014-02-07 09:13:50 -08:00
|
|
|
int32_t aModifiers,
|
|
|
|
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE
|
2012-09-14 18:16:32 -07:00
|
|
|
{
|
|
|
|
if (MessageLoop::current() != mUILoop) {
|
|
|
|
// We have to send this message from the "UI thread" (main
|
|
|
|
// thread).
|
|
|
|
mUILoop->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &RemoteContentController::HandleSingleTap,
|
2014-02-07 09:13:50 -08:00
|
|
|
aPoint, aModifiers, aGuid));
|
2012-09-14 18:16:32 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mRenderFrame) {
|
|
|
|
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
2014-02-07 09:13:50 -08:00
|
|
|
browser->HandleSingleTap(aPoint, aModifiers, aGuid);
|
2012-09-14 18:16:32 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-12 12:27:45 -07:00
|
|
|
virtual void HandleLongTap(const CSSPoint& aPoint,
|
2014-02-07 09:13:50 -08:00
|
|
|
int32_t aModifiers,
|
|
|
|
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE
|
2012-11-08 11:35:02 -08:00
|
|
|
{
|
|
|
|
if (MessageLoop::current() != mUILoop) {
|
|
|
|
// We have to send this message from the "UI thread" (main
|
|
|
|
// thread).
|
|
|
|
mUILoop->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &RemoteContentController::HandleLongTap,
|
2014-02-07 09:13:50 -08:00
|
|
|
aPoint, aModifiers, aGuid));
|
2012-11-08 11:35:02 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mRenderFrame) {
|
|
|
|
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
2014-02-07 09:13:50 -08:00
|
|
|
browser->HandleLongTap(aPoint, aModifiers, aGuid);
|
2012-11-08 11:35:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-12 12:27:45 -07:00
|
|
|
virtual void HandleLongTapUp(const CSSPoint& aPoint,
|
2014-02-07 09:13:50 -08:00
|
|
|
int32_t aModifiers,
|
|
|
|
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE
|
2013-12-11 16:39:06 -08:00
|
|
|
{
|
|
|
|
if (MessageLoop::current() != mUILoop) {
|
|
|
|
// We have to send this message from the "UI thread" (main
|
|
|
|
// thread).
|
|
|
|
mUILoop->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &RemoteContentController::HandleLongTapUp,
|
2014-02-07 09:13:50 -08:00
|
|
|
aPoint, aModifiers, aGuid));
|
2013-12-11 16:39:06 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mRenderFrame) {
|
|
|
|
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
2014-02-07 09:13:50 -08:00
|
|
|
browser->HandleLongTapUp(aPoint, aModifiers, aGuid);
|
2013-12-11 16:39:06 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
void ClearRenderFrame() { mRenderFrame = nullptr; }
|
2012-07-19 23:48:27 -07:00
|
|
|
|
2013-11-08 16:07:00 -08:00
|
|
|
virtual void SendAsyncScrollDOMEvent(bool aIsRoot,
|
2013-07-30 11:03:42 -07:00
|
|
|
const CSSRect& aContentRect,
|
2013-06-10 06:05:44 -07:00
|
|
|
const CSSSize& aContentSize) MOZ_OVERRIDE
|
2012-12-24 22:09:34 -08:00
|
|
|
{
|
|
|
|
if (MessageLoop::current() != mUILoop) {
|
|
|
|
mUILoop->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this,
|
|
|
|
&RemoteContentController::SendAsyncScrollDOMEvent,
|
2013-11-08 16:07:00 -08:00
|
|
|
aIsRoot, aContentRect, aContentSize));
|
2012-12-24 22:09:34 -08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-08 16:07:00 -08:00
|
|
|
if (mRenderFrame && aIsRoot) {
|
2012-12-24 22:09:34 -08:00
|
|
|
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
|
|
|
BrowserElementParent::DispatchAsyncScrollEvent(browser, aContentRect,
|
|
|
|
aContentSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-25 12:50:49 -08:00
|
|
|
virtual void PostDelayedTask(Task* aTask, int aDelayMs) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
|
|
|
|
}
|
|
|
|
|
2014-01-06 10:26:44 -08:00
|
|
|
virtual bool GetRootZoomConstraints(ZoomConstraints* aOutConstraints)
|
2013-09-13 07:18:33 -07:00
|
|
|
{
|
2014-01-06 10:26:44 -08:00
|
|
|
if (mHaveZoomConstraints && aOutConstraints) {
|
|
|
|
*aOutConstraints = mZoomConstraints;
|
2013-09-13 07:18:33 -07:00
|
|
|
}
|
|
|
|
return mHaveZoomConstraints;
|
|
|
|
}
|
|
|
|
|
2014-01-16 12:19:59 -08:00
|
|
|
virtual bool GetTouchSensitiveRegion(CSSRect* aOutRegion)
|
|
|
|
{
|
|
|
|
if (mTouchSensitiveRegion.IsEmpty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
*aOutRegion = CSSRect::FromAppUnits(mTouchSensitiveRegion.GetBounds());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-15 10:39:20 -07:00
|
|
|
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
|
|
|
|
APZStateChange aChange,
|
|
|
|
int aArg)
|
2013-12-09 19:14:55 -08:00
|
|
|
{
|
|
|
|
if (MessageLoop::current() != mUILoop) {
|
|
|
|
mUILoop->PostTask(
|
|
|
|
FROM_HERE,
|
2014-04-15 10:39:20 -07:00
|
|
|
NewRunnableMethod(this, &RemoteContentController::NotifyAPZStateChange,
|
|
|
|
aGuid, aChange, aArg));
|
2013-12-09 19:14:55 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mRenderFrame) {
|
|
|
|
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
2014-04-15 10:39:20 -07:00
|
|
|
browser->NotifyAPZStateChange(aGuid.mScrollId, aChange, aArg);
|
2013-12-09 19:14:55 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-16 12:19:59 -08:00
|
|
|
// Methods used by RenderFrameParent to set fields stored here.
|
|
|
|
|
|
|
|
void SaveZoomConstraints(const ZoomConstraints& aConstraints)
|
|
|
|
{
|
|
|
|
mHaveZoomConstraints = true;
|
|
|
|
mZoomConstraints = aConstraints;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTouchSensitiveRegion(const nsRegion& aRegion)
|
|
|
|
{
|
|
|
|
mTouchSensitiveRegion = aRegion;
|
|
|
|
}
|
2012-07-19 23:48:27 -07:00
|
|
|
private:
|
|
|
|
MessageLoop* mUILoop;
|
|
|
|
RenderFrameParent* mRenderFrame;
|
2013-09-13 07:18:33 -07:00
|
|
|
|
|
|
|
bool mHaveZoomConstraints;
|
2014-01-06 10:26:44 -08:00
|
|
|
ZoomConstraints mZoomConstraints;
|
2014-01-16 12:19:59 -08:00
|
|
|
nsRegion mTouchSensitiveRegion;
|
2012-07-19 23:48:27 -07:00
|
|
|
};
|
|
|
|
|
2014-05-08 07:04:00 -07:00
|
|
|
RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
|
|
|
ScrollingBehavior aScrollingBehavior,
|
|
|
|
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
|
|
|
uint64_t* aId,
|
|
|
|
bool* aSuccess)
|
2012-07-17 16:59:45 -07:00
|
|
|
: mLayersId(0)
|
2014-05-08 07:04:00 -07:00
|
|
|
, mFrameLoader(aFrameLoader)
|
2011-09-27 11:35:23 -07:00
|
|
|
, mFrameLoaderDestroyed(false)
|
2011-10-20 15:17:09 -07:00
|
|
|
, mBackgroundColor(gfxRGBA(1, 1, 1))
|
2010-10-26 10:51:08 -07:00
|
|
|
{
|
2014-05-08 07:04:00 -07:00
|
|
|
*aSuccess = false;
|
|
|
|
if (!mFrameLoader) {
|
|
|
|
return;
|
|
|
|
}
|
2014-01-15 13:10:39 -08:00
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
*aId = 0;
|
|
|
|
|
|
|
|
nsRefPtr<LayerManager> lm = GetFrom(mFrameLoader);
|
2013-01-10 02:02:21 -08:00
|
|
|
// Perhaps the document containing this frame currently has no presentation?
|
2014-01-23 10:26:41 -08:00
|
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
2013-12-08 17:40:59 -08:00
|
|
|
*aTextureFactoryIdentifier =
|
|
|
|
static_cast<ClientLayerManager*>(lm.get())->GetTextureFactoryIdentifier();
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
} else {
|
|
|
|
*aTextureFactoryIdentifier = TextureFactoryIdentifier();
|
2013-01-10 02:02:21 -08:00
|
|
|
}
|
2012-07-17 16:59:45 -07:00
|
|
|
|
2014-08-21 17:16:44 -07:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
2012-07-17 16:59:45 -07:00
|
|
|
// Our remote frame will push layers updates to the compositor,
|
|
|
|
// and we'll keep an indirect reference to that tree.
|
|
|
|
*aId = mLayersId = CompositorParent::AllocateLayerTreeId();
|
2014-01-23 10:26:41 -08:00
|
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
2014-06-14 00:25:02 -07:00
|
|
|
ClientLayerManager *clientManager =
|
|
|
|
static_cast<ClientLayerManager*>(lm.get());
|
2013-07-11 19:32:09 -07:00
|
|
|
clientManager->GetRemoteRenderer()->SendNotifyChildCreated(mLayersId);
|
|
|
|
}
|
2012-07-19 23:48:27 -07:00
|
|
|
if (aScrollingBehavior == ASYNC_PAN_ZOOM) {
|
|
|
|
mContentController = new RemoteContentController(this);
|
2013-07-30 11:03:40 -07:00
|
|
|
CompositorParent::SetControllerForLayerTree(mLayersId, mContentController);
|
2012-07-19 23:48:27 -07:00
|
|
|
}
|
2014-06-10 22:44:39 -07:00
|
|
|
} else if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
|
|
|
ContentChild::GetSingleton()->SendAllocateLayerTreeId(aId);
|
|
|
|
mLayersId = *aId;
|
2014-06-14 00:25:02 -07:00
|
|
|
CompositorChild::Get()->SendNotifyChildCreated(mLayersId);
|
2011-08-09 12:38:26 -07:00
|
|
|
}
|
2013-08-08 00:43:59 -07:00
|
|
|
// Set a default RenderFrameParent
|
|
|
|
mFrameLoader->SetCurrentRemoteFrame(this);
|
2014-05-08 07:04:00 -07:00
|
|
|
*aSuccess = true;
|
2010-10-26 10:51:08 -07:00
|
|
|
}
|
2010-08-20 16:24:41 -07:00
|
|
|
|
2013-07-30 11:03:40 -07:00
|
|
|
APZCTreeManager*
|
|
|
|
RenderFrameParent::GetApzcTreeManager()
|
|
|
|
{
|
|
|
|
// We can't get a ref to the APZCTreeManager until after the child is
|
|
|
|
// created and the static getter knows which CompositorParent is
|
|
|
|
// instantiated with this layers ID. That's why try to fetch it when
|
|
|
|
// we first need it and cache the result.
|
|
|
|
if (!mApzcTreeManager) {
|
|
|
|
mApzcTreeManager = CompositorParent::GetAPZCTreeManager(mLayersId);
|
|
|
|
}
|
|
|
|
return mApzcTreeManager.get();
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
RenderFrameParent::~RenderFrameParent()
|
|
|
|
{}
|
|
|
|
|
2011-01-05 20:54:47 -08:00
|
|
|
void
|
|
|
|
RenderFrameParent::Destroy()
|
|
|
|
{
|
2011-09-27 11:35:23 -07:00
|
|
|
mFrameLoaderDestroyed = true;
|
2011-01-05 20:54:47 -08:00
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
already_AddRefed<Layer>
|
|
|
|
RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
2010-10-13 15:55:45 -07:00
|
|
|
LayerManager* aManager,
|
2012-08-06 20:00:41 -07:00
|
|
|
const nsIntRect& aVisibleRect,
|
2012-09-16 15:25:33 -07:00
|
|
|
nsDisplayItem* aItem,
|
2013-09-26 23:01:16 -07:00
|
|
|
const ContainerLayerParameters& aContainerParameters)
|
2010-08-20 16:24:41 -07:00
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(aFrame,
|
|
|
|
"makes no sense to have a shadow tree without a frame");
|
|
|
|
NS_ABORT_IF_FALSE(!mContainer ||
|
|
|
|
IsTempLayerManager(aManager) ||
|
|
|
|
mContainer->Manager() == aManager,
|
|
|
|
"retaining manager changed out from under us ... HELP!");
|
|
|
|
|
2012-11-13 11:55:52 -08:00
|
|
|
if (IsTempLayerManager(aManager) ||
|
|
|
|
(mContainer && mContainer->Manager() != aManager)) {
|
2010-08-20 16:24:41 -07:00
|
|
|
// This can happen if aManager is a "temporary" manager, or if the
|
|
|
|
// widget's layer manager changed out from under us. We need to
|
|
|
|
// FIXME handle the former case somehow, probably with an API to
|
|
|
|
// draw a manager's subtree. The latter is bad bad bad, but the
|
2013-10-08 11:47:21 -07:00
|
|
|
// the NS_ABORT_IF_FALSE() above will flag it. Returning nullptr
|
2010-08-20 16:24:41 -07:00
|
|
|
// here will just cause the shadow subtree not to be rendered.
|
2012-11-13 11:55:52 -08:00
|
|
|
NS_WARNING("Remote iframe not rendered");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-08-20 16:24:41 -07:00
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
uint64_t id = GetLayerTreeId();
|
2014-08-21 17:16:44 -07:00
|
|
|
if (!id) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-01-25 22:26:37 -08:00
|
|
|
}
|
|
|
|
|
2014-08-21 17:16:44 -07:00
|
|
|
nsRefPtr<Layer> layer =
|
|
|
|
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
|
|
|
|
if (!layer) {
|
|
|
|
layer = aManager->CreateRefLayer();
|
2010-08-20 16:24:41 -07:00
|
|
|
}
|
2014-08-21 17:16:44 -07:00
|
|
|
if (!layer) {
|
|
|
|
// Probably a temporary layer manager that doesn't know how to
|
|
|
|
// use ref layers.
|
|
|
|
return nullptr;
|
2011-02-23 09:45:09 -08:00
|
|
|
}
|
2014-08-21 17:16:44 -07:00
|
|
|
static_cast<RefLayer*>(layer.get())->SetReferentId(id);
|
|
|
|
nsIntPoint offset = GetContentRectLayerOffset(aFrame, aBuilder);
|
|
|
|
// We can only have an offset if we're a child of an inactive
|
|
|
|
// container, but our display item is LAYER_ACTIVE_FORCE which
|
|
|
|
// forces all layers above to be active.
|
|
|
|
MOZ_ASSERT(aContainerParameters.mOffset == nsIntPoint());
|
2014-10-16 02:51:12 -07:00
|
|
|
gfx::Matrix4x4 m = gfx::Matrix4x4::Translation(offset.x, offset.y, 0.0);
|
2014-08-21 17:16:44 -07:00
|
|
|
// Remote content can't be repainted by us, so we multiply down
|
|
|
|
// the resolution that our container expects onto our container.
|
2014-10-16 02:51:12 -07:00
|
|
|
m.PreScale(aContainerParameters.mXScale, aContainerParameters.mYScale, 1.0);
|
2014-08-21 17:16:44 -07:00
|
|
|
layer->SetBaseTransform(m);
|
2010-08-20 16:24:41 -07:00
|
|
|
|
2014-08-21 17:16:44 -07:00
|
|
|
return layer.forget();
|
2010-08-20 16:24:41 -07:00
|
|
|
}
|
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
void
|
|
|
|
RenderFrameParent::OwnerContentChanged(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mFrameLoader->GetOwnerContent() == aContent,
|
|
|
|
"Don't build new map if owner is same!");
|
|
|
|
}
|
|
|
|
|
2014-05-22 11:49:43 -07:00
|
|
|
nsEventStatus
|
2014-03-10 14:59:46 -07:00
|
|
|
RenderFrameParent::NotifyInputEvent(WidgetInputEvent& aEvent,
|
|
|
|
ScrollableLayerGuid* aOutTargetGuid)
|
2012-07-19 23:48:27 -07:00
|
|
|
{
|
2013-07-30 11:03:40 -07:00
|
|
|
if (GetApzcTreeManager()) {
|
2014-05-22 11:49:43 -07:00
|
|
|
return GetApzcTreeManager()->ReceiveInputEvent(aEvent, aOutTargetGuid);
|
2012-07-19 23:48:27 -07:00
|
|
|
}
|
2014-05-22 11:49:43 -07:00
|
|
|
return nsEventStatus_eIgnore;
|
2012-07-19 23:48:27 -07:00
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
void
|
|
|
|
RenderFrameParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
2012-07-19 23:48:27 -07:00
|
|
|
if (mLayersId != 0) {
|
2014-06-10 22:44:39 -07:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
|
|
|
ContentChild::GetSingleton()->SendDeallocateLayerTreeId(mLayersId);
|
|
|
|
} else {
|
|
|
|
CompositorParent::DeallocateLayerTreeId(mLayersId);
|
|
|
|
}
|
2012-07-19 23:48:27 -07:00
|
|
|
if (mContentController) {
|
|
|
|
// Stop our content controller from requesting repaints of our
|
|
|
|
// content.
|
|
|
|
mContentController->ClearRenderFrame();
|
2013-07-30 11:03:40 -07:00
|
|
|
// TODO: notify the compositor?
|
2012-07-19 23:48:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
if (mFrameLoader && mFrameLoader->GetCurrentRemoteFrame() == this) {
|
2010-08-20 16:24:41 -07:00
|
|
|
// XXX this might cause some weird issues ... we'll just not
|
|
|
|
// redraw the part of the window covered by this until the "next"
|
|
|
|
// remote frame has a layer-tree transaction. For
|
|
|
|
// why==NormalShutdown, we'll definitely want to do something
|
|
|
|
// better, especially as nothing guarantees another Update() from
|
|
|
|
// the "next" remote layer tree.
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrameLoader->SetCurrentRemoteFrame(nullptr);
|
2010-08-20 16:24:41 -07:00
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrameLoader = nullptr;
|
2010-08-20 16:24:41 -07:00
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
bool
|
|
|
|
RenderFrameParent::RecvNotifyCompositorTransaction()
|
2010-08-20 16:24:41 -07:00
|
|
|
{
|
2012-07-17 16:59:45 -07:00
|
|
|
TriggerRepaint();
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-17 16:59:45 -07:00
|
|
|
|
2013-08-13 00:56:57 -07:00
|
|
|
bool
|
|
|
|
RenderFrameParent::RecvUpdateHitRegion(const nsRegion& aRegion)
|
|
|
|
{
|
|
|
|
mTouchRegion = aRegion;
|
2014-01-16 12:19:59 -08:00
|
|
|
if (mContentController) {
|
|
|
|
// Tell the content controller about the touch-sensitive region, so
|
|
|
|
// that it can provide it to APZ. This is required for APZ to do
|
|
|
|
// correct hit testing for a remote 'mozpasspointerevents' iframe
|
|
|
|
// until bug 928833 is fixed.
|
|
|
|
mContentController->SetTouchSensitiveRegion(aRegion);
|
|
|
|
}
|
2013-08-13 00:56:57 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
void
|
|
|
|
RenderFrameParent::TriggerRepaint()
|
|
|
|
{
|
|
|
|
mFrameLoader->SetCurrentRemoteFrame(this);
|
|
|
|
|
|
|
|
nsIFrame* docFrame = mFrameLoader->GetPrimaryFrameOfOwningContent();
|
|
|
|
if (!docFrame) {
|
|
|
|
// Bad, but nothing we can do about it (XXX/cjones: or is there?
|
|
|
|
// maybe bug 589337?). When the new frame is created, we'll
|
|
|
|
// probably still be the current render frame and will get to draw
|
|
|
|
// our content then. Or, we're shutting down and this update goes
|
|
|
|
// to /dev/null.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-30 17:42:05 -07:00
|
|
|
docFrame->InvalidateLayer(nsDisplayItem::TYPE_REMOTE);
|
2012-07-17 16:59:45 -07:00
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
uint64_t
|
|
|
|
RenderFrameParent::GetLayerTreeId() const
|
|
|
|
{
|
2012-07-17 16:59:45 -07:00
|
|
|
return mLayersId;
|
2012-07-17 16:59:45 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void
|
2011-01-13 09:45:14 -08:00
|
|
|
RenderFrameParent::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsSubDocumentFrame* aFrame,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
// We're the subdoc for <browser remote="true"> and it has
|
|
|
|
// painted content. Display its shadow layer tree.
|
2013-04-04 04:36:45 -07:00
|
|
|
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
|
2013-03-04 01:56:02 -08:00
|
|
|
|
|
|
|
nsPoint offset = aBuilder->ToReferenceFrame(aFrame);
|
|
|
|
nsRect bounds = aFrame->EnsureInnerView()->GetBounds() + offset;
|
2013-04-04 04:36:45 -07:00
|
|
|
clipState.ClipContentDescendants(bounds);
|
2013-03-04 01:56:02 -08:00
|
|
|
|
2014-08-21 17:16:44 -07:00
|
|
|
aLists.Content()->AppendToTop(
|
|
|
|
new (aBuilder) nsDisplayRemote(aBuilder, aFrame, this));
|
2011-01-13 09:45:14 -08:00
|
|
|
}
|
|
|
|
|
2012-08-08 21:39:02 -07:00
|
|
|
void
|
2013-11-13 10:20:30 -08:00
|
|
|
RenderFrameParent::ZoomToRect(uint32_t aPresShellId, ViewID aViewId,
|
|
|
|
const CSSRect& aRect)
|
2012-08-08 21:39:02 -07:00
|
|
|
{
|
2013-07-30 11:03:40 -07:00
|
|
|
if (GetApzcTreeManager()) {
|
2013-11-13 10:20:30 -08:00
|
|
|
GetApzcTreeManager()->ZoomToRect(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
|
2013-07-30 11:03:40 -07:00
|
|
|
aRect);
|
2012-08-08 21:39:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-21 21:37:06 -07:00
|
|
|
void
|
2013-11-13 10:20:31 -08:00
|
|
|
RenderFrameParent::ContentReceivedTouch(const ScrollableLayerGuid& aGuid,
|
|
|
|
bool aPreventDefault)
|
2012-08-21 21:37:06 -07:00
|
|
|
{
|
2014-02-21 14:58:30 -08:00
|
|
|
if (aGuid.mLayersId != mLayersId) {
|
|
|
|
// Guard against bad data from hijacked child processes
|
|
|
|
NS_ERROR("Unexpected layers id in ContentReceivedTouch; dropping message...");
|
|
|
|
return;
|
|
|
|
}
|
2013-07-30 11:03:40 -07:00
|
|
|
if (GetApzcTreeManager()) {
|
2013-11-13 10:20:31 -08:00
|
|
|
GetApzcTreeManager()->ContentReceivedTouch(aGuid, aPreventDefault);
|
2012-08-21 21:37:06 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-28 19:18:18 -07:00
|
|
|
void
|
2013-11-14 09:35:41 -08:00
|
|
|
RenderFrameParent::UpdateZoomConstraints(uint32_t aPresShellId,
|
|
|
|
ViewID aViewId,
|
2013-11-08 16:07:00 -08:00
|
|
|
bool aIsRoot,
|
2014-01-06 10:26:44 -08:00
|
|
|
const ZoomConstraints& aConstraints)
|
2012-09-28 19:18:18 -07:00
|
|
|
{
|
2013-11-08 16:07:00 -08:00
|
|
|
if (mContentController && aIsRoot) {
|
2014-01-06 10:26:44 -08:00
|
|
|
mContentController->SaveZoomConstraints(aConstraints);
|
2013-09-13 07:18:33 -07:00
|
|
|
}
|
2013-07-30 11:03:40 -07:00
|
|
|
if (GetApzcTreeManager()) {
|
2013-11-14 09:35:41 -08:00
|
|
|
GetApzcTreeManager()->UpdateZoomConstraints(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
|
2014-01-06 10:26:44 -08:00
|
|
|
aConstraints);
|
2012-09-28 19:18:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-13 00:56:57 -07:00
|
|
|
bool
|
|
|
|
RenderFrameParent::HitTest(const nsRect& aRect)
|
|
|
|
{
|
|
|
|
return mTouchRegion.Contains(aRect);
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
} // namespace layout
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
already_AddRefed<Layer>
|
|
|
|
nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 05:11:27 -07:00
|
|
|
LayerManager* aManager,
|
2013-09-26 23:01:16 -07:00
|
|
|
const ContainerLayerParameters& aContainerParameters)
|
2010-08-20 16:24:41 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
2010-10-13 15:55:45 -07:00
|
|
|
nsIntRect visibleRect = GetVisibleRect().ToNearestPixels(appUnitsPerDevPixel);
|
2012-09-16 15:25:33 -07:00
|
|
|
visibleRect += aContainerParameters.mOffset;
|
|
|
|
nsRefPtr<Layer> layer = mRemoteFrame->BuildLayer(aBuilder, mFrame, aManager, visibleRect, this, aContainerParameters);
|
2010-08-20 16:24:41 -07:00
|
|
|
return layer.forget();
|
|
|
|
}
|
2011-01-13 09:45:14 -08:00
|
|
|
|
2013-08-13 00:56:57 -07:00
|
|
|
void
|
|
|
|
nsDisplayRemote::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
|
|
|
{
|
|
|
|
if (mRemoteFrame->HitTest(aRect)) {
|
|
|
|
aOutFrames->AppendElement(mFrame);
|
|
|
|
}
|
|
|
|
}
|
2011-01-13 09:45:14 -08:00
|
|
|
|