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 :
|
|
|
|
*/
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at:
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* The Mozilla Foundation
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Chris Jones <jones.chris.g@gmail.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "mozilla/layers/ShadowLayersParent.h"
|
|
|
|
|
|
|
|
#include "BasicLayers.h"
|
2010-10-13 22:55:45 +00:00
|
|
|
#include "LayerManagerOGL.h"
|
2011-07-04 13:15:05 +00:00
|
|
|
#ifdef MOZ_ENABLE_D3D9_LAYER
|
|
|
|
#include "LayerManagerD3D9.h"
|
|
|
|
#endif //MOZ_ENABLE_D3D9_LAYER
|
2010-08-20 23:24:41 +00:00
|
|
|
#include "RenderFrameParent.h"
|
|
|
|
|
|
|
|
#include "gfx3DMatrix.h"
|
|
|
|
#include "nsFrameLoader.h"
|
|
|
|
#include "nsViewportFrame.h"
|
2011-01-13 17:45:14 +00:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2011-05-19 10:53:02 +00:00
|
|
|
#include "nsIObserver.h"
|
2012-04-25 16:35:58 +00:00
|
|
|
#include "nsContentUtils.h"
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
typedef nsContentView::ViewConfig ViewConfig;
|
2010-08-20 23:24:41 +00:00
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layout {
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
|
|
|
typedef RenderFrameParent::ViewMap ViewMap;
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
// Represents (affine) transforms that are calculated from a content view.
|
|
|
|
struct ViewTransform {
|
2011-04-08 16:35:13 +00:00
|
|
|
ViewTransform(nsIntPoint aTranslation = nsIntPoint(0, 0), float aXScale = 1, float aYScale = 1)
|
2011-01-13 17:45:14 +00:00
|
|
|
: mTranslation(aTranslation)
|
|
|
|
, mXScale(aXScale)
|
|
|
|
, mYScale(aYScale)
|
|
|
|
{}
|
|
|
|
|
|
|
|
operator gfx3DMatrix() const
|
|
|
|
{
|
|
|
|
return
|
2011-08-27 00:06:03 +00:00
|
|
|
gfx3DMatrix::ScalingMatrix(mXScale, mYScale, 1) *
|
2011-01-13 17:45:14 +00:00
|
|
|
gfx3DMatrix::Translation(mTranslation.x, mTranslation.y, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntPoint mTranslation;
|
|
|
|
float mXScale;
|
|
|
|
float mYScale;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Matrix helpers
|
|
|
|
// For our simple purposes, these helpers apply to 2D affine transformations
|
|
|
|
// that can be represented by a scale and a translation. This makes the math
|
|
|
|
// much easier because we only expect the diagonals and the translation
|
|
|
|
// coordinates of the matrix to be non-zero.
|
|
|
|
|
|
|
|
static double GetXScale(const gfx3DMatrix& aTransform)
|
|
|
|
{
|
|
|
|
return aTransform._11;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double GetYScale(const gfx3DMatrix& aTransform)
|
|
|
|
{
|
|
|
|
return aTransform._22;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Scale(gfx3DMatrix& aTransform, double aXScale, double aYScale)
|
|
|
|
{
|
|
|
|
aTransform._11 *= aXScale;
|
|
|
|
aTransform._22 *= aYScale;
|
|
|
|
}
|
|
|
|
|
2011-04-08 16:35:13 +00:00
|
|
|
static void ReverseTranslate(gfx3DMatrix& aTransform, ViewTransform& aViewTransform)
|
|
|
|
{
|
2011-11-17 23:52:29 +00:00
|
|
|
aTransform._41 -= aViewTransform.mTranslation.x / aViewTransform.mXScale;
|
|
|
|
aTransform._42 -= aViewTransform.mTranslation.y / aViewTransform.mYScale;
|
2011-04-08 16:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
static void ApplyTransform(nsRect& aRect,
|
|
|
|
gfx3DMatrix& aTransform,
|
|
|
|
nscoord auPerDevPixel)
|
|
|
|
{
|
|
|
|
aRect.x = aRect.x * aTransform._11 + aTransform._41 * auPerDevPixel;
|
|
|
|
aRect.y = aRect.y * aTransform._22 + aTransform._42 * auPerDevPixel;
|
|
|
|
aRect.width = aRect.width * aTransform._11;
|
|
|
|
aRect.height = aRect.height * aTransform._22;
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
static void
|
|
|
|
AssertInTopLevelChromeDoc(ContainerLayer* aContainer,
|
|
|
|
nsIFrame* aContainedFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(
|
|
|
|
(aContainer->Manager()->GetBackendType() != LayerManager::LAYERS_BASIC) ||
|
|
|
|
(aContainedFrame->GetNearestWidget() ==
|
|
|
|
static_cast<BasicLayerManager*>(aContainer->Manager())->GetRetainerWidget()),
|
|
|
|
"Expected frame to be in top-level chrome document");
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
// Return view for given ID in aArray, NULL if not found.
|
|
|
|
static nsContentView*
|
|
|
|
FindViewForId(const ViewMap& aMap, ViewID aId)
|
|
|
|
{
|
|
|
|
ViewMap::const_iterator iter = aMap.find(aId);
|
|
|
|
return iter != aMap.end() ? iter->second : NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
static const FrameMetrics*
|
|
|
|
GetFrameMetrics(Layer* aLayer)
|
|
|
|
{
|
2011-04-11 20:53:01 +00:00
|
|
|
ContainerLayer* container = aLayer->AsContainerLayer();
|
|
|
|
return container ? &container->GetFrameMetrics() : NULL;
|
2011-01-13 17:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsIntPoint
|
|
|
|
GetRootFrameOffset(nsIFrame* aContainerFrame, nsDisplayListBuilder* aBuilder)
|
|
|
|
{
|
|
|
|
nscoord auPerDevPixel = aContainerFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
|
|
|
|
// Offset to the content rect in case we have borders or padding
|
|
|
|
nsPoint frameOffset =
|
|
|
|
(aBuilder->ToReferenceFrame(aContainerFrame->GetParent()) +
|
|
|
|
aContainerFrame->GetContentRect().TopLeft());
|
|
|
|
|
|
|
|
return frameOffset.ToNearestPixels(auPerDevPixel);
|
|
|
|
}
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
// Compute the transform of the shadow tree contained by
|
|
|
|
// |aContainerFrame| to widget space. We transform because the
|
|
|
|
// subprocess layer manager renders to a different top-left than where
|
|
|
|
// the shadow tree is drawn here and because a scale can be set on the
|
|
|
|
// shadow tree.
|
2011-01-13 17:45:14 +00:00
|
|
|
static ViewTransform
|
2010-10-13 22:55:45 +00:00
|
|
|
ComputeShadowTreeTransform(nsIFrame* aContainerFrame,
|
2011-01-13 17:45:14 +00:00
|
|
|
nsFrameLoader* aRootFrameLoader,
|
|
|
|
const FrameMetrics* aMetrics,
|
2011-01-13 17:45:14 +00:00
|
|
|
const ViewConfig& aConfig,
|
2011-11-17 23:52:29 +00:00
|
|
|
float aTempScaleX = 1.0,
|
|
|
|
float aTempScaleY = 1.0)
|
2010-10-13 22:55:45 +00:00
|
|
|
{
|
2011-01-13 17:45:14 +00:00
|
|
|
// |aMetrics->mViewportScrollOffset| The frame's scroll offset when it was
|
|
|
|
// painted, in content document pixels.
|
|
|
|
// |aConfig.mScrollOffset| What our user expects, or wants, the
|
|
|
|
// frame scroll offset to be in chrome
|
|
|
|
// document app units.
|
|
|
|
//
|
|
|
|
// So we set a compensating translation that moves the content document
|
|
|
|
// pixels to where the user wants them to be.
|
|
|
|
//
|
2010-10-13 22:55:45 +00:00
|
|
|
nscoord auPerDevPixel = aContainerFrame->PresContext()->AppUnitsPerDevPixel();
|
2011-01-13 17:45:14 +00:00
|
|
|
nsIntPoint scrollOffset =
|
|
|
|
aConfig.mScrollOffset.ToNearestPixels(auPerDevPixel);
|
2011-06-22 12:11:29 +00:00
|
|
|
// metricsScrollOffset is in layer coordinates.
|
2011-01-13 17:45:14 +00:00
|
|
|
nsIntPoint metricsScrollOffset = aMetrics->mViewportScrollOffset;
|
|
|
|
|
2011-03-09 21:35:27 +00:00
|
|
|
if (aRootFrameLoader->AsyncScrollEnabled() && !aMetrics->mDisplayPort.IsEmpty()) {
|
|
|
|
// Only use asynchronous scrolling if it is enabled and there is a
|
|
|
|
// displayport defined. It is useful to have a scroll layer that is
|
|
|
|
// synchronously scrolled for identifying a scroll area before it is
|
|
|
|
// being actively scrolled.
|
2011-01-13 17:45:14 +00:00
|
|
|
nsIntPoint scrollCompensation(
|
2011-11-17 23:52:29 +00:00
|
|
|
(scrollOffset.x / aTempScaleX - metricsScrollOffset.x) * aConfig.mXScale,
|
|
|
|
(scrollOffset.y / aTempScaleY - metricsScrollOffset.y) * aConfig.mYScale);
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
return ViewTransform(-scrollCompensation, aConfig.mXScale, aConfig.mYScale);
|
2011-01-11 21:34:31 +00:00
|
|
|
} else {
|
2011-01-13 17:45:14 +00:00
|
|
|
return ViewTransform(nsIntPoint(0, 0), 1, 1);
|
2011-01-11 21:34:31 +00:00
|
|
|
}
|
2010-08-20 23:24:41 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
// Use shadow layer tree to build display list for the browser's frame.
|
2010-10-13 22:55:45 +00:00
|
|
|
static void
|
2011-01-13 17:45:14 +00:00
|
|
|
BuildListForLayer(Layer* aLayer,
|
|
|
|
nsFrameLoader* aRootFrameLoader,
|
2011-06-22 12:11:29 +00:00
|
|
|
const gfx3DMatrix& aTransform,
|
2011-01-13 17:45:14 +00:00
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList& aShadowTree,
|
|
|
|
nsIFrame* aSubdocFrame)
|
2010-10-13 22:55:45 +00:00
|
|
|
{
|
2011-01-13 17:45:14 +00:00
|
|
|
const FrameMetrics* metrics = GetFrameMetrics(aLayer);
|
|
|
|
|
|
|
|
gfx3DMatrix transform;
|
|
|
|
|
|
|
|
if (metrics && metrics->IsScrollable()) {
|
|
|
|
const ViewID scrollId = metrics->mScrollId;
|
2010-10-13 22:55:45 +00:00
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
// We need to figure out the bounds of the scrollable region using the
|
|
|
|
// shadow layer tree from the remote process. The metrics viewport is
|
|
|
|
// defined based on all the transformations of its parent layers and
|
|
|
|
// the scale of the current layer.
|
|
|
|
|
|
|
|
// Calculate transform for this layer.
|
|
|
|
nsContentView* view =
|
|
|
|
aRootFrameLoader->GetCurrentRemoteFrame()->GetContentView(scrollId);
|
2011-06-22 12:11:29 +00:00
|
|
|
// XXX why don't we include aLayer->GetTransform() in the inverse-scale here?
|
|
|
|
// This seems wrong, but it doesn't seem to cause bugs!
|
2011-01-13 17:45:14 +00:00
|
|
|
gfx3DMatrix applyTransform = ComputeShadowTreeTransform(
|
2011-01-26 06:26:37 +00:00
|
|
|
aSubdocFrame, aRootFrameLoader, metrics, view->GetViewConfig(),
|
2011-01-13 17:45:14 +00:00
|
|
|
1 / GetXScale(aTransform), 1 / GetYScale(aTransform));
|
|
|
|
transform = applyTransform * aLayer->GetTransform() * aTransform;
|
|
|
|
|
|
|
|
// As mentioned above, bounds calculation also depends on the scale
|
|
|
|
// of this layer.
|
2011-06-22 12:11:29 +00:00
|
|
|
gfx3DMatrix tmpTransform = aTransform;
|
|
|
|
Scale(tmpTransform, GetXScale(applyTransform), GetYScale(applyTransform));
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
// Calculate rect for this layer based on aTransform.
|
|
|
|
nsRect bounds;
|
|
|
|
{
|
|
|
|
nscoord auPerDevPixel = aSubdocFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
bounds = metrics->mViewport.ToAppUnits(auPerDevPixel);
|
2011-06-22 12:11:29 +00:00
|
|
|
ApplyTransform(bounds, tmpTransform, auPerDevPixel);
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
aShadowTree.AppendToTop(
|
|
|
|
new (aBuilder) nsDisplayRemoteShadow(aBuilder, aSubdocFrame, bounds, scrollId));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
transform = aLayer->GetTransform() * aTransform;
|
|
|
|
}
|
2010-10-13 22:55:45 +00:00
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
for (Layer* child = aLayer->GetFirstChild(); child;
|
2010-10-13 22:55:45 +00:00
|
|
|
child = child->GetNextSibling()) {
|
2011-01-13 17:45:14 +00:00
|
|
|
BuildListForLayer(child, aRootFrameLoader, transform,
|
|
|
|
aBuilder, aShadowTree, aSubdocFrame);
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
// Go down shadow layer tree and apply transformations for scrollable layers.
|
2010-10-13 22:55:45 +00:00
|
|
|
static void
|
2011-01-13 17:45:14 +00:00
|
|
|
TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
|
|
|
|
nsIFrame* aFrame, Layer* aLayer,
|
2011-11-17 23:52:29 +00:00
|
|
|
const ViewTransform& aTransform,
|
|
|
|
float aTempScaleDiffX = 1.0,
|
|
|
|
float aTempScaleDiffY = 1.0)
|
2010-10-13 22:55:45 +00:00
|
|
|
{
|
2011-01-13 17:45:14 +00:00
|
|
|
ShadowLayer* shadow = aLayer->AsShadowLayer();
|
|
|
|
shadow->SetShadowClipRect(aLayer->GetClipRect());
|
|
|
|
shadow->SetShadowVisibleRegion(aLayer->GetVisibleRegion());
|
|
|
|
|
|
|
|
const FrameMetrics* metrics = GetFrameMetrics(aLayer);
|
|
|
|
|
2011-11-17 23:52:29 +00:00
|
|
|
gfx3DMatrix shadowTransform = aLayer->GetTransform();
|
2011-06-22 12:11:29 +00:00
|
|
|
ViewTransform layerTransform = aTransform;
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
if (metrics && metrics->IsScrollable()) {
|
|
|
|
const ViewID scrollId = metrics->mScrollId;
|
|
|
|
const nsContentView* view =
|
|
|
|
aFrameLoader->GetCurrentRemoteFrame()->GetContentView(scrollId);
|
|
|
|
NS_ABORT_IF_FALSE(view, "Array of views should be consistent with layer tree");
|
2011-06-22 12:11:29 +00:00
|
|
|
const gfx3DMatrix& currentTransform = aLayer->GetTransform();
|
2011-01-13 17:45:14 +00:00
|
|
|
|
2011-11-17 23:52:29 +00:00
|
|
|
const ViewConfig& config = view->GetViewConfig();
|
|
|
|
// With temporary scale we should compensate translation
|
|
|
|
// using temporary scale value
|
|
|
|
aTempScaleDiffX *= GetXScale(shadowTransform) * config.mXScale;
|
|
|
|
aTempScaleDiffY *= GetYScale(shadowTransform) * config.mYScale;
|
2011-01-13 17:45:14 +00:00
|
|
|
ViewTransform viewTransform = ComputeShadowTreeTransform(
|
2011-01-26 06:26:37 +00:00
|
|
|
aFrame, aFrameLoader, metrics, view->GetViewConfig(),
|
2011-11-17 23:52:29 +00:00
|
|
|
aTempScaleDiffX, aTempScaleDiffY
|
2011-01-13 17:45:14 +00:00
|
|
|
);
|
|
|
|
|
2011-06-22 12:11:29 +00:00
|
|
|
// Apply the layer's own transform *before* the view transform
|
|
|
|
shadowTransform = gfx3DMatrix(viewTransform) * currentTransform;
|
|
|
|
|
2011-11-17 23:52:29 +00:00
|
|
|
layerTransform = viewTransform;
|
2011-01-13 17:45:14 +00:00
|
|
|
if (metrics->IsRootScrollable()) {
|
2011-06-22 12:11:29 +00:00
|
|
|
// Apply the root frame translation *before* we do the rest of the transforms.
|
|
|
|
nsIntPoint rootFrameOffset = GetRootFrameOffset(aFrame, aBuilder);
|
|
|
|
shadowTransform = shadowTransform *
|
|
|
|
gfx3DMatrix::Translation(float(rootFrameOffset.x), float(rootFrameOffset.y), 0.0);
|
2011-01-13 17:45:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-08 16:35:13 +00:00
|
|
|
if (aLayer->GetIsFixedPosition() &&
|
|
|
|
!aLayer->GetParent()->GetIsFixedPosition()) {
|
2011-06-22 12:11:29 +00:00
|
|
|
ReverseTranslate(shadowTransform, layerTransform);
|
2011-04-08 16:35:13 +00:00
|
|
|
const nsIntRect* clipRect = shadow->GetShadowClipRect();
|
|
|
|
if (clipRect) {
|
|
|
|
nsIntRect transformedClipRect(*clipRect);
|
|
|
|
transformedClipRect.MoveBy(shadowTransform._41, shadowTransform._42);
|
|
|
|
shadow->SetShadowClipRect(&transformedClipRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
shadow->SetShadowTransform(shadowTransform);
|
|
|
|
for (Layer* child = aLayer->GetFirstChild();
|
|
|
|
child; child = child->GetNextSibling()) {
|
2011-11-17 23:52:29 +00:00
|
|
|
TransformShadowTree(aBuilder, aFrameLoader, aFrame, child, layerTransform,
|
|
|
|
aTempScaleDiffX, aTempScaleDiffY);
|
2011-01-13 17:45:14 +00:00
|
|
|
}
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
|
|
|
|
2011-01-26 06:26:37 +00:00
|
|
|
static void
|
|
|
|
ClearContainer(ContainerLayer* aContainer)
|
2010-08-20 23:24:41 +00:00
|
|
|
{
|
2011-01-26 06:26:37 +00:00
|
|
|
while (Layer* layer = aContainer->GetFirstChild()) {
|
|
|
|
aContainer->RemoveChild(layer);
|
|
|
|
}
|
2010-08-20 23:24:41 +00: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.
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool
|
2010-08-20 23:24:41 +00:00
|
|
|
IsTempLayerManager(LayerManager* aManager)
|
|
|
|
{
|
|
|
|
return (LayerManager::LAYERS_BASIC == aManager->GetBackendType() &&
|
|
|
|
!static_cast<BasicLayerManager*>(aManager)->IsRetained());
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
// Recursively create a new array of scrollables, preserving any scrollables
|
|
|
|
// that are still in the layer tree.
|
|
|
|
//
|
|
|
|
// aXScale and aYScale are used to calculate any values that need to be in
|
|
|
|
// chrome-document CSS pixels and aren't part of the rendering loop, such as
|
|
|
|
// the initial scroll offset for a new view.
|
|
|
|
static void
|
|
|
|
BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
|
2011-01-26 06:26:37 +00:00
|
|
|
nsFrameLoader* aFrameLoader, Layer* aLayer,
|
2011-11-17 23:52:29 +00:00
|
|
|
float aXScale = 1, float aYScale = 1,
|
|
|
|
float aAccConfigXScale = 1, float aAccConfigYScale = 1)
|
2011-01-13 17:45:14 +00:00
|
|
|
{
|
2011-04-11 20:53:01 +00:00
|
|
|
ContainerLayer* container = aLayer->AsContainerLayer();
|
|
|
|
if (!container)
|
2011-01-13 17:45:14 +00:00
|
|
|
return;
|
2011-01-13 17:45:14 +00:00
|
|
|
const FrameMetrics metrics = container->GetFrameMetrics();
|
2011-01-13 17:45:14 +00:00
|
|
|
const ViewID scrollId = metrics.mScrollId;
|
2011-07-18 18:04:44 +00:00
|
|
|
const gfx3DMatrix transform = aLayer->GetTransform();
|
|
|
|
aXScale *= GetXScale(transform);
|
|
|
|
aYScale *= GetYScale(transform);
|
2011-01-13 17:45:14 +00:00
|
|
|
|
2011-01-19 16:56:22 +00:00
|
|
|
if (metrics.IsScrollable()) {
|
|
|
|
nscoord auPerDevPixel = aFrameLoader->GetPrimaryFrameOfOwningContent()
|
|
|
|
->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
nsContentView* view = FindViewForId(oldContentViews, scrollId);
|
|
|
|
if (view) {
|
|
|
|
// View already exists. Be sure to propagate scales for any values
|
|
|
|
// that need to be calculated something in chrome-doc CSS pixels.
|
|
|
|
ViewConfig config = view->GetViewConfig();
|
|
|
|
aXScale *= config.mXScale;
|
|
|
|
aYScale *= config.mYScale;
|
2011-07-18 18:04:47 +00:00
|
|
|
view->mFrameLoader = aFrameLoader;
|
2011-11-17 23:52:29 +00:00
|
|
|
// If scale has changed, then we should update
|
|
|
|
// current scroll offset to new scaled value
|
|
|
|
if (aAccConfigXScale != view->mParentScaleX ||
|
|
|
|
aAccConfigYScale != view->mParentScaleY) {
|
|
|
|
float xscroll = 0, yscroll = 0;
|
|
|
|
view->GetScrollX(&xscroll);
|
|
|
|
view->GetScrollY(&yscroll);
|
|
|
|
xscroll = xscroll * (aAccConfigXScale / view->mParentScaleX);
|
|
|
|
yscroll = yscroll * (aAccConfigYScale / view->mParentScaleY);
|
|
|
|
view->ScrollTo(xscroll, yscroll);
|
|
|
|
view->mParentScaleX = aAccConfigXScale;
|
|
|
|
view->mParentScaleY = aAccConfigYScale;
|
|
|
|
}
|
|
|
|
// Collect only config scale values for scroll compensation
|
|
|
|
aAccConfigXScale *= config.mXScale;
|
|
|
|
aAccConfigYScale *= config.mYScale;
|
2011-01-19 16:56:22 +00:00
|
|
|
} else {
|
|
|
|
// View doesn't exist, so generate one. We start the view scroll offset at
|
|
|
|
// the same position as the framemetric's scroll offset from the layer.
|
|
|
|
// The default scale is 1, so no need to propagate scale down.
|
|
|
|
ViewConfig config;
|
|
|
|
config.mScrollOffset = nsPoint(
|
|
|
|
NSIntPixelsToAppUnits(metrics.mViewportScrollOffset.x, auPerDevPixel) * aXScale,
|
|
|
|
NSIntPixelsToAppUnits(metrics.mViewportScrollOffset.y, auPerDevPixel) * aYScale);
|
2011-07-18 18:04:47 +00:00
|
|
|
view = new nsContentView(aFrameLoader, scrollId, config);
|
2011-11-17 23:52:29 +00:00
|
|
|
view->mParentScaleX = aAccConfigXScale;
|
|
|
|
view->mParentScaleY = aAccConfigYScale;
|
2011-01-19 16:56:22 +00:00
|
|
|
}
|
2011-01-13 17:45:14 +00:00
|
|
|
|
2011-01-19 16:56:22 +00:00
|
|
|
view->mViewportSize = nsSize(
|
|
|
|
NSIntPixelsToAppUnits(metrics.mViewport.width, auPerDevPixel) * aXScale,
|
|
|
|
NSIntPixelsToAppUnits(metrics.mViewport.height, auPerDevPixel) * aYScale);
|
|
|
|
view->mContentSize = nsSize(
|
2012-04-12 19:55:26 +00:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(metrics.mCSSContentSize.width) * aXScale,
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(metrics.mCSSContentSize.height) * aYScale);
|
2011-01-13 17:45:14 +00:00
|
|
|
|
2011-01-26 06:26:37 +00:00
|
|
|
newContentViews[scrollId] = view;
|
2011-01-19 16:56:22 +00:00
|
|
|
}
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
for (Layer* child = aLayer->GetFirstChild();
|
|
|
|
child; child = child->GetNextSibling()) {
|
|
|
|
BuildViewMap(oldContentViews, newContentViews, aFrameLoader, child,
|
2011-11-17 23:52:29 +00:00
|
|
|
aXScale, aYScale, aAccConfigXScale, aAccConfigYScale);
|
2011-01-13 17:45:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-26 06:26:37 +00:00
|
|
|
static void
|
|
|
|
BuildBackgroundPatternFor(ContainerLayer* aContainer,
|
|
|
|
ContainerLayer* aShadowRoot,
|
|
|
|
const ViewConfig& aConfig,
|
2011-10-20 22:17:09 +00:00
|
|
|
const gfxRGBA& aColor,
|
2011-01-26 06:26:37 +00:00
|
|
|
LayerManager* aManager,
|
2011-10-20 22:17:09 +00:00
|
|
|
nsIFrame* aFrame)
|
2011-01-26 06:26:37 +00:00
|
|
|
{
|
|
|
|
ShadowLayer* shadowRoot = aShadowRoot->AsShadowLayer();
|
|
|
|
gfxMatrix t;
|
|
|
|
if (!shadowRoot->GetShadowTransform().Is2D(&t)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the rect bounding the shadow content, transformed into the
|
|
|
|
// same space as |aFrame|
|
|
|
|
nsIntRect contentBounds = shadowRoot->GetShadowVisibleRegion().GetBounds();
|
|
|
|
gfxRect contentVis(contentBounds.x, contentBounds.y,
|
|
|
|
contentBounds.width, contentBounds.height);
|
|
|
|
gfxRect localContentVis(t.Transform(contentVis));
|
|
|
|
// Round *in* here because this area is punched out of the background
|
|
|
|
localContentVis.RoundIn();
|
2011-04-19 03:07:21 +00:00
|
|
|
nsIntRect localIntContentVis(localContentVis.X(), localContentVis.Y(),
|
|
|
|
localContentVis.Width(), localContentVis.Height());
|
2011-01-26 06:26:37 +00:00
|
|
|
|
|
|
|
// Get the frame's rect
|
|
|
|
nscoord auPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
nsIntRect frameRect = aFrame->GetRect().ToOutsidePixels(auPerDevPixel);
|
|
|
|
|
|
|
|
// If the shadow tree covers the frame rect, don't bother building
|
|
|
|
// the background, it wouldn't be visible
|
|
|
|
if (localIntContentVis.Contains(frameRect)) {
|
|
|
|
return;
|
|
|
|
}
|
2011-10-20 22:17:09 +00:00
|
|
|
nsRefPtr<ColorLayer> layer = aManager->CreateColorLayer();
|
|
|
|
layer->SetColor(aColor);
|
2011-01-26 06:26:37 +00:00
|
|
|
|
|
|
|
// The visible area of the background is the frame's area minus the
|
|
|
|
// content area
|
|
|
|
nsIntRegion bgRgn(frameRect);
|
|
|
|
bgRgn.Sub(bgRgn, localIntContentVis);
|
2011-10-20 22:17:09 +00:00
|
|
|
bgRgn.MoveBy(-frameRect.TopLeft());
|
2011-01-26 06:26:37 +00:00
|
|
|
layer->SetVisibleRegion(bgRgn);
|
2011-07-18 18:04:47 +00:00
|
|
|
|
2011-01-26 06:26:37 +00:00
|
|
|
aContainer->InsertAfter(layer, nsnull);
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader)
|
|
|
|
: mFrameLoader(aFrameLoader)
|
2011-09-27 18:35:23 +00:00
|
|
|
, mFrameLoaderDestroyed(false)
|
2011-10-20 22:17:09 +00:00
|
|
|
, mBackgroundColor(gfxRGBA(1, 1, 1))
|
2010-10-26 17:51:08 +00:00
|
|
|
{
|
2011-08-09 19:38:26 +00:00
|
|
|
if (aFrameLoader) {
|
|
|
|
mContentViews[FrameMetrics::ROOT_SCROLL_ID] =
|
|
|
|
new nsContentView(aFrameLoader, FrameMetrics::ROOT_SCROLL_ID);
|
|
|
|
}
|
2010-10-26 17:51:08 +00:00
|
|
|
}
|
2010-08-20 23:24:41 +00:00
|
|
|
|
|
|
|
RenderFrameParent::~RenderFrameParent()
|
|
|
|
{}
|
|
|
|
|
2011-01-06 04:54:47 +00:00
|
|
|
void
|
|
|
|
RenderFrameParent::Destroy()
|
|
|
|
{
|
|
|
|
size_t numChildren = ManagedPLayersParent().Length();
|
|
|
|
NS_ABORT_IF_FALSE(0 == numChildren || 1 == numChildren,
|
|
|
|
"render frame must only have 0 or 1 layer manager");
|
|
|
|
|
|
|
|
if (numChildren) {
|
|
|
|
ShadowLayersParent* layers =
|
|
|
|
static_cast<ShadowLayersParent*>(ManagedPLayersParent()[0]);
|
|
|
|
layers->Destroy();
|
|
|
|
}
|
2011-09-27 18:35:23 +00:00
|
|
|
|
|
|
|
mFrameLoaderDestroyed = true;
|
2011-01-06 04:54:47 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
nsContentView*
|
|
|
|
RenderFrameParent::GetContentView(ViewID aId)
|
|
|
|
{
|
|
|
|
return FindViewForId(mContentViews, aId);
|
|
|
|
}
|
|
|
|
|
2011-07-18 18:04:47 +00:00
|
|
|
void
|
|
|
|
RenderFrameParent::ContentViewScaleChanged(nsContentView* aView)
|
|
|
|
{
|
|
|
|
// Since the scale has changed for a view, it and its descendents need their
|
|
|
|
// shadow-space attributes updated. It's easiest to rebuild the view map.
|
|
|
|
BuildViewMap();
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
void
|
2012-03-12 15:50:15 +00:00
|
|
|
RenderFrameParent::ShadowLayersUpdated(bool isFirstPaint)
|
2010-08-20 23:24:41 +00:00
|
|
|
{
|
|
|
|
mFrameLoader->SetCurrentRemoteFrame(this);
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
// View map must only contain views that are associated with the current
|
|
|
|
// shadow layer tree. We must always update the map when shadow layers
|
|
|
|
// are updated.
|
|
|
|
BuildViewMap();
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
nsIFrame* docFrame = mFrameLoader->GetPrimaryFrameOfOwningContent();
|
|
|
|
if (!docFrame) {
|
2010-09-24 22:41:31 +00:00
|
|
|
// 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.
|
2010-08-20 23:24:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME/cjones: we should collect the rects/regions updated for
|
|
|
|
// Painted*Layer() calls and pass that region to here, then only
|
|
|
|
// invalidate that rect
|
|
|
|
//
|
|
|
|
// We pass INVALIDATE_NO_THEBES_LAYERS here because we're
|
|
|
|
// invalidating the <browser> on behalf of its counterpart in the
|
|
|
|
// content process. Not only do we not need to invalidate the
|
|
|
|
// shadow layers, things would just break if we did --- we have no
|
|
|
|
// way to repaint shadow layers from this process.
|
|
|
|
nsRect rect = nsRect(nsPoint(0, 0), docFrame->GetRect().Size());
|
|
|
|
docFrame->InvalidateWithFlags(rect, nsIFrame::INVALIDATE_NO_THEBES_LAYERS);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Layer>
|
|
|
|
RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
2010-10-13 22:55:45 +00:00
|
|
|
LayerManager* aManager,
|
|
|
|
const nsIntRect& aVisibleRect)
|
2010-08-20 23:24:41 +00: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!");
|
|
|
|
|
|
|
|
if (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 NS_ABORT_IF_FALSE() above will flag it. Returning NULL
|
|
|
|
// here will just cause the shadow subtree not to be rendered.
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2011-01-26 06:26:37 +00:00
|
|
|
if (mContainer) {
|
|
|
|
ClearContainer(mContainer);
|
|
|
|
}
|
|
|
|
|
2010-09-03 20:10:45 +00:00
|
|
|
ContainerLayer* shadowRoot = GetRootLayer();
|
2011-01-26 06:26:37 +00:00
|
|
|
if (!shadowRoot) {
|
|
|
|
mContainer = nsnull;
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
NS_ABORT_IF_FALSE(!shadowRoot || shadowRoot->Manager() == aManager,
|
|
|
|
"retaining manager changed out from under us ... HELP!");
|
|
|
|
|
2011-01-26 06:26:37 +00:00
|
|
|
// Wrap the shadow layer tree in mContainer.
|
|
|
|
if (!mContainer) {
|
|
|
|
mContainer = aManager->CreateContainerLayer();
|
2010-08-20 23:24:41 +00:00
|
|
|
}
|
2011-01-26 06:26:37 +00:00
|
|
|
NS_ABORT_IF_FALSE(!mContainer->GetFirstChild(),
|
|
|
|
"container of shadow tree shouldn't have a 'root' here");
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2011-01-26 06:26:37 +00:00
|
|
|
mContainer->InsertAfter(shadowRoot, nsnull);
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2011-01-26 06:26:37 +00:00
|
|
|
AssertInTopLevelChromeDoc(mContainer, aFrame);
|
2011-04-08 16:35:13 +00:00
|
|
|
ViewTransform transform;
|
|
|
|
TransformShadowTree(aBuilder, mFrameLoader, aFrame, shadowRoot, transform);
|
2011-01-26 06:26:37 +00:00
|
|
|
mContainer->SetClipRect(nsnull);
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2011-02-23 17:45:09 +00:00
|
|
|
if (mFrameLoader->AsyncScrollEnabled()) {
|
|
|
|
const nsContentView* view = GetContentView(FrameMetrics::ROOT_SCROLL_ID);
|
|
|
|
BuildBackgroundPatternFor(mContainer,
|
|
|
|
shadowRoot,
|
|
|
|
view->GetViewConfig(),
|
2011-10-20 22:17:09 +00:00
|
|
|
mBackgroundColor,
|
|
|
|
aManager, aFrame);
|
2011-02-23 17:45:09 +00:00
|
|
|
}
|
2011-02-23 05:38:09 +00:00
|
|
|
mContainer->SetVisibleRegion(aVisibleRect);
|
2010-08-20 23:24:41 +00:00
|
|
|
|
|
|
|
return nsRefPtr<Layer>(mContainer).forget();
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
void
|
|
|
|
RenderFrameParent::OwnerContentChanged(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mFrameLoader->GetOwnerContent() == aContent,
|
|
|
|
"Don't build new map if owner is same!");
|
|
|
|
BuildViewMap();
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
void
|
|
|
|
RenderFrameParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
2011-08-09 19:38:26 +00:00
|
|
|
if (mFrameLoader && mFrameLoader->GetCurrentRemoteFrame() == this) {
|
2010-08-20 23:24:41 +00: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.
|
|
|
|
mFrameLoader->SetCurrentRemoteFrame(nsnull);
|
|
|
|
}
|
|
|
|
mFrameLoader = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
PLayersParent*
|
2011-08-09 19:38:26 +00:00
|
|
|
RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType)
|
2010-08-20 23:24:41 +00:00
|
|
|
{
|
2011-09-27 18:35:23 +00:00
|
|
|
if (!mFrameLoader || mFrameLoaderDestroyed) {
|
2011-08-09 19:38:26 +00:00
|
|
|
*aBackendType = LayerManager::LAYERS_NONE;
|
|
|
|
return nsnull;
|
|
|
|
}
|
2012-04-25 16:35:58 +00:00
|
|
|
|
|
|
|
nsRefPtr<LayerManager> lm =
|
|
|
|
nsContentUtils::LayerManagerForDocument(mFrameLoader->OwnerDoc());
|
2011-08-09 19:38:27 +00:00
|
|
|
ShadowLayerManager* slm = lm->AsShadowManager();
|
|
|
|
if (!slm) {
|
2011-07-06 17:29:27 +00:00
|
|
|
*aBackendType = LayerManager::LAYERS_NONE;
|
2011-08-09 19:38:27 +00:00
|
|
|
return nsnull;
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
2011-08-09 19:38:27 +00:00
|
|
|
*aBackendType = lm->GetBackendType();
|
2012-01-19 14:45:37 +00:00
|
|
|
return new ShadowLayersParent(slm, this);
|
2010-08-20 23:24:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
RenderFrameParent::DeallocPLayers(PLayersParent* aLayers)
|
|
|
|
{
|
|
|
|
delete aLayers;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
void
|
|
|
|
RenderFrameParent::BuildViewMap()
|
|
|
|
{
|
|
|
|
ViewMap newContentViews;
|
2011-01-13 17:45:31 +00:00
|
|
|
// BuildViewMap assumes we have a primary frame, which may not be the case.
|
|
|
|
if (GetRootLayer() && mFrameLoader->GetPrimaryFrameOfOwningContent()) {
|
2011-01-13 17:45:14 +00:00
|
|
|
// Some of the content views in our hash map may no longer be active. To
|
|
|
|
// tag them as inactive and to remove any chance of them using a dangling
|
|
|
|
// pointer, we set mContentView to NULL.
|
|
|
|
//
|
2011-07-18 18:04:47 +00:00
|
|
|
// BuildViewMap will restore mFrameLoader if the content view is still
|
2011-01-13 17:45:14 +00:00
|
|
|
// in our hash table.
|
|
|
|
|
|
|
|
for (ViewMap::const_iterator iter = mContentViews.begin();
|
|
|
|
iter != mContentViews.end();
|
|
|
|
++iter) {
|
2011-07-18 18:04:47 +00:00
|
|
|
iter->second->mFrameLoader = NULL;
|
2011-01-13 17:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::layout::BuildViewMap(mContentViews, newContentViews, mFrameLoader, GetRootLayer());
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:31 +00:00
|
|
|
// Here, we guarantee that *only* the root view is preserved in
|
|
|
|
// case we couldn't build a new view map above. This is important because
|
|
|
|
// the content view map should only contain the root view and content
|
|
|
|
// views that are present in the layer tree.
|
|
|
|
if (newContentViews.empty()) {
|
2011-01-26 06:26:37 +00:00
|
|
|
newContentViews[FrameMetrics::ROOT_SCROLL_ID] =
|
|
|
|
FindViewForId(mContentViews, FrameMetrics::ROOT_SCROLL_ID);
|
2011-01-13 17:45:14 +00:00
|
|
|
}
|
2011-07-18 18:04:47 +00:00
|
|
|
|
2011-01-13 17:45:31 +00:00
|
|
|
mContentViews = newContentViews;
|
2011-01-13 17:45:14 +00:00
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
ShadowLayersParent*
|
|
|
|
RenderFrameParent::GetShadowLayers() const
|
|
|
|
{
|
|
|
|
const nsTArray<PLayersParent*>& shadowParents = ManagedPLayersParent();
|
|
|
|
NS_ABORT_IF_FALSE(shadowParents.Length() <= 1,
|
|
|
|
"can only support at most 1 ShadowLayersParent");
|
|
|
|
return (shadowParents.Length() == 1) ?
|
|
|
|
static_cast<ShadowLayersParent*>(shadowParents[0]) : nsnull;
|
|
|
|
}
|
|
|
|
|
2010-09-03 20:10:45 +00:00
|
|
|
ContainerLayer*
|
2010-08-20 23:24:41 +00:00
|
|
|
RenderFrameParent::GetRootLayer() const
|
|
|
|
{
|
|
|
|
ShadowLayersParent* shadowLayers = GetShadowLayers();
|
|
|
|
return shadowLayers ? shadowLayers->GetRoot() : nsnull;
|
|
|
|
}
|
|
|
|
|
2011-01-13 17:45:14 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
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.
|
|
|
|
nsDisplayList shadowTree;
|
2011-09-14 07:51:24 +00:00
|
|
|
ContainerLayer* container = GetRootLayer();
|
|
|
|
if (aBuilder->IsForEventDelivery() && container) {
|
2011-01-13 17:45:14 +00:00
|
|
|
nsRect bounds = aFrame->EnsureInnerView()->GetBounds();
|
|
|
|
ViewTransform offset =
|
|
|
|
ViewTransform(GetRootFrameOffset(aFrame, aBuilder), 1, 1);
|
2011-09-14 07:51:24 +00:00
|
|
|
BuildListForLayer(container, mFrameLoader, offset,
|
2011-01-13 17:45:14 +00:00
|
|
|
aBuilder, shadowTree, aFrame);
|
|
|
|
} else {
|
|
|
|
shadowTree.AppendToTop(
|
|
|
|
new (aBuilder) nsDisplayRemote(aBuilder, aFrame, this));
|
|
|
|
}
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
// Clip the shadow layers to subdoc bounds
|
|
|
|
nsPoint offset = aFrame->GetOffsetToCrossDoc(aBuilder->ReferenceFrame());
|
|
|
|
nsRect bounds = aFrame->EnsureInnerView()->GetBounds() + offset;
|
|
|
|
|
|
|
|
return aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayClip(aBuilder, aFrame, &shadowTree,
|
|
|
|
bounds));
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
} // namespace layout
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
already_AddRefed<Layer>
|
|
|
|
nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 12:11:27 +00:00
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerParameters& aContainerParameters)
|
2010-08-20 23:24:41 +00:00
|
|
|
{
|
2010-10-13 22:55:45 +00:00
|
|
|
PRInt32 appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
nsIntRect visibleRect = GetVisibleRect().ToNearestPixels(appUnitsPerDevPixel);
|
|
|
|
nsRefPtr<Layer> layer = mRemoteFrame->BuildLayer(aBuilder, mFrame, aManager, visibleRect);
|
2010-08-20 23:24:41 +00:00
|
|
|
return layer.forget();
|
|
|
|
}
|
2011-01-13 17:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDisplayRemoteShadow::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
|
|
|
{
|
|
|
|
// If we are here, then rects have intersected.
|
|
|
|
//
|
|
|
|
// XXX I think iframes and divs can be rounded like anything else but we don't
|
|
|
|
// cover that case here.
|
|
|
|
//
|
|
|
|
if (aState->mShadows) {
|
|
|
|
aState->mShadows->AppendElement(mId);
|
|
|
|
}
|
|
|
|
}
|