Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonEndPa rt || m_pressedPart == ForwardButtonStartPart || m_pressedPart == ForwardButton EndPart) | 281 if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonEndPa rt || m_pressedPart == ForwardButtonStartPart || m_pressedPart == ForwardButton EndPart) |
| 282 return ScrollByLine; | 282 return ScrollByLine; |
| 283 return ScrollByPage; | 283 return ScrollByPage; |
| 284 } | 284 } |
| 285 | 285 |
| 286 void Scrollbar::moveThumb(int pos, bool draggingDocument) | 286 void Scrollbar::moveThumb(int pos, bool draggingDocument) |
| 287 { | 287 { |
| 288 if (!m_scrollableArea) | 288 if (!m_scrollableArea) |
| 289 return; | 289 return; |
| 290 | 290 |
| 291 | |
|
jamesr
2013/05/07 03:33:31
nit: don't need this blank line
| |
| 291 int delta = pos - m_pressedPos; | 292 int delta = pos - m_pressedPos; |
| 292 | 293 |
| 293 if (draggingDocument) { | 294 if (draggingDocument) { |
| 294 if (m_draggingDocument) | 295 if (m_draggingDocument) |
| 295 delta = pos - m_documentDragPos; | 296 delta = pos - m_documentDragPos; |
| 296 m_draggingDocument = true; | 297 m_draggingDocument = true; |
| 297 FloatPoint currentPosition = m_scrollableArea->scrollAnimator()->current Position(); | 298 FloatPoint currentPosition = m_scrollableArea->scrollAnimator()->current Position(); |
| 298 int destinationPosition = (m_orientation == HorizontalScrollbar ? curren tPosition.x() : currentPosition.y()) + delta; | 299 float destinationPosition = (m_orientation == HorizontalScrollbar ? curr entPosition.x() : currentPosition.y()) + delta; |
| 299 if (delta > 0) | 300 destinationPosition = m_scrollableArea->clampScrollPosition(m_orientatio n, destinationPosition); |
| 300 destinationPosition = min(destinationPosition + delta, maximum()); | |
| 301 else if (delta < 0) | |
| 302 destinationPosition = max(destinationPosition + delta, 0); | |
| 303 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, destinat ionPosition); | 301 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, destinat ionPosition); |
| 304 m_documentDragPos = pos; | 302 m_documentDragPos = pos; |
| 305 return; | 303 return; |
| 306 } | 304 } |
| 307 | 305 |
| 308 if (m_draggingDocument) { | 306 if (m_draggingDocument) { |
| 309 delta += m_pressedPos - m_documentDragPos; | 307 delta += m_pressedPos - m_documentDragPos; |
| 310 m_draggingDocument = false; | 308 m_draggingDocument = false; |
| 311 } | 309 } |
| 312 | 310 |
| 313 // Drag the thumb. | 311 // Drag the thumb. |
| 314 int thumbPos = theme()->thumbPosition(this); | 312 int thumbPos = theme()->thumbPosition(this); |
| 315 int thumbLen = theme()->thumbLength(this); | 313 int thumbLen = theme()->thumbLength(this); |
| 316 int trackLen = theme()->trackLength(this); | 314 int trackLen = theme()->trackLength(this); |
| 317 int maxPos = trackLen - thumbLen; | |
| 318 if (delta > 0) | 315 if (delta > 0) |
| 319 delta = min(maxPos - thumbPos, delta); | 316 delta = min(trackLen - thumbLen - thumbPos, delta); |
| 320 else if (delta < 0) | 317 else if (delta < 0) |
| 321 delta = max(-thumbPos, delta); | 318 delta = max(-thumbPos, delta); |
| 322 | 319 |
| 320 float minPos = m_scrollableArea->minimumScrollPosition(m_orientation); | |
| 321 float maxPos = m_scrollableArea->maximumScrollPosition(m_orientation); | |
| 323 if (delta) { | 322 if (delta) { |
| 324 float newPosition = static_cast<float>(thumbPos + delta) * maximum() / ( trackLen - thumbLen); | 323 float newPosition = static_cast<float>(thumbPos + delta) * (maxPos - min Pos) / (trackLen - thumbLen) + minPos; |
| 325 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, newPosit ion); | 324 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, newPosit ion); |
| 326 } | 325 } |
| 327 } | 326 } |
| 328 | 327 |
| 329 void Scrollbar::setHoveredPart(ScrollbarPart part) | 328 void Scrollbar::setHoveredPart(ScrollbarPart part) |
| 330 { | 329 { |
| 331 if (part == m_hoveredPart) | 330 if (part == m_hoveredPart) |
| 332 return; | 331 return; |
| 333 | 332 |
| 334 if ((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMous eEnterExit()) | 333 if ((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMous eEnterExit()) |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 | 598 |
| 600 IntPoint Scrollbar::convertFromContainingView(const IntPoint& parentPoint) const | 599 IntPoint Scrollbar::convertFromContainingView(const IntPoint& parentPoint) const |
| 601 { | 600 { |
| 602 if (m_scrollableArea) | 601 if (m_scrollableArea) |
| 603 return m_scrollableArea->convertFromContainingViewToScrollbar(this, pare ntPoint); | 602 return m_scrollableArea->convertFromContainingViewToScrollbar(this, pare ntPoint); |
| 604 | 603 |
| 605 return Widget::convertFromContainingView(parentPoint); | 604 return Widget::convertFromContainingView(parentPoint); |
| 606 } | 605 } |
| 607 | 606 |
| 608 } // namespace WebCore | 607 } // namespace WebCore |
| OLD | NEW |