Enable Scroll Animation for RenderLayerScrollableArea

In Blink, only FrameView scrollbars animation is enabled and serviced.
This patch enables scroll animation for non-mainframe scrollbars (
RenderLayerScrollableArea) and service them.

BUG=575, 299059, 307578, 359028

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

git-svn-id: svn://svn.chromium.org/blink/trunk@172418 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 29a3380e
...@@ -591,6 +591,9 @@ crbug.com/304841 [ SnowLeopard ] inspector/device-emulation/device-emulation-980 ...@@ -591,6 +591,9 @@ crbug.com/304841 [ SnowLeopard ] inspector/device-emulation/device-emulation-980
crbug.com/304841 [ SnowLeopard ] inspector/device-emulation/device-emulation-restore.html [ Failure ] crbug.com/304841 [ SnowLeopard ] inspector/device-emulation/device-emulation-restore.html [ Failure ]
crbug.com/304841 [ SnowLeopard ] inspector/device-emulation/device-emulation-small.html [ Failure ] crbug.com/304841 [ SnowLeopard ] inspector/device-emulation/device-emulation-small.html [ Failure ]
# Mac sets NSUserDefault setting to turn off smooth scrolling, and it cannot be turned on for a single test.
crbug.com/364614 [ Mac ] fast/scroll-behavior/sub-frame-scroll.html [ Failure ]
# Complex text failures on XP (likely caused by r158845). # Complex text failures on XP (likely caused by r158845).
crbug.com/305290 [ XP ] fast/text/international/plane2.html [ Failure ] crbug.com/305290 [ XP ] fast/text/international/plane2.html [ Failure ]
#crbug.com/316145 [ XP ] fast/text/justify-ideograph-complex.html [ Failure Pass ] #crbug.com/316145 [ XP ] fast/text/justify-ideograph-complex.html [ Failure Pass ]
......
This is a testharness.js-based test.
PASS Reset scrollable area to starting point.
PASS Smooth scrolling is on for non mainframe scrollbars.
Harness: the test ran to completion.
<!DOCTYPE html>
<html>
<head>
<style>
#scroll {
width: 100px;
height: 100px;
overflow:scroll;
}
#content {
width: 10000px;
height: 10000px;
background-color: blue;
}
</style>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
if (window.internals) {
window.internals.settings.setScrollAnimatorEnabled(true);
}
setup({explicit_done:true});
</script>
</head>
<body>
<div id="scroll">
<div id="content"></div>
</div>
<script>
/**
* This test is to make sure smooth scrolling is turned on sub frame
* scrollbars.
* Actually animation and calculation is tested by unittest. This only
* test that non main frame scrollbars can scroll and they are not just
* snapping to the correct position when smooth scrolling is on.
*/
function testing() {
var div = document.getElementById("scroll");
// Generate what end position should be if there is no smooth scrolling.
var endPosition = (function() {
if (window.internals) {
window.internals.settings.setScrollAnimatorEnabled(false);
}
div.scrollByPages(10);
if (window.internals) {
window.internals.settings.setScrollAnimatorEnabled(true);
}
return div.scrollTop;
}) ();
// Test that div is scrollable and reset scrollTop to 0.
test(function() {div.scrollTop = 0; assert_equals(div.scrollTop, 0)}, "Reset scrollable area to starting point.");
var smoothScrollTest = async_test("Smooth scrolling is on for non mainframe scrollbars.");
// Test that checks scrollTop is between start and end.
var testFunc = smoothScrollTest.step_func(function() {
var cur = div.scrollTop;
assert_greater_than(cur, 0, "Scrolling has started.");
assert_less_than(cur, endPosition, "Scrolling hasn't ended.");
smoothScrollTest.done();
done();
});
// In the middle of scroll animation, scrollTop should be between start and end position.
div.onscroll = window.setTimeout(testFunc, 200);
div.scrollByPages(10);
// If there is no smooth scrolling, test times out. Explicitly ends test so it would show up as fail.
window.setTimeout(function() {
smoothScrollTest.done();
done();
}, 1000);
}
window.addEventListener('load', testing, false);
</script>
</body>
</html>
...@@ -29,16 +29,26 @@ void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime) ...@@ -29,16 +29,26 @@ void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime)
m_animationFramePending = false; m_animationFramePending = false;
TemporaryChange<bool> servicing(m_servicingAnimations, true); TemporaryChange<bool> servicing(m_servicingAnimations, true);
for (RefPtr<LocalFrame> frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
frame->view()->serviceScrollAnimations();
DocumentAnimations::updateAnimationTimingForAnimationFrame(*frame->document(), monotonicAnimationStartTime);
SVGDocumentExtensions::serviceOnAnimationFrame(*frame->document(), monotonicAnimationStartTime);
}
Vector<RefPtr<Document> > documents; Vector<RefPtr<Document> > documents;
for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) for (RefPtr<LocalFrame> frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext())
documents.append(frame->document()); documents.append(frame->document());
for (size_t i = 0; i < documents.size(); ++i) {
if (documents[i]->frame()) {
documents[i]->view()->serviceScrollAnimations();
if (const FrameView::ScrollableAreaSet* scrollableAreas = documents[i]->view()->scrollableAreas()) {
for (FrameView::ScrollableAreaSet::iterator it = scrollableAreas->begin(); it != scrollableAreas->end(); ++it)
(*it)->serviceScrollAnimations();
}
}
}
for (size_t i = 0; i < documents.size(); ++i) {
DocumentAnimations::updateAnimationTimingForAnimationFrame(*documents[i], monotonicAnimationStartTime);
SVGDocumentExtensions::serviceOnAnimationFrame(*documents[i], monotonicAnimationStartTime);
}
for (size_t i = 0; i < documents.size(); ++i) for (size_t i = 0; i < documents.size(); ++i)
documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime); documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime);
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "core/editing/FrameSelection.h" #include "core/editing/FrameSelection.h"
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLFrameOwnerElement.h" #include "core/html/HTMLFrameOwnerElement.h"
#include "core/inspector/InspectorInstrumentation.h" #include "core/inspector/InspectorInstrumentation.h"
#include "core/page/EventHandler.h" #include "core/page/EventHandler.h"
...@@ -478,6 +479,20 @@ IntPoint RenderLayerScrollableArea::lastKnownMousePosition() const ...@@ -478,6 +479,20 @@ IntPoint RenderLayerScrollableArea::lastKnownMousePosition() const
return m_box->frame() ? m_box->frame()->eventHandler().lastKnownMousePosition() : IntPoint(); return m_box->frame() ? m_box->frame()->eventHandler().lastKnownMousePosition() : IntPoint();
} }
bool RenderLayerScrollableArea::scrollAnimatorEnabled() const
{
return m_box->frame()->settings() && m_box->frame()->settings()->scrollAnimatorEnabled();
}
bool RenderLayerScrollableArea::scheduleAnimation()
{
if (HostWindow* window = m_box->frameView()->hostWindow()) {
window->scheduleAnimation();
return true;
}
return false;
}
bool RenderLayerScrollableArea::shouldSuspendScrollAnimations() const bool RenderLayerScrollableArea::shouldSuspendScrollAnimations() const
{ {
RenderView* view = m_box->view(); RenderView* view = m_box->view();
......
...@@ -102,6 +102,8 @@ public: ...@@ -102,6 +102,8 @@ public:
virtual IntSize contentsSize() const OVERRIDE; virtual IntSize contentsSize() const OVERRIDE;
virtual IntSize overhangAmount() const OVERRIDE; virtual IntSize overhangAmount() const OVERRIDE;
virtual IntPoint lastKnownMousePosition() const OVERRIDE; virtual IntPoint lastKnownMousePosition() const OVERRIDE;
virtual bool scrollAnimatorEnabled() const OVERRIDE;
virtual bool scheduleAnimation() OVERRIDE;
virtual bool shouldSuspendScrollAnimations() const OVERRIDE; virtual bool shouldSuspendScrollAnimations() const OVERRIDE;
virtual bool scrollbarsCanBeActive() const OVERRIDE; virtual bool scrollbarsCanBeActive() const OVERRIDE;
virtual IntRect scrollableAreaBoundingBox() const OVERRIDE; virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment