| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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" | |
| 30 #include "platform/PlatformGestureEvent.h" | 29 #include "platform/PlatformGestureEvent.h" |
| 31 #include "platform/PlatformMouseEvent.h" | 30 #include "platform/PlatformMouseEvent.h" |
| 32 #include "platform/graphics/paint/CullRect.h" | 31 #include "platform/graphics/paint/CullRect.h" |
| 33 // See windowActiveChangedForSnowLeopardOnly() below. | 32 // See windowActiveChangedForSnowLeopardOnly() below. |
| 34 // TODO(ellyjones): remove this when Snow Leopard support is gone. | 33 // TODO(ellyjones): remove this when Snow Leopard support is gone. |
| 35 #if OS(MACOSX) | 34 #if OS(MACOSX) |
| 36 #include "platform/mac/VersionUtilMac.h" | 35 #include "platform/mac/VersionUtilMac.h" |
| 37 #endif | 36 #endif |
| 38 #include "platform/scroll/ScrollAnimatorBase.h" | 37 #include "platform/scroll/ScrollAnimatorBase.h" |
| 39 #include "platform/scroll/ScrollableArea.h" | 38 #include "platform/scroll/ScrollableArea.h" |
| 40 #include "platform/scroll/ScrollbarTheme.h" | 39 #include "platform/scroll/ScrollbarTheme.h" |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableAr
ea, ScrollbarOrientation orientation, ScrollbarControlSize size, HostWindow* hos
tWindow) | 43 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableAr
ea, ScrollbarOrientation orientation, ScrollbarControlSize size) |
| 45 { | 44 { |
| 46 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, h
ostWindow)); | 45 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size)); |
| 47 } | 46 } |
| 48 | 47 |
| 49 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::createForTesting(ScrollableArea* sc
rollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size, Scrol
lbarTheme* theme) | 48 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::createForTesting(ScrollableArea* sc
rollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size, Scrol
lbarTheme* theme) |
| 50 { | 49 { |
| 51 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, n
ullptr, theme)); | 50 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, t
heme)); |
| 52 } | 51 } |
| 53 | 52 |
| 54 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient
ation, ScrollbarControlSize controlSize, HostWindow* hostWindow, ScrollbarTheme*
theme) | 53 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient
ation, ScrollbarControlSize controlSize, ScrollbarTheme* theme) |
| 55 : m_scrollableArea(scrollableArea) | 54 : m_scrollableArea(scrollableArea) |
| 56 , m_orientation(orientation) | 55 , m_orientation(orientation) |
| 57 , m_controlSize(controlSize) | 56 , m_controlSize(controlSize) |
| 58 , m_theme(theme ? *theme : ScrollbarTheme::theme()) | 57 , m_theme(theme ? *theme : ScrollbarTheme::theme()) |
| 59 , m_hostWindow(hostWindow) | |
| 60 , m_visibleSize(0) | 58 , m_visibleSize(0) |
| 61 , m_totalSize(0) | 59 , m_totalSize(0) |
| 62 , m_currentPos(0) | 60 , m_currentPos(0) |
| 63 , m_dragOrigin(0) | 61 , m_dragOrigin(0) |
| 64 , m_hoveredPart(NoPart) | 62 , m_hoveredPart(NoPart) |
| 65 , m_pressedPart(NoPart) | 63 , m_pressedPart(NoPart) |
| 66 , m_pressedPos(0) | 64 , m_pressedPos(0) |
| 67 , m_scrollPos(0) | 65 , m_scrollPos(0) |
| 68 , m_draggingDocument(false) | 66 , m_draggingDocument(false) |
| 69 , m_documentDragPos(0) | 67 , m_documentDragPos(0) |
| 70 , m_enabled(true) | 68 , m_enabled(true) |
| 71 , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired) | 69 , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired) |
| 72 , m_overlapsResizer(false) | 70 , m_overlapsResizer(false) |
| 73 , m_elasticOverscroll(0) | 71 , m_elasticOverscroll(0) |
| 74 , m_trackNeedsRepaint(true) | 72 , m_trackNeedsRepaint(true) |
| 75 , m_thumbNeedsRepaint(true) | 73 , m_thumbNeedsRepaint(true) |
| 76 { | 74 { |
| 77 m_theme.registerScrollbar(*this); | 75 m_theme.registerScrollbar(*this); |
| 78 | 76 |
| 79 // FIXME: This is ugly and would not be necessary if we fix cross-platform c
ode to actually query for | 77 // 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 | 78 // scrollbar thickness and use it when sizing scrollbars (rather than leavin
g one dimension of the scrollbar |
| 81 // alone when sizing). | 79 // alone when sizing). |
| 82 int thickness = m_theme.scrollbarThickness(controlSize); | 80 int thickness = m_theme.scrollbarThickness(controlSize); |
| 83 if (m_hostWindow) | |
| 84 thickness = m_hostWindow->screenToViewport(thickness); | |
| 85 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); | 81 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); |
| 86 | 82 |
| 87 m_currentPos = scrollableAreaCurrentPos(); | 83 m_currentPos = scrollableAreaCurrentPos(); |
| 88 } | 84 } |
| 89 | 85 |
| 90 Scrollbar::~Scrollbar() | 86 Scrollbar::~Scrollbar() |
| 91 { | 87 { |
| 92 m_theme.unregisterScrollbar(*this); | 88 m_theme.unregisterScrollbar(*this); |
| 93 } | 89 } |
| 94 | 90 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 464 |
| 469 void Scrollbar::setEnabled(bool e) | 465 void Scrollbar::setEnabled(bool e) |
| 470 { | 466 { |
| 471 if (m_enabled == e) | 467 if (m_enabled == e) |
| 472 return; | 468 return; |
| 473 m_enabled = e; | 469 m_enabled = e; |
| 474 theme().updateEnabledState(*this); | 470 theme().updateEnabledState(*this); |
| 475 setNeedsPaintInvalidation(); | 471 setNeedsPaintInvalidation(); |
| 476 } | 472 } |
| 477 | 473 |
| 478 int Scrollbar::scrollbarThickness() const | |
| 479 { | |
| 480 int thickness = orientation() == HorizontalScrollbar ? height() : width(); | |
| 481 if (!thickness || !m_hostWindow) | |
| 482 return thickness; | |
| 483 return m_hostWindow->screenToViewport(m_theme.scrollbarThickness(controlSize
())); | |
| 484 } | |
| 485 | |
| 486 | |
| 487 bool Scrollbar::isOverlayScrollbar() const | 474 bool Scrollbar::isOverlayScrollbar() const |
| 488 { | 475 { |
| 489 return m_theme.usesOverlayScrollbars(); | 476 return m_theme.usesOverlayScrollbars(); |
| 490 } | 477 } |
| 491 | 478 |
| 492 bool Scrollbar::shouldParticipateInHitTesting() | 479 bool Scrollbar::shouldParticipateInHitTesting() |
| 493 { | 480 { |
| 494 // Non-overlay scrollbars should always participate in hit testing. | 481 // Non-overlay scrollbars should always participate in hit testing. |
| 495 if (!isOverlayScrollbar()) | 482 if (!isOverlayScrollbar()) |
| 496 return true; | 483 return true; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 invalidParts = AllParts; | 553 invalidParts = AllParts; |
| 567 if (invalidParts & ~ThumbPart) | 554 if (invalidParts & ~ThumbPart) |
| 568 m_trackNeedsRepaint = true; | 555 m_trackNeedsRepaint = true; |
| 569 if (invalidParts & ThumbPart) | 556 if (invalidParts & ThumbPart) |
| 570 m_thumbNeedsRepaint = true; | 557 m_thumbNeedsRepaint = true; |
| 571 if (m_scrollableArea) | 558 if (m_scrollableArea) |
| 572 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); | 559 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); |
| 573 } | 560 } |
| 574 | 561 |
| 575 } // namespace blink | 562 } // namespace blink |
| OLD | NEW |