2010-08-20 23:24:41 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 11:12:37 +00: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 23:24:41 +00:00
|
|
|
|
|
|
|
#ifndef mozilla_layout_RenderFrameParent_h
|
|
|
|
#define mozilla_layout_RenderFrameParent_h
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-20 06:48:27 +00:00
|
|
|
#include <map>
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
#include "mozilla/layout/PRenderFrameParent.h"
|
2012-01-19 14:45:37 +00:00
|
|
|
#include "mozilla/layers/ShadowLayersManager.h"
|
2010-08-20 23:24:41 +00:00
|
|
|
#include "nsDisplayList.h"
|
2012-07-20 06:48:27 +00:00
|
|
|
#include "RenderFrameUtils.h"
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
class nsContentView;
|
2010-08-20 23:24:41 +00:00
|
|
|
class nsFrameLoader;
|
2011-01-13 17:45:14 +00:00
|
|
|
class nsSubDocumentFrame;
|
2010-08-20 23:24:41 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2011-01-13 17:45:14 +00:00
|
|
|
|
2012-07-20 06:48:27 +00:00
|
|
|
class InputEvent;
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
namespace layers {
|
2012-07-20 06:48:27 +00:00
|
|
|
class AsyncPanZoomController;
|
|
|
|
class GestureEventListener;
|
2012-07-24 19:01:09 +00:00
|
|
|
class TargetConfig;
|
2010-08-20 23:24:41 +00:00
|
|
|
class ShadowLayersParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace layout {
|
|
|
|
|
2012-07-20 06:48:27 +00:00
|
|
|
class RemoteContentController;
|
|
|
|
|
2012-01-19 14:45:37 +00:00
|
|
|
class RenderFrameParent : public PRenderFrameParent,
|
|
|
|
public mozilla::layers::ShadowLayersManager
|
2010-08-20 23:24:41 +00:00
|
|
|
{
|
2011-01-13 17:45:14 +00:00
|
|
|
typedef mozilla::layers::FrameMetrics FrameMetrics;
|
2010-08-20 23:24:41 +00:00
|
|
|
typedef mozilla::layers::ContainerLayer ContainerLayer;
|
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
2012-07-24 19:01:09 +00:00
|
|
|
typedef mozilla::layers::TargetConfig TargetConfig;
|
2010-08-20 23:24:41 +00:00
|
|
|
typedef mozilla::layers::ShadowLayersParent ShadowLayersParent;
|
2012-09-16 22:25:33 +00:00
|
|
|
typedef mozilla::FrameLayerBuilder::ContainerParameters ContainerParameters;
|
2011-01-13 17:45:14 +00:00
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
2010-08-20 23:24:41 +00:00
|
|
|
|
|
|
|
public:
|
2011-01-13 17:45:14 +00:00
|
|
|
typedef std::map<ViewID, nsRefPtr<nsContentView> > ViewMap;
|
|
|
|
|
2012-07-20 06:48:27 +00:00
|
|
|
/**
|
|
|
|
* Select the desired scrolling behavior. If ASYNC_PAN_ZOOM is
|
|
|
|
* chosen, then RenderFrameParent will watch input events and use
|
|
|
|
* them to asynchronously pan and zoom.
|
|
|
|
*/
|
2012-07-17 23:59:45 +00:00
|
|
|
RenderFrameParent(nsFrameLoader* aFrameLoader,
|
2012-07-20 06:48:27 +00:00
|
|
|
ScrollingBehavior aScrollingBehavior,
|
2012-07-18 16:31:40 +00:00
|
|
|
mozilla::layers::LayersBackend* aBackendType,
|
2012-07-17 23:59:45 +00:00
|
|
|
int* aMaxTextureSize,
|
|
|
|
uint64_t* aId);
|
2010-08-20 23:24:41 +00:00
|
|
|
virtual ~RenderFrameParent();
|
|
|
|
|
2011-01-06 04:54:47 +00:00
|
|
|
void Destroy();
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
/**
|
|
|
|
* Helper function for getting a non-owning reference to a scrollable.
|
|
|
|
* @param aId The ID of the frame.
|
|
|
|
*/
|
|
|
|
nsContentView* GetContentView(ViewID aId = FrameMetrics::ROOT_SCROLL_ID);
|
|
|
|
|
2011-07-18 18:04:47 +00:00
|
|
|
void ContentViewScaleChanged(nsContentView* aView);
|
|
|
|
|
2012-07-17 23:59:44 +00:00
|
|
|
virtual void ShadowLayersUpdated(ShadowLayersParent* aLayerTree,
|
2012-07-24 19:01:09 +00:00
|
|
|
const TargetConfig& aTargetConfig,
|
2012-07-17 23:59:44 +00:00
|
|
|
bool isFirstPaint) MOZ_OVERRIDE;
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsSubDocumentFrame* aFrame,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
2011-01-13 17:45:14 +00:00
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
2010-10-13 22:55:45 +00:00
|
|
|
LayerManager* aManager,
|
2012-08-07 03:00:41 +00:00
|
|
|
const nsIntRect& aVisibleRect,
|
2012-09-16 22:25:33 +00:00
|
|
|
nsDisplayItem* aItem,
|
|
|
|
const ContainerParameters& aContainerParameters);
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
void OwnerContentChanged(nsIContent* aContent);
|
|
|
|
|
2011-10-20 22:17:09 +00:00
|
|
|
void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); };
|
|
|
|
|
2013-04-05 07:40:13 +00:00
|
|
|
void NotifyInputEvent(const nsInputEvent& aEvent);
|
|
|
|
|
|
|
|
void ApplyZoomCompensationToEvent(nsInputEvent* aEvent);
|
2012-07-20 06:48:27 +00:00
|
|
|
|
|
|
|
void NotifyDimensionsChanged(int width, int height);
|
|
|
|
|
2012-08-09 04:39:02 +00:00
|
|
|
void ZoomToRect(const gfxRect& aRect);
|
|
|
|
|
2012-08-22 04:37:06 +00:00
|
|
|
void ContentReceivedTouch(bool aPreventDefault);
|
|
|
|
|
2012-09-29 02:18:18 +00:00
|
|
|
void UpdateZoomConstraints(bool aAllowZoom, float aMinZoom, float aMaxZoom);
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
protected:
|
2012-07-17 23:59:45 +00:00
|
|
|
void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
virtual bool RecvNotifyCompositorTransaction() MOZ_OVERRIDE;
|
|
|
|
|
2012-08-08 20:38:06 +00:00
|
|
|
virtual bool RecvCancelDefaultPanZoom() MOZ_OVERRIDE;
|
2013-01-05 14:53:16 +00:00
|
|
|
virtual bool RecvDetectScrollableSubframe() MOZ_OVERRIDE;
|
2012-08-08 20:38:06 +00:00
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
virtual PLayersParent* AllocPLayers() MOZ_OVERRIDE;
|
2012-07-17 23:59:45 +00:00
|
|
|
virtual bool DeallocPLayers(PLayersParent* aLayers) MOZ_OVERRIDE;
|
2010-08-20 23:24:41 +00:00
|
|
|
|
|
|
|
private:
|
2011-01-13 17:45:14 +00:00
|
|
|
void BuildViewMap();
|
2012-07-17 23:59:45 +00:00
|
|
|
void TriggerRepaint();
|
2012-07-20 06:48:27 +00:00
|
|
|
void DispatchEventForPanZoomController(const InputEvent& aEvent);
|
2011-01-13 17:45:14 +00:00
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
ShadowLayersParent* GetShadowLayers() const;
|
2012-07-17 23:59:45 +00:00
|
|
|
uint64_t GetLayerTreeId() const;
|
2010-09-03 20:10:45 +00:00
|
|
|
ContainerLayer* GetRootLayer() const;
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
// When our child frame is pushing transactions directly to the
|
|
|
|
// compositor, this is the ID of its layer tree in the compositor's
|
|
|
|
// context.
|
|
|
|
uint64_t mLayersId;
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
nsRefPtr<nsFrameLoader> mFrameLoader;
|
|
|
|
nsRefPtr<ContainerLayer> mContainer;
|
2012-07-20 06:48:27 +00:00
|
|
|
// When our scrolling behavior is ASYNC_PAN_ZOOM, we have a nonnull
|
|
|
|
// AsyncPanZoomController. It's associated with the shadow layer
|
|
|
|
// tree on the compositor thread.
|
|
|
|
nsRefPtr<layers::AsyncPanZoomController> mPanZoomController;
|
|
|
|
nsRefPtr<RemoteContentController> mContentController;
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
// This contains the views for all the scrollable frames currently in the
|
|
|
|
// painted region of our remote content.
|
|
|
|
ViewMap mContentViews;
|
2011-09-27 18:35:23 +00:00
|
|
|
|
|
|
|
// True after Destroy() has been called, which is triggered
|
|
|
|
// originally by nsFrameLoader::Destroy(). After this point, we can
|
|
|
|
// no longer safely ask the frame loader to find its nearest layer
|
|
|
|
// manager, because it may have been disconnected from the DOM.
|
|
|
|
// It's still OK to *tell* the frame loader that we've painted after
|
|
|
|
// it's destroyed; it'll just ignore us, and we won't be able to
|
|
|
|
// find an nsIFrame to invalidate. See ShadowLayersUpdated().
|
|
|
|
//
|
|
|
|
// Prefer the extra bit of state to null'ing out mFrameLoader in
|
|
|
|
// Destroy() so that less code needs to be special-cased for after
|
|
|
|
// Destroy().
|
|
|
|
//
|
|
|
|
// It's possible for mFrameLoader==null and
|
|
|
|
// mFrameLoaderDestroyed==false.
|
|
|
|
bool mFrameLoaderDestroyed;
|
2011-10-20 22:17:09 +00:00
|
|
|
// this is gfxRGBA because that's what ColorLayer wants.
|
|
|
|
gfxRGBA mBackgroundColor;
|
2010-08-20 23:24:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layout
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A DisplayRemote exists solely to graft a child process's shadow
|
|
|
|
* layer tree (for a given RenderFrameParent) into its parent
|
|
|
|
* process's layer tree.
|
|
|
|
*/
|
|
|
|
class nsDisplayRemote : public nsDisplayItem
|
|
|
|
{
|
|
|
|
typedef mozilla::layout::RenderFrameParent RenderFrameParent;
|
|
|
|
|
|
|
|
public:
|
2010-08-24 03:23:37 +00:00
|
|
|
nsDisplayRemote(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
RenderFrameParent* aRemoteFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame)
|
2010-08-20 23:24:41 +00:00
|
|
|
, mRemoteFrame(aRemoteFrame)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 14:05:55 +00:00
|
|
|
LayerManager* aManager,
|
2012-07-06 18:15:45 +00:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE
|
2012-07-23 03:00:36 +00:00
|
|
|
{ return mozilla::LAYER_ACTIVE_FORCE; }
|
2010-08-20 23:24:41 +00:00
|
|
|
|
|
|
|
virtual already_AddRefed<Layer>
|
2011-06-22 12:11:27 +00:00
|
|
|
BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager,
|
2012-07-06 18:15:45 +00:00
|
|
|
const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
|
2010-08-20 23:24:41 +00:00
|
|
|
|
|
|
|
NS_DISPLAY_DECL_NAME("Remote", TYPE_REMOTE)
|
|
|
|
|
|
|
|
private:
|
|
|
|
RenderFrameParent* mRemoteFrame;
|
|
|
|
};
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
/**
|
|
|
|
* nsDisplayRemoteShadow is a way of adding display items for frames in a
|
|
|
|
* separate process, for hit testing only. After being processed, the hit
|
|
|
|
* test state will contain IDs for any remote frames that were hit.
|
|
|
|
*
|
|
|
|
* The frame should be its respective render frame parent.
|
|
|
|
*/
|
|
|
|
class nsDisplayRemoteShadow : public nsDisplayItem
|
|
|
|
{
|
|
|
|
typedef mozilla::layout::RenderFrameParent RenderFrameParent;
|
|
|
|
typedef mozilla::layers::FrameMetrics::ViewID ViewID;
|
|
|
|
|
|
|
|
public:
|
|
|
|
nsDisplayRemoteShadow(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsRect aRect,
|
|
|
|
ViewID aId)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame)
|
|
|
|
, mRect(aRect)
|
|
|
|
, mId(aId)
|
|
|
|
{}
|
|
|
|
|
2012-07-06 18:15:45 +00:00
|
|
|
nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE
|
2011-01-13 17:45:14 +00:00
|
|
|
{
|
2012-04-10 11:24:18 +00:00
|
|
|
*aSnap = false;
|
2011-01-13 17:45:14 +00:00
|
|
|
return mRect;
|
|
|
|
}
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual uint32_t GetPerFrameKey() MOZ_OVERRIDE
|
2011-01-13 17:45:14 +00:00
|
|
|
{
|
|
|
|
NS_ABORT();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-06 18:15:45 +00:00
|
|
|
void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
NS_DISPLAY_DECL_NAME("Remote-Shadow", TYPE_REMOTE_SHADOW)
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRect mRect;
|
|
|
|
ViewID mId;
|
|
|
|
};
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
#endif // mozilla_layout_RenderFrameParent_h
|