Changeset 291597 in webkit
- Timestamp:
- Mar 21, 2022 8:22:44 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 28 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/arithmetic.tentative-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (2 diffs)
-
Source/WebCore/bindings/js/JSCSSStyleValueCustom.cpp (modified) (3 diffs)
-
Source/WebCore/css/typedom/CSSKeywordValue.h (modified) (1 diff)
-
Source/WebCore/css/typedom/CSSNumericValue.cpp (modified) (3 diffs)
-
Source/WebCore/css/typedom/CSSNumericValue.h (modified) (3 diffs)
-
Source/WebCore/css/typedom/CSSStyleValue.h (modified) (1 diff)
-
Source/WebCore/css/typedom/CSSUnitValue.h (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSMathInvert.cpp (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSMathInvert.h (modified) (2 diffs)
-
Source/WebCore/css/typedom/numeric/CSSMathMax.cpp (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSMathMax.h (modified) (2 diffs)
-
Source/WebCore/css/typedom/numeric/CSSMathMin.cpp (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSMathMin.h (modified) (2 diffs)
-
Source/WebCore/css/typedom/numeric/CSSMathNegate.cpp (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSMathNegate.h (modified) (2 diffs)
-
Source/WebCore/css/typedom/numeric/CSSMathProduct.cpp (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSMathProduct.h (modified) (2 diffs)
-
Source/WebCore/css/typedom/numeric/CSSMathSum.cpp (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSMathSum.h (modified) (2 diffs)
-
Source/WebCore/css/typedom/numeric/CSSMathValue.cpp (deleted)
-
Source/WebCore/css/typedom/numeric/CSSMathValue.h (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSNumericArray.cpp (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSNumericArray.h (modified) (1 diff)
-
Source/WebCore/css/typedom/numeric/CSSNumericType.h (modified) (1 diff)
-
Source/WebCore/css/typedom/transform/CSSTransformValue.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r291594 r291597 1 2022-03-21 Alex Christensen <achristensen@webkit.org> 2 3 Implement CSSNumericValue.mul, div, add, sub, max, and min 4 https://bugs.webkit.org/show_bug.cgi?id=238153 5 6 Reviewed by Simon Fraser. 7 8 * web-platform-tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/arithmetic.tentative-expected.txt: 9 1 10 2022-03-21 Oriol Brufau <obrufau@igalia.com> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/arithmetic.tentative-expected.txt
r282356 r291597 2 2 PASS Calling CSSUnitValue.add with no arguments returns itself 3 3 PASS Calling CSSMathValue.add with no arguments returns itself 4 FAIL Calling CSSNumericValue.add with a single CSSNumericValue returns correct type assert_equals: expected "CSSMathSum" but got "CSSUnitValue" 4 PASS Calling CSSNumericValue.add with a single CSSNumericValue returns correct type 5 5 PASS Calling CSSMathValue.add with a single CSSNumericValue returns correct type 6 FAIL Calling CSSNumericValue.add with more than one number CSSNumericValues returns correct type assert_equals: expected "CSSMathSum" but got "CSSUnitValue" 6 PASS Calling CSSNumericValue.add with more than one number CSSNumericValues returns correct type 7 7 PASS Calling CSSNumericValue.add can take numberish values 8 FAIL Calling CSSMathSum.add with number CSSUnitValues simplifies to a CSSUnitValue assert_equals: expected "CSSUnitValue" but got "CSSMathSum" 8 PASS Calling CSSMathSum.add with number CSSUnitValues simplifies to a CSSUnitValue 9 9 PASS Calling CSSNumericValue.add with incompatible types throws TypeError 10 10 PASS Calling CSSUnitValue.sub with no arguments returns itself 11 11 PASS Calling CSSMathValue.sub with no arguments returns itself 12 FAIL Calling CSSNumericValue.sub with a single CSSNumericValue returns correct type assert_equals: expected "CSSMathSum" but got "CSSUnitValue" 12 PASS Calling CSSNumericValue.sub with a single CSSNumericValue returns correct type 13 13 PASS Calling CSSMathValue.sub with a single CSSNumericValue returns correct type 14 FAIL Calling CSSNumericValue.sub with more than one number CSSNumericValues returns correct type assert_equals: expected "CSSMathSum" but got "CSSUnitValue" 14 PASS Calling CSSNumericValue.sub with more than one number CSSNumericValues returns correct type 15 15 PASS Calling CSSNumericValue.sub can take numberish values 16 FAIL Calling CSSMathSum.sub with number CSSUnitValues simplifies to a CSSUnitValue assert_equals: expected "CSSUnitValue" but got "CSSMathSum" 16 PASS Calling CSSMathSum.sub with number CSSUnitValues simplifies to a CSSUnitValue 17 17 PASS Calling CSSNumericValue.sub with incompatible types throws TypeError 18 18 PASS Calling CSSUnitValue.mul with no arguments returns itself 19 19 PASS Calling CSSMathValue.mul with no arguments returns itself 20 FAIL Calling CSSNumericValue.mul with a single CSSNumericValue returns correct type assert_equals: expected "CSSMathProduct" but got "CSSUnitValue" 20 PASS Calling CSSNumericValue.mul with a single CSSNumericValue returns correct type 21 21 PASS Calling CSSMathValue.mul with a single CSSNumericValue returns correct type 22 FAIL Calling CSSNumericValue.mul with more than one number CSSNumericValues returns correct type assert_equals: expected "CSSMathProduct" but got "CSSUnitValue" 22 PASS Calling CSSNumericValue.mul with more than one number CSSNumericValues returns correct type 23 23 PASS Calling CSSNumericValue.mul can take numberish values 24 FAIL Calling CSSMathProduct.mul with number CSSUnitValues simplifies to a CSSUnitValue assert_equals: expected "CSSUnitValue" but got "CSSMathProduct" 24 PASS Calling CSSMathProduct.mul with number CSSUnitValues simplifies to a CSSUnitValue 25 25 PASS Calling CSSNumericValue.mul with incompatible types throws TypeError 26 26 PASS Calling CSSUnitValue.div with no arguments returns itself 27 27 PASS Calling CSSMathValue.div with no arguments returns itself 28 FAIL Calling CSSNumericValue.div with a single CSSNumericValue returns correct type assert_equals: expected "CSSMathProduct" but got "CSSUnitValue" 28 PASS Calling CSSNumericValue.div with a single CSSNumericValue returns correct type 29 29 PASS Calling CSSMathValue.div with a single CSSNumericValue returns correct type 30 FAIL Calling CSSNumericValue.div with more than one number CSSNumericValues returns correct type assert_equals: expected "CSSMathProduct" but got "CSSUnitValue" 30 PASS Calling CSSNumericValue.div with more than one number CSSNumericValues returns correct type 31 31 PASS Calling CSSNumericValue.div can take numberish values 32 FAIL Calling CSSMathProduct.div with number CSSUnitValues simplifies to a CSSUnitValue assert_equals: expected "CSSUnitValue" but got "CSSMathProduct" 32 PASS Calling CSSMathProduct.div with number CSSUnitValues simplifies to a CSSUnitValue 33 33 PASS Calling CSSNumericValue.div with incompatible types throws TypeError 34 34 PASS Calling CSSUnitValue.min with no arguments returns itself 35 35 PASS Calling CSSMathValue.min with no arguments returns itself 36 FAIL Calling CSSNumericValue.min with a single CSSNumericValue returns correct type assert_equals: expected "CSSMathMin" but got "CSSUnitValue" 36 PASS Calling CSSNumericValue.min with a single CSSNumericValue returns correct type 37 37 PASS Calling CSSMathValue.min with a single CSSNumericValue returns correct type 38 FAIL Calling CSSNumericValue.min with more than one number CSSNumericValues returns correct type assert_equals: expected "CSSMathMin" but got "CSSUnitValue" 38 PASS Calling CSSNumericValue.min with more than one number CSSNumericValues returns correct type 39 39 PASS Calling CSSNumericValue.min can take numberish values 40 FAIL Calling CSSMathMin.min with number CSSUnitValues simplifies to a CSSUnitValue assert_equals: expected "CSSUnitValue" but got "CSSMathMin" 40 PASS Calling CSSMathMin.min with number CSSUnitValues simplifies to a CSSUnitValue 41 41 PASS Calling CSSNumericValue.min with incompatible types throws TypeError 42 42 PASS Calling CSSUnitValue.max with no arguments returns itself 43 43 PASS Calling CSSMathValue.max with no arguments returns itself 44 FAIL Calling CSSNumericValue.max with a single CSSNumericValue returns correct type assert_equals: expected "CSSMathMax" but got "CSSUnitValue" 44 PASS Calling CSSNumericValue.max with a single CSSNumericValue returns correct type 45 45 PASS Calling CSSMathValue.max with a single CSSNumericValue returns correct type 46 FAIL Calling CSSNumericValue.max with more than one number CSSNumericValues returns correct type assert_equals: expected "CSSMathMax" but got "CSSUnitValue" 46 PASS Calling CSSNumericValue.max with more than one number CSSNumericValues returns correct type 47 47 PASS Calling CSSNumericValue.max can take numberish values 48 FAIL Calling CSSMathMax.max with number CSSUnitValues simplifies to a CSSUnitValue assert_equals: expected "CSSUnitValue" but got "CSSMathMax" 48 PASS Calling CSSMathMax.max with number CSSUnitValues simplifies to a CSSUnitValue 49 49 PASS Calling CSSNumericValue.max with incompatible types throws TypeError 50 FAIL Calling CSSUnitValue.add with CSSUnitValues with same unit simplifies to a CSSUnitValue assert_equals: expected 17 but got 10 51 FAIL Calling CSSUnitValue.sub with CSSUnitValues with same unit simplifies to a CSSUnitValue assert_equals: expected 3 but got 10 52 FAIL Calling CSSUnitValue.mul with all numbers simplifies to a CSSUnitValue assert_equals: expected 100 but got 10 53 FAIL Calling CSSUnitValue.mul with only one non-number simplifies to a CSSUnitValue assert_equals: expected 100 but got 10 54 FAIL Calling CSSUnitValue.mul with more than one non-number does not simplify to a CSSUnitValue assert_equals: expected "CSSMathProduct" but got "CSSUnitValue" 55 FAIL Calling CSSUnitValue.div with all numbers simplifies to a CSSUnitValue assert_equals: expected 1 but got 10 56 FAIL Calling CSSUnitValue.div on a non-number value simplifies to a CSSUnitValue assert_equals: expected 1 but got 10 57 FAIL Calling CSSUnitValue.div with a non-number value in the arguments does not simplify to a CSSUnitValue assert_equals: expected "CSSMathProduct" but got "CSSUnitValue" 58 FAIL Calling CSSUnitValue.min with CSSUnitValues with same unit simplifies to a CSSUnitValue assert_equals: expected 2 but got 10 50 PASS Calling CSSUnitValue.add with CSSUnitValues with same unit simplifies to a CSSUnitValue 51 PASS Calling CSSUnitValue.sub with CSSUnitValues with same unit simplifies to a CSSUnitValue 52 PASS Calling CSSUnitValue.mul with all numbers simplifies to a CSSUnitValue 53 PASS Calling CSSUnitValue.mul with only one non-number simplifies to a CSSUnitValue 54 PASS Calling CSSUnitValue.mul with more than one non-number does not simplify to a CSSUnitValue 55 PASS Calling CSSUnitValue.div with all numbers simplifies to a CSSUnitValue 56 PASS Calling CSSUnitValue.div on a non-number value simplifies to a CSSUnitValue 57 PASS Calling CSSUnitValue.div with a non-number value in the arguments does not simplify to a CSSUnitValue 58 PASS Calling CSSUnitValue.min with CSSUnitValues with same unit simplifies to a CSSUnitValue 59 59 PASS Calling CSSUnitValue.max with CSSUnitValues with same unit simplifies to a CSSUnitValue 60 FAIL Calling CSSNumericValue.sub negates all argument values assert_equals: expected "CSSMathSum" but got "CSSUnitValue" 61 FAIL Calling CSSNumericValue.div inverts all argument values assert_equals: expected "CSSMathProduct" but got "CSSUnitValue" 62 FAIL Can not divide with CSSUnitValue which has zero value and number type assert_throws_js: function "() => CSS.number(2).div(CSS.number(0))" did not throw 60 PASS Calling CSSNumericValue.sub negates all argument values 61 PASS Calling CSSNumericValue.div inverts all argument values 62 PASS Can not divide with CSSUnitValue which has zero value and number type 63 63 FAIL CSSNumericValue.add should throw TypeError when the types are different. assert_throws_js: function "() => CSS.number(3).add(CSS.px(10) ,CSS.number(0))" did not throw 64 64 FAIL CSSNumericValue.sub should throw TypeError when the types are different. assert_throws_js: function "() => CSS.number(3).sub(CSS.px(10) ,CSS.number(0))" did not throw -
trunk/Source/WebCore/ChangeLog
r291594 r291597 1 2022-03-21 Alex Christensen <achristensen@webkit.org> 2 3 Implement CSSNumericValue.mul, div, add, sub, max, and min 4 https://bugs.webkit.org/show_bug.cgi?id=238153 5 6 Reviewed by Simon Fraser. 7 8 This implements all except the derived units of multiplication and the unit checking of the others. 9 They are an off-by-default experimental feature right now, part of css-typed-om which is being implemented. 10 They are covered by wpt tests. 11 12 * Sources.txt: 13 * WebCore.xcodeproj/project.pbxproj: 14 * bindings/js/JSCSSStyleValueCustom.cpp: 15 (WebCore::toJSNewlyCreated): 16 * css/typedom/CSSKeywordValue.h: 17 (WebCore::CSSKeywordValue::value const): Deleted. 18 (WebCore::CSSKeywordValue::CSSKeywordValue): Deleted. 19 * css/typedom/CSSNumericValue.cpp: 20 (WebCore::negate): 21 (WebCore::invert): 22 (WebCore::operationOnValuesOfSameUnit): 23 (WebCore::CSSNumericValue::prependItemsOfTypeOrThis): 24 (WebCore::CSSNumericValue::addInternal): 25 (WebCore::CSSNumericValue::add): 26 (WebCore::CSSNumericValue::sub): 27 (WebCore::CSSNumericValue::multiplyInternal): 28 (WebCore::CSSNumericValue::mul): 29 (WebCore::CSSNumericValue::div): 30 (WebCore::CSSNumericValue::min): 31 (WebCore::CSSNumericValue::max): 32 (WebCore::CSSNumericValue::rectifyNumberish): 33 (WebCore::CSSNumericValue::toSum): 34 * css/typedom/CSSNumericValue.h: 35 (isType): 36 * css/typedom/CSSStyleValue.h: 37 (WebCore::isCSSNumericValue): 38 (WebCore::isCSSMathValue): 39 * css/typedom/CSSUnitValue.h: 40 (isType): 41 * css/typedom/numeric/CSSMathInvert.cpp: 42 (WebCore::CSSMathInvert::CSSMathInvert): 43 * css/typedom/numeric/CSSMathInvert.h: 44 (isType): 45 (WebCore::CSSMathInvert::value const): Deleted. 46 * css/typedom/numeric/CSSMathMax.cpp: 47 (WebCore::CSSMathMax::CSSMathMax): 48 (WebCore::CSSMathMax::create): Deleted. 49 * css/typedom/numeric/CSSMathMax.h: 50 (isType): 51 * css/typedom/numeric/CSSMathMin.cpp: 52 (WebCore::CSSMathMin::CSSMathMin): 53 (WebCore::CSSMathMin::create): Deleted. 54 * css/typedom/numeric/CSSMathMin.h: 55 (isType): 56 * css/typedom/numeric/CSSMathNegate.cpp: 57 (WebCore::CSSMathNegate::CSSMathNegate): 58 (WebCore::CSSMathNegate::create): Deleted. 59 * css/typedom/numeric/CSSMathNegate.h: 60 (isType): 61 (WebCore::CSSMathNegate::value const): Deleted. 62 * css/typedom/numeric/CSSMathProduct.cpp: 63 (WebCore::CSSMathProduct::CSSMathProduct): 64 (WebCore::CSSMathProduct::create): Deleted. 65 * css/typedom/numeric/CSSMathProduct.h: 66 (isType): 67 * css/typedom/numeric/CSSMathSum.cpp: 68 (WebCore::CSSMathSum::CSSMathSum): 69 (WebCore::CSSMathSum::create): Deleted. 70 (WebCore::CSSMathSum::values const): Deleted. 71 * css/typedom/numeric/CSSMathSum.h: 72 (isType): 73 * css/typedom/numeric/CSSMathValue.cpp: Removed. 74 * css/typedom/numeric/CSSMathValue.h: 75 (WebCore::CSSMathValue::getOperator const): Deleted. 76 (): Deleted. 77 (isType): Deleted. 78 * css/typedom/numeric/CSSNumericArray.cpp: 79 (WebCore::CSSNumericArray::create): 80 (WebCore::CSSNumericArray::CSSNumericArray): 81 * css/typedom/numeric/CSSNumericArray.h: 82 (WebCore::CSSNumericArray::array const): 83 * css/typedom/numeric/CSSNumericType.h: 84 * css/typedom/transform/CSSTransformValue.h: 85 (WebCore::CSSTransformValue::length const): Deleted. 86 1 87 2022-03-21 Oriol Brufau <obrufau@igalia.com> 2 88 -
trunk/Source/WebCore/Sources.txt
r291364 r291597 869 869 css/typedom/numeric/CSSMathProduct.cpp 870 870 css/typedom/numeric/CSSMathSum.cpp 871 css/typedom/numeric/CSSMathValue.cpp872 871 css/typedom/numeric/CSSNumericArray.cpp 873 872 css/typedom/transform/CSSMatrixComponent.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r291589 r291597 8035 8035 2AEF6FE426E802F000326D02 /* CSSMathProduct.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSMathProduct.cpp; sourceTree = "<group>"; }; 8036 8036 2AEF6FE526E802F100326D02 /* CSSMathSum.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSMathSum.cpp; sourceTree = "<group>"; }; 8037 2AEF6FE626E802F100326D02 /* CSSMathValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSMathValue.cpp; sourceTree = "<group>"; };8038 8037 2B42359F15250F6000DBBCD8 /* RenderSVGEllipse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGEllipse.cpp; sourceTree = "<group>"; }; 8039 8038 2B4235A015250F6000DBBCD8 /* RenderSVGEllipse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGEllipse.h; sourceTree = "<group>"; }; … … 20789 20788 2AEF6FC126E716EE00326D02 /* CSSMathSum.h */, 20790 20789 2AEF6FC326E716EE00326D02 /* CSSMathSum.idl */, 20791 2AEF6FE626E802F100326D02 /* CSSMathValue.cpp */,20792 20790 2AEF6FC726E716EE00326D02 /* CSSMathValue.h */, 20793 20791 2AEF6FBE26E716EE00326D02 /* CSSMathValue.idl */, -
trunk/Source/WebCore/bindings/js/JSCSSStyleValueCustom.cpp
r289219 r291597 30 30 31 31 #include "JSCSSKeywordValue.h" 32 #include "JSCSSMathInvert.h" 33 #include "JSCSSMathMax.h" 34 #include "JSCSSMathMin.h" 35 #include "JSCSSMathNegate.h" 36 #include "JSCSSMathProduct.h" 37 #include "JSCSSMathSum.h" 32 38 #include "JSCSSMathValue.h" 33 39 #include "JSCSSNumericValue.h" 34 40 #include "JSCSSStyleImageValue.h" 41 #include "JSCSSTransformValue.h" 35 42 #include "JSCSSUnitValue.h" 36 43 #include "JSCSSUnparsedValue.h" … … 47 54 case CSSStyleValueType::CSSNumericValue: 48 55 return createWrapper<CSSNumericValue>(globalObject, WTFMove(value)); 49 case CSSStyleValueType::CSSMathValue: 50 return createWrapper<CSSMathValue>(globalObject, WTFMove(value)); 56 case CSSStyleValueType::CSSMathInvert: 57 return createWrapper<CSSMathInvert>(globalObject, WTFMove(value)); 58 case CSSStyleValueType::CSSMathMin: 59 return createWrapper<CSSMathMin>(globalObject, WTFMove(value)); 60 case CSSStyleValueType::CSSMathMax: 61 return createWrapper<CSSMathMax>(globalObject, WTFMove(value)); 62 case CSSStyleValueType::CSSMathNegate: 63 return createWrapper<CSSMathNegate>(globalObject, WTFMove(value)); 64 case CSSStyleValueType::CSSMathProduct: 65 return createWrapper<CSSMathProduct>(globalObject, WTFMove(value)); 66 case CSSStyleValueType::CSSMathSum: 67 return createWrapper<CSSMathSum>(globalObject, WTFMove(value)); 51 68 case CSSStyleValueType::CSSUnitValue: 52 69 return createWrapper<CSSUnitValue>(globalObject, WTFMove(value)); … … 56 73 return createWrapper<CSSKeywordValue>(globalObject, WTFMove(value)); 57 74 case CSSStyleValueType::CSSTransformValue: 75 return createWrapper<CSSTransformValue>(globalObject, WTFMove(value)); 58 76 case CSSStyleValueType::CSSStyleValue: 59 77 return createWrapper<CSSStyleValue>(globalObject, WTFMove(value)); -
trunk/Source/WebCore/css/typedom/CSSKeywordValue.h
r282706 r291597 36 36 template<typename> class ExceptionOr; 37 37 38 class CSSKeywordValue : public CSSStyleValue {38 class CSSKeywordValue final : public CSSStyleValue { 39 39 WTF_MAKE_ISO_ALLOCATED(CSSKeywordValue); 40 40 public: -
trunk/Source/WebCore/css/typedom/CSSNumericValue.cpp
r287294 r291597 31 31 #include "CSSNumericValue.h" 32 32 33 #if ENABLE(CSS_TYPED_OM) 34 35 #include "CSSMathInvert.h" 36 #include "CSSMathMax.h" 37 #include "CSSMathMin.h" 38 #include "CSSMathNegate.h" 39 #include "CSSMathProduct.h" 33 40 #include "CSSMathSum.h" 41 #include "CSSNumericArray.h" 34 42 #include "CSSNumericFactory.h" 35 43 #include "CSSNumericType.h" 36 44 #include "CSSUnitValue.h" 37 45 #include "ExceptionOr.h" 38 39 #if ENABLE(CSS_TYPED_OM)40 41 46 #include <wtf/IsoMallocInlines.h> 42 47 … … 45 50 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSNumericValue); 46 51 52 static Ref<CSSNumericValue> negate(Ref<CSSNumericValue>&& value) 53 { 54 // https://drafts.css-houdini.org/css-typed-om/#cssmath-negate-a-cssnumericvalue 55 if (auto* mathNegate = dynamicDowncast<CSSMathNegate>(value.get())) 56 return mathNegate->value(); 57 if (auto* unitValue = dynamicDowncast<CSSUnitValue>(value.get())) 58 return CSSUnitValue::create(-unitValue->value(), unitValue->unit()); 59 return CSSMathNegate::create(WTFMove(value)); 60 } 61 62 static ExceptionOr<Ref<CSSNumericValue>> invert(Ref<CSSNumericValue>&& value) 63 { 64 // https://drafts.css-houdini.org/css-typed-om/#cssmath-invert-a-cssnumericvalue 65 if (auto* mathInvert = dynamicDowncast<CSSMathInvert>(value.get())) 66 return Ref { mathInvert->value() }; 67 68 if (auto* unitValue = dynamicDowncast<CSSUnitValue>(value.get())) { 69 // FIXME: units should be either AtomicStrings or CSSUnitType enumeration values. 70 if (unitValue->unit() == "number") { 71 if (unitValue->value() == 0.0 || unitValue->value() == -0.0) 72 return Exception { RangeError }; 73 return Ref<CSSNumericValue> { CSSUnitValue::create(1.0 / unitValue->value(), unitValue->unit()) }; 74 } 75 } 76 77 return Ref<CSSNumericValue> { CSSMathInvert::create(WTFMove(value)) }; 78 } 79 80 template<typename T> 81 static RefPtr<CSSNumericValue> operationOnValuesOfSameUnit(T&& operation, const Vector<Ref<CSSNumericValue>>& values) 82 { 83 bool allValuesHaveSameUnit = values.size() && WTF::allOf(values, [&] (const Ref<CSSNumericValue>& value) { 84 auto* unitValue = dynamicDowncast<CSSUnitValue>(value.get()); 85 return unitValue ? unitValue->unit() == downcast<CSSUnitValue>(values[0].get()).unit() : false; 86 }); 87 if (allValuesHaveSameUnit) { 88 auto& firstUnitValue = downcast<CSSUnitValue>(values[0].get()); 89 String unit = firstUnitValue.unit(); 90 double result = firstUnitValue.value(); 91 for (size_t i = 1; i < values.size(); i++) 92 result = operation(result, downcast<CSSUnitValue>(values[i].get()).value()); 93 return CSSUnitValue::create(result, unit); 94 } 95 return nullptr; 96 } 97 98 template<typename T> Vector<Ref<CSSNumericValue>> CSSNumericValue::prependItemsOfTypeOrThis(Vector<Ref<CSSNumericValue>>&& numericValues) 99 { 100 Vector<Ref<CSSNumericValue>> values; 101 if (T* t = dynamicDowncast<T>(*this)) 102 values.appendVector(t->values().array()); 103 else 104 values.append(*this); 105 values.appendVector(numericValues); 106 return values; 107 } 108 109 Ref<CSSNumericValue> CSSNumericValue::addInternal(Vector<Ref<CSSNumericValue>>&& numericValues) 110 { 111 // https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-add 112 auto values = prependItemsOfTypeOrThis<CSSMathSum>(WTFMove(numericValues)); 113 114 if (auto result = operationOnValuesOfSameUnit(std::plus<double>(), values)) 115 return *result; 116 117 // FIXME: Implement step 4 to check that the types can be added. 118 119 return CSSMathSum::create(WTFMove(values)); 120 } 121 47 122 Ref<CSSNumericValue> CSSNumericValue::add(FixedVector<CSSNumberish>&& values) 48 123 { 49 UNUSED_PARAM(values); 50 // FIXME: add impl. 51 52 return *this; 124 return addInternal(WTF::map(WTFMove(values), rectifyNumberish)); 53 125 } 54 126 55 127 Ref<CSSNumericValue> CSSNumericValue::sub(FixedVector<CSSNumberish>&& values) 56 128 { 57 UNUSED_PARAM(values); 58 // FIXME: add impl. 59 60 return *this; 129 return addInternal(WTF::map(WTFMove(values), [] (CSSNumberish&& numberish) { 130 return negate(rectifyNumberish(WTFMove(numberish))); 131 })); 132 } 133 134 Ref<CSSNumericValue> CSSNumericValue::multiplyInternal(Vector<Ref<CSSNumericValue>>&& numericValues) 135 { 136 // https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-mul 137 auto values = prependItemsOfTypeOrThis<CSSMathProduct>(WTFMove(numericValues)); 138 139 bool allUnitValues = WTF::allOf(values, [&] (const Ref<CSSNumericValue>& value) { 140 return is<CSSUnitValue>(value.get()); 141 }); 142 if (allUnitValues) { 143 bool multipleUnitsFound { false }; 144 std::optional<size_t> nonNumberUnitIndex; 145 for (size_t i = 0; i < values.size(); i++) { 146 auto& unit = downcast<CSSUnitValue>(values[i].get()).unit(); 147 if (unit == "number") 148 continue; 149 if (nonNumberUnitIndex) { 150 multipleUnitsFound = true; 151 break; 152 } 153 nonNumberUnitIndex = i; 154 } 155 if (!multipleUnitsFound) { 156 double product = 1; 157 for (const Ref<CSSNumericValue>& value : values) 158 product *= downcast<CSSUnitValue>(value.get()).value(); 159 String unit = nonNumberUnitIndex ? downcast<CSSUnitValue>(values[*nonNumberUnitIndex].get()).unit() : "number"; 160 return CSSUnitValue::create(product, unit); 161 } 162 } 163 164 // FIXME: Implement step 5 to produce a unit of the correct type. 165 166 return CSSMathProduct::create(WTFMove(values)); 61 167 } 62 168 63 169 Ref<CSSNumericValue> CSSNumericValue::mul(FixedVector<CSSNumberish>&& values) 64 170 { 65 UNUSED_PARAM(values); 66 // FIXME: add impl. 67 68 return *this; 69 } 70 71 Ref<CSSNumericValue> CSSNumericValue::div(FixedVector<CSSNumberish>&& values) 72 { 73 UNUSED_PARAM(values); 74 // FIXME: add impl. 75 76 return *this; 77 } 78 Ref<CSSNumericValue> CSSNumericValue::min(FixedVector<CSSNumberish>&& values) 79 { 80 UNUSED_PARAM(values); 81 // FIXME: add impl. 82 83 return *this; 84 } 85 Ref<CSSNumericValue> CSSNumericValue::max(FixedVector<CSSNumberish>&& values) 86 { 87 UNUSED_PARAM(values); 88 // FIXME: add impl. 89 90 return *this; 171 return multiplyInternal(WTF::map(WTFMove(values), rectifyNumberish)); 172 } 173 174 ExceptionOr<Ref<CSSNumericValue>> CSSNumericValue::div(FixedVector<CSSNumberish>&& values) 175 { 176 Vector<Ref<CSSNumericValue>> invertedValues; 177 invertedValues.reserveInitialCapacity(values.size()); 178 for (auto&& value : WTFMove(values)) { 179 auto inverted = invert(rectifyNumberish(WTFMove(value))); 180 if (inverted.hasException()) 181 return inverted.releaseException(); 182 invertedValues.uncheckedAppend(inverted.releaseReturnValue()); 183 } 184 return multiplyInternal(WTFMove(invertedValues)); 185 } 186 187 Ref<CSSNumericValue> CSSNumericValue::min(FixedVector<CSSNumberish>&& numberishes) 188 { 189 // https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-min 190 auto values = prependItemsOfTypeOrThis<CSSMathMin>(WTF::map(WTFMove(numberishes), rectifyNumberish)); 191 192 if (auto result = operationOnValuesOfSameUnit<const double&(*)(const double&, const double&)>(std::min<double>, values)) 193 return *result; 194 195 // FIXME: Implement step 4 to check that the types can be added. 196 197 return CSSMathMin::create(WTFMove(values)); 198 } 199 200 Ref<CSSNumericValue> CSSNumericValue::max(FixedVector<CSSNumberish>&& numberishes) 201 { 202 // https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-max 203 auto values = prependItemsOfTypeOrThis<CSSMathMax>(WTF::map(WTFMove(numberishes), rectifyNumberish)); 204 205 if (auto result = operationOnValuesOfSameUnit<const double&(*)(const double&, const double&)>(std::max<double>, values)) 206 return *result; 207 208 // FIXME: Implement step 4 to check that the types can be added. 209 210 return CSSMathMax::create(WTFMove(values)); 91 211 } 92 212 93 213 Ref<CSSNumericValue> CSSNumericValue::rectifyNumberish(CSSNumberish&& numberish) 94 214 { 215 // https://drafts.css-houdini.org/css-typed-om/#rectify-a-numberish-value 95 216 return WTF::switchOn(numberish, [](RefPtr<CSSNumericValue>& value) { 96 217 RELEASE_ASSERT(!!value); … … 122 243 // https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-tosum 123 244 // FIXME: add impl. 124 return CSSMathSum::create( { 1.0 });245 return CSSMathSum::create(FixedVector<CSSNumberish> { 1.0 }); 125 246 } 126 247 -
trunk/Source/WebCore/css/typedom/CSSNumericValue.h
r287294 r291597 49 49 Ref<CSSNumericValue> sub(FixedVector<CSSNumberish>&&); 50 50 Ref<CSSNumericValue> mul(FixedVector<CSSNumberish>&&); 51 Ref<CSSNumericValue> div(FixedVector<CSSNumberish>&&);51 ExceptionOr<Ref<CSSNumericValue>> div(FixedVector<CSSNumberish>&&); 52 52 Ref<CSSNumericValue> min(FixedVector<CSSNumberish>&&); 53 53 Ref<CSSNumericValue> max(FixedVector<CSSNumberish>&&); … … 61 61 static ExceptionOr<Ref<CSSNumericValue>> parse(String&&); 62 62 static Ref<CSSNumericValue> rectifyNumberish(CSSNumberish&&); 63 63 64 64 CSSStyleValueType getType() const override { return CSSStyleValueType::CSSNumericValue; } 65 65 66 66 protected: 67 Ref<CSSNumericValue> addInternal(Vector<Ref<CSSNumericValue>>&&); 68 Ref<CSSNumericValue> multiplyInternal(Vector<Ref<CSSNumericValue>>&&); 69 template<typename T> Vector<Ref<CSSNumericValue>> prependItemsOfTypeOrThis(Vector<Ref<CSSNumericValue>>&&); 70 67 71 CSSNumericValue() = default; 68 72 }; … … 73 77 74 78 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSNumericValue) 75 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSNumericValue; }79 static bool isType(const WebCore::CSSStyleValue& styleValue) { return isCSSNumericValue(styleValue.getType()); } 76 80 SPECIALIZE_TYPE_TRAITS_END() 77 81 -
trunk/Source/WebCore/css/typedom/CSSStyleValue.h
r282758 r291597 45 45 CSSTransformValue, 46 46 CSSNumericValue, 47 CSSMathValue, 47 CSSMathInvert, 48 CSSMathMin, 49 CSSMathMax, 50 CSSMathNegate, 51 CSSMathProduct, 52 CSSMathSum, 48 53 CSSUnitValue, 49 54 CSSUnparsedValue, 50 55 CSSKeywordValue 51 56 }; 57 58 inline bool isCSSNumericValue(CSSStyleValueType type) 59 { 60 switch (type) { 61 case CSSStyleValueType::CSSNumericValue: 62 case CSSStyleValueType::CSSMathInvert: 63 case CSSStyleValueType::CSSMathMin: 64 case CSSStyleValueType::CSSMathMax: 65 case CSSStyleValueType::CSSMathNegate: 66 case CSSStyleValueType::CSSMathProduct: 67 case CSSStyleValueType::CSSMathSum: 68 case CSSStyleValueType::CSSUnitValue: 69 return true; 70 case CSSStyleValueType::CSSStyleValue: 71 case CSSStyleValueType::CSSStyleImageValue: 72 case CSSStyleValueType::CSSTransformValue: 73 case CSSStyleValueType::CSSUnparsedValue: 74 case CSSStyleValueType::CSSKeywordValue: 75 break; 76 } 77 return false; 78 } 79 80 inline bool isCSSMathValue(CSSStyleValueType type) 81 { 82 switch (type) { 83 case CSSStyleValueType::CSSMathInvert: 84 case CSSStyleValueType::CSSMathMin: 85 case CSSStyleValueType::CSSMathMax: 86 case CSSStyleValueType::CSSMathNegate: 87 case CSSStyleValueType::CSSMathProduct: 88 case CSSStyleValueType::CSSMathSum: 89 return true; 90 case CSSStyleValueType::CSSNumericValue: 91 case CSSStyleValueType::CSSUnitValue: 92 case CSSStyleValueType::CSSStyleValue: 93 case CSSStyleValueType::CSSStyleImageValue: 94 case CSSStyleValueType::CSSTransformValue: 95 case CSSStyleValueType::CSSUnparsedValue: 96 case CSSStyleValueType::CSSKeywordValue: 97 break; 98 } 99 return false; 100 } 52 101 53 102 class CSSStyleValue : public RefCounted<CSSStyleValue>, public ScriptWrappable { -
trunk/Source/WebCore/css/typedom/CSSUnitValue.h
r282039 r291597 67 67 68 68 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSUnitValue) 69 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSUnitValue; }69 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSUnitValue; } 70 70 SPECIALIZE_TYPE_TRAITS_END() 71 71 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathInvert.cpp
r282356 r291597 43 43 44 44 CSSMathInvert::CSSMathInvert(CSSNumberish&& numberish) 45 : CSSMathValue(CSSMathOperator::Invert) 46 , m_value(CSSNumericValue::rectifyNumberish(WTFMove(numberish))) 45 : m_value(CSSNumericValue::rectifyNumberish(WTFMove(numberish))) 47 46 { 48 47 } -
trunk/Source/WebCore/css/typedom/numeric/CSSMathInvert.h
r282356 r291597 32 32 namespace WebCore { 33 33 34 class CSSMathInvert : public CSSMathValue {34 class CSSMathInvert final : public CSSMathValue { 35 35 WTF_MAKE_ISO_ALLOCATED(CSSMathInvert); 36 36 public: 37 37 static Ref<CSSMathInvert> create(CSSNumberish&&); 38 const CSSNumericValue& value() const{ return m_value.get(); }38 CSSNumericValue& value() { return m_value.get(); } 39 39 40 40 private: 41 CSSMathOperator getOperator() const final { return CSSMathOperator::Invert; } 42 CSSStyleValueType getType() const final { return CSSStyleValueType::CSSMathInvert; } 43 41 44 CSSMathInvert(CSSNumberish&&); 42 45 Ref<CSSNumericValue> m_value; … … 46 49 47 50 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSMathInvert) 48 static bool isType(const WebCore::CSSStyleValue& styleValue) { return is<WebCore::CSSNumericValue>(styleValue) && isType(downcast<WebCore::CSSNumericValue>(styleValue)); }49 static bool isType(const WebCore::CSSNumericValue& numericValue) { return is<WebCore::CSSMathValue>(numericValue) && isType(downcast<WebCore::CSSMathValue>(numericValue)); }50 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getOperator() == WebCore::CSSMathOperator::Invert; }51 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSMathInvert; } 52 static bool isType(const WebCore::CSSNumericValue& numericValue) { return numericValue.getType() == WebCore::CSSStyleValueType::CSSMathInvert; } 53 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getType() == WebCore::CSSStyleValueType::CSSMathInvert; } 51 54 SPECIALIZE_TYPE_TRAITS_END() 52 55 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathMax.cpp
r287294 r291597 37 37 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSMathMax); 38 38 39 Ref<CSSMathMax> CSSMathMax::create(FixedVector<CSSNumberish>&& numberishes) 39 CSSMathMax::CSSMathMax(FixedVector<CSSNumberish>&& numberishes) 40 : m_values(CSSNumericArray::create(WTFMove(numberishes))) 40 41 { 41 return adoptRef(*new CSSMathMax(WTFMove(numberishes)));42 42 } 43 43 44 CSSMathMax::CSSMathMax(FixedVector<CSSNumberish>&& numberishes) 45 : CSSMathValue(CSSMathOperator::Max) 46 , m_values(CSSNumericArray::create(WTFMove(numberishes))) 44 CSSMathMax::CSSMathMax(Vector<Ref<CSSNumericValue>>&& values) 45 : m_values(CSSNumericArray::create(WTFMove(values))) 47 46 { 48 47 } -
trunk/Source/WebCore/css/typedom/numeric/CSSMathMax.h
r287294 r291597 35 35 class CSSNumericArray; 36 36 37 class CSSMathMax : public CSSMathValue {37 class CSSMathMax final : public CSSMathValue { 38 38 WTF_MAKE_ISO_ALLOCATED(CSSMathMax); 39 39 public: 40 static Ref<CSSMathMax> create(FixedVector<CSSNumberish>&&);40 template<typename... Args> static Ref<CSSMathMax> create(Args&&... args) { return adoptRef(*new CSSMathMax(std::forward<Args>(args)...)); } 41 41 const CSSNumericArray& values() const; 42 42 43 43 private: 44 CSSMathOperator getOperator() const final { return CSSMathOperator::Max; } 45 CSSStyleValueType getType() const final { return CSSStyleValueType::CSSMathMax; } 46 44 47 CSSMathMax(FixedVector<CSSNumberish>&&); 48 CSSMathMax(Vector<Ref<CSSNumericValue>>&&); 45 49 Ref<CSSNumericArray> m_values; 46 50 }; … … 49 53 50 54 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSMathMax) 51 static bool isType(const WebCore::CSSStyleValue& styleValue) { return is<WebCore::CSSNumericValue>(styleValue) && isType(downcast<WebCore::CSSNumericValue>(styleValue)); }52 static bool isType(const WebCore::CSSNumericValue& numericValue) { return is<WebCore::CSSMathValue>(numericValue) && isType(downcast<WebCore::CSSMathValue>(numericValue)); }53 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.get Operator() == WebCore::CSSMathOperator::Max; }55 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSMathMax; } 56 static bool isType(const WebCore::CSSNumericValue& numericValue) { return numericValue.getType() == WebCore::CSSStyleValueType::CSSMathMax; } 57 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getType() == WebCore::CSSStyleValueType::CSSMathMax; } 54 58 SPECIALIZE_TYPE_TRAITS_END() 55 59 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathMin.cpp
r287294 r291597 37 37 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSMathMin); 38 38 39 Ref<CSSMathMin> CSSMathMin::create(FixedVector<CSSNumberish>&& numberishes) 39 CSSMathMin::CSSMathMin(FixedVector<CSSNumberish>&& numberishes) 40 : m_values(CSSNumericArray::create(WTFMove(numberishes))) 40 41 { 41 return adoptRef(*new CSSMathMin(WTFMove(numberishes)));42 42 } 43 43 44 CSSMathMin::CSSMathMin(FixedVector<CSSNumberish>&& numberishes) 45 : CSSMathValue(CSSMathOperator::Min) 46 , m_values(CSSNumericArray::create(WTFMove(numberishes))) 44 CSSMathMin::CSSMathMin(Vector<Ref<CSSNumericValue>>&& values) 45 : m_values(CSSNumericArray::create(WTFMove(values))) 47 46 { 48 47 } -
trunk/Source/WebCore/css/typedom/numeric/CSSMathMin.h
r287294 r291597 35 35 class CSSNumericArray; 36 36 37 class CSSMathMin : public CSSMathValue {37 class CSSMathMin final : public CSSMathValue { 38 38 WTF_MAKE_ISO_ALLOCATED(CSSMathMin); 39 39 public: 40 static Ref<CSSMathMin> create(FixedVector<CSSNumberish>&&);40 template<typename... Args> static Ref<CSSMathMin> create(Args&&... args) { return adoptRef(*new CSSMathMin(std::forward<Args>(args)...)); } 41 41 const CSSNumericArray& values() const; 42 42 43 43 private: 44 CSSMathOperator getOperator() const final { return CSSMathOperator::Min; } 45 CSSStyleValueType getType() const final { return CSSStyleValueType::CSSMathMin; } 46 44 47 CSSMathMin(FixedVector<CSSNumberish>&&); 48 CSSMathMin(Vector<Ref<CSSNumericValue>>&&); 45 49 Ref<CSSNumericArray> m_values; 46 50 }; … … 49 53 50 54 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSMathMin) 51 static bool isType(const WebCore::CSSStyleValue& styleValue) { return is<WebCore::CSSNumericValue>(styleValue) && isType(downcast<WebCore::CSSNumericValue>(styleValue)); }52 static bool isType(const WebCore::CSSNumericValue& numericValue) { return is<WebCore::CSSMathValue>(numericValue) && isType(downcast<WebCore::CSSMathValue>(numericValue)); }53 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getOperator() == WebCore::CSSMathOperator::Min; }55 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSMathMin; } 56 static bool isType(const WebCore::CSSNumericValue& numericValue) { return numericValue.getType() == WebCore::CSSStyleValueType::CSSMathMin; } 57 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getType() == WebCore::CSSStyleValueType::CSSMathMin; } 54 58 SPECIALIZE_TYPE_TRAITS_END() 55 59 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathNegate.cpp
r282356 r291597 37 37 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSMathNegate); 38 38 39 Ref<CSSMathNegate> CSSMathNegate::create(CSSNumberish&& numberish) 39 CSSMathNegate::CSSMathNegate(CSSNumberish&& numberish) 40 : m_value(CSSNumericValue::rectifyNumberish(WTFMove(numberish))) 40 41 { 41 return adoptRef(*new CSSMathNegate(WTFMove(numberish)));42 42 } 43 43 44 CSSMathNegate::CSSMathNegate(CSSNumberish&& numberish) 45 : CSSMathValue(CSSMathOperator::Negate) 46 , m_value(CSSNumericValue::rectifyNumberish(WTFMove(numberish))) 44 CSSMathNegate::CSSMathNegate(Ref<CSSNumericValue>&& value) 45 : m_value(WTFMove(value)) 47 46 { 48 47 } -
trunk/Source/WebCore/css/typedom/numeric/CSSMathNegate.h
r282356 r291597 35 35 class CSSNumericValue; 36 36 37 class CSSMathNegate : public CSSMathValue {37 class CSSMathNegate final : public CSSMathValue { 38 38 WTF_MAKE_ISO_ALLOCATED(CSSMathNegate); 39 39 public: 40 static Ref<CSSMathNegate> create(CSSNumberish&&);41 const CSSNumericValue& value() const{ return m_value.get(); }40 template<typename... Args> static Ref<CSSMathNegate> create(Args&&... args) { return adoptRef(*new CSSMathNegate(std::forward<Args>(args)...)); } 41 CSSNumericValue& value() { return m_value.get(); } 42 42 43 43 private: 44 CSSMathOperator getOperator() const final { return CSSMathOperator::Negate; } 45 CSSStyleValueType getType() const final { return CSSStyleValueType::CSSMathNegate; } 46 44 47 CSSMathNegate(CSSNumberish&&); 48 CSSMathNegate(Ref<CSSNumericValue>&&); 45 49 Ref<CSSNumericValue> m_value; 46 50 }; … … 49 53 50 54 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSMathNegate) 51 static bool isType(const WebCore::CSSStyleValue& styleValue) { return is<WebCore::CSSNumericValue>(styleValue) && isType(downcast<WebCore::CSSNumericValue>(styleValue)); }52 static bool isType(const WebCore::CSSNumericValue& numericValue) { return is<WebCore::CSSMathValue>(numericValue) && isType(downcast<WebCore::CSSMathValue>(numericValue)); }53 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getOperator() == WebCore::CSSMathOperator::Negate; }55 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSMathNegate; } 56 static bool isType(const WebCore::CSSNumericValue& numericValue) { return numericValue.getType() == WebCore::CSSStyleValueType::CSSMathNegate; } 57 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getType() == WebCore::CSSStyleValueType::CSSMathNegate; } 54 58 SPECIALIZE_TYPE_TRAITS_END() 55 59 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathProduct.cpp
r287294 r291597 37 37 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSMathProduct); 38 38 39 Ref<CSSMathProduct> CSSMathProduct::create(FixedVector<CSSNumberish>&& numberishes) 39 CSSMathProduct::CSSMathProduct(FixedVector<CSSNumberish>&& numberishes) 40 : m_values(CSSNumericArray::create(WTFMove(numberishes))) 40 41 { 41 return adoptRef(*new CSSMathProduct(WTFMove(numberishes)));42 42 } 43 43 44 CSSMathProduct::CSSMathProduct(FixedVector<CSSNumberish>&& numberishes) 45 : CSSMathValue(CSSMathOperator::Product) 46 , m_values(CSSNumericArray::create(WTFMove(numberishes))) 44 CSSMathProduct::CSSMathProduct(Vector<Ref<CSSNumericValue>>&& values) 45 : m_values(CSSNumericArray::create(WTFMove(values))) 47 46 { 48 47 } -
trunk/Source/WebCore/css/typedom/numeric/CSSMathProduct.h
r287294 r291597 35 35 class CSSNumericArray; 36 36 37 class CSSMathProduct : public CSSMathValue {37 class CSSMathProduct final : public CSSMathValue { 38 38 WTF_MAKE_ISO_ALLOCATED(CSSMathProduct); 39 39 public: 40 static Ref<CSSMathProduct> create(FixedVector<CSSNumberish>&&);40 template<typename... Args> static Ref<CSSMathProduct> create(Args&&... args) { return adoptRef(*new CSSMathProduct(std::forward<Args>(args)...)); } 41 41 const CSSNumericArray& values() const; 42 43 CSSMathOperator getOperator() const final { return CSSMathOperator::Product; }44 42 45 43 private: 44 CSSMathOperator getOperator() const final { return CSSMathOperator::Product; } 45 CSSStyleValueType getType() const final { return CSSStyleValueType::CSSMathProduct; } 46 46 47 CSSMathProduct(FixedVector<CSSNumberish>&&); 48 CSSMathProduct(Vector<Ref<CSSNumericValue>>&&); 47 49 Ref<CSSNumericArray> m_values; 48 50 }; … … 51 53 52 54 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSMathProduct) 53 static bool isType(const WebCore::CSSStyleValue& styleValue) { return is<WebCore::CSSNumericValue>(styleValue) && isType(downcast<WebCore::CSSNumericValue>(styleValue)); }54 static bool isType(const WebCore::CSSNumericValue& numericValue) { return is<WebCore::CSSMathValue>(numericValue) && isType(downcast<WebCore::CSSMathValue>(numericValue)); }55 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getOperator() == WebCore::CSSMathOperator::Product; }55 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSMathProduct; } 56 static bool isType(const WebCore::CSSNumericValue& numericValue) { return numericValue.getType() == WebCore::CSSStyleValueType::CSSMathProduct; } 57 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getType() == WebCore::CSSStyleValueType::CSSMathProduct; } 56 58 SPECIALIZE_TYPE_TRAITS_END() 57 59 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathSum.cpp
r287294 r291597 37 37 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSMathSum); 38 38 39 Ref<CSSMathSum> CSSMathSum::create(FixedVector<CSSNumberish>&& numberishes)40 {41 return adoptRef(*new CSSMathSum(WTFMove(numberishes)));42 }43 44 39 CSSMathSum::CSSMathSum(FixedVector<CSSNumberish>&& numberishes) 45 : CSSMathValue(CSSMathOperator::Sum) 46 , m_values(CSSNumericArray::create(WTFMove(numberishes))) 40 : m_values(CSSNumericArray::create(WTFMove(numberishes))) 47 41 { 48 42 } 49 43 50 const CSSNumericArray& CSSMathSum::values() const 44 CSSMathSum::CSSMathSum(Vector<Ref<CSSNumericValue>>&& values) 45 : m_values(CSSNumericArray::create(WTFMove(values))) 51 46 { 52 return m_values.get();53 47 } 54 48 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathSum.h
r287294 r291597 36 36 class CSSNumericArray; 37 37 38 class CSSMathSum : public CSSMathValue {38 class CSSMathSum final : public CSSMathValue { 39 39 WTF_MAKE_ISO_ALLOCATED(CSSMathSum); 40 40 public: 41 static Ref<CSSMathSum> create(FixedVector<CSSNumberish>&&);42 const CSSNumericArray& values() const ;41 template<typename... Args> static Ref<CSSMathSum> create(Args&&... args) { return adoptRef(*new CSSMathSum(std::forward<Args>(args)...)); } 42 const CSSNumericArray& values() const { return m_values.get(); } 43 43 44 44 private: 45 CSSMathOperator getOperator() const final { return CSSMathOperator::Sum; } 46 CSSStyleValueType getType() const override { return CSSStyleValueType::CSSMathSum; } 47 45 48 CSSMathSum(FixedVector<CSSNumberish>&&); 49 CSSMathSum(Vector<Ref<CSSNumericValue>>&&); 46 50 Ref<CSSNumericArray> m_values; 47 51 }; … … 50 54 51 55 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSMathSum) 52 static bool isType(const WebCore::CSSStyleValue& styleValue) { return is<WebCore::CSSNumericValue>(styleValue) && isType(downcast<WebCore::CSSNumericValue>(styleValue)); }53 static bool isType(const WebCore::CSSNumericValue& numericValue) { return is<WebCore::CSSMathValue>(numericValue) && isType(downcast<WebCore::CSSMathValue>(numericValue)); }54 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getOperator() == WebCore::CSSMathOperator::Sum; }56 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSMathSum; } 57 static bool isType(const WebCore::CSSNumericValue& numericValue) { return numericValue.getType() == WebCore::CSSStyleValueType::CSSMathSum; } 58 static bool isType(const WebCore::CSSMathValue& mathValue) { return mathValue.getType() == WebCore::CSSStyleValueType::CSSMathSum; } 55 59 SPECIALIZE_TYPE_TRAITS_END() 56 60 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathValue.h
r282356 r291597 35 35 36 36 class CSSMathValue : public CSSNumericValue { 37 WTF_MAKE_ISO_ALLOCATED(CSSMathValue);38 37 public: 39 virtual CSSMathOperator getOperator() const { return m_operator; } 40 41 CSSStyleValueType getType() const final { return CSSStyleValueType::CSSMathValue; } 42 43 protected: 44 CSSMathValue(CSSMathOperator); 45 CSSMathOperator m_operator; 38 virtual CSSMathOperator getOperator() const = 0; 46 39 }; 47 40 48 41 } // namespace WebCore 49 42 50 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSMathValue)51 static bool isType(const WebCore::CSSStyleValue& styleValue) { return styleValue.getType() == WebCore::CSSStyleValueType::CSSMathValue; }52 static bool isType(const WebCore::CSSNumericValue& numericValue) { return numericValue.getType() == WebCore::CSSStyleValueType::CSSMathValue; }53 SPECIALIZE_TYPE_TRAITS_END()54 55 43 #endif -
trunk/Source/WebCore/css/typedom/numeric/CSSNumericArray.cpp
r287294 r291597 46 46 } 47 47 48 Ref<CSSNumericArray> CSSNumericArray::create( FixedVector<Ref<CSSNumericValue>>&& values)48 Ref<CSSNumericArray> CSSNumericArray::create(Vector<Ref<CSSNumericValue>>&& values) 49 49 { 50 50 return adoptRef(*new CSSNumericArray(WTFMove(values))); 51 } 52 53 CSSNumericArray::CSSNumericArray(Vector<Ref<CSSNumericValue>>&& values) 54 : m_array(WTFMove(values)) 55 { 51 56 } 52 57 -
trunk/Source/WebCore/css/typedom/numeric/CSSNumericArray.h
r287294 r291597 42 42 public: 43 43 static Ref<CSSNumericArray> create(const FixedVector<CSSNumberish>&); 44 static Ref<CSSNumericArray> create( FixedVector<Ref<CSSNumericValue>>&&);44 static Ref<CSSNumericArray> create(Vector<Ref<CSSNumericValue>>&&); 45 45 size_t length() const { return m_array.size(); }; 46 46 ExceptionOr<Ref<CSSNumericValue>> item(size_t index); 47 const Vector<Ref<CSSNumericValue>>& array() const { return m_array; } 47 48 48 49 private: 49 FixedVector<Ref<CSSNumericValue>> m_array; 50 Vector<Ref<CSSNumericValue>> m_array; 51 CSSNumericArray(Vector<Ref<CSSNumericValue>>&&); 50 52 CSSNumericArray(FixedVector<Ref<CSSNumericValue>>&&); 51 53 }; -
trunk/Source/WebCore/css/typedom/numeric/CSSNumericType.h
r282356 r291597 29 29 30 30 #include "CSSNumericBaseType.h" 31 #include <optional> 31 32 32 33 namespace WebCore { 33 34 34 35 struct CSSNumericType { 35 long length ;36 long angle ;37 long time ;38 long frequency ;39 long resolution ;40 long flex ;41 long percent ;42 CSSNumericBaseTypepercentHint;36 long length { 0 }; 37 long angle { 0 }; 38 long time { 0 }; 39 long frequency { 0 }; 40 long resolution { 0 }; 41 long flex { 0 }; 42 long percent { 0 }; 43 std::optional<CSSNumericBaseType> percentHint; 43 44 }; 44 45 -
trunk/Source/WebCore/css/typedom/transform/CSSTransformValue.h
r282758 r291597 38 38 template<typename> class ExceptionOr; 39 39 40 class CSSTransformValue : public CSSStyleValue {40 class CSSTransformValue final : public CSSStyleValue { 41 41 WTF_MAKE_ISO_ALLOCATED(CSSTransformValue); 42 42 public:
Note: See TracChangeset
for help on using the changeset viewer.