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