Changeset 295716 in webkit
- Timestamp:
- Jun 21, 2022, 8:00:34 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/equals.tentative-expected.txt
r282356 r295716 1 1 2 FAIL Two CSSUnitValues with same value and unit are equal assert_true: expected true got false 2 PASS Two CSSUnitValues with same value and unit are equal 3 3 PASS Two CSSUnitValues with different values are not equal 4 4 PASS Two CSSUnitValues with different units are not equal … … 6 6 PASS Two CSSMathValues with different number of values are not equal 7 7 PASS Two CSSMathValues with different values are not equal 8 FAIL Two CSSMathValues with same structure are equal assert_true: expected true got false 9 FAIL Multiple CSSMathValues with same structure are equal assert_true: expected true got false 8 PASS Two CSSMathValues with same structure are equal 9 PASS Multiple CSSMathValues with same structure are equal 10 10 PASS Multiple CSSMathValues with one different are not equal 11 11 -
trunk/Source/WebCore/bindings/js/JSCSSStyleValueCustom.cpp
r291597 r295716 52 52 case CSSStyleValueType::CSSStyleImageValue: 53 53 return createWrapper<CSSStyleImageValue>(globalObject, WTFMove(value)); 54 case CSSStyleValueType::CSSNumericValue:55 return createWrapper<CSSNumericValue>(globalObject, WTFMove(value));56 54 case CSSStyleValueType::CSSMathInvert: 57 55 return createWrapper<CSSMathInvert>(globalObject, WTFMove(value)); -
trunk/Source/WebCore/css/typedom/CSSNumericValue.cpp
r295219 r295716 226 226 } 227 227 228 bool CSSNumericValue::equals(FixedVector<CSSNumberish>&& value) 229 { 230 UNUSED_PARAM(value); 228 bool CSSNumericValue::equals(FixedVector<CSSNumberish>&& values) 229 { 231 230 // https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-equals 232 // FIXME: add impl. 233 return false; 231 auto numericValues = WTF::map(WTFMove(values), rectifyNumberish); 232 return WTF::allOf(numericValues, [&] (const Ref<CSSNumericValue>& value) { 233 return this->equals(value.get()); 234 }); 234 235 } 235 236 -
trunk/Source/WebCore/css/typedom/CSSNumericValue.h
r295219 r295716 65 65 static Ref<CSSNumericValue> rectifyNumberish(CSSNumberish&&); 66 66 67 CSSStyleValueType getType() const override { return CSSStyleValueType::CSSNumericValue; }68 69 67 // https://drafts.css-houdini.org/css-typed-om/#sum-value-value 70 68 using UnitMap = HashMap<CSSUnitType, int, WTF::IntHash<CSSUnitType>, WTF::StrongEnumHashTraits<CSSUnitType>>; … … 75 73 using SumValue = Vector<Addend>; 76 74 virtual std::optional<SumValue> toSumValue() const = 0; 75 virtual bool equals(const CSSNumericValue&) const = 0; 77 76 78 77 protected: -
trunk/Source/WebCore/css/typedom/CSSStyleValue.h
r295692 r295716 45 45 CSSStyleImageValue, 46 46 CSSTransformValue, 47 CSSNumericValue,48 47 CSSMathInvert, 49 48 CSSMathMin, … … 60 59 { 61 60 switch (type) { 62 case CSSStyleValueType::CSSNumericValue:63 61 case CSSStyleValueType::CSSMathInvert: 64 62 case CSSStyleValueType::CSSMathMin: … … 89 87 case CSSStyleValueType::CSSMathSum: 90 88 return true; 91 case CSSStyleValueType::CSSNumericValue:92 89 case CSSStyleValueType::CSSUnitValue: 93 90 case CSSStyleValueType::CSSStyleValue: -
trunk/Source/WebCore/css/typedom/CSSUnitValue.cpp
r295219 r295716 175 175 } 176 176 177 bool CSSUnitValue::equals(const CSSNumericValue& other) const 178 { 179 // https://drafts.css-houdini.org/css-typed-om/#equal-numeric-value 180 auto* otherUnitValue = dynamicDowncast<CSSUnitValue>(other); 181 if (!otherUnitValue) 182 return false; 183 return m_value == otherUnitValue->m_value && m_unit == otherUnitValue->m_unit; 184 } 185 177 186 } // namespace WebCore 178 187 -
trunk/Source/WebCore/css/typedom/CSSUnitValue.h
r295219 r295716 57 57 CSSUnitValue(double, CSSUnitType); 58 58 59 CSSStyleValueType getType() const final { return CSSStyleValueType::CSSUnitValue; } 59 60 std::optional<SumValue> toSumValue() const final; 60 CSSStyleValueType getType() const final { return CSSStyleValueType::CSSUnitValue; }61 bool equals(const CSSNumericValue&) const final; 61 62 62 63 double m_value; -
trunk/Source/WebCore/css/typedom/numeric/CSSMathInvert.cpp
r295219 r295716 70 70 CSSMathInvert::CSSMathInvert(CSSNumberish&& numberish) 71 71 : CSSMathValue(negatedType(numberish)) 72 , m_value( CSSNumericValue::rectifyNumberish(WTFMove(numberish)))72 , m_value(rectifyNumberish(WTFMove(numberish))) 73 73 { 74 74 } … … 106 106 } 107 107 108 bool CSSMathInvert::equals(const CSSNumericValue& other) const 109 { 110 // https://drafts.css-houdini.org/css-typed-om/#equal-numeric-value 111 auto* otherInvert = dynamicDowncast<CSSMathInvert>(other); 112 if (!otherInvert) 113 return false; 114 return m_value->equals(otherInvert->value()); 115 116 } 117 108 118 } // namespace WebCore 109 119 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathInvert.h
r295219 r295716 44 44 void serialize(StringBuilder&, OptionSet<SerializationArguments>) const final; 45 45 std::optional<SumValue> toSumValue() const final; 46 bool equals(const CSSNumericValue&) const final; 46 47 47 48 CSSMathInvert(CSSNumberish&&); -
trunk/Source/WebCore/css/typedom/numeric/CSSMathMax.h
r295219 r295716 47 47 void serialize(StringBuilder&, OptionSet<SerializationArguments>) const final; 48 48 std::optional<SumValue> toSumValue() const final; 49 bool equals(const CSSNumericValue& other) const final { return equalsImpl<CSSMathMax>(other); } 49 50 50 51 CSSMathMax(Vector<Ref<CSSNumericValue>>&&, CSSNumericType&&); -
trunk/Source/WebCore/css/typedom/numeric/CSSMathMin.h
r295219 r295716 47 47 void serialize(StringBuilder&, OptionSet<SerializationArguments>) const final; 48 48 std::optional<SumValue> toSumValue() const final; 49 bool equals(const CSSNumericValue& other) const final { return equalsImpl<CSSMathMin>(other); } 49 50 50 51 CSSMathMin(Vector<Ref<CSSNumericValue>>&&, CSSNumericType&&); -
trunk/Source/WebCore/css/typedom/numeric/CSSMathNegate.cpp
r295219 r295716 52 52 CSSMathNegate::CSSMathNegate(CSSNumberish&& numberish) 53 53 : CSSMathValue(copyType(numberish)) 54 , m_value( CSSNumericValue::rectifyNumberish(WTFMove(numberish)))54 , m_value(rectifyNumberish(WTFMove(numberish))) 55 55 { 56 56 } … … 78 78 } 79 79 80 bool CSSMathNegate::equals(const CSSNumericValue& other) const 81 { 82 // https://drafts.css-houdini.org/css-typed-om/#equal-numeric-value 83 auto* otherNegate = dynamicDowncast<CSSMathNegate>(other); 84 if (!otherNegate) 85 return false; 86 return m_value->equals(otherNegate->value()); 87 88 } 89 80 90 } // namespace WebCore 81 91 -
trunk/Source/WebCore/css/typedom/numeric/CSSMathNegate.h
r295219 r295716 47 47 void serialize(StringBuilder&, OptionSet<SerializationArguments>) const final; 48 48 std::optional<SumValue> toSumValue() const final; 49 bool equals(const CSSNumericValue& other) const final; 49 50 50 51 CSSMathNegate(CSSNumberish&&); -
trunk/Source/WebCore/css/typedom/numeric/CSSMathProduct.h
r295219 r295716 47 47 void serialize(StringBuilder&, OptionSet<SerializationArguments>) const; 48 48 std::optional<SumValue> toSumValue() const final; 49 bool equals(const CSSNumericValue& other) const final { return equalsImpl<CSSMathProduct>(other); } 49 50 50 51 CSSMathProduct(Vector<Ref<CSSNumericValue>>, CSSNumericType); -
trunk/Source/WebCore/css/typedom/numeric/CSSMathSum.h
r295219 r295716 48 48 void serialize(StringBuilder&, OptionSet<SerializationArguments>) const final; 49 49 std::optional<SumValue> toSumValue() const final; 50 bool equals(const CSSNumericValue& other) const final { return equalsImpl<CSSMathSum>(other); } 50 51 51 52 CSSMathSum(Vector<Ref<CSSNumericValue>>, CSSNumericType); -
trunk/Source/WebCore/css/typedom/numeric/CSSMathValue.h
r292150 r295716 29 29 30 30 #include "CSSMathOperator.h" 31 #include "CSSNumericArray.h" 31 32 #include "CSSNumericValue.h" 32 33 #include "CSSStyleValue.h" … … 36 37 class CSSMathValue : public CSSNumericValue { 37 38 public: 38 CSSMathValue(CSSNumericType type = { })39 CSSMathValue(CSSNumericType type) 39 40 : CSSNumericValue(WTFMove(type)) { } 40 41 virtual CSSMathOperator getOperator() const = 0; 42 43 template <typename T> 44 bool equalsImpl(const CSSNumericValue& other) const 45 { 46 // https://drafts.css-houdini.org/css-typed-om/#equal-numeric-value 47 auto* otherT = dynamicDowncast<T>(other); 48 if (!otherT) 49 return false; 50 51 ASSERT(getType() == other.getType()); 52 auto& thisValues = static_cast<const T*>(this)->values(); 53 auto& otherValues = otherT->values(); 54 auto length = thisValues.length(); 55 if (length != otherValues.length()) 56 return false; 57 58 for (size_t i = 0 ; i < length; ++i) { 59 if (!thisValues.array()[i]->equals(otherValues.array()[i].get())) 60 return false; 61 } 62 63 return true; 64 65 } 41 66 }; 42 67
Note:
See TracChangeset
for help on using the changeset viewer.