--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -1048,19 +1048,18 @@ nsCSSRendering::PaintFocus(nsPresContext
//----------------------------------------------------------------------
/**
* Helper for ComputeObjectAnchorPoint; parameters are the same as for
* that function, except they're for a single coordinate / a single size
* dimension. (so, x/width vs. y/height)
*/
-typedef nsStyleImageLayers::Position::PositionCoord PositionCoord;
static void
-ComputeObjectAnchorCoord(const PositionCoord& aCoord,
+ComputeObjectAnchorCoord(const Position::PositionCoord& aCoord,
const nscoord aOriginBounds,
const nscoord aImageSize,
nscoord* aTopLeftCoord,
nscoord* aAnchorPointCoord)
{
*aAnchorPointCoord = aCoord.mLength;
*aTopLeftCoord = aCoord.mLength;
@@ -1072,17 +1071,17 @@ ComputeObjectAnchorCoord(const PositionC
// The anchor-point doesn't care about our image's size; just the size
// of the region we're rendering into.
*aAnchorPointCoord += NSToCoordRound(aCoord.mPercent * aOriginBounds);
}
}
void
nsImageRenderer::ComputeObjectAnchorPoint(
- const nsStyleImageLayers::Position& aPos,
+ const Position& aPos,
const nsSize& aOriginBounds,
const nsSize& aImageSize,
nsPoint* aTopLeft,
nsPoint* aAnchorPoint)
{
ComputeObjectAnchorCoord(aPos.mXPosition,
aOriginBounds.width, aImageSize.width,
&aTopLeft->x, &aAnchorPoint->x);
--- a/layout/base/nsCSSRendering.h
+++ b/layout/base/nsCSSRendering.h
@@ -170,17 +170,17 @@ public:
* @param aAnchorPoint [out] A point which should be pixel-aligned by
* nsLayoutUtils::DrawImage. This is the same as aTopLeft, unless
* CSS specifies a percentage (including 'right' or 'bottom'), in
* which case it's that percentage within of aOriginBounds. So
* 'right' would set aAnchorPoint.x to aOriginBounds.XMost().
*
* Points are returned relative to aOriginBounds.
*/
- static void ComputeObjectAnchorPoint(const nsStyleImageLayers::Position& aPos,
+ static void ComputeObjectAnchorPoint(const mozilla::Position& aPos,
const nsSize& aOriginBounds,
const nsSize& aImageSize,
nsPoint* aTopLeft,
nsPoint* aAnchorPoint);
/**
* Compute the size of the rendered image using either the 'cover' or
* 'contain' constraints (aFitType).
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4145,31 +4145,30 @@ ComputeConcreteObjectSize(const nsSize&
default:
MOZ_ASSERT_UNREACHABLE("Unexpected enum value for 'object-fit'");
return aConstraintSize; // fall back to (default) 'fill' behavior
}
}
// (Helper for HasInitialObjectFitAndPosition, to check
// each "object-position" coord.)
-typedef nsStyleImageLayers::Position::PositionCoord PositionCoord;
static bool
-IsCoord50Pct(const PositionCoord& aCoord)
+IsCoord50Pct(const mozilla::Position::PositionCoord& aCoord)
{
return (aCoord.mLength == 0 &&
aCoord.mHasPercent &&
aCoord.mPercent == 0.5f);
}
// Indicates whether the given nsStylePosition has the initial values
// for the "object-fit" and "object-position" properties.
static bool
HasInitialObjectFitAndPosition(const nsStylePosition* aStylePos)
{
- const nsStyleImageLayers::Position& objectPos = aStylePos->mObjectPosition;
+ const mozilla::Position& objectPos = aStylePos->mObjectPosition;
return aStylePos->mObjectFit == NS_STYLE_OBJECT_FIT_FILL &&
IsCoord50Pct(objectPos.mXPosition) &&
IsCoord50Pct(objectPos.mYPosition);
}
/* static */ nsRect
nsLayoutUtils::ComputeObjectDestRect(const nsRect& aConstraintRect,
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -5848,17 +5848,17 @@ CollectScrollSnapCoordinates(nsIFrame* a
const nsStyleDisplay* styleDisplay = f->StyleDisplay();
size_t coordCount = styleDisplay->mScrollSnapCoordinate.Length();
if (coordCount) {
nsRect frameRect = f->GetRect();
nsPoint offset = f->GetOffsetTo(aScrolledFrame);
nsRect edgesRect = nsRect(offset, frameRect.Size());
for (size_t coordNum = 0; coordNum < coordCount; coordNum++) {
- const nsStyleImageLayers::Position &coordPosition =
+ const Position& coordPosition =
f->StyleDisplay()->mScrollSnapCoordinate[coordNum];
nsPoint coordPoint = edgesRect.TopLeft();
coordPoint += nsPoint(coordPosition.mXPosition.mLength,
coordPosition.mYPosition.mLength);
if (coordPosition.mXPosition.mHasPercent) {
coordPoint.x += NSToCoordRound(coordPosition.mXPosition.mPercent *
frameRect.width);
}
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -3305,17 +3305,17 @@ StyleCoordToCSSValue(const nsStyleCoord&
default:
MOZ_ASSERT(false, "unexpected unit");
return false;
}
return true;
}
static void
-SetPositionValue(const nsStyleImageLayers::Position& aPos, nsCSSValue& aCSSValue)
+SetPositionValue(const Position& aPos, nsCSSValue& aCSSValue)
{
RefPtr<nsCSSValue::Array> posArray = nsCSSValue::Array::Create(4);
aCSSValue.SetArrayValue(posArray.get(), eCSSUnit_Array);
// NOTE: Array entries #0 and #2 here are intentionally left untouched, with
// eCSSUnit_Null. The purpose of these entries in our specified-style
// <position> representation is to store edge names. But for values
// extracted from computed style (which is what we're dealing with here),
@@ -3323,17 +3323,17 @@ SetPositionValue(const nsStyleImageLayer
nsCSSValue& xValue = posArray->Item(1);
nsCSSValue& yValue = posArray->Item(3);
SetCalcValue(&aPos.mXPosition, xValue);
SetCalcValue(&aPos.mYPosition, yValue);
}
static void
-SetPositionCoordValue(const nsStyleImageLayers::Position::PositionCoord& aPosCoord,
+SetPositionCoordValue(const Position::PositionCoord& aPosCoord,
nsCSSValue& aCSSValue)
{
RefPtr<nsCSSValue::Array> posArray = nsCSSValue::Array::Create(2);
aCSSValue.SetArrayValue(posArray.get(), eCSSUnit_Array);
// NOTE: Array entry #0 here is intentionally left untouched, with
// eCSSUnit_Null. The purpose of this entry in our specified-style
// <position-coord> representation is to store edge names. But for values
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -2354,33 +2354,33 @@ nsComputedDOMStyle::DoGetBackgroundOrigi
return GetBackgroundList(&nsStyleImageLayers::Layer::mOrigin,
&nsStyleImageLayers::mOriginCount,
StyleBackground()->mImage,
nsCSSProps::kImageLayerOriginKTable);
}
void
nsComputedDOMStyle::SetValueToPositionCoord(
- const nsStyleImageLayers::Position::PositionCoord& aCoord,
+ const Position::PositionCoord& aCoord,
nsROCSSPrimitiveValue* aValue)
{
if (!aCoord.mHasPercent) {
MOZ_ASSERT(aCoord.mPercent == 0.0f,
"Shouldn't have mPercent!");
aValue->SetAppUnits(aCoord.mLength);
} else if (aCoord.mLength == 0) {
aValue->SetPercent(aCoord.mPercent);
} else {
SetValueToCalc(&aCoord, aValue);
}
}
void
nsComputedDOMStyle::SetValueToPosition(
- const nsStyleImageLayers::Position& aPosition,
+ const Position& aPosition,
nsDOMCSSValueList* aValueList)
{
RefPtr<nsROCSSPrimitiveValue> valX = new nsROCSSPrimitiveValue;
SetValueToPositionCoord(aPosition.mXPosition, valX);
aValueList->AppendCSSValue(valX.forget());
RefPtr<nsROCSSPrimitiveValue> valY = new nsROCSSPrimitiveValue;
SetValueToPositionCoord(aPosition.mYPosition, valY);
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -580,20 +580,19 @@ private:
already_AddRefed<CSSValue> DoGetCustomProperty(const nsAString& aPropertyName);
nsDOMCSSValueList* GetROCSSValueList(bool aCommaDelimited);
/* Helper functions */
void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor);
void SetValueToStyleImage(const nsStyleImage& aStyleImage,
nsROCSSPrimitiveValue* aValue);
- void SetValueToPositionCoord(
- const nsStyleImageLayers::Position::PositionCoord& aCoord,
- nsROCSSPrimitiveValue* aValue);
- void SetValueToPosition(const nsStyleImageLayers::Position& aPosition,
+ void SetValueToPositionCoord(const mozilla::Position::PositionCoord& aCoord,
+ nsROCSSPrimitiveValue* aValue);
+ void SetValueToPosition(const mozilla::Position& aPosition,
nsDOMCSSValueList* aValueList);
void SetValueToFragmentOrURL(const mozilla::FragmentOrURL* aFragmentOrURL,
nsROCSSPrimitiveValue* aValue);
/**
* A method to get a percentage base for a percentage value. Returns true
* if a percentage base value was determined, false otherwise.
*/
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -126,20 +126,20 @@ SetStyleShapeSourceToCSSValue(StyleShape
const nsCSSValue* aValue,
nsStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions);
/* Helper function to convert a CSS <position> specified value into its
* computed-style form. */
static void
- ComputePositionValue(nsStyleContext* aStyleContext,
- const nsCSSValue& aValue,
- nsStyleImageLayers::Position& aComputedValue,
- RuleNodeCacheConditions& aConditions);
+ComputePositionValue(nsStyleContext* aStyleContext,
+ const nsCSSValue& aValue,
+ Position& aComputedValue,
+ RuleNodeCacheConditions& aConditions);
/*
* For storage of an |nsRuleNode|'s children in a PLDHashTable.
*/
struct ChildrenHashEntry : public PLDHashEntryHdr {
// key is |mRuleNode->GetKey()|
nsRuleNode *mRuleNode;
@@ -5928,18 +5928,16 @@ nsRuleNode::ComputeDisplayData(void* aSt
break;
default: {
ComputePositionValue(aContext, snapDestination,
display->mScrollSnapDestination, conditions);
}
}
// scroll-snap-coordinate: none, inherit, initial
- typedef nsStyleImageLayers::Position Position;
-
const nsCSSValue& snapCoordinate = *aRuleData->ValueForScrollSnapCoordinate();
switch (snapCoordinate.GetUnit()) {
case eCSSUnit_Null:
break;
case eCSSUnit_Initial:
case eCSSUnit_Unset:
case eCSSUnit_None:
// Unset and Initial is none, indicated by an empty array
@@ -6730,22 +6728,21 @@ struct BackgroundItemComputer<nsCSSValue
}
}
};
/* Helper function for ComputePositionValue.
* This function computes a single PositionCoord from two nsCSSValue objects,
* which represent an edge and an offset from that edge.
*/
-typedef nsStyleImageLayers::Position::PositionCoord PositionCoord;
static void
ComputePositionCoord(nsStyleContext* aStyleContext,
const nsCSSValue& aEdge,
const nsCSSValue& aOffset,
- PositionCoord* aResult,
+ Position::PositionCoord* aResult,
RuleNodeCacheConditions& aConditions)
{
if (eCSSUnit_Percent == aOffset.GetUnit()) {
aResult->mLength = 0;
aResult->mPercent = aOffset.GetPercentValue();
aResult->mHasPercent = true;
} else if (aOffset.IsLengthUnit()) {
aResult->mLength = CalcLength(aOffset, aStyleContext,
@@ -6785,17 +6782,17 @@ ComputePositionCoord(nsStyleContext* aSt
}
}
/* Helper function to convert a CSS <position> specified value into its
* computed-style form. */
static void
ComputePositionValue(nsStyleContext* aStyleContext,
const nsCSSValue& aValue,
- nsStyleImageLayers::Position& aComputedValue,
+ Position& aComputedValue,
RuleNodeCacheConditions& aConditions)
{
NS_ASSERTION(aValue.GetUnit() == eCSSUnit_Array,
"unexpected unit for CSS <position> value");
RefPtr<nsCSSValue::Array> positionArray = aValue.GetArrayValue();
NS_ASSERTION(positionArray->Count() == 4,
"unexpected number of values in CSS <position> value");
@@ -6822,17 +6819,17 @@ ComputePositionValue(nsStyleContext* aSt
aConditions);
}
/* Helper function to convert the -x or -y part of a CSS <position> specified
* value into its computed-style form. */
static void
ComputePositionCoordValue(nsStyleContext* aStyleContext,
const nsCSSValue& aValue,
- nsStyleImageLayers::Position::PositionCoord& aComputedValue,
+ Position::PositionCoord& aComputedValue,
RuleNodeCacheConditions& aConditions)
{
NS_ASSERTION(aValue.GetUnit() == eCSSUnit_Array,
"unexpected unit for position coord value");
RefPtr<nsCSSValue::Array> positionArray = aValue.GetArrayValue();
NS_ASSERTION(positionArray->Count() == 2,
"unexpected number of values, expecting one edge and one offset");
@@ -7019,19 +7016,19 @@ SetImageLayerList(nsStyleContext* aStyle
// This code is duplicated because it would be annoying to make
// SetImageLayerList generic enough to handle both cases.
static void
SetImageLayerPositionCoordList(
nsStyleContext* aStyleContext,
const nsCSSValue& aValue,
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
- nsStyleImageLayers::Position::PositionCoord
- nsStyleImageLayers::Position::* aResultLocation,
- nsStyleImageLayers::Position::PositionCoord aInitialValue,
+ Position::PositionCoord
+ Position::* aResultLocation,
+ Position::PositionCoord aInitialValue,
uint32_t aParentItemCount,
uint32_t& aItemCount,
uint32_t& aMaxItemCount,
bool& aRebuild,
RuleNodeCacheConditions& aConditions)
{
switch (aValue.GetUnit()) {
case eCSSUnit_Null:
@@ -7168,18 +7165,18 @@ FillBackgroundList(
}
}
// The same as FillBackgroundList, but for values stored in
// layer.mPosition.*aResultLocation instead of layer.*aResultLocation.
static void
FillBackgroundPositionCoordList(
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
- nsStyleImageLayers::Position::PositionCoord
- nsStyleImageLayers::Position::* aResultLocation,
+ Position::PositionCoord
+ Position::* aResultLocation,
uint32_t aItemCount, uint32_t aFillCount)
{
NS_PRECONDITION(aFillCount <= aLayers.Length(), "unexpected array length");
for (uint32_t sourceLayer = 0, destLayer = aItemCount;
destLayer < aFillCount;
++sourceLayer, ++destLayer) {
aLayers[destLayer].mPosition.*aResultLocation =
aLayers[sourceLayer].mPosition.*aResultLocation;
@@ -7266,36 +7263,36 @@ nsRuleNode::ComputeBackgroundData(void*
parentBG->mImage.mLayers,
&nsStyleImageLayers::Layer::mOrigin,
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;
+ Position::PositionCoord initialPositionCoord;
initialPositionCoord.mPercent =
nsStyleImageLayers::GetInitialPositionForLayerType(
nsStyleImageLayers::LayerType::Background);
initialPositionCoord.mLength = 0;
initialPositionCoord.mHasPercent = true;
SetImageLayerPositionCoordList(
aContext, *aRuleData->ValueForBackgroundPositionX(),
bg->mImage.mLayers,
parentBG->mImage.mLayers,
- &nsStyleImageLayers::Position::mXPosition,
+ &Position::mXPosition,
initialPositionCoord, parentBG->mImage.mPositionXCount,
bg->mImage.mPositionXCount, maxItemCount, rebuild,
conditions);
SetImageLayerPositionCoordList(
aContext, *aRuleData->ValueForBackgroundPositionY(),
bg->mImage.mLayers,
parentBG->mImage.mLayers,
- &nsStyleImageLayers::Position::mYPosition,
+ &Position::mYPosition,
initialPositionCoord, parentBG->mImage.mPositionYCount,
bg->mImage.mPositionYCount, maxItemCount, rebuild,
conditions);
// background-size: enum, length, auto, inherit, initial [pair list]
nsStyleImageLayers::Size initialSize;
initialSize.SetInitialValues();
SetImageLayerPairList(aContext, *aRuleData->ValueForBackgroundSize(),
@@ -7326,20 +7323,20 @@ nsRuleNode::ComputeBackgroundData(void*
bg->mImage.mClipCount, fillCount);
FillBackgroundList(bg->mImage.mLayers,
&nsStyleImageLayers::Layer::mBlendMode,
bg->mImage.mBlendModeCount, fillCount);
FillBackgroundList(bg->mImage.mLayers,
&nsStyleImageLayers::Layer::mOrigin,
bg->mImage.mOriginCount, fillCount);
FillBackgroundPositionCoordList(bg->mImage.mLayers,
- &nsStyleImageLayers::Position::mXPosition,
+ &Position::mXPosition,
bg->mImage.mPositionXCount, fillCount);
FillBackgroundPositionCoordList(bg->mImage.mLayers,
- &nsStyleImageLayers::Position::mYPosition,
+ &Position::mYPosition,
bg->mImage.mPositionYCount, fillCount);
FillBackgroundList(bg->mImage.mLayers,
&nsStyleImageLayers::Layer::mSize,
bg->mImage.mSizeCount, fillCount);
}
// Now that the dust has settled, register the images with the document
bg->mImage.TrackImages(aContext->PresContext());
@@ -10030,36 +10027,36 @@ nsRuleNode::ComputeSVGResetData(void* aS
parentSVGReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mOrigin,
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;
+ Position::PositionCoord initialPositionCoord;
initialPositionCoord.mPercent =
nsStyleImageLayers::GetInitialPositionForLayerType(
nsStyleImageLayers::LayerType::Mask);
initialPositionCoord.mLength = 0;
initialPositionCoord.mHasPercent = true;
SetImageLayerPositionCoordList(
aContext, *aRuleData->ValueForMaskPositionX(),
svgReset->mMask.mLayers,
parentSVGReset->mMask.mLayers,
- &nsStyleImageLayers::Position::mXPosition,
+ &Position::mXPosition,
initialPositionCoord, parentSVGReset->mMask.mPositionXCount,
svgReset->mMask.mPositionXCount, maxItemCount, rebuild,
conditions);
SetImageLayerPositionCoordList(
aContext, *aRuleData->ValueForMaskPositionY(),
svgReset->mMask.mLayers,
parentSVGReset->mMask.mLayers,
- &nsStyleImageLayers::Position::mYPosition,
+ &Position::mYPosition,
initialPositionCoord, parentSVGReset->mMask.mPositionYCount,
svgReset->mMask.mPositionYCount, maxItemCount, rebuild,
conditions);
// mask-size: enum, length, auto, inherit, initial [pair list]
nsStyleImageLayers::Size initialSize;
initialSize.SetInitialValues();
SetImageLayerPairList(aContext, *aRuleData->ValueForMaskSize(),
@@ -10106,20 +10103,20 @@ nsRuleNode::ComputeSVGResetData(void* aS
svgReset->mMask.mRepeatCount, fillCount);
FillBackgroundList(svgReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mClip,
svgReset->mMask.mClipCount, fillCount);
FillBackgroundList(svgReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mOrigin,
svgReset->mMask.mOriginCount, fillCount);
FillBackgroundPositionCoordList(svgReset->mMask.mLayers,
- &nsStyleImageLayers::Position::mXPosition,
+ &Position::mXPosition,
svgReset->mMask.mPositionXCount, fillCount);
FillBackgroundPositionCoordList(svgReset->mMask.mLayers,
- &nsStyleImageLayers::Position::mYPosition,
+ &Position::mYPosition,
svgReset->mMask.mPositionYCount, fillCount);
FillBackgroundList(svgReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mSize,
svgReset->mMask.mSizeCount, fillCount);
FillBackgroundList(svgReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mMaskMode,
svgReset->mMask.mMaskModeCount, fillCount);
FillBackgroundList(svgReset->mMask.mLayers,
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2501,28 +2501,28 @@ nsStyleImageLayers::IsInitialPositionFor
aPosition.mYPosition.mHasPercent) {
return true;
}
return false;
}
void
-nsStyleImageLayers::Position::SetInitialPercentValues(float aPercentVal)
+Position::SetInitialPercentValues(float aPercentVal)
{
mXPosition.mPercent = aPercentVal;
mXPosition.mLength = 0;
mXPosition.mHasPercent = true;
mYPosition.mPercent = aPercentVal;
mYPosition.mLength = 0;
mYPosition.mHasPercent = true;
}
void
-nsStyleImageLayers::Position::SetInitialZeroValues()
+Position::SetInitialZeroValues()
{
mXPosition.mPercent = 0;
mXPosition.mLength = 0;
mXPosition.mHasPercent = false;
mYPosition.mPercent = 0;
mYPosition.mLength = 0;
mYPosition.mHasPercent = false;
}
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -140,16 +140,46 @@ struct FragmentOrURL
bool IsLocalRef() const { return mIsLocalRef; }
private:
nsCOMPtr<nsIURI> mURL;
bool mIsLocalRef;
};
+struct Position {
+ typedef nsStyleCoord::CalcValue PositionCoord;
+ PositionCoord mXPosition, mYPosition;
+
+ // Initialize nothing
+ Position() {}
+
+ // 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();
+
+ // True if the effective background image position described by this depends
+ // on the size of the corresponding frame.
+ bool DependsOnPositioningAreaSize() const {
+ return mXPosition.mPercent != 0.0f || mYPosition.mPercent != 0.0f;
+ }
+
+ bool operator==(const Position& aOther) const {
+ return mXPosition == aOther.mXPosition &&
+ mYPosition == aOther.mYPosition;
+ }
+ bool operator!=(const Position& aOther) const {
+ return !(*this == aOther);
+ }
+};
+
} // namespace mozilla
// The lifetime of these objects is managed by the presshell's arena.
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont
{
nsStyleFont(const nsFont& aFont, StyleStructContext aContext);
nsStyleFont(const nsStyleFont& aStyleFont);
explicit nsStyleFont(StyleStructContext aContext);
@@ -556,49 +586,17 @@ struct nsStyleImageLayers {
};
explicit nsStyleImageLayers(LayerType aType);
nsStyleImageLayers(const nsStyleImageLayers &aSource);
~nsStyleImageLayers() {
MOZ_COUNT_DTOR(nsStyleImageLayers);
}
- struct Position;
- friend struct Position;
- struct Position {
- typedef nsStyleCoord::CalcValue PositionCoord;
- PositionCoord mXPosition, mYPosition;
-
- // Initialize nothing
- Position() {}
-
- // 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();
-
- // True if the effective background image position described by this depends
- // on the size of the corresponding frame.
- bool DependsOnPositioningAreaSize() const {
- return mXPosition.mPercent != 0.0f || mYPosition.mPercent != 0.0f;
- }
-
- bool operator==(const Position& aOther) const {
- return mXPosition == aOther.mXPosition &&
- mYPosition == aOther.mYPosition;
- }
- bool operator!=(const Position& aOther) const {
- return !(*this == aOther);
- }
- };
-
- static bool IsInitialPositionForLayerType(Position aPosition, LayerType aType);
+ static bool IsInitialPositionForLayerType(mozilla::Position aPosition, LayerType aType);
static float GetInitialPositionForLayerType(LayerType aType) {
return (aType == LayerType::Background) ? 0.0f : 0.5f;
}
struct Size;
friend struct Size;
struct Size {
@@ -695,17 +693,17 @@ struct nsStyleImageLayers {
nsStyleImage mImage; // [reset]
mozilla::FragmentOrURL mSourceURI; // [reset]
// mask-only property
// This property is used for mask layer only.
// For a background layer, it should always
// be the initial value, which is nullptr.
// Store mask-image URI so that we can resolve
// SVG mask path later.
- Position mPosition; // [reset] See nsStyleConsts.h
+ mozilla::Position mPosition; // [reset]
Size mSize; // [reset]
uint8_t mClip; // [reset] See nsStyleConsts.h
MOZ_INIT_OUTSIDE_CTOR
uint8_t mOrigin; // [reset] See nsStyleConsts.h
uint8_t mAttachment; // [reset] See nsStyleConsts.h
// background-only property
// This property is used for background layer
// only. For a mask layer, it should always
@@ -1740,20 +1738,16 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
}
static nsChangeHint DifferenceAlwaysHandledForDescendants() {
// CalcDifference can return all of the reflow hints that are
// sometimes handled for descendants as hints not handled for
// descendants.
return nsChangeHint(0);
}
- // XXXdholbert nsStyleImageLayers::Position should probably be moved to a
- // different scope, since we're now using it in multiple style structs.
- typedef nsStyleImageLayers::Position Position;
-
/**
* Return the computed value for 'align-content'.
*/
uint16_t ComputedAlignContent() const { return mAlignContent; }
/**
* Return the computed value for 'align-items'.
*/
@@ -1777,17 +1771,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
uint8_t ComputedJustifyItems(nsStyleContext* aParent) const;
/**
* Return the computed value for 'justify-self' given our parent StyleContext
* aParent (or null for the root).
*/
uint8_t ComputedJustifySelf(nsStyleContext* aParent) const;
- Position mObjectPosition; // [reset]
+ mozilla::Position mObjectPosition; // [reset]
nsStyleSides mOffset; // [reset] coord, percent, calc, auto
nsStyleCoord mWidth; // [reset] coord, percent, enum, calc, auto
nsStyleCoord mMinWidth; // [reset] coord, percent, enum, calc
nsStyleCoord mMaxWidth; // [reset] coord, percent, enum, calc, none
nsStyleCoord mHeight; // [reset] coord, percent, calc, auto
nsStyleCoord mMinHeight; // [reset] coord, percent, calc
nsStyleCoord mMaxHeight; // [reset] coord, percent, calc, none
nsStyleCoord mFlexBasis; // [reset] coord, percent, enum, calc, auto
@@ -2546,17 +2540,16 @@ public:
StyleFillRule GetFillRule() const { return mFillRule; }
void SetFillRule(StyleFillRule aFillRule)
{
MOZ_ASSERT(mType == StyleBasicShapeType::Polygon, "expected polygon");
mFillRule = aFillRule;
}
- typedef nsStyleImageLayers::Position Position;
Position& GetPosition() {
MOZ_ASSERT(mType == StyleBasicShapeType::Circle ||
mType == StyleBasicShapeType::Ellipse,
"expected circle or ellipse");
return mPosition;
}
const Position& GetPosition() const {
MOZ_ASSERT(mType == StyleBasicShapeType::Circle ||
@@ -2821,21 +2814,16 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
}
static nsChangeHint DifferenceAlwaysHandledForDescendants() {
// CalcDifference can return all of the reflow hints that are
// sometimes handled for descendants as hints not handled for
// descendants.
return nsChangeHint(0);
}
- // XXXdholbert, XXXkgilbert nsStyleImageLayers::Position should probably be
- // moved to a different scope, since we're now using it in multiple style
- // structs.
- typedef nsStyleImageLayers::Position Position;
-
// We guarantee that if mBinding is non-null, so are mBinding->GetURI() and
// mBinding->mOriginPrincipal.
RefPtr<mozilla::css::URLValue> mBinding; // [reset]
uint8_t mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
uint8_t mOriginalDisplay; // [reset] saved mDisplay for position:absolute/fixed
// and float:left/right; otherwise equal
// to mDisplay
uint8_t mContain; // [reset] see nsStyleConsts.h NS_STYLE_CONTAIN_*
@@ -2867,18 +2855,18 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
nsTArray<nsString> mWillChange;
uint8_t mTouchAction; // [reset] see nsStyleConsts.h
uint8_t mScrollBehavior; // [reset] see nsStyleConsts.h NS_STYLE_SCROLL_BEHAVIOR_*
uint8_t mScrollSnapTypeX; // [reset] see nsStyleConsts.h NS_STYLE_SCROLL_SNAP_TYPE_*
uint8_t mScrollSnapTypeY; // [reset] see nsStyleConsts.h NS_STYLE_SCROLL_SNAP_TYPE_*
nsStyleCoord mScrollSnapPointsX; // [reset]
nsStyleCoord mScrollSnapPointsY; // [reset]
- Position mScrollSnapDestination; // [reset]
- nsTArray<Position> mScrollSnapCoordinate; // [reset]
+ mozilla::Position mScrollSnapDestination; // [reset]
+ nsTArray<mozilla::Position> mScrollSnapCoordinate; // [reset]
// mSpecifiedTransform is the list of transform functions as
// specified, or null to indicate there is no transform. (inherit or
// initial are replaced by an actual list of transform functions, or
// null, as appropriate.)
uint8_t mBackfaceVisibility;
uint8_t mTransformStyle;
uint8_t mTransformBox; // [reset] see nsStyleConsts.h
--- a/layout/style/nsStyleUtil.cpp
+++ b/layout/style/nsStyleUtil.cpp
@@ -681,19 +681,18 @@ nsStyleUtil::IsSignificantChild(nsIConte
return aTextIsSignificant && isText && aChild->TextLength() != 0 &&
(aWhitespaceIsSignificant ||
!aChild->TextIsOnlyWhitespace());
}
// For a replaced element whose concrete object size is no larger than the
// element's content-box, this method checks whether the given
// "object-position" coordinate might cause overflow in its dimension.
-typedef nsStyleImageLayers::Position::PositionCoord PositionCoord;
static bool
-ObjectPositionCoordMightCauseOverflow(const PositionCoord& aCoord)
+ObjectPositionCoordMightCauseOverflow(const Position::PositionCoord& aCoord)
{
// Any nonzero length in "object-position" can push us to overflow
// (particularly if our concrete object size is exactly the same size as the
// replaced element's content-box).
if (aCoord.mLength != 0) {
return true;
}
@@ -719,17 +718,17 @@ nsStyleUtil::ObjectPropsMightCauseOverfl
objectFit == NS_STYLE_OBJECT_FIT_NONE) {
return true;
}
// (All other object-fit values produce a concrete object size that's no larger
// than the constraint region.)
// Check each of our "object-position" coords to see if it could cause
// overflow in its dimension:
- const nsStyleImageLayers::Position& objectPosistion = aStylePos->mObjectPosition;
+ const Position& objectPosistion = aStylePos->mObjectPosition;
if (ObjectPositionCoordMightCauseOverflow(objectPosistion.mXPosition) ||
ObjectPositionCoordMightCauseOverflow(objectPosistion.mYPosition)) {
return true;
}
return false;
}