зеркало из https://github.com/mozilla/pjs.git
Backout de70e79ced32, ddd519d0767e, 9b952d924953 & 03efce585669 (bug 758620) for reftest failures
This commit is contained in:
Родитель
be64584f0e
Коммит
ac1f65a6e5
|
@ -731,15 +731,6 @@ public:
|
|||
*/
|
||||
void SetIsFixedPosition(bool aFixedPosition) { mIsFixedPosition = aFixedPosition; }
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* If a layer is "fixed position", this determines which point on the layer
|
||||
* is considered the "anchor" point, that is, the point which remains in the
|
||||
* same position when compositing the layer tree with a transformation
|
||||
* (such as when asynchronously scrolling and zooming).
|
||||
*/
|
||||
void SetFixedPositionAnchor(const gfxPoint& aAnchor) { mAnchor = aAnchor; }
|
||||
|
||||
// These getters can be used anytime.
|
||||
float GetOpacity() { return mOpacity; }
|
||||
const nsIntRect* GetClipRect() { return mUseClipRect ? &mClipRect : nsnull; }
|
||||
|
@ -752,7 +743,6 @@ public:
|
|||
virtual Layer* GetLastChild() { return nsnull; }
|
||||
const gfx3DMatrix& GetTransform() { return mTransform; }
|
||||
bool GetIsFixedPosition() { return mIsFixedPosition; }
|
||||
gfxPoint GetFixedPositionAnchor() { return mAnchor; }
|
||||
Layer* GetMaskLayer() { return mMaskLayer; }
|
||||
|
||||
/**
|
||||
|
@ -1002,7 +992,6 @@ protected:
|
|||
bool mUseClipRect;
|
||||
bool mUseTileSourceRect;
|
||||
bool mIsFixedPosition;
|
||||
gfxPoint mAnchor;
|
||||
DebugOnly<PRUint32> mDebugColorIndex;
|
||||
};
|
||||
|
||||
|
|
|
@ -313,35 +313,27 @@ Translate2D(gfx3DMatrix& aTransform, const gfxPoint& aOffset)
|
|||
}
|
||||
|
||||
void
|
||||
CompositorParent::TransformFixedLayers(Layer* aLayer,
|
||||
const gfxPoint& aTranslation,
|
||||
const gfxPoint& aScaleDiff)
|
||||
CompositorParent::TranslateFixedLayers(Layer* aLayer,
|
||||
const gfxPoint& aTranslation)
|
||||
{
|
||||
if (aLayer->GetIsFixedPosition() &&
|
||||
!aLayer->GetParent()->GetIsFixedPosition()) {
|
||||
// When a scale has been applied to a layer, it focuses around (0,0).
|
||||
// The anchor position is used here as a scale focus point (assuming that
|
||||
// aScaleDiff has already been applied) to re-focus the scale.
|
||||
const gfxPoint& anchor = aLayer->GetFixedPositionAnchor();
|
||||
gfxPoint translation(aTranslation.x - (anchor.x - anchor.x / aScaleDiff.x),
|
||||
aTranslation.y - (anchor.y - anchor.y / aScaleDiff.y));
|
||||
|
||||
gfx3DMatrix layerTransform = aLayer->GetTransform();
|
||||
Translate2D(layerTransform, translation);
|
||||
Translate2D(layerTransform, aTranslation);
|
||||
ShadowLayer* shadow = aLayer->AsShadowLayer();
|
||||
shadow->SetShadowTransform(layerTransform);
|
||||
|
||||
const nsIntRect* clipRect = aLayer->GetClipRect();
|
||||
if (clipRect) {
|
||||
nsIntRect transformedClipRect(*clipRect);
|
||||
transformedClipRect.MoveBy(translation.x, translation.y);
|
||||
transformedClipRect.MoveBy(aTranslation.x, aTranslation.y);
|
||||
shadow->SetShadowClipRect(&transformedClipRect);
|
||||
}
|
||||
}
|
||||
|
||||
for (Layer* child = aLayer->GetFirstChild();
|
||||
child; child = child->GetNextSibling()) {
|
||||
TransformFixedLayers(child, aTranslation, aScaleDiff);
|
||||
TranslateFixedLayers(child, aTranslation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,30 +411,16 @@ CompositorParent::TransformShadowTree()
|
|||
ViewTransform treeTransform(-scrollCompensation, mXScale, mYScale);
|
||||
shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform);
|
||||
|
||||
// Translate fixed position layers so that they stay in the correct position
|
||||
// when mScrollOffset and metricsScrollOffset differ.
|
||||
gfxPoint scaleDiff(tempScaleDiffX, tempScaleDiffY);
|
||||
gfxPoint offset(clamped(mScrollOffset.x / tempScaleDiffX, mContentRect.x / tempScaleDiffX,
|
||||
(mContentRect.XMost() - mWidgetSize.width / tempScaleDiffX)) -
|
||||
metricsScrollOffset.x,
|
||||
clamped(mScrollOffset.y / tempScaleDiffY, mContentRect.y / tempScaleDiffY,
|
||||
(mContentRect.YMost() - mWidgetSize.height / tempScaleDiffY)) -
|
||||
metricsScrollOffset.y);
|
||||
// Alter the scroll offset so that fixed position layers remain within
|
||||
// the page area.
|
||||
float offsetX = mScrollOffset.x / tempScaleDiffX;
|
||||
float offsetY = mScrollOffset.y / tempScaleDiffY;
|
||||
offsetX = NS_MAX((float)mContentRect.x, NS_MIN(offsetX, (float)(mContentRect.XMost() - mWidgetSize.width)));
|
||||
offsetY = NS_MAX((float)mContentRect.y, NS_MIN(offsetY, (float)(mContentRect.YMost() - mWidgetSize.height)));
|
||||
gfxPoint reverseViewTranslation(offsetX - metricsScrollOffset.x,
|
||||
offsetY - metricsScrollOffset.y);
|
||||
|
||||
// If the contents can fit entirely within the widget area on a particular
|
||||
// dimenson, we need to translate and scale so that the fixed layers remain
|
||||
// within the page boundaries.
|
||||
if (mContentRect.width * tempScaleDiffX < mWidgetSize.width) {
|
||||
offset.x = -metricsScrollOffset.x;
|
||||
scaleDiff.x = NS_MIN(1.0f, mWidgetSize.width / (float)mContentRect.width);
|
||||
}
|
||||
|
||||
if (mContentRect.height * tempScaleDiffY < mWidgetSize.height) {
|
||||
offset.y = -metricsScrollOffset.y;
|
||||
scaleDiff.y = NS_MIN(1.0f, mWidgetSize.height / (float)mContentRect.height);
|
||||
}
|
||||
|
||||
TransformFixedLayers(layer, offset, scaleDiff);
|
||||
TranslateFixedLayers(layer, reverseViewTranslation);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -107,15 +107,10 @@ private:
|
|||
Layer* GetPrimaryScrollableLayer();
|
||||
|
||||
/**
|
||||
* Recursively applies the given translation to all top-level fixed position
|
||||
* layers that are descendants of the given layer.
|
||||
* aScaleDiff is considered to be the scale transformation applied when
|
||||
* displaying the layers, and is used to make sure the anchor points of
|
||||
* fixed position layers remain in the same position.
|
||||
* Recursively applies the given translation to all fixed position layers
|
||||
* that aren't children of other fixed position layers.
|
||||
*/
|
||||
void TransformFixedLayers(Layer* aLayer,
|
||||
const gfxPoint& aTranslation,
|
||||
const gfxPoint& aScaleDiff);
|
||||
void TranslateFixedLayers(Layer* aLayer, const gfxPoint& aTranslation);
|
||||
|
||||
nsRefPtr<LayerManager> mLayerManager;
|
||||
nsIWidget* mWidget;
|
||||
|
|
|
@ -12,7 +12,6 @@ include protocol PRenderFrame;
|
|||
include "gfxipc/ShadowLayerUtils.h";
|
||||
|
||||
using gfx3DMatrix;
|
||||
using gfxPoint;
|
||||
using gfxRGBA;
|
||||
using nsIntPoint;
|
||||
using nsIntRect;
|
||||
|
@ -86,7 +85,6 @@ struct CommonLayerAttributes {
|
|||
bool useClipRect;
|
||||
nsIntRect clipRect;
|
||||
bool isFixedPosition;
|
||||
gfxPoint fixedPositionAnchor;
|
||||
nullable PLayer maskLayer;
|
||||
};
|
||||
|
||||
|
|
|
@ -291,7 +291,6 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
|
|||
common.clipRect() = (common.useClipRect() ?
|
||||
*mutant->GetClipRect() : nsIntRect());
|
||||
common.isFixedPosition() = mutant->GetIsFixedPosition();
|
||||
common.fixedPositionAnchor() = mutant->GetFixedPositionAnchor();
|
||||
if (Layer* maskLayer = mutant->GetMaskLayer()) {
|
||||
common.maskLayerChild() = Shadow(maskLayer->AsShadowableLayer());
|
||||
} else {
|
||||
|
|
|
@ -207,7 +207,6 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
|||
static bool fixedPositionLayersEnabled = getenv("MOZ_ENABLE_FIXED_POSITION_LAYERS") != 0;
|
||||
if (fixedPositionLayersEnabled) {
|
||||
layer->SetIsFixedPosition(common.isFixedPosition());
|
||||
layer->SetFixedPositionAnchor(common.fixedPositionAnchor());
|
||||
}
|
||||
if (PLayerParent* maskLayer = common.maskLayerParent()) {
|
||||
layer->SetMaskLayer(cast(maskLayer)->AsLayer());
|
||||
|
|
|
@ -427,27 +427,6 @@ struct ParamTraits<gfxMatrix>
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<gfxPoint>
|
||||
{
|
||||
typedef gfxPoint paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
WriteParam(aMsg, aParam.x);
|
||||
WriteParam(aMsg, aParam.y);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
if (ReadParam(aMsg, aIter, &aResult->x) &&
|
||||
ReadParam(aMsg, aIter, &aResult->y))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<gfxSize>
|
||||
{
|
||||
|
|
|
@ -2002,68 +2002,6 @@ nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|||
return layer.forget();
|
||||
}
|
||||
|
||||
nsDisplayFixedPosition::nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder,
|
||||
nsIFrame* aFrame,
|
||||
nsDisplayList* aList)
|
||||
: nsDisplayOwnLayer(aBuilder, aFrame, aList) {
|
||||
MOZ_COUNT_CTOR(nsDisplayFixedPosition);
|
||||
}
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
nsDisplayFixedPosition::~nsDisplayFixedPosition() {
|
||||
MOZ_COUNT_DTOR(nsDisplayFixedPosition);
|
||||
}
|
||||
#endif
|
||||
|
||||
already_AddRefed<Layer>
|
||||
nsDisplayFixedPosition::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerParameters& aContainerParameters) {
|
||||
nsRefPtr<Layer> layer =
|
||||
nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, aContainerParameters);
|
||||
|
||||
// Work out the anchor point for this fixed position layer. We assume that
|
||||
// any positioning set (left/top/right/bottom) indicates that the
|
||||
// corresponding side of its container should be the anchor point,
|
||||
// defaulting to top-left.
|
||||
nsIFrame* viewportFrame = mFrame->GetParent();
|
||||
nsPresContext *presContext = viewportFrame->PresContext();
|
||||
|
||||
// Fixed position frames are reflowed into the scroll-port size if one has
|
||||
// been set.
|
||||
nsSize containingBlockSize = viewportFrame->GetSize();
|
||||
if (presContext->PresShell()->IsScrollPositionClampingScrollPortSizeSet()) {
|
||||
containingBlockSize = presContext->PresShell()->
|
||||
GetScrollPositionClampingScrollPortSize();
|
||||
}
|
||||
|
||||
// Find out the rect of the viewport frame relative to the reference frame.
|
||||
// This, in conjunction with the container scale, will correspond to the
|
||||
// coordinate-space of the built layer.
|
||||
float factor = presContext->AppUnitsPerDevPixel();
|
||||
nsPoint origin = aBuilder->ToReferenceFrame(viewportFrame);
|
||||
gfxRect anchorRect(NSAppUnitsToFloatPixels(origin.x, factor) *
|
||||
aContainerParameters.mXScale,
|
||||
NSAppUnitsToFloatPixels(origin.y, factor) *
|
||||
aContainerParameters.mYScale,
|
||||
NSAppUnitsToFloatPixels(containingBlockSize.width, factor) *
|
||||
aContainerParameters.mXScale,
|
||||
NSAppUnitsToFloatPixels(containingBlockSize.height, factor) *
|
||||
aContainerParameters.mYScale);
|
||||
|
||||
gfxPoint anchor(anchorRect.x, anchorRect.y);
|
||||
|
||||
const nsStylePosition* position = mFrame->GetStylePosition();
|
||||
if (position->mOffset.GetRightUnit() != eStyleUnit_Auto)
|
||||
anchor.x = anchorRect.XMost();
|
||||
if (position->mOffset.GetBottomUnit() != eStyleUnit_Auto)
|
||||
anchor.y = anchorRect.YMost();
|
||||
|
||||
layer->SetFixedPositionAnchor(anchor);
|
||||
|
||||
return layer.forget();
|
||||
}
|
||||
|
||||
nsDisplayScrollLayer::nsDisplayScrollLayer(nsDisplayListBuilder* aBuilder,
|
||||
nsDisplayList* aList,
|
||||
nsIFrame* aForFrame,
|
||||
|
|
|
@ -1909,25 +1909,6 @@ public:
|
|||
NS_DISPLAY_DECL_NAME("OwnLayer", TYPE_OWN_LAYER)
|
||||
};
|
||||
|
||||
/**
|
||||
* A display item used to represent fixed position elements. This will ensure
|
||||
* the contents gets its own layer, and that the built layer will have
|
||||
* position-related metadata set on it.
|
||||
*/
|
||||
class nsDisplayFixedPosition : public nsDisplayOwnLayer {
|
||||
public:
|
||||
nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
||||
nsDisplayList* aList);
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
virtual ~nsDisplayFixedPosition();
|
||||
#endif
|
||||
|
||||
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerParameters& aContainerParameters);
|
||||
NS_DISPLAY_DECL_NAME("FixedPosition", TYPE_OWN_LAYER)
|
||||
};
|
||||
|
||||
/**
|
||||
* This potentially creates a layer for the given list of items, whose
|
||||
* visibility is determined by the displayport for the given frame instead of
|
||||
|
|
|
@ -8965,23 +8965,9 @@ PresShell::SizeOfTextRuns(nsMallocSizeOfFun aMallocSizeOf) const
|
|||
void
|
||||
nsIPresShell::SetScrollPositionClampingScrollPortSize(nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
if (!mScrollPositionClampingScrollPortSizeSet ||
|
||||
mScrollPositionClampingScrollPortSize.width != aWidth ||
|
||||
mScrollPositionClampingScrollPortSize.height != aHeight) {
|
||||
mScrollPositionClampingScrollPortSizeSet = true;
|
||||
mScrollPositionClampingScrollPortSize.width = aWidth;
|
||||
mScrollPositionClampingScrollPortSize.height = aHeight;
|
||||
|
||||
// Reflow fixed position children.
|
||||
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
|
||||
if (rootFrame) {
|
||||
const nsFrameList& childList = rootFrame->GetChildList(nsIFrame::kFixedList);
|
||||
for (nsIFrame* child = childList.FirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
FrameNeedsReflow(child, eResize, NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
mScrollPositionClampingScrollPortSizeSet = true;
|
||||
mScrollPositionClampingScrollPortSize.width = aWidth;
|
||||
mScrollPositionClampingScrollPortSize.height = aHeight;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -2168,16 +2168,8 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
|
|||
// Genuine stacking contexts, and positioned pseudo-stacking-contexts,
|
||||
// go in this level.
|
||||
if (!list.IsEmpty()) {
|
||||
// Make sure the root of a fixed position frame sub-tree gets the
|
||||
// correct displaylist item type.
|
||||
nsDisplayItem* item;
|
||||
if (!child->GetParent()->GetParent() &&
|
||||
disp->mPosition == NS_STYLE_POSITION_FIXED) {
|
||||
item = new (aBuilder) nsDisplayFixedPosition(aBuilder, child, &list);
|
||||
} else {
|
||||
item = new (aBuilder) nsDisplayWrapList(aBuilder, child, &list);
|
||||
}
|
||||
rv = aLists.PositionedDescendants()->AppendNewToTop(item);
|
||||
rv = aLists.PositionedDescendants()->AppendNewToTop(new (aBuilder)
|
||||
nsDisplayWrapList(aBuilder, child, &list));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
} else if (disp->IsFloating()) {
|
||||
|
|
|
@ -234,20 +234,10 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
|
|||
"We don't handle correct positioning of fixed frames with "
|
||||
"scrollbars in odd positions");
|
||||
|
||||
// If a scroll position clamping scroll-port size has been set, layout
|
||||
// fixed position elements to this size instead of the computed size.
|
||||
nscoord width = reflowState.ComputedWidth();
|
||||
nscoord height = reflowState.ComputedHeight();
|
||||
if (aPresContext->PresShell()->IsScrollPositionClampingScrollPortSizeSet()) {
|
||||
nsSize size = aPresContext->PresShell()->
|
||||
GetScrollPositionClampingScrollPortSize();
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
}
|
||||
|
||||
// Just reflow all the fixed-pos frames.
|
||||
rv = GetAbsoluteContainingBlock()->Reflow(this, aPresContext, reflowState, aStatus,
|
||||
width, height,
|
||||
reflowState.ComputedWidth(),
|
||||
reflowState.ComputedHeight(),
|
||||
false, true, true, // XXX could be optimized
|
||||
&aDesiredSize.mOverflowAreas);
|
||||
}
|
||||
|
|
|
@ -2328,17 +2328,11 @@ Tab.prototype = {
|
|||
let x = aViewport.x / aViewport.zoom;
|
||||
let y = aViewport.y / aViewport.zoom;
|
||||
|
||||
// Set scroll position and scroll-port clamping size
|
||||
let [pageWidth, pageHeight] = this.getPageSize(this.browser.contentDocument,
|
||||
aViewport.width, aViewport.height);
|
||||
let scrollPortWidth = Math.min(gScreenWidth / aViewport.zoom, pageWidth);
|
||||
let scrollPortHeight = Math.min(gScreenHeight / aViewport.zoom, pageHeight);
|
||||
|
||||
// Set scroll position
|
||||
let win = this.browser.contentWindow;
|
||||
win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).
|
||||
setScrollPositionClampingScrollPortSize(scrollPortWidth, scrollPortHeight);
|
||||
win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).setScrollPositionClampingScrollPortSize(
|
||||
gScreenWidth / aViewport.zoom, gScreenHeight / aViewport.zoom);
|
||||
win.scrollTo(x, y);
|
||||
|
||||
this.userScrollPos.x = win.scrollX;
|
||||
this.userScrollPos.y = win.scrollY;
|
||||
this.setResolution(aViewport.zoom, false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче