| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2008, 2009 Google Inc. | 3 * Copyright (C) 2008, 2009 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "platform/scroll/ScrollbarThemeNonMacCommon.h" | 27 #include "platform/scroll/ScrollbarThemeNonMacCommon.h" |
| 28 | 28 |
| 29 #include "platform/PlatformMouseEvent.h" | 29 #include "platform/PlatformMouseEvent.h" |
| 30 #include "platform/graphics/GraphicsContextStateSaver.h" | 30 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 31 #include "platform/graphics/paint/DrawingRecorder.h" | 31 #include "platform/graphics/paint/DrawingRecorder.h" |
| 32 #include "platform/scroll/ScrollableArea.h" | 32 #include "platform/scroll/ScrollableArea.h" |
| 33 #include "platform/scroll/ScrollbarThemeClient.h" | |
| 34 | 33 |
| 35 namespace blink { | 34 namespace blink { |
| 36 | 35 |
| 37 bool ScrollbarThemeNonMacCommon::hasThumb(const ScrollbarThemeClient& scrollbar) | 36 bool ScrollbarThemeNonMacCommon::hasThumb(const ScrollbarThemeClient& scrollbar) |
| 38 { | 37 { |
| 39 // This method is just called as a paint-time optimization to see if | 38 // This method is just called as a paint-time optimization to see if |
| 40 // painting the thumb can be skipped. We don't have to be exact here. | 39 // painting the thumb can be skipped. We don't have to be exact here. |
| 41 return thumbLength(scrollbar) > 0; | 40 return thumbLength(scrollbar) > 0; |
| 42 } | 41 } |
| 43 | 42 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 66 x = scrollbar.x(); | 65 x = scrollbar.x(); |
| 67 y = scrollbar.y() + scrollbar.height() - size.height(); | 66 y = scrollbar.y() + scrollbar.height() - size.height(); |
| 68 } | 67 } |
| 69 return IntRect(x, y, size.width(), size.height()); | 68 return IntRect(x, y, size.width(), size.height()); |
| 70 } | 69 } |
| 71 | 70 |
| 72 IntRect ScrollbarThemeNonMacCommon::trackRect(const ScrollbarThemeClient& scroll
bar, bool) | 71 IntRect ScrollbarThemeNonMacCommon::trackRect(const ScrollbarThemeClient& scroll
bar, bool) |
| 73 { | 72 { |
| 74 // The track occupies all space between the two buttons. | 73 // The track occupies all space between the two buttons. |
| 75 IntSize bs = buttonSize(scrollbar); | 74 IntSize bs = buttonSize(scrollbar); |
| 76 int thickness = scrollbarThickness(scrollbar.controlSize()); | |
| 77 if (scrollbar.orientation() == HorizontalScrollbar) { | 75 if (scrollbar.orientation() == HorizontalScrollbar) { |
| 78 if (scrollbar.width() <= 2 * bs.width()) | 76 if (scrollbar.width() <= 2 * bs.width()) |
| 79 return IntRect(); | 77 return IntRect(); |
| 80 return IntRect(scrollbar.x() + bs.width(), scrollbar.y(), scrollbar.widt
h() - 2 * bs.width(), thickness); | 78 return IntRect(scrollbar.x() + bs.width(), scrollbar.y(), scrollbar.widt
h() - 2 * bs.width(), scrollbar.height()); |
| 81 } | 79 } |
| 82 if (scrollbar.height() <= 2 * bs.height()) | 80 if (scrollbar.height() <= 2 * bs.height()) |
| 83 return IntRect(); | 81 return IntRect(); |
| 84 return IntRect(scrollbar.x(), scrollbar.y() + bs.height(), thickness, scroll
bar.height() - 2 * bs.height()); | 82 return IntRect(scrollbar.x(), scrollbar.y() + bs.height(), scrollbar.width()
, scrollbar.height() - 2 * bs.height()); |
| 85 } | 83 } |
| 86 | 84 |
| 87 void ScrollbarThemeNonMacCommon::paintTrackBackground(GraphicsContext& context,
const ScrollbarThemeClient& scrollbar, const IntRect& rect) | 85 void ScrollbarThemeNonMacCommon::paintTrackBackground(GraphicsContext& context,
const ScrollbarThemeClient& scrollbar, const IntRect& rect) |
| 88 { | 86 { |
| 89 // Just assume a forward track part. We only paint the track as a single pie
ce when there is no thumb. | 87 // Just assume a forward track part. We only paint the track as a single pie
ce when there is no thumb. |
| 90 if (!hasThumb(scrollbar)) | 88 if (!hasThumb(scrollbar)) |
| 91 paintTrackPiece(context, scrollbar, rect, ForwardTrackPart); | 89 paintTrackPiece(context, scrollbar, rect, ForwardTrackPart); |
| 92 } | 90 } |
| 93 | 91 |
| 94 void ScrollbarThemeNonMacCommon::paintTickmarks(GraphicsContext& context, const
ScrollbarThemeClient& scrollbar, const IntRect& rect) | 92 void ScrollbarThemeNonMacCommon::paintTickmarks(GraphicsContext& context, const
ScrollbarThemeClient& scrollbar, const IntRect& rect) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 121 | 119 |
| 122 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); | 120 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); |
| 123 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); | 121 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); |
| 124 | 122 |
| 125 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); | 123 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); |
| 126 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); | 124 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); |
| 127 } | 125 } |
| 128 } | 126 } |
| 129 | 127 |
| 130 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |