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

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

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

Powered by Google App Engine
This is Rietveld 408576698