зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1277788
- Part 1. Set initial value of mask-position as center. r=dbaron.
MozReview-Commit-ID: BflQ6tz8ZjM --HG-- extra : rebase_source : 01b05533f5c791da0987af81d5cca276ec36e3f0
This commit is contained in:
Родитель
eea03e9e4d
Коммит
ed7978775a
|
@ -12083,28 +12083,33 @@ CSSParserImpl::ParseImageLayersItem(
|
|||
aState.mClip->mValue.SetIntValue(NS_STYLE_IMAGELAYER_CLIP_BORDER,
|
||||
eCSSUnit_Enumerated);
|
||||
|
||||
|
||||
|
||||
|
||||
if (eCSSProperty_mask == aTable[nsStyleImageLayers::shorthand]) {
|
||||
aState.mOrigin->mValue.SetIntValue(NS_STYLE_IMAGELAYER_ORIGIN_BORDER,
|
||||
eCSSUnit_Enumerated);
|
||||
aState.mRepeat->mXValue.SetIntValue(NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT,
|
||||
eCSSUnit_Enumerated);
|
||||
} else {
|
||||
aState.mOrigin->mValue.SetIntValue(NS_STYLE_IMAGELAYER_ORIGIN_PADDING,
|
||||
eCSSUnit_Enumerated);
|
||||
aState.mRepeat->mXValue.SetIntValue(NS_STYLE_IMAGELAYER_REPEAT_REPEAT,
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
aState.mRepeat->mXValue.SetIntValue(NS_STYLE_IMAGELAYER_REPEAT_REPEAT,
|
||||
eCSSUnit_Enumerated);
|
||||
aState.mRepeat->mYValue.Reset();
|
||||
|
||||
RefPtr<nsCSSValue::Array> positionXArr = nsCSSValue::Array::Create(2);
|
||||
RefPtr<nsCSSValue::Array> positionYArr = nsCSSValue::Array::Create(2);
|
||||
aState.mPositionX->mValue.SetArrayValue(positionXArr, eCSSUnit_Array);
|
||||
aState.mPositionY->mValue.SetArrayValue(positionYArr, eCSSUnit_Array);
|
||||
positionXArr->Item(1).SetPercentValue(0.0f);
|
||||
positionYArr->Item(1).SetPercentValue(0.0f);
|
||||
|
||||
if (eCSSProperty_mask == aTable[nsStyleImageLayers::shorthand]) {
|
||||
aState.mOrigin->mValue.SetIntValue(NS_STYLE_IMAGELAYER_ORIGIN_BORDER,
|
||||
eCSSUnit_Enumerated);
|
||||
aState.mRepeat->mXValue.SetIntValue(NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT,
|
||||
eCSSUnit_Enumerated);
|
||||
|
||||
positionXArr->Item(1).SetPercentValue(0.5f);
|
||||
positionYArr->Item(1).SetPercentValue(0.5f);
|
||||
} else {
|
||||
aState.mOrigin->mValue.SetIntValue(NS_STYLE_IMAGELAYER_ORIGIN_PADDING,
|
||||
eCSSUnit_Enumerated);
|
||||
aState.mRepeat->mXValue.SetIntValue(NS_STYLE_IMAGELAYER_REPEAT_REPEAT,
|
||||
eCSSUnit_Enumerated);
|
||||
|
||||
positionXArr->Item(1).SetPercentValue(0.0f);
|
||||
positionYArr->Item(1).SetPercentValue(0.0f);
|
||||
}
|
||||
|
||||
aState.mSize->mXValue.SetAutoValue();
|
||||
aState.mSize->mYValue.SetAutoValue();
|
||||
aState.mComposite->mValue.SetIntValue(NS_STYLE_MASK_COMPOSITE_ADD,
|
||||
|
|
|
@ -6148,7 +6148,7 @@ nsComputedDOMStyle::DoGetMask()
|
|||
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() ||
|
||||
!firstLayer.mPosition.IsInitialValue(nsStyleImageLayers::LayerType::Mask) ||
|
||||
!firstLayer.mRepeat.IsInitialValue(nsStyleImageLayers::LayerType::Mask) ||
|
||||
!firstLayer.mSize.IsInitialValue() ||
|
||||
!(firstLayer.mImage.GetType() == eStyleImageType_Null ||
|
||||
|
|
|
@ -2488,12 +2488,21 @@ nsStyleImageLayers::HasLayerWithImage() const
|
|||
}
|
||||
|
||||
bool
|
||||
nsStyleImageLayers::Position::IsInitialValue() const
|
||||
nsStyleImageLayers::Position::IsInitialValue(LayerType aType) const
|
||||
{
|
||||
if (mXPosition.mPercent == 0.0 && mXPosition.mLength == 0 &&
|
||||
mXPosition.mHasPercent && mYPosition.mPercent == 0.0 &&
|
||||
mYPosition.mLength == 0 && mYPosition.mHasPercent) {
|
||||
return true;
|
||||
if (aType == LayerType::Background) {
|
||||
if (mXPosition.mPercent == 0.0 && mXPosition.mLength == 0 &&
|
||||
mXPosition.mHasPercent && mYPosition.mPercent == 0.0 &&
|
||||
mYPosition.mLength == 0 && mYPosition.mHasPercent) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(aType == LayerType::Mask);
|
||||
if (mXPosition.mPercent == 0.5f && mXPosition.mLength == 0 &&
|
||||
mXPosition.mHasPercent && mYPosition.mPercent == 0.5f &&
|
||||
mYPosition.mLength == 0 && mYPosition.mHasPercent) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -2658,7 +2667,6 @@ nsStyleImageLayers::Layer::Layer()
|
|||
, mComposite(NS_STYLE_MASK_COMPOSITE_ADD)
|
||||
, mMaskMode(NS_STYLE_MASK_MODE_MATCH_SOURCE)
|
||||
{
|
||||
mPosition.SetInitialPercentValues(0.0f); // Initial value is "0% 0%"
|
||||
mImage.SetNull();
|
||||
mSize.SetInitialValues();
|
||||
}
|
||||
|
@ -2674,9 +2682,11 @@ nsStyleImageLayers::Layer::Initialize(nsStyleImageLayers::LayerType aType)
|
|||
|
||||
if (aType == LayerType::Background) {
|
||||
mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_PADDING;
|
||||
mPosition.SetInitialPercentValues(0.0f); // Initial value is "0% 0%"
|
||||
} else {
|
||||
MOZ_ASSERT(aType == LayerType::Mask, "unsupported layer type.");
|
||||
mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_BORDER;
|
||||
mPosition.SetInitialPercentValues(0.5f); // Initial value is "50% 50%"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -566,7 +566,7 @@ struct nsStyleImageLayers {
|
|||
// Initialize nothing
|
||||
Position() {}
|
||||
|
||||
bool IsInitialValue() const;
|
||||
bool IsInitialValue(LayerType aType) const;
|
||||
|
||||
// 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%")
|
||||
|
|
Загрузка…
Ссылка в новой задаче