mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 886298 - Convert Layers fixed position margins to typed units. r=kats
This commit is contained in:
parent
e3186541d9
commit
10605e0e62
@ -879,7 +879,7 @@ public:
|
||||
* layer represents are auto-positioned, and so fixed position margins should
|
||||
* not have an effect on the corresponding axis.
|
||||
*/
|
||||
void SetFixedPositionMargins(const gfx::Margin& aMargins)
|
||||
void SetFixedPositionMargins(const LayerMargin& aMargins)
|
||||
{
|
||||
if (mMargins != aMargins) {
|
||||
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) FixedPositionMargins", this));
|
||||
@ -906,7 +906,7 @@ public:
|
||||
float GetPostYScale() const { return mPostYScale; }
|
||||
bool GetIsFixedPosition() { return mIsFixedPosition; }
|
||||
LayerPoint GetFixedPositionAnchor() { return mAnchor; }
|
||||
const gfx::Margin& GetFixedPositionMargins() { return mMargins; }
|
||||
const LayerMargin& GetFixedPositionMargins() { return mMargins; }
|
||||
Layer* GetMaskLayer() const { return mMaskLayer; }
|
||||
|
||||
// Note that all lengths in animation data are either in CSS pixels or app
|
||||
@ -1261,7 +1261,7 @@ protected:
|
||||
bool mUseTileSourceRect;
|
||||
bool mIsFixedPosition;
|
||||
LayerPoint mAnchor;
|
||||
gfx::Margin mMargins;
|
||||
LayerMargin mMargins;
|
||||
DebugOnly<uint32_t> mDebugColorIndex;
|
||||
// If this layer is used for OMTA, then this counter is used to ensure we
|
||||
// stay in sync with the animation manager
|
||||
|
@ -174,14 +174,14 @@ AccumulateLayerTransforms2D(Layer* aLayer,
|
||||
|
||||
static LayerPoint
|
||||
GetLayerFixedMarginsOffset(Layer* aLayer,
|
||||
const gfx::Margin& aFixedLayerMargins)
|
||||
const LayerMargin& aFixedLayerMargins)
|
||||
{
|
||||
// Work out the necessary translation, in root scrollable layer space.
|
||||
// Because fixed layer margins are stored relative to the root scrollable
|
||||
// layer, we can just take the difference between these values.
|
||||
LayerPoint translation;
|
||||
const LayerPoint& anchor = aLayer->GetFixedPositionAnchor();
|
||||
const gfx::Margin& fixedMargins = aLayer->GetFixedPositionMargins();
|
||||
const LayerMargin& fixedMargins = aLayer->GetFixedPositionMargins();
|
||||
|
||||
if (fixedMargins.left >= 0) {
|
||||
if (anchor.x > 0) {
|
||||
@ -206,7 +206,7 @@ void
|
||||
AsyncCompositionManager::AlignFixedLayersForAnchorPoint(Layer* aLayer,
|
||||
Layer* aTransformedSubtreeRoot,
|
||||
const gfx3DMatrix& aPreviousTransformForRoot,
|
||||
const gfx::Margin& aFixedLayerMargins)
|
||||
const LayerMargin& aFixedLayerMargins)
|
||||
{
|
||||
if (aLayer != aTransformedSubtreeRoot && aLayer->GetIsFixedPosition() &&
|
||||
!aLayer->GetParent()->GetIsFixedPosition()) {
|
||||
@ -451,7 +451,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram
|
||||
/ LayerToLayoutDeviceScale(rootTransform.GetXScale(), rootTransform.GetYScale());
|
||||
CSSRect displayPort(metrics.mCriticalDisplayPort.IsEmpty() ?
|
||||
metrics.mDisplayPort : metrics.mCriticalDisplayPort);
|
||||
gfx::Margin fixedLayerMargins(0, 0, 0, 0);
|
||||
LayerMargin fixedLayerMargins(0, 0, 0, 0);
|
||||
ScreenPoint offset(0, 0);
|
||||
SyncFrameMetrics(scrollOffset, treeTransform.mScale.scale, metrics.mScrollableRect,
|
||||
mLayersUpdated, displayPort, paintScale,
|
||||
@ -537,7 +537,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const LayoutDev
|
||||
) * geckoZoom);
|
||||
displayPort += scrollOffsetLayerPixels;
|
||||
|
||||
gfx::Margin fixedLayerMargins(0, 0, 0, 0);
|
||||
LayerMargin fixedLayerMargins(0, 0, 0, 0);
|
||||
ScreenPoint offset(0, 0);
|
||||
|
||||
// Ideally we would initialize userZoom to AsyncPanZoomController::CalculateResolution(metrics)
|
||||
@ -699,7 +699,7 @@ AsyncCompositionManager::SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
||||
bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset,
|
||||
CSSToScreenScale& aScale,
|
||||
gfx::Margin& aFixedLayerMargins,
|
||||
LayerMargin& aFixedLayerMargins,
|
||||
ScreenPoint& aOffset)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
@ -721,7 +721,7 @@ AsyncCompositionManager::SyncFrameMetrics(const ScreenPoint& aScrollOffset,
|
||||
const CSSRect& aDisplayPort,
|
||||
const CSSToLayerScale& aDisplayResolution,
|
||||
bool aIsFirstPaint,
|
||||
gfx::Margin& aFixedLayerMargins,
|
||||
LayerMargin& aFixedLayerMargins,
|
||||
ScreenPoint& aOffset)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
@ -131,7 +131,7 @@ private:
|
||||
bool aLayersUpdated,
|
||||
ScreenPoint& aScrollOffset,
|
||||
CSSToScreenScale& aScale,
|
||||
gfx::Margin& aFixedLayerMargins,
|
||||
LayerMargin& aFixedLayerMargins,
|
||||
ScreenPoint& aOffset);
|
||||
void SyncFrameMetrics(const ScreenPoint& aScrollOffset,
|
||||
float aZoom,
|
||||
@ -140,7 +140,7 @@ private:
|
||||
const CSSRect& aDisplayPort,
|
||||
const CSSToLayerScale& aDisplayResolution,
|
||||
bool aIsFirstPaint,
|
||||
gfx::Margin& aFixedLayerMargins,
|
||||
LayerMargin& aFixedLayerMargins,
|
||||
ScreenPoint& aOffset);
|
||||
|
||||
/**
|
||||
@ -156,7 +156,7 @@ private:
|
||||
void AlignFixedLayersForAnchorPoint(Layer* aLayer,
|
||||
Layer* aTransformedSubtreeRoot,
|
||||
const gfx3DMatrix& aPreviousTransformForRoot,
|
||||
const gfx::Margin& aFixedLayerMargins);
|
||||
const LayerMargin& aFixedLayerMargins);
|
||||
|
||||
/**
|
||||
* DRAWING PHASE ONLY
|
||||
|
@ -29,8 +29,8 @@ using mozilla::ScreenRotation;
|
||||
using nsCSSProperty;
|
||||
using mozilla::dom::ScreenOrientation;
|
||||
using mozilla::layers::TextureInfo;
|
||||
using mozilla::LayerMargin;
|
||||
using mozilla::LayerPoint;
|
||||
using mozilla::gfx::Margin;
|
||||
using mozilla::layers::ImageLayer::ScaleMode;
|
||||
|
||||
namespace mozilla {
|
||||
@ -188,7 +188,7 @@ struct CommonLayerAttributes {
|
||||
nsIntRect clipRect;
|
||||
bool isFixedPosition;
|
||||
LayerPoint fixedPositionAnchor;
|
||||
Margin fixedPositionMargin;
|
||||
LayerMargin fixedPositionMargin;
|
||||
nullable PLayer maskLayer;
|
||||
// Animated colors will only honored for ColorLayers.
|
||||
Animation[] animations;
|
||||
|
@ -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<>
|
||||
struct ParamTraits<nsRect>
|
||||
{
|
||||
|
@ -3116,14 +3116,14 @@ nsDisplayFixedPosition::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
// Also make sure the layer is aware of any fixed position margins that have
|
||||
// been set.
|
||||
nsMargin fixedMargins = presContext->PresShell()->GetContentDocumentFixedPositionMargins();
|
||||
mozilla::gfx::Margin fixedLayerMargins(NSAppUnitsToFloatPixels(fixedMargins.top, factor) *
|
||||
aContainerParameters.mYScale,
|
||||
NSAppUnitsToFloatPixels(fixedMargins.right, factor) *
|
||||
aContainerParameters.mXScale,
|
||||
NSAppUnitsToFloatPixels(fixedMargins.bottom, factor) *
|
||||
aContainerParameters.mYScale,
|
||||
NSAppUnitsToFloatPixels(fixedMargins.left, factor) *
|
||||
aContainerParameters.mXScale);
|
||||
LayerMargin fixedLayerMargins(NSAppUnitsToFloatPixels(fixedMargins.top, factor) *
|
||||
aContainerParameters.mYScale,
|
||||
NSAppUnitsToFloatPixels(fixedMargins.right, factor) *
|
||||
aContainerParameters.mXScale,
|
||||
NSAppUnitsToFloatPixels(fixedMargins.bottom, factor) *
|
||||
aContainerParameters.mYScale,
|
||||
NSAppUnitsToFloatPixels(fixedMargins.left, factor) *
|
||||
aContainerParameters.mXScale);
|
||||
|
||||
// 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
|
||||
|
@ -2161,7 +2161,7 @@ AndroidBridge::SetPageRect(const CSSRect& aCssPageRect)
|
||||
void
|
||||
AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
@ -2174,7 +2174,7 @@ AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLay
|
||||
|
||||
void AndroidBridge::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
|
@ -376,10 +376,10 @@ public:
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
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,
|
||||
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 RemovePluginView(jobject view, bool isFullScreen);
|
||||
|
@ -949,7 +949,7 @@ AndroidGeckoLayerClient::SetPageRect(const CSSRect& aCssPageRect)
|
||||
void
|
||||
AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
gfx::Margin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
|
||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
||||
@ -981,7 +981,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, cons
|
||||
void
|
||||
AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
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!");
|
||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
||||
@ -1258,7 +1258,7 @@ AndroidViewTransform::GetScale(JNIEnv *env)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidViewTransform::GetFixedLayerMargins(JNIEnv *env, gfx::Margin &aFixedLayerMargins)
|
||||
AndroidViewTransform::GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins)
|
||||
{
|
||||
if (!env)
|
||||
return;
|
||||
|
@ -197,7 +197,7 @@ public:
|
||||
float GetX(JNIEnv *env);
|
||||
float GetY(JNIEnv *env);
|
||||
float GetScale(JNIEnv *env);
|
||||
void GetFixedLayerMargins(JNIEnv *env, gfx::Margin &aFixedLayerMargins);
|
||||
void GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins);
|
||||
float GetOffsetX(JNIEnv *env);
|
||||
float GetOffsetY(JNIEnv *env);
|
||||
|
||||
@ -273,10 +273,10 @@ public:
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
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,
|
||||
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 CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
|
||||
bool ActivateProgram(AutoLocalJNIFrame *jniFrame);
|
||||
|
Loading…
Reference in New Issue
Block a user