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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 if (rect.height() <= 0 || rect.width() <= 0) | 101 if (rect.height() <= 0 || rect.width() <= 0) |
102 return; | 102 return; |
103 | 103 |
104 // Get the tickmarks for the frameview. | 104 // Get the tickmarks for the frameview. |
105 Vector<IntRect> tickmarks; | 105 Vector<IntRect> tickmarks; |
106 scrollbar->getTickmarks(tickmarks); | 106 scrollbar->getTickmarks(tickmarks); |
107 if (!tickmarks.size()) | 107 if (!tickmarks.size()) |
108 return; | 108 return; |
109 | 109 |
110 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTickmar
ks, rect); | 110 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarTickmarks)) |
111 if (recorder.canUseCachedDrawing()) | |
112 return; | 111 return; |
113 | 112 |
| 113 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTickmar
ks, rect); |
114 GraphicsContextStateSaver stateSaver(*context); | 114 GraphicsContextStateSaver stateSaver(*context); |
115 context->setShouldAntialias(false); | 115 context->setShouldAntialias(false); |
116 | 116 |
117 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); i != tickmarks.e
nd(); ++i) { | 117 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); i != tickmarks.e
nd(); ++i) { |
118 // Calculate how far down (in %) the tick-mark should appear. | 118 // Calculate how far down (in %) the tick-mark should appear. |
119 const float percent = static_cast<float>(i->y()) / scrollbar->totalSize(
); | 119 const float percent = static_cast<float>(i->y()) / scrollbar->totalSize(
); |
120 | 120 |
121 // Calculate how far down (in pixels) the tick-mark should appear. | 121 // Calculate how far down (in pixels) the tick-mark should appear. |
122 const int yPos = rect.y() + (rect.height() * percent); | 122 const int yPos = rect.y() + (rect.height() * percent); |
123 | 123 |
124 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); | 124 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); |
125 context->fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); | 125 context->fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); |
126 | 126 |
127 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); | 127 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); |
128 context->fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); | 128 context->fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 } // namespace blink | 132 } // namespace blink |
OLD | NEW |