Commit 92377998 authored by ajuma@chromium.org's avatar ajuma@chromium.org

Define WebScrollOffsetAnimationCurveImpl

This defines WebScrollOffsetAnimationCurveImpl, which wraps a
cc::ScrollOffsetAnimationCurve. This is needed for
implementing the CSSOM Smooth Scroll API.

BUG=243871

Review URL: https://codereview.chromium.org/112933005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245645 0039d316-1c4b-4281-b951-d872f2087c98
parent c27ce8eb
...@@ -32,8 +32,8 @@ static const char* const s_targetPropertyNames[] = { ...@@ -32,8 +32,8 @@ static const char* const s_targetPropertyNames[] = {
"Transform", "Transform",
"Opacity", "Opacity",
"Filter", "Filter",
"BackgroundColor", "ScrollOffset",
"ScrollOffset" "BackgroundColor"
}; };
COMPILE_ASSERT(static_cast<int>(cc::Animation::TargetPropertyEnumSize) == COMPILE_ASSERT(static_cast<int>(cc::Animation::TargetPropertyEnumSize) ==
......
...@@ -42,8 +42,8 @@ class CC_EXPORT Animation { ...@@ -42,8 +42,8 @@ class CC_EXPORT Animation {
Transform = 0, Transform = 0,
Opacity, Opacity,
Filter, Filter,
BackgroundColor,
ScrollOffset, ScrollOffset,
BackgroundColor,
// This sentinel must be last. // This sentinel must be last.
TargetPropertyEnumSize TargetPropertyEnumSize
}; };
......
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
'web_layer_impl_fixed_bounds.h', 'web_layer_impl_fixed_bounds.h',
'web_nine_patch_layer_impl.cc', 'web_nine_patch_layer_impl.cc',
'web_nine_patch_layer_impl.h', '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.cc',
'web_scrollbar_layer_impl.h', 'web_scrollbar_layer_impl.h',
'web_solid_color_layer_impl.cc', 'web_solid_color_layer_impl.cc',
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/WebKit/public/platform/WebAnimationCurve.h" #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_filter_animation_curve_impl.h"
#include "webkit/renderer/compositor_bindings/web_float_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" #include "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h"
using cc::Animation; using cc::Animation;
...@@ -51,6 +52,14 @@ WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve, ...@@ -51,6 +52,14 @@ WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve,
curve = filter_curve_impl->CloneToAnimationCurve(); curve = filter_curve_impl->CloneToAnimationCurve();
break; 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( animation_ = Animation::Create(
curve.Pass(), curve.Pass(),
...@@ -109,5 +118,9 @@ COMPILE_ASSERT_MATCHING_ENUMS( ...@@ -109,5 +118,9 @@ COMPILE_ASSERT_MATCHING_ENUMS(
WebAnimation::TargetPropertyOpacity, Animation::Opacity); WebAnimation::TargetPropertyOpacity, Animation::Opacity);
COMPILE_ASSERT_MATCHING_ENUMS( COMPILE_ASSERT_MATCHING_ENUMS(
WebAnimation::TargetPropertyFilter, Animation::Filter); WebAnimation::TargetPropertyFilter, Animation::Filter);
#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED
COMPILE_ASSERT_MATCHING_ENUMS(
WebAnimation::TargetPropertyScrollOffset, Animation::ScrollOffset);
#endif
} // namespace webkit } // namespace webkit
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "webkit/renderer/compositor_bindings/web_image_layer_impl.h" #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_layer_impl.h"
#include "webkit/renderer/compositor_bindings/web_nine_patch_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_scrollbar_layer_impl.h"
#include "webkit/renderer/compositor_bindings/web_solid_color_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" #include "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h"
...@@ -40,6 +41,9 @@ using blink::WebScrollbar; ...@@ -40,6 +41,9 @@ using blink::WebScrollbar;
using blink::WebScrollbarLayer; using blink::WebScrollbarLayer;
using blink::WebScrollbarThemeGeometry; using blink::WebScrollbarThemeGeometry;
using blink::WebScrollbarThemePainter; using blink::WebScrollbarThemePainter;
#if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED
using blink::WebScrollOffsetAnimationCurve;
#endif
using blink::WebSolidColorLayer; using blink::WebSolidColorLayer;
using blink::WebTransformAnimationCurve; using blink::WebTransformAnimationCurve;
using blink::WebTransformOperations; using blink::WebTransformOperations;
...@@ -106,6 +110,15 @@ WebFloatAnimationCurve* WebCompositorSupportImpl::createFloatAnimationCurve() { ...@@ -106,6 +110,15 @@ WebFloatAnimationCurve* WebCompositorSupportImpl::createFloatAnimationCurve() {
return new WebFloatAnimationCurveImpl(); 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* WebTransformAnimationCurve*
WebCompositorSupportImpl::createTransformAnimationCurve() { WebCompositorSupportImpl::createTransformAnimationCurve() {
return new WebTransformAnimationCurveImpl(); return new WebTransformAnimationCurveImpl();
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop_proxy.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/WebCompositorSupport.h"
#include "third_party/WebKit/public/platform/WebLayer.h" #include "third_party/WebKit/public/platform/WebLayer.h"
#include "third_party/WebKit/public/platform/WebTransformOperations.h" #include "third_party/WebKit/public/platform/WebTransformOperations.h"
...@@ -43,6 +44,12 @@ class WebCompositorSupportImpl : public blink::WebCompositorSupport { ...@@ -43,6 +44,12 @@ class WebCompositorSupportImpl : public blink::WebCompositorSupport {
int animation_id); int animation_id);
virtual blink::WebFilterAnimationCurve* createFilterAnimationCurve(); virtual blink::WebFilterAnimationCurve* createFilterAnimationCurve();
virtual blink::WebFloatAnimationCurve* createFloatAnimationCurve(); 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::WebTransformAnimationCurve* createTransformAnimationCurve();
virtual blink::WebTransformOperations* createTransformOperations(); virtual blink::WebTransformOperations* createTransformOperations();
virtual blink::WebFilterOperations* createFilterOperations(); virtual blink::WebFilterOperations* createFilterOperations();
......
// 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
// 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_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment