mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
18084d9cce
- Add legacycollector.org to add-ons whitelist (dc69faacb) - Bug 1112469 - Part 1: Implement an XPCOM service responsible to trigger daily updates of service workers; r=nsm (74f735500) - Bug 1133601 - Implement about:serviceworkers, r=ehsan (e21767ec1) - Bug 1038811 - Push Notifications - Move old push to simplepush. (14b0a1547) - Bug 1041339 - ServiceWorkers: Update implementation based on clarification of force-refresh. r=nsm (484675660) - Bug 1154547 - Part 1: Linkify the worker script URLs in about:serviceworkers; r=baku (db2097fa7) - Bug 1154547 - Part 2: Make it possible to update a service worker from about:serviceworkers; r=baku (03d7363aa) - Bug 1154721 - Add an Unregister button to about:serviceworkers, r=ehsan (7b5a9873f) - Bug 1156052 - Add push information to about:serviceworkers. r=baku (995f5b1d3) - Bug 1158811 - remove the flickering in about:serviceworkers, r=ehsan (70a4cb1bc) - Bug 1158361 - Improve the localized messages in about:serviceworkers, r=ehsan, f=stef (751202c01) - Bug 1151664 - Make claim return undefined for now. r=nsm (84f36584b) - Bug 1142693 - Recognize EMSGSIZE as non-fatal on OS X for IPC sendmsg(). r=bent (c133bb505) - Bug 1150916 - Non-unified bustage follow-up fix. (19adaff8b) - Bug 1151607 - Step 1: Add Linux sandboxing hook for when child processes are still single-threaded. r=kang r=bent (e5e67f4b1) - Bug 1151607 - Step 1.5: Avoid unlikely false positives in Linux SandboxInfo feature detection. r=kang (944805781) - Bug 1151607 - Step 2: Apply net/ipc namespace separation and chroot to media plugins. r=kang (3dc0e575f) - Bug 1151607 - Step 0: sort includes to make the following patches cleaner. r=kang (9b918989b) - Bug 1038811 - Push Notifications - Firefox front end changes for preferences, and permission notification. r=MattN+bmo@mozilla.com (fdb4c7636) - (adapted) Bug 1147281 - Shared browser notification icon CSS. r=MattN (2243c83a1) - Bug 1123523 - Part 1: Add an nsIAnimationObserver interface to watch adding/changing/removing AnimationPlayer objects. r=smaug (d889e512c) - Bug 1123523 - Part 2: Add an animations option for MutationObservers and expose chrome-only animation members on MutationRecords. r=smaug (6c9622c0f) - Bug 1123523 - Part 3: Store a flag on AnimationPlayer for whether it is exposed by Element.getAnimationPlayers(). r=birtles (d146779c0) - Bug 1123523 - Part 4: Add macro for notifying observers only when they implement a specific derived interface. r=smaug (38714002f) - Bug 1123523 - Part 5: Record on a document whether it might have any nsIAnimationObservers registered. r=smaug (585e30299) - Bug 1123523 - Part 6: Listen for nsIAnimationObserver notifications and translate them to MutationObserver notifications. r=smaug (9980c91e5) - Bug 1123523 - Part 7: Add utility functions to notify registered nsIAnimationObservers. r=smaug (82d3a15cf) - Bug 1123523 - Part 8: Dispatch nsIAnimationObserver notifications when an animation is added or removed. r=birtles (056b8bf7a) - Bug 1123523 - Part 9: Dispatch an nsIAnimationObserver notification when an animation is changed. r=birtles (5787cdbc1) - Bug 1123523 - Part 10: Tests. r=birtles (d134aa3b0) - Bug 1123523 - Followup build fix. (b88bae25d) - Bug 1137515 part 1 - Change to configure.in r=mwu (150534251) - Bug 1136065 - Remove GetRangeCount() in Selection.h. r=ehsan (bd35dba49) - Bug 1129249 - Expose the element id in Gecko profiler for Restyle. r=dholbert r=benwa (77231d128) - Bug 979293 - Add a FrozenAtomSet to clarify how |permanentAtoms| works. r=bhackett. (1c4ca9315) - Bug 979293 - Don't write collision bits in HashTable unnecessarily. r=luke. (c42ebc7b5) - Bug 1135200: Hook up nsCSSParser's pref-backed bool variables in a startup method. r=heycam (e129dcfc8) - Bug 1107378 - Part 1: Create a JS-implemented "CSS Unprefixing Service" that can convert certain -webkit prefixed CSS to an unprefixed form. r=dbaron (c860167d2) - Bug 1107378 - Part 2: Make the CSS Parser call out to the unprefixing service, when it detects a vendor-prefixed property name (if pref is enabled). r=dbaron (1fe4e48dd) - Bug 1107378 - Part 3: In cases where we're unprefixing, treat "display:-webkit-box" as "display: flex" (& same for "-moz-box" if we previously saw "-webkit-box"). r=dbaron (00299fb08) - Bug 1107378 - Part 4: Add mochitest for our CSS unprefixing functionality. r=dbaron (95a0e6c41) - Bug 1132743: Only allow CSS Unprefixing Service to be activated for hosts on a small, hardcoded whitelist. r=dbaron f=bz (6afd0dd07) - Bug 1132743 followup: hook up nsPrincipal.cpp's gCodeBasePrincipalSupport in new InitializeStatics method, instead of lazily. implicit rs=dbaron (7223553f1) - Bug 1124503 move AppConstants.jsm to toolkit r=gavin (0a90334ff) - Bug 1130195: Report the failed bitmap creation, but still crash. (9e8c8fcde) - Bug 1136241 - making sure that hint/role strings are returned with no spaces to support localization. r=eeejay (665243ab4) - Bug 1127084 - Remove __iterator__ from ContentPrefStore. (126621dbf) - Bug 1133449 - [B2G] The default audio type didn't be set correctly when the call screen app is launched. r=baku (0470b702a) - Bug 1133449 - [B2G] The default audio type didn't be set correctly when the call screen app is launched. r=baku (016b84983) - Bug 1130175 - nICEr: avoid sysctl.h include. r=bwc (5446f87d1) - Bug 794984 - [mozprocess] Add ability to separate stderr from stdout. r=ahal (9388e0e08) - Bug 1136803 - Properly remove the force-dtc override flag on retained layers when listeners are removed. r=botond (1047b11a7) - Bug 1134493 - Ensure we don't set the force-empty-hit-region flag when a subdocument has mozpasspointerevents. r=botond (fda5e8176) - Bug 1136487: Destroy the compositors for all windows when any window detects a device reset. r=jrmuizel (22d45787c) - bits of Bug 1135773 - Initialize QI return values to null in the cycle collector. (rest was already part of 1119482 (6f30ef196) - Bug 1135772 - Return null on failure in nsXPCWrappedJS's QueryInterface. r=smaug (67fca5218) - Bug 1136584 - Copy JIT options from global settings. r=bhackett (6696b345e) - Bug 1135912 - Don't repaint vibrant regions on mouseover. (1de120955) - Bug 961887 - Refactor mVisibleAboveRegion management. r=roc (8281fb9f8) - Bug 961887 - Make FindOpaqueBackgroundColorFor take a region instead of a PaintedLayerData. r=roc (f42ddc1a1) - Bug 961887 - Find uniform opaque background colors under ContainerLayers. r=roc (7378892b8)
680 lines
23 KiB
C++
680 lines
23 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* vim: sw=2 ts=8 et :
|
|
*/
|
|
/* 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/. */
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "BasicLayers.h"
|
|
#include "gfxPrefs.h"
|
|
#ifdef MOZ_ENABLE_D3D9_LAYER
|
|
# include "LayerManagerD3D9.h"
|
|
#endif //MOZ_ENABLE_D3D9_LAYER
|
|
#include "mozilla/BrowserElementParent.h"
|
|
#include "mozilla/EventForwards.h" // for Modifiers
|
|
#include "mozilla/dom/ContentChild.h"
|
|
#include "mozilla/dom/TabParent.h"
|
|
#include "mozilla/layers/APZCTreeManager.h"
|
|
#include "mozilla/layers/APZThreadUtils.h"
|
|
#include "mozilla/layers/CompositorParent.h"
|
|
#include "mozilla/layers/LayerTransactionParent.h"
|
|
#include "nsContentUtils.h"
|
|
#include "nsFocusManager.h"
|
|
#include "nsFrameLoader.h"
|
|
#include "nsIObserver.h"
|
|
#include "nsStyleStructInlines.h"
|
|
#include "nsSubDocumentFrame.h"
|
|
#include "nsView.h"
|
|
#include "nsViewportFrame.h"
|
|
#include "RenderFrameParent.h"
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
|
#include "mozilla/layers/CompositorChild.h"
|
|
#include "ClientLayerManager.h"
|
|
#include "FrameLayerBuilder.h"
|
|
|
|
using namespace mozilla::dom;
|
|
using namespace mozilla::gfx;
|
|
using namespace mozilla::layers;
|
|
|
|
namespace mozilla {
|
|
namespace layout {
|
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
|
|
|
/**
|
|
* 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).
|
|
*/
|
|
static nsIntPoint
|
|
GetContentRectLayerOffset(nsIFrame* aContainerFrame, nsDisplayListBuilder* aBuilder)
|
|
{
|
|
nscoord auPerDevPixel = aContainerFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
// Offset to the content rect in case we have borders or padding
|
|
// 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) +
|
|
aContainerFrame->GetContentRectRelativeToSelf().TopLeft();
|
|
|
|
return frameOffset.ToNearestPixels(auPerDevPixel);
|
|
}
|
|
|
|
// 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.
|
|
inline static bool
|
|
IsTempLayerManager(LayerManager* aManager)
|
|
{
|
|
return (mozilla::layers::LayersBackend::LAYERS_BASIC == aManager->GetBackendType() &&
|
|
!static_cast<BasicLayerManager*>(aManager)->IsRetained());
|
|
}
|
|
|
|
already_AddRefed<LayerManager>
|
|
GetFrom(nsFrameLoader* aFrameLoader)
|
|
{
|
|
nsIDocument* doc = aFrameLoader->GetOwnerDoc();
|
|
if (!doc) {
|
|
return nullptr;
|
|
}
|
|
return nsContentUtils::LayerManagerForDocument(doc);
|
|
}
|
|
|
|
class RemoteContentController : public GoannaContentController {
|
|
public:
|
|
explicit RemoteContentController(RenderFrameParent* aRenderFrame)
|
|
: mUILoop(MessageLoop::current())
|
|
, mRenderFrame(aRenderFrame)
|
|
, mHaveZoomConstraints(false)
|
|
{ }
|
|
|
|
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) override
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->UpdateFrame(aFrameMetrics);
|
|
}
|
|
}
|
|
|
|
virtual void RequestFlingSnap(const FrameMetrics::ViewID& aScrollId,
|
|
const mozilla::CSSPoint& aDestination) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::RequestFlingSnap,
|
|
aScrollId, aDestination));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->RequestFlingSnap(aScrollId, aDestination);
|
|
}
|
|
}
|
|
|
|
virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
|
|
const uint32_t& aScrollGeneration) 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 = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
|
|
}
|
|
}
|
|
|
|
virtual void HandleDoubleTap(const CSSPoint& aPoint,
|
|
Modifiers aModifiers,
|
|
const ScrollableLayerGuid& aGuid) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::HandleDoubleTap,
|
|
aPoint, aModifiers, aGuid));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->HandleDoubleTap(aPoint, aModifiers, aGuid);
|
|
}
|
|
}
|
|
|
|
virtual void HandleSingleTap(const CSSPoint& aPoint,
|
|
Modifiers aModifiers,
|
|
const ScrollableLayerGuid& aGuid) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::HandleSingleTap,
|
|
aPoint, aModifiers, aGuid));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
mRenderFrame->TakeFocusForClick();
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->HandleSingleTap(aPoint, aModifiers, aGuid);
|
|
}
|
|
}
|
|
|
|
virtual void HandleLongTap(const CSSPoint& aPoint,
|
|
Modifiers aModifiers,
|
|
const ScrollableLayerGuid& aGuid,
|
|
uint64_t aInputBlockId) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::HandleLongTap,
|
|
aPoint, aModifiers, aGuid, aInputBlockId));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->HandleLongTap(aPoint, aModifiers, aGuid, aInputBlockId);
|
|
}
|
|
}
|
|
|
|
virtual void HandleLongTapUp(const CSSPoint& aPoint,
|
|
Modifiers aModifiers,
|
|
const ScrollableLayerGuid& aGuid) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
// We have to send this message from the "UI thread" (main
|
|
// thread).
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::HandleLongTapUp,
|
|
aPoint, aModifiers, aGuid));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->HandleLongTapUp(aPoint, aModifiers, aGuid);
|
|
}
|
|
}
|
|
|
|
void ClearRenderFrame() { mRenderFrame = nullptr; }
|
|
|
|
virtual void SendAsyncScrollDOMEvent(bool aIsRoot,
|
|
const CSSRect& aContentRect,
|
|
const CSSSize& aContentSize) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this,
|
|
&RemoteContentController::SendAsyncScrollDOMEvent,
|
|
aIsRoot, aContentRect, aContentSize));
|
|
return;
|
|
}
|
|
if (mRenderFrame && aIsRoot) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
BrowserElementParent::DispatchAsyncScrollEvent(browser, aContentRect,
|
|
aContentSize);
|
|
}
|
|
}
|
|
|
|
virtual void PostDelayedTask(Task* aTask, int aDelayMs) override
|
|
{
|
|
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
|
|
}
|
|
|
|
virtual bool GetRootZoomConstraints(ZoomConstraints* aOutConstraints) override
|
|
{
|
|
if (mHaveZoomConstraints && aOutConstraints) {
|
|
*aOutConstraints = mZoomConstraints;
|
|
}
|
|
return mHaveZoomConstraints;
|
|
}
|
|
|
|
virtual bool GetTouchSensitiveRegion(CSSRect* aOutRegion) override
|
|
{
|
|
if (mTouchSensitiveRegion.IsEmpty())
|
|
return false;
|
|
|
|
*aOutRegion = CSSRect::FromAppUnits(mTouchSensitiveRegion.GetBounds());
|
|
return true;
|
|
}
|
|
|
|
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
|
|
APZStateChange aChange,
|
|
int aArg) override
|
|
{
|
|
if (MessageLoop::current() != mUILoop) {
|
|
mUILoop->PostTask(
|
|
FROM_HERE,
|
|
NewRunnableMethod(this, &RemoteContentController::NotifyAPZStateChange,
|
|
aGuid, aChange, aArg));
|
|
return;
|
|
}
|
|
if (mRenderFrame) {
|
|
TabParent* browser = TabParent::GetFrom(mRenderFrame->Manager());
|
|
browser->NotifyAPZStateChange(aGuid.mScrollId, aChange, aArg);
|
|
}
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
private:
|
|
MessageLoop* mUILoop;
|
|
RenderFrameParent* mRenderFrame;
|
|
|
|
bool mHaveZoomConstraints;
|
|
ZoomConstraints mZoomConstraints;
|
|
nsRegion mTouchSensitiveRegion;
|
|
};
|
|
|
|
RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
|
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
|
uint64_t* aId,
|
|
bool* aSuccess)
|
|
: mLayersId(0)
|
|
, mFrameLoader(aFrameLoader)
|
|
, mFrameLoaderDestroyed(false)
|
|
, mBackgroundColor(gfxRGBA(1, 1, 1))
|
|
{
|
|
*aSuccess = false;
|
|
if (!mFrameLoader) {
|
|
return;
|
|
}
|
|
|
|
*aId = 0;
|
|
|
|
nsRefPtr<LayerManager> lm = GetFrom(mFrameLoader);
|
|
// Perhaps the document containing this frame currently has no presentation?
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
*aTextureFactoryIdentifier =
|
|
static_cast<ClientLayerManager*>(lm.get())->GetTextureFactoryIdentifier();
|
|
} else {
|
|
*aTextureFactoryIdentifier = TextureFactoryIdentifier();
|
|
}
|
|
|
|
if (XRE_GetProcessType() == GoannaProcessType_Default) {
|
|
// Our remote frame will push layers updates to the compositor,
|
|
// and we'll keep an indirect reference to that tree.
|
|
*aId = mLayersId = CompositorParent::AllocateLayerTreeId();
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
ClientLayerManager *clientManager =
|
|
static_cast<ClientLayerManager*>(lm.get());
|
|
clientManager->GetRemoteRenderer()->SendNotifyChildCreated(mLayersId);
|
|
}
|
|
if (gfxPrefs::AsyncPanZoomEnabled()) {
|
|
mContentController = new RemoteContentController(this);
|
|
CompositorParent::SetControllerForLayerTree(mLayersId, mContentController);
|
|
}
|
|
} else if (XRE_GetProcessType() == GoannaProcessType_Content) {
|
|
ContentChild::GetSingleton()->SendAllocateLayerTreeId(aId);
|
|
mLayersId = *aId;
|
|
CompositorChild::Get()->SendNotifyChildCreated(mLayersId);
|
|
}
|
|
// Set a default RenderFrameParent
|
|
mFrameLoader->SetCurrentRemoteFrame(this);
|
|
*aSuccess = true;
|
|
}
|
|
|
|
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 && gfxPrefs::AsyncPanZoomEnabled()) {
|
|
mApzcTreeManager = CompositorParent::GetAPZCTreeManager(mLayersId);
|
|
}
|
|
return mApzcTreeManager.get();
|
|
}
|
|
|
|
RenderFrameParent::~RenderFrameParent()
|
|
{}
|
|
|
|
void
|
|
RenderFrameParent::Destroy()
|
|
{
|
|
mFrameLoaderDestroyed = true;
|
|
}
|
|
|
|
already_AddRefed<Layer>
|
|
RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
nsIFrame* aFrame,
|
|
LayerManager* aManager,
|
|
const nsIntRect& aVisibleRect,
|
|
nsDisplayItem* aItem,
|
|
const ContainerLayerParameters& aContainerParameters)
|
|
{
|
|
MOZ_ASSERT(aFrame,
|
|
"makes no sense to have a shadow tree without a frame");
|
|
MOZ_ASSERT(!mContainer ||
|
|
IsTempLayerManager(aManager) ||
|
|
mContainer->Manager() == aManager,
|
|
"retaining manager changed out from under us ... HELP!");
|
|
|
|
if (IsTempLayerManager(aManager) ||
|
|
(mContainer && mContainer->Manager() != aManager)) {
|
|
// 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 the
|
|
// MOZ_ASSERT() above will flag it. Returning nullptr here will just
|
|
// cause the shadow subtree not to be rendered.
|
|
NS_WARNING("Remote iframe not rendered");
|
|
return nullptr;
|
|
}
|
|
|
|
uint64_t id = GetLayerTreeId();
|
|
if (!id) {
|
|
return nullptr;
|
|
}
|
|
|
|
nsRefPtr<Layer> layer =
|
|
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
|
|
if (!layer) {
|
|
layer = aManager->CreateRefLayer();
|
|
}
|
|
if (!layer) {
|
|
// Probably a temporary layer manager that doesn't know how to
|
|
// use ref layers.
|
|
return nullptr;
|
|
}
|
|
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());
|
|
gfx::Matrix4x4 m = gfx::Matrix4x4::Translation(offset.x, offset.y, 0.0);
|
|
// Remote content can't be repainted by us, so we multiply down
|
|
// the resolution that our container expects onto our container.
|
|
m.PreScale(aContainerParameters.mXScale, aContainerParameters.mYScale, 1.0);
|
|
layer->SetBaseTransform(m);
|
|
|
|
return layer.forget();
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::OwnerContentChanged(nsIContent* aContent)
|
|
{
|
|
MOZ_ASSERT(mFrameLoader->GetOwnerContent() == aContent,
|
|
"Don't build new map if owner is same!");
|
|
|
|
nsRefPtr<LayerManager> lm = GetFrom(mFrameLoader);
|
|
// Perhaps the document containing this frame currently has no presentation?
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
ClientLayerManager *clientManager =
|
|
static_cast<ClientLayerManager*>(lm.get());
|
|
clientManager->GetRemoteRenderer()->SendAdoptChild(mLayersId);
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::ActorDestroy(ActorDestroyReason why)
|
|
{
|
|
if (mLayersId != 0) {
|
|
if (XRE_GetProcessType() == GoannaProcessType_Content) {
|
|
ContentChild::GetSingleton()->SendDeallocateLayerTreeId(mLayersId);
|
|
} else {
|
|
CompositorParent::DeallocateLayerTreeId(mLayersId);
|
|
}
|
|
if (mContentController) {
|
|
// Stop our content controller from requesting repaints of our
|
|
// content.
|
|
mContentController->ClearRenderFrame();
|
|
// TODO: notify the compositor?
|
|
}
|
|
}
|
|
|
|
if (mFrameLoader && mFrameLoader->GetCurrentRemoteFrame() == this) {
|
|
// 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.
|
|
mFrameLoader->SetCurrentRemoteFrame(nullptr);
|
|
}
|
|
mFrameLoader = nullptr;
|
|
}
|
|
|
|
bool
|
|
RenderFrameParent::RecvNotifyCompositorTransaction()
|
|
{
|
|
TriggerRepaint();
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
RenderFrameParent::RecvUpdateHitRegion(const nsRegion& aRegion)
|
|
{
|
|
mTouchRegion = aRegion;
|
|
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);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
docFrame->InvalidateLayer(nsDisplayItem::TYPE_REMOTE);
|
|
}
|
|
|
|
uint64_t
|
|
RenderFrameParent::GetLayerTreeId() const
|
|
{
|
|
return mLayersId;
|
|
}
|
|
|
|
void
|
|
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.
|
|
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
|
|
|
|
nsPoint offset = aBuilder->ToReferenceFrame(aFrame);
|
|
nsRect bounds = aFrame->EnsureInnerView()->GetBounds() + offset;
|
|
clipState.ClipContentDescendants(bounds);
|
|
|
|
aLists.Content()->AppendToTop(
|
|
new (aBuilder) nsDisplayRemote(aBuilder, aFrame, this));
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::ZoomToRect(uint32_t aPresShellId, ViewID aViewId,
|
|
const CSSRect& aRect)
|
|
{
|
|
if (GetApzcTreeManager()) {
|
|
GetApzcTreeManager()->ZoomToRect(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
|
|
aRect);
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid,
|
|
uint64_t aInputBlockId,
|
|
bool aPreventDefault)
|
|
{
|
|
if (aGuid.mLayersId != mLayersId) {
|
|
// Guard against bad data from hijacked child processes
|
|
NS_ERROR("Unexpected layers id in ContentReceivedInputBlock; dropping message...");
|
|
return;
|
|
}
|
|
if (GetApzcTreeManager()) {
|
|
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
|
|
GetApzcTreeManager(), &APZCTreeManager::ContentReceivedInputBlock,
|
|
aInputBlockId, aPreventDefault));
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::SetTargetAPZC(uint64_t aInputBlockId,
|
|
const nsTArray<ScrollableLayerGuid>& aTargets)
|
|
{
|
|
for (size_t i = 0; i < aTargets.Length(); i++) {
|
|
if (aTargets[i].mLayersId != mLayersId) {
|
|
// Guard against bad data from hijacked child processes
|
|
NS_ERROR("Unexpected layers id in SetTargetAPZC; dropping message...");
|
|
return;
|
|
}
|
|
}
|
|
if (GetApzcTreeManager()) {
|
|
// need a local var to disambiguate between the SetTargetAPZC overloads.
|
|
void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&)
|
|
= &APZCTreeManager::SetTargetAPZC;
|
|
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
|
|
GetApzcTreeManager(), setTargetApzcFunc,
|
|
aInputBlockId, aTargets));
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::UpdateZoomConstraints(uint32_t aPresShellId,
|
|
ViewID aViewId,
|
|
bool aIsRoot,
|
|
const ZoomConstraints& aConstraints)
|
|
{
|
|
if (mContentController && aIsRoot) {
|
|
mContentController->SaveZoomConstraints(aConstraints);
|
|
}
|
|
if (GetApzcTreeManager()) {
|
|
GetApzcTreeManager()->UpdateZoomConstraints(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
|
|
aConstraints);
|
|
}
|
|
}
|
|
|
|
bool
|
|
RenderFrameParent::HitTest(const nsRect& aRect)
|
|
{
|
|
return mTouchRegion.Contains(aRect);
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier)
|
|
{
|
|
nsRefPtr<LayerManager> lm = GetFrom(mFrameLoader);
|
|
// Perhaps the document containing this frame currently has no presentation?
|
|
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
*aTextureFactoryIdentifier =
|
|
static_cast<ClientLayerManager*>(lm.get())->GetTextureFactoryIdentifier();
|
|
} else {
|
|
*aTextureFactoryIdentifier = TextureFactoryIdentifier();
|
|
}
|
|
}
|
|
|
|
void
|
|
RenderFrameParent::TakeFocusForClick()
|
|
{
|
|
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
if (!fm) {
|
|
return;
|
|
}
|
|
nsCOMPtr<nsIContent> owner = mFrameLoader->GetOwnerContent();
|
|
if (!owner) {
|
|
return;
|
|
}
|
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(owner);
|
|
if (!element) {
|
|
return;
|
|
}
|
|
fm->SetFocus(element, nsIFocusManager::FLAG_BYMOUSE |
|
|
nsIFocusManager::FLAG_NOSCROLL);
|
|
}
|
|
|
|
} // namespace layout
|
|
} // namespace mozilla
|
|
|
|
nsDisplayRemote::nsDisplayRemote(nsDisplayListBuilder* aBuilder,
|
|
nsSubDocumentFrame* aFrame,
|
|
RenderFrameParent* aRemoteFrame)
|
|
: nsDisplayItem(aBuilder, aFrame)
|
|
, mRemoteFrame(aRemoteFrame)
|
|
, mEventRegionsOverride(EventRegionsOverride::NoOverride)
|
|
{
|
|
if (aBuilder->IsBuildingLayerEventRegions()) {
|
|
bool frameIsPointerEventsNone = !aFrame->PassPointerEventsToChildren()
|
|
&& (aFrame->StyleVisibility()->GetEffectivePointerEvents(aFrame) == NS_STYLE_POINTER_EVENTS_NONE);
|
|
if (aBuilder->IsInsidePointerEventsNoneDoc() || frameIsPointerEventsNone) {
|
|
mEventRegionsOverride |= EventRegionsOverride::ForceEmptyHitRegion;
|
|
}
|
|
if (nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(aFrame->PresContext()->PresShell())) {
|
|
mEventRegionsOverride |= EventRegionsOverride::ForceDispatchToContent;
|
|
}
|
|
}
|
|
}
|
|
|
|
already_AddRefed<Layer>
|
|
nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
LayerManager* aManager,
|
|
const ContainerLayerParameters& aContainerParameters)
|
|
{
|
|
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
|
nsIntRect visibleRect = GetVisibleRect().ToNearestPixels(appUnitsPerDevPixel);
|
|
visibleRect += aContainerParameters.mOffset;
|
|
nsRefPtr<Layer> layer = mRemoteFrame->BuildLayer(aBuilder, mFrame, aManager, visibleRect, this, aContainerParameters);
|
|
if (layer && layer->AsContainerLayer()) {
|
|
layer->AsContainerLayer()->SetEventRegionsOverride(mEventRegionsOverride);
|
|
}
|
|
return layer.forget();
|
|
}
|
|
|
|
void
|
|
nsDisplayRemote::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
|
{
|
|
if (mRemoteFrame->HitTest(aRect)) {
|
|
aOutFrames->AppendElement(mFrame);
|
|
}
|
|
}
|
|
|