| 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" |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 36 bool ScrollbarThemeNonMacCommon::hasThumb(const ScrollbarThemeClient& scrollbar) | 37 bool ScrollbarThemeNonMacCommon::hasThumb(const ScrollbarThemeClient& scrollbar) |
| 37 { | 38 { |
| 38 // This method is just called as a paint-time optimization to see if | 39 // This method is just called as a paint-time optimization to see if |
| 39 // painting the thumb can be skipped. We don't have to be exact here. | 40 // painting the thumb can be skipped. We don't have to be exact here. |
| 40 return thumbLength(scrollbar) > 0; | 41 return thumbLength(scrollbar) > 0; |
| 41 } | 42 } |
| 42 | 43 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 65 x = scrollbar.x(); | 66 x = scrollbar.x(); |
| 66 y = scrollbar.y() + scrollbar.height() - size.height(); | 67 y = scrollbar.y() + scrollbar.height() - size.height(); |
| 67 } | 68 } |
| 68 return IntRect(x, y, size.width(), size.height()); | 69 return IntRect(x, y, size.width(), size.height()); |
| 69 } | 70 } |
| 70 | 71 |
| 71 IntRect ScrollbarThemeNonMacCommon::trackRect(const ScrollbarThemeClient& scroll
bar, bool) | 72 IntRect ScrollbarThemeNonMacCommon::trackRect(const ScrollbarThemeClient& scroll
bar, bool) |
| 72 { | 73 { |
| 73 // The track occupies all space between the two buttons. | 74 // The track occupies all space between the two buttons. |
| 74 IntSize bs = buttonSize(scrollbar); | 75 IntSize bs = buttonSize(scrollbar); |
| 76 int thickness = scrollbarThickness(scrollbar.controlSize()); |
| 75 if (scrollbar.orientation() == HorizontalScrollbar) { | 77 if (scrollbar.orientation() == HorizontalScrollbar) { |
| 76 if (scrollbar.width() <= 2 * bs.width()) | 78 if (scrollbar.width() <= 2 * bs.width()) |
| 77 return IntRect(); | 79 return IntRect(); |
| 78 return IntRect(scrollbar.x() + bs.width(), scrollbar.y(), scrollbar.widt
h() - 2 * bs.width(), scrollbar.height()); | 80 return IntRect(scrollbar.x() + bs.width(), scrollbar.y(), scrollbar.widt
h() - 2 * bs.width(), thickness); |
| 79 } | 81 } |
| 80 if (scrollbar.height() <= 2 * bs.height()) | 82 if (scrollbar.height() <= 2 * bs.height()) |
| 81 return IntRect(); | 83 return IntRect(); |
| 82 return IntRect(scrollbar.x(), scrollbar.y() + bs.height(), scrollbar.width()
, scrollbar.height() - 2 * bs.height()); | 84 return IntRect(scrollbar.x(), scrollbar.y() + bs.height(), thickness, scroll
bar.height() - 2 * bs.height()); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void ScrollbarThemeNonMacCommon::paintTrackBackground(GraphicsContext& context,
const ScrollbarThemeClient& scrollbar, const IntRect& rect) | 87 void ScrollbarThemeNonMacCommon::paintTrackBackground(GraphicsContext& context,
const ScrollbarThemeClient& scrollbar, const IntRect& rect) |
| 86 { | 88 { |
| 87 // Just assume a forward track part. We only paint the track as a single pie
ce when there is no thumb. | 89 // Just assume a forward track part. We only paint the track as a single pie
ce when there is no thumb. |
| 88 if (!hasThumb(scrollbar)) | 90 if (!hasThumb(scrollbar)) |
| 89 paintTrackPiece(context, scrollbar, rect, ForwardTrackPart); | 91 paintTrackPiece(context, scrollbar, rect, ForwardTrackPart); |
| 90 } | 92 } |
| 91 | 93 |
| 92 void ScrollbarThemeNonMacCommon::paintTickmarks(GraphicsContext& context, const
ScrollbarThemeClient& scrollbar, const IntRect& rect) | 94 void ScrollbarThemeNonMacCommon::paintTickmarks(GraphicsContext& context, const
ScrollbarThemeClient& scrollbar, const IntRect& rect) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 119 | 121 |
| 120 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); | 122 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); |
| 121 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); | 123 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); |
| 122 | 124 |
| 123 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); | 125 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); |
| 124 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); | 126 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 | 129 |
| 128 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |