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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp

Issue 1496693005: Update RootFrameViewport::userScroll to distribute scrolls between viewports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollableArea.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 m_scrollOrigin = origin; 123 m_scrollOrigin = origin;
124 m_scrollOriginChanged = true; 124 m_scrollOriginChanged = true;
125 } 125 }
126 } 126 }
127 127
128 GraphicsLayer* ScrollableArea::layerForContainer() const 128 GraphicsLayer* ScrollableArea::layerForContainer() const
129 { 129 {
130 return layerForScrolling() ? layerForScrolling()->parent() : 0; 130 return layerForScrolling() ? layerForScrolling()->parent() : 0;
131 } 131 }
132 132
133 ScrollbarOrientation ScrollableArea::scrollbarOrientationFromDirection(ScrollDir ectionPhysical direction) const
134 {
135 return (direction == ScrollUp || direction == ScrollDown) ? VerticalScrollb ar : HorizontalScrollbar;
136 }
137
138 float ScrollableArea::scrollStep(ScrollGranularity granularity, ScrollbarOrienta tion orientation) const
139 {
140 switch (granularity) {
141 case ScrollByLine:
142 return lineStep(orientation);
143 case ScrollByPage:
144 return pageStep(orientation);
145 case ScrollByDocument:
146 return documentStep(orientation);
147 case ScrollByPixel:
148 case ScrollByPrecisePixel:
149 return pixelStep(orientation);
150 default:
151 ASSERT_NOT_REACHED();
152 return 0.0f;
153 }
154 }
155
133 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di rection, ScrollGranularity granularity, float delta) 156 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di rection, ScrollGranularity granularity, float delta)
134 { 157 {
135 ScrollbarOrientation orientation; 158 ScrollbarOrientation orientation = scrollbarOrientationFromDirection(directi on);
136 if (direction == ScrollUp || direction == ScrollDown)
137 orientation = VerticalScrollbar;
138 else
139 orientation = HorizontalScrollbar;
140
141 if (!userInputScrollable(orientation)) 159 if (!userInputScrollable(orientation))
142 return ScrollResultOneDimensional(false, delta); 160 return ScrollResultOneDimensional(false, delta);
143 161
144 cancelProgrammaticScrollAnimation(); 162 cancelProgrammaticScrollAnimation();
145 163
146 float step = 0; 164 float step = scrollStep(granularity, orientation);
147 switch (granularity) {
148 case ScrollByLine:
149 step = lineStep(orientation);
150 break;
151 case ScrollByPage:
152 step = pageStep(orientation);
153 break;
154 case ScrollByDocument:
155 step = documentStep(orientation);
156 break;
157 case ScrollByPixel:
158 case ScrollByPrecisePixel:
159 step = pixelStep(orientation);
160 break;
161 }
162 165
163 if (direction == ScrollUp || direction == ScrollLeft) 166 if (direction == ScrollUp || direction == ScrollLeft)
164 delta = -delta; 167 delta = -delta;
165 168
166 return scrollAnimator().userScroll(orientation, granularity, step, delta); 169 return scrollAnimator().userScroll(orientation, granularity, step, delta);
167 } 170 }
168 171
169 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s crollType, ScrollBehavior behavior) 172 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s crollType, ScrollBehavior behavior)
170 { 173 {
171 if (behavior == ScrollBehaviorAuto) 174 if (behavior == ScrollBehaviorAuto)
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 570
568 } 571 }
569 572
570 DEFINE_TRACE(ScrollableArea) 573 DEFINE_TRACE(ScrollableArea)
571 { 574 {
572 visitor->trace(m_scrollAnimator); 575 visitor->trace(m_scrollAnimator);
573 visitor->trace(m_programmaticScrollAnimator); 576 visitor->trace(m_programmaticScrollAnimator);
574 } 577 }
575 578
576 } // namespace blink 579 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollableArea.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698