diff options
8 files changed, 141 insertions, 3 deletions
diff --git a/cc/animation/animation.cc b/cc/animation/animation.cc index f21a1d4..263c347 100644 --- a/cc/animation/animation.cc +++ b/cc/animation/animation.cc @@ -32,8 +32,8 @@ static const char* const s_targetPropertyNames[] = { "Transform", "Opacity", "Filter", - "BackgroundColor", - "ScrollOffset" + "ScrollOffset", + "BackgroundColor" }; COMPILE_ASSERT(static_cast<int>(cc::Animation::TargetPropertyEnumSize) == diff --git a/cc/animation/animation.h b/cc/animation/animation.h index c7d53c2..f996c38 100644 --- a/cc/animation/animation.h +++ b/cc/animation/animation.h @@ -42,8 +42,8 @@ class CC_EXPORT Animation { Transform = 0, Opacity, Filter, - BackgroundColor, ScrollOffset, + BackgroundColor, // This sentinel must be last. TargetPropertyEnumSize }; diff --git a/webkit/renderer/compositor_bindings/compositor_bindings.gyp b/webkit/renderer/compositor_bindings/compositor_bindings.gyp index 6acc57c..09f4b51 100644 --- a/webkit/renderer/compositor_bindings/compositor_bindings.gyp +++ b/webkit/renderer/compositor_bindings/compositor_bindings.gyp @@ -69,6 +69,8 @@ 'web_layer_impl_fixed_bounds.h', 'web_nine_patch_layer_impl.cc', 'web_nine_patch_layer_impl.h', + 'web_scroll_offset_animation_curve_impl.cc', + 'web_scroll_offset_animation_curve_impl.h', 'web_scrollbar_layer_impl.cc', 'web_scrollbar_layer_impl.h', 'web_solid_color_layer_impl.cc', diff --git a/webkit/renderer/compositor_bindings/web_animation_impl.cc b/webkit/renderer/compositor_bindings/web_animation_impl.cc index dbcc184..c401d5c 100644 --- a/webkit/renderer/compositor_bindings/web_animation_impl.cc +++ b/webkit/renderer/compositor_bindings/web_animation_impl.cc @@ -11,6 +11,7 @@ #include "third_party/WebKit/public/platform/WebAnimationCurve.h" #include "webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h" #include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h" +#include "webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.h" #include "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h" using cc::Animation; @@ -51,6 +52,14 @@ WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve, curve = filter_curve_impl->CloneToAnimationCurve(); break; } +#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED + case WebAnimationCurve::AnimationCurveTypeScrollOffset: { + const WebScrollOffsetAnimationCurveImpl* scroll_curve_impl = + static_cast<const WebScrollOffsetAnimationCurveImpl*>(&web_curve); + curve = scroll_curve_impl->CloneToAnimationCurve(); + break; + } +#endif } animation_ = Animation::Create( curve.Pass(), @@ -109,5 +118,9 @@ COMPILE_ASSERT_MATCHING_ENUMS( WebAnimation::TargetPropertyOpacity, Animation::Opacity); COMPILE_ASSERT_MATCHING_ENUMS( WebAnimation::TargetPropertyFilter, Animation::Filter); +#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED +COMPILE_ASSERT_MATCHING_ENUMS( + WebAnimation::TargetPropertyScrollOffset, Animation::ScrollOffset); +#endif } // namespace webkit diff --git a/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc b/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc index a49de09..51bb621 100644 --- a/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc +++ b/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc @@ -19,6 +19,7 @@ #include "webkit/renderer/compositor_bindings/web_image_layer_impl.h" #include "webkit/renderer/compositor_bindings/web_layer_impl.h" #include "webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.h" +#include "webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.h" #include "webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h" #include "webkit/renderer/compositor_bindings/web_solid_color_layer_impl.h" #include "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h" @@ -40,6 +41,9 @@ using blink::WebScrollbar; using blink::WebScrollbarLayer; using blink::WebScrollbarThemeGeometry; using blink::WebScrollbarThemePainter; +#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED +using blink::WebScrollOffsetAnimationCurve; +#endif using blink::WebSolidColorLayer; using blink::WebTransformAnimationCurve; using blink::WebTransformOperations; @@ -106,6 +110,15 @@ WebFloatAnimationCurve* WebCompositorSupportImpl::createFloatAnimationCurve() { return new WebFloatAnimationCurveImpl(); } +#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED +WebScrollOffsetAnimationCurve* +WebCompositorSupportImpl::createScrollOffsetAnimationCurve( + blink::WebFloatPoint target_value, + blink::WebAnimationCurve::TimingFunctionType timing_function) { + return new WebScrollOffsetAnimationCurveImpl(target_value, timing_function); +} +#endif + WebTransformAnimationCurve* WebCompositorSupportImpl::createTransformAnimationCurve() { return new WebTransformAnimationCurveImpl(); diff --git a/webkit/renderer/compositor_bindings/web_compositor_support_impl.h b/webkit/renderer/compositor_bindings/web_compositor_support_impl.h index 276a5906..e89a0cb 100644 --- a/webkit/renderer/compositor_bindings/web_compositor_support_impl.h +++ b/webkit/renderer/compositor_bindings/web_compositor_support_impl.h @@ -7,6 +7,7 @@ #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop_proxy.h" +#include "third_party/WebKit/public/platform/WebAnimationCurve.h" #include "third_party/WebKit/public/platform/WebCompositorSupport.h" #include "third_party/WebKit/public/platform/WebLayer.h" #include "third_party/WebKit/public/platform/WebTransformOperations.h" @@ -43,6 +44,12 @@ class WebCompositorSupportImpl : public blink::WebCompositorSupport { int animation_id); virtual blink::WebFilterAnimationCurve* createFilterAnimationCurve(); virtual blink::WebFloatAnimationCurve* createFloatAnimationCurve(); +#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED + virtual blink::WebScrollOffsetAnimationCurve* + createScrollOffsetAnimationCurve( + blink::WebFloatPoint target_value, + blink::WebAnimationCurve::TimingFunctionType timing_function); +#endif virtual blink::WebTransformAnimationCurve* createTransformAnimationCurve(); virtual blink::WebTransformOperations* createTransformOperations(); virtual blink::WebFilterOperations* createFilterOperations(); diff --git a/webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.cc b/webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.cc new file mode 100644 index 0000000..fc6c76a --- /dev/null +++ b/webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.cc @@ -0,0 +1,52 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.h" + +#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED + +#include "cc/animation/scroll_offset_animation_curve.h" +#include "cc/animation/timing_function.h" +#include "webkit/renderer/compositor_bindings/web_animation_curve_common.h" + +using blink::WebFloatPoint; + +namespace webkit { + +WebScrollOffsetAnimationCurveImpl::WebScrollOffsetAnimationCurveImpl( + WebFloatPoint target_value, + TimingFunctionType timing_function) + : curve_(cc::ScrollOffsetAnimationCurve::Create( + gfx::Vector2dF(target_value.x, target_value.y), + CreateTimingFunction(timing_function))) {} + +WebScrollOffsetAnimationCurveImpl::~WebScrollOffsetAnimationCurveImpl() {} + +blink::WebAnimationCurve::AnimationCurveType +WebScrollOffsetAnimationCurveImpl::type() const { + return WebAnimationCurve::AnimationCurveTypeScrollOffset; +} + +void WebScrollOffsetAnimationCurveImpl::setInitialValue( + WebFloatPoint initial_value) { + curve_->SetInitialValue(gfx::Vector2dF(initial_value.x, initial_value.y)); +} + +WebFloatPoint WebScrollOffsetAnimationCurveImpl::getValue(double time) const { + gfx::Vector2dF value = curve_->GetValue(time); + return WebFloatPoint(value.x(), value.y()); +} + +double WebScrollOffsetAnimationCurveImpl::duration() const { + return curve_->Duration(); +} + +scoped_ptr<cc::AnimationCurve> +WebScrollOffsetAnimationCurveImpl::CloneToAnimationCurve() const { + return curve_->Clone(); +} + +} // namespace webkit + +#endif // WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED diff --git a/webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.h b/webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.h new file mode 100644 index 0000000..ae1c8b0 --- /dev/null +++ b/webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_impl.h @@ -0,0 +1,51 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SCROLL_OFFSET_ANIMATION_CURVE_IMPL_H_ +#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SCROLL_OFFSET_ANIMATION_CURVE_IMPL_H_ + +#include "third_party/WebKit/public/platform/WebAnimationCurve.h" + +#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED + +#include "base/memory/scoped_ptr.h" +#include "third_party/WebKit/public/platform/WebScrollOffsetAnimationCurve.h" +#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h" + +namespace cc { +class AnimationCurve; +class ScrollOffsetAnimationCurve; +} + +namespace webkit { + +class WebScrollOffsetAnimationCurveImpl + : public blink::WebScrollOffsetAnimationCurve { + public: + WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebScrollOffsetAnimationCurveImpl( + blink::WebFloatPoint target_value, + TimingFunctionType timing_function); + virtual ~WebScrollOffsetAnimationCurveImpl(); + + // blink::WebAnimationCurve implementation. + virtual AnimationCurveType type() const; + + // blink::WebScrollOffsetAnimationCurve implementation. + virtual void setInitialValue(blink::WebFloatPoint initial_value); + virtual blink::WebFloatPoint getValue(double time) const; + virtual double duration() const; + + scoped_ptr<cc::AnimationCurve> CloneToAnimationCurve() const; + + private: + scoped_ptr<cc::ScrollOffsetAnimationCurve> curve_; + + DISALLOW_COPY_AND_ASSIGN(WebScrollOffsetAnimationCurveImpl); +}; + +} // namespace webkit + +#endif // WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED + +#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SCROLL_OFFSET_ANIMATION_CURVE_IMPL_H_ |