summaryrefslogtreecommitdiffstats
path: root/cc/scrollbar_animation_controller.cc
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 16:34:53 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 16:34:53 +0000
commit5c4824e1449f42aa88d6ccd2136d3170213e8803 (patch)
tree0a01c6a8ffa3a2acd1495f0f7ee2595aa47c1ef8 /cc/scrollbar_animation_controller.cc
parentb938d4f552356e79b96a7ecca85d98c782e2c659 (diff)
downloadchromium_src-5c4824e1449f42aa88d6ccd2136d3170213e8803.zip
chromium_src-5c4824e1449f42aa88d6ccd2136d3170213e8803.tar.gz
chromium_src-5c4824e1449f42aa88d6ccd2136d3170213e8803.tar.bz2
Separate layer property pushes from tree structure syncs and clean up scrollbar layer pointers
We need sync the cc::Layer tree structure and layer properties to cc::LayerImpls at commit time. We track when properties and tree structure change and use that to decide whether to do a full tree sync or just a property push. This patch separates the property push to always happen seperately from the tree sync. The scrollbar and scroll layer pointer code needed a bit of cleanup to make this work. Before this patch, the way that scrolling worked was during the scrollbar pointer sync inside TreeSynchronizer::synchronizeTrees() was what actually updated the scroll offsets as a side effect of setting the pointer values. This patch rejiggers things so the ScrollbarAnimationController maintains the scroll properties at all times and the scrollbar layers pull values from their controller. As a bonus, this means changes to the scroll offset no longer need a full tree sync - they just need a property push. The scrollable bounds are also now pulled from the layer directly instead of the first child of a layer to avoid depending on properties updating in a specific order and be overall less hacky. This depends on webkit.org/b/106518 BUG=169143 Review URL: https://chromiumcodereview.appspot.com/11821064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/scrollbar_animation_controller.cc')
-rw-r--r--cc/scrollbar_animation_controller.cc33
1 files changed, 12 insertions, 21 deletions
diff --git a/cc/scrollbar_animation_controller.cc b/cc/scrollbar_animation_controller.cc
index f2e471c..8d35cff 100644
--- a/cc/scrollbar_animation_controller.cc
+++ b/cc/scrollbar_animation_controller.cc
@@ -52,39 +52,30 @@ void ScrollbarAnimationController::updateScrollOffset(LayerImpl* scrollLayer)
updateScrollOffsetAtTime(scrollLayer, (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
}
-gfx::Size ScrollbarAnimationController::getScrollLayerBounds(const LayerImpl* scrollLayer)
+void ScrollbarAnimationController::setHorizontalScrollbarLayer(ScrollbarLayerImpl* layer)
{
- if (!scrollLayer->children().size())
- return gfx::Size();
- // Copy & paste from LayerTreeHostImpl...
- // FIXME: Hardcoding the first child here is weird. Think of
- // a cleaner way to get the contentBounds on the Impl side.
- return scrollLayer->children()[0]->bounds();
+ m_horizontalScrollbarLayer = layer;
+ if (layer)
+ layer->setAnimationController(this);
+}
+
+void ScrollbarAnimationController::setVerticalScrollbarLayer(ScrollbarLayerImpl* layer)
+{
+ m_verticalScrollbarLayer = layer;
+ if (layer)
+ layer->setAnimationController(this);
}
void ScrollbarAnimationController::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double)
{
m_currentOffset = scrollLayer->scrollOffset() + scrollLayer->scrollDelta();
- m_totalSize = getScrollLayerBounds(scrollLayer);
+ m_totalSize = scrollLayer->bounds();
m_maximum = scrollLayer->maxScrollOffset();
// Get the m_currentOffset.y() value for a sanity-check on scrolling
// benchmark metrics. Specifically, we want to make sure
// BasicMouseWheelSmoothScrollGesture has proper scroll curves.
TRACE_COUNTER_ID1("gpu", "scroll_offset_y", this, m_currentOffset.y());
-
-
- if (m_horizontalScrollbarLayer) {
- m_horizontalScrollbarLayer->setCurrentPos(m_currentOffset.x());
- m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width());
- m_horizontalScrollbarLayer->setMaximum(m_maximum.x());
- }
-
- if (m_verticalScrollbarLayer) {
- m_verticalScrollbarLayer->setCurrentPos(m_currentOffset.y());
- m_verticalScrollbarLayer->setTotalSize(m_totalSize.height());
- m_verticalScrollbarLayer->setMaximum(m_maximum.y());
- }
}
} // namespace cc