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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include <algorithm> | 29 #include <algorithm> |
30 #include "platform/graphics/GraphicsContext.h" | 30 #include "platform/graphics/GraphicsContext.h" |
31 #include "platform/PlatformGestureEvent.h" | 31 #include "platform/PlatformGestureEvent.h" |
32 #include "platform/PlatformMouseEvent.h" | 32 #include "platform/PlatformMouseEvent.h" |
33 #include "platform/scroll/ScrollAnimator.h" | 33 #include "platform/scroll/ScrollAnimator.h" |
34 #include "platform/scroll/ScrollView.h" | 34 #include "platform/scroll/ScrollView.h" |
35 #include "platform/scroll/ScrollableArea.h" | 35 #include "platform/scroll/ScrollableArea.h" |
36 #include "platform/scroll/ScrollbarTheme.h" | 36 #include "platform/scroll/ScrollbarTheme.h" |
37 | 37 |
38 using namespace std; | |
39 | |
40 #if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN)) | 38 #if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN)) |
41 // The position of the scrollbar thumb affects the appearance of the steppers, s
o | 39 // The position of the scrollbar thumb affects the appearance of the steppers, s
o |
42 // when the thumb moves, we have to invalidate them for painting. | 40 // when the thumb moves, we have to invalidate them for painting. |
43 #define THUMB_POSITION_AFFECTS_BUTTONS | 41 #define THUMB_POSITION_AFFECTS_BUTTONS |
44 #endif | 42 #endif |
45 | 43 |
46 namespace blink { | 44 namespace blink { |
47 | 45 |
48 PassRefPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableArea, Scrollba
rOrientation orientation, ScrollbarControlSize size) | 46 PassRefPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableArea, Scrollba
rOrientation orientation, ScrollbarControlSize size) |
49 { | 47 { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if (m_draggingDocument) { | 293 if (m_draggingDocument) { |
296 delta += m_pressedPos - m_documentDragPos; | 294 delta += m_pressedPos - m_documentDragPos; |
297 m_draggingDocument = false; | 295 m_draggingDocument = false; |
298 } | 296 } |
299 | 297 |
300 // Drag the thumb. | 298 // Drag the thumb. |
301 int thumbPos = theme()->thumbPosition(this); | 299 int thumbPos = theme()->thumbPosition(this); |
302 int thumbLen = theme()->thumbLength(this); | 300 int thumbLen = theme()->thumbLength(this); |
303 int trackLen = theme()->trackLength(this); | 301 int trackLen = theme()->trackLength(this); |
304 if (delta > 0) | 302 if (delta > 0) |
305 delta = min(trackLen - thumbLen - thumbPos, delta); | 303 delta = std::min(trackLen - thumbLen - thumbPos, delta); |
306 else if (delta < 0) | 304 else if (delta < 0) |
307 delta = max(-thumbPos, delta); | 305 delta = std::max(-thumbPos, delta); |
308 | 306 |
309 float minPos = m_scrollableArea->minimumScrollPosition(m_orientation); | 307 float minPos = m_scrollableArea->minimumScrollPosition(m_orientation); |
310 float maxPos = m_scrollableArea->maximumScrollPosition(m_orientation); | 308 float maxPos = m_scrollableArea->maximumScrollPosition(m_orientation); |
311 if (delta) { | 309 if (delta) { |
312 float newPosition = static_cast<float>(thumbPos + delta) * (maxPos - min
Pos) / (trackLen - thumbLen) + minPos; | 310 float newPosition = static_cast<float>(thumbPos + delta) * (maxPos - min
Pos) / (trackLen - thumbLen) + minPos; |
313 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, newPosit
ion); | 311 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, newPosit
ion); |
314 } | 312 } |
315 } | 313 } |
316 | 314 |
317 void Scrollbar::setHoveredPart(ScrollbarPart part) | 315 void Scrollbar::setHoveredPart(ScrollbarPart part) |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 if (!m_scrollableArea) | 590 if (!m_scrollableArea) |
593 return 0; | 591 return 0; |
594 | 592 |
595 if (m_orientation == HorizontalScrollbar) | 593 if (m_orientation == HorizontalScrollbar) |
596 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu
mScrollPosition().x(); | 594 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu
mScrollPosition().x(); |
597 | 595 |
598 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr
ollPosition().y(); | 596 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr
ollPosition().y(); |
599 } | 597 } |
600 | 598 |
601 } // namespace blink | 599 } // namespace blink |
OLD | NEW |