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

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

Issue 1690493002: Switch to LayoutThemeMobile when emulating mobile device in DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more mac compile Created 4 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
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 23 matching lines...) Expand all
34 #include "platform/graphics/GraphicsContext.h" 34 #include "platform/graphics/GraphicsContext.h"
35 #include "platform/graphics/GraphicsContextStateSaver.h" 35 #include "platform/graphics/GraphicsContextStateSaver.h"
36 #include "public/platform/Platform.h" 36 #include "public/platform/Platform.h"
37 #include "public/platform/WebRect.h" 37 #include "public/platform/WebRect.h"
38 #include "public/platform/WebThemeEngine.h" 38 #include "public/platform/WebThemeEngine.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 namespace { 42 namespace {
43 43
44 #if !USE(NEW_THEME)
44 const unsigned defaultButtonBackgroundColor = 0xffdddddd; 45 const unsigned defaultButtonBackgroundColor = 0xffdddddd;
46 #endif
45 47
46 bool useMockTheme() 48 bool useMockTheme()
47 { 49 {
48 return LayoutTestSupport::isMockThemeEnabledForTest(); 50 return LayoutTestSupport::isMockThemeEnabledForTest();
49 } 51 }
50 52
51 WebThemeEngine::State getWebThemeState(const LayoutObject& o) 53 WebThemeEngine::State getWebThemeState(const LayoutObject& o)
52 { 54 {
53 if (!LayoutTheme::isEnabled(o)) 55 if (!LayoutTheme::isEnabled(o))
54 return WebThemeEngine::StateDisabled; 56 return WebThemeEngine::StateDisabled;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Move the rect into partLayoutObject's coords. 128 // Move the rect into partLayoutObject's coords.
127 partRect.move(offsetFromInputLayoutObject); 129 partRect.move(offsetFromInputLayoutObject);
128 // Account for the local drawing offset. 130 // Account for the local drawing offset.
129 partRect.move(localOffset.x(), localOffset.y()); 131 partRect.move(localOffset.x(), localOffset.y());
130 132
131 return pixelSnappedIntRect(partRect); 133 return pixelSnappedIntRect(partRect);
132 } 134 }
133 135
134 } // namespace 136 } // namespace
135 137
138 #if !USE(NEW_THEME)
136 bool ThemePainterDefault::paintCheckbox(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 139 bool ThemePainterDefault::paintCheckbox(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
137 { 140 {
138 WebThemeEngine::ExtraParams extraParams; 141 WebThemeEngine::ExtraParams extraParams;
139 WebCanvas* canvas = i.context.canvas(); 142 WebCanvas* canvas = i.context.canvas();
140 extraParams.button.checked = LayoutTheme::isChecked(o); 143 extraParams.button.checked = LayoutTheme::isChecked(o);
141 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o); 144 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o);
142 145
143 float zoomLevel = o.styleRef().effectiveZoom(); 146 float zoomLevel = o.styleRef().effectiveZoom();
144 GraphicsContextStateSaver stateSaver(i.context, false); 147 GraphicsContextStateSaver stateSaver(i.context, false);
145 IntRect unzoomedRect = rect; 148 IntRect unzoomedRect = rect;
146 if (zoomLevel != 1) { 149 if (zoomLevel != 1) {
147 stateSaver.save(); 150 stateSaver.save();
148 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 151 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
149 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 152 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
150 i.context.translate(unzoomedRect.x(), unzoomedRect.y()); 153 i.context.translate(unzoomedRect.x(), unzoomedRect.y());
151 i.context.scale(zoomLevel, zoomLevel); 154 i.context.scale(zoomLevel, zoomLevel);
152 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y()); 155 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y());
153 } 156 }
154 157
155 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartCheckb ox, getWebThemeState(o), WebRect(unzoomedRect), &extraParams); 158 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartCheckb ox, getWebThemeState(o), WebRect(unzoomedRect), &extraParams);
156 return false; 159 return false;
157 } 160 }
161 #endif // !USE(NEW_THEME)
158 162
163 #if !USE(NEW_THEME)
159 bool ThemePainterDefault::paintRadio(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 164 bool ThemePainterDefault::paintRadio(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
160 { 165 {
161 WebThemeEngine::ExtraParams extraParams; 166 WebThemeEngine::ExtraParams extraParams;
162 WebCanvas* canvas = i.context.canvas(); 167 WebCanvas* canvas = i.context.canvas();
163 extraParams.button.checked = LayoutTheme::isChecked(o); 168 extraParams.button.checked = LayoutTheme::isChecked(o);
164 169
165 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartRadio, getWebThemeState(o), WebRect(rect), &extraParams); 170 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartRadio, getWebThemeState(o), WebRect(rect), &extraParams);
166 return false; 171 return false;
167 } 172 }
173 #endif // !USE(NEW_THEME)
168 174
175 #if !USE(NEW_THEME)
169 bool ThemePainterDefault::paintButton(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 176 bool ThemePainterDefault::paintButton(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
170 { 177 {
171 WebThemeEngine::ExtraParams extraParams; 178 WebThemeEngine::ExtraParams extraParams;
172 WebCanvas* canvas = i.context.canvas(); 179 WebCanvas* canvas = i.context.canvas();
173 extraParams.button.hasBorder = true; 180 extraParams.button.hasBorder = true;
174 extraParams.button.backgroundColor = useMockTheme() ? 0xffc0c0c0 : defaultBu ttonBackgroundColor; 181 extraParams.button.backgroundColor = useMockTheme() ? 0xffc0c0c0 : defaultBu ttonBackgroundColor;
175 if (o.hasBackground()) 182 if (o.hasBackground())
176 extraParams.button.backgroundColor = o.resolveColor(CSSPropertyBackgroun dColor).rgb(); 183 extraParams.button.backgroundColor = o.resolveColor(CSSPropertyBackgroun dColor).rgb();
177 184
178 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartButton , getWebThemeState(o), WebRect(rect), &extraParams); 185 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartButton , getWebThemeState(o), WebRect(rect), &extraParams);
179 return false; 186 return false;
180 } 187 }
188 #endif // !USE(NEW_THEME)
181 189
182 bool ThemePainterDefault::paintTextField(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 190 bool ThemePainterDefault::paintTextField(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
183 { 191 {
184 // WebThemeEngine does not handle border rounded corner and background image 192 // WebThemeEngine does not handle border rounded corner and background image
185 // so return true to draw CSS border and background. 193 // so return true to draw CSS border and background.
186 if (o.styleRef().hasBorderRadius() || o.styleRef().hasBackgroundImage()) 194 if (o.styleRef().hasBorderRadius() || o.styleRef().hasBackgroundImage())
187 return true; 195 return true;
188 196
189 ControlPart part = o.styleRef().appearance(); 197 ControlPart part = o.styleRef().appearance();
190 198
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 324 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
317 i.context.translate(unzoomedRect.x(), unzoomedRect.y()); 325 i.context.translate(unzoomedRect.x(), unzoomedRect.y());
318 i.context.scale(zoomLevel, zoomLevel); 326 i.context.scale(zoomLevel, zoomLevel);
319 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y()); 327 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y());
320 } 328 }
321 329
322 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartSlider Thumb, getWebThemeState(o), WebRect(unzoomedRect), &extraParams); 330 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartSlider Thumb, getWebThemeState(o), WebRect(unzoomedRect), &extraParams);
323 return false; 331 return false;
324 } 332 }
325 333
334 #if !USE(NEW_THEME)
326 bool ThemePainterDefault::paintInnerSpinButton(const LayoutObject& o, const Pain tInfo& i, const IntRect& rect) 335 bool ThemePainterDefault::paintInnerSpinButton(const LayoutObject& o, const Pain tInfo& i, const IntRect& rect)
327 { 336 {
328 WebThemeEngine::ExtraParams extraParams; 337 WebThemeEngine::ExtraParams extraParams;
329 WebCanvas* canvas = i.context.canvas(); 338 WebCanvas* canvas = i.context.canvas();
330 extraParams.innerSpin.spinUp = (LayoutTheme::controlStatesForLayoutObject(o) & SpinUpControlState); 339 extraParams.innerSpin.spinUp = (LayoutTheme::controlStatesForLayoutObject(o) & SpinUpControlState);
331 extraParams.innerSpin.readOnly = LayoutTheme::isReadOnlyControl(o); 340 extraParams.innerSpin.readOnly = LayoutTheme::isReadOnlyControl(o);
332 341
333 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartInnerS pinButton, getWebThemeState(o), WebRect(rect), &extraParams); 342 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartInnerS pinButton, getWebThemeState(o), WebRect(rect), &extraParams);
334 return false; 343 return false;
335 } 344 }
345 #endif // !USE(NEW_THEME)
336 346
337 bool ThemePainterDefault::paintProgressBar(const LayoutObject& o, const PaintInf o& i, const IntRect& rect) 347 bool ThemePainterDefault::paintProgressBar(const LayoutObject& o, const PaintInf o& i, const IntRect& rect)
338 { 348 {
339 if (!o.isProgress()) 349 if (!o.isProgress())
340 return true; 350 return true;
341 351
342 const LayoutProgress& layoutProgress = toLayoutProgress(o); 352 const LayoutProgress& layoutProgress = toLayoutProgress(o);
343 IntRect valueRect = progressValueRectFor(layoutProgress, rect); 353 IntRect valueRect = progressValueRectFor(layoutProgress, rect);
344 354
345 WebThemeEngine::ExtraParams extraParams; 355 WebThemeEngine::ExtraParams extraParams;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2 , 424 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2 ,
415 magnifierSize, magnifierSize); 425 magnifierSize, magnifierSize);
416 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, magnifierObject , magnifierRect, r); 426 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, magnifierObject , magnifierRect, r);
417 427
418 DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searc hMagnifier"))); 428 DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searc hMagnifier")));
419 paintInfo.context.drawImage(magnifierImage, paintingRect); 429 paintInfo.context.drawImage(magnifierImage, paintingRect);
420 return false; 430 return false;
421 } 431 }
422 432
423 } // namespace blink 433 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698