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

Side by Side Diff: Source/core/rendering/RenderThemeChromiumDefault.cpp

Issue 41733004: Roll up patch for running layout tests under Aura. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add even more comments about why we have special logic for the layout tests Created 7 years, 1 month 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 * 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 11 matching lines...) Expand all
22 * 22 *
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26 #include "core/rendering/RenderThemeChromiumDefault.h" 26 #include "core/rendering/RenderThemeChromiumDefault.h"
27 27
28 #include "CSSValueKeywords.h" 28 #include "CSSValueKeywords.h"
29 #include "UserAgentStyleSheets.h" 29 #include "UserAgentStyleSheets.h"
30 #include "core/platform/graphics/GraphicsContext.h" 30 #include "core/platform/graphics/GraphicsContext.h"
31 #include "core/platform/graphics/GraphicsContextStateSaver.h" 31 #include "core/platform/graphics/GraphicsContextStateSaver.h"
32 #include "core/platform/graphics/chromium/TransparencyWin.h"
32 #include "core/rendering/PaintInfo.h" 33 #include "core/rendering/PaintInfo.h"
33 #include "core/rendering/RenderObject.h" 34 #include "core/rendering/RenderObject.h"
34 #include "core/rendering/RenderProgress.h" 35 #include "core/rendering/RenderProgress.h"
36 #include "platform/LayoutTestSupport.h"
35 #include "platform/graphics/Color.h" 37 #include "platform/graphics/Color.h"
36 #include "public/platform/default/WebThemeEngine.h" 38 #include "public/platform/default/WebThemeEngine.h"
37 #include "public/platform/Platform.h" 39 #include "public/platform/Platform.h"
38 #include "public/platform/WebRect.h" 40 #include "public/platform/WebRect.h"
39 41
40 namespace WebCore { 42 namespace WebCore {
41 43
44 namespace {
45
46 // FIXME: The ThemePainter concept was needed on Windows to emulate the way the
47 // GDI controls handled transparency (see RenderThemeChromiumWin.cpp and
48 // core/platform/graphics/chromium/TransparencyWin.cpp). We use it here so that
49 // we can match the mock theme baselines that were based on the native code.
50 // Not using the theme painter produces a few minor diffs on tests that involve
51 // translated or rotated controls; we'd need to investigate if those diffs
52 // involve real bugs before we get rid of this.
53 class ThemePainter {
54 public:
55 ThemePainter(GraphicsContext* context, const IntRect& r)
56 {
57 TransparencyWin::TransformMode transformMode;
58
59 AffineTransform matrix = context->getCTM();
60 if (matrix.b() || matrix.c()) // Skew.0
61 transformMode = TransparencyWin::Untransform;
62 else if (matrix.a() != 1.0 || matrix.d() != 1.0) // Scale.
63 transformMode = TransparencyWin::ScaleTransform;
64 else // Nothing interesting.
65 transformMode = TransparencyWin::KeepTransform;
66
67 TransparencyWin::LayerMode layerMode;
68 if (context->canvas()->isDrawingToLayer())
69 layerMode = TransparencyWin::OpaqueCompositeLayer;
70 else if (transformMode == TransparencyWin::KeepTransform)
71 layerMode = TransparencyWin::NoLayer;
72 else
73 layerMode = TransparencyWin::OpaqueCompositeLayer;
74
75 m_helper.init(context, layerMode, transformMode, r);
76 }
77
78 GraphicsContext* context() { return m_helper.context(); }
79
80 WebKit::WebCanvas* canvas() { return m_helper.context()->canvas(); }
81
82 const IntRect& drawRect() { return m_helper.drawRect(); }
83
84 void composite() { m_helper.composite(); }
85 private:
86 TransparencyWin m_helper;
87 };
88
89 } // namespace
90
42 unsigned RenderThemeChromiumDefault::m_activeSelectionBackgroundColor = 91 unsigned RenderThemeChromiumDefault::m_activeSelectionBackgroundColor =
43 0xff1e90ff; 92 0xff1e90ff;
44 unsigned RenderThemeChromiumDefault::m_activeSelectionForegroundColor = 93 unsigned RenderThemeChromiumDefault::m_activeSelectionForegroundColor =
45 Color::black; 94 Color::black;
46 unsigned RenderThemeChromiumDefault::m_inactiveSelectionBackgroundColor = 95 unsigned RenderThemeChromiumDefault::m_inactiveSelectionBackgroundColor =
47 0xffc8c8c8; 96 0xffc8c8c8;
48 unsigned RenderThemeChromiumDefault::m_inactiveSelectionForegroundColor = 97 unsigned RenderThemeChromiumDefault::m_inactiveSelectionForegroundColor =
49 0xff323232; 98 0xff323232;
50 99
51 double RenderThemeChromiumDefault::m_caretBlinkInterval; 100 double RenderThemeChromiumDefault::m_caretBlinkInterval;
52 101
53 static const unsigned defaultButtonBackgroundColor = 0xffdddddd; 102 static const unsigned defaultButtonBackgroundColor = 0xffdddddd;
54 103
55 static WebKit::WebThemeEngine::State getWebThemeState(const RenderTheme* theme, const RenderObject* o) 104 static WebKit::WebThemeEngine::State getWebThemeState(const RenderTheme* theme, const RenderObject* o)
56 { 105 {
106 if (isRunningLayoutTest()) {
107 // The order of these is important: readonly > focused > hot.
108 // The normal Aura theme doesn't render readonly specially, nor does
109 // it distinguish between hover and hot states.
110 if (!theme->isEnabled(o))
111 return WebKit::WebThemeEngine::StateDisabled;
112 if (theme->isReadOnlyControl(o))
113 return WebKit::WebThemeEngine::StateReadonly;
114 if (theme->isPressed(o))
115 return WebKit::WebThemeEngine::StatePressed;
116 if (theme->isFocused(o))
117 return WebKit::WebThemeEngine::StateFocused;
118 if (theme->isHovered(o))
119 return WebKit::WebThemeEngine::StateHot; // Hot, not hover: hover is only used in scroll bars in the mock theme.
120 return WebKit::WebThemeEngine::StateNormal;
121 }
122
57 if (!theme->isEnabled(o)) 123 if (!theme->isEnabled(o))
58 return WebKit::WebThemeEngine::StateDisabled; 124 return WebKit::WebThemeEngine::StateDisabled;
59 if (theme->isPressed(o)) 125 if (theme->isPressed(o))
60 return WebKit::WebThemeEngine::StatePressed; 126 return WebKit::WebThemeEngine::StatePressed;
61 if (theme->isHovered(o)) 127 if (theme->isHovered(o))
62 return WebKit::WebThemeEngine::StateHover; 128 return WebKit::WebThemeEngine::StateHover;
63 129
64 return WebKit::WebThemeEngine::StateNormal; 130 return WebKit::WebThemeEngine::StateNormal;
65 } 131 }
66 132
(...skipping 13 matching lines...) Expand all
80 146
81 RenderThemeChromiumDefault::RenderThemeChromiumDefault() 147 RenderThemeChromiumDefault::RenderThemeChromiumDefault()
82 { 148 {
83 m_caretBlinkInterval = RenderTheme::caretBlinkInterval(); 149 m_caretBlinkInterval = RenderTheme::caretBlinkInterval();
84 } 150 }
85 151
86 RenderThemeChromiumDefault::~RenderThemeChromiumDefault() 152 RenderThemeChromiumDefault::~RenderThemeChromiumDefault()
87 { 153 {
88 } 154 }
89 155
156 bool RenderThemeChromiumDefault::supportsFocusRing(const RenderStyle* style) con st
157 {
158 if (isRunningLayoutTest()) {
159 // Don't use focus rings for buttons when mocking controls.
160 return style->appearance() == ButtonPart
161 || style->appearance() == PushButtonPart
162 || style->appearance() == SquareButtonPart;
163 }
164
165 // Otherwise, use the default implementation.
166 return RenderTheme::supportsFocusRing(style);
167 }
168
90 Color RenderThemeChromiumDefault::systemColor(CSSValueID cssValueId) const 169 Color RenderThemeChromiumDefault::systemColor(CSSValueID cssValueId) const
91 { 170 {
92 static const Color defaultButtonGrayColor(0xffdddddd); 171 static const Color defaultButtonGrayColor(0xffdddddd);
93 static const Color defaultMenuColor(0xfff7f7f7); 172 static const Color defaultMenuColor(0xfff7f7f7);
94 173
95 if (cssValueId == CSSValueButtonface) 174 if (cssValueId == CSSValueButtonface) {
175 if (isRunningLayoutTest())
176 return Color(0xc0, 0xc0, 0xc0);
96 return defaultButtonGrayColor; 177 return defaultButtonGrayColor;
178 }
97 if (cssValueId == CSSValueMenu) 179 if (cssValueId == CSSValueMenu)
98 return defaultMenuColor; 180 return defaultMenuColor;
99 return RenderTheme::systemColor(cssValueId); 181 return RenderTheme::systemColor(cssValueId);
100 } 182 }
101 183
102 String RenderThemeChromiumDefault::extraDefaultStyleSheet() 184 String RenderThemeChromiumDefault::extraDefaultStyleSheet()
103 { 185 {
104 #if !OS(WIN) 186 #if !OS(WIN)
105 return RenderTheme::extraDefaultStyleSheet() + 187 return RenderTheme::extraDefaultStyleSheet() +
106 RenderThemeChromiumSkia::extraDefaultStyleSheet() + 188 RenderThemeChromiumSkia::extraDefaultStyleSheet() +
(...skipping 24 matching lines...) Expand all
131 return Color(0xc8, 0xc8, 0xc8); 213 return Color(0xc8, 0xc8, 0xc8);
132 } 214 }
133 215
134 Color RenderThemeChromiumDefault::inactiveListBoxSelectionForegroundColor() cons t 216 Color RenderThemeChromiumDefault::inactiveListBoxSelectionForegroundColor() cons t
135 { 217 {
136 return Color(0x32, 0x32, 0x32); 218 return Color(0x32, 0x32, 0x32);
137 } 219 }
138 220
139 Color RenderThemeChromiumDefault::platformActiveSelectionBackgroundColor() const 221 Color RenderThemeChromiumDefault::platformActiveSelectionBackgroundColor() const
140 { 222 {
223 if (isRunningLayoutTest())
224 return Color(0x00, 0x00, 0xff); // Royal blue.
jamesr 2013/11/06 21:54:09 the activeSelectionBackgroundColor (and other sele
Dirk Pranke 2013/11/06 22:29:11 I don't think I was aware of that API. I will look
141 return m_activeSelectionBackgroundColor; 225 return m_activeSelectionBackgroundColor;
142 } 226 }
143 227
144 Color RenderThemeChromiumDefault::platformInactiveSelectionBackgroundColor() con st 228 Color RenderThemeChromiumDefault::platformInactiveSelectionBackgroundColor() con st
145 { 229 {
230 if (isRunningLayoutTest())
231 return Color(0x99, 0x99, 0x99); // Medium gray.
146 return m_inactiveSelectionBackgroundColor; 232 return m_inactiveSelectionBackgroundColor;
147 } 233 }
148 234
149 Color RenderThemeChromiumDefault::platformActiveSelectionForegroundColor() const 235 Color RenderThemeChromiumDefault::platformActiveSelectionForegroundColor() const
150 { 236 {
237 if (isRunningLayoutTest())
238 return Color(0xff, 0xff, 0xcc); // Pale yellow.
151 return m_activeSelectionForegroundColor; 239 return m_activeSelectionForegroundColor;
152 } 240 }
153 241
154 Color RenderThemeChromiumDefault::platformInactiveSelectionForegroundColor() con st 242 Color RenderThemeChromiumDefault::platformInactiveSelectionForegroundColor() con st
155 { 243 {
244 if (isRunningLayoutTest())
245 return Color::white;
156 return m_inactiveSelectionForegroundColor; 246 return m_inactiveSelectionForegroundColor;
157 } 247 }
158 248
159 IntSize RenderThemeChromiumDefault::sliderTickSize() const 249 IntSize RenderThemeChromiumDefault::sliderTickSize() const
160 { 250 {
251 if (isRunningLayoutTest())
252 return IntSize(1, 3);
161 return IntSize(1, 6); 253 return IntSize(1, 6);
162 } 254 }
163 255
164 int RenderThemeChromiumDefault::sliderTickOffsetFromTrackCenter() const 256 int RenderThemeChromiumDefault::sliderTickOffsetFromTrackCenter() const
165 { 257 {
258 if (isRunningLayoutTest())
259 return 11;
166 return -16; 260 return -16;
167 } 261 }
168 262
169 void RenderThemeChromiumDefault::adjustSliderThumbSize(RenderStyle* style, Eleme nt* element) const 263 void RenderThemeChromiumDefault::adjustSliderThumbSize(RenderStyle* style, Eleme nt* element) const
170 { 264 {
265 if (isRunningLayoutTest()) {
266 // These sizes match what WinXP draws for various menus.
jamesr 2013/11/06 21:54:09 we're about to call into the theme to get the size
Dirk Pranke 2013/11/06 22:29:11 Good question, I'll look into that.
267 const int sliderThumbAlongAxis = 11;
268 const int sliderThumbAcrossAxis = 21;
269 if (style->appearance() == SliderThumbHorizontalPart) {
270 style->setWidth(Length(sliderThumbAlongAxis, Fixed));
271 style->setHeight(Length(sliderThumbAcrossAxis, Fixed));
272 } else if (style->appearance() == SliderThumbVerticalPart) {
273 style->setWidth(Length(sliderThumbAcrossAxis, Fixed));
274 style->setHeight(Length(sliderThumbAlongAxis, Fixed));
275 } else {
276 RenderThemeChromiumSkia::adjustSliderThumbSize(style, element);
277 }
278 return;
279 }
280
171 IntSize size = WebKit::Platform::current()->themeEngine()->getSize(WebKit::W ebThemeEngine::PartSliderThumb); 281 IntSize size = WebKit::Platform::current()->themeEngine()->getSize(WebKit::W ebThemeEngine::PartSliderThumb);
172 float zoomLevel = style->effectiveZoom(); 282 float zoomLevel = style->effectiveZoom();
173 if (style->appearance() == SliderThumbHorizontalPart) { 283 if (style->appearance() == SliderThumbHorizontalPart) {
174 style->setWidth(Length(size.width() * zoomLevel, Fixed)); 284 style->setWidth(Length(size.width() * zoomLevel, Fixed));
175 style->setHeight(Length(size.height() * zoomLevel, Fixed)); 285 style->setHeight(Length(size.height() * zoomLevel, Fixed));
176 } else if (style->appearance() == SliderThumbVerticalPart) { 286 } else if (style->appearance() == SliderThumbVerticalPart) {
177 style->setWidth(Length(size.height() * zoomLevel, Fixed)); 287 style->setWidth(Length(size.height() * zoomLevel, Fixed));
178 style->setHeight(Length(size.width() * zoomLevel, Fixed)); 288 style->setHeight(Length(size.width() * zoomLevel, Fixed));
179 } else 289 } else
180 RenderThemeChromiumSkia::adjustSliderThumbSize(style, element); 290 RenderThemeChromiumSkia::adjustSliderThumbSize(style, element);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 size.setWidth(size.width() * zoomLevel); 373 size.setWidth(size.width() * zoomLevel);
264 size.setHeight(size.height() * zoomLevel); 374 size.setHeight(size.height() * zoomLevel);
265 setSizeIfAuto(style, size); 375 setSizeIfAuto(style, size);
266 } 376 }
267 377
268 bool RenderThemeChromiumDefault::paintButton(RenderObject* o, const PaintInfo& i , const IntRect& rect) 378 bool RenderThemeChromiumDefault::paintButton(RenderObject* o, const PaintInfo& i , const IntRect& rect)
269 { 379 {
270 WebKit::WebThemeEngine::ExtraParams extraParams; 380 WebKit::WebThemeEngine::ExtraParams extraParams;
271 WebKit::WebCanvas* canvas = i.context->canvas(); 381 WebKit::WebCanvas* canvas = i.context->canvas();
272 extraParams.button.hasBorder = true; 382 extraParams.button.hasBorder = true;
383
384 if (isRunningLayoutTest()) {
385 extraParams.button.backgroundColor = 0xffc0c0c0;
386 if (o->hasBackground())
387 extraParams.button.backgroundColor = o->resolveColor(CSSPropertyBack groundColor).rgb();
388 ThemePainter painter(i.context, rect);
jamesr 2013/11/06 21:54:09 why do we need a ThemePainter in the layout test p
Dirk Pranke 2013/11/06 22:29:11 To be honest, I don't fully understand/recall how
jamesr 2013/11/06 23:16:15 I think it'd be better to either mark those as fai
Dirk Pranke 2013/11/06 23:46:38 Yes, that is certainly true. I will remove it and
389 WebKit::Platform::current()->themeEngine()->paint(painter.canvas(), WebK it::WebThemeEngine::PartButton,
390 getWebThemeState(this, o), WebKit::WebRect(painter.drawRect()), &ext raParams);
391 painter.composite();
392 return false;
393 }
394
273 extraParams.button.backgroundColor = defaultButtonBackgroundColor; 395 extraParams.button.backgroundColor = defaultButtonBackgroundColor;
274 if (o->hasBackground()) 396 if (o->hasBackground())
275 extraParams.button.backgroundColor = o->resolveColor(CSSPropertyBackgrou ndColor).rgb(); 397 extraParams.button.backgroundColor = o->resolveColor(CSSPropertyBackgrou ndColor).rgb();
276 398
277 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartButton, getWebThemeState(this, o), WebKit::WebRect(rect), &extraParams ); 399 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartButton, getWebThemeState(this, o), WebKit::WebRect(rect), &extraParams );
278 return false; 400 return false;
279 } 401 }
280 402
281 bool RenderThemeChromiumDefault::paintTextField(RenderObject* o, const PaintInfo & i, const IntRect& rect) 403 bool RenderThemeChromiumDefault::paintTextField(RenderObject* o, const PaintInfo & i, const IntRect& rect)
282 { 404 {
283 // WebThemeEngine does not handle border rounded corner and background image 405 // WebThemeEngine does not handle border rounded corner and background image
284 // so return true to draw CSS border and background. 406 // so return true to draw CSS border and background.
285 if (o->style()->hasBorderRadius() || o->style()->hasBackgroundImage()) 407 if (o->style()->hasBorderRadius() || o->style()->hasBackgroundImage())
286 return true; 408 return true;
287 409
288 ControlPart part = o->style()->appearance(); 410 ControlPart part = o->style()->appearance();
289 411
290 WebKit::WebThemeEngine::ExtraParams extraParams; 412 WebKit::WebThemeEngine::ExtraParams extraParams;
291 extraParams.textField.isTextArea = part == TextAreaPart; 413 extraParams.textField.isTextArea = part == TextAreaPart;
292 extraParams.textField.isListbox = part == ListboxPart; 414 extraParams.textField.isListbox = part == ListboxPart;
293 415
294 WebKit::WebCanvas* canvas = i.context->canvas(); 416 WebKit::WebCanvas* canvas = i.context->canvas();
295 417
296 // Fallback to white if the specified color object is invalid. 418 // Fallback to white if the specified color object is invalid.
297 Color backgroundColor = o->resolveColor(CSSPropertyBackgroundColor, Color::w hite); 419 Color backgroundColor = o->resolveColor(CSSPropertyBackgroundColor, Color::w hite);
298 extraParams.textField.backgroundColor = backgroundColor.rgb(); 420 extraParams.textField.backgroundColor = backgroundColor.rgb();
299 421
422 if (isRunningLayoutTest()) {
423 ThemePainter painter(i.context, rect);
jamesr 2013/11/06 21:54:09 same question here
Dirk Pranke 2013/11/06 22:29:11 same answer :).
424 WebKit::Platform::current()->themeEngine()->paint(painter.canvas(), WebK it::WebThemeEngine::PartTextField, getWebThemeState(this, o), WebKit::WebRect(pa inter.drawRect()), &extraParams);
425 painter.composite();
426 return false;
427 }
428
300 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartTextField, getWebThemeState(this, o), WebKit::WebRect(rect), &extraPar ams); 429 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartTextField, getWebThemeState(this, o), WebKit::WebRect(rect), &extraPar ams);
301 return false; 430 return false;
302 } 431 }
303 432
304 bool RenderThemeChromiumDefault::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& rect) 433 bool RenderThemeChromiumDefault::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& rect)
305 { 434 {
306 if (!o->isBox()) 435 if (!o->isBox())
307 return false; 436 return false;
308 437
309 const int right = rect.x() + rect.width(); 438 const int right = rect.x() + rect.width();
310 const int middle = rect.y() + rect.height() / 2; 439 const int middle = rect.y() + rect.height() / 2;
311 440
312 WebKit::WebThemeEngine::ExtraParams extraParams; 441 WebKit::WebThemeEngine::ExtraParams extraParams;
313 extraParams.menuList.arrowX = (o->style()->direction() == RTL) ? rect.x() + 7 : right - 13;
314 extraParams.menuList.arrowY = middle; 442 extraParams.menuList.arrowY = middle;
315 const RenderBox* box = toRenderBox(o); 443 const RenderBox* box = toRenderBox(o);
316 // Match Chromium Win behaviour of showing all borders if any are shown. 444 // Match Chromium Win behaviour of showing all borders if any are shown.
317 extraParams.menuList.hasBorder = box->borderRight() || box->borderLeft() || box->borderTop() || box->borderBottom(); 445 extraParams.menuList.hasBorder = box->borderRight() || box->borderLeft() || box->borderTop() || box->borderBottom();
318 extraParams.menuList.hasBorderRadius = o->style()->hasBorderRadius(); 446 extraParams.menuList.hasBorderRadius = o->style()->hasBorderRadius();
319 // Fallback to transparent if the specified color object is invalid. 447 // Fallback to transparent if the specified color object is invalid.
320 extraParams.menuList.backgroundColor = Color::transparent; 448 Color backgroundColor(Color::transparent);
321 if (o->hasBackground()) 449 if (o->hasBackground())
322 extraParams.menuList.backgroundColor = o->resolveColor(CSSPropertyBackgr oundColor).rgb(); 450 backgroundColor = o->resolveColor(CSSPropertyBackgroundColor);
451 extraParams.menuList.backgroundColor = backgroundColor.rgb();
323 452
453 // If we have a background image, don't fill the content area to expose the
454 // parent's background. Also, we shouldn't fill the content area if the
455 // alpha of the color is 0. The API of Windows GDI ignores the alpha.
456 // FIXME: the normal Aura theme doesn't care about this, so we should
457 // investigate if we really need fillContentArea.
458 extraParams.menuList.fillContentArea = !o->style()->hasBackgroundImage() && backgroundColor.alpha();
459
460 if (isRunningLayoutTest()) {
461 // The size and position of the drop-down button is different between
462 // the mock theme and the regular aura theme.
463 int borderLeft = box->borderLeft();
464 int borderRight = box->borderRight();
465 int borderTop = box->borderTop();
466 int borderBottom = box->borderBottom();
467 int spacingTop = borderTop + box->paddingTop();
468 int spacingBottom = borderBottom + box->paddingBottom();
469 int spacingLeft = borderLeft + box->paddingLeft();
470 int spacingRight = borderRight + box->paddingRight();
471
472 extraParams.menuList.arrowX = (o->style()->direction() == RTL) ? rect.x( ) + 4 + spacingRight: right - 13 - spacingRight;
473 extraParams.menuList.arrowHeight = rect.height() - spacingBottom - spaci ngTop;
474
475 if (o->style()->hasBorderRadius()) {
476 // If the style has rounded borders, setup the context to clip the
477 // background (themed or filled) appropriately.
478 // FIXME: make sure we do the right thing if css background-clip is set.
479 i.context->save();
480 i.context->clipRoundedRect(o->style()->getRoundedBorderFor(rect));
481 }
482
483 ThemePainter painter(i.context, rect);
484 WebKit::Platform::current()->themeEngine()->paint(painter.canvas(), WebK it::WebThemeEngine::PartMenuList, getWebThemeState(this, o), WebKit::WebRect(pai nter.drawRect()), &extraParams);
485 painter.composite();
486
487 if (o->style()->hasBorderRadius())
488 i.context->restore();
489 return false;
490 }
491
492 extraParams.menuList.arrowX = (o->style()->direction() == RTL) ? rect.x() + 7 : right - 13;
324 WebKit::WebCanvas* canvas = i.context->canvas(); 493 WebKit::WebCanvas* canvas = i.context->canvas();
325 494
326 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartMenuList, getWebThemeState(this, o), WebKit::WebRect(rect), &extraPara ms); 495 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartMenuList, getWebThemeState(this, o), WebKit::WebRect(rect), &extraPara ms);
327 return false; 496 return false;
328 } 497 }
329 498
330 bool RenderThemeChromiumDefault::paintSliderTrack(RenderObject* o, const PaintIn fo& i, const IntRect& rect) 499 bool RenderThemeChromiumDefault::paintSliderTrack(RenderObject* o, const PaintIn fo& i, const IntRect& rect)
331 { 500 {
332 WebKit::WebThemeEngine::ExtraParams extraParams; 501 WebKit::WebThemeEngine::ExtraParams extraParams;
333 WebKit::WebCanvas* canvas = i.context->canvas(); 502 WebKit::WebCanvas* canvas = i.context->canvas();
334 extraParams.slider.vertical = o->style()->appearance() == SliderVerticalPart ; 503 extraParams.slider.vertical = o->style()->appearance() == SliderVerticalPart ;
335 504
336 paintSliderTicks(o, i, rect); 505 paintSliderTicks(o, i, rect);
337 506
507 if (isRunningLayoutTest()) {
508 ThemePainter painter(i.context, rect);
509 WebKit::Platform::current()->themeEngine()->paint(painter.canvas(), WebK it::WebThemeEngine::PartSliderTrack, getWebThemeState(this, o), WebKit::WebRect( painter.drawRect()), &extraParams);
510 painter.composite();
511 return false;
512 }
513
338 float zoomLevel = o->style()->effectiveZoom(); 514 float zoomLevel = o->style()->effectiveZoom();
339 GraphicsContextStateSaver stateSaver(*i.context); 515 GraphicsContextStateSaver stateSaver(*i.context);
340 IntRect unzoomedRect = rect; 516 IntRect unzoomedRect = rect;
341 if (zoomLevel != 1) { 517 if (zoomLevel != 1) {
342 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 518 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
343 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 519 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
344 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 520 i.context->translate(unzoomedRect.x(), unzoomedRect.y());
345 i.context->scale(FloatSize(zoomLevel, zoomLevel)); 521 i.context->scale(FloatSize(zoomLevel, zoomLevel));
346 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 522 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
347 } 523 }
348 524
349 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartSliderTrack, getWebThemeState(this, o), WebKit::WebRect(unzoomedRect), &extraParams); 525 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartSliderTrack, getWebThemeState(this, o), WebKit::WebRect(unzoomedRect), &extraParams);
350 526
351 return false; 527 return false;
352 } 528 }
353 529
354 bool RenderThemeChromiumDefault::paintSliderThumb(RenderObject* o, const PaintIn fo& i, const IntRect& rect) 530 bool RenderThemeChromiumDefault::paintSliderThumb(RenderObject* o, const PaintIn fo& i, const IntRect& rect)
355 { 531 {
356 WebKit::WebThemeEngine::ExtraParams extraParams; 532 WebKit::WebThemeEngine::ExtraParams extraParams;
357 WebKit::WebCanvas* canvas = i.context->canvas(); 533 WebKit::WebCanvas* canvas = i.context->canvas();
358 extraParams.slider.vertical = o->style()->appearance() == SliderThumbVertica lPart; 534 extraParams.slider.vertical = o->style()->appearance() == SliderThumbVertica lPart;
359 extraParams.slider.inDrag = isPressed(o); 535 extraParams.slider.inDrag = isPressed(o);
360 536
537 if (isRunningLayoutTest()) {
538 ThemePainter painter(i.context, rect);
539 WebKit::Platform::current()->themeEngine()->paint(painter.canvas(),
540 WebKit::WebThemeEngine::PartSliderThumb, getWebThemeState(this, o), WebKit::WebRect(painter.drawRect()), &extraParams);
541 painter.composite();
542 return false;
543 }
544
361 float zoomLevel = o->style()->effectiveZoom(); 545 float zoomLevel = o->style()->effectiveZoom();
362 GraphicsContextStateSaver stateSaver(*i.context); 546 GraphicsContextStateSaver stateSaver(*i.context);
363 IntRect unzoomedRect = rect; 547 IntRect unzoomedRect = rect;
364 if (zoomLevel != 1) { 548 if (zoomLevel != 1) {
365 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 549 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
366 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 550 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
367 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 551 i.context->translate(unzoomedRect.x(), unzoomedRect.y());
368 i.context->scale(FloatSize(zoomLevel, zoomLevel)); 552 i.context->scale(FloatSize(zoomLevel, zoomLevel));
369 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 553 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
370 } 554 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 WebKit::WebCanvas* canvas = i.context->canvas(); 595 WebKit::WebCanvas* canvas = i.context->canvas();
412 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartProgressBar, getWebThemeState(this, o), WebKit::WebRect(rect), &extraP arams); 596 WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEn gine::PartProgressBar, getWebThemeState(this, o), WebKit::WebRect(rect), &extraP arams);
413 return false; 597 return false;
414 } 598 }
415 599
416 bool RenderThemeChromiumDefault::shouldOpenPickerWithF4Key() const 600 bool RenderThemeChromiumDefault::shouldOpenPickerWithF4Key() const
417 { 601 {
418 return true; 602 return true;
419 } 603 }
420 604
605 bool RenderThemeChromiumDefault::shouldUseFallbackTheme(RenderStyle* style) cons t
606 {
607 if (isRunningLayoutTest()) {
608 // The mock theme can't handle zoomed controls, so we fall back to the " fallback" theme.
609 ControlPart part = style->appearance();
610 if (part == CheckboxPart || part == RadioPart)
611 return style->effectiveZoom() != 1;
612 }
613 return RenderTheme::shouldUseFallbackTheme(style);
614 }
615
421 } // namespace WebCore 616 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698