Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Unified Diff: Source/core/rendering/RenderListBox.cpp

Issue 134443003: Implement CSSOM Smooth Scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderListBox.cpp
diff --git a/Source/core/rendering/RenderListBox.cpp b/Source/core/rendering/RenderListBox.cpp
index 98e40b489503361520ebd2f17a0374170e44ac42..a630593c351269c4e9ce8fc103477fa926383391 100644
--- a/Source/core/rendering/RenderListBox.cpp
+++ b/Source/core/rendering/RenderListBox.cpp
@@ -100,8 +100,10 @@ RenderListBox::~RenderListBox()
{
setHasVerticalScrollbar(false);
- if (FrameView* frameView = frame()->view())
+ if (FrameView* frameView = frame()->view()) {
frameView->removeScrollableArea(this);
+ frameView->removeAnimatingScrollableArea(this);
+ }
}
// FIXME: Instead of this hack we should add a ShadowRoot to <select> with no insertion point
@@ -697,7 +699,7 @@ int RenderListBox::scrollLeft() const
return 0;
}
-void RenderListBox::setScrollLeft(int)
+void RenderListBox::setScrollLeft(int, ScrollBehavior)
{
}
@@ -706,14 +708,21 @@ int RenderListBox::scrollTop() const
return m_indexOffset * itemHeight();
}
-void RenderListBox::setScrollTop(int newTop)
+void RenderListBox::setScrollTop(int newTop, ScrollBehavior scrollBehavior)
{
+ cancelProgrammaticScrollAnimation();
+
// Determine an index and scroll to it.
int index = newTop / itemHeight();
if (index < 0 || index >= numItems() || index == m_indexOffset)
return;
- scrollToOffsetWithoutAnimation(VerticalScrollbar, index);
+ if (scrollBehavior == ScrollBehaviorAuto)
+ scrollBehavior = style()->scrollBehavior();
+ if (scrollBehavior == ScrollBehaviorSmooth)
+ programmaticallyScrollSmoothlyToOffset(FloatPoint(0, index));
+ else
+ scrollToOffsetWithoutAnimation(VerticalScrollbar, index);
}
bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
@@ -873,6 +882,26 @@ bool RenderListBox::scrollbarsCanBeActive() const
return view->frameView()->scrollbarsCanBeActive();
}
+bool RenderListBox::registerForAnimation()
+{
+ if (FrameView* frameView = frame()->view())
+ return frameView->addAnimatingScrollableArea(this);
+ return false;
+}
+
+void RenderListBox::deregisterForAnimation()
+{
+ if (FrameView* frameView = frame()->view())
+ frameView->removeAnimatingScrollableArea(this);
+}
+
+bool RenderListBox::scheduleAnimation()
+{
+ if (FrameView* frameView = frame()->view())
+ return frameView->scheduleAnimation();
+ return false;
+}
+
IntPoint RenderListBox::minimumScrollPosition() const
{
return IntPoint();

Powered by Google App Engine
This is Rietveld 408576698