Bug 1295084 Part 2 - Move two Position methods into nsStyleImageLayers.
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -6143,17 +6143,18 @@ nsComputedDOMStyle::DoGetMask()
// Mask is now a shorthand, but it used to be a longhand, so that we
// need to support computed style for the cases where it used to be
// a longhand.
if (svg->mMask.mImageCount > 1 ||
firstLayer.mClip != NS_STYLE_IMAGELAYER_CLIP_BORDER ||
firstLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_BORDER ||
firstLayer.mComposite != NS_STYLE_MASK_COMPOSITE_ADD ||
firstLayer.mMaskMode != NS_STYLE_MASK_MODE_MATCH_SOURCE ||
- !firstLayer.mPosition.IsInitialValue(nsStyleImageLayers::LayerType::Mask) ||
+ !nsStyleImageLayers::IsInitialPositionForLayerType(
+ firstLayer.mPosition, nsStyleImageLayers::LayerType::Mask) ||
!firstLayer.mRepeat.IsInitialValue(nsStyleImageLayers::LayerType::Mask) ||
!firstLayer.mSize.IsInitialValue() ||
!(firstLayer.mImage.GetType() == eStyleImageType_Null ||
firstLayer.mImage.GetType() == eStyleImageType_Image)) {
return nullptr;
}
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -7268,17 +7268,17 @@ nsRuleNode::ComputeBackgroundData(void*
uint8_t(NS_STYLE_IMAGELAYER_ORIGIN_PADDING),
parentBG->mImage.mOriginCount,
bg->mImage.mOriginCount, maxItemCount, rebuild,
conditions);
// background-position-x/y: enum, length, percent (flags), inherit [list]
nsStyleImageLayers::Position::PositionCoord initialPositionCoord;
initialPositionCoord.mPercent =
- nsStyleImageLayers::Position::GetInitialValue(
+ nsStyleImageLayers::GetInitialPositionForLayerType(
nsStyleImageLayers::LayerType::Background);
initialPositionCoord.mLength = 0;
initialPositionCoord.mHasPercent = true;
SetImageLayerPositionCoordList(
aContext, *aRuleData->ValueForBackgroundPositionX(),
bg->mImage.mLayers,
parentBG->mImage.mLayers,
@@ -10032,17 +10032,17 @@ nsRuleNode::ComputeSVGResetData(void* aS
uint8_t(NS_STYLE_IMAGELAYER_ORIGIN_BORDER),
parentSVGReset->mMask.mOriginCount,
svgReset->mMask.mOriginCount, maxItemCount, rebuild,
conditions);
// mask-position-x/y: enum, length, percent (flags), inherit [list]
nsStyleImageLayers::Position::PositionCoord initialPositionCoord;
initialPositionCoord.mPercent =
- nsStyleImageLayers::Position::GetInitialValue(
+ nsStyleImageLayers::GetInitialPositionForLayerType(
nsStyleImageLayers::LayerType::Mask);
initialPositionCoord.mLength = 0;
initialPositionCoord.mHasPercent = true;
SetImageLayerPositionCoordList(
aContext, *aRuleData->ValueForMaskPositionX(),
svgReset->mMask.mLayers,
parentSVGReset->mMask.mLayers,
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2485,22 +2485,25 @@ nsStyleImageLayers::HasLayerWithImage()
return true;
}
}
return false;
}
bool
-nsStyleImageLayers::Position::IsInitialValue(LayerType aType) const
+nsStyleImageLayers::IsInitialPositionForLayerType(Position aPosition, LayerType aType)
{
- float intialValue = nsStyleImageLayers::Position::GetInitialValue(aType);
- if (mXPosition.mPercent == intialValue && mXPosition.mLength == 0 &&
- mXPosition.mHasPercent && mYPosition.mPercent == intialValue &&
- mYPosition.mLength == 0 && mYPosition.mHasPercent) {
+ float intialValue = nsStyleImageLayers::GetInitialPositionForLayerType(aType);
+ if (aPosition.mXPosition.mPercent == intialValue &&
+ aPosition.mXPosition.mLength == 0 &&
+ aPosition.mXPosition.mHasPercent &&
+ aPosition.mYPosition.mPercent == intialValue &&
+ aPosition.mYPosition.mLength == 0 &&
+ aPosition.mYPosition.mHasPercent) {
return true;
}
return false;
}
void
nsStyleImageLayers::Position::SetInitialPercentValues(float aPercentVal)
@@ -2670,17 +2673,17 @@ nsStyleImageLayers::Layer::~Layer()
}
void
nsStyleImageLayers::Layer::Initialize(nsStyleImageLayers::LayerType aType)
{
mRepeat.SetInitialValues(aType);
float initialPositionValue =
- nsStyleImageLayers::Position::GetInitialValue(aType);
+ nsStyleImageLayers::GetInitialPositionForLayerType(aType);
mPosition.SetInitialPercentValues(initialPositionValue);
if (aType == LayerType::Background) {
mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_PADDING;
} else {
MOZ_ASSERT(aType == LayerType::Mask, "unsupported layer type.");
mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_BORDER;
}
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -565,22 +565,16 @@ struct nsStyleImageLayers {
friend struct Position;
struct Position {
typedef nsStyleCoord::CalcValue PositionCoord;
PositionCoord mXPosition, mYPosition;
// Initialize nothing
Position() {}
- bool IsInitialValue(LayerType aType) const;
-
- static float GetInitialValue(LayerType aType) {
- return (aType == LayerType::Background) ? 0.0f : 0.5f;
- }
-
// Sets both mXPosition and mYPosition to the given percent value for the
// initial property-value (e.g. 0.0f for "0% 0%", or 0.5f for "50% 50%")
void SetInitialPercentValues(float aPercentVal);
// Sets both mXPosition and mYPosition to 0 (app units) for the
// initial property-value as a length with no percentage component.
void SetInitialZeroValues();
@@ -594,16 +588,22 @@ struct nsStyleImageLayers {
return mXPosition == aOther.mXPosition &&
mYPosition == aOther.mYPosition;
}
bool operator!=(const Position& aOther) const {
return !(*this == aOther);
}
};
+ static bool IsInitialPositionForLayerType(Position aPosition, LayerType aType);
+
+ static float GetInitialPositionForLayerType(LayerType aType) {
+ return (aType == LayerType::Background) ? 0.0f : 0.5f;
+ }
+
struct Size;
friend struct Size;
struct Size {
struct Dimension : public nsStyleCoord::CalcValue {
nscoord ResolveLengthPercentage(nscoord aAvailable) const {
double d = double(mPercent) * double(aAvailable) + double(mLength);
if (d < 0.0) {
return 0;