| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2011 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 #if !OS(MACOSX) | 44 #if !OS(MACOSX) |
| 45 #include "public/platform/WebRect.h" | 45 #include "public/platform/WebRect.h" |
| 46 #include "public/platform/WebThemeEngine.h" | 46 #include "public/platform/WebThemeEngine.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 bool ScrollbarTheme::gMockScrollbarsEnabled = false; | 51 bool ScrollbarTheme::gMockScrollbarsEnabled = false; |
| 52 | 52 |
| 53 static inline bool shouldPaintScrollbarPart(const IntRect& partRect, const IntRe
ct& damageRect) |
| 54 { |
| 55 return (RuntimeEnabledFeatures::slimmingPaintEnabled() && !partRect.isEmpty(
)) || damageRect.intersects(partRect); |
| 56 } |
| 57 |
| 53 bool ScrollbarTheme::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* gra
phicsContext, const IntRect& damageRect) | 58 bool ScrollbarTheme::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* gra
phicsContext, const IntRect& damageRect) |
| 54 { | 59 { |
| 55 // Create the ScrollbarControlPartMask based on the damageRect | 60 // Create the ScrollbarControlPartMask based on the damageRect |
| 56 ScrollbarControlPartMask scrollMask = NoPart; | 61 ScrollbarControlPartMask scrollMask = NoPart; |
| 57 | 62 |
| 58 IntRect backButtonStartPaintRect; | 63 IntRect backButtonStartPaintRect; |
| 59 IntRect backButtonEndPaintRect; | 64 IntRect backButtonEndPaintRect; |
| 60 IntRect forwardButtonStartPaintRect; | 65 IntRect forwardButtonStartPaintRect; |
| 61 IntRect forwardButtonEndPaintRect; | 66 IntRect forwardButtonEndPaintRect; |
| 62 if (hasButtons(scrollbar)) { | 67 if (hasButtons(scrollbar)) { |
| 63 backButtonStartPaintRect = backButtonRect(scrollbar, BackButtonStartPart
, true); | 68 backButtonStartPaintRect = backButtonRect(scrollbar, BackButtonStartPart
, true); |
| 64 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.interse
cts(backButtonStartPaintRect)) | 69 if (shouldPaintScrollbarPart(backButtonStartPaintRect, damageRect)) |
| 65 scrollMask |= BackButtonStartPart; | 70 scrollMask |= BackButtonStartPart; |
| 66 backButtonEndPaintRect = backButtonRect(scrollbar, BackButtonEndPart, tr
ue); | 71 backButtonEndPaintRect = backButtonRect(scrollbar, BackButtonEndPart, tr
ue); |
| 67 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.interse
cts(backButtonEndPaintRect)) | 72 if (shouldPaintScrollbarPart(backButtonEndPaintRect, damageRect)) |
| 68 scrollMask |= BackButtonEndPart; | 73 scrollMask |= BackButtonEndPart; |
| 69 forwardButtonStartPaintRect = forwardButtonRect(scrollbar, ForwardButton
StartPart, true); | 74 forwardButtonStartPaintRect = forwardButtonRect(scrollbar, ForwardButton
StartPart, true); |
| 70 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.interse
cts(forwardButtonStartPaintRect)) | 75 if (shouldPaintScrollbarPart(forwardButtonStartPaintRect, damageRect)) |
| 71 scrollMask |= ForwardButtonStartPart; | 76 scrollMask |= ForwardButtonStartPart; |
| 72 forwardButtonEndPaintRect = forwardButtonRect(scrollbar, ForwardButtonEn
dPart, true); | 77 forwardButtonEndPaintRect = forwardButtonRect(scrollbar, ForwardButtonEn
dPart, true); |
| 73 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.interse
cts(forwardButtonEndPaintRect)) | 78 if (shouldPaintScrollbarPart(forwardButtonEndPaintRect, damageRect)) |
| 74 scrollMask |= ForwardButtonEndPart; | 79 scrollMask |= ForwardButtonEndPart; |
| 75 } | 80 } |
| 76 | 81 |
| 77 IntRect startTrackRect; | 82 IntRect startTrackRect; |
| 78 IntRect thumbRect; | 83 IntRect thumbRect; |
| 79 IntRect endTrackRect; | 84 IntRect endTrackRect; |
| 80 IntRect trackPaintRect = trackRect(scrollbar, true); | 85 IntRect trackPaintRect = trackRect(scrollbar, true); |
| 81 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.intersects(
trackPaintRect)) | 86 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.intersects(
trackPaintRect)) |
| 82 scrollMask |= TrackBGPart; | 87 scrollMask |= TrackBGPart; |
| 83 bool thumbPresent = hasThumb(scrollbar); | 88 bool thumbPresent = hasThumb(scrollbar); |
| 84 if (thumbPresent) { | 89 if (thumbPresent) { |
| 85 IntRect track = trackRect(scrollbar); | 90 IntRect track = trackRect(scrollbar); |
| 86 splitTrack(scrollbar, track, startTrackRect, thumbRect, endTrackRect); | 91 splitTrack(scrollbar, track, startTrackRect, thumbRect, endTrackRect); |
| 87 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.interse
cts(thumbRect)) | 92 if (shouldPaintScrollbarPart(thumbRect, damageRect)) |
| 88 scrollMask |= ThumbPart; | 93 scrollMask |= ThumbPart; |
| 89 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.interse
cts(startTrackRect)) | 94 if (shouldPaintScrollbarPart(startTrackRect, damageRect)) |
| 90 scrollMask |= BackTrackPart; | 95 scrollMask |= BackTrackPart; |
| 91 if (RuntimeEnabledFeatures::slimmingPaintEnabled() || damageRect.interse
cts(endTrackRect)) | 96 if (shouldPaintScrollbarPart(endTrackRect, damageRect)) |
| 92 scrollMask |= ForwardTrackPart; | 97 scrollMask |= ForwardTrackPart; |
| 93 } | 98 } |
| 94 | 99 |
| 95 // Paint the scrollbar background (only used by custom CSS scrollbars). | 100 // Paint the scrollbar background (only used by custom CSS scrollbars). |
| 96 paintScrollbarBackground(graphicsContext, scrollbar); | 101 paintScrollbarBackground(graphicsContext, scrollbar); |
| 97 | 102 |
| 98 // Paint the back and forward buttons. | 103 // Paint the back and forward buttons. |
| 99 if (scrollMask & BackButtonStartPart) | 104 if (scrollMask & BackButtonStartPart) |
| 100 paintButton(graphicsContext, scrollbar, backButtonStartPaintRect, BackBu
ttonStartPart); | 105 paintButton(graphicsContext, scrollbar, backButtonStartPaintRect, BackBu
ttonStartPart); |
| 101 if (scrollMask & BackButtonEndPart) | 106 if (scrollMask & BackButtonEndPart) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 return DisplayItem::ScrollbarBackTrack; | 372 return DisplayItem::ScrollbarBackTrack; |
| 368 case ForwardTrackPart: | 373 case ForwardTrackPart: |
| 369 return DisplayItem::ScrollbarForwardTrack; | 374 return DisplayItem::ScrollbarForwardTrack; |
| 370 default: | 375 default: |
| 371 ASSERT_NOT_REACHED(); | 376 ASSERT_NOT_REACHED(); |
| 372 return DisplayItem::ScrollbarBackTrack; | 377 return DisplayItem::ScrollbarBackTrack; |
| 373 } | 378 } |
| 374 } | 379 } |
| 375 | 380 |
| 376 } // namespace blink | 381 } // namespace blink |
| OLD | NEW |