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

Side by Side Diff: WebCore/platform/Scrollbar.cpp

Issue 3364013: Merge 67001 - 2010-09-08 Peter Kasting <pkasting@google.com>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/517/
Patch Set: Created 10 years, 3 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 | « WebCore/platform/Scrollbar.h ('k') | WebCore/platform/ScrollbarClient.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) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); 94 Widget::setFrameRect(IntRect(0, 0, thickness, thickness));
95 } 95 }
96 96
97 Scrollbar::~Scrollbar() 97 Scrollbar::~Scrollbar()
98 { 98 {
99 stopTimerIfNeeded(); 99 stopTimerIfNeeded();
100 100
101 m_theme->unregisterScrollbar(this); 101 m_theme->unregisterScrollbar(this);
102 } 102 }
103 103
104 bool Scrollbar::setValue(int v) 104 bool Scrollbar::setValue(int v, ScrollSource source)
105 { 105 {
106 v = max(min(v, m_totalSize - m_visibleSize), 0); 106 v = max(min(v, m_totalSize - m_visibleSize), 0);
107 if (value() == v) 107 if (value() == v)
108 return false; // Our value stayed the same. 108 return false; // Our value stayed the same.
109 setCurrentPos(v); 109 setCurrentPos(v, source);
110 return true; 110 return true;
111 } 111 }
112 112
113 void Scrollbar::setProportion(int visibleSize, int totalSize) 113 void Scrollbar::setProportion(int visibleSize, int totalSize)
114 { 114 {
115 if (visibleSize == m_visibleSize && totalSize == m_totalSize) 115 if (visibleSize == m_visibleSize && totalSize == m_totalSize)
116 return; 116 return;
117 117
118 m_visibleSize = visibleSize; 118 m_visibleSize = visibleSize;
119 m_totalSize = totalSize; 119 m_totalSize = totalSize;
(...skipping 27 matching lines...) Expand all
147 return false; 147 return false;
148 float step = 0; 148 float step = 0;
149 switch (granularity) { 149 switch (granularity) {
150 case ScrollByLine: step = m_lineStep; break; 150 case ScrollByLine: step = m_lineStep; break;
151 case ScrollByPage: step = m_pageStep; break; 151 case ScrollByPage: step = m_pageStep; break;
152 case ScrollByDocument: step = m_totalSize; break; 152 case ScrollByDocument: step = m_totalSize; break;
153 case ScrollByPixel: step = m_pixelStep; break; 153 case ScrollByPixel: step = m_pixelStep; break;
154 } 154 }
155 if (direction == ScrollUp || direction == ScrollLeft) 155 if (direction == ScrollUp || direction == ScrollLeft)
156 multiplier = -multiplier; 156 multiplier = -multiplier;
157 if (client())
158 return client()->scroll(m_orientation, granularity, step, multiplier);
157 159
158 return setCurrentPos(max(min(m_currentPos + (step * multiplier), static_cast <float>(m_totalSize - m_visibleSize)), 0.0f)); 160 return setCurrentPos(max(min(m_currentPos + (step * multiplier), static_cast <float>(m_totalSize - m_visibleSize)), 0.0f), NotFromScrollAnimator);
159 } 161 }
160 162
161 void Scrollbar::updateThumb() 163 void Scrollbar::updateThumb()
162 { 164 {
163 #ifdef THUMB_POSITION_AFFECTS_BUTTONS 165 #ifdef THUMB_POSITION_AFFECTS_BUTTONS
164 invalidate(); 166 invalidate();
165 #else 167 #else
166 theme()->invalidateParts(this, ForwardTrackPart | BackTrackPart | ThumbPart) ; 168 theme()->invalidateParts(this, ForwardTrackPart | BackTrackPart | ThumbPart) ;
167 #endif 169 #endif
168 } 170 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 int thumbPos = theme()->thumbPosition(this); 282 int thumbPos = theme()->thumbPosition(this);
281 int thumbLen = theme()->thumbLength(this); 283 int thumbLen = theme()->thumbLength(this);
282 int trackLen = theme()->trackLength(this); 284 int trackLen = theme()->trackLength(this);
283 int maxPos = trackLen - thumbLen; 285 int maxPos = trackLen - thumbLen;
284 int delta = pos - m_pressedPos; 286 int delta = pos - m_pressedPos;
285 if (delta > 0) 287 if (delta > 0)
286 delta = min(maxPos - thumbPos, delta); 288 delta = min(maxPos - thumbPos, delta);
287 else if (delta < 0) 289 else if (delta < 0)
288 delta = max(-thumbPos, delta); 290 delta = max(-thumbPos, delta);
289 if (delta) 291 if (delta)
290 setCurrentPos(static_cast<float>(thumbPos + delta) * maximum() / (trackL en - thumbLen)); 292 setCurrentPos(static_cast<float>(thumbPos + delta) * maximum() / (trackL en - thumbLen), NotFromScrollAnimator);
291 } 293 }
292 294
293 bool Scrollbar::setCurrentPos(float pos) 295 bool Scrollbar::setCurrentPos(float pos, ScrollSource source)
294 { 296 {
297 if ((source != FromScrollAnimator) && client())
298 client()->setScrollPositionAndStopAnimation(m_orientation, pos);
299
295 if (pos == m_currentPos) 300 if (pos == m_currentPos)
296 return false; 301 return false;
297 302
298 int oldValue = value(); 303 int oldValue = value();
299 int oldThumbPos = theme()->thumbPosition(this); 304 int oldThumbPos = theme()->thumbPosition(this);
300 m_currentPos = pos; 305 m_currentPos = pos;
301 updateThumbPosition(); 306 updateThumbPosition();
302 if (m_pressedPart == ThumbPart) 307 if (m_pressedPart == ThumbPart)
303 setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPos) ; 308 setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPos) ;
304 309
(...skipping 24 matching lines...) Expand all
329 if (m_pressedPart != NoPart) 334 if (m_pressedPart != NoPart)
330 theme()->invalidatePart(this, m_pressedPart); 335 theme()->invalidatePart(this, m_pressedPart);
331 else if (m_hoveredPart != NoPart) // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part. 336 else if (m_hoveredPart != NoPart) // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part.
332 theme()->invalidatePart(this, m_hoveredPart); 337 theme()->invalidatePart(this, m_hoveredPart);
333 } 338 }
334 339
335 bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt) 340 bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
336 { 341 {
337 if (m_pressedPart == ThumbPart) { 342 if (m_pressedPart == ThumbPart) {
338 if (theme()->shouldSnapBackToDragOrigin(this, evt)) 343 if (theme()->shouldSnapBackToDragOrigin(this, evt))
339 setCurrentPos(m_dragOrigin); 344 setCurrentPos(m_dragOrigin, NotFromScrollAnimator);
340 else { 345 else {
341 moveThumb(m_orientation == HorizontalScrollbar ? 346 moveThumb(m_orientation == HorizontalScrollbar ?
342 convertFromContainingWindow(evt.pos()).x() : 347 convertFromContainingWindow(evt.pos()).x() :
343 convertFromContainingWindow(evt.pos()).y()); 348 convertFromContainingWindow(evt.pos()).y());
344 } 349 }
345 return true; 350 return true;
346 } 351 }
347 352
348 if (m_pressedPart != NoPart) 353 if (m_pressedPart != NoPart)
349 m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContai ningWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y()); 354 m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContai ningWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 510
506 IntPoint Scrollbar::convertFromContainingView(const IntPoint& parentPoint) const 511 IntPoint Scrollbar::convertFromContainingView(const IntPoint& parentPoint) const
507 { 512 {
508 if (m_client) 513 if (m_client)
509 return m_client->convertFromContainingViewToScrollbar(this, parentPoint) ; 514 return m_client->convertFromContainingViewToScrollbar(this, parentPoint) ;
510 515
511 return Widget::convertFromContainingView(parentPoint); 516 return Widget::convertFromContainingView(parentPoint);
512 } 517 }
513 518
514 } 519 }
OLDNEW
« no previous file with comments | « WebCore/platform/Scrollbar.h ('k') | WebCore/platform/ScrollbarClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698