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

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

Issue 6523001: Merge 78431 - Some Scrollbar functions assume an attached ScrollableArea but ... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/648/
Patch Set: Created 9 years, 10 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 | « Source/WebCore/ChangeLog ('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) 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return; 189 return;
190 190
191 // Handle the track. 191 // Handle the track.
192 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) { 192 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
193 theme()->invalidatePart(this, m_pressedPart); 193 theme()->invalidatePart(this, m_pressedPart);
194 setHoveredPart(ThumbPart); 194 setHoveredPart(ThumbPart);
195 return; 195 return;
196 } 196 }
197 197
198 // Handle the arrows and track. 198 // Handle the arrows and track.
199 if (scrollableArea()->scroll(pressedPartScrollDirection(), pressedPartScroll Granularity())) 199 if (m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection( ), pressedPartScrollGranularity()))
200 startTimerIfNeeded(delay); 200 startTimerIfNeeded(delay);
201 } 201 }
202 202
203 void Scrollbar::startTimerIfNeeded(double delay) 203 void Scrollbar::startTimerIfNeeded(double delay)
204 { 204 {
205 // Don't do anything for the thumb. 205 // Don't do anything for the thumb.
206 if (m_pressedPart == ThumbPart) 206 if (m_pressedPart == ThumbPart)
207 return; 207 return;
208 208
209 // Handle the track. We halt track scrolling once the thumb is level 209 // Handle the track. We halt track scrolling once the thumb is level
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 int trackLen = theme()->trackLength(this); 261 int trackLen = theme()->trackLength(this);
262 int maxPos = trackLen - thumbLen; 262 int maxPos = trackLen - thumbLen;
263 int delta = pos - m_pressedPos; 263 int delta = pos - m_pressedPos;
264 if (delta > 0) 264 if (delta > 0)
265 delta = min(maxPos - thumbPos, delta); 265 delta = min(maxPos - thumbPos, delta);
266 else if (delta < 0) 266 else if (delta < 0)
267 delta = max(-thumbPos, delta); 267 delta = max(-thumbPos, delta);
268 268
269 if (delta) { 269 if (delta) {
270 float newPosition = static_cast<float>(thumbPos + delta) * maximum() / ( trackLen - thumbLen); 270 float newPosition = static_cast<float>(thumbPos + delta) * maximum() / ( trackLen - thumbLen);
271 scrollableArea()->scrollToOffsetWithoutAnimation(m_orientation, newPosit ion); 271 if (m_scrollableArea)
272 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, newP osition);
272 } 273 }
273 } 274 }
274 275
275 void Scrollbar::setHoveredPart(ScrollbarPart part) 276 void Scrollbar::setHoveredPart(ScrollbarPart part)
276 { 277 {
277 if (part == m_hoveredPart) 278 if (part == m_hoveredPart)
278 return; 279 return;
279 280
280 if ((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMous eEnterExit()) 281 if ((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMous eEnterExit())
281 invalidate(); // Just invalidate the whole scrollbar, since the buttons at either end change anyway. 282 invalidate(); // Just invalidate the whole scrollbar, since the buttons at either end change anyway.
(...skipping 11 matching lines...) Expand all
293 m_pressedPart = part; 294 m_pressedPart = part;
294 if (m_pressedPart != NoPart) 295 if (m_pressedPart != NoPart)
295 theme()->invalidatePart(this, m_pressedPart); 296 theme()->invalidatePart(this, m_pressedPart);
296 else if (m_hoveredPart != NoPart) // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part. 297 else if (m_hoveredPart != NoPart) // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part.
297 theme()->invalidatePart(this, m_hoveredPart); 298 theme()->invalidatePart(this, m_hoveredPart);
298 } 299 }
299 300
300 bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt) 301 bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
301 { 302 {
302 if (m_pressedPart == ThumbPart) { 303 if (m_pressedPart == ThumbPart) {
303 if (theme()->shouldSnapBackToDragOrigin(this, evt)) 304 if (theme()->shouldSnapBackToDragOrigin(this, evt)) {
304 scrollableArea()->scrollToOffsetWithoutAnimation(m_orientation, m_dr agOrigin); 305 if (m_scrollableArea)
305 else { 306 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, m_dragOrigin);
307 } else {
306 moveThumb(m_orientation == HorizontalScrollbar ? 308 moveThumb(m_orientation == HorizontalScrollbar ?
307 convertFromContainingWindow(evt.pos()).x() : 309 convertFromContainingWindow(evt.pos()).x() :
308 convertFromContainingWindow(evt.pos()).y()); 310 convertFromContainingWindow(evt.pos()).y());
309 } 311 }
310 return true; 312 return true;
311 } 313 }
312 314
313 if (m_pressedPart != NoPart) 315 if (m_pressedPart != NoPart)
314 m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContai ningWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y()); 316 m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContai ningWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());
315 317
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 481
480 IntPoint Scrollbar::convertFromContainingView(const IntPoint& parentPoint) const 482 IntPoint Scrollbar::convertFromContainingView(const IntPoint& parentPoint) const
481 { 483 {
482 if (m_scrollableArea) 484 if (m_scrollableArea)
483 return m_scrollableArea->convertFromContainingViewToScrollbar(this, pare ntPoint); 485 return m_scrollableArea->convertFromContainingViewToScrollbar(this, pare ntPoint);
484 486
485 return Widget::convertFromContainingView(parentPoint); 487 return Widget::convertFromContainingView(parentPoint);
486 } 488 }
487 489
488 } // namespace WebCore 490 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698