OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/scroll/ScrollbarThemeAura.h" | 31 #include "platform/scroll/ScrollbarThemeAura.h" |
32 | 32 |
33 #include "platform/LayoutTestSupport.h" | 33 #include "platform/LayoutTestSupport.h" |
34 #include "platform/PlatformMouseEvent.h" | 34 #include "platform/PlatformMouseEvent.h" |
35 #include "platform/RuntimeEnabledFeatures.h" | 35 #include "platform/RuntimeEnabledFeatures.h" |
36 #include "platform/graphics/GraphicsContext.h" | 36 #include "platform/graphics/GraphicsContext.h" |
37 #include "platform/graphics/GraphicsContextStateSaver.h" | |
38 #include "platform/graphics/paint/DrawingRecorder.h" | 37 #include "platform/graphics/paint/DrawingRecorder.h" |
39 #include "platform/scroll/ScrollableArea.h" | 38 #include "platform/scroll/ScrollableArea.h" |
40 #include "platform/scroll/Scrollbar.h" | 39 #include "platform/scroll/Scrollbar.h" |
41 #include "platform/scroll/ScrollbarThemeOverlay.h" | 40 #include "platform/scroll/ScrollbarThemeOverlay.h" |
42 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
43 #include "public/platform/WebRect.h" | 42 #include "public/platform/WebRect.h" |
44 #include "public/platform/WebThemeEngine.h" | 43 #include "public/platform/WebThemeEngine.h" |
45 | 44 |
46 namespace blink { | 45 namespace blink { |
47 | 46 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 IntSize size = Platform::current()->themeEngine()->getSize( | 217 IntSize size = Platform::current()->themeEngine()->getSize( |
219 WebThemeEngine::PartScrollbarVerticalThumb); | 218 WebThemeEngine::PartScrollbarVerticalThumb); |
220 return size.height(); | 219 return size.height(); |
221 } | 220 } |
222 | 221 |
223 IntSize size = Platform::current()->themeEngine()->getSize( | 222 IntSize size = Platform::current()->themeEngine()->getSize( |
224 WebThemeEngine::PartScrollbarHorizontalThumb); | 223 WebThemeEngine::PartScrollbarHorizontalThumb); |
225 return size.width(); | 224 return size.width(); |
226 } | 225 } |
227 | 226 |
228 void ScrollbarThemeAura::paintTickmarks(GraphicsContext& context, | |
229 const Scrollbar& scrollbar, | |
230 const IntRect& rect) { | |
231 if (scrollbar.orientation() != VerticalScrollbar) | |
232 return; | |
233 | |
234 if (rect.height() <= 0 || rect.width() <= 0) | |
235 return; | |
236 | |
237 // Get the tickmarks for the frameview. | |
238 Vector<IntRect> tickmarks; | |
239 scrollbar.getTickmarks(tickmarks); | |
240 if (!tickmarks.size()) | |
241 return; | |
242 | |
243 if (DrawingRecorder::useCachedDrawingIfPossible( | |
244 context, scrollbar, DisplayItem::kScrollbarTickmarks)) | |
245 return; | |
246 | |
247 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarTickmarks, | |
248 rect); | |
249 GraphicsContextStateSaver stateSaver(context); | |
250 context.setShouldAntialias(false); | |
251 | |
252 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); | |
253 i != tickmarks.end(); ++i) { | |
254 // Calculate how far down (in %) the tick-mark should appear. | |
255 const float percent = static_cast<float>(i->y()) / scrollbar.totalSize(); | |
256 | |
257 // Calculate how far down (in pixels) the tick-mark should appear. | |
258 const int yPos = rect.y() + (rect.height() * percent); | |
259 | |
260 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); | |
261 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); | |
262 | |
263 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); | |
264 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); | |
265 } | |
266 } | |
267 | |
268 void ScrollbarThemeAura::paintTrackBackground(GraphicsContext& context, | 227 void ScrollbarThemeAura::paintTrackBackground(GraphicsContext& context, |
269 const Scrollbar& scrollbar, | 228 const Scrollbar& scrollbar, |
270 const IntRect& rect) { | 229 const IntRect& rect) { |
271 // Just assume a forward track part. We only paint the track as a single piece | 230 // Just assume a forward track part. We only paint the track as a single piece |
272 // when there is no thumb. | 231 // when there is no thumb. |
273 if (!hasThumb(scrollbar) && !rect.isEmpty()) | 232 if (!hasThumb(scrollbar) && !rect.isEmpty()) |
274 paintTrackPiece(context, scrollbar, rect, ForwardTrackPart); | 233 paintTrackPiece(context, scrollbar, rect, ForwardTrackPart); |
275 } | 234 } |
276 | 235 |
277 void ScrollbarThemeAura::paintTrackPiece(GraphicsContext& gc, | 236 void ScrollbarThemeAura::paintTrackPiece(GraphicsContext& gc, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 351 } |
393 | 352 |
394 // HorizontalScrollbar | 353 // HorizontalScrollbar |
395 int squareSize = scrollbar.height(); | 354 int squareSize = scrollbar.height(); |
396 return IntSize( | 355 return IntSize( |
397 scrollbar.width() < 2 * squareSize ? scrollbar.width() / 2 : squareSize, | 356 scrollbar.width() < 2 * squareSize ? scrollbar.width() / 2 : squareSize, |
398 squareSize); | 357 squareSize); |
399 } | 358 } |
400 | 359 |
401 } // namespace blink | 360 } // namespace blink |
OLD | NEW |