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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Fixed nits. Created 3 years, 6 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 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 document.UpdateStyleAndLayout(); 1740 document.UpdateStyleAndLayout();
1734 1741
1735 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to 1742 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to
1736 // keep the point under the cursor in view. 1743 // keep the point under the cursor in view.
1737 } 1744 }
1738 1745
1739 LayoutRect PaintLayerScrollableArea::ScrollIntoView( 1746 LayoutRect PaintLayerScrollableArea::ScrollIntoView(
1740 const LayoutRect& rect, 1747 const LayoutRect& rect,
1741 const ScrollAlignment& align_x, 1748 const ScrollAlignment& align_x,
1742 const ScrollAlignment& align_y, 1749 const ScrollAlignment& align_y,
1750 bool is_smooth,
1743 ScrollType scroll_type) { 1751 ScrollType scroll_type) {
1744 LayoutRect local_expose_rect( 1752 LayoutRect local_expose_rect(
1745 Box() 1753 Box()
1746 .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms) 1754 .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms)
1747 .BoundingBox()); 1755 .BoundingBox());
1748 local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop()); 1756 local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop());
1749 LayoutRect visible_rect(LayoutPoint(), ClientSize()); 1757 LayoutRect visible_rect(LayoutPoint(), ClientSize());
1750 LayoutRect r = ScrollAlignment::GetRectToExpose( 1758 LayoutRect r = ScrollAlignment::GetRectToExpose(
1751 visible_rect, local_expose_rect, align_x, align_y); 1759 visible_rect, local_expose_rect, align_x, align_y);
1752 1760
1753 ScrollOffset old_scroll_offset = GetScrollOffset(); 1761 ScrollOffset old_scroll_offset = GetScrollOffset();
1754 ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize( 1762 ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize(
1755 ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset)))); 1763 ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset))));
1756 SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant); 1764 if (is_smooth) {
1757 ScrollOffset scroll_offset_difference = GetScrollOffset() - old_scroll_offset; 1765 DCHECK(scroll_type == kProgrammaticScroll);
1766 GetSmoothScrollSequencer()->QueueAnimation(this, new_scroll_offset);
1767 } else {
1768 SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant);
1769 }
1770 ScrollOffset scroll_offset_difference =
1771 ClampScrollOffset(new_scroll_offset) - old_scroll_offset;
1758 local_expose_rect.Move(-LayoutSize(scroll_offset_difference)); 1772 local_expose_rect.Move(-LayoutSize(scroll_offset_difference));
1759 1773
1760 LayoutRect intersect = 1774 LayoutRect intersect =
1761 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect)); 1775 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect));
1762 if (intersect.IsEmpty() && !visible_rect.IsEmpty() && 1776 if (intersect.IsEmpty() && !visible_rect.IsEmpty() &&
1763 !local_expose_rect.IsEmpty()) { 1777 !local_expose_rect.IsEmpty()) {
1764 return LocalToAbsolute(Box(), local_expose_rect); 1778 return LocalToAbsolute(Box(), local_expose_rect);
1765 } 1779 }
1766 return intersect; 1780 return intersect;
1767 } 1781 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 2208
2195 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2209 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2196 ClampScrollableAreas() { 2210 ClampScrollableAreas() {
2197 for (auto& scrollable_area : *needs_clamp_) 2211 for (auto& scrollable_area : *needs_clamp_)
2198 scrollable_area->ClampScrollOffsetAfterOverflowChange(); 2212 scrollable_area->ClampScrollOffsetAfterOverflowChange();
2199 delete needs_clamp_; 2213 delete needs_clamp_;
2200 needs_clamp_ = nullptr; 2214 needs_clamp_ = nullptr;
2201 } 2215 }
2202 2216
2203 } // namespace blink 2217 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698