On the HTML5 spec page ( http://whatwg.org/c ), we instantiate 1683 ScrollAnimator objects, but only a single one is used. Bytes Used Count Symbol Name 420.75 KB 1.0% 1683 WebCore::ScrollAnimator::create(WebCore::ScrollableArea*) 420.75 KB 1.0% 1683 WebCore::ScrollableArea::scrollAnimator() const 420.25 KB 1.0% 1681 WebCore::ScrollableArea::scrollToOffsetWithoutAnimation(WebCore::FloatPoint const&) 420.25 KB 1.0% 1681 WebCore::RenderLayer::scrollToOffset(int, int, WebCore::RenderLayer::ScrollOffsetClamping) 420.25 KB 1.0% 1681 WebCore::RenderLayer::updateScrollInfoAfterLayout() 420.25 KB 1.0% 1681 WebCore::RenderBlock::updateScrollInfoAfterLayout() 420.25 KB 1.0% 1681 WebCore::RenderBlock::layoutBlock(bool, int, WebCore::RenderBlock::BlockLayoutPass) 420.25 KB 1.0% 1681 WebCore::RenderBlock::layout() 256 Bytes 0.0% 1 WebCore::ScrollableArea::didAddVerticalScrollbar(WebCore::Scrollbar*) 256 Bytes 0.0% 1 WebCore::FrameView::contentsResized() We should find a way to avoid creating the RenderLayer ones unless they're actually needed.
Created attachment 119794 [details] Proposed patch
Comment on attachment 119794 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=119794&action=review > Source/WebCore/platform/ScrollableArea.cpp:133 > + if (!m_scrollAnimator && !offset.x() && !offset.y()) > + return; This is a great idea. But I don’t think this it is technically correct; the offset might already be something other than 0,0 if it was already scrolled by a call to setScrollOffset rather than a call to scrollToOffsetWithoutAnimation. It would be great to have this check in ScrollableArea, but at the moment it seems impractical to do it correctly given what’s abstract in the class and what’s concrete. Instead, I suggest putting a check into RenderLayer::scrollToOffset: IntPoint newScrollOffset(x, y); if (newScrollOffset != scrollOffset()) scrollToOffsetWithoutAnimation(newScrollOffset); I also noticed two other things: 1) In RenderLayer there are two calls that use explicit ScrollableArea prefixes where they need not: This one and the call to ScrollableArea::setConstrainsScrollingToContentEdge. 2) There is a unpleasant mix of float, int, and LayoutUnit in RenderLayer and ScrollableArea. It’s bizarre that scrollToOffsetWithoutAnimation takes a FloatPoint, setScrollOffset takes an IntPoint, and scrollToOffset takes a LayoutUnit. There may be some reason why, but I am not clear what it is.
Created attachment 119872 [details] Proposed patch v2
Comment on attachment 119872 [details] Proposed patch v2 Looks good!
Committed r103245: <http://trac.webkit.org/changeset/103245>