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

Side by Side Diff: sky/engine/platform/scroll/ScrollableArea.cpp

Issue 856443005: Delete some noop and dead scrollbar code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/platform/scroll/ScrollableArea.h ('k') | sky/engine/platform/scroll/Scrollbar.h » ('j') | 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 int ScrollableArea::maxOverlapBetweenPages() 67 int ScrollableArea::maxOverlapBetweenPages()
68 { 68 {
69 static int maxOverlapBetweenPages = std::numeric_limits<int>::max(); 69 static int maxOverlapBetweenPages = std::numeric_limits<int>::max();
70 return maxOverlapBetweenPages; 70 return maxOverlapBetweenPages;
71 } 71 }
72 72
73 ScrollableArea::ScrollableArea() 73 ScrollableArea::ScrollableArea()
74 : m_constrainsScrollingToContentEdge(true) 74 : m_constrainsScrollingToContentEdge(true)
75 , m_verticalScrollElasticity(ScrollElasticityNone) 75 , m_verticalScrollElasticity(ScrollElasticityNone)
76 , m_horizontalScrollElasticity(ScrollElasticityNone) 76 , m_horizontalScrollElasticity(ScrollElasticityNone)
77 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
78 , m_scrollOriginChanged(false) 77 , m_scrollOriginChanged(false)
79 { 78 {
80 } 79 }
81 80
82 ScrollableArea::~ScrollableArea() 81 ScrollableArea::~ScrollableArea()
83 { 82 {
84 } 83 }
85 84
86 ScrollAnimator* ScrollableArea::scrollAnimator() const 85 ScrollAnimator* ScrollableArea::scrollAnimator() const
87 { 86 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 142 }
144 143
145 void ScrollableArea::scrollToOffsetWithoutAnimation(ScrollbarOrientation orienta tion, float offset) 144 void ScrollableArea::scrollToOffsetWithoutAnimation(ScrollbarOrientation orienta tion, float offset)
146 { 145 {
147 if (orientation == HorizontalScrollbar) 146 if (orientation == HorizontalScrollbar)
148 scrollToOffsetWithoutAnimation(FloatPoint(offset, scrollAnimator()->curr entPosition().y())); 147 scrollToOffsetWithoutAnimation(FloatPoint(offset, scrollAnimator()->curr entPosition().y()));
149 else 148 else
150 scrollToOffsetWithoutAnimation(FloatPoint(scrollAnimator()->currentPosit ion().x(), offset)); 149 scrollToOffsetWithoutAnimation(FloatPoint(scrollAnimator()->currentPosit ion().x(), offset));
151 } 150 }
152 151
153 void ScrollableArea::notifyScrollPositionChanged(const IntPoint& position)
154 {
155 scrollPositionChanged(position);
156 scrollAnimator()->setCurrentPosition(position);
157 }
158
159 void ScrollableArea::scrollPositionChanged(const IntPoint& position) 152 void ScrollableArea::scrollPositionChanged(const IntPoint& position)
160 { 153 {
161 TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged"); 154 TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged");
162 155
163 IntPoint oldPosition = scrollPosition(); 156 IntPoint oldPosition = scrollPosition();
164 // Tell the derived class to scroll its contents. 157 // Tell the derived class to scroll its contents.
165 setScrollOffset(position); 158 setScrollOffset(position);
166 159
167 Scrollbar* verticalScrollbar = this->verticalScrollbar(); 160 if (Scrollbar* scrollbar = this->horizontalScrollbar())
161 scrollbar->offsetDidChange();
168 162
169 // Tell the scrollbars to update their thumb postions. 163 if (Scrollbar* scrollbar = this->verticalScrollbar())
170 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { 164 scrollbar->offsetDidChange();
171 horizontalScrollbar->offsetDidChange();
172 if (horizontalScrollbar->isOverlayScrollbar()) {
173 if (!verticalScrollbar)
174 horizontalScrollbar->invalidate();
175 }
176 }
177 if (verticalScrollbar) {
178 verticalScrollbar->offsetDidChange();
179 if (verticalScrollbar->isOverlayScrollbar())
180 verticalScrollbar->invalidate();
181 }
182 165
183 if (scrollPosition() != oldPosition) 166 if (scrollPosition() != oldPosition)
184 scrollAnimator()->notifyContentAreaScrolled(scrollPosition() - oldPositi on); 167 scrollAnimator()->notifyContentAreaScrolled(scrollPosition() - oldPositi on);
185 } 168 }
186 169
187 bool ScrollableArea::scrollBehaviorFromString(const String& behaviorString, Scro llBehavior& behavior) 170 bool ScrollableArea::scrollBehaviorFromString(const String& behaviorString, Scro llBehavior& behavior)
188 { 171 {
189 if (behaviorString == "auto") 172 if (behaviorString == "auto")
190 behavior = ScrollBehaviorAuto; 173 behavior = ScrollBehaviorAuto;
191 else if (behaviorString == "instant") 174 else if (behaviorString == "instant")
192 behavior = ScrollBehaviorInstant; 175 behavior = ScrollBehaviorInstant;
193 else if (behaviorString == "smooth") 176 else if (behaviorString == "smooth")
194 behavior = ScrollBehaviorSmooth; 177 behavior = ScrollBehaviorSmooth;
195 else 178 else
196 return false; 179 return false;
197 180
198 return true; 181 return true;
199 } 182 }
200 183
201 bool ScrollableArea::handleWheelEvent(const PlatformWheelEvent& wheelEvent) 184 bool ScrollableArea::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
202 { 185 {
203 // ctrl+wheel events are used to trigger zooming, not scrolling. 186 // ctrl+wheel events are used to trigger zooming, not scrolling.
204 if (wheelEvent.modifiers() & PlatformEvent::CtrlKey) 187 if (wheelEvent.modifiers() & PlatformEvent::CtrlKey)
205 return false; 188 return false;
206 189
207 return scrollAnimator()->handleWheelEvent(wheelEvent); 190 return scrollAnimator()->handleWheelEvent(wheelEvent);
208 } 191 }
209 192
210 // NOTE: Only called from Internals for testing.
211 void ScrollableArea::setScrollOffsetFromInternals(const IntPoint& offset)
212 {
213 setScrollOffsetFromAnimation(offset);
214 }
215
216 void ScrollableArea::setScrollOffsetFromAnimation(const IntPoint& offset) 193 void ScrollableArea::setScrollOffsetFromAnimation(const IntPoint& offset)
217 { 194 {
218 scrollPositionChanged(offset); 195 scrollPositionChanged(offset);
219 } 196 }
220 197
221 void ScrollableArea::mouseEnteredContentArea() const 198 void ScrollableArea::mouseEnteredContentArea() const
222 { 199 {
223 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) 200 if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
224 scrollAnimator->mouseEnteredContentArea(); 201 scrollAnimator->mouseEnteredContentArea();
225 } 202 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) 240 if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
264 scrollAnimator->finishCurrentScrollAnimations(); 241 scrollAnimator->finishCurrentScrollAnimations();
265 } 242 }
266 243
267 void ScrollableArea::didAddScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation) 244 void ScrollableArea::didAddScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation)
268 { 245 {
269 if (orientation == VerticalScrollbar) 246 if (orientation == VerticalScrollbar)
270 scrollAnimator()->didAddVerticalScrollbar(scrollbar); 247 scrollAnimator()->didAddVerticalScrollbar(scrollbar);
271 else 248 else
272 scrollAnimator()->didAddHorizontalScrollbar(scrollbar); 249 scrollAnimator()->didAddHorizontalScrollbar(scrollbar);
273
274 // <rdar://problem/9797253> AppKit resets the scrollbar's style when you att ach a scrollbar
275 setScrollbarOverlayStyle(scrollbarOverlayStyle());
276 } 250 }
277 251
278 void ScrollableArea::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientat ion orientation) 252 void ScrollableArea::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientat ion orientation)
279 { 253 {
280 if (orientation == VerticalScrollbar) 254 if (orientation == VerticalScrollbar)
281 scrollAnimator()->willRemoveVerticalScrollbar(scrollbar); 255 scrollAnimator()->willRemoveVerticalScrollbar(scrollbar);
282 else 256 else
283 scrollAnimator()->willRemoveHorizontalScrollbar(scrollbar); 257 scrollAnimator()->willRemoveHorizontalScrollbar(scrollbar);
284 } 258 }
285 259
286 void ScrollableArea::contentsResized() 260 void ScrollableArea::contentsResized()
287 { 261 {
288 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) 262 if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
289 scrollAnimator->contentsResized(); 263 scrollAnimator->contentsResized();
290 } 264 }
291 265
292 bool ScrollableArea::hasOverlayScrollbars() const 266 bool ScrollableArea::hasOverlayScrollbars() const
293 { 267 {
294 Scrollbar* vScrollbar = verticalScrollbar(); 268 Scrollbar* vScrollbar = verticalScrollbar();
295 if (vScrollbar && vScrollbar->isOverlayScrollbar()) 269 if (vScrollbar && vScrollbar->isOverlayScrollbar())
296 return true; 270 return true;
297 Scrollbar* hScrollbar = horizontalScrollbar(); 271 Scrollbar* hScrollbar = horizontalScrollbar();
298 return hScrollbar && hScrollbar->isOverlayScrollbar(); 272 return hScrollbar && hScrollbar->isOverlayScrollbar();
299 } 273 }
300 274
301 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle )
302 {
303 m_scrollbarOverlayStyle = overlayStyle;
304
305 if (Scrollbar* scrollbar = horizontalScrollbar()) {
306 scrollbar->invalidate();
307 }
308
309 if (Scrollbar* scrollbar = verticalScrollbar()) {
310 scrollbar->invalidate();
311 }
312 }
313
314 bool ScrollableArea::scheduleAnimation() 275 bool ScrollableArea::scheduleAnimation()
315 { 276 {
316 WTF_LOG(ScriptedAnimationController, "ScrollableArea::scheduleAnimation: win dow = %d", 277 WTF_LOG(ScriptedAnimationController, "ScrollableArea::scheduleAnimation: win dow = %d",
317 hostWindow() ? 1 : 0); 278 hostWindow() ? 1 : 0);
318 if (HostWindow* window = hostWindow()) { 279 if (HostWindow* window = hostWindow()) {
319 window->scheduleAnimation(); 280 window->scheduleAnimation();
320 return true; 281 return true;
321 } 282 }
322 return false; 283 return false;
323 } 284 }
(...skipping 18 matching lines...) Expand all
342 { 303 {
343 return scrollSize(orientation); 304 return scrollSize(orientation);
344 } 305 }
345 306
346 float ScrollableArea::pixelStep(ScrollbarOrientation) const 307 float ScrollableArea::pixelStep(ScrollbarOrientation) const
347 { 308 {
348 return 1; 309 return 1;
349 } 310 }
350 311
351 } // namespace blink 312 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/scroll/ScrollableArea.h ('k') | sky/engine/platform/scroll/Scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698