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 19 matching lines...) Expand all Loading... |
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" | 37 #include "platform/graphics/GraphicsContextStateSaver.h" |
38 #include "platform/graphics/paint/DrawingRecorder.h" | 38 #include "platform/graphics/paint/DrawingRecorder.h" |
39 #include "platform/scroll/ScrollableArea.h" | 39 #include "platform/scroll/ScrollableArea.h" |
40 #include "platform/scroll/ScrollbarThemeClient.h" | 40 #include "platform/scroll/Scrollbar.h" |
41 #include "platform/scroll/ScrollbarThemeOverlay.h" | 41 #include "platform/scroll/ScrollbarThemeOverlay.h" |
42 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
43 #include "public/platform/WebRect.h" | 43 #include "public/platform/WebRect.h" |
44 #include "public/platform/WebThemeEngine.h" | 44 #include "public/platform/WebThemeEngine.h" |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
50 static bool useMockTheme() | 50 static bool useMockTheme() |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 { | 202 { |
203 if (scrollbar.orientation() == VerticalScrollbar) { | 203 if (scrollbar.orientation() == VerticalScrollbar) { |
204 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngin
e::PartScrollbarVerticalThumb); | 204 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngin
e::PartScrollbarVerticalThumb); |
205 return size.height(); | 205 return size.height(); |
206 } | 206 } |
207 | 207 |
208 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P
artScrollbarHorizontalThumb); | 208 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P
artScrollbarHorizontalThumb); |
209 return size.width(); | 209 return size.width(); |
210 } | 210 } |
211 | 211 |
212 void ScrollbarThemeAura::paintTickmarks(GraphicsContext& context, const Scrollba
rThemeClient& scrollbar, const IntRect& rect) | 212 void ScrollbarThemeAura::paintTickmarks(GraphicsContext& context, const Scrollba
r& scrollbar, const IntRect& rect) |
213 { | 213 { |
214 if (scrollbar.orientation() != VerticalScrollbar) | 214 if (scrollbar.orientation() != VerticalScrollbar) |
215 return; | 215 return; |
216 | 216 |
217 if (rect.height() <= 0 || rect.width() <= 0) | 217 if (rect.height() <= 0 || rect.width() <= 0) |
218 return; | 218 return; |
219 | 219 |
220 // Get the tickmarks for the frameview. | 220 // Get the tickmarks for the frameview. |
221 Vector<IntRect> tickmarks; | 221 Vector<IntRect> tickmarks; |
222 scrollbar.getTickmarks(tickmarks); | 222 scrollbar.getTickmarks(tickmarks); |
(...skipping 15 matching lines...) Expand all Loading... |
238 const int yPos = rect.y() + (rect.height() * percent); | 238 const int yPos = rect.y() + (rect.height() * percent); |
239 | 239 |
240 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); | 240 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); |
241 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); | 241 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); |
242 | 242 |
243 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); | 243 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); |
244 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); | 244 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 void ScrollbarThemeAura::paintTrackBackground(GraphicsContext& context, const Sc
rollbarThemeClient& scrollbar, const IntRect& rect) | 248 void ScrollbarThemeAura::paintTrackBackground(GraphicsContext& context, const Sc
rollbar& scrollbar, const IntRect& rect) |
249 { | 249 { |
250 // Just assume a forward track part. We only paint the track as a single pie
ce when there is no thumb. | 250 // Just assume a forward track part. We only paint the track as a single pie
ce when there is no thumb. |
251 if (!hasThumb(scrollbar) && !rect.isEmpty()) | 251 if (!hasThumb(scrollbar) && !rect.isEmpty()) |
252 paintTrackPiece(context, scrollbar, rect, ForwardTrackPart); | 252 paintTrackPiece(context, scrollbar, rect, ForwardTrackPart); |
253 } | 253 } |
254 | 254 |
255 void ScrollbarThemeAura::paintTrackPiece(GraphicsContext& gc, const ScrollbarThe
meClient& scrollbar, const IntRect& rect, ScrollbarPart partType) | 255 void ScrollbarThemeAura::paintTrackPiece(GraphicsContext& gc, const Scrollbar& s
crollbar, const IntRect& rect, ScrollbarPart partType) |
256 { | 256 { |
257 DisplayItem::Type displayItemType = trackPiecePartToDisplayItemType(partType
); | 257 DisplayItem::Type displayItemType = trackPiecePartToDisplayItemType(partType
); |
258 if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, displayItemTy
pe)) | 258 if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, displayItemTy
pe)) |
259 return; | 259 return; |
260 | 260 |
261 DrawingRecorder recorder(gc, scrollbar, displayItemType, rect); | 261 DrawingRecorder recorder(gc, scrollbar, displayItemType, rect); |
262 | 262 |
263 WebThemeEngine::State state = scrollbar.hoveredPart() == partType ? WebTheme
Engine::StateHover : WebThemeEngine::StateNormal; | 263 WebThemeEngine::State state = scrollbar.hoveredPart() == partType ? WebTheme
Engine::StateHover : WebThemeEngine::StateNormal; |
264 | 264 |
265 if (useMockTheme() && !scrollbar.enabled()) | 265 if (useMockTheme() && !scrollbar.enabled()) |
266 state = WebThemeEngine::StateDisabled; | 266 state = WebThemeEngine::StateDisabled; |
267 | 267 |
268 IntRect alignRect = trackRect(scrollbar, false); | 268 IntRect alignRect = trackRect(scrollbar, false); |
269 WebThemeEngine::ExtraParams extraParams; | 269 WebThemeEngine::ExtraParams extraParams; |
270 extraParams.scrollbarTrack.isBack = (partType == BackTrackPart); | 270 extraParams.scrollbarTrack.isBack = (partType == BackTrackPart); |
271 extraParams.scrollbarTrack.trackX = alignRect.x(); | 271 extraParams.scrollbarTrack.trackX = alignRect.x(); |
272 extraParams.scrollbarTrack.trackY = alignRect.y(); | 272 extraParams.scrollbarTrack.trackY = alignRect.y(); |
273 extraParams.scrollbarTrack.trackWidth = alignRect.width(); | 273 extraParams.scrollbarTrack.trackWidth = alignRect.width(); |
274 extraParams.scrollbarTrack.trackHeight = alignRect.height(); | 274 extraParams.scrollbarTrack.trackHeight = alignRect.height(); |
275 Platform::current()->themeEngine()->paint(gc.canvas(), scrollbar.orientation
() == HorizontalScrollbar ? WebThemeEngine::PartScrollbarHorizontalTrack : WebTh
emeEngine::PartScrollbarVerticalTrack, state, WebRect(rect), &extraParams); | 275 Platform::current()->themeEngine()->paint(gc.canvas(), scrollbar.orientation
() == HorizontalScrollbar ? WebThemeEngine::PartScrollbarHorizontalTrack : WebTh
emeEngine::PartScrollbarVerticalTrack, state, WebRect(rect), &extraParams); |
276 } | 276 } |
277 | 277 |
278 void ScrollbarThemeAura::paintButton(GraphicsContext& gc, const ScrollbarThemeCl
ient& scrollbar, const IntRect& rect, ScrollbarPart part) | 278 void ScrollbarThemeAura::paintButton(GraphicsContext& gc, const Scrollbar& scrol
lbar, const IntRect& rect, ScrollbarPart part) |
279 { | 279 { |
280 DisplayItem::Type displayItemType = buttonPartToDisplayItemType(part); | 280 DisplayItem::Type displayItemType = buttonPartToDisplayItemType(part); |
281 if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, displayItemTy
pe)) | 281 if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, displayItemTy
pe)) |
282 return; | 282 return; |
283 PartPaintingParams params = buttonPartPaintingParams(scrollbar, scrollbar.cu
rrentPos(), part); | 283 PartPaintingParams params = buttonPartPaintingParams(scrollbar, scrollbar.cu
rrentPos(), part); |
284 if (!params.shouldPaint) | 284 if (!params.shouldPaint) |
285 return; | 285 return; |
286 DrawingRecorder recorder(gc, scrollbar, displayItemType, rect); | 286 DrawingRecorder recorder(gc, scrollbar, displayItemType, rect); |
287 Platform::current()->themeEngine()->paint(gc.canvas(), params.part, params.s
tate, WebRect(rect), 0); | 287 Platform::current()->themeEngine()->paint(gc.canvas(), params.part, params.s
tate, WebRect(rect), 0); |
288 } | 288 } |
289 | 289 |
290 void ScrollbarThemeAura::paintThumb(GraphicsContext& gc, const ScrollbarThemeCli
ent& scrollbar, const IntRect& rect) | 290 void ScrollbarThemeAura::paintThumb(GraphicsContext& gc, const Scrollbar& scroll
bar, const IntRect& rect) |
291 { | 291 { |
292 if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, DisplayItem::
ScrollbarThumb)) | 292 if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, DisplayItem::
ScrollbarThumb)) |
293 return; | 293 return; |
294 | 294 |
295 DrawingRecorder recorder(gc, scrollbar, DisplayItem::ScrollbarThumb, rect); | 295 DrawingRecorder recorder(gc, scrollbar, DisplayItem::ScrollbarThumb, rect); |
296 | 296 |
297 WebThemeEngine::State state; | 297 WebThemeEngine::State state; |
298 WebCanvas* canvas = gc.canvas(); | 298 WebCanvas* canvas = gc.canvas(); |
299 if (scrollbar.pressedPart() == ThumbPart) | 299 if (scrollbar.pressedPart() == ThumbPart) |
300 state = WebThemeEngine::StatePressed; | 300 state = WebThemeEngine::StatePressed; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 int squareSize = scrollbar.width(); | 341 int squareSize = scrollbar.width(); |
342 return IntSize(squareSize, scrollbar.height() < 2 * squareSize ? scrollb
ar.height() / 2 : squareSize); | 342 return IntSize(squareSize, scrollbar.height() < 2 * squareSize ? scrollb
ar.height() / 2 : squareSize); |
343 } | 343 } |
344 | 344 |
345 // HorizontalScrollbar | 345 // HorizontalScrollbar |
346 int squareSize = scrollbar.height(); | 346 int squareSize = scrollbar.height(); |
347 return IntSize(scrollbar.width() < 2 * squareSize ? scrollbar.width() / 2 :
squareSize, squareSize); | 347 return IntSize(scrollbar.width() < 2 * squareSize ? scrollbar.width() / 2 :
squareSize, squareSize); |
348 } | 348 } |
349 | 349 |
350 } // namespace blink | 350 } // namespace blink |
OLD | NEW |