Modified: trunk/Source/WebCore/ChangeLog (273602 => 273603)
--- trunk/Source/WebCore/ChangeLog 2021-02-27 00:17:43 UTC (rev 273602)
+++ trunk/Source/WebCore/ChangeLog 2021-02-27 00:29:26 UTC (rev 273603)
@@ -1,3 +1,26 @@
+2021-02-26 Antoine Quint <[email protected]>
+
+ Length blending should allow for a ValueRange parameter
+ https://bugs.webkit.org/show_bug.cgi?id=222497
+
+ Reviewed by Dean Jackson.
+
+ We introduced a new NonNegativeLengthPropertyWrapper in r273001, the fix for bug 222034, with a special
+ blend() override implementation which would disallow negative values. However, this is something that
+ should ideally be provided lower down in the blending code in the blend() function on the Length type
+ itself. This will allow us to blend other non-negative length-related types, such as LengthBox, without
+ duplicating this code.
+
+ We also use this opportunity to not use the { 0, Fixed } value in all cases where we clip to 0, and
+ instead use the type from the blended values, provided one isn't 0.
+
+ * animation/CSSPropertyAnimation.cpp:
+ (WebCore::blendFunc):
+ (WebCore::NonNegativeLengthPropertyWrapper::NonNegativeLengthPropertyWrapper):
+ * platform/Length.cpp:
+ (WebCore::blend):
+ * platform/Length.h:
+
2021-02-26 Zalan Bujtas <[email protected]>
[LFC][Coverage] Do not bail out on text underline position when text-decoration is 'none'
Modified: trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp (273602 => 273603)
--- trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp 2021-02-27 00:17:43 UTC (rev 273602)
+++ trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp 2021-02-27 00:29:26 UTC (rev 273603)
@@ -88,9 +88,9 @@
return blend(from, to, progress);
}
-static inline Length blendFunc(const CSSPropertyBlendingClient*, const Length& from, const Length& to, double progress)
+static inline Length blendFunc(const CSSPropertyBlendingClient*, const Length& from, const Length& to, double progress, ValueRange valueRange = ValueRangeAll)
{
- return blend(from, to, progress);
+ return blend(from, to, progress, valueRange);
}
static inline GapLength blendFunc(const CSSPropertyBlendingClient*, const GapLength& from, const GapLength& to, double progress)
@@ -699,31 +699,18 @@
void (RenderStyle::*m_setter)(Length&&);
};
-class NonNegativeLengthPropertyWrapper : public PropertyWrapperGetter<const Length&> {
+class NonNegativeLengthPropertyWrapper : public LengthPropertyWrapper {
WTF_MAKE_FAST_ALLOCATED;
public:
NonNegativeLengthPropertyWrapper(CSSPropertyID prop, const Length& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(Length&&))
- : PropertyWrapperGetter<const Length&>(prop, getter)
- , m_setter(setter)
+ : LengthPropertyWrapper(prop, getter, setter)
{
}
- bool canInterpolate(const RenderStyle* a, const RenderStyle* b) const override
- {
- return !(a->*PropertyWrapperGetter<const Length&>::m_getter)().isAuto() && !(b->*PropertyWrapperGetter<const Length&>::m_getter)().isAuto();
- }
-
void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override
{
- auto blended = blendFunc(anim, (a->*PropertyWrapperGetter<const Length&>::m_getter)(), (b->*PropertyWrapperGetter<const Length&>::m_getter)(), progress);
- if (blended.isNegative())
- (dst->*m_setter)(Length(0, LengthType::Fixed));
- else
- (dst->*m_setter)(WTFMove(blended));
+ (dst->*m_setter)(blendFunc(anim, (a->*PropertyWrapperGetter<const Length&>::m_getter)(), (b->*PropertyWrapperGetter<const Length&>::m_getter)(), progress, ValueRangeNonNegative));
}
-
-protected:
- void (RenderStyle::*m_setter)(Length&&);
};
template <typename T>
Modified: trunk/Source/WebCore/platform/Length.cpp (273602 => 273603)
--- trunk/Source/WebCore/platform/Length.cpp 2021-02-27 00:17:43 UTC (rev 273602)
+++ trunk/Source/WebCore/platform/Length.cpp 2021-02-27 00:29:26 UTC (rev 273603)
@@ -335,6 +335,14 @@
return Length(WebCore::blend(fromValue, toValue, progress), resultType);
}
+Length blend(const Length& from, const Length& to, double progress, ValueRange valueRange)
+{
+ auto blended = blend(from, to, progress);
+ if (valueRange == ValueRangeNonNegative && blended.isNegative())
+ return { 0, from.isZero () ? to.type() : from.type() };
+ return blended;
+}
+
struct SameSizeAsLength {
int32_t value;
int32_t metaData;
Modified: trunk/Source/WebCore/platform/Length.h (273602 => 273603)
--- trunk/Source/WebCore/platform/Length.h 2021-02-27 00:17:43 UTC (rev 273602)
+++ trunk/Source/WebCore/platform/Length.h 2021-02-27 00:29:26 UTC (rev 273603)
@@ -138,6 +138,7 @@
// Blend two lengths to produce a new length that is in between them. Used for animation.
Length blend(const Length& from, const Length& to, double progress);
+Length blend(const Length& from, const Length& to, double progress, ValueRange);
UniqueArray<Length> newCoordsArray(const String&, int& length);
UniqueArray<Length> newLengthArray(const String&, int& length);