hyatt@apple.com | f18feec | 2008-09-15 00:56:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "ScrollbarThemeComposite.h" |
| 28 | |
aroben@apple.com | a7c639a | 2009-12-18 17:38:45 +0000 | [diff] [blame] | 29 | #include "Chrome.h" |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 30 | #include "ChromeClient.h" |
| 31 | #include "Frame.h" |
| 32 | #include "FrameView.h" |
| 33 | #include "GraphicsContext.h" |
| 34 | #include "Page.h" |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 35 | #include "PlatformMouseEvent.h" |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 36 | #include "Scrollbar.h" |
weinig@apple.com | d7d77c3 | 2011-01-21 20:15:04 +0000 | [diff] [blame] | 37 | #include "ScrollableArea.h" |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 38 | #include "Settings.h" |
| 39 | |
weinig@apple.com | fe3ba1a | 2011-01-27 21:23:06 +0000 | [diff] [blame] | 40 | using namespace std; |
| 41 | |
hyatt@apple.com | f18feec | 2008-09-15 00:56:11 +0000 | [diff] [blame] | 42 | namespace WebCore { |
| 43 | |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 44 | bool ScrollbarThemeComposite::paint(Scrollbar* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect) |
| 45 | { |
| 46 | // Create the ScrollbarControlPartMask based on the damageRect |
| 47 | ScrollbarControlPartMask scrollMask = NoPart; |
| 48 | |
hyatt@apple.com | d48dbf3 | 2008-09-20 03:21:14 +0000 | [diff] [blame] | 49 | IntRect backButtonStartPaintRect; |
| 50 | IntRect backButtonEndPaintRect; |
| 51 | IntRect forwardButtonStartPaintRect; |
| 52 | IntRect forwardButtonEndPaintRect; |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 53 | if (hasButtons(scrollbar)) { |
hyatt@apple.com | d48dbf3 | 2008-09-20 03:21:14 +0000 | [diff] [blame] | 54 | backButtonStartPaintRect = backButtonRect(scrollbar, BackButtonStartPart, true); |
| 55 | if (damageRect.intersects(backButtonStartPaintRect)) |
hyatt@apple.com | 57b2d52 | 2008-09-19 23:39:26 +0000 | [diff] [blame] | 56 | scrollMask |= BackButtonStartPart; |
hyatt@apple.com | d48dbf3 | 2008-09-20 03:21:14 +0000 | [diff] [blame] | 57 | backButtonEndPaintRect = backButtonRect(scrollbar, BackButtonEndPart, true); |
| 58 | if (damageRect.intersects(backButtonEndPaintRect)) |
| 59 | scrollMask |= BackButtonEndPart; |
| 60 | forwardButtonStartPaintRect = forwardButtonRect(scrollbar, ForwardButtonStartPart, true); |
| 61 | if (damageRect.intersects(forwardButtonStartPaintRect)) |
| 62 | scrollMask |= ForwardButtonStartPart; |
| 63 | forwardButtonEndPaintRect = forwardButtonRect(scrollbar, ForwardButtonEndPart, true); |
| 64 | if (damageRect.intersects(forwardButtonEndPaintRect)) |
hyatt@apple.com | 57b2d52 | 2008-09-19 23:39:26 +0000 | [diff] [blame] | 65 | scrollMask |= ForwardButtonEndPart; |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | IntRect startTrackRect; |
| 69 | IntRect thumbRect; |
| 70 | IntRect endTrackRect; |
| 71 | IntRect trackPaintRect = trackRect(scrollbar, true); |
hyatt@apple.com | f245267 | 2008-10-11 07:50:03 +0000 | [diff] [blame] | 72 | if (damageRect.intersects(trackPaintRect)) |
| 73 | scrollMask |= TrackBGPart; |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 74 | bool thumbPresent = hasThumb(scrollbar); |
| 75 | if (thumbPresent) { |
| 76 | IntRect track = trackRect(scrollbar); |
| 77 | splitTrack(scrollbar, track, startTrackRect, thumbRect, endTrackRect); |
hyatt@apple.com | 2e4835d | 2008-10-10 02:33:16 +0000 | [diff] [blame] | 78 | if (damageRect.intersects(thumbRect)) |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 79 | scrollMask |= ThumbPart; |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 80 | if (damageRect.intersects(startTrackRect)) |
| 81 | scrollMask |= BackTrackPart; |
| 82 | if (damageRect.intersects(endTrackRect)) |
| 83 | scrollMask |= ForwardTrackPart; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 84 | } |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 85 | |
hyatt@apple.com | 2e4835d | 2008-10-10 02:33:16 +0000 | [diff] [blame] | 86 | // Paint the scrollbar background (only used by custom CSS scrollbars). |
| 87 | paintScrollbarBackground(graphicsContext, scrollbar); |
| 88 | |
hyatt@apple.com | c92f8c2 | 2008-10-10 20:12:14 +0000 | [diff] [blame] | 89 | // Paint the back and forward buttons. |
| 90 | if (scrollMask & BackButtonStartPart) |
| 91 | paintButton(graphicsContext, scrollbar, backButtonStartPaintRect, BackButtonStartPart); |
| 92 | if (scrollMask & BackButtonEndPart) |
| 93 | paintButton(graphicsContext, scrollbar, backButtonEndPaintRect, BackButtonEndPart); |
| 94 | if (scrollMask & ForwardButtonStartPart) |
| 95 | paintButton(graphicsContext, scrollbar, forwardButtonStartPaintRect, ForwardButtonStartPart); |
| 96 | if (scrollMask & ForwardButtonEndPart) |
| 97 | paintButton(graphicsContext, scrollbar, forwardButtonEndPaintRect, ForwardButtonEndPart); |
| 98 | |
hyatt@apple.com | f245267 | 2008-10-11 07:50:03 +0000 | [diff] [blame] | 99 | if (scrollMask & TrackBGPart) |
hyatt@apple.com | 2e4835d | 2008-10-10 02:33:16 +0000 | [diff] [blame] | 100 | paintTrackBackground(graphicsContext, scrollbar, trackPaintRect); |
| 101 | |
hyatt@apple.com | f245267 | 2008-10-11 07:50:03 +0000 | [diff] [blame] | 102 | if ((scrollMask & ForwardTrackPart) || (scrollMask & BackTrackPart)) { |
hyatt@apple.com | 739b8f0 | 2008-10-11 06:12:14 +0000 | [diff] [blame] | 103 | // Paint the track pieces above and below the thumb. |
hyatt@apple.com | 2e4835d | 2008-10-10 02:33:16 +0000 | [diff] [blame] | 104 | if (scrollMask & BackTrackPart) |
| 105 | paintTrackPiece(graphicsContext, scrollbar, startTrackRect, BackTrackPart); |
| 106 | if (scrollMask & ForwardTrackPart) |
| 107 | paintTrackPiece(graphicsContext, scrollbar, endTrackRect, ForwardTrackPart); |
darin@chromium.org | 2b36792 | 2008-11-24 23:12:03 +0000 | [diff] [blame] | 108 | |
| 109 | paintTickmarks(graphicsContext, scrollbar, trackPaintRect); |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 110 | } |
| 111 | |
hyatt@apple.com | 065494e | 2008-09-15 06:33:40 +0000 | [diff] [blame] | 112 | // Paint the thumb. |
| 113 | if (scrollMask & ThumbPart) |
| 114 | paintThumb(graphicsContext, scrollbar, thumbRect); |
| 115 | |
| 116 | return true; |
hyatt@apple.com | f18feec | 2008-09-15 00:56:11 +0000 | [diff] [blame] | 117 | } |
| 118 | |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 119 | ScrollbarPart ScrollbarThemeComposite::hitTest(Scrollbar* scrollbar, const PlatformMouseEvent& evt) |
| 120 | { |
| 121 | ScrollbarPart result = NoPart; |
hyatt@apple.com | d1a0124 | 2008-09-18 01:32:42 +0000 | [diff] [blame] | 122 | if (!scrollbar->enabled()) |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 123 | return result; |
| 124 | |
| 125 | IntPoint mousePosition = scrollbar->convertFromContainingWindow(evt.pos()); |
| 126 | mousePosition.move(scrollbar->x(), scrollbar->y()); |
hyatt@apple.com | f245267 | 2008-10-11 07:50:03 +0000 | [diff] [blame] | 127 | |
| 128 | if (!scrollbar->frameRect().contains(mousePosition)) |
| 129 | return NoPart; |
| 130 | |
| 131 | result = ScrollbarBGPart; |
| 132 | |
hyatt@apple.com | c92f8c2 | 2008-10-10 20:12:14 +0000 | [diff] [blame] | 133 | IntRect track = trackRect(scrollbar); |
| 134 | if (track.contains(mousePosition)) { |
| 135 | IntRect beforeThumbRect; |
| 136 | IntRect thumbRect; |
| 137 | IntRect afterThumbRect; |
| 138 | splitTrack(scrollbar, track, beforeThumbRect, thumbRect, afterThumbRect); |
hyatt@apple.com | 4c767e2 | 2008-10-11 06:04:02 +0000 | [diff] [blame] | 139 | if (thumbRect.contains(mousePosition)) |
hyatt@apple.com | c92f8c2 | 2008-10-10 20:12:14 +0000 | [diff] [blame] | 140 | result = ThumbPart; |
hyatt@apple.com | 4c767e2 | 2008-10-11 06:04:02 +0000 | [diff] [blame] | 141 | else if (beforeThumbRect.contains(mousePosition)) |
| 142 | result = BackTrackPart; |
hyatt@apple.com | f245267 | 2008-10-11 07:50:03 +0000 | [diff] [blame] | 143 | else if (afterThumbRect.contains(mousePosition)) |
hyatt@apple.com | c92f8c2 | 2008-10-10 20:12:14 +0000 | [diff] [blame] | 144 | result = ForwardTrackPart; |
hyatt@apple.com | f245267 | 2008-10-11 07:50:03 +0000 | [diff] [blame] | 145 | else |
| 146 | result = TrackBGPart; |
hyatt@apple.com | c92f8c2 | 2008-10-10 20:12:14 +0000 | [diff] [blame] | 147 | } else if (backButtonRect(scrollbar, BackButtonStartPart).contains(mousePosition)) |
hyatt@apple.com | 57b2d52 | 2008-09-19 23:39:26 +0000 | [diff] [blame] | 148 | result = BackButtonStartPart; |
hyatt@apple.com | ea254e2 | 2008-09-20 00:42:36 +0000 | [diff] [blame] | 149 | else if (backButtonRect(scrollbar, BackButtonEndPart).contains(mousePosition)) |
| 150 | result = BackButtonEndPart; |
| 151 | else if (forwardButtonRect(scrollbar, ForwardButtonStartPart).contains(mousePosition)) |
| 152 | result = ForwardButtonStartPart; |
| 153 | else if (forwardButtonRect(scrollbar, ForwardButtonEndPart).contains(mousePosition)) |
hyatt@apple.com | 57b2d52 | 2008-09-19 23:39:26 +0000 | [diff] [blame] | 154 | result = ForwardButtonEndPart; |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 155 | return result; |
| 156 | } |
| 157 | |
| 158 | void ScrollbarThemeComposite::invalidatePart(Scrollbar* scrollbar, ScrollbarPart part) |
| 159 | { |
| 160 | if (part == NoPart) |
| 161 | return; |
| 162 | |
| 163 | IntRect result; |
| 164 | switch (part) { |
hyatt@apple.com | 57b2d52 | 2008-09-19 23:39:26 +0000 | [diff] [blame] | 165 | case BackButtonStartPart: |
hyatt@apple.com | ea254e2 | 2008-09-20 00:42:36 +0000 | [diff] [blame] | 166 | result = backButtonRect(scrollbar, BackButtonStartPart, true); |
| 167 | break; |
hyatt@apple.com | 57b2d52 | 2008-09-19 23:39:26 +0000 | [diff] [blame] | 168 | case BackButtonEndPart: |
hyatt@apple.com | ea254e2 | 2008-09-20 00:42:36 +0000 | [diff] [blame] | 169 | result = backButtonRect(scrollbar, BackButtonEndPart, true); |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 170 | break; |
hyatt@apple.com | 57b2d52 | 2008-09-19 23:39:26 +0000 | [diff] [blame] | 171 | case ForwardButtonStartPart: |
hyatt@apple.com | ea254e2 | 2008-09-20 00:42:36 +0000 | [diff] [blame] | 172 | result = forwardButtonRect(scrollbar, ForwardButtonStartPart, true); |
| 173 | break; |
hyatt@apple.com | 57b2d52 | 2008-09-19 23:39:26 +0000 | [diff] [blame] | 174 | case ForwardButtonEndPart: |
hyatt@apple.com | ea254e2 | 2008-09-20 00:42:36 +0000 | [diff] [blame] | 175 | result = forwardButtonRect(scrollbar, ForwardButtonEndPart, true); |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 176 | break; |
hyatt@apple.com | 668b671 | 2008-10-12 04:26:47 +0000 | [diff] [blame] | 177 | case TrackBGPart: |
| 178 | result = trackRect(scrollbar, true); |
| 179 | break; |
| 180 | case ScrollbarBGPart: |
| 181 | result = scrollbar->frameRect(); |
| 182 | break; |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 183 | default: { |
| 184 | IntRect beforeThumbRect, thumbRect, afterThumbRect; |
| 185 | splitTrack(scrollbar, trackRect(scrollbar), beforeThumbRect, thumbRect, afterThumbRect); |
| 186 | if (part == BackTrackPart) |
| 187 | result = beforeThumbRect; |
| 188 | else if (part == ForwardTrackPart) |
| 189 | result = afterThumbRect; |
| 190 | else |
| 191 | result = thumbRect; |
| 192 | } |
| 193 | } |
leviw@chromium.org | 35e0131 | 2011-06-03 02:41:09 +0000 | [diff] [blame] | 194 | result.moveBy(-scrollbar->location()); |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 195 | scrollbar->invalidateRect(result); |
| 196 | } |
| 197 | |
hyatt@apple.com | 0578b13 | 2008-10-12 04:20:26 +0000 | [diff] [blame] | 198 | void ScrollbarThemeComposite::splitTrack(Scrollbar* scrollbar, const IntRect& unconstrainedTrackRect, IntRect& beforeThumbRect, IntRect& thumbRect, IntRect& afterThumbRect) |
hyatt@apple.com | 8e80993 | 2008-09-16 02:29:09 +0000 | [diff] [blame] | 199 | { |
| 200 | // This function won't even get called unless we're big enough to have some combination of these three rects where at least |
| 201 | // one of them is non-empty. |
hyatt@apple.com | 0578b13 | 2008-10-12 04:20:26 +0000 | [diff] [blame] | 202 | IntRect trackRect = constrainTrackRectToTrackPieces(scrollbar, unconstrainedTrackRect); |
hyatt@apple.com | 2e4835d | 2008-10-10 02:33:16 +0000 | [diff] [blame] | 203 | int thickness = scrollbar->orientation() == HorizontalScrollbar ? scrollbar->height() : scrollbar->width(); |
hyatt@apple.com | 8e80993 | 2008-09-16 02:29:09 +0000 | [diff] [blame] | 204 | int thumbPos = thumbPosition(scrollbar); |
hyatt@apple.com | 0578b13 | 2008-10-12 04:20:26 +0000 | [diff] [blame] | 205 | if (scrollbar->orientation() == HorizontalScrollbar) { |
| 206 | thumbRect = IntRect(trackRect.x() + thumbPos, trackRect.y() + (trackRect.height() - thickness) / 2, thumbLength(scrollbar), thickness); |
| 207 | beforeThumbRect = IntRect(trackRect.x(), trackRect.y(), thumbPos + thumbRect.width() / 2, trackRect.height()); |
hyatt@apple.com | aa0cba0 | 2011-02-01 21:39:47 +0000 | [diff] [blame] | 208 | afterThumbRect = IntRect(trackRect.x() + beforeThumbRect.width(), trackRect.y(), trackRect.maxX() - beforeThumbRect.maxX(), trackRect.height()); |
hyatt@apple.com | 8e80993 | 2008-09-16 02:29:09 +0000 | [diff] [blame] | 209 | } else { |
hyatt@apple.com | 0578b13 | 2008-10-12 04:20:26 +0000 | [diff] [blame] | 210 | thumbRect = IntRect(trackRect.x() + (trackRect.width() - thickness) / 2, trackRect.y() + thumbPos, thickness, thumbLength(scrollbar)); |
| 211 | beforeThumbRect = IntRect(trackRect.x(), trackRect.y(), trackRect.width(), thumbPos + thumbRect.height() / 2); |
hyatt@apple.com | aa0cba0 | 2011-02-01 21:39:47 +0000 | [diff] [blame] | 212 | afterThumbRect = IntRect(trackRect.x(), trackRect.y() + beforeThumbRect.height(), trackRect.width(), trackRect.maxY() - beforeThumbRect.maxY()); |
hyatt@apple.com | 8e80993 | 2008-09-16 02:29:09 +0000 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | |
weinig@apple.com | fe3ba1a | 2011-01-27 21:23:06 +0000 | [diff] [blame] | 216 | // Returns the size represented by track taking into account scrolling past |
| 217 | // the end of the document. |
| 218 | static float usedTotalSize(Scrollbar* scrollbar) |
| 219 | { |
| 220 | float overhangAtStart = -scrollbar->currentPos(); |
| 221 | float overhangAtEnd = scrollbar->currentPos() + scrollbar->visibleSize() - scrollbar->totalSize(); |
| 222 | float overhang = max(0.0f, max(overhangAtStart, overhangAtEnd)); |
| 223 | return scrollbar->totalSize() + overhang; |
| 224 | } |
| 225 | |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 226 | int ScrollbarThemeComposite::thumbPosition(Scrollbar* scrollbar) |
| 227 | { |
commit-queue@webkit.org | 0e0315b | 2011-07-22 03:00:52 +0000 | [diff] [blame] | 228 | if (scrollbar->enabled()) { |
| 229 | float pos = max(0.0f, scrollbar->currentPos()) * (trackLength(scrollbar) - thumbLength(scrollbar)) / (usedTotalSize(scrollbar) - scrollbar->visibleSize()); |
| 230 | return (pos < 1 && pos > 0) ? 1 : pos; |
| 231 | } |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | int ScrollbarThemeComposite::thumbLength(Scrollbar* scrollbar) |
| 236 | { |
hyatt@apple.com | d1a0124 | 2008-09-18 01:32:42 +0000 | [diff] [blame] | 237 | if (!scrollbar->enabled()) |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 238 | return 0; |
| 239 | |
weinig@apple.com | fe3ba1a | 2011-01-27 21:23:06 +0000 | [diff] [blame] | 240 | float proportion = scrollbar->visibleSize() / usedTotalSize(scrollbar); |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 241 | int trackLen = trackLength(scrollbar); |
| 242 | int length = proportion * trackLen; |
hyatt@apple.com | 8e80993 | 2008-09-16 02:29:09 +0000 | [diff] [blame] | 243 | length = max(length, minimumThumbLength(scrollbar)); |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 244 | if (length > trackLen) |
| 245 | length = 0; // Once the thumb is below the track length, it just goes away (to make more room for the track). |
| 246 | return length; |
| 247 | } |
| 248 | |
hyatt@apple.com | 8e80993 | 2008-09-16 02:29:09 +0000 | [diff] [blame] | 249 | int ScrollbarThemeComposite::minimumThumbLength(Scrollbar* scrollbar) |
| 250 | { |
| 251 | return scrollbarThickness(scrollbar->controlSize()); |
| 252 | } |
| 253 | |
hyatt@apple.com | 1cd4bcc | 2008-09-16 06:53:34 +0000 | [diff] [blame] | 254 | int ScrollbarThemeComposite::trackPosition(Scrollbar* scrollbar) |
| 255 | { |
hyatt@apple.com | 0578b13 | 2008-10-12 04:20:26 +0000 | [diff] [blame] | 256 | IntRect constrainedTrackRect = constrainTrackRectToTrackPieces(scrollbar, trackRect(scrollbar)); |
| 257 | return (scrollbar->orientation() == HorizontalScrollbar) ? constrainedTrackRect.x() - scrollbar->x() : constrainedTrackRect.y() - scrollbar->y(); |
hyatt@apple.com | 1cd4bcc | 2008-09-16 06:53:34 +0000 | [diff] [blame] | 258 | } |
| 259 | |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 260 | int ScrollbarThemeComposite::trackLength(Scrollbar* scrollbar) |
| 261 | { |
hyatt@apple.com | 0578b13 | 2008-10-12 04:20:26 +0000 | [diff] [blame] | 262 | IntRect constrainedTrackRect = constrainTrackRectToTrackPieces(scrollbar, trackRect(scrollbar)); |
| 263 | return (scrollbar->orientation() == HorizontalScrollbar) ? constrainedTrackRect.width() : constrainedTrackRect.height(); |
hyatt@apple.com | 63739ce | 2008-09-15 23:44:10 +0000 | [diff] [blame] | 264 | } |
| 265 | |
andersca@apple.com | aabadfa | 2011-10-03 22:31:24 +0000 | [diff] [blame] | 266 | void ScrollbarThemeComposite::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect) |
hyatt@apple.com | 3b82dce | 2008-10-01 17:51:02 +0000 | [diff] [blame] | 267 | { |
krit@webkit.org | 2f1d535 | 2010-10-20 13:09:50 +0000 | [diff] [blame] | 268 | context->fillRect(cornerRect, Color::white, ColorSpaceDeviceRGB); |
hyatt@apple.com | 3b82dce | 2008-10-01 17:51:02 +0000 | [diff] [blame] | 269 | } |
| 270 | |
commit-queue@webkit.org | f6a1fd2 | 2011-08-16 18:45:35 +0000 | [diff] [blame] | 271 | void ScrollbarThemeComposite::paintOverhangAreas(ScrollView*, GraphicsContext* context, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect& dirtyRect) |
| 272 | { |
| 273 | context->setFillColor(Color::white, ColorSpaceDeviceRGB); |
| 274 | if (!horizontalOverhangRect.isEmpty()) |
| 275 | context->fillRect(intersection(horizontalOverhangRect, dirtyRect)); |
| 276 | |
| 277 | context->setFillColor(Color::white, ColorSpaceDeviceRGB); |
| 278 | if (!verticalOverhangRect.isEmpty()) |
| 279 | context->fillRect(intersection(verticalOverhangRect, dirtyRect)); |
| 280 | } |
| 281 | |
hyatt@apple.com | f18feec | 2008-09-15 00:56:11 +0000 | [diff] [blame] | 282 | } |