Bug 886298 - Convert Layers fixed position margins to typed units. r=kats

This commit is contained in:
Chris Lord 2013-07-22 09:50:13 +01:00
parent e3186541d9
commit 10605e0e62
10 changed files with 55 additions and 33 deletions

View File

@ -879,7 +879,7 @@ public:
* layer represents are auto-positioned, and so fixed position margins should * layer represents are auto-positioned, and so fixed position margins should
* not have an effect on the corresponding axis. * not have an effect on the corresponding axis.
*/ */
void SetFixedPositionMargins(const gfx::Margin& aMargins) void SetFixedPositionMargins(const LayerMargin& aMargins)
{ {
if (mMargins != aMargins) { if (mMargins != aMargins) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FixedPositionMargins", this)); MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FixedPositionMargins", this));
@ -906,7 +906,7 @@ public:
float GetPostYScale() const { return mPostYScale; } float GetPostYScale() const { return mPostYScale; }
bool GetIsFixedPosition() { return mIsFixedPosition; } bool GetIsFixedPosition() { return mIsFixedPosition; }
LayerPoint GetFixedPositionAnchor() { return mAnchor; } LayerPoint GetFixedPositionAnchor() { return mAnchor; }
const gfx::Margin& GetFixedPositionMargins() { return mMargins; } const LayerMargin& GetFixedPositionMargins() { return mMargins; }
Layer* GetMaskLayer() const { return mMaskLayer; } Layer* GetMaskLayer() const { return mMaskLayer; }
// Note that all lengths in animation data are either in CSS pixels or app // Note that all lengths in animation data are either in CSS pixels or app
@ -1261,7 +1261,7 @@ protected:
bool mUseTileSourceRect; bool mUseTileSourceRect;
bool mIsFixedPosition; bool mIsFixedPosition;
LayerPoint mAnchor; LayerPoint mAnchor;
gfx::Margin mMargins; LayerMargin mMargins;
DebugOnly<uint32_t> mDebugColorIndex; DebugOnly<uint32_t> mDebugColorIndex;
// If this layer is used for OMTA, then this counter is used to ensure we // If this layer is used for OMTA, then this counter is used to ensure we
// stay in sync with the animation manager // stay in sync with the animation manager

View File

@ -174,14 +174,14 @@ AccumulateLayerTransforms2D(Layer* aLayer,
static LayerPoint static LayerPoint
GetLayerFixedMarginsOffset(Layer* aLayer, GetLayerFixedMarginsOffset(Layer* aLayer,
const gfx::Margin& aFixedLayerMargins) const LayerMargin& aFixedLayerMargins)
{ {
// Work out the necessary translation, in root scrollable layer space. // Work out the necessary translation, in root scrollable layer space.
// Because fixed layer margins are stored relative to the root scrollable // Because fixed layer margins are stored relative to the root scrollable
// layer, we can just take the difference between these values. // layer, we can just take the difference between these values.
LayerPoint translation; LayerPoint translation;
const LayerPoint& anchor = aLayer->GetFixedPositionAnchor(); const LayerPoint& anchor = aLayer->GetFixedPositionAnchor();
const gfx::Margin& fixedMargins = aLayer->GetFixedPositionMargins(); const LayerMargin& fixedMargins = aLayer->GetFixedPositionMargins();
if (fixedMargins.left >= 0) { if (fixedMargins.left >= 0) {
if (anchor.x > 0) { if (anchor.x > 0) {
@ -206,7 +206,7 @@ void
AsyncCompositionManager::AlignFixedLayersForAnchorPoint(Layer* aLayer, AsyncCompositionManager::AlignFixedLayersForAnchorPoint(Layer* aLayer,
Layer* aTransformedSubtreeRoot, Layer* aTransformedSubtreeRoot,
const gfx3DMatrix& aPreviousTransformForRoot, const gfx3DMatrix& aPreviousTransformForRoot,
const gfx::Margin& aFixedLayerMargins) const LayerMargin& aFixedLayerMargins)
{ {
if (aLayer != aTransformedSubtreeRoot && aLayer->GetIsFixedPosition() && if (aLayer != aTransformedSubtreeRoot && aLayer->GetIsFixedPosition() &&
!aLayer->GetParent()->GetIsFixedPosition()) { !aLayer->GetParent()->GetIsFixedPosition()) {
@ -451,7 +451,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram
/ LayerToLayoutDeviceScale(rootTransform.GetXScale(), rootTransform.GetYScale()); / LayerToLayoutDeviceScale(rootTransform.GetXScale(), rootTransform.GetYScale());
CSSRect displayPort(metrics.mCriticalDisplayPort.IsEmpty() ? CSSRect displayPort(metrics.mCriticalDisplayPort.IsEmpty() ?
metrics.mDisplayPort : metrics.mCriticalDisplayPort); metrics.mDisplayPort : metrics.mCriticalDisplayPort);
gfx::Margin fixedLayerMargins(0, 0, 0, 0); LayerMargin fixedLayerMargins(0, 0, 0, 0);
ScreenPoint offset(0, 0); ScreenPoint offset(0, 0);
SyncFrameMetrics(scrollOffset, treeTransform.mScale.scale, metrics.mScrollableRect, SyncFrameMetrics(scrollOffset, treeTransform.mScale.scale, metrics.mScrollableRect,
mLayersUpdated, displayPort, paintScale, mLayersUpdated, displayPort, paintScale,
@ -537,7 +537,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const LayoutDev
) * geckoZoom); ) * geckoZoom);
displayPort += scrollOffsetLayerPixels; displayPort += scrollOffsetLayerPixels;
gfx::Margin fixedLayerMargins(0, 0, 0, 0); LayerMargin fixedLayerMargins(0, 0, 0, 0);
ScreenPoint offset(0, 0); ScreenPoint offset(0, 0);
// Ideally we would initialize userZoom to AsyncPanZoomController::CalculateResolution(metrics) // Ideally we would initialize userZoom to AsyncPanZoomController::CalculateResolution(metrics)
@ -699,7 +699,7 @@ AsyncCompositionManager::SyncViewportInfo(const LayerIntRect& aDisplayPort,
bool aLayersUpdated, bool aLayersUpdated,
ScreenPoint& aScrollOffset, ScreenPoint& aScrollOffset,
CSSToScreenScale& aScale, CSSToScreenScale& aScale,
gfx::Margin& aFixedLayerMargins, LayerMargin& aFixedLayerMargins,
ScreenPoint& aOffset) ScreenPoint& aOffset)
{ {
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID
@ -721,7 +721,7 @@ AsyncCompositionManager::SyncFrameMetrics(const ScreenPoint& aScrollOffset,
const CSSRect& aDisplayPort, const CSSRect& aDisplayPort,
const CSSToLayerScale& aDisplayResolution, const CSSToLayerScale& aDisplayResolution,
bool aIsFirstPaint, bool aIsFirstPaint,
gfx::Margin& aFixedLayerMargins, LayerMargin& aFixedLayerMargins,
ScreenPoint& aOffset) ScreenPoint& aOffset)
{ {
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID

View File

@ -131,7 +131,7 @@ private:
bool aLayersUpdated, bool aLayersUpdated,
ScreenPoint& aScrollOffset, ScreenPoint& aScrollOffset,
CSSToScreenScale& aScale, CSSToScreenScale& aScale,
gfx::Margin& aFixedLayerMargins, LayerMargin& aFixedLayerMargins,
ScreenPoint& aOffset); ScreenPoint& aOffset);
void SyncFrameMetrics(const ScreenPoint& aScrollOffset, void SyncFrameMetrics(const ScreenPoint& aScrollOffset,
float aZoom, float aZoom,
@ -140,7 +140,7 @@ private:
const CSSRect& aDisplayPort, const CSSRect& aDisplayPort,
const CSSToLayerScale& aDisplayResolution, const CSSToLayerScale& aDisplayResolution,
bool aIsFirstPaint, bool aIsFirstPaint,
gfx::Margin& aFixedLayerMargins, LayerMargin& aFixedLayerMargins,
ScreenPoint& aOffset); ScreenPoint& aOffset);
/** /**
@ -156,7 +156,7 @@ private:
void AlignFixedLayersForAnchorPoint(Layer* aLayer, void AlignFixedLayersForAnchorPoint(Layer* aLayer,
Layer* aTransformedSubtreeRoot, Layer* aTransformedSubtreeRoot,
const gfx3DMatrix& aPreviousTransformForRoot, const gfx3DMatrix& aPreviousTransformForRoot,
const gfx::Margin& aFixedLayerMargins); const LayerMargin& aFixedLayerMargins);
/** /**
* DRAWING PHASE ONLY * DRAWING PHASE ONLY

View File

@ -29,8 +29,8 @@ using mozilla::ScreenRotation;
using nsCSSProperty; using nsCSSProperty;
using mozilla::dom::ScreenOrientation; using mozilla::dom::ScreenOrientation;
using mozilla::layers::TextureInfo; using mozilla::layers::TextureInfo;
using mozilla::LayerMargin;
using mozilla::LayerPoint; using mozilla::LayerPoint;
using mozilla::gfx::Margin;
using mozilla::layers::ImageLayer::ScaleMode; using mozilla::layers::ImageLayer::ScaleMode;
namespace mozilla { namespace mozilla {
@ -188,7 +188,7 @@ struct CommonLayerAttributes {
nsIntRect clipRect; nsIntRect clipRect;
bool isFixedPosition; bool isFixedPosition;
LayerPoint fixedPositionAnchor; LayerPoint fixedPositionAnchor;
Margin fixedPositionMargin; LayerMargin fixedPositionMargin;
nullable PLayer maskLayer; nullable PLayer maskLayer;
// Animated colors will only honored for ColorLayers. // Animated colors will only honored for ColorLayers.
Animation[] animations; Animation[] animations;

View File

@ -924,6 +924,28 @@ struct ParamTraits<mozilla::gfx::Margin>
} }
}; };
template<class T>
struct ParamTraits< mozilla::gfx::MarginTyped<T> >
{
typedef mozilla::gfx::MarginTyped<T> paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.top);
WriteParam(msg, param.right);
WriteParam(msg, param.bottom);
WriteParam(msg, param.left);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->top) &&
ReadParam(msg, iter, &result->right) &&
ReadParam(msg, iter, &result->bottom) &&
ReadParam(msg, iter, &result->left));
}
};
template<> template<>
struct ParamTraits<nsRect> struct ParamTraits<nsRect>
{ {

View File

@ -3116,14 +3116,14 @@ nsDisplayFixedPosition::BuildLayer(nsDisplayListBuilder* aBuilder,
// Also make sure the layer is aware of any fixed position margins that have // Also make sure the layer is aware of any fixed position margins that have
// been set. // been set.
nsMargin fixedMargins = presContext->PresShell()->GetContentDocumentFixedPositionMargins(); nsMargin fixedMargins = presContext->PresShell()->GetContentDocumentFixedPositionMargins();
mozilla::gfx::Margin fixedLayerMargins(NSAppUnitsToFloatPixels(fixedMargins.top, factor) * LayerMargin fixedLayerMargins(NSAppUnitsToFloatPixels(fixedMargins.top, factor) *
aContainerParameters.mYScale, aContainerParameters.mYScale,
NSAppUnitsToFloatPixels(fixedMargins.right, factor) * NSAppUnitsToFloatPixels(fixedMargins.right, factor) *
aContainerParameters.mXScale, aContainerParameters.mXScale,
NSAppUnitsToFloatPixels(fixedMargins.bottom, factor) * NSAppUnitsToFloatPixels(fixedMargins.bottom, factor) *
aContainerParameters.mYScale, aContainerParameters.mYScale,
NSAppUnitsToFloatPixels(fixedMargins.left, factor) * NSAppUnitsToFloatPixels(fixedMargins.left, factor) *
aContainerParameters.mXScale); aContainerParameters.mXScale);
// If the frame is auto-positioned on either axis, set the top/left layer // If the frame is auto-positioned on either axis, set the top/left layer
// margins to -1, to indicate to the compositor that this layer is // margins to -1, to indicate to the compositor that this layer is

View File

@ -2161,7 +2161,7 @@ AndroidBridge::SetPageRect(const CSSRect& aCssPageRect)
void void
AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution, AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale, bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset) LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
{ {
AndroidGeckoLayerClient *client = mLayerClient; AndroidGeckoLayerClient *client = mLayerClient;
if (!client) if (!client)
@ -2174,7 +2174,7 @@ AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLay
void AndroidBridge::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect, void AndroidBridge::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution, bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset) bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
{ {
AndroidGeckoLayerClient *client = mLayerClient; AndroidGeckoLayerClient *client = mLayerClient;
if (!client) if (!client)

View File

@ -376,10 +376,10 @@ public:
void SetPageRect(const CSSRect& aCssPageRect); void SetPageRect(const CSSRect& aCssPageRect);
void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution, void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale, bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset); LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset);
void SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect, void SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution, bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset); bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset);
void AddPluginView(jobject view, const gfxRect& rect, bool isFullScreen); void AddPluginView(jobject view, const gfxRect& rect, bool isFullScreen);
void RemovePluginView(jobject view, bool isFullScreen); void RemovePluginView(jobject view, bool isFullScreen);

View File

@ -949,7 +949,7 @@ AndroidGeckoLayerClient::SetPageRect(const CSSRect& aCssPageRect)
void void
AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution, AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale, bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset) LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
{ {
NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!"); NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
@ -981,7 +981,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, cons
void void
AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect, AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution, bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset) bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
{ {
NS_ASSERTION(!isNull(), "SyncFrameMetrics called on null layer client!"); NS_ASSERTION(!isNull(), "SyncFrameMetrics called on null layer client!");
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
@ -1258,7 +1258,7 @@ AndroidViewTransform::GetScale(JNIEnv *env)
} }
void void
AndroidViewTransform::GetFixedLayerMargins(JNIEnv *env, gfx::Margin &aFixedLayerMargins) AndroidViewTransform::GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins)
{ {
if (!env) if (!env)
return; return;

View File

@ -197,7 +197,7 @@ public:
float GetX(JNIEnv *env); float GetX(JNIEnv *env);
float GetY(JNIEnv *env); float GetY(JNIEnv *env);
float GetScale(JNIEnv *env); float GetScale(JNIEnv *env);
void GetFixedLayerMargins(JNIEnv *env, gfx::Margin &aFixedLayerMargins); void GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins);
float GetOffsetX(JNIEnv *env); float GetOffsetX(JNIEnv *env);
float GetOffsetY(JNIEnv *env); float GetOffsetY(JNIEnv *env);
@ -273,10 +273,10 @@ public:
void SetPageRect(const CSSRect& aCssPageRect); void SetPageRect(const CSSRect& aCssPageRect);
void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution, void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale, bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset); LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset);
void SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect, void SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution, bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset); bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset);
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY); bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame); bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
bool ActivateProgram(AutoLocalJNIFrame *jniFrame); bool ActivateProgram(AutoLocalJNIFrame *jniFrame);