--- a/layout/style/Declaration.cpp
+++ b/layout/style/Declaration.cpp
@@ -1449,25 +1449,16 @@ Declaration::GetPropertyValueInternal(
aValue.Append(char16_t(' '));
}
}
if (!isDefaultColor) {
AppendValueToString(eCSSProperty_text_emphasis_color, aValue);
}
break;
}
- case eCSSProperty__moz_transform: {
- // shorthands that are just aliases with different parsing rules
- const nsCSSPropertyID* subprops =
- nsCSSProps::SubpropertyEntryFor(aProperty);
- MOZ_ASSERT(subprops[1] == eCSSProperty_UNKNOWN,
- "must have exactly one subproperty");
- AppendValueToString(subprops[0], aValue);
- break;
- }
case eCSSProperty_overscroll_behavior: {
const nsCSSValue& xValue =
*data->ValueFor(eCSSProperty_overscroll_behavior_x);
const nsCSSValue& yValue =
*data->ValueFor(eCSSProperty_overscroll_behavior_y);
AppendValueToString(eCSSProperty_overscroll_behavior_x, aValue);
if (yValue != xValue) {
aValue.Append(char16_t(' '));
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -926,17 +926,17 @@ protected:
bool ParseFontVariationSettings(nsCSSValue& aValue);
bool ParseFontSrc(nsCSSValue& aValue);
bool ParseFontSrcFormat(InfallibleTArray<nsCSSValue>& values);
bool ParseFontRanges(nsCSSValue& aValue);
bool ParseListStyle();
bool ParseListStyleType(nsCSSValue& aValue);
bool ParseMargin();
bool ParseClipPath(nsCSSValue& aValue);
- bool ParseTransform(bool aIsPrefixed, nsCSSPropertyID aProperty,
+ bool ParseTransform(nsCSSPropertyID aProperty,
bool aDisallowRelativeValues = false);
bool ParseObjectPosition();
bool ParseOutline();
bool ParseOverflow();
bool ParseOverflowClipBox();
bool ParsePadding();
bool ParseQuotes();
bool ParseTextAlign(nsCSSValue& aValue,
@@ -1245,17 +1245,17 @@ protected:
bool ParseCircleOrEllipseFunction(nsCSSKeyword, nsCSSValue& aValue);
bool ParseInsetFunction(nsCSSValue& aValue);
// We parse position values differently for basic-shape, by expanding defaults
// and replacing keywords with percentages
bool ParsePositionValueForBasicShape(nsCSSValue& aOut);
/* Functions for transform Parsing */
- bool ParseSingleTransform(bool aIsPrefixed, bool aDisallowRelativeValues,
+ bool ParseSingleTransform(bool aDisallowRelativeValues,
nsCSSValue& aValue);
bool ParseFunction(nsCSSKeyword aFunction, const uint32_t aAllowedTypes[],
uint32_t aVariantMaskAll, uint16_t aMinElems,
uint16_t aMaxElems, nsCSSValue &aValue);
bool ParseFunctionInternals(const uint32_t aVariantMask[],
uint32_t aVariantMaskAll,
uint16_t aMinElems,
uint16_t aMaxElems,
@@ -1822,17 +1822,17 @@ CSSParserImpl::ParseTransformProperty(co
mData.AssertInitialState();
mTempData.AssertInitialState();
nsCSSScanner scanner(aPropValue, 0);
css::ErrorReporter reporter(scanner, mSheet, mChildLoader, nullptr);
InitScanner(scanner, reporter, nullptr, nullptr, nullptr);
- bool parsedOK = ParseTransform(false, eCSSProperty_transform,
+ bool parsedOK = ParseTransform(eCSSProperty_transform,
aDisallowRelativeValues);
// We should now be at EOF
if (parsedOK && GetToken(true)) {
parsedOK = false;
mTempData.ClearProperty(eCSSProperty_transform);
}
bool changed = false;
@@ -11781,19 +11781,17 @@ CSSParserImpl::ParsePropertyByFunction(n
case eCSSProperty_text_decoration:
return ParseTextDecoration();
case eCSSProperty_text_emphasis:
return ParseTextEmphasis();
case eCSSProperty_will_change:
return ParseWillChange();
case eCSSProperty_transform:
case eCSSProperty__moz_window_transform:
- return ParseTransform(false, aPropID);
- case eCSSProperty__moz_transform:
- return ParseTransform(true, eCSSProperty_transform);
+ return ParseTransform(aPropID);
case eCSSProperty_transform_origin:
case eCSSProperty_perspective_origin:
case eCSSProperty__moz_window_transform_origin:
return ParseTransformOrigin(aPropID);
case eCSSProperty_transition:
return ParseTransition();
case eCSSProperty_animation:
return ParseAnimation();
@@ -15850,27 +15848,24 @@ CSSParserImpl::ParseFunction(nsCSSKeywor
/**
* Given a token, determines the minimum and maximum number of function
* parameters to read, along with the mask that should be used to read
* those function parameters. If the token isn't a transform function,
* returns an error.
*
* @param aToken The token identifying the function.
- * @param aIsPrefixed If true, parse matrices using the matrix syntax
- * for -moz-transform.
* @param aDisallowRelativeValues If true, only allow variants that are
* numbers or have non-relative dimensions.
* @param aMinElems [out] The minimum number of elements to read.
* @param aMaxElems [out] The maximum number of elements to read
* @param aVariantMask [out] The variant mask to use during parsing
* @return Whether the information was loaded successfully.
*/
static bool GetFunctionParseInformation(nsCSSKeyword aToken,
- bool aIsPrefixed,
bool aDisallowRelativeValues,
uint16_t &aMinElems,
uint16_t &aMaxElems,
const uint32_t *& aVariantMask)
{
/* These types represent the common variant masks that will be used to
* parse out the individual functions. The order in the enumeration
* must match the order in which the masks are declared.
@@ -15886,19 +15881,17 @@ static bool GetFunctionParseInformation(
eTwoAngles,
eNumber,
eNonNegativeLength,
eNonNegativeAbsoluteLength,
eTwoNumbers,
eThreeNumbers,
eThreeNumbersOneAngle,
eMatrix,
- eMatrixPrefixed,
eMatrix3d,
- eMatrix3dPrefixed,
eNumVariantMasks };
static const int32_t kMaxElemsPerFunction = 16;
static const uint32_t kVariantMasks[eNumVariantMasks][kMaxElemsPerFunction] = {
{VARIANT_LPCALC},
{VARIANT_LCALC},
{VARIANT_LB},
{VARIANT_LPCALC, VARIANT_LPCALC},
{VARIANT_LBCALC, VARIANT_LBCALC},
@@ -15910,25 +15903,19 @@ static bool GetFunctionParseInformation(
{VARIANT_LENGTH|VARIANT_NONNEGATIVE_DIMENSION},
{VARIANT_LB|VARIANT_NONNEGATIVE_DIMENSION},
{VARIANT_NUMBER, VARIANT_NUMBER},
{VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER},
{VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_ANGLE_OR_ZERO},
{VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
VARIANT_NUMBER, VARIANT_NUMBER},
{VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
- VARIANT_LPNCALC, VARIANT_LPNCALC},
- {VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
- VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER},
- {VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
- VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
- VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
- VARIANT_LPNCALC, VARIANT_LPNCALC, VARIANT_LNCALC, VARIANT_NUMBER}};
+ VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER}};
// Map from a mask to a congruent mask that excludes relative variants.
static const int32_t kNonRelativeVariantMap[eNumVariantMasks] = {
eAbsoluteLengthCalc,
eAbsoluteLengthCalc,
eAbsoluteLengthCalc,
eTwoAbsoluteLengthCalcs,
eTwoAbsoluteLengthCalcs,
eThreeAbsoluteLengthCalc,
@@ -15937,23 +15924,21 @@ static bool GetFunctionParseInformation(
eTwoAngles,
eNumber,
eNonNegativeAbsoluteLength,
eNonNegativeAbsoluteLength,
eTwoNumbers,
eThreeNumbers,
eThreeNumbersOneAngle,
eMatrix,
- eMatrix,
- eMatrix3d,
eMatrix3d };
#ifdef DEBUG
static const uint8_t kVariantMaskLengths[eNumVariantMasks] =
- {1, 1, 1, 2, 2, 3, 3, 1, 2, 1, 1, 1, 2, 3, 4, 6, 6, 16, 16};
+ {1, 1, 1, 2, 2, 3, 3, 1, 2, 1, 1, 1, 2, 3, 4, 6, 16};
#endif
int32_t variantIndex = eNumVariantMasks;
switch (aToken) {
case eCSSKeyword_translatex:
case eCSSKeyword_translatey:
/* Exactly one length or percent. */
@@ -16028,23 +16013,23 @@ static bool GetFunctionParseInformation(
case eCSSKeyword_skewy:
/* Exactly one angle. */
variantIndex = eAngle;
aMinElems = 1U;
aMaxElems = 1U;
break;
case eCSSKeyword_matrix:
/* Six values, all numbers. */
- variantIndex = aIsPrefixed ? eMatrixPrefixed : eMatrix;
+ variantIndex = eMatrix;
aMinElems = 6U;
aMaxElems = 6U;
break;
case eCSSKeyword_matrix3d:
/* 16 matrix values, all numbers */
- variantIndex = aIsPrefixed ? eMatrix3dPrefixed : eMatrix3d;
+ variantIndex = eMatrix3d;
aMinElems = 16U;
aMaxElems = 16U;
break;
case eCSSKeyword_perspective:
/* Exactly one scale number. */
variantIndex = eNonNegativeLength;
aMinElems = 1U;
aMaxElems = 1U;
@@ -16124,33 +16109,32 @@ bool CSSParserImpl::ParseWillChange()
AppendValue(eCSSProperty_will_change, listValue);
return true;
}
/* Reads a single transform function from the tokenizer stream, reporting an
* error if something goes wrong.
*/
bool
-CSSParserImpl::ParseSingleTransform(bool aIsPrefixed,
- bool aDisallowRelativeValues,
+CSSParserImpl::ParseSingleTransform(bool aDisallowRelativeValues,
nsCSSValue& aValue)
{
if (!GetToken(true))
return false;
if (mToken.mType != eCSSToken_Function) {
UngetToken();
return false;
}
const uint32_t* variantMask;
uint16_t minElems, maxElems;
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(mToken.mIdent);
- if (!GetFunctionParseInformation(keyword, aIsPrefixed,
+ if (!GetFunctionParseInformation(keyword,
aDisallowRelativeValues,
minElems, maxElems,
variantMask))
return false;
return ParseFunction(keyword, variantMask, 0, minElems, maxElems, aValue);
}
@@ -16158,29 +16142,29 @@ CSSParserImpl::ParseSingleTransform(bool
* and constructing a matrix from it.
* aProperty can be transform or -moz-window-transform.
* FIXME: For -moz-window-transform, it would be nice to reject non-2d
* transforms at parse time, because the implementation only supports 2d
* transforms. Instead, at the moment, non-2d transforms are treated as the
* identity transform very late in the pipeline.
*/
bool
-CSSParserImpl::ParseTransform(bool aIsPrefixed, nsCSSPropertyID aProperty,
+CSSParserImpl::ParseTransform(nsCSSPropertyID aProperty,
bool aDisallowRelativeValues)
{
nsCSSValue value;
// 'inherit', 'initial', 'unset' and 'none' must be alone
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NONE,
nullptr)) {
nsCSSValueSharedList* list = new nsCSSValueSharedList;
value.SetSharedListValue(list);
list->mHead = new nsCSSValueList;
nsCSSValueList* cur = list->mHead;
for (;;) {
- if (!ParseSingleTransform(aIsPrefixed, aDisallowRelativeValues,
+ if (!ParseSingleTransform(aDisallowRelativeValues,
cur->mValue)) {
return false;
}
if (CheckEndProperty()) {
break;
}
cur->mNext = new nsCSSValueList;
cur = cur->mNext;
--- a/layout/style/nsCSSPropAliasList.h
+++ b/layout/style/nsCSSPropAliasList.h
@@ -39,16 +39,21 @@
******/
CSS_PROP_ALIAS(word-wrap,
word_wrap,
overflow_wrap,
WordWrap,
"")
+CSS_PROP_ALIAS(-moz-transform,
+ _moz_transform,
+ transform,
+ MozTransform,
+ "layout.css.prefixes.transforms")
CSS_PROP_ALIAS(-moz-transform-origin,
_moz_transform_origin,
transform_origin,
MozTransformOrigin,
"layout.css.prefixes.transforms")
CSS_PROP_ALIAS(-moz-perspective-origin,
_moz_perspective_origin,
perspective_origin,
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -4277,25 +4277,16 @@ CSS_PROP_DISPLAY(
CSS_PROPERTY_CREATES_STACKING_CONTEXT |
CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR |
CSS_PROPERTY_FIXPOS_CB,
"",
0,
nullptr,
offsetof(nsStyleDisplay, mSpecifiedTransform),
eStyleAnimType_Custom)
-// This shorthand is essentially an alias, but it requires different
-// parsing rules, and it therefore implemented as a shorthand.
-CSS_PROP_SHORTHAND(
- -moz-transform,
- _moz_transform,
- MozTransform,
- CSS_PROPERTY_PARSE_FUNCTION |
- CSS_PROPERTY_IS_ALIAS,
- "layout.css.prefixes.transforms")
CSS_PROP_DISPLAY(
transform-box,
transform_box,
TransformBox,
CSS_PROPERTY_PARSE_VALUE,
"svg.transform-box.enabled",
VARIANT_HK,
kTransformBoxKTable,
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -2986,23 +2986,16 @@ static const nsCSSPropertyID gPlaceItems
};
static const nsCSSPropertyID gPlaceSelfSubpropTable[] = {
eCSSProperty_align_self,
eCSSProperty_justify_self,
eCSSProperty_UNKNOWN
};
-// Subproperty tables for shorthands that are just aliases with
-// different parsing rules.
-static const nsCSSPropertyID gMozTransformSubpropTable[] = {
- eCSSProperty_transform,
- eCSSProperty_UNKNOWN
-};
-
static const nsCSSPropertyID gOverscrollBehaviorSubpropTable[] = {
eCSSProperty_overscroll_behavior_x,
eCSSProperty_overscroll_behavior_y,
eCSSProperty_UNKNOWN
};
static const nsCSSPropertyID gScrollSnapTypeSubpropTable[] = {
eCSSProperty_scroll_snap_type_x,
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -5400,81 +5400,16 @@ var gCSSProperties = {
subproperties: [ "overflow-wrap" ],
},
"-moz-transform": {
domProp: "MozTransform",
inherited: false,
type: CSS_TYPE_SHORTHAND_AND_LONGHAND,
alias_for: "transform",
subproperties: [ "transform" ],
- // NOTE: We specify other_values & invalid_values explicitly here (instead
- // of deferring to "transform") because we accept some legacy syntax as
- // valid for "-moz-transform" but not for "transform".
- other_values: [ "translatex(1px)", "translatex(4em)",
- "translatex(-4px)", "translatex(3px)",
- "translatex(0px) translatex(1px) translatex(2px) translatex(3px) translatex(4px)",
- "translatey(4em)", "translate(3px)", "translate(10px, -3px)",
- "rotate(45deg)", "rotate(45grad)", "rotate(45rad)",
- "rotate(0.25turn)", "rotate(0)", "scalex(10)", "scaley(10)",
- "scale(10)", "scale(10, 20)", "skewx(30deg)", "skewx(0)",
- "skewy(0)", "skewx(30grad)", "skewx(30rad)", "skewx(0.08turn)",
- "skewy(30deg)", "skewy(30grad)", "skewy(30rad)", "skewy(0.08turn)",
- "rotate(45deg) scale(2, 1)", "skewx(45deg) skewx(-50grad)",
- "translate(0, 0) scale(1, 1) skewx(0) skewy(0) matrix(1, 0, 0, 1, 0, 0)",
- "translatex(50%)", "translatey(50%)", "translate(50%)",
- "translate(3%, 5px)", "translate(5px, 3%)",
- "matrix(1, 2, 3, 4, 5, 6)",
- /* valid calc() values */
- "translatex(calc(5px + 10%))",
- "translatey(calc(0.25 * 5px + 10% / 3))",
- "translate(calc(5px - 10% * 3))",
- "translate(calc(5px - 3 * 10%), 50px)",
- "translate(-50px, calc(5px - 10% * 3))",
- /* valid only when prefixed */
- "matrix(1, 2, 3, 4, 5px, 6%)",
- "matrix(1, 2, 3, 4, 5%, 6px)",
- "matrix(1, 2, 3, 4, 5%, 6%)",
- "matrix(1, 2, 3, 4, 5px, 6em)",
- "matrix(1, 0, 0, 1, calc(5px * 3), calc(10% - 3px))",
- "translatez(1px)", "translatez(4em)", "translatez(-4px)",
- "translatez(0px)", "translatez(2px) translatez(5px)",
- "translate3d(3px, 4px, 5px)", "translate3d(2em, 3px, 1em)",
- "translatex(2px) translate3d(4px, 5px, 6px) translatey(1px)",
- "scale3d(4, 4, 4)", "scale3d(-2, 3, -7)", "scalez(4)",
- "scalez(-6)", "rotate3d(2, 3, 4, 45deg)",
- "rotate3d(-3, 7, 0, 12rad)", "rotatex(15deg)", "rotatey(-12grad)",
- "rotatez(72rad)", "rotatex(0.125turn)",
- "perspective(0px)", "perspective(1000px)",
- "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)",
- /* valid only when prefixed */
- "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13px, 14em, 15px, 16)",
- "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 20%, 10%, 15, 16)",
- ],
- invalid_values: ["1px", "#0000ff", "red", "auto",
- "translatex(1)", "translatey(1)", "translate(2)",
- "translate(-3, -4)",
- "translatex(1px 1px)", "translatex(translatex(1px))",
- "translatex(#0000ff)", "translatex(red)", "translatey()",
- "matrix(1px, 2px, 3px, 4px, 5px, 6px)", "scale(150%)",
- "skewx(red)", "matrix(1%, 0, 0, 0, 0px, 0px)",
- "matrix(0, 1%, 2, 3, 4px,5px)", "matrix(0, 1, 2%, 3, 4px, 5px)",
- "matrix(0, 1, 2, 3%, 4%, 5%)",
- /* invalid calc() values */
- "translatey(-moz-min(5px,10%))",
- "translatex(-moz-max(5px,10%))",
- "translate(10px, calc(min(5px,10%)))",
- "translate(calc(max(5px,10%)), 10%)",
- "matrix(1, 0, 0, 1, max(5px * 3), calc(10% - 3px))",
- "perspective(-10px)", "matrix3d(dinosaur)",
- "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)",
- "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)",
- "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15%, 16)",
- "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16px)",
- "rotatey(words)", "rotatex(7)", "translate3d(3px, 4px, 1px, 7px)",
- ],
},
"-moz-transform-origin": {
domProp: "MozTransformOrigin",
inherited: false,
type: CSS_TYPE_SHORTHAND_AND_LONGHAND,
alias_for: "transform-origin",
subproperties: [ "transform-origin" ],
},
--- a/servo/components/style/properties/declaration_block.rs
+++ b/servo/components/style/properties/declaration_block.rs
@@ -869,31 +869,23 @@ impl PropertyDeclarationBlock {
with_variables: false,
}
}
};
// Substeps 7 and 8
// We need to check the shorthand whether it's an alias property or not.
// If it's an alias property, it should be serialized like its longhand.
- if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) {
- append_serialization::<Cloned<slice::Iter< _>>, _>(
- dest,
- &property,
- value,
- importance,
- &mut is_first_serialization)?;
- } else {
- append_serialization::<Cloned<slice::Iter< _>>, _>(
- dest,
- &shorthand,
- value,
- importance,
- &mut is_first_serialization)?;
- }
+ append_serialization::<Cloned<slice::Iter< _>>, _>(
+ dest,
+ &shorthand,
+ value,
+ importance,
+ &mut is_first_serialization,
+ )?;
for current_longhand in ¤t_longhands {
// Substep 9
already_serialized.insert(current_longhand.id());
}
// FIXME(https://github.com/w3c/csswg-drafts/issues/1774)
// The specification does not include an instruction to abort
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -963,20 +963,17 @@ def set_gecko_property(ffi_name, expr):
}
}
}
</%def>
<%
transform_functions = [
("Matrix3D", "matrix3d", ["number"] * 16),
- ("PrefixedMatrix3D", "matrix3d", ["number"] * 12 + ["lopon"] * 2
- + ["lon"] + ["number"]),
("Matrix", "matrix", ["number"] * 6),
- ("PrefixedMatrix", "matrix", ["number"] * 4 + ["lopon"] * 2),
("Translate", "translate", ["lop", "optional_lop"]),
("Translate3D", "translate3d", ["lop", "lop", "length"]),
("TranslateX", "translatex", ["lop"]),
("TranslateY", "translatey", ["lop"]),
("TranslateZ", "translatez", ["length"]),
("Scale3D", "scale3d", ["number"] * 3),
("Scale", "scale", ["number", "optional_number"]),
("ScaleX", "scalex", ["number"]),
@@ -1022,18 +1019,16 @@ transform_functions = [
# %s substituted with the corresponding variable
css_value_setters = {
"length" : "bindings::Gecko_CSSValue_SetPixelLength(%s, %s.px())",
"percentage" : "bindings::Gecko_CSSValue_SetPercentage(%s, %s.0)",
# Note: This is an integer type, but we use it as a percentage value in Gecko, so
# need to cast it to f32.
"integer_to_percentage" : "bindings::Gecko_CSSValue_SetPercentage(%s, %s as f32)",
"lop" : "%s.set_lop(%s)",
- "lopon" : "set_lopon(%s, %s)",
- "lon" : "set_lon(%s, %s)",
"angle" : "%s.set_angle(%s)",
"number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)",
# Note: We use nsCSSValueSharedList here, instead of nsCSSValueList_heap
# because this function is not called on the main thread and
# nsCSSValueList_heap is not thread safe.
"list" : "%s.set_shared_list(%s.0.iter().map(&convert_to_ns_css_value));",
}
%>
@@ -1101,26 +1096,17 @@ transform_functions = [
post_symbols = "})"
field_names = None
if keyword == "interpolatematrix":
field_names = ["from_list", "to_list", "progress"]
elif keyword == "accumulatematrix":
field_names = ["from_list", "to_list", "count"]
%>
- <%
-
- guard = ""
- if name == "Matrix3D" or name == "Matrix":
- guard = "if !needs_prefix "
- elif name == "PrefixedMatrix3D" or name == "PrefixedMatrix":
- guard = "if needs_prefix "
-
- %>
- structs::nsCSSKeyword::eCSSKeyword_${keyword} ${guard}=> {
+ structs::nsCSSKeyword::eCSSKeyword_${keyword} => {
::values::generics::transform::TransformOperation::${name}${pre_symbols}
% for index, item in enumerate(items):
% if keyword == "matrix3d":
m${index / 4 + 1}${index % 4 + 1}:
% elif keyword == "matrix":
${chr(ord('a') + index)}:
% elif keyword == "interpolatematrix" or keyword == "accumulatematrix":
${field_names[index]}:
@@ -1144,42 +1130,25 @@ transform_functions = [
${post_symbols}
},
</%def>
fn set_single_transform_function(
servo_value: &values::computed::TransformOperation,
gecko_value: &mut structs::nsCSSValue /* output */
) {
- use values::computed::{Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
use values::computed::TransformOperation;
use values::generics::transform::{Matrix, Matrix3D};
let convert_to_ns_css_value = |item: &TransformOperation| -> structs::nsCSSValue {
let mut value = structs::nsCSSValue::null();
set_single_transform_function(item, &mut value);
value
};
- unsafe fn set_lopon(css: &mut structs::nsCSSValue, lopon: LengthOrPercentageOrNumber) {
- let lop = match lopon {
- Either::First(number) => LengthOrPercentage::Length(Length::new(number)),
- Either::Second(lop) => lop,
- };
- css.set_lop(lop);
- }
-
- unsafe fn set_lon(css: &mut structs::nsCSSValue, lopon: LengthOrNumber) {
- let length = match lopon {
- Either::Second(number) => Length::new(number),
- Either::First(l) => l,
- };
- bindings::Gecko_CSSValue_SetPixelLength(css, length.px())
- }
-
unsafe {
match *servo_value {
% for servo, gecko, format in transform_functions:
${transform_function_arm(servo, gecko, format)}
% endfor
}
}
}
@@ -1223,29 +1192,16 @@ fn clone_single_transform_function(
.map(|item| clone_single_transform_function(item))
.collect()
};
let transform_function = unsafe {
bindings::Gecko_CSSValue_GetKeyword(bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 0))
};
- let needs_prefix = if transform_function == structs::nsCSSKeyword::eCSSKeyword_matrix3d {
- unsafe {
- bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 13).mUnit
- != structs::nsCSSUnit::eCSSUnit_Number ||
- bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 14).mUnit
- != structs::nsCSSUnit::eCSSUnit_Number ||
- bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 15).mUnit
- != structs::nsCSSUnit::eCSSUnit_Number
- }
- } else {
- false
- };
-
unsafe {
match transform_function {
% for servo, gecko, format in transform_functions:
${computed_operation_arm(servo, gecko, format)}
% endfor
_ => panic!("unacceptable transform function"),
}
}
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -390,17 +390,17 @@
gecko_pref="layout.css.scroll-snap.enabled",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
animation_value_type="discrete",
allow_empty="NotInitial"
)}
${helpers.predefined_type("transform", "Transform",
"generics::transform::Transform::none()",
- extra_prefixes="webkit",
+ extra_prefixes="webkit moz",
animation_value_type="ComputedValue",
gecko_ffi_name="mSpecifiedTransform",
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
spec="https://drafts.csswg.org/css-transforms/#propdef-transform",
servo_restyle_damage = "reflow_out_of_flow")}
${helpers.predefined_type("rotate", "Rotate",
"generics::transform::Rotate::None",
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -686,24 +686,22 @@ bitflags! {
/// This property requires a stacking context.
const CREATES_STACKING_CONTEXT = 1 << 0;
/// This property has values that can establish a containing block for
/// fixed positioned and absolutely positioned elements.
const FIXPOS_CB = 1 << 1;
/// This property has values that can establish a containing block for
/// absolutely positioned elements.
const ABSPOS_CB = 1 << 2;
- /// This shorthand property is an alias of another property.
- const SHORTHAND_ALIAS_PROPERTY = 1 << 3;
/// This longhand property applies to ::first-letter.
- const APPLIES_TO_FIRST_LETTER = 1 << 4;
+ const APPLIES_TO_FIRST_LETTER = 1 << 3;
/// This longhand property applies to ::first-line.
- const APPLIES_TO_FIRST_LINE = 1 << 5;
+ const APPLIES_TO_FIRST_LINE = 1 << 4;
/// This longhand property applies to ::placeholder.
- const APPLIES_TO_PLACEHOLDER = 1 << 6;
+ const APPLIES_TO_PLACEHOLDER = 1 << 5;
}
}
/// An identifier for a given longhand property.
#[derive(Clone, Copy, Eq, Hash, MallocSizeOf, PartialEq)]
#[repr(u16)]
pub enum LonghandId {
% for i, property in enumerate(data.longhands):
@@ -1685,27 +1683,20 @@ pub struct VariableDeclaration {
impl ToCss for VariableDeclaration {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: fmt::Write,
{
// https://drafts.csswg.org/css-variables/#variables-in-shorthands
match self.value.from_shorthand {
- // Normally, we shouldn't be printing variables here if they came from
- // shorthands. But we should allow properties that came from shorthand
- // aliases. That also matches with the Gecko behavior.
- // FIXME(emilio): This is just a hack for `-moz-transform`.
- Some(shorthand) if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) => {
- dest.write_str(&*self.value.css)?
- }
None => {
dest.write_str(&*self.value.css)?
}
- _ => {},
+ Some(..) => {},
}
Ok(())
}
}
/// A custom property declaration with the property name and the declared value.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, PartialEq)]
@@ -1766,30 +1757,21 @@ impl PropertyDeclaration {
_ => id,
});
PropertyDeclarationId::Longhand(id)
}
fn with_variables_from_shorthand(&self, shorthand: ShorthandId) -> Option< &str> {
match *self {
PropertyDeclaration::WithVariables(ref declaration) => {
- if let Some(s) = declaration.value.from_shorthand {
- if s == shorthand {
- Some(&*declaration.value.css)
- } else { None }
- } else {
- // Normally, longhand property that doesn't come from a shorthand
- // should return None here. But we return Some to longhands if they
- // came from a shorthand alias. Because for example, we should be able to
- // get -moz-transform's value from transform.
- if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) {
- return Some(&*declaration.value.css);
- }
- None
+ let s = declaration.value.from_shorthand?;
+ if s != shorthand {
+ return None;
}
+ Some(&*declaration.value.css)
},
_ => None,
}
}
/// Returns a CSS-wide keyword if the declaration's value is one.
pub fn get_css_wide_keyword(&self) -> Option<CSSWideKeyword> {
match *self {
--- a/servo/components/style/properties/shorthand/box.mako.rs
+++ b/servo/components/style/properties/shorthand/box.mako.rs
@@ -387,17 +387,17 @@ macro_rules! try_parse_one {
</%helpers:shorthand>
<%helpers:shorthand name="overscroll-behavior" products="gecko"
gecko_pref="layout.css.overscroll-behavior.enabled"
sub_properties="overscroll-behavior-x overscroll-behavior-y"
spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties">
pub fn parse_value<'i, 't>(
_: &ParserContext,
- input: &mut Parser<'i, 't>
+ input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
use values::specified::OverscrollBehavior;
let behavior_x = OverscrollBehavior::parse(input)?;
let behavior_y = input.try(OverscrollBehavior::parse).unwrap_or(behavior_x);
Ok(expanded! {
overscroll_behavior_x: behavior_x,
overscroll_behavior_y: behavior_y,
})
@@ -411,23 +411,8 @@ macro_rules! try_parse_one {
if self.overscroll_behavior_y != self.overscroll_behavior_x {
dest.write_str(" ")?;
self.overscroll_behavior_y.to_css(dest)?;
}
Ok(())
}
}
</%helpers:shorthand>
-
-<%helpers:shorthand name="-moz-transform" products="gecko"
- sub_properties="transform"
- gecko_pref="layout.css.prefixes.transforms"
- flags="SHORTHAND_ALIAS_PROPERTY"
- derive_serialize="True"
- spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform">
- pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
- -> Result<Longhands, ParseError<'i>> {
- use values::specified::transform::Transform;
- Ok(expanded! {
- transform: Transform::parse_prefixed(context, input)?,
- })
- }
-</%helpers:shorthand>
--- a/servo/components/style/values/computed/transform.rs
+++ b/servo/components/style/values/computed/transform.rs
@@ -1,39 +1,36 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed types for CSS values that are related to transformations.
use euclid::{Transform3D, Vector3D};
use num_traits::Zero;
-use super::{CSSFloat, Either};
+use super::CSSFloat;
use values::animated::ToAnimatedZero;
use values::computed::{Angle, Integer, Length, LengthOrPercentage, Number, Percentage};
-use values::computed::{LengthOrNumber, LengthOrPercentageOrNumber};
use values::generics::transform::{self, Matrix as GenericMatrix, Matrix3D as GenericMatrix3D};
use values::generics::transform::{Transform as GenericTransform, TransformOperation as GenericTransformOperation};
use values::generics::transform::Rotate as GenericRotate;
use values::generics::transform::Scale as GenericScale;
use values::generics::transform::TimingFunction as GenericTimingFunction;
use values::generics::transform::TransformOrigin as GenericTransformOrigin;
use values::generics::transform::Translate as GenericTranslate;
pub use values::generics::transform::TransformStyle;
/// A single operation in a computed CSS `transform`
pub type TransformOperation = GenericTransformOperation<
Angle,
Number,
Length,
Integer,
- LengthOrNumber,
LengthOrPercentage,
- LengthOrPercentageOrNumber,
>;
/// A computed CSS `transform`
pub type Transform = GenericTransform<TransformOperation>;
/// The computed value of a CSS `<transform-origin>`
pub type TransformOrigin = GenericTransformOrigin<LengthOrPercentage, LengthOrPercentage, Length>;
/// A computed timing function.
@@ -51,22 +48,18 @@ impl TransformOrigin {
LengthOrPercentage::Percentage(Percentage(0.5)),
Length::new(0.),
)
}
}
/// computed value of matrix3d()
pub type Matrix3D = GenericMatrix3D<Number>;
-/// computed value of matrix3d() in -moz-transform
-pub type PrefixedMatrix3D = GenericMatrix3D<Number, LengthOrPercentageOrNumber, LengthOrNumber>;
/// computed value of matrix()
pub type Matrix = GenericMatrix<Number>;
-/// computed value of matrix() in -moz-transform
-pub type PrefixedMatrix = GenericMatrix<Number, LengthOrPercentageOrNumber>;
// we rustfmt_skip here because we want the matrices to look like
// matrices instead of being split across lines
#[cfg_attr(rustfmt, rustfmt_skip)]
impl Matrix3D {
#[inline]
/// Get an identity matrix
pub fn identity() -> Self {
@@ -91,31 +84,16 @@ impl Matrix3D {
})
} else {
Err(())
}
}
}
#[cfg_attr(rustfmt, rustfmt_skip)]
-impl PrefixedMatrix3D {
- #[inline]
- /// Get an identity matrix
- pub fn identity() -> Self {
- Self {
- m11: 1.0, m12: 0.0, m13: 0.0, m14: 0.0,
- m21: 0.0, m22: 1.0, m23: 0.0, m24: 0.0,
- m31: 0.0, m32: 0.0, m33: 1.0, m34: 0.0,
- m41: Either::First(0.), m42: Either::First(0.),
- m43: Either::First(Length::new(0.)), m44: 1.0
- }
- }
-}
-
-#[cfg_attr(rustfmt, rustfmt_skip)]
impl Matrix {
#[inline]
/// Get an identity matrix
pub fn identity() -> Self {
Self {
a: 1., c: 0., /* 0 0*/
b: 0., d: 1., /* 0 0*/
/* 0 0 1 0 */
@@ -132,30 +110,16 @@ impl From<Matrix> for Matrix3D {
m21: m.c, m22: m.d, m23: 0.0, m24: 0.0,
m31: 0.0, m32: 0.0, m33: 1.0, m34: 0.0,
m41: m.e, m42: m.f, m43: 0.0, m44: 1.0
}
}
}
#[cfg_attr(rustfmt, rustfmt_skip)]
-impl PrefixedMatrix {
- #[inline]
- /// Get an identity matrix
- pub fn identity() -> Self {
- Self {
- a: 1., c: 0., /* 0 0 */
- b: 0., d: 1., /* 0 0 */
- /* 0 0 1 0 */
- e: Either::First(0.), f: Either::First(0.), /* 0 1 */
- }
- }
-}
-
-#[cfg_attr(rustfmt, rustfmt_skip)]
impl From<Transform3D<CSSFloat>> for Matrix3D {
#[inline]
fn from(m: Transform3D<CSSFloat>) -> Self {
Matrix3D {
m11: m.m11, m12: m.m12, m13: m.m13, m14: m.m14,
m21: m.m21, m22: m.m22, m23: m.m23, m24: m.m24,
m31: m.m31, m32: m.m32, m33: m.m33, m34: m.m34,
m41: m.m41, m42: m.m42, m43: m.m43, m44: m.m44
@@ -208,27 +172,17 @@ impl TransformOperation {
/// Build an equivalent 'identity transform function list' based
/// on an existing transform list.
/// http://dev.w3.org/csswg/css-transforms/#none-transform-animation
impl ToAnimatedZero for TransformOperation {
fn to_animated_zero(&self) -> Result<Self, ()> {
match *self {
GenericTransformOperation::Matrix3D(..) => Ok(GenericTransformOperation::Matrix3D(Matrix3D::identity())),
- GenericTransformOperation::PrefixedMatrix3D(..) => {
- Ok(GenericTransformOperation::PrefixedMatrix3D(
- PrefixedMatrix3D::identity(),
- ))
- },
GenericTransformOperation::Matrix(..) => Ok(GenericTransformOperation::Matrix(Matrix::identity())),
- GenericTransformOperation::PrefixedMatrix(..) => {
- Ok(GenericTransformOperation::PrefixedMatrix(
- PrefixedMatrix::identity(),
- ))
- },
GenericTransformOperation::Skew(sx, sy) => {
Ok(GenericTransformOperation::Skew(
sx.to_animated_zero()?,
sy.to_animated_zero()?,
))
},
GenericTransformOperation::SkewX(s) => Ok(GenericTransformOperation::SkewX(s.to_animated_zero()?)),
GenericTransformOperation::SkewY(s) => Ok(GenericTransformOperation::SkewY(s.to_animated_zero()?)),
--- a/servo/components/style/values/generics/transform.rs
+++ b/servo/components/style/values/generics/transform.rs
@@ -14,34 +14,34 @@ use values::computed::length::Length as
use values::computed::length::LengthOrPercentage as ComputedLengthOrPercentage;
use values::specified::length::Length as SpecifiedLength;
use values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage;
/// A generic 2D transformation matrix.
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
#[css(comma, function)]
-pub struct Matrix<T, U = T> {
+pub struct Matrix<T> {
pub a: T,
pub b: T,
pub c: T,
pub d: T,
- pub e: U,
- pub f: U,
+ pub e: T,
+ pub f: T,
}
#[allow(missing_docs)]
#[cfg_attr(rustfmt, rustfmt_skip)]
#[css(comma, function = "matrix3d")]
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
-pub struct Matrix3D<T, U = T, V = T> {
+pub struct Matrix3D<T> {
pub m11: T, pub m12: T, pub m13: T, pub m14: T,
pub m21: T, pub m22: T, pub m23: T, pub m24: T,
pub m31: T, pub m32: T, pub m33: T, pub m34: T,
- pub m41: U, pub m42: U, pub m43: V, pub m44: T,
+ pub m41: T, pub m42: T, pub m43: T, pub m44: T,
}
#[cfg_attr(rustfmt, rustfmt_skip)]
impl<T: Into<f64>> From<Matrix<T>> for Transform3D<f64> {
#[inline]
fn from(m: Matrix<T>) -> Self {
Transform3D::row_major(
m.a.into(), m.b.into(), 0.0, 0.0,
@@ -195,27 +195,21 @@ impl TimingKeyword {
TimingKeyword::EaseOut => (0., 0., 0.58, 1.),
TimingKeyword::EaseInOut => (0.42, 0., 0.58, 1.),
}
}
}
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
/// A single operation in the list of a `transform` value
-pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, LengthOrPercentage, LoPoNumber> {
+pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage> {
/// Represents a 2D 2x3 matrix.
Matrix(Matrix<Number>),
- /// Represents a 3D 4x4 matrix with percentage and length values.
- /// For `moz-transform`.
- PrefixedMatrix(Matrix<Number, LoPoNumber>),
/// Represents a 3D 4x4 matrix.
Matrix3D(Matrix3D<Number>),
- /// Represents a 3D 4x4 matrix with percentage and length values.
- /// For `moz-transform`.
- PrefixedMatrix3D(Matrix3D<Number, LoPoNumber, LengthOrNumber>),
/// A 2D skew.
///
/// If the second angle is not provided it is assumed zero.
///
/// Syntax can be skew(angle) or skew(angle, angle)
#[css(comma, function)]
Skew(Angle, Option<Angle>),
/// skewX(angle)
@@ -295,32 +289,28 @@ pub enum TransformOperation<Angle, Numbe
#[compute(ignore_bound)]
#[css(ignore_bound)]
from_list: Transform<
TransformOperation<
Angle,
Number,
Length,
Integer,
- LengthOrNumber,
LengthOrPercentage,
- LoPoNumber,
>,
>,
#[compute(ignore_bound)]
#[css(ignore_bound)]
to_list: Transform<
TransformOperation<
Angle,
Number,
Length,
Integer,
- LengthOrNumber,
LengthOrPercentage,
- LoPoNumber,
>,
>,
#[compute(clone)]
progress: computed::Percentage,
},
/// A intermediate type for accumulation of mismatched transform lists.
#[allow(missing_docs)]
#[css(comma, function = "accumulatematrix")]
@@ -328,45 +318,41 @@ pub enum TransformOperation<Angle, Numbe
#[compute(ignore_bound)]
#[css(ignore_bound)]
from_list: Transform<
TransformOperation<
Angle,
Number,
Length,
Integer,
- LengthOrNumber,
LengthOrPercentage,
- LoPoNumber,
>,
>,
#[compute(ignore_bound)]
#[css(ignore_bound)]
to_list: Transform<
TransformOperation<
Angle,
Number,
Length,
Integer,
- LengthOrNumber,
LengthOrPercentage,
- LoPoNumber,
>,
>,
count: Integer,
},
}
#[derive(Animate, ToComputedValue)]
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
/// A value of the `transform` property
pub struct Transform<T>(pub Vec<T>);
-impl<Angle, Number, Length, Integer, LengthOrNumber, LengthOrPercentage, LoPoNumber>
- TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, LengthOrPercentage, LoPoNumber> {
+impl<Angle, Number, Length, Integer, LengthOrPercentage>
+ TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage> {
/// Check if it is any translate function
pub fn is_translate(&self) -> bool {
use self::TransformOperation::*;
match *self {
Translate(..) | Translate3D(..) | TranslateX(..) | TranslateY(..) | TranslateZ(..) => true,
_ => false,
}
}
@@ -445,32 +431,31 @@ impl ToAbsoluteLength for ComputedLength
pub trait ToMatrix {
/// Check if it is a 3d transform function.
fn is_3d(&self) -> bool;
/// Return the equivalent 3d matrix.
fn to_3d_matrix(&self, reference_box: Option<&Rect<Au>>) -> Result<Transform3D<f64>, ()>;
}
-impl<Angle, Number, Length, Integer, LoN, LoP, LoPoNumber> ToMatrix
- for TransformOperation<Angle, Number, Length, Integer, LoN, LoP, LoPoNumber>
+impl<Angle, Number, Length, Integer, LoP> ToMatrix
+ for TransformOperation<Angle, Number, Length, Integer, LoP>
where
Angle: Copy + AsRef<computed::angle::Angle>,
Number: Copy + Into<f32> + Into<f64>,
Length: ToAbsoluteLength,
LoP: ToAbsoluteLength,
{
#[inline]
fn is_3d(&self) -> bool {
use self::TransformOperation::*;
match *self {
Translate3D(..) | TranslateZ(..) |
Rotate3D(..) | RotateX(..) | RotateY(..) | RotateZ(..) |
- Scale3D(..) | ScaleZ(..) |
- Perspective(..) | Matrix3D(..) | PrefixedMatrix3D(..) => true,
+ Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true,
_ => false,
}
}
/// If |reference_box| is None, we will drop the percent part from translate because
/// we cannot resolve it without the layout info, for computed TransformOperation.
/// However, for specified TransformOperation, we will return Err(()) if there is any relative
/// lengths because the only caller, DOMMatrix, doesn't accept relative lengths.
@@ -548,20 +533,16 @@ where
SkewY(theta) => {
Transform3D::create_skew(
euclid::Angle::radians(0.),
euclid::Angle::radians(theta.as_ref().radians64()),
)
},
Matrix3D(m) => m.into(),
Matrix(m) => m.into(),
- PrefixedMatrix3D(_) | PrefixedMatrix(_) => {
- unreachable!("-moz-transform` is not implemented in Servo yet, and DOMMatrix \
- doesn't support this")
- },
InterpolateMatrix { .. } | AccumulateMatrix { .. } => {
// TODO: Convert InterpolateMatrix/AccumulateMatrix into a valid Transform3D by
// the reference box and do interpolation on these two Transform3D matrices.
// Both Gecko and Servo don't support this for computing distance, and Servo
// doesn't support animations on InterpolateMatrix/AccumulateMatrix, so
// return an identity matrix.
// Note: DOMMatrix doesn't go into this arm.
Transform3D::identity()
--- a/servo/components/style/values/specified/transform.rs
+++ b/servo/components/style/values/specified/transform.rs
@@ -13,48 +13,44 @@ use values::computed::{Percentage as Com
use values::computed::transform::TimingFunction as ComputedTimingFunction;
use values::generics::transform::{Matrix3D, Transform as GenericTransform};
use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction, Matrix};
use values::generics::transform::{TimingKeyword, TransformOrigin as GenericTransformOrigin};
use values::generics::transform::Rotate as GenericRotate;
use values::generics::transform::Scale as GenericScale;
use values::generics::transform::TransformOperation as GenericTransformOperation;
use values::generics::transform::Translate as GenericTranslate;
-use values::specified::{self, Angle, Number, Length, Integer};
-use values::specified::{LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
+use values::specified::{self, Angle, Number, Length, Integer, LengthOrPercentage};
use values::specified::position::{Side, X, Y};
pub use values::generics::transform::TransformStyle;
/// A single operation in a specified CSS `transform`
pub type TransformOperation = GenericTransformOperation<
Angle,
Number,
Length,
Integer,
- LengthOrNumber,
LengthOrPercentage,
- LengthOrPercentageOrNumber,
>;
/// A specified CSS `transform`
pub type Transform = GenericTransform<TransformOperation>;
/// The specified value of a CSS `<transform-origin>`
pub type TransformOrigin = GenericTransformOrigin<OriginComponent<X>, OriginComponent<Y>, Length>;
impl Transform {
/// Internal parse function for deciding if we wish to accept prefixed values or not
///
/// `transform` allows unitless zero angles as an exception, see:
/// https://github.com/w3c/csswg-drafts/issues/1162
fn parse_internal<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
- prefixed: bool,
) -> Result<Self, ParseError<'i>> {
use style_traits::{Separator, Space};
if input
.try(|input| input.expect_ident_matching("none"))
.is_ok()
{
return Ok(GenericTransform(Vec::new()));
@@ -70,29 +66,21 @@ impl Transform {
let a = Number::parse(context, input)?;
input.expect_comma()?;
let b = Number::parse(context, input)?;
input.expect_comma()?;
let c = Number::parse(context, input)?;
input.expect_comma()?;
let d = Number::parse(context, input)?;
input.expect_comma()?;
- if !prefixed {
- // Standard matrix parsing.
- let e = Number::parse(context, input)?;
- input.expect_comma()?;
- let f = Number::parse(context, input)?;
- Ok(GenericTransformOperation::Matrix(Matrix { a, b, c, d, e, f }))
- } else {
- // Non-standard prefixed matrix parsing for -moz-transform.
- let e = LengthOrPercentageOrNumber::parse(context, input)?;
- input.expect_comma()?;
- let f = LengthOrPercentageOrNumber::parse(context, input)?;
- Ok(GenericTransformOperation::PrefixedMatrix(Matrix { a, b, c, d, e, f }))
- }
+ // Standard matrix parsing.
+ let e = Number::parse(context, input)?;
+ input.expect_comma()?;
+ let f = Number::parse(context, input)?;
+ Ok(GenericTransformOperation::Matrix(Matrix { a, b, c, d, e, f }))
},
"matrix3d" => {
let m11 = Number::parse(context, input)?;
input.expect_comma()?;
let m12 = Number::parse(context, input)?;
input.expect_comma()?;
let m13 = Number::parse(context, input)?;
input.expect_comma()?;
@@ -109,47 +97,30 @@ impl Transform {
let m31 = Number::parse(context, input)?;
input.expect_comma()?;
let m32 = Number::parse(context, input)?;
input.expect_comma()?;
let m33 = Number::parse(context, input)?;
input.expect_comma()?;
let m34 = Number::parse(context, input)?;
input.expect_comma()?;
- if !prefixed {
- // Standard matrix3d parsing.
- let m41 = Number::parse(context, input)?;
- input.expect_comma()?;
- let m42 = Number::parse(context, input)?;
- input.expect_comma()?;
- let m43 = Number::parse(context, input)?;
- input.expect_comma()?;
- let m44 = Number::parse(context, input)?;
- Ok(GenericTransformOperation::Matrix3D(Matrix3D {
- m11, m12, m13, m14,
- m21, m22, m23, m24,
- m31, m32, m33, m34,
- m41, m42, m43, m44,
- }))
- } else {
- // Non-standard prefixed matrix parsing for -moz-transform.
- let m41 = LengthOrPercentageOrNumber::parse(context, input)?;
- input.expect_comma()?;
- let m42 = LengthOrPercentageOrNumber::parse(context, input)?;
- input.expect_comma()?;
- let m43 = LengthOrNumber::parse(context, input)?;
- input.expect_comma()?;
- let m44 = Number::parse(context, input)?;
- Ok(GenericTransformOperation::PrefixedMatrix3D(Matrix3D {
- m11, m12, m13, m14,
- m21, m22, m23, m24,
- m31, m32, m33, m34,
- m41, m42, m43, m44,
- }))
- }
+ // Standard matrix3d parsing.
+ let m41 = Number::parse(context, input)?;
+ input.expect_comma()?;
+ let m42 = Number::parse(context, input)?;
+ input.expect_comma()?;
+ let m43 = Number::parse(context, input)?;
+ input.expect_comma()?;
+ let m44 = Number::parse(context, input)?;
+ Ok(GenericTransformOperation::Matrix3D(Matrix3D {
+ m11, m12, m13, m14,
+ m21, m22, m23, m24,
+ m31, m32, m33, m34,
+ m41, m42, m43, m44,
+ }))
},
"translate" => {
let sx = specified::LengthOrPercentage::parse(context, input)?;
if input.try(|input| input.expect_comma()).is_ok() {
let sy = specified::LengthOrPercentage::parse(context, input)?;
Ok(GenericTransformOperation::Translate(sx, Some(sy)))
} else {
Ok(GenericTransformOperation::Translate(sx, None))
@@ -254,34 +225,24 @@ impl Transform {
},
_ => Err(()),
};
result
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone())))
})
})?))
}
-
- /// Parses `-moz-transform` property. This prefixed property also accepts LengthOrPercentage
- /// in the nondiagonal homogeneous components of matrix and matrix3d.
- #[inline]
- pub fn parse_prefixed<'i, 't>(
- context: &ParserContext,
- input: &mut Parser<'i, 't>,
- ) -> Result<Self, ParseError<'i>> {
- Transform::parse_internal(context, input, true)
- }
}
impl Parse for Transform {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>> {
- Transform::parse_internal(context, input, false)
+ Transform::parse_internal(context, input)
}
}
/// The specified value of a component of a CSS `<transform-origin>`.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
pub enum OriginComponent<S> {
/// `center`
Center,