0

cc: Remove all remaining use of WebCore Rect/Point/Size types from the compositor.

This change removes all IntPoint/FloatRect/IntSize/etc from the compositor.
There remains an indirect dependency on these types through the
WebCore::Region class, which we wrap but need to replace. However, the wrapper
there hides the WebCore types inside it, so there are now no references to the
types from anywhere else in the compositor.

I went back and forth on how to deal with scroll "positions". The name suggested
that they should be Points, and that the deltas should be Vectors. However this
lent itself to super awkward math at times. In the end, it was much cleaner to
make all scroll "positions" into scroll "offsets" and represent everything as
Vectors.

Covered by existing tests; no change in behaviour.

R=enne
BUG=147395
Relanding: https://codereview.chromium.org/11367080/

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166027 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
danakj@chromium.org
2012-11-05 20:46:13 +00:00
parent 6e3d7e7d27
commit c9c1ebe247
57 changed files with 597 additions and 853 deletions

17
cc/DEPS

@@ -5,22 +5,7 @@ include_rules = [
"+third_party/khronos/GLES2/gl2ext.h", "+third_party/khronos/GLES2/gl2ext.h",
"+ui/gfx", "+ui/gfx",
"+media", "+media",
# http://crbug.com/144542 # http://crbug.com/147395
"+third_party/WebKit/Source/WebCore/platform/graphics/FloatPoint.h",
"+third_party/WebKit/Source/WebCore/platform/graphics/FloatQuad.h",
"+third_party/WebKit/Source/WebCore/platform/graphics/FloatRect.h",
"+third_party/WebKit/Source/WebCore/platform/graphics/FloatSize.h",
"+third_party/WebKit/Source/WebCore/platform/graphics/IntPoint.h",
"+third_party/WebKit/Source/WebCore/platform/graphics/IntRect.h",
"+third_party/WebKit/Source/WebCore/platform/graphics/IntSize.h",
"+Source/WebCore/platform/graphics/FloatPoint.h",
"+Source/WebCore/platform/graphics/FloatQuad.h",
"+Source/WebCore/platform/graphics/FloatRect.h",
"+Source/WebCore/platform/graphics/FloatSize.h",
"+Source/WebCore/platform/graphics/IntPoint.h",
"+Source/WebCore/platform/graphics/IntRect.h",
"+Source/WebCore/platform/graphics/IntSize.h",
# http://crbug.com/144540
"+third_party/WebKit/Source/WebCore/platform/graphics/Region.h", "+third_party/WebKit/Source/WebCore/platform/graphics/Region.h",
"+Source/WebCore/platform/graphics/Region.h", "+Source/WebCore/platform/graphics/Region.h",
# TODO(jamesr): Resolve these # TODO(jamesr): Resolve these

@@ -257,18 +257,10 @@
], ],
'sources': [ 'sources': [
'<@(cc_source_files)', '<@(cc_source_files)',
'stubs/FloatPoint.h',
'stubs/FloatSize.h',
'stubs/IntPoint.h',
'stubs/IntSize.h',
'stubs/Region.h', 'stubs/Region.h',
'stubs/UnitBezier.h', 'stubs/UnitBezier.h',
'stubs/config.h', 'stubs/config.h',
'stubs/float_point.h',
'stubs/float_size.h',
'stubs/int_point.h',
'stubs/int_size.h',
'stubs/unit_bezier.h', 'stubs/unit_bezier.h',
], ],
}, },

@@ -5,9 +5,10 @@
#ifndef CC_GEOMETRY_H_ #ifndef CC_GEOMETRY_H_
#define CC_GEOMETRY_H_ #define CC_GEOMETRY_H_
#include "ui/gfx/size.h" #include "ui/gfx/rect.h"
#include "ui/gfx/rect_f.h"
#include "ui/gfx/vector2d.h"
#include "ui/gfx/vector2d_f.h" #include "ui/gfx/vector2d_f.h"
#include <cmath>
namespace cc { namespace cc {
@@ -16,6 +17,67 @@ inline gfx::Size ClampSizeFromAbove(gfx::Size s, gfx::Size other) {
s.height() < other.height() ? s.height() : other.height()); s.height() < other.height() ? s.height() : other.height());
} }
inline gfx::Vector2dF ClampFromAbove(gfx::Vector2dF s, gfx::Vector2dF max) {
return gfx::Vector2dF(s.x() < max.x() ? s.x() : max.x(),
s.y() < max.y() ? s.y() : max.y());
}
inline gfx::Vector2dF ClampFromBelow(gfx::Vector2dF s, gfx::Vector2dF min) {
return gfx::Vector2dF(s.x() > min.x() ? s.x() : min.x(),
s.y() > min.y() ? s.y() : min.y());
}
inline gfx::Vector2d ClampFromAbove(gfx::Vector2d s, gfx::Vector2d max) {
return gfx::Vector2d(s.x() < max.x() ? s.x() : max.x(),
s.y() < max.y() ? s.y() : max.y());
}
inline gfx::Vector2d ClampFromBelow(gfx::Vector2d s, gfx::Vector2d min) {
return gfx::Vector2d(s.x() > min.x() ? s.x() : min.x(),
s.y() > min.y() ? s.y() : min.y());
}
inline gfx::PointF ClampFromAbove(gfx::PointF s, gfx::PointF max) {
return gfx::PointF(s.x() < max.x() ? s.x() : max.x(),
s.y() < max.y() ? s.y() : max.y());
}
inline gfx::PointF ClampFromBelow(gfx::PointF s, gfx::PointF min) {
return gfx::PointF(s.x() > min.x() ? s.x() : min.x(),
s.y() > min.y() ? s.y() : min.y());
}
inline gfx::Point ClampFromAbove(gfx::Point s, gfx::Point max) {
return gfx::Point(s.x() < max.x() ? s.x() : max.x(),
s.y() < max.y() ? s.y() : max.y());
}
inline gfx::Point ClampFromBelow(gfx::Point s, gfx::Point min) {
return gfx::Point(s.x() > min.x() ? s.x() : min.x(),
s.y() > min.y() ? s.y() : min.y());
}
inline gfx::Point BottomRight(gfx::Rect rect) {
return gfx::Point(rect.right(), rect.bottom());
}
inline gfx::PointF BottomRight(gfx::RectF rect) {
return gfx::PointF(rect.right(), rect.bottom());
}
// Return a vector that is |v| scaled by the given scale factors along each
// axis.
inline gfx::Vector2dF ScaleVector2d(gfx::Vector2dF v, float x_scale, float y_scale) {
gfx::Vector2dF scaled = v;
scaled.Scale(x_scale, y_scale);
return scaled;
}
// Return a vector that is |v| scaled by the given scale factor.
inline gfx::Vector2dF ScaleVector2d(gfx::Vector2dF v, float scale) {
return ScaleVector2d(v, scale, scale);
}
} // namespace cc } // namespace cc
#endif // CC_GEOMETRY_H_ #endif // CC_GEOMETRY_H_

@@ -11,13 +11,11 @@
namespace gfx { namespace gfx {
class Point; class Point;
class Vector2d;
} }
namespace cc { namespace cc {
class IntPoint;
class IntSize;
// The InputHandler is a way for the embedders to interact with // The InputHandler is a way for the embedders to interact with
// the impl thread side of the compositor implementation. // the impl thread side of the compositor implementation.
// //
@@ -36,7 +34,7 @@ public:
// can be scrolled, ScrollOnMainThread if the scroll event should instead be // can be scrolled, ScrollOnMainThread if the scroll event should instead be
// delegated to the main thread, or ScrollIgnored if there is nothing to be // delegated to the main thread, or ScrollIgnored if there is nothing to be
// scrolled at the given coordinates. // scrolled at the given coordinates.
virtual ScrollStatus scrollBegin(const gfx::Point&, ScrollInputType) = 0; virtual ScrollStatus scrollBegin(gfx::Point, ScrollInputType) = 0;
// Scroll the selected layer starting at the given position. If the scroll // Scroll the selected layer starting at the given position. If the scroll
// type given to scrollBegin was a gesture, then the scroll point and delta // type given to scrollBegin was a gesture, then the scroll point and delta
@@ -45,17 +43,17 @@ public:
// layer in the requested direction, its first ancestor layer that can be // layer in the requested direction, its first ancestor layer that can be
// scrolled will be moved instead. Should only be called if scrollBegin() // scrolled will be moved instead. Should only be called if scrollBegin()
// returned ScrollStarted. // returned ScrollStarted.
virtual void scrollBy(const gfx::Point&, const IntSize&) = 0; virtual void scrollBy(gfx::Point, gfx::Vector2d) = 0;
// Stop scrolling the selected layer. Should only be called if scrollBegin() // Stop scrolling the selected layer. Should only be called if scrollBegin()
// returned ScrollStarted. // returned ScrollStarted.
virtual void scrollEnd() = 0; virtual void scrollEnd() = 0;
virtual void pinchGestureBegin() = 0; virtual void pinchGestureBegin() = 0;
virtual void pinchGestureUpdate(float magnifyDelta, const IntPoint& anchor) = 0; virtual void pinchGestureUpdate(float magnifyDelta, gfx::Point anchor) = 0;
virtual void pinchGestureEnd() = 0; virtual void pinchGestureEnd() = 0;
virtual void startPageScaleAnimation(const IntSize& targetPosition, virtual void startPageScaleAnimation(gfx::Vector2d targetOffset,
bool anchorPoint, bool anchorPoint,
float pageScale, float pageScale,
base::TimeTicks startTime, base::TimeTicks startTime,

@@ -408,21 +408,21 @@ bool Layer::transformIsAnimating() const
return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform); return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform);
} }
void Layer::setScrollPosition(const IntPoint& scrollPosition) void Layer::setScrollOffset(gfx::Vector2d scrollOffset)
{ {
if (m_scrollPosition == scrollPosition) if (m_scrollOffset == scrollOffset)
return; return;
m_scrollPosition = scrollPosition; m_scrollOffset = scrollOffset;
if (m_layerScrollClient) if (m_layerScrollClient)
m_layerScrollClient->didScroll(); m_layerScrollClient->didScroll();
setNeedsCommit(); setNeedsCommit();
} }
void Layer::setMaxScrollPosition(const IntSize& maxScrollPosition) void Layer::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
{ {
if (m_maxScrollPosition == maxScrollPosition) if (m_maxScrollOffset == maxScrollOffset)
return; return;
m_maxScrollPosition = maxScrollPosition; m_maxScrollOffset = maxScrollOffset;
setNeedsCommit(); setNeedsCommit();
} }
@@ -587,8 +587,8 @@ void Layer::pushPropertiesTo(LayerImpl* layer)
layer->setFixedToContainerLayer(m_fixedToContainerLayer); layer->setFixedToContainerLayer(m_fixedToContainerLayer);
layer->setPreserves3D(preserves3D()); layer->setPreserves3D(preserves3D());
layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility); layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility);
layer->setScrollPosition(m_scrollPosition); layer->setScrollOffset(m_scrollOffset);
layer->setMaxScrollPosition(m_maxScrollPosition); layer->setMaxScrollOffset(m_maxScrollOffset);
layer->setSublayerTransform(m_sublayerTransform); layer->setSublayerTransform(m_sublayerTransform);
if (!transformIsAnimating()) if (!transformIsAnimating())
layer->setTransform(m_transform); layer->setTransform(m_transform);
@@ -600,7 +600,7 @@ void Layer::pushPropertiesTo(LayerImpl* layer)
layer->setUpdateRect(m_updateRect); layer->setUpdateRect(m_updateRect);
layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta()); layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta());
layer->setSentScrollDelta(IntSize()); layer->setSentScrollDelta(gfx::Vector2d());
layer->setStackingOrderChanged(m_stackingOrderChanged); layer->setStackingOrderChanged(m_stackingOrderChanged);

@@ -5,7 +5,6 @@
#ifndef CC_LAYER_H_ #ifndef CC_LAYER_H_
#define CC_LAYER_H_ #define CC_LAYER_H_
#include "IntPoint.h"
#include "Region.h" #include "Region.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
@@ -129,11 +128,11 @@ public:
const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; } const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; }
void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleContentRect = visibleContentRect; } void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleContentRect = visibleContentRect; }
void setScrollPosition(const IntPoint&); void setScrollOffset(gfx::Vector2d);
const IntPoint& scrollPosition() const { return m_scrollPosition; } gfx::Vector2d scrollOffset() const { return m_scrollOffset; }
void setMaxScrollPosition(const IntSize&); void setMaxScrollOffset(gfx::Vector2d);
const IntSize& maxScrollPosition() const { return m_maxScrollPosition; } gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; }
void setScrollable(bool); void setScrollable(bool);
bool scrollable() const { return m_scrollable; } bool scrollable() const { return m_scrollable; }
@@ -156,7 +155,7 @@ public:
bool forceRenderSurface() const { return m_forceRenderSurface; } bool forceRenderSurface() const { return m_forceRenderSurface; }
void setForceRenderSurface(bool); void setForceRenderSurface(bool);
IntSize scrollDelta() const { return IntSize(); } gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); }
void setImplTransform(const WebKit::WebTransformationMatrix&); void setImplTransform(const WebKit::WebTransformationMatrix&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; } const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
@@ -344,8 +343,8 @@ private:
// Uses layer's content space. // Uses layer's content space.
gfx::Rect m_visibleContentRect; gfx::Rect m_visibleContentRect;
IntPoint m_scrollPosition; gfx::Vector2d m_scrollOffset;
IntSize m_maxScrollPosition; gfx::Vector2d m_maxScrollOffset;
bool m_scrollable; bool m_scrollable;
bool m_shouldScrollOnMainThread; bool m_shouldScrollOnMainThread;
bool m_haveWheelEventHandlers; bool m_haveWheelEventHandlers;

@@ -9,6 +9,7 @@
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "cc/debug_border_draw_quad.h" #include "cc/debug_border_draw_quad.h"
#include "cc/geometry.h"
#include "cc/layer_sorter.h" #include "cc/layer_sorter.h"
#include "cc/math_util.h" #include "cc/math_util.h"
#include "cc/proxy.h" #include "cc/proxy.h"
@@ -179,13 +180,15 @@ ResourceProvider::ResourceId LayerImpl::contentsResourceId() const
return 0; return 0;
} }
FloatSize LayerImpl::scrollBy(const FloatSize& scroll) gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll)
{ {
IntSize minDelta = -toSize(m_scrollPosition); gfx::Vector2dF minDelta = -m_scrollOffset;
IntSize maxDelta = m_maxScrollPosition - toSize(m_scrollPosition); gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset;
// Clamp newDelta so that position + delta stays within scroll bounds. // Clamp newDelta so that position + delta stays within scroll bounds.
FloatSize newDelta = (m_scrollDelta + scroll).expandedTo(minDelta).shrunkTo(maxDelta); gfx::Vector2dF newDelta = (m_scrollDelta + scroll);
FloatSize unscrolled = m_scrollDelta + scroll - newDelta; newDelta = ClampFromBelow(newDelta, minDelta);
newDelta = ClampFromAbove(newDelta, maxDelta);
gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta;
if (m_scrollDelta == newDelta) if (m_scrollDelta == newDelta)
return unscrolled; return unscrolled;
@@ -623,16 +626,16 @@ void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
m_layerPropertyChanged = true; m_layerPropertyChanged = true;
} }
void LayerImpl::setScrollPosition(const IntPoint& scrollPosition) void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset)
{ {
if (m_scrollPosition == scrollPosition) if (m_scrollOffset == scrollOffset)
return; return;
m_scrollPosition = scrollPosition; m_scrollOffset = scrollOffset;
noteLayerPropertyChangedForSubtree(); noteLayerPropertyChangedForSubtree();
} }
void LayerImpl::setScrollDelta(const FloatSize& scrollDelta) void LayerImpl::setScrollDelta(const gfx::Vector2dF& scrollDelta)
{ {
if (m_scrollDelta == scrollDelta) if (m_scrollDelta == scrollDelta)
return; return;
@@ -670,9 +673,9 @@ void LayerImpl::didLoseContext()
{ {
} }
void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition) void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
{ {
m_maxScrollPosition = maxScrollPosition; m_maxScrollOffset = maxScrollOffset;
if (!m_scrollbarAnimationController) if (!m_scrollbarAnimationController)
return; return;

@@ -7,8 +7,6 @@
#include <string> #include <string>
#include "FloatSize.h"
#include "IntPoint.h"
#include "Region.h" #include "Region.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
@@ -187,23 +185,23 @@ public:
float contentsScaleY() const { return m_contentsScaleY; } float contentsScaleY() const { return m_contentsScaleY; }
void setContentsScale(float contentsScaleX, float contentsScaleY); void setContentsScale(float contentsScaleX, float contentsScaleY);
const IntPoint& scrollPosition() const { return m_scrollPosition; } gfx::Vector2d scrollOffset() const { return m_scrollOffset; }
void setScrollPosition(const IntPoint&); void setScrollOffset(gfx::Vector2d);
const IntSize& maxScrollPosition() const {return m_maxScrollPosition; } gfx::Vector2d maxScrollOffset() const {return m_maxScrollOffset; }
void setMaxScrollPosition(const IntSize&); void setMaxScrollOffset(gfx::Vector2d);
const FloatSize& scrollDelta() const { return m_scrollDelta; } const gfx::Vector2dF& scrollDelta() const { return m_scrollDelta; }
void setScrollDelta(const FloatSize&); void setScrollDelta(const gfx::Vector2dF&);
const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; } const WebKit::WebTransformationMatrix& implTransform() const { return m_implTransform; }
void setImplTransform(const WebKit::WebTransformationMatrix& transform); void setImplTransform(const WebKit::WebTransformationMatrix& transform);
const IntSize& sentScrollDelta() const { return m_sentScrollDelta; } const gfx::Vector2d& sentScrollDelta() const { return m_sentScrollDelta; }
void setSentScrollDelta(const IntSize& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; } void setSentScrollDelta(const gfx::Vector2d& sentScrollDelta) { m_sentScrollDelta = sentScrollDelta; }
// Returns the delta of the scroll that was outside of the bounds of the initial scroll // Returns the delta of the scroll that was outside of the bounds of the initial scroll
FloatSize scrollBy(const FloatSize& scroll); gfx::Vector2dF scrollBy(const gfx::Vector2dF& scroll);
bool scrollable() const { return m_scrollable; } bool scrollable() const { return m_scrollable; }
void setScrollable(bool scrollable) { m_scrollable = scrollable; } void setScrollable(bool scrollable) { m_scrollable = scrollable; }
@@ -316,7 +314,7 @@ private:
gfx::Size m_contentBounds; gfx::Size m_contentBounds;
float m_contentsScaleX; float m_contentsScaleX;
float m_contentsScaleY; float m_contentsScaleY;
IntPoint m_scrollPosition; gfx::Vector2d m_scrollOffset;
bool m_scrollable; bool m_scrollable;
bool m_shouldScrollOnMainThread; bool m_shouldScrollOnMainThread;
bool m_haveWheelEventHandlers; bool m_haveWheelEventHandlers;
@@ -356,9 +354,9 @@ private:
// This is true if the layer should be fixed to the closest ancestor container. // This is true if the layer should be fixed to the closest ancestor container.
bool m_fixedToContainerLayer; bool m_fixedToContainerLayer;
FloatSize m_scrollDelta; gfx::Vector2dF m_scrollDelta;
IntSize m_sentScrollDelta; gfx::Vector2d m_sentScrollDelta;
IntSize m_maxScrollPosition; gfx::Vector2d m_maxScrollOffset;
WebKit::WebTransformationMatrix m_implTransform; WebKit::WebTransformationMatrix m_implTransform;
// The layer whose coordinate space this layer draws into. This can be // The layer whose coordinate space this layer draws into. This can be

@@ -76,6 +76,7 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
float arbitraryNumber = 0.352f; float arbitraryNumber = 0.352f;
gfx::Size arbitrarySize = gfx::Size(111, 222); gfx::Size arbitrarySize = gfx::Size(111, 222);
gfx::Point arbitraryPoint = gfx::Point(333, 444); gfx::Point arbitraryPoint = gfx::Point(333, 444);
gfx::Vector2d arbitraryVector2d = gfx::Vector2d(111, 222);
gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize); gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize);
gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5.678f)); gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5.678f));
SkColor arbitraryColor = SkColorSetRGB(10, 20, 30); SkColor arbitraryColor = SkColorSetRGB(10, 20, 30);
@@ -94,7 +95,7 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawableContentRect(arbitraryRect)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawableContentRect(arbitraryRect));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUpdateRect(arbitraryRectF)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUpdateRect(arbitraryRectF));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setVisibleContentRect(arbitraryRect)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setVisibleContentRect(arbitraryRect));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollPosition(cc::IntSize(arbitrarySize))); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollOffset(arbitraryVector2d));
// Changing these properties affects the entire subtree of layers. // Changing these properties affects the entire subtree of layers.
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryPointF)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryPointF));
@@ -109,9 +110,9 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPosition(arbitraryPointF)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPosition(arbitraryPointF));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPreserves3D(true)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPreserves3D(true));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setDoubleSided(false)); // constructor initializes it to "true". EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setDoubleSided(false)); // constructor initializes it to "true".
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->scrollBy(cc::IntSize(arbitrarySize))); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->scrollBy(arbitraryVector2d));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollDelta(cc::IntSize())); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollDelta(gfx::Vector2d()));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollPosition(cc::IntPoint(arbitraryPoint))); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollOffset(arbitraryVector2d));
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setImplTransform(arbitraryTransform)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setImplTransform(arbitraryTransform));
// Changing these properties only affects the layer itself. // Changing these properties only affects the layer itself.
@@ -149,8 +150,8 @@ TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPreserves3D(true)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPreserves3D(true));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTransform(arbitraryTransform)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTransform(arbitraryTransform));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDoubleSided(false)); // constructor initializes it to "true". EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDoubleSided(false)); // constructor initializes it to "true".
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollDelta(cc::IntSize())); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollDelta(gfx::Vector2d()));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollPosition(cc::IntPoint(arbitraryPoint))); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollOffset(arbitraryVector2d));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setImplTransform(arbitraryTransform)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setImplTransform(arbitraryTransform));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentBounds(arbitrarySize)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentBounds(arbitrarySize));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentsScale(arbitraryNumber, arbitraryNumber)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentsScale(arbitraryNumber, arbitraryNumber));

@@ -451,9 +451,9 @@ void LayerTreeHost::setVisible(bool visible)
m_proxy->setVisible(visible); m_proxy->setVisible(visible);
} }
void LayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) void LayerTreeHost::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
{ {
m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, duration); m_proxy->startPageScaleAnimation(targetOffset, useAnchor, scale, duration);
} }
void LayerTreeHost::loseContext(int numTimes) void LayerTreeHost::loseContext(int numTimes)
@@ -694,7 +694,7 @@ void LayerTreeHost::applyScrollAndScale(const ScrollAndScaleSet& info)
return; return;
Layer* rootScrollLayer = findFirstScrollableLayer(m_rootLayer.get()); Layer* rootScrollLayer = findFirstScrollableLayer(m_rootLayer.get());
IntSize rootScrollDelta; gfx::Vector2d rootScrollDelta;
for (size_t i = 0; i < info.scrolls.size(); ++i) { for (size_t i = 0; i < info.scrolls.size(); ++i) {
Layer* layer = LayerTreeHostCommon::findLayerInSubtree(m_rootLayer.get(), info.scrolls[i].layerId); Layer* layer = LayerTreeHostCommon::findLayerInSubtree(m_rootLayer.get(), info.scrolls[i].layerId);
@@ -703,9 +703,9 @@ void LayerTreeHost::applyScrollAndScale(const ScrollAndScaleSet& info)
if (layer == rootScrollLayer) if (layer == rootScrollLayer)
rootScrollDelta += info.scrolls[i].scrollDelta; rootScrollDelta += info.scrolls[i].scrollDelta;
else else
layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].scrollDelta); layer->setScrollOffset(layer->scrollOffset() + info.scrolls[i].scrollDelta);
} }
if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1) if (!rootScrollDelta.IsZero() || info.pageScaleDelta != 1)
m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta); m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta);
} }

@@ -190,7 +190,7 @@ public:
bool visible() const { return m_visible; } bool visible() const { return m_visible; }
void setVisible(bool); void setVisible(bool);
void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration); void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
void applyScrollAndScale(const ScrollAndScaleSet&); void applyScrollAndScale(const ScrollAndScaleSet&);
gfx::PointF adjustEventPointForPinchZoom(const gfx::PointF&) const; gfx::PointF adjustEventPointForPinchZoom(const gfx::PointF&) const;

@@ -7,13 +7,16 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
namespace gfx {
class Vector2d;
}
namespace WebKit { namespace WebKit {
class WebCompositorOutputSurface; class WebCompositorOutputSurface;
} }
namespace cc { namespace cc {
class InputHandler; class InputHandler;
class IntSize;
class LayerTreeHostClient { class LayerTreeHostClient {
public: public:
@@ -22,7 +25,7 @@ public:
virtual void didBeginFrame() = 0; virtual void didBeginFrame() = 0;
virtual void animate(double frameBeginTime) = 0; virtual void animate(double frameBeginTime) = 0;
virtual void layout() = 0; virtual void layout() = 0;
virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0; virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) = 0;
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() = 0; virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() = 0;
virtual void didRecreateOutputSurface(bool success) = 0; virtual void didRecreateOutputSurface(bool success) = 0;
virtual scoped_ptr<InputHandler> createInputHandler() = 0; virtual scoped_ptr<InputHandler> createInputHandler() = 0;

@@ -289,7 +289,7 @@ WebTransformationMatrix computeScrollCompensationForThisLayer(LayerImpl* scrolli
partialLayerOriginTransform.multiply(scrollingLayer->implTransform()); partialLayerOriginTransform.multiply(scrollingLayer->implTransform());
WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3 WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3
scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().width(), scrollingLayer->scrollDelta().height()); // Step 2 scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2
scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse()); // Step 1 scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse()); // Step 1
return scrollCompensationForThisLayer; return scrollCompensationForThisLayer;
} }
@@ -320,7 +320,7 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
// //
// Avoid the overheads (including stack allocation and matrix initialization/copy) if we know that the scroll compensation doesn't need to be reset or adjusted. // Avoid the overheads (including stack allocation and matrix initialization/copy) if we know that the scroll compensation doesn't need to be reset or adjusted.
if (!layer->isContainerForFixedPositionLayers() && layer->scrollDelta().isZero() && !layer->renderSurface()) if (!layer->isContainerForFixedPositionLayers() && layer->scrollDelta().IsZero() && !layer->renderSurface())
return currentScrollCompensationMatrix; return currentScrollCompensationMatrix;
// Start as identity matrix. // Start as identity matrix.
@@ -332,7 +332,7 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerImpl* la
// If the current layer has a non-zero scrollDelta, then we should compute its local scrollCompensation // If the current layer has a non-zero scrollDelta, then we should compute its local scrollCompensation
// and accumulate it to the nextScrollCompensationMatrix. // and accumulate it to the nextScrollCompensationMatrix.
if (!layer->scrollDelta().isZero()) { if (!layer->scrollDelta().IsZero()) {
WebTransformationMatrix scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix); WebTransformationMatrix scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix);
nextScrollCompensationMatrix.multiply(scrollCompensationForThisLayer); nextScrollCompensationMatrix.multiply(scrollCompensationForThisLayer);
} }
@@ -491,7 +491,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
gfx::Size bounds = layer->bounds(); gfx::Size bounds = layer->bounds();
gfx::PointF anchorPoint = layer->anchorPoint(); gfx::PointF anchorPoint = layer->anchorPoint();
gfx::PointF position = layer->position() - gfx::Vector2d(layer->scrollDelta().width(), layer->scrollDelta().height()); gfx::PointF position = layer->position() - layer->scrollDelta();
WebTransformationMatrix layerLocalTransform; WebTransformationMatrix layerLocalTransform;
// LT = Tr[origin] * Tr[origin2anchor] // LT = Tr[origin] * Tr[origin2anchor]

@@ -9,7 +9,7 @@
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/scoped_ptr_vector.h" #include "cc/scoped_ptr_vector.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "IntSize.h" #include "ui/gfx/vector2d.h"
#include <public/WebTransformationMatrix.h> #include <public/WebTransformationMatrix.h>
namespace cc { namespace cc {
@@ -46,7 +46,7 @@ public:
struct ScrollUpdateInfo { struct ScrollUpdateInfo {
int layerId; int layerId;
IntSize scrollDelta; gfx::Vector2d scrollDelta;
}; };
}; };

@@ -801,7 +801,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
grandChild->setFixedToContainerLayer(true); grandChild->setFixedToContainerLayer(true);
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform; WebTransformationMatrix expectedChildTransform;
@@ -811,7 +811,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
// Case 2: scrollDelta of 10, 10 // Case 2: scrollDelta of 10, 10
child->setScrollDelta(IntSize(10, 10)); child->setScrollDelta(gfx::Vector2d(10, 10));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected. // Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected.
@@ -847,7 +847,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
grandChild->setFixedToContainerLayer(true); grandChild->setFixedToContainerLayer(true);
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform; WebTransformationMatrix expectedChildTransform;
@@ -859,7 +859,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
// Case 2: scrollDelta of 10, 20 // Case 2: scrollDelta of 10, 20
child->setScrollDelta(IntSize(10, 20)); child->setScrollDelta(gfx::Vector2d(10, 20));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// The child should be affected by scrollDelta, but the fixed position grandChild should not be affected. // The child should be affected by scrollDelta, but the fixed position grandChild should not be affected.
@@ -887,7 +887,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
greatGrandChild->setFixedToContainerLayer(true); greatGrandChild->setFixedToContainerLayer(true);
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform; WebTransformationMatrix expectedChildTransform;
@@ -901,7 +901,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
// Case 2: scrollDelta of 10, 10 // Case 2: scrollDelta of 10, 10
child->setScrollDelta(IntSize(10, 10)); child->setScrollDelta(gfx::Vector2d(10, 10));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
@@ -936,7 +936,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the renderTarget. greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the renderTarget.
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform; WebTransformationMatrix expectedChildTransform;
@@ -954,7 +954,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
// Case 2: scrollDelta of 10, 20 // Case 2: scrollDelta of 10, 20
child->setScrollDelta(IntSize(10, 20)); child->setScrollDelta(gfx::Vector2d(10, 20));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
@@ -998,7 +998,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the renderTarget. greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the renderTarget.
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform; WebTransformationMatrix expectedChildTransform;
@@ -1016,8 +1016,8 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
// Case 2: scrollDelta of 10, 20 // Case 2: scrollDelta of 10, 20
child->setScrollDelta(IntSize(10, 0)); child->setScrollDelta(gfx::Vector2d(10, 0));
grandChild->setScrollDelta(IntSize(5, 0)); grandChild->setScrollDelta(gfx::Vector2d(5, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
@@ -1061,7 +1061,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
grandChild->setTransform(rotationAboutZ); grandChild->setTransform(rotationAboutZ);
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform; WebTransformationMatrix expectedChildTransform;
@@ -1077,7 +1077,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
// Case 2: scrollDelta of 10, 30 // Case 2: scrollDelta of 10, 30
child->setScrollDelta(IntSize(10, 30)); child->setScrollDelta(gfx::Vector2d(10, 30));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// Here the grandChild remains unchanged, because it scrolls along with the // Here the grandChild remains unchanged, because it scrolls along with the
@@ -1153,7 +1153,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
greatGrandChild->setTransform(rotationAboutZ); greatGrandChild->setTransform(rotationAboutZ);
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform; WebTransformationMatrix expectedChildTransform;
@@ -1182,7 +1182,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPositionChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPositionChild->drawTransform());
// Case 2: scrollDelta of 10, 30 // Case 2: scrollDelta of 10, 30
child->setScrollDelta(IntSize(10, 30)); child->setScrollDelta(gfx::Vector2d(10, 30));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
expectedChildTransform.makeIdentity(); expectedChildTransform.makeIdentity();
@@ -1239,7 +1239,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
grandChild->setDrawsContent(true); grandChild->setDrawsContent(true);
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedSurfaceDrawTransform; WebTransformationMatrix expectedSurfaceDrawTransform;
@@ -1252,7 +1252,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
// Case 2: scrollDelta of 10, 10 // Case 2: scrollDelta of 10, 10
child->setScrollDelta(IntSize(10, 10)); child->setScrollDelta(gfx::Vector2d(10, 10));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// The surface is translated by scrollDelta, the child transform doesn't change // The surface is translated by scrollDelta, the child transform doesn't change
@@ -1287,7 +1287,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
grandChild->setIsContainerForFixedPositionLayers(true); grandChild->setIsContainerForFixedPositionLayers(true);
// Case 1: scrollDelta of 0, 0 // Case 1: scrollDelta of 0, 0
child->setScrollDelta(IntSize(0, 0)); child->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix expectedChildTransform; WebTransformationMatrix expectedChildTransform;
@@ -1296,7 +1296,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
// Case 2: scrollDelta of 10, 10 // Case 2: scrollDelta of 10, 10
child->setScrollDelta(IntSize(10, 10)); child->setScrollDelta(gfx::Vector2d(10, 10));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected. // Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected.
@@ -1324,7 +1324,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
grandChild->setFixedToContainerLayer(true); grandChild->setFixedToContainerLayer(true);
// Case 1: root scrollDelta of 0, 0 // Case 1: root scrollDelta of 0, 0
root->setScrollDelta(IntSize(0, 0)); root->setScrollDelta(gfx::Vector2d(0, 0));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
WebTransformationMatrix identityMatrix; WebTransformationMatrix identityMatrix;
@@ -1333,7 +1333,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()); EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform());
// Case 2: root scrollDelta of 10, 10 // Case 2: root scrollDelta of 10, 10
root->setScrollDelta(IntSize(10, 20)); root->setScrollDelta(gfx::Vector2d(10, 20));
executeCalculateDrawTransformsAndVisibility(root.get()); executeCalculateDrawTransformsAndVisibility(root.get());
// The child is affected by scrollDelta, but it is already implcitly accounted for by // The child is affected by scrollDelta, but it is already implcitly accounted for by

@@ -14,6 +14,7 @@
#include "cc/delay_based_time_source.h" #include "cc/delay_based_time_source.h"
#include "cc/font_atlas.h" #include "cc/font_atlas.h"
#include "cc/frame_rate_counter.h" #include "cc/frame_rate_counter.h"
#include "cc/geometry.h"
#include "cc/gl_renderer.h" #include "cc/gl_renderer.h"
#include "cc/heads_up_display_layer_impl.h" #include "cc/heads_up_display_layer_impl.h"
#include "cc/layer_iterator.h" #include "cc/layer_iterator.h"
@@ -32,6 +33,7 @@
#include "cc/software_renderer.h" #include "cc/software_renderer.h"
#include "cc/texture_uploader.h" #include "cc/texture_uploader.h"
#include "ui/gfx/size_conversions.h" #include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
#include <algorithm> #include <algorithm>
using WebKit::WebTransformationMatrix; using WebKit::WebTransformationMatrix;
@@ -101,12 +103,12 @@ gfx::RectF PinchZoomViewport::bounds() const
scaledViewportSize = scaledViewportSize.Scale(1 / totalPageScaleFactor()); scaledViewportSize = scaledViewportSize.Scale(1 / totalPageScaleFactor());
gfx::RectF bounds(gfx::PointF(), scaledViewportSize); gfx::RectF bounds(gfx::PointF(), scaledViewportSize);
bounds.set_origin(m_pinchViewportScrollDelta); bounds.Offset(m_pinchViewportScrollDelta);
return bounds; return bounds;
} }
FloatSize PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta) gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
{ {
gfx::Vector2dF overflow; gfx::Vector2dF overflow;
gfx::RectF pinchedBounds = bounds(); gfx::RectF pinchedBounds = bounds();
@@ -131,9 +133,9 @@ FloatSize PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height());
pinchedBounds.Offset(0, m_layoutViewportSize.height() - pinchedBounds.bottom()); pinchedBounds.Offset(0, m_layoutViewportSize.height() - pinchedBounds.bottom());
} }
m_pinchViewportScrollDelta = cc::FloatPoint(pinchedBounds.origin()); m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin();
return cc::FloatSize(overflow); return overflow;
} }
WebTransformationMatrix PinchZoomViewport::implTransform() const WebTransformationMatrix PinchZoomViewport::implTransform() const
@@ -249,7 +251,7 @@ void LayerTreeHostImpl::commitComplete()
TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete"); TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete");
// Recompute max scroll position; must be after layer content bounds are // Recompute max scroll position; must be after layer content bounds are
// updated. // updated.
updateMaxScrollPosition(); updateMaxScrollOffset();
m_client->sendManagedMemoryStats(); m_client->sendManagedMemoryStats();
} }
@@ -290,26 +292,26 @@ void LayerTreeHostImpl::animate(base::TimeTicks monotonicTime, base::Time wallCl
animateScrollbars(monotonicTime); animateScrollbars(monotonicTime);
} }
void LayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration)
{ {
if (!m_rootScrollLayerImpl) if (!m_rootScrollLayerImpl)
return; return;
IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta()); gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootScrollLayerImpl->scrollDelta();
scrollTotal.scale(m_pinchZoomViewport.pageScaleDelta()); scrollTotal.Scale(m_pinchZoomViewport.pageScaleDelta());
float scaleTotal = m_pinchZoomViewport.totalPageScaleFactor(); float scaleTotal = m_pinchZoomViewport.totalPageScaleFactor();
gfx::Size scaledContentSize = gfx::ToFlooredSize(contentSize().Scale(m_pinchZoomViewport.pageScaleDelta())); gfx::Size scaledContentSize = gfx::ToFlooredSize(contentSize().Scale(m_pinchZoomViewport.pageScaleDelta()));
double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF(); double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF();
m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, scaleTotal, cc::IntSize(m_deviceViewportSize), scaledContentSize, startTimeSeconds); m_pageScaleAnimation = PageScaleAnimation::create(gfx::ToFlooredVector2d(scrollTotal), scaleTotal, m_deviceViewportSize, scaledContentSize, startTimeSeconds);
if (anchorPoint) { if (anchorPoint) {
IntSize windowAnchor(targetPosition); gfx::Vector2dF windowAnchor = targetOffset;
windowAnchor.scale(scaleTotal / pageScale); windowAnchor.Scale(scaleTotal / pageScale);
windowAnchor -= scrollTotal; windowAnchor -= scrollTotal;
m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration.InSecondsF()); m_pageScaleAnimation->zoomWithAnchor(gfx::ToFlooredVector2d(windowAnchor), pageScale, duration.InSecondsF());
} else } else
m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration.InSecondsF()); m_pageScaleAnimation->zoomTo(targetOffset, pageScale, duration.InSecondsF());
m_client->setNeedsRedrawOnImplThread(); m_client->setNeedsRedrawOnImplThread();
m_client->setNeedsCommitOnImplThread(); m_client->setNeedsCommitOnImplThread();
@@ -890,9 +892,9 @@ void LayerTreeHostImpl::setViewportSize(const gfx::Size& layoutViewportSize, con
m_layoutViewportSize = layoutViewportSize; m_layoutViewportSize = layoutViewportSize;
m_deviceViewportSize = deviceViewportSize; m_deviceViewportSize = deviceViewportSize;
m_pinchZoomViewport.setLayoutViewportSize(FloatSize(layoutViewportSize)); m_pinchZoomViewport.setLayoutViewportSize(layoutViewportSize);
updateMaxScrollPosition(); updateMaxScrollOffset();
if (m_renderer) if (m_renderer)
m_renderer->viewportChanged(); m_renderer->viewportChanged();
@@ -907,8 +909,8 @@ static void adjustScrollsForPageScaleChange(LayerImpl* layerImpl, float pageScal
if (layerImpl->scrollable()) { if (layerImpl->scrollable()) {
// We need to convert impl-side scroll deltas to pageScale space. // We need to convert impl-side scroll deltas to pageScale space.
FloatSize scrollDelta = layerImpl->scrollDelta(); gfx::Vector2dF scrollDelta = layerImpl->scrollDelta();
scrollDelta.scale(pageScaleChange); scrollDelta.Scale(pageScaleChange);
layerImpl->setScrollDelta(scrollDelta); layerImpl->setScrollDelta(scrollDelta);
} }
@@ -922,7 +924,7 @@ void LayerTreeHostImpl::setDeviceScaleFactor(float deviceScaleFactor)
return; return;
m_deviceScaleFactor = deviceScaleFactor; m_deviceScaleFactor = deviceScaleFactor;
updateMaxScrollPosition(); updateMaxScrollOffset();
} }
float LayerTreeHostImpl::pageScaleFactor() const float LayerTreeHostImpl::pageScaleFactor() const
@@ -952,10 +954,10 @@ void LayerTreeHostImpl::setPageScaleDelta(float delta)
{ {
m_pinchZoomViewport.setPageScaleDelta(delta); m_pinchZoomViewport.setPageScaleDelta(delta);
updateMaxScrollPosition(); updateMaxScrollOffset();
} }
void LayerTreeHostImpl::updateMaxScrollPosition() void LayerTreeHostImpl::updateMaxScrollOffset()
{ {
if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size()) if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size())
return; return;
@@ -981,14 +983,14 @@ void LayerTreeHostImpl::updateMaxScrollPosition()
viewBounds = viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta()); viewBounds = viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
} }
IntSize maxScroll = cc::IntSize(contentBounds) - expandedIntSize(cc::FloatSize(viewBounds)); gfx::Vector2dF maxScroll = BottomRight(gfx::Rect(contentBounds)) - BottomRight(gfx::RectF(viewBounds));
maxScroll.scale(1 / m_deviceScaleFactor); maxScroll.Scale(1 / m_deviceScaleFactor);
// The viewport may be larger than the contents in some cases, such as // The viewport may be larger than the contents in some cases, such as
// having a vertical scrollbar but no horizontal overflow. // having a vertical scrollbar but no horizontal overflow.
maxScroll.clampNegativeToZero(); maxScroll = ClampFromBelow(maxScroll, gfx::Vector2dF());
m_rootScrollLayerImpl->setMaxScrollPosition(maxScroll); m_rootScrollLayerImpl->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll));
} }
void LayerTreeHostImpl::setNeedsRedraw() void LayerTreeHostImpl::setNeedsRedraw()
@@ -1017,7 +1019,7 @@ bool LayerTreeHostImpl::ensureRenderSurfaceLayerList()
return m_renderSurfaceLayerList.size(); return m_renderSurfaceLayerList.size();
} }
InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(const gfx::Point& viewportPoint, InputHandlerClient::ScrollInputType type) InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewportPoint, InputHandlerClient::ScrollInputType type)
{ {
TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin");
@@ -1070,7 +1072,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(const gfx::Point
return ScrollIgnored; return ScrollIgnored;
} }
static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, const gfx::PointF& viewportPoint, const FloatSize& viewportDelta) static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::Vector2dF viewportDelta)
{ {
// Layers with non-invertible screen space transforms should not have passed the scroll hit // Layers with non-invertible screen space transforms should not have passed the scroll hit
// test in the first place. // test in the first place.
@@ -1079,8 +1081,8 @@ static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport,
gfx::PointF screenSpacePoint = viewportPoint.Scale(scaleFromViewportToScreenSpace); gfx::PointF screenSpacePoint = viewportPoint.Scale(scaleFromViewportToScreenSpace);
FloatSize screenSpaceDelta = viewportDelta; gfx::Vector2dF screenSpaceDelta = viewportDelta;
screenSpaceDelta.scale(scaleFromViewportToScreenSpace, scaleFromViewportToScreenSpace); screenSpaceDelta.Scale(scaleFromViewportToScreenSpace);
// First project the scroll start and end points to local layer space to find the scroll delta // First project the scroll start and end points to local layer space to find the scroll delta
// in layer coordinates. // in layer coordinates.
@@ -1093,7 +1095,7 @@ static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport,
DCHECK(!startClipped); DCHECK(!startClipped);
DCHECK(!endClipped); DCHECK(!endClipped);
if (startClipped || endClipped) if (startClipped || endClipped)
return FloatSize(); return gfx::Vector2dF();
// localStartPoint and localEndPoint are in content space but we want to move them to layer space for scrolling. // localStartPoint and localEndPoint are in content space but we want to move them to layer space for scrolling.
float widthScale = 1 / layerImpl.contentsScaleX(); float widthScale = 1 / layerImpl.contentsScaleX();
@@ -1102,8 +1104,8 @@ static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport,
localEndPoint = localEndPoint.Scale(widthScale, heightScale); localEndPoint = localEndPoint.Scale(widthScale, heightScale);
// Apply the scroll delta. // Apply the scroll delta.
FloatSize previousDelta(layerImpl.scrollDelta()); gfx::Vector2dF previousDelta = layerImpl.scrollDelta();
FloatSize unscrolled = layerImpl.scrollBy(cc::FloatSize(localEndPoint - localStartPoint)); gfx::Vector2dF unscrolled = layerImpl.scrollBy(localEndPoint - localStartPoint);
if (viewport) if (viewport)
viewport->applyScroll(unscrolled); viewport->applyScroll(unscrolled);
@@ -1116,32 +1118,32 @@ static FloatSize scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewport,
gfx::PointF actualScreenSpaceEndPoint = MathUtil::mapPoint(layerImpl.screenSpaceTransform(), actualLocalContentEndPoint, endClipped); gfx::PointF actualScreenSpaceEndPoint = MathUtil::mapPoint(layerImpl.screenSpaceTransform(), actualLocalContentEndPoint, endClipped);
DCHECK(!endClipped); DCHECK(!endClipped);
if (endClipped) if (endClipped)
return FloatSize(); return gfx::Vector2dF();
gfx::PointF actualViewportEndPoint = actualScreenSpaceEndPoint.Scale(1 / scaleFromViewportToScreenSpace); gfx::PointF actualViewportEndPoint = actualScreenSpaceEndPoint.Scale(1 / scaleFromViewportToScreenSpace);
return cc::FloatSize(actualViewportEndPoint - viewportPoint); return actualViewportEndPoint - viewportPoint;
} }
static FloatSize scrollLayerWithLocalDelta(LayerImpl& layerImpl, const FloatSize& localDelta) static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vector2dF localDelta)
{ {
FloatSize previousDelta(layerImpl.scrollDelta()); gfx::Vector2dF previousDelta(layerImpl.scrollDelta());
layerImpl.scrollBy(localDelta); layerImpl.scrollBy(localDelta);
return layerImpl.scrollDelta() - previousDelta; return layerImpl.scrollDelta() - previousDelta;
} }
void LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, const IntSize& scrollDelta) void LayerTreeHostImpl::scrollBy(gfx::Point viewportPoint, gfx::Vector2d scrollDelta)
{ {
TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy");
if (!m_currentlyScrollingLayerImpl) if (!m_currentlyScrollingLayerImpl)
return; return;
FloatSize pendingDelta(scrollDelta); gfx::Vector2dF pendingDelta = scrollDelta;
for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerImpl = layerImpl->parent()) { for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerImpl = layerImpl->parent()) {
if (!layerImpl->scrollable()) if (!layerImpl->scrollable())
continue; continue;
PinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_pinchZoomViewport : 0; PinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_pinchZoomViewport : 0;
FloatSize appliedDelta; gfx::Vector2dF appliedDelta;
if (m_scrollDeltaIsInViewportSpace) { if (m_scrollDeltaIsInViewportSpace) {
float scaleFromViewportToScreenSpace = m_deviceScaleFactor; float scaleFromViewportToScreenSpace = m_deviceScaleFactor;
appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImpl, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta); appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImpl, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta);
@@ -1150,27 +1152,27 @@ void LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, const IntSize&
// If the layer wasn't able to move, try the next one in the hierarchy. // If the layer wasn't able to move, try the next one in the hierarchy.
float moveThresholdSquared = 0.1f * 0.1f; float moveThresholdSquared = 0.1f * 0.1f;
if (appliedDelta.diagonalLengthSquared() < moveThresholdSquared) if (appliedDelta.LengthSquared() < moveThresholdSquared)
continue; continue;
// If the applied delta is within 45 degrees of the input delta, bail out to make it easier // If the applied delta is within 45 degrees of the input delta, bail out to make it easier
// to scroll just one layer in one direction without affecting any of its parents. // to scroll just one layer in one direction without affecting any of its parents.
float angleThreshold = 45; float angleThreshold = 45;
if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) {
pendingDelta = FloatSize(); pendingDelta = gfx::Vector2d();
break; break;
} }
// Allow further movement only on an axis perpendicular to the direction in which the layer // Allow further movement only on an axis perpendicular to the direction in which the layer
// moved. // moved.
FloatSize perpendicularAxis(-appliedDelta.height(), appliedDelta.width()); gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x());
pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis);
if (flooredIntSize(pendingDelta).isZero()) if (gfx::ToFlooredVector2d(pendingDelta).IsZero())
break; break;
} }
if (!scrollDelta.isZero() && flooredIntSize(pendingDelta).isEmpty()) { if (!scrollDelta.IsZero() && gfx::ToFlooredVector2d(pendingDelta).IsZero()) {
m_client->setNeedsCommitOnImplThread(); m_client->setNeedsCommitOnImplThread();
m_client->setNeedsRedrawOnImplThread(); m_client->setNeedsRedrawOnImplThread();
} }
@@ -1190,42 +1192,40 @@ void LayerTreeHostImpl::scrollEnd()
void LayerTreeHostImpl::pinchGestureBegin() void LayerTreeHostImpl::pinchGestureBegin()
{ {
m_pinchGestureActive = true; m_pinchGestureActive = true;
m_previousPinchAnchor = IntPoint(); m_previousPinchAnchor = gfx::Point();
if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationController()) if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationController())
m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureBegin(); m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureBegin();
} }
void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor)
const IntPoint& anchor)
{ {
TRACE_EVENT0("cc", "LayerTreeHostImpl::pinchGestureUpdate"); TRACE_EVENT0("cc", "LayerTreeHostImpl::pinchGestureUpdate");
if (!m_rootScrollLayerImpl) if (!m_rootScrollLayerImpl)
return; return;
if (m_previousPinchAnchor == IntPoint::zero()) if (m_previousPinchAnchor == gfx::Point())
m_previousPinchAnchor = anchor; m_previousPinchAnchor = anchor;
// Keep the center-of-pinch anchor specified by (x, y) in a stable // Keep the center-of-pinch anchor specified by (x, y) in a stable
// position over the course of the magnify. // position over the course of the magnify.
float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta();
FloatPoint previousScaleAnchor(m_previousPinchAnchor.x() / pageScaleDelta, gfx::PointF previousScaleAnchor = m_previousPinchAnchor.Scale(1 / pageScaleDelta);
m_previousPinchAnchor.y() / pageScaleDelta);
setPageScaleDelta(pageScaleDelta * magnifyDelta); setPageScaleDelta(pageScaleDelta * magnifyDelta);
pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); pageScaleDelta = m_pinchZoomViewport.pageScaleDelta();
FloatPoint newScaleAnchor(anchor.x() / pageScaleDelta, anchor.y() / pageScaleDelta); gfx::PointF newScaleAnchor = anchor.Scale(1 / pageScaleDelta);
FloatSize move = previousScaleAnchor - newScaleAnchor; gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor;
m_previousPinchAnchor = anchor; m_previousPinchAnchor = anchor;
if (Settings::pageScalePinchZoomEnabled()) { if (Settings::pageScalePinchZoomEnabled()) {
// Compute the application of the delta with respect to the current page zoom of the page. // Compute the application of the delta with respect to the current page zoom of the page.
move.scale(1 / (m_pinchZoomViewport.pageScaleFactor() * m_deviceScaleFactor)); move.Scale(1 / (m_pinchZoomViewport.pageScaleFactor() * m_deviceScaleFactor));
} }
FloatSize scrollOverflow = Settings::pageScalePinchZoomEnabled() ? m_pinchZoomViewport.applyScroll(move) : move; gfx::Vector2dF scrollOverflow = Settings::pageScalePinchZoomEnabled() ? m_pinchZoomViewport.applyScroll(move) : move;
m_rootScrollLayerImpl->scrollBy(roundedIntSize(scrollOverflow)); m_rootScrollLayerImpl->scrollBy(scrollOverflow);
if (m_rootScrollLayerImpl->scrollbarAnimationController()) if (m_rootScrollLayerImpl->scrollbarAnimationController())
m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUpdate(); m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUpdate();
@@ -1247,9 +1247,9 @@ void LayerTreeHostImpl::pinchGestureEnd()
void LayerTreeHostImpl::computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo) void LayerTreeHostImpl::computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo)
{ {
float pageScale = m_pageScaleAnimation->finalPageScale(); float pageScale = m_pageScaleAnimation->finalPageScale();
IntSize scrollOffset = m_pageScaleAnimation->finalScrollOffset(); gfx::Vector2dF scrollOffset = m_pageScaleAnimation->finalScrollOffset();
scrollOffset.scale(m_pinchZoomViewport.pageScaleFactor() / pageScale); scrollOffset.Scale(m_pinchZoomViewport.pageScaleFactor() / pageScale);
makeScrollAndScaleSet(scrollInfo, scrollOffset, pageScale); makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollOffset), pageScale);
} }
void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo) void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo)
@@ -1266,31 +1266,32 @@ void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo)
// Compute where the scroll offset/page scale would be if fully pinch-zoomed // Compute where the scroll offset/page scale would be if fully pinch-zoomed
// out from the anchor point. // out from the anchor point.
IntSize scrollBegin = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta()); gfx::Vector2dF scrollBegin = m_rootScrollLayerImpl->scrollOffset() + m_rootScrollLayerImpl->scrollDelta();
scrollBegin.scale(m_pinchZoomViewport.pageScaleDelta()); scrollBegin.Scale(m_pinchZoomViewport.pageScaleDelta());
float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor(); float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor();
float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pinchZoomViewport.pageScaleFactor(); float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pinchZoomViewport.pageScaleFactor();
gfx::SizeF scaledContentsSize = contentSize().Scale(pageScaleDeltaToSend); gfx::SizeF scaledContentsSize = contentSize().Scale(pageScaleDeltaToSend);
FloatSize anchor = toSize(m_previousPinchAnchor); gfx::Vector2d anchorOffset = m_previousPinchAnchor.OffsetFromOrigin();
FloatSize scrollEnd = scrollBegin + anchor; gfx::Vector2dF scrollEnd = scrollBegin + anchorOffset;
scrollEnd.scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin); scrollEnd.Scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin);
scrollEnd -= anchor; scrollEnd -= anchorOffset;
scrollEnd = scrollEnd.shrunkTo(roundedIntSize(cc::FloatSize(scaledContentsSize) - cc::IntSize(m_deviceViewportSize))).expandedTo(FloatSize(0, 0)); scrollEnd = ClampFromAbove(scrollEnd, BottomRight(gfx::RectF(scaledContentsSize)) - BottomRight(gfx::Rect(m_deviceViewportSize)));
scrollEnd.scale(1 / pageScaleDeltaToSend); scrollEnd = ClampFromBelow(scrollEnd, gfx::Vector2d());
scrollEnd.scale(m_deviceScaleFactor); scrollEnd.Scale(1 / pageScaleDeltaToSend);
scrollEnd.Scale(m_deviceScaleFactor);
makeScrollAndScaleSet(scrollInfo, roundedIntSize(scrollEnd), m_pinchZoomViewport.minPageScaleFactor()); makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollEnd), m_pinchZoomViewport.minPageScaleFactor());
} }
void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, const IntSize& scrollOffset, float pageScale) void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scrollOffset, float pageScale)
{ {
if (!m_rootScrollLayerImpl) if (!m_rootScrollLayerImpl)
return; return;
LayerTreeHostCommon::ScrollUpdateInfo scroll; LayerTreeHostCommon::ScrollUpdateInfo scroll;
scroll.layerId = m_rootScrollLayerImpl->id(); scroll.layerId = m_rootScrollLayerImpl->id();
scroll.scrollDelta = scrollOffset - toSize(m_rootScrollLayerImpl->scrollPosition()); scroll.scrollDelta = scrollOffset - m_rootScrollLayerImpl->scrollOffset();
scrollInfo->scrolls.push_back(scroll); scrollInfo->scrolls.push_back(scroll);
m_rootScrollLayerImpl->setSentScrollDelta(scroll.scrollDelta); m_rootScrollLayerImpl->setSentScrollDelta(scroll.scrollDelta);
scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.pageScaleFactor(); scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.pageScaleFactor();
@@ -1302,8 +1303,8 @@ static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI
if (!layerImpl) if (!layerImpl)
return; return;
if (!layerImpl->scrollDelta().isZero()) { if (!layerImpl->scrollDelta().IsZero()) {
IntSize scrollDelta = flooredIntSize(layerImpl->scrollDelta()); gfx::Vector2d scrollDelta = gfx::ToFlooredVector2d(layerImpl->scrollDelta());
LayerTreeHostCommon::ScrollUpdateInfo scroll; LayerTreeHostCommon::ScrollUpdateInfo scroll;
scroll.layerId = layerImpl->id(); scroll.layerId = layerImpl->id();
scroll.scrollDelta = scrollDelta; scroll.scrollDelta = scrollDelta;
@@ -1360,11 +1361,11 @@ void LayerTreeHostImpl::animatePageScale(base::TimeTicks time)
return; return;
double monotonicTime = (time - base::TimeTicks()).InSecondsF(); double monotonicTime = (time - base::TimeTicks()).InSecondsF();
IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta()); gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootScrollLayerImpl->scrollDelta();
setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor()); setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor());
IntSize nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime); gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime);
nextScroll.scale(1 / m_pinchZoomViewport.pageScaleDelta()); nextScroll.Scale(1 / m_pinchZoomViewport.pageScaleDelta());
m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal); m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal);
m_client->setNeedsRedrawOnImplThread(); m_client->setNeedsRedrawOnImplThread();

@@ -5,7 +5,6 @@
#ifndef CC_LAYER_TREE_HOST_IMPL_H_ #ifndef CC_LAYER_TREE_HOST_IMPL_H_
#define CC_LAYER_TREE_HOST_IMPL_H_ #define CC_LAYER_TREE_HOST_IMPL_H_
#include "FloatPoint.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/time.h" #include "base/time.h"
@@ -78,14 +77,14 @@ public:
// Returns the bounds and offset of the scaled and translated viewport to use for pinch-zoom. // Returns the bounds and offset of the scaled and translated viewport to use for pinch-zoom.
gfx::RectF bounds() const; gfx::RectF bounds() const;
const FloatPoint& scrollDelta() const { return m_pinchViewportScrollDelta; } const gfx::Vector2dF& scrollDelta() const { return m_pinchViewportScrollDelta; }
void setLayoutViewportSize(const gfx::SizeF& size) { m_layoutViewportSize = size; } void setLayoutViewportSize(const gfx::SizeF& size) { m_layoutViewportSize = size; }
// Apply the scroll offset in layout space to the offset of the pinch-zoom viewport. The viewport cannot be // Apply the scroll offset in layout space to the offset of the pinch-zoom viewport. The viewport cannot be
// scrolled outside of the layout viewport bounds. Returns the component of the scroll that is un-applied due to // scrolled outside of the layout viewport bounds. Returns the component of the scroll that is un-applied due to
// this constraint. // this constraint.
FloatSize applyScroll(const gfx::Vector2dF&); gfx::Vector2dF applyScroll(const gfx::Vector2dF&);
WebKit::WebTransformationMatrix implTransform() const; WebKit::WebTransformationMatrix implTransform() const;
@@ -96,7 +95,7 @@ private:
float m_maxPageScaleFactor; float m_maxPageScaleFactor;
float m_minPageScaleFactor; float m_minPageScaleFactor;
FloatPoint m_pinchViewportScrollDelta; gfx::Vector2dF m_pinchViewportScrollDelta;
gfx::SizeF m_layoutViewportSize; gfx::SizeF m_layoutViewportSize;
}; };
@@ -111,13 +110,13 @@ public:
virtual ~LayerTreeHostImpl(); virtual ~LayerTreeHostImpl();
// InputHandlerClient implementation // InputHandlerClient implementation
virtual InputHandlerClient::ScrollStatus scrollBegin(const gfx::Point&, InputHandlerClient::ScrollInputType) OVERRIDE; virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandlerClient::ScrollInputType) OVERRIDE;
virtual void scrollBy(const gfx::Point&, const IntSize&) OVERRIDE; virtual void scrollBy(gfx::Point, gfx::Vector2d) OVERRIDE;
virtual void scrollEnd() OVERRIDE; virtual void scrollEnd() OVERRIDE;
virtual void pinchGestureBegin() OVERRIDE; virtual void pinchGestureBegin() OVERRIDE;
virtual void pinchGestureUpdate(float, const IntPoint&) OVERRIDE; virtual void pinchGestureUpdate(float, gfx::Point) OVERRIDE;
virtual void pinchGestureEnd() OVERRIDE; virtual void pinchGestureEnd() OVERRIDE;
virtual void startPageScaleAnimation(const IntSize& targetPosition, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVERRIDE; virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVERRIDE;
virtual void scheduleAnimation() OVERRIDE; virtual void scheduleAnimation() OVERRIDE;
struct CC_EXPORT FrameData : public RenderPassSink { struct CC_EXPORT FrameData : public RenderPassSink {
@@ -213,7 +212,7 @@ public:
scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> processScrollDeltas();
WebKit::WebTransformationMatrix implTransform() const; WebKit::WebTransformationMatrix implTransform() const;
void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor, float scale, base::TimeDelta duration); void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
SkColor backgroundColor() const { return m_backgroundColor; } SkColor backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(SkColor color) { m_backgroundColor = color; } void setBackgroundColor(SkColor color) { m_backgroundColor = color; }
@@ -285,10 +284,10 @@ protected:
private: private:
void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo); void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo);
void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo); void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo);
void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, const IntSize& scrollOffset, float pageScale); void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scrollOffset, float pageScale);
void setPageScaleDelta(float); void setPageScaleDelta(float);
void updateMaxScrollPosition(); void updateMaxScrollOffset();
void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& renderSurfaceLayerList); void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& renderSurfaceLayerList);
// Returns false if the frame should not be displayed. This function should // Returns false if the frame should not be displayed. This function should
@@ -331,7 +330,7 @@ private:
// If this is true, it is necessary to traverse the layer tree ticking the animators. // If this is true, it is necessary to traverse the layer tree ticking the animators.
bool m_needsAnimateLayers; bool m_needsAnimateLayers;
bool m_pinchGestureActive; bool m_pinchGestureActive;
IntPoint m_previousPinchAnchor; gfx::Point m_previousPinchAnchor;
scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; scoped_ptr<PageScaleAnimation> m_pageScaleAnimation;

@@ -10,6 +10,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/hash_tables.h" #include "base/hash_tables.h"
#include "cc/delegated_renderer_layer_impl.h" #include "cc/delegated_renderer_layer_impl.h"
#include "cc/geometry.h"
#include "cc/gl_renderer.h" #include "cc/gl_renderer.h"
#include "cc/heads_up_display_layer_impl.h" #include "cc/heads_up_display_layer_impl.h"
#include "cc/io_surface_layer_impl.h" #include "cc/io_surface_layer_impl.h"
@@ -40,6 +41,7 @@
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/size_conversions.h" #include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
#include <public/WebVideoFrame.h> #include <public/WebVideoFrame.h>
#include <public/WebVideoFrameProvider.h> #include <public/WebVideoFrameProvider.h>
@@ -122,20 +124,19 @@ public:
static void expectClearedScrollDeltasRecursive(LayerImpl* layer) static void expectClearedScrollDeltasRecursive(LayerImpl* layer)
{ {
ASSERT_EQ(layer->scrollDelta(), IntSize()); ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d());
for (size_t i = 0; i < layer->children().size(); ++i) for (size_t i = 0; i < layer->children().size(); ++i)
expectClearedScrollDeltasRecursive(layer->children()[i]); expectClearedScrollDeltasRecursive(layer->children()[i]);
} }
static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, const IntSize& scrollDelta) static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, const gfx::Vector2d& scrollDelta)
{ {
int timesEncountered = 0; int timesEncountered = 0;
for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) {
if (scrollInfo.scrolls[i].layerId != id) if (scrollInfo.scrolls[i].layerId != id)
continue; continue;
EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.width()); EXPECT_VECTOR_EQ(scrollDelta, scrollInfo.scrolls[i].scrollDelta);
EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.height());
timesEncountered++; timesEncountered++;
} }
@@ -146,8 +147,8 @@ public:
{ {
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
root->setScrollable(true); root->setScrollable(true);
root->setScrollPosition(IntPoint(0, 0)); root->setScrollOffset(gfx::Vector2d(0, 0));
root->setMaxScrollPosition(cc::IntSize(contentSize)); root->setMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.height()));
root->setBounds(contentSize); root->setBounds(contentSize);
root->setContentBounds(contentSize); root->setContentBounds(contentSize);
root->setPosition(gfx::PointF(0, 0)); root->setPosition(gfx::PointF(0, 0));
@@ -170,7 +171,7 @@ public:
layer->setDrawsContent(true); layer->setDrawsContent(true);
layer->setBounds(size); layer->setBounds(size);
layer->setContentBounds(size); layer->setContentBounds(size);
layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2)); layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height() * 2));
return layer.Pass(); return layer.Pass();
} }
@@ -299,13 +300,13 @@ TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls) TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
{ {
IntPoint scrollPosition(20, 30); gfx::Vector2d scrollOffset(20, 30);
IntSize scrollDelta(11, -15); gfx::Vector2d scrollDelta(11, -15);
{ {
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
root->setScrollPosition(scrollPosition); root->setScrollOffset(scrollOffset);
root->setScrollable(true); root->setScrollable(true);
root->setMaxScrollPosition(IntSize(100, 100)); root->setMaxScrollOffset(gfx::Vector2d(100, 100));
root->scrollBy(scrollDelta); root->scrollBy(scrollDelta);
m_hostImpl->setRootLayer(root.Pass()); m_hostImpl->setRootLayer(root.Pass());
} }
@@ -315,17 +316,17 @@ TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
scrollInfo = m_hostImpl->processScrollDeltas(); scrollInfo = m_hostImpl->processScrollDeltas();
ASSERT_EQ(scrollInfo->scrolls.size(), 1u); ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
EXPECT_EQ(root->sentScrollDelta(), scrollDelta); EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta);
expectContains(*scrollInfo, root->id(), scrollDelta); expectContains(*scrollInfo, root->id(), scrollDelta);
IntSize scrollDelta2(-5, 27); gfx::Vector2d scrollDelta2(-5, 27);
root->scrollBy(scrollDelta2); root->scrollBy(scrollDelta2);
scrollInfo = m_hostImpl->processScrollDeltas(); scrollInfo = m_hostImpl->processScrollDeltas();
ASSERT_EQ(scrollInfo->scrolls.size(), 1u); ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2);
root->scrollBy(IntSize()); root->scrollBy(gfx::Vector2d());
scrollInfo = m_hostImpl->processScrollDeltas(); scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
} }
@@ -337,7 +338,7 @@ TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit); EXPECT_TRUE(m_didRequestCommit);
@@ -379,7 +380,7 @@ TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling)
setupScrollAndContentsLayers(gfx::Size(100, 100)); setupScrollAndContentsLayers(gfx::Size(100, 100));
// We should still be scrolling, because the scrolled layer also exists in the new tree. // We should still be scrolling, because the scrolled layer also exists in the new tree.
IntSize scrollDelta(0, 10); gfx::Vector2d scrollDelta(0, 10);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -442,10 +443,10 @@ TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic)
// All scroll types outside this region should succeed. // All scroll types outside this region should succeed.
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
} }
@@ -461,14 +462,14 @@ TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
// This point would fall into the non-fast scrollable region except that we've moved the layer down by 25 pixels. // This point would fall into the non-fast scrollable region except that we've moved the layer down by 25 pixels.
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 1)); m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1));
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
// This point is still inside the non-fast region. // This point is still inside the non-fast region.
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel), InputHandlerClient::ScrollOnMainThread); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel), InputHandlerClient::ScrollOnMainThread);
} }
TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor)
{ {
setupScrollAndContentsLayers(gfx::Size(100, 100)); setupScrollAndContentsLayers(gfx::Size(100, 100));
@@ -477,12 +478,12 @@ TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor)
gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScaleFactor))); gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScaleFactor)));
m_hostImpl->setViewportSize(layoutViewport, deviceViewport); m_hostImpl->setViewportSize(layoutViewport, deviceViewport);
m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25)); EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(25, 25));
deviceScaleFactor = 1; deviceScaleFactor = 1;
m_hostImpl->setViewportSize(layoutViewport, layoutViewport); m_hostImpl->setViewportSize(layoutViewport, layoutViewport);
m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75)); EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(75, 75));
} }
TEST_P(LayerTreeHostImplTest, implPinchZoom) TEST_P(LayerTreeHostImplTest, implPinchZoom)
@@ -505,11 +506,11 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
{ {
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform); scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize()); scrollLayer->setScrollDelta(gfx::Vector2d());
float pageScaleDelta = 2; float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit); EXPECT_TRUE(m_didRequestCommit);
@@ -517,7 +518,7 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50)); EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(50, 50));
} }
// Scrolling after a pinch gesture should always be in local space. The scroll deltas do not // Scrolling after a pinch gesture should always be in local space. The scroll deltas do not
@@ -525,14 +526,14 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
{ {
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform); scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize()); scrollLayer->setScrollDelta(gfx::Vector2d());
float pageScaleDelta = 2; float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0));
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
IntSize scrollDelta(0, 10); gfx::Vector2d scrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
@@ -559,11 +560,11 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{ {
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform); scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize()); scrollLayer->setScrollDelta(gfx::Vector2d());
float pageScaleDelta = 2; float pageScaleDelta = 2;
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit); EXPECT_TRUE(m_didRequestCommit);
@@ -576,11 +577,11 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{ {
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform); scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize()); scrollLayer->setScrollDelta(gfx::Vector2d());
float pageScaleDelta = 10; float pageScaleDelta = 10;
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -591,12 +592,12 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{ {
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform); scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize()); scrollLayer->setScrollDelta(gfx::Vector2d());
scrollLayer->setScrollPosition(IntPoint(50, 50)); scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
float pageScaleDelta = 0.1f; float pageScaleDelta = 0.1f;
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0));
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -604,7 +605,7 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
if (!Settings::pageScalePinchZoomEnabled()) { if (!Settings::pageScalePinchZoomEnabled()) {
// Pushed to (0,0) via clamping against contents layer size. // Pushed to (0,0) via clamping against contents layer size.
expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
} else { } else {
EXPECT_TRUE(scrollInfo->scrolls.empty()); EXPECT_TRUE(scrollInfo->scrolls.empty());
} }
@@ -614,18 +615,18 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
{ {
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform); scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize()); scrollLayer->setScrollDelta(gfx::Vector2d());
scrollLayer->setScrollPosition(IntPoint(20, 20)); scrollLayer->setScrollOffset(gfx::Vector2d(20, 20));
float pageScaleDelta = 1; float pageScaleDelta = 1;
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10)); m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10));
m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20)); m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20));
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10));
} }
} }
@@ -650,9 +651,9 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
{ {
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform); scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollPosition(IntPoint(50, 50)); scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration); m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, startTime, duration);
m_hostImpl->animate(halfwayThroughAnimation, base::Time()); m_hostImpl->animate(halfwayThroughAnimation, base::Time());
EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestRedraw);
m_hostImpl->animate(endTime, base::Time()); m_hostImpl->animate(endTime, base::Time());
@@ -660,16 +661,16 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, 2); EXPECT_EQ(scrollInfo->pageScaleDelta, 2);
expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
} }
// Anchor zoom-out // Anchor zoom-out
{ {
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
scrollLayer->setImplTransform(identityScaleTransform); scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollPosition(IntPoint(50, 50)); scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration); m_hostImpl->startPageScaleAnimation(gfx::Vector2d(25, 25), true, minPageScale, startTime, duration);
m_hostImpl->animate(endTime, base::Time()); m_hostImpl->animate(endTime, base::Time());
EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit); EXPECT_TRUE(m_didRequestCommit);
@@ -677,7 +678,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
// Pushed to (0,0) via clamping against contents layer size. // Pushed to (0,0) via clamping against contents layer size.
expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50));
} }
} }
@@ -699,7 +700,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
const float zoomInDelta = 2; const float zoomInDelta = 2;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50)); m_hostImpl->pinchGestureUpdate(zoomInDelta, gfx::Point(50, 50));
// Because we are pinch zooming in, we shouldn't get any scroll or page // Because we are pinch zooming in, we shouldn't get any scroll or page
// scale deltas. // scale deltas.
@@ -712,7 +713,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
scrollInfo = m_hostImpl->processScrollDeltas(); scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta); EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta);
if (!Settings::pageScalePinchZoomEnabled()) { if (!Settings::pageScalePinchZoomEnabled()) {
expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
} else { } else {
EXPECT_TRUE(scrollInfo->scrolls.empty()); EXPECT_TRUE(scrollInfo->scrolls.empty());
} }
@@ -724,14 +725,14 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
const float zoomOutDelta = 0.75; const float zoomOutDelta = 0.75;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50)); m_hostImpl->pinchGestureUpdate(zoomOutDelta, gfx::Point(50, 50));
// Since we are pinch zooming out, we should get an update to zoom all // Since we are pinch zooming out, we should get an update to zoom all
// the way out to the minimum page scale. // the way out to the minimum page scale.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
if (!Settings::pageScalePinchZoomEnabled()) { if (!Settings::pageScalePinchZoomEnabled()) {
EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(0, 0));
} else { } else {
EXPECT_EQ(scrollInfo->pageScaleDelta, 1); EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
EXPECT_TRUE(scrollInfo->scrolls.empty()); EXPECT_TRUE(scrollInfo->scrolls.empty());
@@ -742,10 +743,10 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
scrollInfo = m_hostImpl->processScrollDeltas(); scrollInfo = m_hostImpl->processScrollDeltas();
if (Settings::pageScalePinchZoomEnabled()) { if (Settings::pageScalePinchZoomEnabled()) {
EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
} else { } else {
EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta);
expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(8, 8));
} }
} }
} }
@@ -768,7 +769,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
// Start a page scale animation. // Start a page scale animation.
const float pageScaleDelta = 2; const float pageScaleDelta = 2;
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration); m_hostImpl->startPageScaleAnimation(gfx::Vector2d(50, 50), false, pageScaleDelta, startTime, duration);
// We should immediately get the final zoom and scroll values for the // We should immediately get the final zoom and scroll values for the
// animation. // animation.
@@ -777,14 +778,14 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
if (!Settings::pageScalePinchZoomEnabled()) { if (!Settings::pageScalePinchZoomEnabled()) {
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
} else { } else {
EXPECT_EQ(scrollInfo->pageScaleDelta, 1); EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
EXPECT_TRUE(scrollInfo->scrolls.empty()); EXPECT_TRUE(scrollInfo->scrolls.empty());
} }
// Scrolling during the animation is ignored. // Scrolling during the animation is ignored.
const IntSize scrollDelta(0, 10); const gfx::Vector2d scrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
@@ -794,7 +795,7 @@ TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
m_hostImpl->animate(endTime, base::Time()); m_hostImpl->animate(endTime, base::Time());
scrollInfo = m_hostImpl->processScrollDeltas(); scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
} }
class DidDrawCheckLayer : public TiledLayerImpl { class DidDrawCheckLayer : public TiledLayerImpl {
@@ -1049,7 +1050,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot)
scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2); scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2);
scrollLayer->setScrollable(true); scrollLayer->setScrollable(true);
scrollLayer->setMaxScrollPosition(cc::IntSize(surfaceSize)); scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSize.height()));
scrollLayer->setBounds(surfaceSize); scrollLayer->setBounds(surfaceSize);
scrollLayer->setContentBounds(surfaceSize); scrollLayer->setContentBounds(surfaceSize);
scrollLayer->setPosition(gfx::PointF(0, 0)); scrollLayer->setPosition(gfx::PointF(0, 0));
@@ -1061,7 +1062,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot)
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit); EXPECT_TRUE(m_didRequestCommit);
@@ -1079,7 +1080,7 @@ TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestRedraw);
EXPECT_TRUE(m_didRequestCommit); EXPECT_TRUE(m_didRequestCommit);
@@ -1150,9 +1151,9 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize); m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
IntSize scrollDelta(0, 10); gfx::Vector2d scrollDelta(0, 10);
IntSize expectedScrollDelta(scrollDelta); gfx::Vector2d expectedScrollDelta(scrollDelta);
IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
@@ -1162,13 +1163,13 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
if (!Settings::pageScalePinchZoomEnabled()) { if (!Settings::pageScalePinchZoomEnabled()) {
// The scale should apply to the scroll delta. // The scale should apply to the scroll delta.
expectedScrollDelta.scale(pageScale); expectedScrollDelta = gfx::ToFlooredVector2d(cc::ScaleVector2d(expectedScrollDelta, pageScale));
} }
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta); expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
// The scroll range should also have been updated. // The scroll range should also have been updated.
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale. // The page scale delta remains constant because the impl thread did not scale.
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix()); EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix());
@@ -1184,16 +1185,16 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
IntSize scrollDelta(0, 10); gfx::Vector2d scrollDelta(0, 10);
IntSize expectedScrollDelta(scrollDelta); gfx::Vector2d expectedScrollDelta(scrollDelta);
IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
// Set new page scale on impl thread by pinching. // Set new page scale on impl thread by pinching.
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform(); m_hostImpl->updateRootScrollLayerImplTransform();
@@ -1202,7 +1203,7 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta); expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
// The scroll range should also have been updated. // The scroll range should also have been updated.
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta should match the new scale on the impl side. // The page scale delta should match the new scale on the impl side.
WebTransformationMatrix expectedScale; WebTransformationMatrix expectedScale;
@@ -1231,7 +1232,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
// Set new page scale on impl thread by pinching. // Set new page scale on impl thread by pinching.
m_hostImpl->pinchGestureBegin(); m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
m_hostImpl->pinchGestureEnd(); m_hostImpl->pinchGestureEnd();
m_hostImpl->updateRootScrollLayerImplTransform(); m_hostImpl->updateRootScrollLayerImplTransform();
@@ -1271,9 +1272,9 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
IntSize scrollDelta(0, 10); gfx::Vector2d scrollDelta(0, 10);
IntSize expectedScrollDelta(scrollDelta); gfx::Vector2d expectedScrollDelta(scrollDelta);
IntSize expectedMaxScroll(child->maxScrollPosition()); gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
@@ -1285,13 +1286,13 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
if (!Settings::pageScalePinchZoomEnabled()) { if (!Settings::pageScalePinchZoomEnabled()) {
// The scale should apply to the scroll delta. // The scale should apply to the scroll delta.
expectedScrollDelta.scale(pageScale); expectedScrollDelta = gfx::ToFlooredVector2d(cc::ScaleVector2d(expectedScrollDelta, pageScale));
} }
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
// The scroll range should not have changed. // The scroll range should not have changed.
EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll); EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale. // The page scale delta remains constant because the impl thread did not scale.
WebTransformationMatrix identityTransform; WebTransformationMatrix identityTransform;
@@ -1307,10 +1308,10 @@ TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize);
grandChild->setScrollPosition(IntPoint(0, 5)); grandChild->setScrollOffset(gfx::Vector2d(0, 5));
scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
child->setScrollPosition(IntPoint(3, 0)); child->setScrollOffset(gfx::Vector2d(3, 0));
child->addChild(grandChild.Pass()); child->addChild(grandChild.Pass());
root->addChild(child.Pass()); root->addChild(child.Pass());
@@ -1318,7 +1319,7 @@ TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize); m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
{ {
IntSize scrollDelta(-8, -7); gfx::Vector2d scrollDelta(-8, -7);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
@@ -1328,10 +1329,10 @@ TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
// The grand child should have scrolled up to its limit. // The grand child should have scrolled up to its limit.
LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
LayerImpl* grandChild = child->children()[0]; LayerImpl* grandChild = child->children()[0];
expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5));
// The child should have only scrolled on the other axis. // The child should have only scrolled on the other axis.
expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); expectContains(*scrollInfo.get(), child->id(), gfx::Vector2d(-3, 0));
} }
} }
@@ -1350,7 +1351,7 @@ TEST_P(LayerTreeHostImplTest, scrollEventBubbling)
m_hostImpl->setViewportSize(surfaceSize, surfaceSize); m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
{ {
IntSize scrollDelta(0, 4); gfx::Vector2d scrollDelta(0, 4);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
@@ -1392,18 +1393,18 @@ TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
// Scroll to the right in screen coordinates with a gesture. // Scroll to the right in screen coordinates with a gesture.
IntSize gestureScrollDelta(10, 0); gfx::Vector2d gestureScrollDelta(10, 0);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
// The layer should have scrolled down in its local coordinates. // The layer should have scrolled down in its local coordinates.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, gestureScrollDelta.width())); expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector2d(0, gestureScrollDelta.x()));
// Reset and scroll down with the wheel. // Reset and scroll down with the wheel.
m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
IntSize wheelScrollDelta(0, 10); gfx::Vector2d wheelScrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
@@ -1428,7 +1429,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
child->setTransform(rotateTransform); child->setTransform(rotateTransform);
// Only allow vertical scrolling. // Only allow vertical scrolling.
child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height()));
m_hostImpl->rootLayer()->addChild(child.Pass()); m_hostImpl->rootLayer()->addChild(child.Pass());
gfx::Size surfaceSize(50, 50); gfx::Size surfaceSize(50, 50);
@@ -1437,14 +1438,14 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
{ {
// Scroll down in screen coordinates with a gesture. // Scroll down in screen coordinates with a gesture.
IntSize gestureScrollDelta(0, 10); gfx::Vector2d gestureScrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
// The child layer should have scrolled down in its local coordinates an amount proportional to // The child layer should have scrolled down in its local coordinates an amount proportional to
// the angle between it and the input scroll delta. // the angle between it and the input scroll delta.
IntSize expectedScrollDelta(0, gestureScrollDelta.height() * cosf(deg2rad(childLayerAngle))); gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * cosf(deg2rad(childLayerAngle)));
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
@@ -1455,21 +1456,21 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
{ {
// Now reset and scroll the same amount horizontally. // Now reset and scroll the same amount horizontally.
m_hostImpl->rootLayer()->children()[1]->setScrollDelta(FloatSize()); m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF());
IntSize gestureScrollDelta(10, 0); gfx::Vector2d gestureScrollDelta(10, 0);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
// The child layer should have scrolled down in its local coordinates an amount proportional to // The child layer should have scrolled down in its local coordinates an amount proportional to
// the angle between it and the input scroll delta. // the angle between it and the input scroll delta.
IntSize expectedScrollDelta(0, -gestureScrollDelta.width() * sinf(deg2rad(childLayerAngle))); gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * sinf(deg2rad(childLayerAngle)));
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
// The root layer should have scrolled more, since the input scroll delta was mostly // The root layer should have scrolled more, since the input scroll delta was mostly
// orthogonal to the child layer's vertical scroll axis. // orthogonal to the child layer's vertical scroll axis.
IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(deg2rad(childLayerAngle)), 2), 0); gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * pow(cosf(deg2rad(childLayerAngle)), 2), 0);
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedRootScrollDelta); expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedRootScrollDelta);
} }
} }
@@ -1489,18 +1490,18 @@ TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
initializeRendererAndDrawFrame(); initializeRendererAndDrawFrame();
// Scroll down in screen coordinates with a gesture. // Scroll down in screen coordinates with a gesture.
IntSize scrollDelta(0, 10); gfx::Vector2d scrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), scrollDelta); m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();
// The layer should have scrolled down in its local coordinates, but half he amount. // The layer should have scrolled down in its local coordinates, but half he amount.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, scrollDelta.height() / scale)); expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector2d(0, scrollDelta.y() / scale));
// Reset and scroll down with the wheel. // Reset and scroll down with the wheel.
m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
IntSize wheelScrollDelta(0, 10); gfx::Vector2d wheelScrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta);
m_hostImpl->scrollEnd(); m_hostImpl->scrollEnd();

@@ -24,6 +24,7 @@
#include "third_party/khronos/GLES2/gl2ext.h" #include "third_party/khronos/GLES2/gl2ext.h"
#include "ui/gfx/point_conversions.h" #include "ui/gfx/point_conversions.h"
#include "ui/gfx/size_conversions.h" #include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
#include <public/WebLayerScrollClient.h> #include <public/WebLayerScrollClient.h>
#include <public/WebSize.h> #include <public/WebSize.h>
@@ -834,8 +835,8 @@ SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAnimationFinishedEvents)
class LayerTreeHostTestScrollSimple : public LayerTreeHostTest { class LayerTreeHostTestScrollSimple : public LayerTreeHostTest {
public: public:
LayerTreeHostTestScrollSimple() LayerTreeHostTestScrollSimple()
: m_initialScroll(IntPoint(10, 20)) : m_initialScroll(10, 20)
, m_secondScroll(IntPoint(40, 5)) , m_secondScroll(40, 5)
, m_scrollAmount(2, -1) , m_scrollAmount(2, -1)
, m_scrolls(0) , m_scrolls(0)
{ {
@@ -844,7 +845,7 @@ public:
virtual void beginTest() OVERRIDE virtual void beginTest() OVERRIDE
{ {
m_layerTreeHost->rootLayer()->setScrollable(true); m_layerTreeHost->rootLayer()->setScrollable(true);
m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll); m_layerTreeHost->rootLayer()->setScrollOffset(m_initialScroll);
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
} }
@@ -852,39 +853,39 @@ public:
{ {
Layer* root = m_layerTreeHost->rootLayer(); Layer* root = m_layerTreeHost->rootLayer();
if (!m_layerTreeHost->commitNumber()) if (!m_layerTreeHost->commitNumber())
EXPECT_EQ(root->scrollPosition(), m_initialScroll); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
else { else {
EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount);
// Pretend like Javascript updated the scroll position itself. // Pretend like Javascript updated the scroll position itself.
root->setScrollPosition(m_secondScroll); root->setScrollOffset(m_secondScroll);
} }
} }
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{ {
LayerImpl* root = impl->rootLayer(); LayerImpl* root = impl->rootLayer();
EXPECT_EQ(root->scrollDelta(), IntSize()); EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
root->setScrollable(true); root->setScrollable(true);
root->setMaxScrollPosition(IntSize(100, 100)); root->setMaxScrollOffset(gfx::Vector2d(100, 100));
root->scrollBy(m_scrollAmount); root->scrollBy(m_scrollAmount);
if (!impl->sourceFrameNumber()) { if (!impl->sourceFrameNumber()) {
EXPECT_EQ(root->scrollPosition(), m_initialScroll); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
EXPECT_EQ(root->scrollDelta(), m_scrollAmount); EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) { } else if (impl->sourceFrameNumber() == 1) {
EXPECT_EQ(root->scrollPosition(), m_secondScroll); EXPECT_VECTOR_EQ(root->scrollOffset(), m_secondScroll);
EXPECT_EQ(root->scrollDelta(), m_scrollAmount); EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
endTest(); endTest();
} }
} }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{ {
IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition(); gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
m_scrolls++; m_scrolls++;
} }
@@ -893,9 +894,9 @@ public:
EXPECT_EQ(1, m_scrolls); EXPECT_EQ(1, m_scrolls);
} }
private: private:
IntPoint m_initialScroll; gfx::Vector2d m_initialScroll;
IntPoint m_secondScroll; gfx::Vector2d m_secondScroll;
IntSize m_scrollAmount; gfx::Vector2d m_scrollAmount;
int m_scrolls; int m_scrolls;
}; };
@@ -907,7 +908,7 @@ TEST_F(LayerTreeHostTestScrollSimple, runMultiThread)
class LayerTreeHostTestScrollMultipleRedraw : public LayerTreeHostTest { class LayerTreeHostTestScrollMultipleRedraw : public LayerTreeHostTest {
public: public:
LayerTreeHostTestScrollMultipleRedraw() LayerTreeHostTestScrollMultipleRedraw()
: m_initialScroll(IntPoint(40, 10)) : m_initialScroll(40, 10)
, m_scrollAmount(-3, 17) , m_scrollAmount(-3, 17)
, m_scrolls(0) , m_scrolls(0)
{ {
@@ -916,7 +917,7 @@ public:
virtual void beginTest() OVERRIDE virtual void beginTest() OVERRIDE
{ {
m_layerTreeHost->rootLayer()->setScrollable(true); m_layerTreeHost->rootLayer()->setScrollable(true);
m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll); m_layerTreeHost->rootLayer()->setScrollOffset(m_initialScroll);
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
} }
@@ -924,48 +925,48 @@ public:
{ {
Layer* root = m_layerTreeHost->rootLayer(); Layer* root = m_layerTreeHost->rootLayer();
if (!m_layerTreeHost->commitNumber()) if (!m_layerTreeHost->commitNumber())
EXPECT_EQ(root->scrollPosition(), m_initialScroll); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
else if (m_layerTreeHost->commitNumber() == 1) else if (m_layerTreeHost->commitNumber() == 1)
EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
else if (m_layerTreeHost->commitNumber() == 2) else if (m_layerTreeHost->commitNumber() == 2)
EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
} }
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{ {
LayerImpl* root = impl->rootLayer(); LayerImpl* root = impl->rootLayer();
root->setScrollable(true); root->setScrollable(true);
root->setMaxScrollPosition(IntSize(100, 100)); root->setMaxScrollOffset(gfx::Vector2d(100, 100));
if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 1) { if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 1) {
// First draw after first commit. // First draw after first commit.
EXPECT_EQ(root->scrollDelta(), IntSize()); EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
root->scrollBy(m_scrollAmount); root->scrollBy(m_scrollAmount);
EXPECT_EQ(root->scrollDelta(), m_scrollAmount); EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount);
EXPECT_EQ(root->scrollPosition(), m_initialScroll); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
postSetNeedsRedrawToMainThread(); postSetNeedsRedrawToMainThread();
} else if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 2) { } else if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 2) {
// Second draw after first commit. // Second draw after first commit.
EXPECT_EQ(root->scrollDelta(), m_scrollAmount); EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
root->scrollBy(m_scrollAmount); root->scrollBy(m_scrollAmount);
EXPECT_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmount); EXPECT_VECTOR_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmount);
EXPECT_EQ(root->scrollPosition(), m_initialScroll); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll);
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) { } else if (impl->sourceFrameNumber() == 1) {
// Third or later draw after second commit. // Third or later draw after second commit.
EXPECT_GE(impl->sourceAnimationFrameNumber(), 3); EXPECT_GE(impl->sourceAnimationFrameNumber(), 3);
EXPECT_EQ(root->scrollDelta(), IntSize()); EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount); EXPECT_VECTOR_EQ(root->scrollOffset(), m_initialScroll + m_scrollAmount + m_scrollAmount);
endTest(); endTest();
} }
} }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{ {
IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition(); gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
m_scrolls++; m_scrolls++;
} }
@@ -974,8 +975,8 @@ public:
EXPECT_EQ(1, m_scrolls); EXPECT_EQ(1, m_scrolls);
} }
private: private:
IntPoint m_initialScroll; gfx::Vector2d m_initialScroll;
IntSize m_scrollAmount; gfx::Vector2d m_scrollAmount;
int m_scrolls; int m_scrolls;
}; };
@@ -1029,20 +1030,20 @@ public:
virtual void beginTest() OVERRIDE virtual void beginTest() OVERRIDE
{ {
m_layerTreeHost->rootLayer()->setScrollable(true); m_layerTreeHost->rootLayer()->setScrollable(true);
m_layerTreeHost->rootLayer()->setScrollPosition(IntPoint()); m_layerTreeHost->rootLayer()->setScrollOffset(gfx::Vector2d());
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
postSetNeedsRedrawToMainThread(); postSetNeedsRedrawToMainThread();
} }
void requestStartPageScaleAnimation() void requestStartPageScaleAnimation()
{ {
layerTreeHost()->startPageScaleAnimation(IntSize(), false, 1.25, base::TimeDelta()); layerTreeHost()->startPageScaleAnimation(gfx::Vector2d(), false, 1.25, base::TimeDelta());
} }
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{ {
impl->rootLayer()->setScrollable(true); impl->rootLayer()->setScrollable(true);
impl->rootLayer()->setScrollPosition(IntPoint()); impl->rootLayer()->setScrollOffset(gfx::Vector2d());
impl->setPageScaleFactorAndLimits(impl->pageScaleFactor(), 0.5, 2); impl->setPageScaleFactorAndLimits(impl->pageScaleFactor(), 0.5, 2);
// We request animation only once. // We request animation only once.
@@ -1052,10 +1053,10 @@ public:
} }
} }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{ {
IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition(); gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2); m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2);
} }
@@ -2090,36 +2091,36 @@ public:
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{ {
LayerImpl* root = impl->rootLayer(); LayerImpl* root = impl->rootLayer();
root->setMaxScrollPosition(IntSize(100, 100)); root->setMaxScrollOffset(gfx::Vector2d(100, 100));
// Check that a fractional scroll delta is correctly accumulated over multiple commits. // Check that a fractional scroll delta is correctly accumulated over multiple commits.
if (!impl->sourceFrameNumber()) { if (!impl->sourceFrameNumber()) {
EXPECT_EQ(root->scrollPosition(), IntPoint(0, 0)); EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::Vector2d(0, 0));
EXPECT_EQ(root->scrollDelta(), FloatSize(0, 0)); EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d(0, 0));
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 1) { } else if (impl->sourceFrameNumber() == 1) {
EXPECT_EQ(root->scrollPosition(), flooredIntPoint(m_scrollAmount)); EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scrollAmount));
EXPECT_EQ(root->scrollDelta(), FloatSize(fmod(m_scrollAmount.width(), 1), 0)); EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(m_scrollAmount.x(), 1), 0));
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
} else if (impl->sourceFrameNumber() == 2) { } else if (impl->sourceFrameNumber() == 2) {
EXPECT_EQ(root->scrollPosition(), flooredIntPoint(m_scrollAmount + m_scrollAmount)); EXPECT_VECTOR_EQ(root->scrollOffset(), gfx::ToFlooredVector2d(m_scrollAmount + m_scrollAmount));
EXPECT_EQ(root->scrollDelta(), FloatSize(fmod(2 * m_scrollAmount.width(), 1), 0)); EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2dF(fmod(2 * m_scrollAmount.x(), 1), 0));
endTest(); endTest();
} }
root->scrollBy(m_scrollAmount); root->scrollBy(m_scrollAmount);
} }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{ {
IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition(); gfx::Vector2d offset = m_layerTreeHost->rootLayer()->scrollOffset();
m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); m_layerTreeHost->rootLayer()->setScrollOffset(offset + scrollDelta);
} }
virtual void afterTest() OVERRIDE virtual void afterTest() OVERRIDE
{ {
} }
private: private:
FloatSize m_scrollAmount; gfx::Vector2dF m_scrollAmount;
}; };
TEST_F(LayerTreeHostTestFractionalScroll, runMultiThread) TEST_F(LayerTreeHostTestFractionalScroll, runMultiThread)
@@ -2223,8 +2224,8 @@ class LayerTreeHostTestScrollChildLayer : public LayerTreeHostTest, public WebLa
public: public:
LayerTreeHostTestScrollChildLayer(float deviceScaleFactor) LayerTreeHostTestScrollChildLayer(float deviceScaleFactor)
: m_deviceScaleFactor(deviceScaleFactor) : m_deviceScaleFactor(deviceScaleFactor)
, m_initialScroll(IntPoint(10, 20)) , m_initialScroll(10, 20)
, m_secondScroll(IntPoint(40, 5)) , m_secondScroll(40, 5)
, m_scrollAmount(2, -1) , m_scrollAmount(2, -1)
, m_rootScrolls(0) , m_rootScrolls(0)
{ {
@@ -2246,7 +2247,7 @@ public:
m_rootScrollLayer->setIsDrawable(true); m_rootScrollLayer->setIsDrawable(true);
m_rootScrollLayer->setScrollable(true); m_rootScrollLayer->setScrollable(true);
m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100)); m_rootScrollLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
m_childLayer = ContentLayer::create(&m_mockDelegate); m_childLayer = ContentLayer::create(&m_mockDelegate);
@@ -2260,42 +2261,42 @@ public:
m_childLayer->setIsDrawable(true); m_childLayer->setIsDrawable(true);
m_childLayer->setScrollable(true); m_childLayer->setScrollable(true);
m_childLayer->setMaxScrollPosition(IntSize(100, 100)); m_childLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
m_rootScrollLayer->addChild(m_childLayer); m_rootScrollLayer->addChild(m_childLayer);
m_childLayer->setScrollPosition(m_initialScroll); m_childLayer->setScrollOffset(m_initialScroll);
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
} }
virtual void didScroll() OVERRIDE virtual void didScroll() OVERRIDE
{ {
m_finalScrollPosition = m_childLayer->scrollPosition(); m_finalScrollOffset = m_childLayer->scrollOffset();
} }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{ {
IntPoint position = m_rootScrollLayer->scrollPosition(); gfx::Vector2d offset = m_rootScrollLayer->scrollOffset();
m_rootScrollLayer->setScrollPosition(position + scrollDelta); m_rootScrollLayer->setScrollOffset(offset + scrollDelta);
m_rootScrolls++; m_rootScrolls++;
} }
virtual void layout() OVERRIDE virtual void layout() OVERRIDE
{ {
EXPECT_EQ(IntPoint(), m_rootScrollLayer->scrollPosition()); EXPECT_VECTOR_EQ(gfx::Vector2d(), m_rootScrollLayer->scrollOffset());
switch (m_layerTreeHost->commitNumber()) { switch (m_layerTreeHost->commitNumber()) {
case 0: case 0:
EXPECT_POINT_EQ(m_initialScroll, m_childLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_initialScroll, m_childLayer->scrollOffset());
break; break;
case 1: case 1:
EXPECT_POINT_EQ(m_initialScroll + m_scrollAmount, m_childLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_initialScroll + m_scrollAmount, m_childLayer->scrollOffset());
// Pretend like Javascript updated the scroll position itself. // Pretend like Javascript updated the scroll position itself.
m_childLayer->setScrollPosition(m_secondScroll); m_childLayer->setScrollOffset(m_secondScroll);
break; break;
case 2: case 2:
EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_childLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_childLayer->scrollOffset());
break; break;
} }
} }
@@ -2306,8 +2307,8 @@ public:
LayerImpl* rootScrollLayer = root->children()[0]; LayerImpl* rootScrollLayer = root->children()[0];
LayerImpl* childLayer = rootScrollLayer->children()[0]; LayerImpl* childLayer = rootScrollLayer->children()[0];
EXPECT_SIZE_EQ(root->scrollDelta(), IntSize()); EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
EXPECT_SIZE_EQ(rootScrollLayer->scrollDelta(), IntSize()); EXPECT_VECTOR_EQ(rootScrollLayer->scrollDelta(), gfx::Vector2d());
EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootScrollLayer->contentBounds().width()); EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootScrollLayer->contentBounds().width());
EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, rootScrollLayer->contentBounds().height()); EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, rootScrollLayer->contentBounds().height());
EXPECT_EQ(childLayer->bounds().width() * m_deviceScaleFactor, childLayer->contentBounds().width()); EXPECT_EQ(childLayer->bounds().width() * m_deviceScaleFactor, childLayer->contentBounds().width());
@@ -2320,8 +2321,8 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount); impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd(); impl->scrollEnd();
EXPECT_POINT_EQ(m_initialScroll, childLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_initialScroll, childLayer->scrollOffset());
EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta()); EXPECT_VECTOR_EQ(m_scrollAmount, childLayer->scrollDelta());
break; break;
case 1: case 1:
// Wheel scroll on impl thread. // Wheel scroll on impl thread.
@@ -2329,12 +2330,12 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount); impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd(); impl->scrollEnd();
EXPECT_POINT_EQ(m_secondScroll, childLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_secondScroll, childLayer->scrollOffset());
EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta()); EXPECT_VECTOR_EQ(m_scrollAmount, childLayer->scrollDelta());
break; break;
case 2: case 2:
EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, childLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, childLayer->scrollOffset());
EXPECT_SIZE_EQ(IntSize(0, 0), childLayer->scrollDelta()); EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), childLayer->scrollDelta());
endTest(); endTest();
} }
@@ -2343,16 +2344,16 @@ public:
virtual void afterTest() OVERRIDE virtual void afterTest() OVERRIDE
{ {
EXPECT_EQ(0, m_rootScrolls); EXPECT_EQ(0, m_rootScrolls);
EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_finalScrollPosition); EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_finalScrollOffset);
} }
private: private:
float m_deviceScaleFactor; float m_deviceScaleFactor;
IntPoint m_initialScroll; gfx::Vector2d m_initialScroll;
IntPoint m_secondScroll; gfx::Vector2d m_secondScroll;
IntSize m_scrollAmount; gfx::Vector2d m_scrollAmount;
int m_rootScrolls; int m_rootScrolls;
IntPoint m_finalScrollPosition; gfx::Vector2d m_finalScrollOffset;
MockContentLayerClient m_mockDelegate; MockContentLayerClient m_mockDelegate;
scoped_refptr<Layer> m_rootScrollLayer; scoped_refptr<Layer> m_rootScrollLayer;
@@ -2383,8 +2384,8 @@ class LayerTreeHostTestScrollRootScrollLayer : public LayerTreeHostTest {
public: public:
LayerTreeHostTestScrollRootScrollLayer(float deviceScaleFactor) LayerTreeHostTestScrollRootScrollLayer(float deviceScaleFactor)
: m_deviceScaleFactor(deviceScaleFactor) : m_deviceScaleFactor(deviceScaleFactor)
, m_initialScroll(IntPoint(10, 20)) , m_initialScroll(10, 20)
, m_secondScroll(IntPoint(40, 5)) , m_secondScroll(40, 5)
, m_scrollAmount(2, -1) , m_scrollAmount(2, -1)
, m_rootScrolls(0) , m_rootScrolls(0)
{ {
@@ -2399,25 +2400,25 @@ public:
m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor); m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
m_rootScrollLayer = ContentLayer::create(&m_mockDelegate); m_rootScrollLayer = ContentLayer::create(&m_mockDelegate);
m_rootScrollLayer->setBounds(IntSize(110, 110)); m_rootScrollLayer->setBounds(gfx::Size(110, 110));
m_rootScrollLayer->setPosition(gfx::PointF(0, 0)); m_rootScrollLayer->setPosition(gfx::PointF(0, 0));
m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0)); m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0));
m_rootScrollLayer->setIsDrawable(true); m_rootScrollLayer->setIsDrawable(true);
m_rootScrollLayer->setScrollable(true); m_rootScrollLayer->setScrollable(true);
m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100)); m_rootScrollLayer->setMaxScrollOffset(gfx::Vector2d(100, 100));
m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
m_rootScrollLayer->setScrollPosition(m_initialScroll); m_rootScrollLayer->setScrollOffset(m_initialScroll);
postSetNeedsCommitToMainThread(); postSetNeedsCommitToMainThread();
} }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{ {
IntPoint position = m_rootScrollLayer->scrollPosition(); gfx::Vector2d offset = m_rootScrollLayer->scrollOffset();
m_rootScrollLayer->setScrollPosition(position + scrollDelta); m_rootScrollLayer->setScrollOffset(offset + scrollDelta);
m_rootScrolls++; m_rootScrolls++;
} }
@@ -2425,16 +2426,16 @@ public:
{ {
switch (m_layerTreeHost->commitNumber()) { switch (m_layerTreeHost->commitNumber()) {
case 0: case 0:
EXPECT_POINT_EQ(m_initialScroll, m_rootScrollLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_initialScroll, m_rootScrollLayer->scrollOffset());
break; break;
case 1: case 1:
EXPECT_POINT_EQ(m_initialScroll + m_scrollAmount, m_rootScrollLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_initialScroll + m_scrollAmount, m_rootScrollLayer->scrollOffset());
// Pretend like Javascript updated the scroll position itself. // Pretend like Javascript updated the scroll position itself.
m_rootScrollLayer->setScrollPosition(m_secondScroll); m_rootScrollLayer->setScrollOffset(m_secondScroll);
break; break;
case 2: case 2:
EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, m_rootScrollLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, m_rootScrollLayer->scrollOffset());
break; break;
} }
} }
@@ -2444,7 +2445,7 @@ public:
LayerImpl* root = impl->rootLayer(); LayerImpl* root = impl->rootLayer();
LayerImpl* rootScrollLayer = root->children()[0]; LayerImpl* rootScrollLayer = root->children()[0];
EXPECT_SIZE_EQ(root->scrollDelta(), IntSize()); EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d());
EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootScrollLayer->contentBounds().width()); EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootScrollLayer->contentBounds().width());
EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, rootScrollLayer->contentBounds().height()); EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, rootScrollLayer->contentBounds().height());
@@ -2455,8 +2456,8 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount); impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd(); impl->scrollEnd();
EXPECT_POINT_EQ(m_initialScroll, rootScrollLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_initialScroll, rootScrollLayer->scrollOffset());
EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta()); EXPECT_VECTOR_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
break; break;
case 1: case 1:
// Wheel scroll on impl thread. // Wheel scroll on impl thread.
@@ -2464,12 +2465,12 @@ public:
impl->scrollBy(gfx::Point(), m_scrollAmount); impl->scrollBy(gfx::Point(), m_scrollAmount);
impl->scrollEnd(); impl->scrollEnd();
EXPECT_POINT_EQ(m_secondScroll, rootScrollLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_secondScroll, rootScrollLayer->scrollOffset());
EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta()); EXPECT_VECTOR_EQ(m_scrollAmount, rootScrollLayer->scrollDelta());
break; break;
case 2: case 2:
EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, rootScrollLayer->scrollPosition()); EXPECT_VECTOR_EQ(m_secondScroll + m_scrollAmount, rootScrollLayer->scrollOffset());
EXPECT_SIZE_EQ(IntSize(0, 0), rootScrollLayer->scrollDelta()); EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), rootScrollLayer->scrollDelta());
endTest(); endTest();
} }
@@ -2482,9 +2483,9 @@ public:
private: private:
float m_deviceScaleFactor; float m_deviceScaleFactor;
IntPoint m_initialScroll; gfx::Vector2d m_initialScroll;
IntPoint m_secondScroll; gfx::Vector2d m_secondScroll;
IntSize m_scrollAmount; gfx::Vector2d m_scrollAmount;
int m_rootScrolls; int m_rootScrolls;
MockContentLayerClient m_mockDelegate; MockContentLayerClient m_mockDelegate;

@@ -511,7 +511,7 @@ TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOnMainThread(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOnMainThread(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrollableRegion(gfx::Rect(1, 1, 2, 2))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrollableRegion(gfx::Rect(1, 1, 2, 2)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollOffset(gfx::Vector2d(10, 10)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer")); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer"));

@@ -6,12 +6,14 @@
#include "cc/math_util.h" #include "cc/math_util.h"
#include "FloatSize.h" #include <cmath>
#include <limits>
#include "ui/gfx/quad_f.h" #include "ui/gfx/quad_f.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include <cmath> #include "ui/gfx/vector2d_f.h"
#include <public/WebTransformationMatrix.h> #include <public/WebTransformationMatrix.h>
using WebKit::WebTransformationMatrix; using WebKit::WebTransformationMatrix;
@@ -378,19 +380,24 @@ gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const WebTransformati
return gfx::Vector2dF(xScale, yScale); return gfx::Vector2dF(xScale, yScale);
} }
float MathUtil::smallestAngleBetweenVectors(const FloatSize& v1, const FloatSize& v2) static inline double rad2deg(double r)
{ {
float dotProduct = (v1.width() * v2.width() + v1.height() * v2.height()) / (v1.diagonalLength() * v2.diagonalLength()); double pi = 3.14159265358979323846;
// Clamp to compensate for rounding errors. return r * 180.0 / pi;
dotProduct = std::max(-1.f, std::min(1.f, dotProduct));
return rad2deg(acosf(dotProduct));
} }
FloatSize MathUtil::projectVector(const FloatSize& source, const FloatSize& destination) float MathUtil::smallestAngleBetweenVectors(gfx::Vector2dF v1, gfx::Vector2dF v2)
{ {
float sourceDotDestination = source.width() * destination.width() + source.height() * destination.height(); double dotProduct = gfx::DotProduct(v1, v2) / v1.Length() / v2.Length();
float projectedLength = sourceDotDestination / destination.diagonalLengthSquared(); // Clamp to compensate for rounding errors.
return FloatSize(projectedLength * destination.width(), projectedLength * destination.height()); dotProduct = std::max(-1.0, std::min(1.0, dotProduct));
return static_cast<float>(rad2deg(std::acos(dotProduct)));
}
gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF destination)
{
float projectedLength = gfx::DotProduct(source, destination) / destination.LengthSquared();
return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * destination.y());
} }
} // namespace cc } // namespace cc

@@ -18,12 +18,11 @@ namespace gfx {
class QuadF; class QuadF;
class Rect; class Rect;
class RectF; class RectF;
class Vector2dF;
} }
namespace cc { namespace cc {
class FloatSize;
struct HomogeneousCoordinate { struct HomogeneousCoordinate {
HomogeneousCoordinate(double newX, double newY, double newZ, double newW) HomogeneousCoordinate(double newX, double newY, double newZ, double newW)
: x(newX) : x(newX)
@@ -104,10 +103,10 @@ public:
// Returns the smallest angle between the given two vectors in degrees. Neither vector is // Returns the smallest angle between the given two vectors in degrees. Neither vector is
// assumed to be normalized. // assumed to be normalized.
static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&); static float smallestAngleBetweenVectors(gfx::Vector2dF, gfx::Vector2dF);
// Projects the |source| vector onto |destination|. Neither vector is assumed to be normalized. // Projects the |source| vector onto |destination|. Neither vector is assumed to be normalized.
static FloatSize projectVector(const FloatSize& source, const FloatSize& destination); static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF destination);
}; };
} // namespace cc } // namespace cc

@@ -6,7 +6,8 @@
#include "cc/math_util.h" #include "cc/math_util.h"
#include "FloatSize.h" #include <cmath>
#include "cc/test/geometry_test_utils.h" #include "cc/test/geometry_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
@@ -136,9 +137,9 @@ TEST(MathUtilTest, verifyEnclosingRectOfVerticesUsesCorrectInitialBounds)
TEST(MathUtilTest, smallestAngleBetweenVectors) TEST(MathUtilTest, smallestAngleBetweenVectors)
{ {
FloatSize x(1, 0); gfx::Vector2dF x(1, 0);
FloatSize y(0, 1); gfx::Vector2dF y(0, 1);
FloatSize testVector(0.5, 0.5); gfx::Vector2dF testVector(0.5, 0.5);
// Orthogonal vectors are at an angle of 90 degress. // Orthogonal vectors are at an angle of 90 degress.
EXPECT_EQ(90, MathUtil::smallestAngleBetweenVectors(x, y)); EXPECT_EQ(90, MathUtil::smallestAngleBetweenVectors(x, y));
@@ -154,31 +155,31 @@ TEST(MathUtilTest, smallestAngleBetweenVectors)
EXPECT_FLOAT_EQ(180, MathUtil::smallestAngleBetweenVectors(testVector, -testVector)); EXPECT_FLOAT_EQ(180, MathUtil::smallestAngleBetweenVectors(testVector, -testVector));
// The test vector is at a known angle. // The test vector is at a known angle.
EXPECT_FLOAT_EQ(45, floor(MathUtil::smallestAngleBetweenVectors(testVector, x))); EXPECT_FLOAT_EQ(45, std::floor(MathUtil::smallestAngleBetweenVectors(testVector, x)));
EXPECT_FLOAT_EQ(45, floor(MathUtil::smallestAngleBetweenVectors(testVector, y))); EXPECT_FLOAT_EQ(45, std::floor(MathUtil::smallestAngleBetweenVectors(testVector, y)));
} }
TEST(MathUtilTest, vectorProjection) TEST(MathUtilTest, vectorProjection)
{ {
FloatSize x(1, 0); gfx::Vector2dF x(1, 0);
FloatSize y(0, 1); gfx::Vector2dF y(0, 1);
FloatSize testVector(0.3f, 0.7f); gfx::Vector2dF testVector(0.3f, 0.7f);
// Orthogonal vectors project to a zero vector. // Orthogonal vectors project to a zero vector.
EXPECT_EQ(FloatSize(0, 0), MathUtil::projectVector(x, y)); EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), MathUtil::projectVector(x, y));
EXPECT_EQ(FloatSize(0, 0), MathUtil::projectVector(y, x)); EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), MathUtil::projectVector(y, x));
// Projecting a vector onto the orthonormal basis gives the corresponding component of the // Projecting a vector onto the orthonormal basis gives the corresponding component of the
// vector. // vector.
EXPECT_EQ(FloatSize(testVector.width(), 0), MathUtil::projectVector(testVector, x)); EXPECT_VECTOR_EQ(gfx::Vector2dF(testVector.x(), 0), MathUtil::projectVector(testVector, x));
EXPECT_EQ(FloatSize(0, testVector.height()), MathUtil::projectVector(testVector, y)); EXPECT_VECTOR_EQ(gfx::Vector2dF(0, testVector.y()), MathUtil::projectVector(testVector, y));
// Finally check than an arbitrary vector projected to another one gives a vector parallel to // Finally check than an arbitrary vector projected to another one gives a vector parallel to
// the second vector. // the second vector.
FloatSize targetVector(0.5, 0.2f); gfx::Vector2dF targetVector(0.5, 0.2f);
FloatSize projectedVector = MathUtil::projectVector(testVector, targetVector); gfx::Vector2dF projectedVector = MathUtil::projectVector(testVector, targetVector);
EXPECT_EQ(projectedVector.width() / targetVector.width(), EXPECT_EQ(projectedVector.x() / targetVector.x(),
projectedVector.height() / targetVector.height()); projectedVector.y() / targetVector.y());
} }
} // anonymous namespace } // anonymous namespace

@@ -6,22 +6,21 @@
#include "cc/page_scale_animation.h" #include "cc/page_scale_animation.h"
#include "FloatPoint.h" #include "cc/geometry.h"
#include "FloatSize.h"
#include "IntPoint.h"
#include "IntSize.h"
#include "ui/gfx/rect_f.h" #include "ui/gfx/rect_f.h"
#include "ui/gfx/vector2d_conversions.h"
#include "ui/gfx/vector2d_f.h"
#include <math.h> #include <math.h>
namespace cc { namespace cc {
scoped_ptr<PageScaleAnimation> PageScaleAnimation::create(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime) scoped_ptr<PageScaleAnimation> PageScaleAnimation::create(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
{ {
return make_scoped_ptr(new PageScaleAnimation(scrollStart, pageScaleStart, windowSize, contentSize, startTime)); return make_scoped_ptr(new PageScaleAnimation(scrollStart, pageScaleStart, windowSize, contentSize, startTime));
} }
PageScaleAnimation::PageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime) PageScaleAnimation::PageScaleAnimation(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime)
: m_scrollStart(scrollStart) : m_scrollStart(scrollStart)
, m_pageScaleStart(pageScaleStart) , m_pageScaleStart(pageScaleStart)
, m_windowSize(windowSize) , m_windowSize(windowSize)
@@ -38,13 +37,13 @@ PageScaleAnimation::~PageScaleAnimation()
{ {
} }
void PageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale, double duration) void PageScaleAnimation::zoomTo(gfx::Vector2d finalScroll, float finalPageScale, double duration)
{ {
if (m_pageScaleStart != finalPageScale) { if (m_pageScaleStart != finalPageScale) {
// For uniform-looking zooming, infer the anchor (point that remains in // For uniform-looking zooming, infer the anchor (point that remains in
// place throughout the zoom) from the start and end rects. // place throughout the zoom) from the start and end rects.
gfx::RectF startRect(cc::FloatPoint(cc::IntPoint(m_scrollStart)), m_windowSize); gfx::RectF startRect(gfx::PointAtOffsetFromOrigin(m_scrollStart), m_windowSize);
gfx::RectF endRect(cc::FloatPoint(cc::IntPoint(finalScroll)), m_windowSize); gfx::RectF endRect(gfx::PointAtOffsetFromOrigin(finalScroll), m_windowSize);
endRect.Scale(m_pageScaleStart / finalPageScale); endRect.Scale(m_pageScaleStart / finalPageScale);
// The anchor is the point which is at the same ratio of the sides of // The anchor is the point which is at the same ratio of the sides of
@@ -61,7 +60,7 @@ void PageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale
float ratioX = (startRect.x() - endRect.x()) / (endRect.width() - startRect.width()); float ratioX = (startRect.x() - endRect.x()) / (endRect.width() - startRect.width());
float ratioY = (startRect.y() - endRect.y()) / (endRect.height() - startRect.height()); float ratioY = (startRect.y() - endRect.y()) / (endRect.height() - startRect.height());
IntSize anchor(m_windowSize.width() * ratioX, m_windowSize.height() * ratioY); gfx::Vector2d anchor(m_windowSize.width() * ratioX, m_windowSize.height() * ratioY);
zoomWithAnchor(anchor, finalPageScale, duration); zoomWithAnchor(anchor, finalPageScale, duration);
} else { } else {
// If this is a pure translation, then there exists no anchor. Linearly // If this is a pure translation, then there exists no anchor. Linearly
@@ -73,16 +72,17 @@ void PageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale
} }
} }
void PageScaleAnimation::zoomWithAnchor(const IntSize& anchor, float finalPageScale, double duration) void PageScaleAnimation::zoomWithAnchor(gfx::Vector2d anchor, float finalPageScale, double duration)
{ {
m_scrollEnd = m_scrollStart + anchor; m_scrollEnd = m_scrollStart + anchor;
m_scrollEnd.scale(finalPageScale / m_pageScaleStart); m_scrollEnd = gfx::ToFlooredVector2d(cc::ScaleVector2d(m_scrollEnd, finalPageScale / m_pageScaleStart));
m_scrollEnd -= anchor; m_scrollEnd -= anchor;
m_scrollEnd.clampNegativeToZero(); m_scrollEnd = ClampFromBelow(m_scrollEnd, gfx::Vector2d());
gfx::SizeF scaledContentSize = m_contentSize.Scale(finalPageScale / m_pageScaleStart); gfx::SizeF scaledContentSize = m_contentSize.Scale(finalPageScale / m_pageScaleStart);
IntSize maxScrollPosition = roundedIntSize(cc::FloatSize(scaledContentSize) - cc::IntSize(m_windowSize)); gfx::Vector2d maxScrollOffset = gfx::ToRoundedVector2d(BottomRight(gfx::RectF(scaledContentSize)) - BottomRight(gfx::Rect(m_windowSize)));
m_scrollEnd = m_scrollEnd.shrunkTo(maxScrollPosition); m_scrollEnd = m_scrollEnd;
m_scrollEnd = ClampFromAbove(m_scrollEnd, maxScrollOffset);
m_anchor = anchor; m_anchor = anchor;
m_pageScaleEnd = finalPageScale; m_pageScaleEnd = finalPageScale;
@@ -90,7 +90,7 @@ void PageScaleAnimation::zoomWithAnchor(const IntSize& anchor, float finalPageSc
m_anchorMode = true; m_anchorMode = true;
} }
IntSize PageScaleAnimation::scrollOffsetAtTime(double time) const gfx::Vector2d PageScaleAnimation::scrollOffsetAtTime(double time) const
{ {
return scrollOffsetAtRatio(progressRatioForTime(time)); return scrollOffsetAtRatio(progressRatioForTime(time));
} }
@@ -113,7 +113,7 @@ float PageScaleAnimation::progressRatioForTime(double time) const
return (time - m_startTime) / m_duration; return (time - m_startTime) / m_duration;
} }
IntSize PageScaleAnimation::scrollOffsetAtRatio(float ratio) const gfx::Vector2d PageScaleAnimation::scrollOffsetAtRatio(float ratio) const
{ {
if (ratio <= 0) if (ratio <= 0)
return m_scrollStart; return m_scrollStart;
@@ -121,23 +121,23 @@ IntSize PageScaleAnimation::scrollOffsetAtRatio(float ratio) const
return m_scrollEnd; return m_scrollEnd;
float currentPageScale = pageScaleAtRatio(ratio); float currentPageScale = pageScaleAtRatio(ratio);
IntSize currentScrollOffset; gfx::Vector2d currentScrollOffset;
if (m_anchorMode) { if (m_anchorMode) {
// Keep the anchor stable on the screen at the current scale. // Keep the anchor stable on the screen at the current scale.
IntSize documentAnchor = m_scrollStart + m_anchor; gfx::Vector2dF documentAnchor = m_scrollStart + m_anchor;
documentAnchor.scale(currentPageScale / m_pageScaleStart); documentAnchor.Scale(currentPageScale / m_pageScaleStart);
currentScrollOffset = documentAnchor - m_anchor; currentScrollOffset = gfx::ToRoundedVector2d(documentAnchor - m_anchor);
} else { } else {
// First move both scroll offsets to the current coordinate space. // First move both scroll offsets to the current coordinate space.
FloatSize scaledStartScroll(m_scrollStart); gfx::Vector2dF scaledStartScroll(m_scrollStart);
scaledStartScroll.scale(currentPageScale / m_pageScaleStart); scaledStartScroll.Scale(currentPageScale / m_pageScaleStart);
FloatSize scaledEndScroll(m_scrollEnd); gfx::Vector2dF scaledEndScroll(m_scrollEnd);
scaledEndScroll.scale(currentPageScale / m_pageScaleEnd); scaledEndScroll.Scale(currentPageScale / m_pageScaleEnd);
// Linearly interpolate between them. // Linearly interpolate between them.
FloatSize delta = scaledEndScroll - scaledStartScroll; gfx::Vector2dF delta = scaledEndScroll - scaledStartScroll;
delta.scale(ratio); delta.Scale(ratio);
currentScrollOffset = roundedIntSize(scaledStartScroll + delta); currentScrollOffset = gfx::ToRoundedVector2d(scaledStartScroll + delta);
} }
return currentScrollOffset; return currentScrollOffset;

@@ -6,7 +6,8 @@
#define CC_PAGE_SCALE_ANIMATION_H_ #define CC_PAGE_SCALE_ANIMATION_H_
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "IntSize.h" #include "ui/gfx/size.h"
#include "ui/gfx/vector2d.h"
namespace cc { namespace cc {
@@ -19,7 +20,7 @@ public:
// Construct with the starting page scale and scroll offset (which is in // Construct with the starting page scale and scroll offset (which is in
// pageScaleStart space). The window size is the user-viewable area // pageScaleStart space). The window size is the user-viewable area
// in pixels. // in pixels.
static scoped_ptr<PageScaleAnimation> create(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime); static scoped_ptr<PageScaleAnimation> create(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
~PageScaleAnimation(); ~PageScaleAnimation();
// The following methods initialize the animation. Call one of them // The following methods initialize the animation. Call one of them
@@ -27,16 +28,16 @@ public:
// Zoom while explicitly specifying the top-left scroll position. The // Zoom while explicitly specifying the top-left scroll position. The
// scroll offset is in finalPageScale coordinates. // scroll offset is in finalPageScale coordinates.
void zoomTo(const IntSize& finalScroll, float finalPageScale, double duration); void zoomTo(gfx::Vector2d finalScroll, float finalPageScale, double duration);
// Zoom based on a specified onscreen anchor, which will remain at the same // Zoom based on a specified onscreen anchor, which will remain at the same
// position on the screen throughout the animation. The anchor is in local // position on the screen throughout the animation. The anchor is in local
// space relative to scrollStart. // space relative to scrollStart.
void zoomWithAnchor(const IntSize& anchor, float finalPageScale, double duration); void zoomWithAnchor(gfx::Vector2d anchor, float finalPageScale, double duration);
// Call these functions while the animation is in progress to output the // Call these functions while the animation is in progress to output the
// current state. // current state.
IntSize scrollOffsetAtTime(double time) const; gfx::Vector2d scrollOffsetAtTime(double time) const;
float pageScaleAtTime(double time) const; float pageScaleAtTime(double time) const;
bool isAnimationCompleteAtTime(double time) const; bool isAnimationCompleteAtTime(double time) const;
@@ -45,25 +46,25 @@ public:
double startTime() const { return m_startTime; } double startTime() const { return m_startTime; }
double duration() const { return m_duration; } double duration() const { return m_duration; }
double endTime() const { return m_startTime + m_duration; } double endTime() const { return m_startTime + m_duration; }
const IntSize& finalScrollOffset() const { return m_scrollEnd; } gfx::Vector2d finalScrollOffset() const { return m_scrollEnd; }
float finalPageScale() const { return m_pageScaleEnd; } float finalPageScale() const { return m_pageScaleEnd; }
protected: protected:
PageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime); PageScaleAnimation(gfx::Vector2d scrollStart, float pageScaleStart, const gfx::Size& windowSize, const gfx::Size& contentSize, double startTime);
private: private:
float progressRatioForTime(double time) const; float progressRatioForTime(double time) const;
IntSize scrollOffsetAtRatio(float ratio) const; gfx::Vector2d scrollOffsetAtRatio(float ratio) const;
float pageScaleAtRatio(float ratio) const; float pageScaleAtRatio(float ratio) const;
IntSize m_scrollStart; gfx::Vector2d m_scrollStart;
float m_pageScaleStart; float m_pageScaleStart;
gfx::Size m_windowSize; gfx::Size m_windowSize;
gfx::Size m_contentSize; gfx::Size m_contentSize;
bool m_anchorMode; bool m_anchorMode;
IntSize m_anchor; gfx::Vector2d m_anchor;
IntSize m_scrollEnd; gfx::Vector2d m_scrollEnd;
float m_pageScaleEnd; float m_pageScaleEnd;
double m_startTime; double m_startTime;

@@ -13,12 +13,12 @@
namespace gfx { namespace gfx {
class Rect; class Rect;
class Vector2d;
} }
namespace cc { namespace cc {
class Thread; class Thread;
class IntSize;
struct RenderingStats; struct RenderingStats;
struct RendererCapabilities; struct RendererCapabilities;
@@ -40,7 +40,7 @@ public:
virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) = 0; virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) = 0;
virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) = 0; virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) = 0;
virtual void finishAllRendering() = 0; virtual void finishAllRendering() = 0;

@@ -77,20 +77,20 @@ gfx::Size ScrollbarAnimationController::getScrollLayerBounds(const LayerImpl* sc
void ScrollbarAnimationController::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double) void ScrollbarAnimationController::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double)
{ {
m_currentPos = scrollLayer->scrollPosition() + scrollLayer->scrollDelta(); m_currentOffset = scrollLayer->scrollOffset() + scrollLayer->scrollDelta();
m_totalSize = getScrollLayerBounds(scrollLayer); m_totalSize = getScrollLayerBounds(scrollLayer);
m_maximum = scrollLayer->maxScrollPosition(); m_maximum = scrollLayer->maxScrollOffset();
if (m_horizontalScrollbarLayer) { if (m_horizontalScrollbarLayer) {
m_horizontalScrollbarLayer->setCurrentPos(m_currentPos.x()); m_horizontalScrollbarLayer->setCurrentPos(m_currentOffset.x());
m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width()); m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width());
m_horizontalScrollbarLayer->setMaximum(m_maximum.width()); m_horizontalScrollbarLayer->setMaximum(m_maximum.x());
} }
if (m_verticalScrollbarLayer) { if (m_verticalScrollbarLayer) {
m_verticalScrollbarLayer->setCurrentPos(m_currentPos.y()); m_verticalScrollbarLayer->setCurrentPos(m_currentOffset.y());
m_verticalScrollbarLayer->setTotalSize(m_totalSize.height()); m_verticalScrollbarLayer->setTotalSize(m_totalSize.height());
m_verticalScrollbarLayer->setMaximum(m_maximum.height()); m_verticalScrollbarLayer->setMaximum(m_maximum.y());
} }
} }

@@ -7,12 +7,9 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "FloatPoint.h" #include "ui/gfx/size.h"
#include "IntSize.h" #include "ui/gfx/vector2d.h"
#include "ui/gfx/vector2d_f.h"
namespace gfx {
class Size;
}
namespace cc { namespace cc {
@@ -39,9 +36,9 @@ public:
void setVerticalScrollbarLayer(ScrollbarLayerImpl* layer) { m_verticalScrollbarLayer = layer; } void setVerticalScrollbarLayer(ScrollbarLayerImpl* layer) { m_verticalScrollbarLayer = layer; }
ScrollbarLayerImpl* verticalScrollbarLayer() const { return m_verticalScrollbarLayer; } ScrollbarLayerImpl* verticalScrollbarLayer() const { return m_verticalScrollbarLayer; }
FloatPoint currentPos() const { return m_currentPos; } gfx::Vector2dF currentOffset() const { return m_currentOffset; }
gfx::Size totalSize() const { return m_totalSize; } gfx::Size totalSize() const { return m_totalSize; }
IntSize maximum() const { return m_maximum; } gfx::Vector2d maximum() const { return m_maximum; }
virtual void didPinchGestureBeginAtTime(double monotonicTime) { } virtual void didPinchGestureBeginAtTime(double monotonicTime) { }
virtual void didPinchGestureUpdateAtTime(double monotonicTime) { } virtual void didPinchGestureUpdateAtTime(double monotonicTime) { }
@@ -58,9 +55,9 @@ private:
ScrollbarLayerImpl* m_horizontalScrollbarLayer; ScrollbarLayerImpl* m_horizontalScrollbarLayer;
ScrollbarLayerImpl* m_verticalScrollbarLayer; ScrollbarLayerImpl* m_verticalScrollbarLayer;
FloatPoint m_currentPos; gfx::Vector2dF m_currentOffset;
gfx::Size m_totalSize; gfx::Size m_totalSize;
IntSize m_maximum; gfx::Vector2d m_maximum;
}; };
} // namespace cc } // namespace cc

@@ -51,10 +51,10 @@ void ScrollbarAnimationControllerLinearFade::didPinchGestureEndAtTime(double mon
void ScrollbarAnimationControllerLinearFade::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double monotonicTime) void ScrollbarAnimationControllerLinearFade::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double monotonicTime)
{ {
FloatPoint previousPos = currentPos(); gfx::Vector2dF previousPos = currentOffset();
ScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, monotonicTime); ScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, monotonicTime);
if (previousPos == currentPos()) if (previousPos == currentOffset())
return; return;
m_lastAwakenTime = monotonicTime; m_lastAwakenTime = monotonicTime;

@@ -23,8 +23,8 @@ protected:
m_contentLayer = m_scrollLayer->children()[0]; m_contentLayer = m_scrollLayer->children()[0];
m_scrollbarLayer = ScrollbarLayerImpl::create(3); m_scrollbarLayer = ScrollbarLayerImpl::create(3);
m_scrollLayer->setMaxScrollPosition(IntSize(50, 50)); m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50));
m_contentLayer->setBounds(IntSize(50, 50)); m_contentLayer->setBounds(gfx::Size(50, 50));
m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m_scrollLayer.get(), 2, 3); m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m_scrollLayer.get(), 2, 3);
m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get()); m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get());
@@ -50,13 +50,13 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin)
TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll) TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
{ {
m_scrollLayer->setScrollDelta(IntSize(1, 1)); m_scrollLayer->setScrollDelta(gfx::Vector2d(1, 1));
m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0); m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0);
m_scrollbarController->animate(0); m_scrollbarController->animate(0);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
m_scrollbarController->animate(1); m_scrollbarController->animate(1);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
m_scrollLayer->setScrollDelta(IntSize(2, 2)); m_scrollLayer->setScrollDelta(gfx::Vector2d(2, 2));
m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1); m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1);
m_scrollbarController->animate(2); m_scrollbarController->animate(2);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
@@ -68,7 +68,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity());
m_scrollbarController->animate(5); m_scrollbarController->animate(5);
EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity());
m_scrollLayer->setScrollDelta(IntSize(3, 3)); m_scrollLayer->setScrollDelta(gfx::Vector2d(3, 3));
m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 5); m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 5);
m_scrollbarController->animate(6); m_scrollbarController->animate(6);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
@@ -90,7 +90,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch)
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
m_scrollbarController->animate(1); m_scrollbarController->animate(1);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
m_scrollLayer->setScrollDelta(IntSize(1, 1)); m_scrollLayer->setScrollDelta(gfx::Vector2d(1, 1));
m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1); m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1);
m_scrollbarController->animate(2); m_scrollbarController->animate(2);
EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());

@@ -30,9 +30,9 @@ void ScrollbarGeometryFixedThumb::update(WebScrollbar* scrollbar)
int length = ScrollbarGeometryStub::thumbLength(scrollbar); int length = ScrollbarGeometryStub::thumbLength(scrollbar);
if (scrollbar->orientation() == WebScrollbar::Horizontal) if (scrollbar->orientation() == WebScrollbar::Horizontal)
m_thumbSize = IntSize(length, scrollbar->size().height); m_thumbSize = gfx::Size(length, scrollbar->size().height);
else else
m_thumbSize = IntSize(scrollbar->size().width, length); m_thumbSize = gfx::Size(scrollbar->size().width, length);
} }
WebScrollbarThemeGeometry* ScrollbarGeometryFixedThumb::clone() const WebScrollbarThemeGeometry* ScrollbarGeometryFixedThumb::clone() const

@@ -5,9 +5,9 @@
#ifndef CC_SCROLLBAR_GEOMETRY_FIXED_THUMB_H_ #ifndef CC_SCROLLBAR_GEOMETRY_FIXED_THUMB_H_
#define CC_SCROLLBAR_GEOMETRY_FIXED_THUMB_H_ #define CC_SCROLLBAR_GEOMETRY_FIXED_THUMB_H_
#include "IntSize.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/scrollbar_geometry_stub.h" #include "cc/scrollbar_geometry_stub.h"
#include "ui/gfx/size.h"
namespace cc { namespace cc {
@@ -32,7 +32,7 @@ public:
private: private:
explicit ScrollbarGeometryFixedThumb(scoped_ptr<WebKit::WebScrollbarThemeGeometry>); explicit ScrollbarGeometryFixedThumb(scoped_ptr<WebKit::WebScrollbarThemeGeometry>);
IntSize m_thumbSize; gfx::Size m_thumbSize;
}; };
} }

@@ -97,9 +97,9 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
layerTreeRoot->addChild(contentLayer); layerTreeRoot->addChild(contentLayer);
layerTreeRoot->addChild(scrollbarLayer); layerTreeRoot->addChild(scrollbarLayer);
layerTreeRoot->setScrollPosition(IntPoint(10, 20)); layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20));
layerTreeRoot->setMaxScrollPosition(IntSize(30, 50)); layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50));
contentLayer->setBounds(IntSize(100, 200)); contentLayer->setBounds(gfx::Size(100, 200));
scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), 0); scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), 0);
@@ -109,9 +109,9 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
EXPECT_EQ(100, ccScrollbarLayer->totalSize()); EXPECT_EQ(100, ccScrollbarLayer->totalSize());
EXPECT_EQ(30, ccScrollbarLayer->maximum()); EXPECT_EQ(30, ccScrollbarLayer->maximum());
layerTreeRoot->setScrollPosition(IntPoint(100, 200)); layerTreeRoot->setScrollOffset(gfx::Vector2d(100, 200));
layerTreeRoot->setMaxScrollPosition(IntSize(300, 500)); layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(300, 500));
contentLayer->setBounds(IntSize(1000, 2000)); contentLayer->setBounds(gfx::Size(1000, 2000));
ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrollbarAnimationController(); ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrollbarAnimationController();
layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), 0); layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), 0);
@@ -121,7 +121,7 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
EXPECT_EQ(1000, ccScrollbarLayer->totalSize()); EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
EXPECT_EQ(300, ccScrollbarLayer->maximum()); EXPECT_EQ(300, ccScrollbarLayer->maximum());
layerImplTreeRoot->scrollBy(FloatSize(12, 34)); layerImplTreeRoot->scrollBy(gfx::Vector2d(12, 34));
EXPECT_EQ(112, ccScrollbarLayer->currentPos()); EXPECT_EQ(112, ccScrollbarLayer->currentPos());
EXPECT_EQ(1000, ccScrollbarLayer->totalSize()); EXPECT_EQ(1000, ccScrollbarLayer->totalSize());

@@ -62,9 +62,9 @@ bool SingleThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect
return true; return true;
} }
void SingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) void SingleThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
{ {
m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, base::TimeTicks::Now(), duration); m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale, base::TimeTicks::Now(), duration);
} }
void SingleThreadProxy::finishAllRendering() void SingleThreadProxy::finishAllRendering()

@@ -23,7 +23,7 @@ public:
// Proxy implementation // Proxy implementation
virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE; virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE;
virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE; virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
virtual void finishAllRendering() OVERRIDE; virtual void finishAllRendering() OVERRIDE;
virtual bool isStarted() const OVERRIDE; virtual bool isStarted() const OVERRIDE;
virtual bool initializeContext() OVERRIDE; virtual bool initializeContext() OVERRIDE;

@@ -1,6 +0,0 @@
// Copyright 2012 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.
// Temporary forwarding header
#include "cc/stubs/float_point.h"

@@ -1,6 +0,0 @@
// Copyright 2012 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.
// Temporary forwarding header
#include "cc/stubs/float_size.h"

@@ -1,6 +0,0 @@
// Copyright 2012 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.
// Temporary forwarding header
#include "cc/stubs/int_point.h"

@@ -1,6 +0,0 @@
// Copyright 2012 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.
// Temporary forwarding header
#include "cc/stubs/int_size.h"

@@ -1,58 +0,0 @@
// Copyright (c) 2012 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 CC_STUBS_FLOATPOINT_H_
#define CC_STUBS_FLOATPOINT_H_
#include "FloatSize.h"
#include "IntPoint.h"
#if INSIDE_WEBKIT_BUILD
#include "Source/WebCore/platform/graphics/FloatPoint.h"
#else
#include "third_party/WebKit/Source/WebCore/platform/graphics/FloatPoint.h"
#endif
#include "ui/gfx/point_f.h"
namespace cc {
class FloatPoint : public WebCore::FloatPoint {
public:
FloatPoint() { }
FloatPoint(float width, float height)
: WebCore::FloatPoint(width, height)
{
}
FloatPoint(FloatSize size)
: WebCore::FloatPoint(size)
{
}
FloatPoint(IntPoint point)
: WebCore::FloatPoint(point)
{
}
FloatPoint(WebCore::IntPoint point)
: WebCore::FloatPoint(point)
{
}
FloatPoint(WebCore::FloatPoint point)
: WebCore::FloatPoint(point.x(), point.y())
{
}
explicit FloatPoint(gfx::PointF point)
: WebCore::FloatPoint(point.x(), point.y())
{
}
operator gfx::PointF() const { return gfx::PointF(x(), y()); }
};
}
#endif

@@ -1,59 +0,0 @@
// Copyright (c) 2012 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 CC_STUBS_FLOATSIZE_H_
#define CC_STUBS_FLOATSIZE_H_
#include "IntSize.h"
#if INSIDE_WEBKIT_BUILD
#include "Source/WebCore/platform/graphics/FloatSize.h"
#else
#include "third_party/WebKit/Source/WebCore/platform/graphics/FloatSize.h"
#endif
#include "ui/gfx/size_f.h"
#include "ui/gfx/vector2d_f.h"
namespace cc {
class FloatSize : public WebCore::FloatSize {
public:
FloatSize() { }
FloatSize(float width, float height)
: WebCore::FloatSize(width, height)
{
}
FloatSize(IntSize size)
: WebCore::FloatSize(size.width(), size.height())
{
}
FloatSize(WebCore::FloatSize size)
: WebCore::FloatSize(size.width(), size.height())
{
}
FloatSize(WebCore::IntSize size)
: WebCore::FloatSize(size.width(), size.height())
{
}
explicit FloatSize(gfx::SizeF size)
: WebCore::FloatSize(size.width(), size.height())
{
}
explicit FloatSize(gfx::Vector2dF vector)
: WebCore::FloatSize(vector.x(), vector.y())
{
}
operator gfx::SizeF() const { return gfx::SizeF(width(), height()); }
operator gfx::Vector2dF() const { return gfx::Vector2dF(width(), height()); }
};
}
#endif

@@ -1,47 +0,0 @@
// Copyright (c) 2012 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 CC_STUBS_INTPOINT_H_
#define CC_STUBS_INTPOINT_H_
#include "IntSize.h"
#if INSIDE_WEBKIT_BUILD
#include "Source/WebCore/platform/graphics/IntPoint.h"
#else
#include "third_party/WebKit/Source/WebCore/platform/graphics/IntPoint.h"
#endif
#include "ui/gfx/point.h"
namespace cc {
class IntPoint : public WebCore::IntPoint {
public:
IntPoint() { }
IntPoint(int width, int height)
: WebCore::IntPoint(width, height)
{
}
IntPoint(IntSize size)
: WebCore::IntPoint(size.width(), size.height())
{
}
IntPoint(WebCore::IntPoint point)
: WebCore::IntPoint(point.x(), point.y())
{
}
explicit IntPoint(gfx::Point point)
: WebCore::IntPoint(point.x(), point.y())
{
}
operator gfx::Point() const { return gfx::Point(x(), y()); }
};
}
#endif

@@ -1,50 +0,0 @@
// Copyright (c) 2012 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 CC_STUBS_INTSIZE_H_
#define CC_STUBS_INTSIZE_H_
#if INSIDE_WEBKIT_BUILD
#include "Source/WebCore/platform/graphics/IntSize.h"
#else
#include "third_party/WebKit/Source/WebCore/platform/graphics/IntSize.h"
#endif
#include "ui/gfx/size.h"
#include "ui/gfx/vector2d.h"
namespace cc {
class IntSize : public WebCore::IntSize {
public:
IntSize() { }
IntSize(int width, int height)
: WebCore::IntSize(width, height)
{
}
IntSize(WebCore::IntSize size)
: WebCore::IntSize(size.width(), size.height())
{
}
explicit IntSize(gfx::Size size)
: WebCore::IntSize(size.width(), size.height())
{
}
explicit IntSize(gfx::Vector2d vector)
: WebCore::IntSize(vector.x(), vector.y())
{
}
operator gfx::Size() const { return gfx::Size(width(), height()); }
operator gfx::Vector2d() const { return gfx::Vector2d(width(), height()); }
};
}
#endif

@@ -20,7 +20,7 @@ public:
virtual void didBeginFrame() OVERRIDE { } virtual void didBeginFrame() OVERRIDE { }
virtual void animate(double monotonicFrameBeginTime) OVERRIDE { } virtual void animate(double monotonicFrameBeginTime) OVERRIDE { }
virtual void layout() OVERRIDE { } virtual void layout() OVERRIDE { }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) OVERRIDE { } virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) OVERRIDE { }
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() OVERRIDE; virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() OVERRIDE;
virtual void didRecreateOutputSurface(bool success) OVERRIDE { } virtual void didRecreateOutputSurface(bool success) OVERRIDE { }

@@ -13,32 +13,38 @@ namespace WebKitTests {
// These are macros instead of functions so that we get useful line numbers where a test failed. // These are macros instead of functions so that we get useful line numbers where a test failed.
#define EXPECT_FLOAT_RECT_EQ(expected, actual) \ #define EXPECT_FLOAT_RECT_EQ(expected, actual) \
{ \ do { \
EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \
EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \
} } while (false)
#define EXPECT_RECT_EQ(expected, actual) \ #define EXPECT_RECT_EQ(expected, actual) \
{ \ do { \
EXPECT_EQ((expected).x(), (actual).x()); \ EXPECT_EQ((expected).x(), (actual).x()); \
EXPECT_EQ((expected).y(), (actual).y()); \ EXPECT_EQ((expected).y(), (actual).y()); \
EXPECT_EQ((expected).width(), (actual).width()); \ EXPECT_EQ((expected).width(), (actual).width()); \
EXPECT_EQ((expected).height(), (actual).height()); \ EXPECT_EQ((expected).height(), (actual).height()); \
} } while (false)
#define EXPECT_SIZE_EQ(expected, actual) \ #define EXPECT_SIZE_EQ(expected, actual) \
{ \ do { \
EXPECT_EQ((expected).width(), (actual).width()); \ EXPECT_EQ((expected).width(), (actual).width()); \
EXPECT_EQ((expected).height(), (actual).height()); \ EXPECT_EQ((expected).height(), (actual).height()); \
} } while (false)
#define EXPECT_POINT_EQ(expected, actual) \ #define EXPECT_POINT_EQ(expected, actual) \
{ \ do { \
EXPECT_EQ((expected).x(), (actual).x()); \ EXPECT_EQ((expected).x(), (actual).x()); \
EXPECT_EQ((expected).y(), (actual).y()); \ EXPECT_EQ((expected).y(), (actual).y()); \
} } while (false)
#define EXPECT_VECTOR_EQ(expected, actual) \
do { \
EXPECT_EQ((expected).x(), (actual).x()); \
EXPECT_EQ((expected).y(), (actual).y()); \
} while (false)
// This is a function rather than a macro because when this is included as a macro // This is a function rather than a macro because when this is included as a macro
// in bulk, it causes a significant slow-down in compilation time. This problem // in bulk, it causes a significant slow-down in compilation time. This problem

@@ -219,7 +219,7 @@ public:
m_testHooks->layout(); m_testHooks->layout();
} }
virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OVERRIDE virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE
{ {
m_testHooks->applyScrollAndScale(scrollDelta, scale); m_testHooks->applyScrollAndScale(scrollDelta, scale);
} }

@@ -34,7 +34,7 @@ public:
virtual void drawLayersOnThread(cc::LayerTreeHostImpl*) { } virtual void drawLayersOnThread(cc::LayerTreeHostImpl*) { }
virtual void animateLayers(cc::LayerTreeHostImpl*, base::TimeTicks monotonicTime) { } virtual void animateLayers(cc::LayerTreeHostImpl*, base::TimeTicks monotonicTime) { }
virtual void willAnimateLayers(cc::LayerTreeHostImpl*, base::TimeTicks monotonicTime) { } virtual void willAnimateLayers(cc::LayerTreeHostImpl*, base::TimeTicks monotonicTime) { }
virtual void applyScrollAndScale(const cc::IntSize&, float) { } virtual void applyScrollAndScale(gfx::Vector2d, float) { }
virtual void animate(base::TimeTicks monotonicTime) { } virtual void animate(base::TimeTicks monotonicTime) { }
virtual void layout() { } virtual void layout() { }
virtual void didRecreateOutputSurface(bool succeeded) { } virtual void didRecreateOutputSurface(bool succeeded) { }

@@ -117,17 +117,17 @@ void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request)
m_schedulerOnImplThread->setNeedsForcedRedraw(); m_schedulerOnImplThread->setNeedsForcedRedraw();
} }
void ThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) void ThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
{ {
DCHECK(Proxy::isMainThread()); DCHECK(Proxy::isMainThread());
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScaleAnimationOnImplThread, base::Unretained(this), targetPosition, useAnchor, scale, duration)); Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScaleAnimationOnImplThread, base::Unretained(this), targetOffset, useAnchor, scale, duration));
} }
void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, base::TimeDelta duration) void ThreadProxy::requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
{ {
DCHECK(Proxy::isImplThread()); DCHECK(Proxy::isImplThread());
if (m_layerTreeHostImpl.get()) if (m_layerTreeHostImpl.get())
m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, base::TimeTicks::Now(), duration); m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale, base::TimeTicks::Now(), duration);
} }
void ThreadProxy::finishAllRendering() void ThreadProxy::finishAllRendering()

@@ -30,7 +30,7 @@ public:
// Proxy implementation // Proxy implementation
virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE; virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE;
virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE; virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
virtual void finishAllRendering() OVERRIDE; virtual void finishAllRendering() OVERRIDE;
virtual bool isStarted() const OVERRIDE; virtual bool isStarted() const OVERRIDE;
virtual bool initializeContext() OVERRIDE; virtual bool initializeContext() OVERRIDE;
@@ -111,7 +111,7 @@ private:
void beginFrameCompleteOnImplThread(CompletionEvent*, ResourceUpdateQueue*); void beginFrameCompleteOnImplThread(CompletionEvent*, ResourceUpdateQueue*);
void beginFrameAbortedOnImplThread(); void beginFrameAbortedOnImplThread();
void requestReadbackOnImplThread(ReadbackRequest*); void requestReadbackOnImplThread(ReadbackRequest*);
void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, base::TimeDelta duration); void requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
void finishAllRenderingOnImplThread(CompletionEvent*); void finishAllRenderingOnImplThread(CompletionEvent*);
void initializeImplOnImplThread(CompletionEvent*, InputHandler*); void initializeImplOnImplThread(CompletionEvent*, InputHandler*);
void setSurfaceReadyOnImplThread(); void setSurfaceReadyOnImplThread();

@@ -86,8 +86,6 @@
], ],
'sources': [ 'sources': [
'<@(webkit_compositor_bindings_sources)', '<@(webkit_compositor_bindings_sources)',
'webcore_convert.cc',
'webcore_convert.h',
], ],
}, },
], ],

@@ -12,7 +12,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "webcore_convert.h"
using namespace cc; using namespace cc;

@@ -18,7 +18,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h"
#include "web_animation_impl.h" #include "web_animation_impl.h"
#include "webcore_convert.h"
using cc::ActiveAnimation; using cc::ActiveAnimation;
using cc::Layer; using cc::Layer;
@@ -346,22 +345,22 @@ void WebLayerImpl::setForceRenderSurface(bool forceRenderSurface)
void WebLayerImpl::setScrollPosition(WebPoint position) void WebLayerImpl::setScrollPosition(WebPoint position)
{ {
m_layer->setScrollPosition(convert(position)); m_layer->setScrollOffset(gfx::Point(position).OffsetFromOrigin());
} }
WebPoint WebLayerImpl::scrollPosition() const WebPoint WebLayerImpl::scrollPosition() const
{ {
return WebPoint(m_layer->scrollPosition().x(), m_layer->scrollPosition().y()); return gfx::PointAtOffsetFromOrigin(m_layer->scrollOffset());
} }
void WebLayerImpl::setMaxScrollPosition(WebSize maxScrollPosition) void WebLayerImpl::setMaxScrollPosition(WebSize maxScrollPosition)
{ {
m_layer->setMaxScrollPosition(convert(maxScrollPosition)); m_layer->setMaxScrollOffset(maxScrollPosition);
} }
WebSize WebLayerImpl::maxScrollPosition() const WebSize WebLayerImpl::maxScrollPosition() const
{ {
return convert(m_layer->maxScrollPosition()); return m_layer->maxScrollOffset();
} }
void WebLayerImpl::setScrollable(bool scrollable) void WebLayerImpl::setScrollable(bool scrollable)

@@ -16,7 +16,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "webcore_convert.h"
#include "web_layer_impl.h" #include "web_layer_impl.h"
#include "web_to_ccinput_handler_adapter.h" #include "web_to_ccinput_handler_adapter.h"
@@ -130,7 +129,7 @@ void WebLayerTreeViewImpl::setPageScaleFactorAndLimits(float pageScaleFactor, fl
void WebLayerTreeViewImpl::startPageScaleAnimation(const WebPoint& scroll, bool useAnchor, float newPageScale, double durationSec) void WebLayerTreeViewImpl::startPageScaleAnimation(const WebPoint& scroll, bool useAnchor, float newPageScale, double durationSec)
{ {
base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec * base::Time::kMicrosecondsPerSecond); base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec * base::Time::kMicrosecondsPerSecond);
m_layerTreeHost->startPageScaleAnimation(IntSize(scroll.x, scroll.y), useAnchor, newPageScale, duration); m_layerTreeHost->startPageScaleAnimation(gfx::Vector2d(scroll.x, scroll.y), useAnchor, newPageScale, duration);
} }
void WebLayerTreeViewImpl::setNeedsAnimate() void WebLayerTreeViewImpl::setNeedsAnimate()
@@ -231,9 +230,9 @@ void WebLayerTreeViewImpl::layout()
m_client->layout(); m_client->layout();
} }
void WebLayerTreeViewImpl::applyScrollAndScale(const cc::IntSize& scrollDelta, float pageScale) void WebLayerTreeViewImpl::applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale)
{ {
m_client->applyScrollAndScale(convert(scrollDelta), pageScale); m_client->applyScrollAndScale(scrollDelta, pageScale);
} }
scoped_ptr<WebCompositorOutputSurface> WebLayerTreeViewImpl::createOutputSurface() scoped_ptr<WebCompositorOutputSurface> WebLayerTreeViewImpl::createOutputSurface()

@@ -58,7 +58,7 @@ public:
virtual void didBeginFrame() OVERRIDE; virtual void didBeginFrame() OVERRIDE;
virtual void animate(double monotonicFrameBeginTime) OVERRIDE; virtual void animate(double monotonicFrameBeginTime) OVERRIDE;
virtual void layout() OVERRIDE; virtual void layout() OVERRIDE;
virtual void applyScrollAndScale(const cc::IntSize& scrollDelta, float pageScale) OVERRIDE; virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) OVERRIDE;
virtual scoped_ptr<WebCompositorOutputSurface> createOutputSurface() OVERRIDE; virtual scoped_ptr<WebCompositorOutputSurface> createOutputSurface() OVERRIDE;
virtual void didRecreateOutputSurface(bool success) OVERRIDE; virtual void didRecreateOutputSurface(bool success) OVERRIDE;
virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE;

@@ -6,10 +6,7 @@
#include "web_to_ccinput_handler_adapter.h" #include "web_to_ccinput_handler_adapter.h"
#include "cc/stubs/int_point.h"
#include "cc/stubs/int_size.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandlerClient.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandlerClient.h"
#include "webcore_convert.h"
#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, cc_name) \ #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, cc_name) \
COMPILE_ASSERT(int(WebKit::webkit_name) == int(cc::cc_name), mismatching_enums) COMPILE_ASSERT(int(WebKit::webkit_name) == int(cc::cc_name), mismatching_enums)
@@ -54,7 +51,7 @@ public:
virtual void scrollBy(WebPoint point, WebSize offset) OVERRIDE virtual void scrollBy(WebPoint point, WebSize offset) OVERRIDE
{ {
m_client->scrollBy(point, convert(offset)); m_client->scrollBy(point, offset);
} }
virtual void scrollEnd() OVERRIDE virtual void scrollEnd() OVERRIDE
@@ -69,7 +66,7 @@ public:
virtual void pinchGestureUpdate(float magnifyDelta, WebPoint anchor) OVERRIDE virtual void pinchGestureUpdate(float magnifyDelta, WebPoint anchor) OVERRIDE
{ {
m_client->pinchGestureUpdate(magnifyDelta, convert(anchor)); m_client->pinchGestureUpdate(magnifyDelta, anchor);
} }
virtual void pinchGestureEnd() OVERRIDE virtual void pinchGestureEnd() OVERRIDE
@@ -85,7 +82,7 @@ public:
{ {
base::TimeTicks startTime = base::TimeTicks::FromInternalValue(startTimeSec * base::Time::kMicrosecondsPerSecond); base::TimeTicks startTime = base::TimeTicks::FromInternalValue(startTimeSec * base::Time::kMicrosecondsPerSecond);
base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec * base::Time::kMicrosecondsPerSecond); base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec * base::Time::kMicrosecondsPerSecond);
m_client->startPageScaleAnimation(convert(targetPosition), anchorPoint, pageScale, startTime, duration); m_client->startPageScaleAnimation(targetPosition, anchorPoint, pageScale, startTime, duration);
} }
virtual void scheduleAnimation() OVERRIDE virtual void scheduleAnimation() OVERRIDE

@@ -1,38 +0,0 @@
// Copyright (c) 2012 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 "config.h"
#include "webcore_convert.h"
namespace WebKit {
WebCore::FloatPoint convert(const WebFloatPoint& point)
{
return WebCore::FloatPoint(point.x, point.y);
}
WebCore::IntPoint convert(const WebPoint& point)
{
return WebCore::IntPoint(point.x, point.y);
}
WebCore::IntSize convert(const WebSize& size)
{
return WebCore::IntSize(size.width, size.height);
}
WebSize convert(const WebCore::IntSize& size)
{
return WebSize(size.width(), size.height());
}
WebFloatPoint convert(const WebCore::FloatPoint& point)
{
return WebFloatPoint(point.x(), point.y());
}
}

@@ -1,26 +0,0 @@
// Copyright (c) 2012 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_COMPOSITOR_BINDINGS_WEBCORE_CONVERT_H_
#define WEBKIT_COMPOSITOR_BINDINGS_WEBCORE_CONVERT_H_
#include "FloatPoint.h"
#include "IntPoint.h"
#include "IntSize.h"
#include <public/WebFloatPoint.h>
#include <public/WebRect.h>
#include <public/WebPoint.h>
#include <public/WebSize.h>
namespace WebKit {
WebCore::FloatPoint convert(const WebFloatPoint& point);
WebCore::IntPoint convert(const WebPoint& point);
WebCore::IntSize convert(const WebSize& size);
WebSize convert(const WebCore::IntSize& size);
WebFloatPoint convert(const WebCore::FloatPoint& point);
}
#endif // WEBKIT_COMPOSITOR_BINDINGS_WEBCORE_CONVERT_H_