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

Side by Side Diff: Source/core/layout/LayoutThemeChromiumDefault.cpp

Issue 894393003: Constify and use reference for RenderStyle in LayoutTheme (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. 2 * Copyright (C) 2007 Apple Inc.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2008 Collabora Ltd. 4 * Copyright (C) 2008 Collabora Ltd.
5 * Copyright (C) 2008, 2009 Google Inc. 5 * Copyright (C) 2008, 2009 Google Inc.
6 * Copyright (C) 2009 Kenneth Rohde Christiansen 6 * Copyright (C) 2009 Kenneth Rohde Christiansen
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 LayoutThemeChromiumDefault::LayoutThemeChromiumDefault() 78 LayoutThemeChromiumDefault::LayoutThemeChromiumDefault()
79 { 79 {
80 m_caretBlinkInterval = LayoutTheme::caretBlinkInterval(); 80 m_caretBlinkInterval = LayoutTheme::caretBlinkInterval();
81 } 81 }
82 82
83 LayoutThemeChromiumDefault::~LayoutThemeChromiumDefault() 83 LayoutThemeChromiumDefault::~LayoutThemeChromiumDefault()
84 { 84 {
85 } 85 }
86 86
87 bool LayoutThemeChromiumDefault::supportsFocusRing(const RenderStyle* style) con st 87 bool LayoutThemeChromiumDefault::supportsFocusRing(const RenderStyle& style) con st
88 { 88 {
89 if (useMockTheme()) { 89 if (useMockTheme()) {
90 // Don't use focus rings for buttons when mocking controls. 90 // Don't use focus rings for buttons when mocking controls.
91 return style->appearance() == ButtonPart 91 return style.appearance() == ButtonPart
92 || style->appearance() == PushButtonPart 92 || style.appearance() == PushButtonPart
93 || style->appearance() == SquareButtonPart; 93 || style.appearance() == SquareButtonPart;
94 } 94 }
95 95
96 return LayoutThemeChromiumSkia::supportsFocusRing(style); 96 return LayoutThemeChromiumSkia::supportsFocusRing(style);
97 } 97 }
98 98
99 Color LayoutThemeChromiumDefault::systemColor(CSSValueID cssValueId) const 99 Color LayoutThemeChromiumDefault::systemColor(CSSValueID cssValueId) const
100 { 100 {
101 static const Color defaultButtonGrayColor(0xffdddddd); 101 static const Color defaultButtonGrayColor(0xffdddddd);
102 static const Color defaultMenuColor(0xfff7f7f7); 102 static const Color defaultMenuColor(0xfff7f7f7);
103 103
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return IntSize(1, 6); 176 return IntSize(1, 6);
177 } 177 }
178 178
179 int LayoutThemeChromiumDefault::sliderTickOffsetFromTrackCenter() const 179 int LayoutThemeChromiumDefault::sliderTickOffsetFromTrackCenter() const
180 { 180 {
181 if (useMockTheme()) 181 if (useMockTheme())
182 return 11; 182 return 11;
183 return -16; 183 return -16;
184 } 184 }
185 185
186 void LayoutThemeChromiumDefault::adjustSliderThumbSize(RenderStyle* style, Eleme nt* element) const 186 void LayoutThemeChromiumDefault::adjustSliderThumbSize(RenderStyle& style, Eleme nt* element) const
187 { 187 {
188 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artSliderThumb); 188 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artSliderThumb);
189 189
190 // FIXME: Mock theme doesn't handle zoomed sliders. 190 // FIXME: Mock theme doesn't handle zoomed sliders.
191 float zoomLevel = useMockTheme() ? 1 : style->effectiveZoom(); 191 float zoomLevel = useMockTheme() ? 1 : style.effectiveZoom();
192 if (style->appearance() == SliderThumbHorizontalPart) { 192 if (style.appearance() == SliderThumbHorizontalPart) {
193 style->setWidth(Length(size.width() * zoomLevel, Fixed)); 193 style.setWidth(Length(size.width() * zoomLevel, Fixed));
194 style->setHeight(Length(size.height() * zoomLevel, Fixed)); 194 style.setHeight(Length(size.height() * zoomLevel, Fixed));
195 } else if (style->appearance() == SliderThumbVerticalPart) { 195 } else if (style.appearance() == SliderThumbVerticalPart) {
196 style->setWidth(Length(size.height() * zoomLevel, Fixed)); 196 style.setWidth(Length(size.height() * zoomLevel, Fixed));
197 style->setHeight(Length(size.width() * zoomLevel, Fixed)); 197 style.setHeight(Length(size.width() * zoomLevel, Fixed));
198 } else { 198 } else {
199 LayoutThemeChromiumSkia::adjustSliderThumbSize(style, element); 199 LayoutThemeChromiumSkia::adjustSliderThumbSize(style, element);
200 } 200 }
201 } 201 }
202 202
203 void LayoutThemeChromiumDefault::setCaretBlinkInterval(double interval) 203 void LayoutThemeChromiumDefault::setCaretBlinkInterval(double interval)
204 { 204 {
205 m_caretBlinkInterval = interval; 205 m_caretBlinkInterval = interval;
206 } 206 }
207 207
(...skipping 30 matching lines...) Expand all
238 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 238 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
239 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 239 i.context->translate(unzoomedRect.x(), unzoomedRect.y());
240 i.context->scale(zoomLevel, zoomLevel); 240 i.context->scale(zoomLevel, zoomLevel);
241 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 241 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
242 } 242 }
243 243
244 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartCheckb ox, getWebThemeState(this, o), WebRect(unzoomedRect), &extraParams); 244 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartCheckb ox, getWebThemeState(this, o), WebRect(unzoomedRect), &extraParams);
245 return false; 245 return false;
246 } 246 }
247 247
248 void LayoutThemeChromiumDefault::setCheckboxSize(RenderStyle* style) const 248 void LayoutThemeChromiumDefault::setCheckboxSize(RenderStyle& style) const
249 { 249 {
250 // If the width and height are both specified, then we have nothing to do. 250 // If the width and height are both specified, then we have nothing to do.
251 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) 251 if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto())
252 return; 252 return;
253 253
254 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artCheckbox); 254 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artCheckbox);
255 float zoomLevel = style->effectiveZoom(); 255 float zoomLevel = style.effectiveZoom();
256 size.setWidth(size.width() * zoomLevel); 256 size.setWidth(size.width() * zoomLevel);
257 size.setHeight(size.height() * zoomLevel); 257 size.setHeight(size.height() * zoomLevel);
258 setSizeIfAuto(style, size); 258 setSizeIfAuto(style, size);
259 } 259 }
260 260
261 bool LayoutThemeChromiumDefault::paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& rect) 261 bool LayoutThemeChromiumDefault::paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& rect)
262 { 262 {
263 WebThemeEngine::ExtraParams extraParams; 263 WebThemeEngine::ExtraParams extraParams;
264 WebCanvas* canvas = i.context->canvas(); 264 WebCanvas* canvas = i.context->canvas();
265 extraParams.button.checked = isChecked(o); 265 extraParams.button.checked = isChecked(o);
266 266
267 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartRadio, getWebThemeState(this, o), WebRect(rect), &extraParams); 267 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartRadio, getWebThemeState(this, o), WebRect(rect), &extraParams);
268 return false; 268 return false;
269 } 269 }
270 270
271 void LayoutThemeChromiumDefault::setRadioSize(RenderStyle* style) const 271 void LayoutThemeChromiumDefault::setRadioSize(RenderStyle& style) const
272 { 272 {
273 // If the width and height are both specified, then we have nothing to do. 273 // If the width and height are both specified, then we have nothing to do.
274 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) 274 if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto())
275 return; 275 return;
276 276
277 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artRadio); 277 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artRadio);
278 float zoomLevel = style->effectiveZoom(); 278 float zoomLevel = style.effectiveZoom();
279 size.setWidth(size.width() * zoomLevel); 279 size.setWidth(size.width() * zoomLevel);
280 size.setHeight(size.height() * zoomLevel); 280 size.setHeight(size.height() * zoomLevel);
281 setSizeIfAuto(style, size); 281 setSizeIfAuto(style, size);
282 } 282 }
283 283
284 bool LayoutThemeChromiumDefault::paintButton(RenderObject* o, const PaintInfo& i , const IntRect& rect) 284 bool LayoutThemeChromiumDefault::paintButton(RenderObject* o, const PaintInfo& i , const IntRect& rect)
285 { 285 {
286 WebThemeEngine::ExtraParams extraParams; 286 WebThemeEngine::ExtraParams extraParams;
287 WebCanvas* canvas = i.context->canvas(); 287 WebCanvas* canvas = i.context->canvas();
288 extraParams.button.hasBorder = true; 288 extraParams.button.hasBorder = true;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 438 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
439 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 439 i.context->translate(unzoomedRect.x(), unzoomedRect.y());
440 i.context->scale(zoomLevel, zoomLevel); 440 i.context->scale(zoomLevel, zoomLevel);
441 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 441 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
442 } 442 }
443 443
444 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartSlider Thumb, getWebThemeState(this, o), WebRect(unzoomedRect), &extraParams); 444 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartSlider Thumb, getWebThemeState(this, o), WebRect(unzoomedRect), &extraParams);
445 return false; 445 return false;
446 } 446 }
447 447
448 void LayoutThemeChromiumDefault::adjustInnerSpinButtonStyle(RenderStyle* style, Element*) const 448 void LayoutThemeChromiumDefault::adjustInnerSpinButtonStyle(RenderStyle& style, Element*) const
449 { 449 {
450 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artInnerSpinButton); 450 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artInnerSpinButton);
451 451
452 style->setWidth(Length(size.width(), Fixed)); 452 style.setWidth(Length(size.width(), Fixed));
453 style->setMinWidth(Length(size.width(), Fixed)); 453 style.setMinWidth(Length(size.width(), Fixed));
454 } 454 }
455 455
456 bool LayoutThemeChromiumDefault::paintInnerSpinButton(RenderObject* o, const Pai ntInfo& i, const IntRect& rect) 456 bool LayoutThemeChromiumDefault::paintInnerSpinButton(RenderObject* o, const Pai ntInfo& i, const IntRect& rect)
457 { 457 {
458 WebThemeEngine::ExtraParams extraParams; 458 WebThemeEngine::ExtraParams extraParams;
459 WebCanvas* canvas = i.context->canvas(); 459 WebCanvas* canvas = i.context->canvas();
460 extraParams.innerSpin.spinUp = (controlStatesForRenderer(o) & SpinUpControlS tate); 460 extraParams.innerSpin.spinUp = (controlStatesForRenderer(o) & SpinUpControlS tate);
461 extraParams.innerSpin.readOnly = isReadOnlyControl(o); 461 extraParams.innerSpin.readOnly = isReadOnlyControl(o);
462 462
463 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartInnerS pinButton, getWebThemeState(this, o), WebRect(rect), &extraParams); 463 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartInnerS pinButton, getWebThemeState(this, o), WebRect(rect), &extraParams);
(...skipping 19 matching lines...) Expand all
483 WebCanvas* canvas = i.context->canvas(); 483 WebCanvas* canvas = i.context->canvas();
484 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartProgre ssBar, getWebThemeState(this, o), WebRect(rect), &extraParams); 484 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartProgre ssBar, getWebThemeState(this, o), WebRect(rect), &extraParams);
485 return false; 485 return false;
486 } 486 }
487 487
488 bool LayoutThemeChromiumDefault::shouldOpenPickerWithF4Key() const 488 bool LayoutThemeChromiumDefault::shouldOpenPickerWithF4Key() const
489 { 489 {
490 return true; 490 return true;
491 } 491 }
492 492
493 bool LayoutThemeChromiumDefault::shouldUseFallbackTheme(RenderStyle* style) cons t 493 bool LayoutThemeChromiumDefault::shouldUseFallbackTheme(const RenderStyle& style ) const
494 { 494 {
495 if (useMockTheme()) { 495 if (useMockTheme()) {
496 // The mock theme can't handle zoomed controls, so we fall back to the " fallback" theme. 496 // The mock theme can't handle zoomed controls, so we fall back to the " fallback" theme.
497 ControlPart part = style->appearance(); 497 ControlPart part = style.appearance();
498 if (part == CheckboxPart || part == RadioPart) 498 if (part == CheckboxPart || part == RadioPart)
499 return style->effectiveZoom() != 1; 499 return style.effectiveZoom() != 1;
500 } 500 }
501 return LayoutTheme::shouldUseFallbackTheme(style); 501 return LayoutTheme::shouldUseFallbackTheme(style);
502 } 502 }
503 503
504 } // namespace blink 504 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698