summaryrefslogtreecommitdiffstats
path: root/layout/style
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@wolfbeast.com>2019-02-03 08:34:43 +0100
committerGitHub <noreply@github.com>2019-02-03 08:34:43 +0100
commit4874970d329943e08bcca7c61e7b7d2bc0f7c9d3 (patch)
tree4d1df04790cc8c785141e8dd8ffea9e6da5a0c02 /layout/style
parentfa311a4cae5ea526e848adc4f49c6aa0b700702c (diff)
parentb241a84d884293e1ce49a79c75e362c02c0899f9 (diff)
downloadUXP-4874970d329943e08bcca7c61e7b7d2bc0f7c9d3.tar
UXP-4874970d329943e08bcca7c61e7b7d2bc0f7c9d3.tar.gz
UXP-4874970d329943e08bcca7c61e7b7d2bc0f7c9d3.tar.lz
UXP-4874970d329943e08bcca7c61e7b7d2bc0f7c9d3.tar.xz
UXP-4874970d329943e08bcca7c61e7b7d2bc0f7c9d3.zip
Merge pull request #961 from kn-yami/issue908
implement missing parts of CSS mask
Diffstat (limited to 'layout/style')
-rw-r--r--layout/style/Declaration.cpp39
-rw-r--r--layout/style/StyleAnimationValue.cpp4
-rw-r--r--layout/style/nsCSSDataBlock.cpp2
-rw-r--r--layout/style/nsCSSKeywordList.h1
-rw-r--r--layout/style/nsCSSParser.cpp31
-rw-r--r--layout/style/nsCSSPropAliasList.h2
-rw-r--r--layout/style/nsCSSPropList.h20
-rw-r--r--layout/style/nsCSSProps.cpp62
-rw-r--r--layout/style/nsCSSProps.h3
-rw-r--r--layout/style/nsComputedDOMStyle.cpp60
-rw-r--r--layout/style/nsComputedDOMStyle.h12
-rw-r--r--layout/style/nsComputedDOMStylePropertyList.h2
-rw-r--r--layout/style/nsRuleNode.cpp40
-rw-r--r--layout/style/nsStyleConsts.h47
-rw-r--r--layout/style/nsStyleStruct.cpp8
-rw-r--r--layout/style/nsStyleStruct.h8
16 files changed, 151 insertions, 190 deletions
diff --git a/layout/style/Declaration.cpp b/layout/style/Declaration.cpp
index c67f6b2a2..b2de159ed 100644
--- a/layout/style/Declaration.cpp
+++ b/layout/style/Declaration.cpp
@@ -395,28 +395,25 @@ Declaration::GetImageLayerValue(
origin->mValue.GetUnit() == eCSSUnit_Enumerated,
"should not have inherit/initial within list");
- int32_t originDefaultValue =
+ StyleGeometryBox originDefaultValue =
(aTable == nsStyleImageLayers::kBackgroundLayerTable)
- ? NS_STYLE_IMAGELAYER_ORIGIN_PADDING : NS_STYLE_IMAGELAYER_ORIGIN_BORDER;
- if (clip->mValue.GetIntValue() != NS_STYLE_IMAGELAYER_CLIP_BORDER ||
- origin->mValue.GetIntValue() != originDefaultValue) {
+ ? StyleGeometryBox::Padding : StyleGeometryBox::Border;
+ if (static_cast<StyleGeometryBox>(clip->mValue.GetIntValue()) !=
+ StyleGeometryBox::Border ||
+ static_cast<StyleGeometryBox>(origin->mValue.GetIntValue()) !=
+ originDefaultValue) {
#ifdef DEBUG
- for (size_t i = 0; nsCSSProps::kImageLayerOriginKTable[i].mValue != -1; i++) {
+ const nsCSSProps::KTableEntry* originTable =
+ nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::origin]];
+ const nsCSSProps::KTableEntry* clipTable =
+ nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::clip]];
+ for (size_t i = 0; originTable[i].mValue != -1; i++) {
// For each keyword & value in kOriginKTable, ensure that
// kBackgroundKTable has a matching entry at the same position.
- MOZ_ASSERT(nsCSSProps::kImageLayerOriginKTable[i].mKeyword ==
- nsCSSProps::kBackgroundClipKTable[i].mKeyword);
- MOZ_ASSERT(nsCSSProps::kImageLayerOriginKTable[i].mValue ==
- nsCSSProps::kBackgroundClipKTable[i].mValue);
+ MOZ_ASSERT(originTable[i].mKeyword == clipTable[i].mKeyword);
+ MOZ_ASSERT(originTable[i].mValue == clipTable[i].mValue);
}
#endif
- static_assert(NS_STYLE_IMAGELAYER_CLIP_BORDER ==
- NS_STYLE_IMAGELAYER_ORIGIN_BORDER &&
- NS_STYLE_IMAGELAYER_CLIP_PADDING ==
- NS_STYLE_IMAGELAYER_ORIGIN_PADDING &&
- NS_STYLE_IMAGELAYER_CLIP_CONTENT ==
- NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
- "mask-clip and mask-origin style constants must agree");
aValue.Append(char16_t(' '));
origin->mValue.AppendToString(aTable[nsStyleImageLayers::origin], aValue,
aSerialization);
@@ -462,11 +459,7 @@ Declaration::GetImageLayerValue(
}
// This layer is an mask layer
} else {
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
MOZ_ASSERT(aTable == nsStyleImageLayers::kMaskLayerTable);
-#else
- MOZ_ASSERT_UNREACHABLE("Should never get here when mask-as-shorthand is disable");
-#endif
if (repeat || positionX || positionY || clip || origin || size ||
composite || mode) {
// Uneven length lists, so can't be serialized as shorthand.
@@ -487,11 +480,7 @@ Declaration::GetImageLayerValue(
}
// This layer is an mask layer
} else {
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
MOZ_ASSERT(aTable == nsStyleImageLayers::kMaskLayerTable);
-#else
- MOZ_ASSERT_UNREACHABLE("Should never get here when mask-as-shorthand is disable");
-#endif
if (!repeat || !positionX || !positionY || !clip || !origin || !size ||
!composite || !mode) {
// Uneven length lists, so can't be serialized as shorthand.
@@ -817,7 +806,6 @@ Declaration::GetPropertyValueInternal(
nsStyleImageLayers::kBackgroundLayerTable);
break;
}
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
case eCSSProperty_mask: {
GetImageLayerValue(data, aValue, aSerialization,
nsStyleImageLayers::kMaskLayerTable);
@@ -828,7 +816,6 @@ Declaration::GetPropertyValueInternal(
nsStyleImageLayers::kMaskLayerTable);
break;
}
-#endif
case eCSSProperty_font: {
// systemFont might not be present; other values are guaranteed to be
// available based on the shorthand check at the beginning of the
diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp
index eb34c3d83..a0f52b4ea 100644
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -4255,7 +4255,6 @@ StyleAnimationValue::ExtractComputedValue(nsCSSPropertyID aProperty,
}
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
case eCSSProperty_mask_position_x: {
const nsStyleImageLayers& layers =
static_cast<const nsStyleSVGReset*>(styleStruct)->mMask;
@@ -4269,21 +4268,18 @@ StyleAnimationValue::ExtractComputedValue(nsCSSPropertyID aProperty,
break;
}
-#endif
case eCSSProperty_background_size: {
const nsStyleImageLayers& layers =
static_cast<const nsStyleBackground*>(styleStruct)->mImage;
ExtractImageLayerSizePairList(layers, aComputedValue);
break;
}
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
case eCSSProperty_mask_size: {
const nsStyleImageLayers& layers =
static_cast<const nsStyleSVGReset*>(styleStruct)->mMask;
ExtractImageLayerSizePairList(layers, aComputedValue);
break;
}
-#endif
case eCSSProperty_clip_path: {
const nsStyleSVGReset* svgReset =
diff --git a/layout/style/nsCSSDataBlock.cpp b/layout/style/nsCSSDataBlock.cpp
index fe2dc621a..1dfdaed0e 100644
--- a/layout/style/nsCSSDataBlock.cpp
+++ b/layout/style/nsCSSDataBlock.cpp
@@ -61,7 +61,6 @@ TryToStartImageLoadOnValue(const nsCSSValue& aValue, nsIDocument* aDocument,
MOZ_ASSERT(aDocument);
if (aValue.GetUnit() == eCSSUnit_URL) {
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
// The 'mask-image' property accepts local reference URIs.
// For example,
// mask-image: url(#mask_id); // refer to a SVG mask element, whose id is
@@ -94,7 +93,6 @@ TryToStartImageLoadOnValue(const nsCSSValue& aValue, nsIDocument* aDocument,
}
}
}
-#endif
aValue.StartImageLoad(aDocument);
if (aForTokenStream && aContext) {
CSSVariableImageTable::Add(aContext, aProperty,
diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h
index 94968faca..34a46ffce 100644
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -405,6 +405,7 @@ CSS_KEY(n-resize, n_resize)
CSS_KEY(narrower, narrower)
CSS_KEY(ne-resize, ne_resize)
CSS_KEY(nesw-resize, nesw_resize)
+CSS_KEY(no-clip, no_clip)
CSS_KEY(no-close-quote, no_close_quote)
CSS_KEY(no-common-ligatures, no_common_ligatures)
CSS_KEY(no-contextual, no_contextual)
diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp
index 736c66f87..a8309314f 100644
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -12005,7 +12005,6 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSPropertyID aPropID)
return ParsePaintOrder();
case eCSSProperty_scroll_snap_type:
return ParseScrollSnapType();
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
case eCSSProperty_mask:
return ParseImageLayers(nsStyleImageLayers::kMaskLayerTable);
case eCSSProperty_mask_repeat:
@@ -12018,7 +12017,6 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSPropertyID aPropID)
aPropID == eCSSProperty_mask_position_x);
case eCSSProperty_mask_size:
return ParseImageLayerSize(eCSSProperty_mask_size);
-#endif
case eCSSProperty__webkit_text_stroke:
return ParseWebkitTextStroke();
case eCSSProperty_all:
@@ -12424,7 +12422,7 @@ CSSParserImpl::ParseImageLayersItem(
aState.mImage->mValue.SetNoneValue();
aState.mAttachment->mValue.SetIntValue(NS_STYLE_IMAGELAYER_ATTACHMENT_SCROLL,
eCSSUnit_Enumerated);
- aState.mClip->mValue.SetIntValue(NS_STYLE_IMAGELAYER_CLIP_BORDER,
+ aState.mClip->mValue.SetIntValue(StyleGeometryBox::Border,
eCSSUnit_Enumerated);
aState.mRepeat->mXValue.SetIntValue(NS_STYLE_IMAGELAYER_REPEAT_REPEAT,
@@ -12437,10 +12435,10 @@ CSSParserImpl::ParseImageLayersItem(
aState.mPositionY->mValue.SetArrayValue(positionYArr, eCSSUnit_Array);
if (eCSSProperty_mask == aTable[nsStyleImageLayers::shorthand]) {
- aState.mOrigin->mValue.SetIntValue(NS_STYLE_IMAGELAYER_ORIGIN_BORDER,
+ aState.mOrigin->mValue.SetIntValue(StyleGeometryBox::Border,
eCSSUnit_Enumerated);
} else {
- aState.mOrigin->mValue.SetIntValue(NS_STYLE_IMAGELAYER_ORIGIN_PADDING,
+ aState.mOrigin->mValue.SetIntValue(StyleGeometryBox::Padding,
eCSSUnit_Enumerated);
}
positionXArr->Item(1).SetPercentValue(0.0f);
@@ -12462,6 +12460,8 @@ CSSParserImpl::ParseImageLayersItem(
haveMode = false,
haveSomething = false;
+ const KTableEntry* originTable =
+ nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::origin]];
while (GetToken(true)) {
nsCSSTokenType tt = mToken.mType;
UngetToken(); // ...but we'll still cheat and use mToken
@@ -12531,8 +12531,7 @@ CSSParserImpl::ParseImageLayersItem(
aState.mSize->mXValue = scratch.mXValue;
aState.mSize->mYValue = scratch.mYValue;
}
- } else if (nsCSSProps::FindKeyword(keyword,
- nsCSSProps::kImageLayerOriginKTable, dummy)) {
+ } else if (nsCSSProps::FindKeyword(keyword, originTable, dummy)) {
if (haveOrigin)
return false;
haveOrigin = true;
@@ -12547,23 +12546,15 @@ CSSParserImpl::ParseImageLayersItem(
// immediately following the first one (for background-origin).
#ifdef DEBUG
- for (size_t i = 0; nsCSSProps::kImageLayerOriginKTable[i].mValue != -1; i++) {
+ const KTableEntry* clipTable =
+ nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::clip]];
+ for (size_t i = 0; originTable[i].mValue != -1; i++) {
// For each keyword & value in kOriginKTable, ensure that
// kBackgroundKTable has a matching entry at the same position.
- MOZ_ASSERT(nsCSSProps::kImageLayerOriginKTable[i].mKeyword ==
- nsCSSProps::kBackgroundClipKTable[i].mKeyword);
- MOZ_ASSERT(nsCSSProps::kImageLayerOriginKTable[i].mValue ==
- nsCSSProps::kBackgroundClipKTable[i].mValue);
+ MOZ_ASSERT(originTable[i].mKeyword == clipTable[i].mKeyword);
+ MOZ_ASSERT(originTable[i].mValue == clipTable[i].mValue);
}
#endif
- static_assert(NS_STYLE_IMAGELAYER_CLIP_BORDER ==
- NS_STYLE_IMAGELAYER_ORIGIN_BORDER &&
- NS_STYLE_IMAGELAYER_CLIP_PADDING ==
- NS_STYLE_IMAGELAYER_ORIGIN_PADDING &&
- NS_STYLE_IMAGELAYER_CLIP_CONTENT ==
- NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
- "bg-clip and bg-origin style constants must agree");
-
CSSParseResult result =
ParseSingleValueProperty(aState.mClip->mValue,
aTable[nsStyleImageLayers::clip]);
diff --git a/layout/style/nsCSSPropAliasList.h b/layout/style/nsCSSPropAliasList.h
index 2699549ff..f7938af9e 100644
--- a/layout/style/nsCSSPropAliasList.h
+++ b/layout/style/nsCSSPropAliasList.h
@@ -453,7 +453,6 @@ CSS_PROP_ALIAS(-webkit-user-select,
WebkitUserSelect,
WEBKIT_PREFIX_PREF)
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
CSS_PROP_ALIAS(-webkit-mask,
mask,
WebkitMask,
@@ -494,5 +493,4 @@ CSS_PROP_ALIAS(-webkit-mask-size,
mask_size,
WebkitMaskSize,
WEBKIT_PREFIX_PREF)
-#endif
#undef WEBKIT_PREFIX_PREF
diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h
index b04921dcb..2049f70e8 100644
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -564,7 +564,7 @@ CSS_PROP_BACKGROUND(
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
"",
VARIANT_KEYWORD, // used by list parsing
- kImageLayerOriginKTable,
+ kBackgroundOriginKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Discrete)
CSS_PROP_SHORTHAND(
@@ -2645,19 +2645,6 @@ CSS_PROP_SVG(
nullptr,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Discrete)
-#ifndef MOZ_ENABLE_MASK_AS_SHORTHAND
-CSS_PROP_SVGRESET(
- mask,
- mask,
- Mask,
- CSS_PROPERTY_PARSE_VALUE |
- CSS_PROPERTY_CREATES_STACKING_CONTEXT,
- "",
- VARIANT_HUO,
- nullptr,
- CSS_PROP_NO_OFFSET,
- eStyleAnimType_Discrete)
-#else
CSS_PROP_SHORTHAND(
mask,
mask,
@@ -2672,7 +2659,7 @@ CSS_PROP_SVGRESET(
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
"",
VARIANT_KEYWORD, // used by list parsing
- kImageLayerOriginKTable,
+ kMaskClipKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Discrete)
CSS_PROP_SVGRESET(
@@ -2718,7 +2705,7 @@ CSS_PROP_SVGRESET(
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
"",
VARIANT_KEYWORD, // used by list parsing
- kImageLayerOriginKTable,
+ kMaskOriginKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Discrete)
CSS_PROP_SHORTHAND(
@@ -2776,7 +2763,6 @@ CSS_PROP_SVGRESET(
kImageLayerSizeKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Custom)
-#endif // MOZ_ENABLE_MASK_AS_SHORTHAND
CSS_PROP_SVGRESET(
mask-type,
mask_type,
diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp
index 9805eae14..ac2978c27 100644
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -932,33 +932,43 @@ const KTableEntry nsCSSProps::kImageLayerAttachmentKTable[] = {
{ eCSSKeyword_UNKNOWN, -1 }
};
-static_assert(NS_STYLE_IMAGELAYER_CLIP_BORDER == NS_STYLE_IMAGELAYER_ORIGIN_BORDER &&
- NS_STYLE_IMAGELAYER_CLIP_PADDING == NS_STYLE_IMAGELAYER_ORIGIN_PADDING &&
- NS_STYLE_IMAGELAYER_CLIP_CONTENT == NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
- "Except background-clip:text, all {background,mask}-clip and "
- "{background,mask}-origin style constants must agree");
-
-const KTableEntry nsCSSProps::kImageLayerOriginKTable[] = {
- { eCSSKeyword_border_box, NS_STYLE_IMAGELAYER_ORIGIN_BORDER },
- { eCSSKeyword_padding_box, NS_STYLE_IMAGELAYER_ORIGIN_PADDING },
- { eCSSKeyword_content_box, NS_STYLE_IMAGELAYER_ORIGIN_CONTENT },
+const KTableEntry nsCSSProps::kBackgroundOriginKTable[] = {
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_padding_box, StyleGeometryBox::Padding },
+ { eCSSKeyword_content_box, StyleGeometryBox::Content },
{ eCSSKeyword_UNKNOWN, -1 }
};
KTableEntry nsCSSProps::kBackgroundClipKTable[] = {
- { eCSSKeyword_border_box, NS_STYLE_IMAGELAYER_CLIP_BORDER },
- { eCSSKeyword_padding_box, NS_STYLE_IMAGELAYER_CLIP_PADDING },
- { eCSSKeyword_content_box, NS_STYLE_IMAGELAYER_CLIP_CONTENT },
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_padding_box, StyleGeometryBox::Padding },
+ { eCSSKeyword_content_box, StyleGeometryBox::Content },
// The next entry is controlled by the layout.css.background-clip-text.enabled
// pref.
- { eCSSKeyword_text, NS_STYLE_IMAGELAYER_CLIP_TEXT },
+ { eCSSKeyword_text, StyleGeometryBox::Text },
{ eCSSKeyword_UNKNOWN, -1 }
};
-static_assert(MOZ_ARRAY_LENGTH(nsCSSProps::kImageLayerOriginKTable) ==
- MOZ_ARRAY_LENGTH(nsCSSProps::kBackgroundClipKTable) - 1,
- "background-clip has one extra value, which is text, compared"
- "to {background,mask}-origin");
+const KTableEntry nsCSSProps::kMaskOriginKTable[] = {
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_padding_box, StyleGeometryBox::Padding },
+ { eCSSKeyword_content_box, StyleGeometryBox::Content },
+ { eCSSKeyword_fill_box, StyleGeometryBox::Fill },
+ { eCSSKeyword_stroke_box, StyleGeometryBox::Stroke },
+ { eCSSKeyword_view_box, StyleGeometryBox::View },
+ { eCSSKeyword_UNKNOWN, -1 }
+};
+
+const KTableEntry nsCSSProps::kMaskClipKTable[] = {
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_padding_box, StyleGeometryBox::Padding },
+ { eCSSKeyword_content_box, StyleGeometryBox::Content },
+ { eCSSKeyword_fill_box, StyleGeometryBox::Fill },
+ { eCSSKeyword_stroke_box, StyleGeometryBox::Stroke },
+ { eCSSKeyword_view_box, StyleGeometryBox::View },
+ { eCSSKeyword_no_clip, StyleGeometryBox::NoClip },
+ { eCSSKeyword_UNKNOWN, -1 }
+};
// Note: Don't change this table unless you update
// ParseImageLayerPosition!
@@ -2346,13 +2356,13 @@ const KTableEntry nsCSSProps::kFillRuleKTable[] = {
};
const KTableEntry nsCSSProps::kClipPathGeometryBoxKTable[] = {
- { eCSSKeyword_content_box, StyleClipPathGeometryBox::Content },
- { eCSSKeyword_padding_box, StyleClipPathGeometryBox::Padding },
- { eCSSKeyword_border_box, StyleClipPathGeometryBox::Border },
- { eCSSKeyword_margin_box, StyleClipPathGeometryBox::Margin },
- { eCSSKeyword_fill_box, StyleClipPathGeometryBox::Fill },
- { eCSSKeyword_stroke_box, StyleClipPathGeometryBox::Stroke },
- { eCSSKeyword_view_box, StyleClipPathGeometryBox::View },
+ { eCSSKeyword_content_box, StyleGeometryBox::Content },
+ { eCSSKeyword_padding_box, StyleGeometryBox::Padding },
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_margin_box, StyleGeometryBox::Margin },
+ { eCSSKeyword_fill_box, StyleGeometryBox::Fill },
+ { eCSSKeyword_stroke_box, StyleGeometryBox::Stroke },
+ { eCSSKeyword_view_box, StyleGeometryBox::View },
{ eCSSKeyword_UNKNOWN, -1 }
};
@@ -3051,7 +3061,6 @@ static const nsCSSPropertyID gScrollSnapTypeSubpropTable[] = {
eCSSProperty_scroll_snap_type_y,
eCSSProperty_UNKNOWN
};
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
static const nsCSSPropertyID gMaskSubpropTable[] = {
eCSSProperty_mask_image,
eCSSProperty_mask_repeat,
@@ -3069,7 +3078,6 @@ static const nsCSSPropertyID gMaskPositionSubpropTable[] = {
eCSSProperty_mask_position_y,
eCSSProperty_UNKNOWN
};
-#endif
// FIXME: mask-border tables should be added when we implement
// mask-border properties.
diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h
index dfe35afd8..e67e1d41d 100644
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -717,6 +717,8 @@ public:
static const KTableEntry kTransformStyleKTable[];
static const KTableEntry kImageLayerAttachmentKTable[];
static const KTableEntry kImageLayerOriginKTable[];
+ static const KTableEntry kBackgroundOriginKTable[];
+ static const KTableEntry kMaskOriginKTable[];
static const KTableEntry kImageLayerPositionKTable[];
static const KTableEntry kImageLayerRepeatKTable[];
static const KTableEntry kImageLayerRepeatPartKTable[];
@@ -726,6 +728,7 @@ public:
// Not const because we modify its entries when the pref
// "layout.css.background-clip.text" changes:
static KTableEntry kBackgroundClipKTable[];
+ static const KTableEntry kMaskClipKTable[];
static const KTableEntry kBlendModeKTable[];
static const KTableEntry kBorderCollapseKTable[];
static const KTableEntry kBorderImageRepeatKTable[];
diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp
index 4f8d3edf6..36c3a6385 100644
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -74,6 +74,30 @@ NS_NewComputedDOMStyle(dom::Element* aElement, const nsAString& aPseudoElt,
return computedStyle.forget();
}
+static nsDOMCSSValueList*
+GetROCSSValueList(bool aCommaDelimited)
+{
+ return new nsDOMCSSValueList(aCommaDelimited, true);
+}
+
+template<typename T>
+already_AddRefed<CSSValue>
+GetBackgroundList(T nsStyleImageLayers::Layer::* aMember,
+ uint32_t nsStyleImageLayers::* aCount,
+ const nsStyleImageLayers& aLayers,
+ const KTableEntry aTable[])
+{
+ RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(true);
+
+ for (uint32_t i = 0, i_end = aLayers.*aCount; i < i_end; ++i) {
+ RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
+ val->SetIdent(nsCSSProps::ValueToKeywordEnum(aLayers.mLayers[i].*aMember, aTable));
+ valueList->AppendCSSValue(val.forget());
+ }
+
+ return valueList.forget();
+}
+
/**
* An object that represents the ordered set of properties that are exposed on
* an nsComputedDOMStyle object and how their computed values can be obtained.
@@ -1803,24 +1827,6 @@ nsComputedDOMStyle::DoGetFontVariantPosition()
}
already_AddRefed<CSSValue>
-nsComputedDOMStyle::GetBackgroundList(uint8_t nsStyleImageLayers::Layer::* aMember,
- uint32_t nsStyleImageLayers::* aCount,
- const nsStyleImageLayers& aLayers,
- const KTableEntry aTable[])
-{
- RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(true);
-
- for (uint32_t i = 0, i_end = aLayers.*aCount; i < i_end; ++i) {
- RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
- val->SetIdent(nsCSSProps::ValueToKeywordEnum(aLayers.mLayers[i].*aMember,
- aTable));
- valueList->AppendCSSValue(val.forget());
- }
-
- return valueList.forget();
-}
-
-already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetBackgroundAttachment()
{
return GetBackgroundList(&nsStyleImageLayers::Layer::mAttachment,
@@ -2367,7 +2373,7 @@ nsComputedDOMStyle::DoGetBackgroundOrigin()
return GetBackgroundList(&nsStyleImageLayers::Layer::mOrigin,
&nsStyleImageLayers::mOriginCount,
StyleBackground()->mImage,
- nsCSSProps::kImageLayerOriginKTable);
+ nsCSSProps::kBackgroundOriginKTable);
}
void
@@ -5013,12 +5019,6 @@ nsComputedDOMStyle::DoGetTop()
return GetOffsetWidthFor(NS_SIDE_TOP);
}
-nsDOMCSSValueList*
-nsComputedDOMStyle::GetROCSSValueList(bool aCommaDelimited)
-{
- return new nsDOMCSSValueList(aCommaDelimited, true);
-}
-
already_AddRefed<CSSValue>
nsComputedDOMStyle::GetOffsetWidthFor(mozilla::css::Side aSide)
{
@@ -6180,8 +6180,8 @@ nsComputedDOMStyle::DoGetMask()
// 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.mClip != StyleGeometryBox::Border ||
+ firstLayer.mOrigin != StyleGeometryBox::Border ||
firstLayer.mComposite != NS_STYLE_MASK_COMPOSITE_ADD ||
firstLayer.mMaskMode != NS_STYLE_MASK_MODE_MATCH_SOURCE ||
!nsStyleImageLayers::IsInitialPositionForLayerType(
@@ -6200,14 +6200,13 @@ nsComputedDOMStyle::DoGetMask()
return val.forget();
}
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetMaskClip()
{
return GetBackgroundList(&nsStyleImageLayers::Layer::mClip,
&nsStyleImageLayers::mClipCount,
StyleSVGReset()->mMask,
- nsCSSProps::kImageLayerOriginKTable);
+ nsCSSProps::kMaskClipKTable);
}
already_AddRefed<CSSValue>
@@ -6241,7 +6240,7 @@ nsComputedDOMStyle::DoGetMaskOrigin()
return GetBackgroundList(&nsStyleImageLayers::Layer::mOrigin,
&nsStyleImageLayers::mOriginCount,
StyleSVGReset()->mMask,
- nsCSSProps::kImageLayerOriginKTable);
+ nsCSSProps::kMaskOriginKTable);
}
already_AddRefed<CSSValue>
@@ -6278,7 +6277,6 @@ nsComputedDOMStyle::DoGetMaskSize()
const nsStyleImageLayers& layers = StyleSVGReset()->mMask;
return DoGetImageLayerSize(layers);
}
-#endif
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetMaskType()
diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h
index 27e2086e9..77df71ec8 100644
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -53,6 +53,7 @@ private:
// Convenience typedefs:
typedef nsCSSProps::KTableEntry KTableEntry;
typedef mozilla::dom::CSSValue CSSValue;
+ typedef mozilla::StyleGeometryBox StyleGeometryBox;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@@ -202,12 +203,6 @@ private:
const nscolor& aDefaultColor,
bool aIsBoxShadow);
- already_AddRefed<CSSValue> GetBackgroundList(
- uint8_t nsStyleImageLayers::Layer::* aMember,
- uint32_t nsStyleImageLayers::* aCount,
- const nsStyleImageLayers& aLayers,
- const KTableEntry aTable[]);
-
void GetCSSGradientString(const nsStyleGradient* aGradient,
nsAString& aString);
void GetImageRectString(nsIURI* aURI,
@@ -310,7 +305,6 @@ private:
/* Mask properties */
already_AddRefed<CSSValue> DoGetMask();
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
already_AddRefed<CSSValue> DoGetMaskImage();
already_AddRefed<CSSValue> DoGetMaskPosition();
already_AddRefed<CSSValue> DoGetMaskPositionX();
@@ -321,7 +315,7 @@ private:
already_AddRefed<CSSValue> DoGetMaskSize();
already_AddRefed<CSSValue> DoGetMaskMode();
already_AddRefed<CSSValue> DoGetMaskComposite();
-#endif
+
/* Padding properties */
already_AddRefed<CSSValue> DoGetPaddingTop();
already_AddRefed<CSSValue> DoGetPaddingBottom();
@@ -582,8 +576,6 @@ private:
/* Custom properties */
already_AddRefed<CSSValue> DoGetCustomProperty(const nsAString& aPropertyName);
- nsDOMCSSValueList* GetROCSSValueList(bool aCommaDelimited);
-
/* Helper functions */
void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor);
void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue,
diff --git a/layout/style/nsComputedDOMStylePropertyList.h b/layout/style/nsComputedDOMStylePropertyList.h
index 1983208ac..825976b58 100644
--- a/layout/style/nsComputedDOMStylePropertyList.h
+++ b/layout/style/nsComputedDOMStylePropertyList.h
@@ -332,7 +332,6 @@ COMPUTED_STYLE_PROP(marker_end, MarkerEnd)
COMPUTED_STYLE_PROP(marker_mid, MarkerMid)
COMPUTED_STYLE_PROP(marker_start, MarkerStart)
COMPUTED_STYLE_PROP(mask, Mask)
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
COMPUTED_STYLE_PROP(mask_clip, MaskClip)
COMPUTED_STYLE_PROP(mask_composite, MaskComposite)
COMPUTED_STYLE_PROP(mask_image, MaskImage)
@@ -343,7 +342,6 @@ COMPUTED_STYLE_PROP(mask_position_x, MaskPositionX)
COMPUTED_STYLE_PROP(mask_position_y, MaskPositionY)
COMPUTED_STYLE_PROP(mask_repeat, MaskRepeat)
COMPUTED_STYLE_PROP(mask_size, MaskSize)
-#endif
COMPUTED_STYLE_PROP(mask_type, MaskType)
COMPUTED_STYLE_PROP(paint_order, PaintOrder)
COMPUTED_STYLE_PROP(shape_rendering, ShapeRendering)
diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp
index 9b9fc3948..6bcef02a0 100644
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -22,6 +22,7 @@
#include "mozilla/Unused.h"
#include "mozilla/css/Declaration.h"
+#include "mozilla/TypeTraits.h"
#include "nsAlgorithm.h" // for clamped()
#include "nsRuleNode.h"
@@ -6800,6 +6801,21 @@ struct BackgroundItemComputer<nsCSSValueList, RefPtr<css::URLValueData>>
}
};
+template <typename T>
+struct BackgroundItemComputer<nsCSSValueList, T>
+{
+ typedef typename EnableIf<IsEnum<T>::value, T>::Type ComputedType;
+
+ static void ComputeValue(nsStyleContext* aStyleContext,
+ const nsCSSValueList* aSpecifiedValue,
+ ComputedType& aComputedValue,
+ RuleNodeCacheConditions& aConditions)
+ {
+ aComputedValue =
+ static_cast<T>(aSpecifiedValue->mValue.GetIntValue());
+ }
+};
+
/* Helper function for ComputePositionValue.
* This function computes a single PositionCoord from two nsCSSValue objects,
* which represent an edge and an offset from that edge.
@@ -7353,7 +7369,7 @@ nsRuleNode::ComputeBackgroundData(void* aStartStruct,
bg->mImage.mLayers,
parentBG->mImage.mLayers,
&nsStyleImageLayers::Layer::mClip,
- uint8_t(NS_STYLE_IMAGELAYER_CLIP_BORDER),
+ StyleGeometryBox::Border,
parentBG->mImage.mClipCount,
bg->mImage.mClipCount, maxItemCount, rebuild, conditions);
@@ -7372,7 +7388,7 @@ nsRuleNode::ComputeBackgroundData(void* aStartStruct,
bg->mImage.mLayers,
parentBG->mImage.mLayers,
&nsStyleImageLayers::Layer::mOrigin,
- uint8_t(NS_STYLE_IMAGELAYER_ORIGIN_PADDING),
+ StyleGeometryBox::Padding,
parentBG->mImage.mOriginCount,
bg->mImage.mOriginCount, maxItemCount, rebuild,
conditions);
@@ -10005,7 +10021,6 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
parentSVGReset->mMaskType,
NS_STYLE_MASK_TYPE_LUMINANCE);
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
uint32_t maxItemCount = 1;
bool rebuild = false;
@@ -10043,7 +10058,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
svgReset->mMask.mLayers,
parentSVGReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mClip,
- uint8_t(NS_STYLE_IMAGELAYER_CLIP_BORDER),
+ StyleGeometryBox::Border,
parentSVGReset->mMask.mClipCount,
svgReset->mMask.mClipCount, maxItemCount, rebuild,
conditions);
@@ -10053,7 +10068,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
svgReset->mMask.mLayers,
parentSVGReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mOrigin,
- uint8_t(NS_STYLE_IMAGELAYER_ORIGIN_BORDER),
+ StyleGeometryBox::Border,
parentSVGReset->mMask.mOriginCount,
svgReset->mMask.mOriginCount, maxItemCount, rebuild,
conditions);
@@ -10113,21 +10128,6 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
if (rebuild) {
FillAllBackgroundLists(svgReset->mMask, maxItemCount);
}
-#else
- // mask: none | <url>
- const nsCSSValue* maskValue = aRuleData->ValueForMask();
- if (eCSSUnit_URL == maskValue->GetUnit()) {
- svgReset->mMask.mLayers[0].mSourceURI = maskValue->GetURLStructValue();
- } else if (eCSSUnit_None == maskValue->GetUnit() ||
- eCSSUnit_Initial == maskValue->GetUnit() ||
- eCSSUnit_Unset == maskValue->GetUnit()) {
- svgReset->mMask.mLayers[0].mSourceURI = nullptr;
- } else if (eCSSUnit_Inherit == maskValue->GetUnit()) {
- conditions.SetUncacheable();
- svgReset->mMask.mLayers[0].mSourceURI =
- parentSVGReset->mMask.mLayers[0].mSourceURI;
- }
-#endif
COMPUTE_END_RESET(SVGReset, svgReset)
}
diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h
index be588113e..6d207aec9 100644
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -134,16 +134,35 @@ enum class StyleClear : uint8_t {
Max = 13 // Max = (Both | Line)
};
-// clip-path geometry box
-enum class StyleClipPathGeometryBox : uint8_t {
- NoBox,
+// Define geometry box for clip-path's reference-box, background-clip,
+// background-origin, mask-clip and mask-origin.
+enum class StyleGeometryBox : uint8_t {
Content,
Padding,
Border,
- Margin,
- Fill,
- Stroke,
- View,
+ Margin, // XXX Bug 1260094 comment 9.
+ // Although margin-box is required by mask-origin and mask-clip, we
+ // do not implement that due to lack of support in other browsers.
+ // clip-path reference-box only.
+ Fill, // mask-clip, mask-origin and clip-path reference-box only.
+ Stroke, // mask-clip, mask-origin and clip-path reference-box only.
+ View, // mask-clip, mask-origin and clip-path reference-box only.
+ NoClip, // mask-clip only.
+ Text, // background-clip only.
+ NoBox, // Depending on which kind of element this style value applied on,
+ // the default value of a reference-box can be different.
+ // For an HTML element, the default value of reference-box is
+ // border-box; for an SVG element, the default value is fill-box.
+ // Since we can not determine the default value at parsing time,
+ // set it as NoBox so that we make a decision later.
+ // clip-path reference-box only.
+ MozAlmostPadding = 127 // A magic value that we use for our "pretend that
+ // background-clip is 'padding' when we have a solid
+ // border" optimization. This isn't actually equal
+ // to StyleGeometryBox::Padding because using that
+ // causes antialiasing seams between the background
+ // and border.
+ // background-clip only.
};
// fill-rule
@@ -359,14 +378,6 @@ enum class FillMode : uint32_t;
#define NS_STYLE_IMAGELAYER_ATTACHMENT_FIXED 1
#define NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL 2
-// See nsStyleImageLayers
-// Code depends on these constants having the same values as IMAGELAYER_ORIGIN_*
-#define NS_STYLE_IMAGELAYER_CLIP_BORDER 0
-#define NS_STYLE_IMAGELAYER_CLIP_PADDING 1
-#define NS_STYLE_IMAGELAYER_CLIP_CONTENT 2
-// One extra constant which does not exist in IMAGELAYER_ORIGIN_*
-#define NS_STYLE_IMAGELAYER_CLIP_TEXT 3
-
// A magic value that we use for our "pretend that background-clip is
// 'padding' when we have a solid border" optimization. This isn't
// actually equal to NS_STYLE_IMAGELAYER_CLIP_PADDING because using that
@@ -375,12 +386,6 @@ enum class FillMode : uint32_t;
#define NS_STYLE_IMAGELAYER_CLIP_MOZ_ALMOST_PADDING 127
// See nsStyleImageLayers
-// Code depends on these constants having the same values as BG_CLIP_*
-#define NS_STYLE_IMAGELAYER_ORIGIN_BORDER 0
-#define NS_STYLE_IMAGELAYER_ORIGIN_PADDING 1
-#define NS_STYLE_IMAGELAYER_ORIGIN_CONTENT 2
-
-// See nsStyleImageLayers
// The parser code depends on |ing these values together.
#define NS_STYLE_IMAGELAYER_POSITION_CENTER (1<<0)
#define NS_STYLE_IMAGELAYER_POSITION_TOP (1<<1)
diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp
index 52491a288..72c103724 100644
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2465,7 +2465,6 @@ const nsCSSPropertyID nsStyleImageLayers::kBackgroundLayerTable[] = {
eCSSProperty_UNKNOWN // composite
};
-#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
const nsCSSPropertyID nsStyleImageLayers::kMaskLayerTable[] = {
eCSSProperty_mask, // shorthand
eCSSProperty_UNKNOWN, // color
@@ -2480,7 +2479,6 @@ const nsCSSPropertyID nsStyleImageLayers::kMaskLayerTable[] = {
eCSSProperty_mask_mode, // maskMode
eCSSProperty_mask_composite // composite
};
-#endif
nsStyleImageLayers::nsStyleImageLayers(nsStyleImageLayers::LayerType aType)
: mAttachmentCount(1)
@@ -2787,7 +2785,7 @@ nsStyleImageLayers::Size::operator==(const Size& aOther) const
}
nsStyleImageLayers::Layer::Layer()
- : mClip(NS_STYLE_IMAGELAYER_CLIP_BORDER)
+ : mClip(StyleGeometryBox::Border)
, mAttachment(NS_STYLE_IMAGELAYER_ATTACHMENT_SCROLL)
, mBlendMode(NS_STYLE_BLEND_NORMAL)
, mComposite(NS_STYLE_MASK_COMPOSITE_ADD)
@@ -2809,10 +2807,10 @@ nsStyleImageLayers::Layer::Initialize(nsStyleImageLayers::LayerType aType)
mPosition.SetInitialPercentValues(0.0f);
if (aType == LayerType::Background) {
- mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_PADDING;
+ mOrigin = StyleGeometryBox::Padding;
} else {
MOZ_ASSERT(aType == LayerType::Mask, "unsupported layer type.");
- mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_BORDER;
+ mOrigin = StyleGeometryBox::Border;
}
}
diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h
index 1cadea840..c8182b8f1 100644
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -782,6 +782,8 @@ struct nsStyleImageLayers {
struct Layer;
friend struct Layer;
struct Layer {
+ typedef mozilla::StyleGeometryBox StyleGeometryBox;
+
nsStyleImage mImage; // [reset]
RefPtr<mozilla::css::URLValueData> mSourceURI; // [reset]
// mask-only property
@@ -793,9 +795,9 @@ struct nsStyleImageLayers {
// or an ImageValue.)
mozilla::Position mPosition; // [reset]
Size mSize; // [reset]
- uint8_t mClip; // [reset] See nsStyleConsts.h
+ StyleGeometryBox mClip; // [reset] See nsStyleConsts.h
MOZ_INIT_OUTSIDE_CTOR
- uint8_t mOrigin; // [reset] See nsStyleConsts.h
+ StyleGeometryBox mOrigin; // [reset] See nsStyleConsts.h
uint8_t mAttachment; // [reset] See nsStyleConsts.h
// background-only property
// This property is used for background layer
@@ -2755,7 +2757,7 @@ private:
ReferenceBox mReferenceBox = ReferenceBox::NoBox;
};
-using StyleClipPath = StyleShapeSource<StyleClipPathGeometryBox>;
+using StyleClipPath = StyleShapeSource<StyleGeometryBox>;
using StyleShapeOutside = StyleShapeSource<StyleShapeOutsideShapeBox>;
} // namespace mozilla