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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Rebase Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@gmail.com> 10 * Christian Biesinger <cbiesinger@gmail.com>
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 visitor->Trace(scroll_anchor_); 202 visitor->Trace(scroll_anchor_);
203 ScrollableArea::Trace(visitor); 203 ScrollableArea::Trace(visitor);
204 } 204 }
205 205
206 PlatformChromeClient* PaintLayerScrollableArea::GetChromeClient() const { 206 PlatformChromeClient* PaintLayerScrollableArea::GetChromeClient() const {
207 if (Page* page = Box().GetFrame()->GetPage()) 207 if (Page* page = Box().GetFrame()->GetPage())
208 return &page->GetChromeClient(); 208 return &page->GetChromeClient();
209 return nullptr; 209 return nullptr;
210 } 210 }
211 211
212 SmoothScrollSequencer* PaintLayerScrollableArea::GetSmoothScrollSequencer()
213 const {
214 if (Page* page = Box().GetFrame()->GetPage())
215 return page->GetSmoothScrollSequencer();
216 return nullptr;
217 }
218
212 GraphicsLayer* PaintLayerScrollableArea::LayerForScrolling() const { 219 GraphicsLayer* PaintLayerScrollableArea::LayerForScrolling() const {
213 return Layer()->HasCompositedLayerMapping() 220 return Layer()->HasCompositedLayerMapping()
214 ? Layer()->GetCompositedLayerMapping()->ScrollingContentsLayer() 221 ? Layer()->GetCompositedLayerMapping()->ScrollingContentsLayer()
215 : 0; 222 : 0;
216 } 223 }
217 224
218 GraphicsLayer* PaintLayerScrollableArea::LayerForHorizontalScrollbar() const { 225 GraphicsLayer* PaintLayerScrollableArea::LayerForHorizontalScrollbar() const {
219 // See crbug.com/343132. 226 // See crbug.com/343132.
220 DisableCompositingQueryAsserts disabler; 227 DisableCompositingQueryAsserts disabler;
221 228
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 document.UpdateStyleAndLayout(); 1723 document.UpdateStyleAndLayout();
1717 1724
1718 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to 1725 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to
1719 // keep the point under the cursor in view. 1726 // keep the point under the cursor in view.
1720 } 1727 }
1721 1728
1722 LayoutRect PaintLayerScrollableArea::ScrollIntoView( 1729 LayoutRect PaintLayerScrollableArea::ScrollIntoView(
1723 const LayoutRect& rect, 1730 const LayoutRect& rect,
1724 const ScrollAlignment& align_x, 1731 const ScrollAlignment& align_x,
1725 const ScrollAlignment& align_y, 1732 const ScrollAlignment& align_y,
1726 ScrollType scroll_type) { 1733 ScrollType scroll_type,
1734 bool is_smooth) {
1727 LayoutRect local_expose_rect( 1735 LayoutRect local_expose_rect(
1728 Box() 1736 Box()
1729 .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms) 1737 .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms)
1730 .BoundingBox()); 1738 .BoundingBox());
1731 local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop()); 1739 local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop());
1732 LayoutRect visible_rect(LayoutPoint(), ClientSize()); 1740 LayoutRect visible_rect(LayoutPoint(), ClientSize());
1733 LayoutRect r = ScrollAlignment::GetRectToExpose( 1741 LayoutRect r = ScrollAlignment::GetRectToExpose(
1734 visible_rect, local_expose_rect, align_x, align_y); 1742 visible_rect, local_expose_rect, align_x, align_y);
1735 1743
1736 ScrollOffset old_scroll_offset = GetScrollOffset(); 1744 ScrollOffset old_scroll_offset = GetScrollOffset();
1737 ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize( 1745 ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize(
1738 ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset)))); 1746 ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset))));
1739 SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant); 1747 if (is_smooth) {
1740 ScrollOffset scroll_offset_difference = GetScrollOffset() - old_scroll_offset; 1748 DCHECK(scroll_type != kUserScroll);
1749 GetSmoothScrollSequencer()->QueueAnimation(this, new_scroll_offset);
1750 } else {
1751 SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant);
1752 }
1753 ScrollOffset scroll_offset_difference =
1754 ClampScrollOffset(new_scroll_offset) - old_scroll_offset;
1741 local_expose_rect.Move(-LayoutSize(scroll_offset_difference)); 1755 local_expose_rect.Move(-LayoutSize(scroll_offset_difference));
1742 1756
1743 LayoutRect intersect = 1757 LayoutRect intersect =
1744 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect)); 1758 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect));
1745 if (intersect.IsEmpty() && !visible_rect.IsEmpty() && 1759 if (intersect.IsEmpty() && !visible_rect.IsEmpty() &&
1746 !local_expose_rect.IsEmpty()) { 1760 !local_expose_rect.IsEmpty()) {
1747 return LocalToAbsolute(Box(), local_expose_rect); 1761 return LocalToAbsolute(Box(), local_expose_rect);
1748 } 1762 }
1749 return intersect; 1763 return intersect;
1750 } 1764 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 2191
2178 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2192 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2179 ClampScrollableAreas() { 2193 ClampScrollableAreas() {
2180 for (auto& scrollable_area : *needs_clamp_) 2194 for (auto& scrollable_area : *needs_clamp_)
2181 scrollable_area->ClampScrollOffsetAfterOverflowChange(); 2195 scrollable_area->ClampScrollOffsetAfterOverflowChange();
2182 delete needs_clamp_; 2196 delete needs_clamp_;
2183 needs_clamp_ = nullptr; 2197 needs_clamp_ = nullptr;
2184 } 2198 }
2185 2199
2186 } // namespace blink 2200 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698