| 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" |
| 29 #include "platform/PlatformGestureEvent.h" | 30 #include "platform/PlatformGestureEvent.h" |
| 30 #include "platform/PlatformMouseEvent.h" | 31 #include "platform/PlatformMouseEvent.h" |
| 31 #include "platform/graphics/paint/CullRect.h" | 32 #include "platform/graphics/paint/CullRect.h" |
| 32 // See windowActiveChangedForSnowLeopardOnly() below. | 33 // See windowActiveChangedForSnowLeopardOnly() below. |
| 33 // TODO(ellyjones): remove this when Snow Leopard support is gone. | 34 // TODO(ellyjones): remove this when Snow Leopard support is gone. |
| 34 #if OS(MACOSX) | 35 #if OS(MACOSX) |
| 35 #include "platform/mac/VersionUtilMac.h" | 36 #include "platform/mac/VersionUtilMac.h" |
| 36 #endif | 37 #endif |
| 37 #include "platform/scroll/ScrollAnimatorBase.h" | 38 #include "platform/scroll/ScrollAnimatorBase.h" |
| 38 #include "platform/scroll/ScrollableArea.h" | 39 #include "platform/scroll/ScrollableArea.h" |
| 39 #include "platform/scroll/ScrollbarTheme.h" | 40 #include "platform/scroll/ScrollbarTheme.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableAr
ea, ScrollbarOrientation orientation, ScrollbarControlSize size) | 44 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableAr
ea, ScrollbarOrientation orientation, ScrollbarControlSize size, HostWindow* hos
tWindow) |
| 44 { | 45 { |
| 45 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size)); | 46 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, h
ostWindow)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::createForTesting(ScrollableArea* sc
rollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size, Scrol
lbarTheme* theme) | 49 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::createForTesting(ScrollableArea* sc
rollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size, Scrol
lbarTheme* theme) |
| 49 { | 50 { |
| 50 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, t
heme)); | 51 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, n
ullptr, theme)); |
| 51 } | 52 } |
| 52 | 53 |
| 53 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient
ation, ScrollbarControlSize controlSize, ScrollbarTheme* theme) | 54 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient
ation, ScrollbarControlSize controlSize, HostWindow* hostWindow, ScrollbarTheme*
theme) |
| 54 : m_scrollableArea(scrollableArea) | 55 : m_scrollableArea(scrollableArea) |
| 55 , m_orientation(orientation) | 56 , m_orientation(orientation) |
| 56 , m_controlSize(controlSize) | 57 , m_controlSize(controlSize) |
| 57 , m_theme(theme ? *theme : ScrollbarTheme::theme()) | 58 , m_theme(theme ? *theme : ScrollbarTheme::theme()) |
| 59 , m_hostWindow(hostWindow) |
| 58 , m_visibleSize(0) | 60 , m_visibleSize(0) |
| 59 , m_totalSize(0) | 61 , m_totalSize(0) |
| 60 , m_currentPos(0) | 62 , m_currentPos(0) |
| 61 , m_dragOrigin(0) | 63 , m_dragOrigin(0) |
| 62 , m_hoveredPart(NoPart) | 64 , m_hoveredPart(NoPart) |
| 63 , m_pressedPart(NoPart) | 65 , m_pressedPart(NoPart) |
| 64 , m_pressedPos(0) | 66 , m_pressedPos(0) |
| 65 , m_scrollPos(0) | 67 , m_scrollPos(0) |
| 66 , m_draggingDocument(false) | 68 , m_draggingDocument(false) |
| 67 , m_documentDragPos(0) | 69 , m_documentDragPos(0) |
| 68 , m_enabled(true) | 70 , m_enabled(true) |
| 69 , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired) | 71 , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired) |
| 70 , m_overlapsResizer(false) | 72 , m_overlapsResizer(false) |
| 71 , m_elasticOverscroll(0) | 73 , m_elasticOverscroll(0) |
| 72 , m_trackNeedsRepaint(true) | 74 , m_trackNeedsRepaint(true) |
| 73 , m_thumbNeedsRepaint(true) | 75 , m_thumbNeedsRepaint(true) |
| 74 { | 76 { |
| 75 m_theme.registerScrollbar(*this); | 77 m_theme.registerScrollbar(*this); |
| 76 | 78 |
| 77 // FIXME: This is ugly and would not be necessary if we fix cross-platform c
ode to actually query for | 79 // FIXME: This is ugly and would not be necessary if we fix cross-platform c
ode to actually query for |
| 78 // scrollbar thickness and use it when sizing scrollbars (rather than leavin
g one dimension of the scrollbar | 80 // scrollbar thickness and use it when sizing scrollbars (rather than leavin
g one dimension of the scrollbar |
| 79 // alone when sizing). | 81 // alone when sizing). |
| 80 int thickness = m_theme.scrollbarThickness(controlSize); | 82 int thickness = m_theme.scrollbarThickness(controlSize); |
| 83 if (m_hostWindow) |
| 84 thickness = m_hostWindow->screenToViewport(thickness); |
| 81 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); | 85 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); |
| 82 | 86 |
| 83 m_currentPos = scrollableAreaCurrentPos(); | 87 m_currentPos = scrollableAreaCurrentPos(); |
| 84 } | 88 } |
| 85 | 89 |
| 86 Scrollbar::~Scrollbar() | 90 Scrollbar::~Scrollbar() |
| 87 { | 91 { |
| 88 m_theme.unregisterScrollbar(*this); | 92 m_theme.unregisterScrollbar(*this); |
| 89 } | 93 } |
| 90 | 94 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 468 |
| 465 void Scrollbar::setEnabled(bool e) | 469 void Scrollbar::setEnabled(bool e) |
| 466 { | 470 { |
| 467 if (m_enabled == e) | 471 if (m_enabled == e) |
| 468 return; | 472 return; |
| 469 m_enabled = e; | 473 m_enabled = e; |
| 470 theme().updateEnabledState(*this); | 474 theme().updateEnabledState(*this); |
| 471 setNeedsPaintInvalidation(); | 475 setNeedsPaintInvalidation(); |
| 472 } | 476 } |
| 473 | 477 |
| 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 |
| 474 bool Scrollbar::isOverlayScrollbar() const | 487 bool Scrollbar::isOverlayScrollbar() const |
| 475 { | 488 { |
| 476 return m_theme.usesOverlayScrollbars(); | 489 return m_theme.usesOverlayScrollbars(); |
| 477 } | 490 } |
| 478 | 491 |
| 479 bool Scrollbar::shouldParticipateInHitTesting() | 492 bool Scrollbar::shouldParticipateInHitTesting() |
| 480 { | 493 { |
| 481 // Non-overlay scrollbars should always participate in hit testing. | 494 // Non-overlay scrollbars should always participate in hit testing. |
| 482 if (!isOverlayScrollbar()) | 495 if (!isOverlayScrollbar()) |
| 483 return true; | 496 return true; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 invalidParts = AllParts; | 566 invalidParts = AllParts; |
| 554 if (invalidParts & ~ThumbPart) | 567 if (invalidParts & ~ThumbPart) |
| 555 m_trackNeedsRepaint = true; | 568 m_trackNeedsRepaint = true; |
| 556 if (invalidParts & ThumbPart) | 569 if (invalidParts & ThumbPart) |
| 557 m_thumbNeedsRepaint = true; | 570 m_thumbNeedsRepaint = true; |
| 558 if (m_scrollableArea) | 571 if (m_scrollableArea) |
| 559 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); | 572 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); |
| 560 } | 573 } |
| 561 | 574 |
| 562 } // namespace blink | 575 } // namespace blink |
| OLD | NEW |