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 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "platform/scroll/Scrollbar.h" | 26 #include "platform/scroll/Scrollbar.h" |
27 | 27 |
28 #include <algorithm> | 28 #include <algorithm> |
29 #include "platform/HostWindow.h" | 29 #include "platform/HostWindow.h" |
30 #include "platform/PlatformGestureEvent.h" | 30 #include "platform/PlatformGestureEvent.h" |
31 #include "platform/PlatformMouseEvent.h" | 31 #include "platform/PlatformMouseEvent.h" |
| 32 #include "platform/geometry/FloatRect.h" |
32 #include "platform/graphics/paint/CullRect.h" | 33 #include "platform/graphics/paint/CullRect.h" |
33 // See windowActiveChangedForSnowLeopardOnly() below. | 34 // See windowActiveChangedForSnowLeopardOnly() below. |
34 // TODO(ellyjones): remove this when Snow Leopard support is gone. | 35 // TODO(ellyjones): remove this when Snow Leopard support is gone. |
35 #if OS(MACOSX) | 36 #if OS(MACOSX) |
36 #include "platform/mac/VersionUtilMac.h" | 37 #include "platform/mac/VersionUtilMac.h" |
37 #endif | 38 #endif |
38 #include "platform/scroll/ScrollAnimatorBase.h" | 39 #include "platform/scroll/ScrollAnimatorBase.h" |
39 #include "platform/scroll/ScrollableArea.h" | 40 #include "platform/scroll/ScrollableArea.h" |
40 #include "platform/scroll/ScrollbarTheme.h" | 41 #include "platform/scroll/ScrollbarTheme.h" |
41 | 42 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 , m_trackNeedsRepaint(true) | 75 , m_trackNeedsRepaint(true) |
75 , m_thumbNeedsRepaint(true) | 76 , m_thumbNeedsRepaint(true) |
76 { | 77 { |
77 m_theme.registerScrollbar(*this); | 78 m_theme.registerScrollbar(*this); |
78 | 79 |
79 // FIXME: This is ugly and would not be necessary if we fix cross-platform c
ode to actually query for | 80 // FIXME: This is ugly and would not be necessary if we fix cross-platform c
ode to actually query for |
80 // scrollbar thickness and use it when sizing scrollbars (rather than leavin
g one dimension of the scrollbar | 81 // scrollbar thickness and use it when sizing scrollbars (rather than leavin
g one dimension of the scrollbar |
81 // alone when sizing). | 82 // alone when sizing). |
82 int thickness = m_theme.scrollbarThickness(controlSize); | 83 int thickness = m_theme.scrollbarThickness(controlSize); |
83 if (m_hostWindow) | 84 if (m_hostWindow) |
84 thickness = m_hostWindow->screenToViewport(thickness); | 85 thickness = m_hostWindow->windowToViewport(FloatRect(0, 0, thickness, 0)
).width(); |
85 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); | 86 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); |
86 | 87 |
87 m_currentPos = scrollableAreaCurrentPos(); | 88 m_currentPos = scrollableAreaCurrentPos(); |
88 } | 89 } |
89 | 90 |
90 Scrollbar::~Scrollbar() | 91 Scrollbar::~Scrollbar() |
91 { | 92 { |
92 m_theme.unregisterScrollbar(*this); | 93 m_theme.unregisterScrollbar(*this); |
93 } | 94 } |
94 | 95 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 m_enabled = e; | 476 m_enabled = e; |
476 theme().updateEnabledState(*this); | 477 theme().updateEnabledState(*this); |
477 setNeedsPaintInvalidation(AllParts); | 478 setNeedsPaintInvalidation(AllParts); |
478 } | 479 } |
479 | 480 |
480 int Scrollbar::scrollbarThickness() const | 481 int Scrollbar::scrollbarThickness() const |
481 { | 482 { |
482 int thickness = orientation() == HorizontalScrollbar ? height() : width(); | 483 int thickness = orientation() == HorizontalScrollbar ? height() : width(); |
483 if (!thickness || !m_hostWindow) | 484 if (!thickness || !m_hostWindow) |
484 return thickness; | 485 return thickness; |
485 return m_hostWindow->screenToViewport(m_theme.scrollbarThickness(controlSize
())); | 486 return m_hostWindow->windowToViewport(FloatRect(0, 0, m_theme.scrollbarThick
ness(controlSize()), 0)).width(); |
486 } | 487 } |
487 | 488 |
488 | 489 |
489 bool Scrollbar::isOverlayScrollbar() const | 490 bool Scrollbar::isOverlayScrollbar() const |
490 { | 491 { |
491 return m_theme.usesOverlayScrollbars(); | 492 return m_theme.usesOverlayScrollbars(); |
492 } | 493 } |
493 | 494 |
494 bool Scrollbar::shouldParticipateInHitTesting() | 495 bool Scrollbar::shouldParticipateInHitTesting() |
495 { | 496 { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 invalidParts = AllParts; | 580 invalidParts = AllParts; |
580 if (invalidParts & ~ThumbPart) | 581 if (invalidParts & ~ThumbPart) |
581 m_trackNeedsRepaint = true; | 582 m_trackNeedsRepaint = true; |
582 if (invalidParts & ThumbPart) | 583 if (invalidParts & ThumbPart) |
583 m_thumbNeedsRepaint = true; | 584 m_thumbNeedsRepaint = true; |
584 if (m_scrollableArea) | 585 if (m_scrollableArea) |
585 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); | 586 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); |
586 } | 587 } |
587 | 588 |
588 } // namespace blink | 589 } // namespace blink |
OLD | NEW |