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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Change the default setting. 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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 document.UpdateStyleAndLayout(); 1732 document.UpdateStyleAndLayout();
1726 1733
1727 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to 1734 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to
1728 // keep the point under the cursor in view. 1735 // keep the point under the cursor in view.
1729 } 1736 }
1730 1737
1731 LayoutRect PaintLayerScrollableArea::ScrollIntoView( 1738 LayoutRect PaintLayerScrollableArea::ScrollIntoView(
1732 const LayoutRect& rect, 1739 const LayoutRect& rect,
1733 const ScrollAlignment& align_x, 1740 const ScrollAlignment& align_x,
1734 const ScrollAlignment& align_y, 1741 const ScrollAlignment& align_y,
1742 bool is_smooth,
1735 ScrollType scroll_type) { 1743 ScrollType scroll_type) {
1736 LayoutRect local_expose_rect( 1744 LayoutRect local_expose_rect(
1737 Box() 1745 Box()
1738 .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms) 1746 .AbsoluteToLocalQuad(FloatQuad(FloatRect(rect)), kUseTransforms)
1739 .BoundingBox()); 1747 .BoundingBox());
1740 local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop()); 1748 local_expose_rect.Move(-Box().BorderLeft(), -Box().BorderTop());
1741 LayoutRect visible_rect(LayoutPoint(), ClientSize()); 1749 LayoutRect visible_rect(LayoutPoint(), ClientSize());
1742 LayoutRect r = ScrollAlignment::GetRectToExpose( 1750 LayoutRect r = ScrollAlignment::GetRectToExpose(
1743 visible_rect, local_expose_rect, align_x, align_y); 1751 visible_rect, local_expose_rect, align_x, align_y);
1744 1752
1745 ScrollOffset old_scroll_offset = GetScrollOffset(); 1753 ScrollOffset old_scroll_offset = GetScrollOffset();
1746 ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize( 1754 ScrollOffset new_scroll_offset(ClampScrollOffset(RoundedIntSize(
1747 ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset)))); 1755 ToScrollOffset(FloatPoint(r.Location()) + old_scroll_offset))));
1748 SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant); 1756 if (is_smooth) {
1749 ScrollOffset scroll_offset_difference = GetScrollOffset() - old_scroll_offset; 1757 DCHECK(scroll_type == kProgrammaticScroll);
1758 GetSmoothScrollSequencer()->QueueAnimation(this, new_scroll_offset);
1759 } else {
1760 SetScrollOffset(new_scroll_offset, scroll_type, kScrollBehaviorInstant);
1761 }
1762 ScrollOffset scroll_offset_difference =
1763 ClampScrollOffset(new_scroll_offset) - old_scroll_offset;
1750 local_expose_rect.Move(-LayoutSize(scroll_offset_difference)); 1764 local_expose_rect.Move(-LayoutSize(scroll_offset_difference));
1751 1765
1752 LayoutRect intersect = 1766 LayoutRect intersect =
1753 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect)); 1767 LocalToAbsolute(Box(), Intersection(visible_rect, local_expose_rect));
1754 if (intersect.IsEmpty() && !visible_rect.IsEmpty() && 1768 if (intersect.IsEmpty() && !visible_rect.IsEmpty() &&
1755 !local_expose_rect.IsEmpty()) { 1769 !local_expose_rect.IsEmpty()) {
1756 return LocalToAbsolute(Box(), local_expose_rect); 1770 return LocalToAbsolute(Box(), local_expose_rect);
1757 } 1771 }
1758 return intersect; 1772 return intersect;
1759 } 1773 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 2200
2187 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: 2201 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
2188 ClampScrollableAreas() { 2202 ClampScrollableAreas() {
2189 for (auto& scrollable_area : *needs_clamp_) 2203 for (auto& scrollable_area : *needs_clamp_)
2190 scrollable_area->ClampScrollOffsetAfterOverflowChange(); 2204 scrollable_area->ClampScrollOffsetAfterOverflowChange();
2191 delete needs_clamp_; 2205 delete needs_clamp_;
2192 needs_clamp_ = nullptr; 2206 needs_clamp_ = nullptr;
2193 } 2207 }
2194 2208
2195 } // namespace blink 2209 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698