Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: third_party/WebKit/Source/core/paint/ThemePainter.cpp

Issue 1512803004: Use refs for GraphicsContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ScrollbarTheme
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * This file is part of the theme implementation for form controls in WebCore. 2 * This file is part of the theme implementation for form controls in WebCore.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return paintUsingFallbackTheme(o, paintInfo, r); 69 return paintUsingFallbackTheme(o, paintInfo, r);
70 70
71 #if USE(NEW_THEME) 71 #if USE(NEW_THEME)
72 switch (part) { 72 switch (part) {
73 case CheckboxPart: 73 case CheckboxPart:
74 case RadioPart: 74 case RadioPart:
75 case PushButtonPart: 75 case PushButtonPart:
76 case SquareButtonPart: 76 case SquareButtonPart:
77 case ButtonPart: 77 case ButtonPart:
78 case InnerSpinButtonPart: 78 case InnerSpinButtonPart:
79 platformTheme()->paint(part, LayoutTheme::controlStatesForLayoutObject(o ), const_cast<GraphicsContext*>(paintInfo.context), r, o.styleRef().effectiveZoo m(), o.view()->frameView()); 79 platformTheme()->paint(part, LayoutTheme::controlStatesForLayoutObject(o ), const_cast<GraphicsContext&>(paintInfo.context), r, o.styleRef().effectiveZoo m(), o.view()->frameView());
80 return false; 80 return false;
81 default: 81 default:
82 break; 82 break;
83 } 83 }
84 #endif 84 #endif
85 85
86 // Call the appropriate paint method based off the appearance value. 86 // Call the appropriate paint method based off the appearance value.
87 switch (part) { 87 switch (part) {
88 #if !USE(NEW_THEME) 88 #if !USE(NEW_THEME)
89 case CheckboxPart: 89 case CheckboxPart:
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (!input->isValidValue(value)) 307 if (!input->isValidValue(value))
308 continue; 308 continue;
309 double parsedValue = parseToDoubleForNumberType(input->sanitizeValue(val ue)); 309 double parsedValue = parseToDoubleForNumberType(input->sanitizeValue(val ue));
310 double tickFraction = (parsedValue - min) / (max - min); 310 double tickFraction = (parsedValue - min) / (max - min);
311 double tickRatio = isHorizontal && o.styleRef().isLeftToRightDirection() ? tickFraction : 1.0 - tickFraction; 311 double tickRatio = isHorizontal && o.styleRef().isLeftToRightDirection() ? tickFraction : 1.0 - tickFraction;
312 double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tic kRatio); 312 double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tic kRatio);
313 if (isHorizontal) 313 if (isHorizontal)
314 tickRect.setX(tickPosition); 314 tickRect.setX(tickPosition);
315 else 315 else
316 tickRect.setY(tickPosition); 316 tickRect.setY(tickPosition);
317 paintInfo.context->fillRect(tickRect, o.resolveColor(CSSPropertyColor)); 317 paintInfo.context.fillRect(tickRect, o.resolveColor(CSSPropertyColor));
318 } 318 }
319 } 319 }
320 320
321 bool ThemePainter::paintUsingFallbackTheme(const LayoutObject& o, const PaintInf o& i, const IntRect&r) 321 bool ThemePainter::paintUsingFallbackTheme(const LayoutObject& o, const PaintInf o& i, const IntRect&r)
322 { 322 {
323 ControlPart part = o.styleRef().appearance(); 323 ControlPart part = o.styleRef().appearance();
324 switch (part) { 324 switch (part) {
325 case CheckboxPart: 325 case CheckboxPart:
326 return paintCheckboxUsingFallbackTheme(o, i, r); 326 return paintCheckboxUsingFallbackTheme(o, i, r);
327 case RadioPart: 327 case RadioPart:
328 return paintRadioUsingFallbackTheme(o, i, r); 328 return paintRadioUsingFallbackTheme(o, i, r);
329 default: 329 default:
330 break; 330 break;
331 } 331 }
332 return true; 332 return true;
333 } 333 }
334 334
335 bool ThemePainter::paintCheckboxUsingFallbackTheme(const LayoutObject& o, const PaintInfo& i, const IntRect&r) 335 bool ThemePainter::paintCheckboxUsingFallbackTheme(const LayoutObject& o, const PaintInfo& i, const IntRect&r)
336 { 336 {
337 WebFallbackThemeEngine::ExtraParams extraParams; 337 WebFallbackThemeEngine::ExtraParams extraParams;
338 WebCanvas* canvas = i.context->canvas(); 338 WebCanvas* canvas = i.context.canvas();
339 extraParams.button.checked = LayoutTheme::isChecked(o); 339 extraParams.button.checked = LayoutTheme::isChecked(o);
340 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o); 340 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o);
341 341
342 float zoomLevel = o.styleRef().effectiveZoom(); 342 float zoomLevel = o.styleRef().effectiveZoom();
343 GraphicsContextStateSaver stateSaver(*i.context); 343 GraphicsContextStateSaver stateSaver(i.context);
344 IntRect unzoomedRect = r; 344 IntRect unzoomedRect = r;
345 if (zoomLevel != 1) { 345 if (zoomLevel != 1) {
346 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 346 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
347 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 347 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
348 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 348 i.context.translate(unzoomedRect.x(), unzoomedRect.y());
349 i.context->scale(zoomLevel, zoomLevel); 349 i.context.scale(zoomLevel, zoomLevel);
350 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 350 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y());
351 } 351 }
352 352
353 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartCheckbox, getWebFallbackThemeState(o), WebRect(unzoomedRect), &extraPa rams); 353 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartCheckbox, getWebFallbackThemeState(o), WebRect(unzoomedRect), &extraPa rams);
354 return false; 354 return false;
355 } 355 }
356 356
357 bool ThemePainter::paintRadioUsingFallbackTheme(const LayoutObject& o, const Pai ntInfo& i, const IntRect&r) 357 bool ThemePainter::paintRadioUsingFallbackTheme(const LayoutObject& o, const Pai ntInfo& i, const IntRect&r)
358 { 358 {
359 WebFallbackThemeEngine::ExtraParams extraParams; 359 WebFallbackThemeEngine::ExtraParams extraParams;
360 WebCanvas* canvas = i.context->canvas(); 360 WebCanvas* canvas = i.context.canvas();
361 extraParams.button.checked = LayoutTheme::isChecked(o); 361 extraParams.button.checked = LayoutTheme::isChecked(o);
362 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o); 362 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o);
363 363
364 float zoomLevel = o.styleRef().effectiveZoom(); 364 float zoomLevel = o.styleRef().effectiveZoom();
365 GraphicsContextStateSaver stateSaver(*i.context); 365 GraphicsContextStateSaver stateSaver(i.context);
366 IntRect unzoomedRect = r; 366 IntRect unzoomedRect = r;
367 if (zoomLevel != 1) { 367 if (zoomLevel != 1) {
368 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 368 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
369 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 369 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
370 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 370 i.context.translate(unzoomedRect.x(), unzoomedRect.y());
371 i.context->scale(zoomLevel, zoomLevel); 371 i.context.scale(zoomLevel, zoomLevel);
372 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 372 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y());
373 } 373 }
374 374
375 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartRadio, getWebFallbackThemeState(o), WebRect(unzoomedRect), &extraParam s); 375 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartRadio, getWebFallbackThemeState(o), WebRect(unzoomedRect), &extraParam s);
376 return false; 376 return false;
377 } 377 }
378 378
379 } // namespace blink 379 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/TextPainterTest.cpp ('k') | third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698