summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kobes <skobes@chromium.org>2016-03-10 10:57:39 -0800
committerSteve Kobes <skobes@chromium.org>2016-03-10 18:59:29 +0000
commit984e315638932b66c55ffac58df5ebc9e5ce8a0f (patch)
treee5195180b62cc30c4db35db34d37f339b49b1f73
parent90987823fb61e3e94c0289a68095b5e52342762a (diff)
downloadchromium_src-984e315638932b66c55ffac58df5ebc9e5ce8a0f.zip
chromium_src-984e315638932b66c55ffac58df5ebc9e5ce8a0f.tar.gz
chromium_src-984e315638932b66c55ffac58df5ebc9e5ce8a0f.tar.bz2
Account for scroll origin in scroll animators.
Blink and cc have different notions of scroll offset - Blink's is relative to the scroll origin which is non-zero in RTL documents. The CompositorScrollOffsetAnimationCurve must work entirely in cc scroll offsets since it is handed over to cc which doesn't know about the scroll origin. This patch teaches ScrollAnimator and ProgrammaticScrollAnimator to convert in both directions when creating and using the curve object. BUG=581264 Review URL: https://codereview.chromium.org/1776503002 Cr-Commit-Position: refs/heads/master@{#379974} (cherry picked from commit 0bb16600006793953292ee1e7fd8bf0a66f575dc) Review URL: https://codereview.chromium.org/1777353002 . Cr-Commit-Position: refs/branch-heads/2623@{#609} Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
-rw-r--r--third_party/WebKit/LayoutTests/TestExpectations1
-rw-r--r--third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl-expected.txt11
-rw-r--r--third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl.html40
-rw-r--r--third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp10
-rw-r--r--third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp14
-rw-r--r--third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp12
-rw-r--r--third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h3
7 files changed, 81 insertions, 10 deletions
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 02b2188..a21031c 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -856,6 +856,7 @@ crbug.com/364614 [ Mac ] virtual/threaded/fast/scroll-behavior/overflow-scroll-r
crbug.com/364614 [ Mac ] virtual/scroll_customization/fast/scroll-behavior/overflow-scroll-root-frame-animates.html [ Skip ]
crbug.com/574283 [ Mac ] virtual/threaded/fast/scroll-behavior/smooth-scroll/fixed-background-in-iframe.html [ Skip ]
+crbug.com/574283 [ Mac ] virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl.html [ Skip ]
crbug.com/552556 [ Win Linux ] virtual/threaded/fast/scroll-behavior/overflow-scroll-root-frame-animates.html [ Pass Slow Timeout ]
crbug.com/552556 [ Win Linux ] virtual/threaded/fast/scroll-behavior/overflow-scroll-animates.html [ Pass Slow Timeout ]
diff --git a/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl-expected.txt b/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl-expected.txt
new file mode 100644
index 0000000..955b971
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl-expected.txt
@@ -0,0 +1,11 @@
+This test verifies that both input-driven and programmatic smooth scrolls serviced by the compositor thread go to the correct scroll position on RTL pages with horizontal overflow.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS scrollX became -80
+PASS scrollX became -40
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl.html b/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl.html
new file mode 100644
index 0000000..e011d22
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/virtual/threaded/fast/scroll-behavior/smooth-scroll/horizontal-smooth-scroll-in-rtl.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<script src="../../../../../resources/js-test.js"></script>
+<style>
+
+html {
+ writing-mode: vertical-rl;
+ width: 1000px;
+}
+
+</style>
+<script>
+
+var jsTestIsAsync = true;
+
+description("This test verifies that both input-driven and programmatic " +
+ "smooth scrolls serviced by the compositor thread go to the correct " +
+ "scroll position on RTL pages with horizontal overflow.");
+
+onload = function() {
+ if (!window.eventSender) {
+ debug("This test requires window.eventSender.")
+ finishJSTest();
+ return;
+ }
+
+ // Start scrolled due to http://crbug.com/592799.
+ scrollBy(-120, 0);
+
+ // Click scrollbar stepper.
+ eventSender.mouseMoveTo(795, 595);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ shouldBecomeEqual("scrollX", "-80", function() {
+ scrollBy({left: 40, behavior: "smooth"});
+ shouldBecomeEqual("scrollX", "-40", finishJSTest);
+ });
+};
+
+</script>
diff --git a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp
index 1b38d83..3fa59ee 100644
--- a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp
@@ -52,7 +52,7 @@ void ProgrammaticScrollAnimator::animateToOffset(FloatPoint offset)
m_startTime = 0.0;
m_targetOffset = offset;
m_animationCurve = adoptPtr(Platform::current()->compositorSupport()->createScrollOffsetAnimationCurve(
- m_targetOffset,
+ compositorOffsetFromBlinkOffset(m_targetOffset),
WebCompositorAnimationCurve::TimingFunctionTypeEaseInOut,
WebScrollOffsetAnimationCurve::ScrollDurationDeltaBased));
@@ -79,7 +79,7 @@ void ProgrammaticScrollAnimator::tickAnimation(double monotonicTime)
m_startTime = monotonicTime;
double elapsedTime = monotonicTime - m_startTime;
bool isFinished = (elapsedTime > m_animationCurve->duration());
- FloatPoint offset = m_animationCurve->getValue(elapsedTime);
+ FloatPoint offset = blinkOffsetFromCompositorOffset(m_animationCurve->getValue(elapsedTime));
notifyPositionChanged(IntPoint(offset.x(), offset.y()));
if (isFinished) {
@@ -128,7 +128,8 @@ void ProgrammaticScrollAnimator::updateCompositorAnimations()
if (!sentToCompositor) {
m_runState = RunState::RunningOnMainThread;
- m_animationCurve->setInitialValue(FloatPoint(m_scrollableArea->scrollPosition()));
+ m_animationCurve->setInitialValue(compositorOffsetFromBlinkOffset(
+ FloatPoint(m_scrollableArea->scrollPosition())));
if (!m_scrollableArea->scheduleAnimation()) {
notifyPositionChanged(IntPoint(m_targetOffset.x(), m_targetOffset.y()));
resetAnimationState();
@@ -147,7 +148,8 @@ void ProgrammaticScrollAnimator::layerForCompositedScrollingDidChange(WebComposi
m_runState = RunState::RunningOnMainThread;
m_compositorAnimationId = 0;
m_compositorAnimationGroupId = 0;
- m_animationCurve->setInitialValue(FloatPoint(m_scrollableArea->scrollPosition()));
+ m_animationCurve->setInitialValue(compositorOffsetFromBlinkOffset(
+ FloatPoint(m_scrollableArea->scrollPosition())));
m_scrollableArea->registerForAnimation();
if (!m_scrollableArea->scheduleAnimation()) {
resetAnimationState();
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
index de0000b..7952137 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
@@ -131,7 +131,8 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(
// Running on the main thread, simply update the target offset instead
// of sending to the compositor.
- m_animationCurve->updateTarget(m_timeFunction() - m_startTime, targetPos);
+ m_animationCurve->updateTarget(m_timeFunction() - m_startTime,
+ compositorOffsetFromBlinkOffset(targetPos));
return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0);
}
@@ -170,8 +171,9 @@ void ScrollAnimator::tickAnimation(double monotonicTime)
double elapsedTime = monotonicTime - m_startTime;
bool isFinished = (elapsedTime > m_animationCurve->duration());
- FloatPoint offset = isFinished ? m_animationCurve->targetValue()
- : m_animationCurve->getValue(elapsedTime);
+ FloatPoint offset = blinkOffsetFromCompositorOffset(isFinished
+ ? m_animationCurve->targetValue()
+ : m_animationCurve->getValue(elapsedTime));
offset = FloatPoint(m_scrollableArea->clampScrollPosition(offset));
@@ -219,19 +221,19 @@ void ScrollAnimator::updateCompositorAnimations()
m_compositorAnimationGroupId = 0;
m_animationCurve->updateTarget(m_timeFunction() - m_startTime,
- m_targetOffset);
+ compositorOffsetFromBlinkOffset(m_targetOffset));
m_runState = RunState::WaitingToSendToCompositor;
}
if (!m_animationCurve) {
m_animationCurve = adoptPtr(Platform::current()->compositorSupport()
->createScrollOffsetAnimationCurve(
- m_targetOffset,
+ compositorOffsetFromBlinkOffset(m_targetOffset),
WebCompositorAnimationCurve::TimingFunctionTypeEaseInOut,
m_lastGranularity == ScrollByPixel ?
WebScrollOffsetAnimationCurve::ScrollDurationInverseDelta :
WebScrollOffsetAnimationCurve::ScrollDurationConstant));
- m_animationCurve->setInitialValue(currentPosition());
+ m_animationCurve->setInitialValue(compositorOffsetFromBlinkOffset(currentPosition()));
}
bool sentToCompositor = false;
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp
index 142b27e..19f77ba 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp
@@ -195,4 +195,16 @@ WebCompositorAnimationPlayer* ScrollAnimatorCompositorCoordinator::compositorPla
return m_compositorPlayer.get();
}
+FloatPoint ScrollAnimatorCompositorCoordinator::compositorOffsetFromBlinkOffset(FloatPoint offset)
+{
+ offset.moveBy(scrollableArea()->scrollOrigin());
+ return offset;
+}
+
+FloatPoint ScrollAnimatorCompositorCoordinator::blinkOffsetFromCompositorOffset(FloatPoint offset)
+{
+ offset.moveBy(-scrollableArea()->scrollOrigin());
+ return offset;
+}
+
} // namespace blink
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h
index 2f38927..afc0ef1 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h
@@ -46,6 +46,9 @@ protected:
void removeAnimation();
void abortAnimation();
+ FloatPoint compositorOffsetFromBlinkOffset(FloatPoint);
+ FloatPoint blinkOffsetFromCompositorOffset(FloatPoint);
+
void compositorAnimationFinished(int groupId);
void reattachCompositorPlayerIfNeeded(WebCompositorAnimationTimeline*);