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

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

Issue 134443003: Implement CSSOM Smooth Scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
« no previous file with comments | « Source/core/rendering/RenderLayerScrollableArea.h ('k') | Source/core/rendering/RenderListBox.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderLayerScrollableArea.cpp
diff --git a/Source/core/rendering/RenderLayerScrollableArea.cpp b/Source/core/rendering/RenderLayerScrollableArea.cpp
index db17dc86836e0e73505ae696e504cc2e811dff1c..587575edc38b027a23c3ffad0f6881cc2bcdd5ae 100644
--- a/Source/core/rendering/RenderLayerScrollableArea.cpp
+++ b/Source/core/rendering/RenderLayerScrollableArea.cpp
@@ -50,6 +50,7 @@
#include "core/editing/FrameSelection.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
+#include "core/frame/Settings.h"
#include "core/html/HTMLFrameOwnerElement.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/InspectorTraceEvents.h"
@@ -111,6 +112,7 @@ RenderLayerScrollableArea::~RenderLayerScrollableArea()
if (LocalFrame* frame = box().frame()) {
if (FrameView* frameView = frame->view()) {
frameView->removeScrollableArea(this);
+ frameView->removeAnimatingScrollableArea(this);
}
}
@@ -518,6 +520,23 @@ int RenderLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const
return max(pageStep, 1);
}
+void RenderLayerScrollableArea::registerForAnimation()
+{
+ box().frameView()->addAnimatingScrollableArea(this);
+}
+
+void RenderLayerScrollableArea::deregisterForAnimation()
+{
+ if (FrameView* frameView = box().frameView()) {
+ frameView->removeAnimatingScrollableArea(this);
+ }
+}
+
+bool RenderLayerScrollableArea::scheduleAnimation()
+{
+ return box().frameView()->scheduleAnimation();
+}
+
RenderBox& RenderLayerScrollableArea::box() const
{
return *m_layer.renderBox();
@@ -564,11 +583,18 @@ void RenderLayerScrollableArea::computeScrollDimensions()
setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow));
}
-void RenderLayerScrollableArea::scrollToOffset(const IntSize& scrollOffset, ScrollOffsetClamping clamp)
+void RenderLayerScrollableArea::scrollToOffset(const IntSize& scrollOffset, ScrollOffsetClamping clamp, ScrollBehavior scrollBehavior)
{
+ cancelProgrammaticScrollAnimation();
IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(scrollOffset) : scrollOffset;
- if (newScrollOffset != adjustedScrollOffset())
- scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset);
+ if (scrollBehavior == ScrollBehaviorAuto)
+ scrollBehavior = box().style()->scrollBehavior();
+ if (newScrollOffset != adjustedScrollOffset()) {
+ if (scrollBehavior == ScrollBehaviorSmooth)
+ programmaticallyScrollSmoothlyToOffset(-scrollOrigin() + newScrollOffset);
+ else
+ scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset);
+ }
}
void RenderLayerScrollableArea::updateAfterLayout()
@@ -1383,6 +1409,7 @@ void RenderLayerScrollableArea::resize(const PlatformEvent& evt, const LayoutSiz
LayoutRect RenderLayerScrollableArea::exposeRect(const LayoutRect& rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
{
+ cancelProgrammaticScrollAnimation();
LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms).boundingBox());
LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight());
LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, alignX, alignY);
« no previous file with comments | « Source/core/rendering/RenderLayerScrollableArea.h ('k') | Source/core/rendering/RenderListBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698