Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: Source/core/animation/LengthBoxStyleInterpolation.h

Issue 878863002: Animation: Add CSSPropertyClip and CSSPropertyBorderImageSlice to StringKeyframe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Handling auto values Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/animation/LengthBoxStyleInterpolation.h
diff --git a/Source/core/animation/LengthBoxStyleInterpolation.h b/Source/core/animation/LengthBoxStyleInterpolation.h
index 1542dda42dce5f69c30f407eafbc0ce4b024e7c4..ee6bd5c1bef85f2226864b810508df053b4d9a5c 100644
--- a/Source/core/animation/LengthBoxStyleInterpolation.h
+++ b/Source/core/animation/LengthBoxStyleInterpolation.h
@@ -7,41 +7,66 @@
#include "core/animation/LengthStyleInterpolation.h"
#include "core/css/CSSBorderImageSliceValue.h"
+#include "core/css/Rect.h"
namespace blink {
class LengthBoxStyleInterpolation : public StyleInterpolation {
public:
- static PassRefPtrWillBeRawPtr<LengthBoxStyleInterpolation> create(const CSSValue& start, const CSSValue& end, CSSPropertyID id)
+ static bool onlyLengthToAuto(Rect* startRect, Rect* endRect)
Eric Willigers 2015/02/11 03:56:32 This method isn't trivial, so move implementation
jadeg 2015/02/12 05:06:00 Done.
{
- return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(lengthBoxtoInterpolableValue(start), lengthBoxtoInterpolableValue(end), id, false));
+ return (startRect->left()->isLength() == endRect->left()->isValueID() || endRect->left()->isLength() == startRect->left()->isValueID())
+ && (startRect->right()->isLength() == endRect->right()->isValueID() || endRect->right()->isLength() == startRect->right()->isValueID())
+ && (startRect->top()->isLength() == endRect->top()->isValueID() || endRect->top()->isLength() == startRect->top()->isValueID())
+ && (startRect->bottom()->isLength() == endRect->bottom()->isValueID() || endRect->bottom()->isLength() == startRect->bottom()->isValueID());
}
- static PassRefPtrWillBeRawPtr<LengthBoxStyleInterpolation> createFromBorderImageSlice(CSSValue& start, CSSValue& end, CSSPropertyID id)
+ static PassRefPtrWillBeRawPtr<LengthBoxStyleInterpolation> maybeCreateFrom(CSSValue* start, CSSValue* end, CSSPropertyID id)
Eric Willigers 2015/02/11 03:56:32 This method isn't trivial, so move implementation
jadeg 2015/02/12 05:06:00 Done.
{
- return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(borderImageSlicetoInterpolableValue(start), borderImageSlicetoInterpolableValue(end), id, toCSSBorderImageSliceValue(start).m_fill));
- }
+ bool startRect = start->isPrimitiveValue() && toCSSPrimitiveValue(start)->isRect();
+ bool endRect = end->isPrimitiveValue() && toCSSPrimitiveValue(end)->isRect();
+ bool startAuto = start->isPrimitiveValue() && toCSSPrimitiveValue(start)->isValueID() && toCSSPrimitiveValue(start)->getValueID() == CSSValueAuto;
+ bool endAuto = end->isPrimitiveValue() && toCSSPrimitiveValue(end)->isValueID() && toCSSPrimitiveValue(end)->getValueID() == CSSValueAuto;
+
+ if (startAuto || endAuto) {
+ return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(InterpolableBool::create(false), InterpolableBool::create(true), id, false, start, end));
+ }
+ if (startRect && endRect) {
+ Rect* startRectValue = toCSSPrimitiveValue(start)->getRectValue();
+ Rect* endRectValue = toCSSPrimitiveValue(end)->getRectValue();
- static bool canCreateFrom(const CSSValue&);
+ if (onlyLengthToAuto(startRectValue, endRectValue))
+ return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(InterpolableBool::create(false), InterpolableBool::create(true), id, false, start, end));
+ return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(lengthBoxtoInterpolableValue(*start, *end, false), lengthBoxtoInterpolableValue(*end, *start, true), id, false, start, end));
+ }
+ if (start->isBorderImageSliceValue() && toCSSBorderImageSliceValue(start)->slices()
+ && end->isBorderImageSliceValue() && toCSSBorderImageSliceValue(end)->slices()
+ && toCSSBorderImageSliceValue(start)->m_fill == toCSSBorderImageSliceValue(end)->m_fill)
+ return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(borderImageSlicetoInterpolableValue(*start), borderImageSlicetoInterpolableValue(*end), id, toCSSBorderImageSliceValue(start)->m_fill, start, end));
+ return nullptr;
+ }
- static bool matchingFill(CSSValue&, CSSValue&);
- static bool canCreateFromBorderImageSlice(CSSValue&);
+ static bool usesDefault(const CSSValue&, const CSSValue&);
virtual void apply(StyleResolverState&) const override;
virtual void trace(Visitor*) override;
private:
- LengthBoxStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id, bool fill)
- : StyleInterpolation(start, end, id)
+ LengthBoxStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> startInterpolation, PassOwnPtrWillBeRawPtr<InterpolableValue> endInterpolation, CSSPropertyID id, bool fill, CSSValue* startCSS, CSSValue* endCSS)
+ : StyleInterpolation(startInterpolation, endInterpolation, id)
, m_fill(fill)
+ , m_startCSSValue(startCSS)
+ , m_endCSSValue(endCSS)
{ }
- static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthBoxtoInterpolableValue(const CSSValue&);
- static PassOwnPtrWillBeRawPtr<InterpolableValue> borderImageSlicetoInterpolableValue(CSSValue&);
- static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLengthBox(InterpolableValue*, InterpolationRange = RangeAll);
+ static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthBoxtoInterpolableValue(const CSSValue&, const CSSValue&, bool);
+ static PassOwnPtrWillBeRawPtr<InterpolableValue> borderImageSlicetoInterpolableValue(const CSSValue&);
+ static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLengthBox(InterpolableValue*, const CSSValue&, const CSSValue&);
static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToBorderImageSlice(InterpolableValue*, bool);
bool m_fill;
+ RefPtrWillBeMember<CSSValue> m_startCSSValue;
+ RefPtrWillBeMember<CSSValue> m_endCSSValue;
friend class AnimationLengthBoxStyleInterpolationTest;
};

Powered by Google App Engine
This is Rietveld 408576698