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

Side by Side Diff: third_party/WebKit/Source/core/paint/ThemePainterDefault.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 * 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 bool m_needsFlipping; 74 bool m_needsFlipping;
75 const PaintInfo& m_paintInfo; 75 const PaintInfo& m_paintInfo;
76 }; 76 };
77 77
78 DirectionFlippingScope::DirectionFlippingScope(const LayoutObject& layoutObject, const PaintInfo& paintInfo, const IntRect& rect) 78 DirectionFlippingScope::DirectionFlippingScope(const LayoutObject& layoutObject, const PaintInfo& paintInfo, const IntRect& rect)
79 : m_needsFlipping(!layoutObject.styleRef().isLeftToRightDirection()) 79 : m_needsFlipping(!layoutObject.styleRef().isLeftToRightDirection())
80 , m_paintInfo(paintInfo) 80 , m_paintInfo(paintInfo)
81 { 81 {
82 if (!m_needsFlipping) 82 if (!m_needsFlipping)
83 return; 83 return;
84 m_paintInfo.context->save(); 84 m_paintInfo.context.save();
85 m_paintInfo.context->translate(2 * rect.x() + rect.width(), 0); 85 m_paintInfo.context.translate(2 * rect.x() + rect.width(), 0);
86 m_paintInfo.context->scale(-1, 1); 86 m_paintInfo.context.scale(-1, 1);
87 } 87 }
88 88
89 DirectionFlippingScope::~DirectionFlippingScope() 89 DirectionFlippingScope::~DirectionFlippingScope()
90 { 90 {
91 if (!m_needsFlipping) 91 if (!m_needsFlipping)
92 return; 92 return;
93 m_paintInfo.context->restore(); 93 m_paintInfo.context.restore();
94 } 94 }
95 95
96 IntRect determinateProgressValueRectFor(const LayoutProgress& layoutProgress, co nst IntRect& rect) 96 IntRect determinateProgressValueRectFor(const LayoutProgress& layoutProgress, co nst IntRect& rect)
97 { 97 {
98 int dx = rect.width() * layoutProgress.position(); 98 int dx = rect.width() * layoutProgress.position();
99 return IntRect(rect.x(), rect.y(), dx, rect.height()); 99 return IntRect(rect.x(), rect.y(), dx, rect.height());
100 } 100 }
101 101
102 IntRect indeterminateProgressValueRectFor(const LayoutProgress& layoutProgress, const IntRect& rect) 102 IntRect indeterminateProgressValueRectFor(const LayoutProgress& layoutProgress, const IntRect& rect)
103 { 103 {
(...skipping 26 matching lines...) Expand all
130 partRect.move(localOffset.x(), localOffset.y()); 130 partRect.move(localOffset.x(), localOffset.y());
131 131
132 return pixelSnappedIntRect(partRect); 132 return pixelSnappedIntRect(partRect);
133 } 133 }
134 134
135 } // namespace 135 } // namespace
136 136
137 bool ThemePainterDefault::paintCheckbox(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 137 bool ThemePainterDefault::paintCheckbox(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
138 { 138 {
139 WebThemeEngine::ExtraParams extraParams; 139 WebThemeEngine::ExtraParams extraParams;
140 WebCanvas* canvas = i.context->canvas(); 140 WebCanvas* canvas = i.context.canvas();
141 extraParams.button.checked = LayoutTheme::isChecked(o); 141 extraParams.button.checked = LayoutTheme::isChecked(o);
142 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o); 142 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o);
143 143
144 float zoomLevel = o.styleRef().effectiveZoom(); 144 float zoomLevel = o.styleRef().effectiveZoom();
145 GraphicsContextStateSaver stateSaver(*i.context, false); 145 GraphicsContextStateSaver stateSaver(i.context, false);
146 IntRect unzoomedRect = rect; 146 IntRect unzoomedRect = rect;
147 if (zoomLevel != 1) { 147 if (zoomLevel != 1) {
148 stateSaver.save(); 148 stateSaver.save();
149 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 149 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
150 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 150 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
151 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 151 i.context.translate(unzoomedRect.x(), unzoomedRect.y());
152 i.context->scale(zoomLevel, zoomLevel); 152 i.context.scale(zoomLevel, zoomLevel);
153 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 153 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y());
154 } 154 }
155 155
156 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartCheckb ox, getWebThemeState(o), WebRect(unzoomedRect), &extraParams); 156 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartCheckb ox, getWebThemeState(o), WebRect(unzoomedRect), &extraParams);
157 return false; 157 return false;
158 } 158 }
159 159
160 bool ThemePainterDefault::paintRadio(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 160 bool ThemePainterDefault::paintRadio(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
161 { 161 {
162 WebThemeEngine::ExtraParams extraParams; 162 WebThemeEngine::ExtraParams extraParams;
163 WebCanvas* canvas = i.context->canvas(); 163 WebCanvas* canvas = i.context.canvas();
164 extraParams.button.checked = LayoutTheme::isChecked(o); 164 extraParams.button.checked = LayoutTheme::isChecked(o);
165 165
166 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartRadio, getWebThemeState(o), WebRect(rect), &extraParams); 166 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartRadio, getWebThemeState(o), WebRect(rect), &extraParams);
167 return false; 167 return false;
168 } 168 }
169 169
170 bool ThemePainterDefault::paintButton(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 170 bool ThemePainterDefault::paintButton(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
171 { 171 {
172 WebThemeEngine::ExtraParams extraParams; 172 WebThemeEngine::ExtraParams extraParams;
173 WebCanvas* canvas = i.context->canvas(); 173 WebCanvas* canvas = i.context.canvas();
174 extraParams.button.hasBorder = true; 174 extraParams.button.hasBorder = true;
175 extraParams.button.backgroundColor = useMockTheme() ? 0xffc0c0c0 : defaultBu ttonBackgroundColor; 175 extraParams.button.backgroundColor = useMockTheme() ? 0xffc0c0c0 : defaultBu ttonBackgroundColor;
176 if (o.hasBackground()) 176 if (o.hasBackground())
177 extraParams.button.backgroundColor = o.resolveColor(CSSPropertyBackgroun dColor).rgb(); 177 extraParams.button.backgroundColor = o.resolveColor(CSSPropertyBackgroun dColor).rgb();
178 178
179 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartButton , getWebThemeState(o), WebRect(rect), &extraParams); 179 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartButton , getWebThemeState(o), WebRect(rect), &extraParams);
180 return false; 180 return false;
181 } 181 }
182 182
183 bool ThemePainterDefault::paintTextField(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 183 bool ThemePainterDefault::paintTextField(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
184 { 184 {
185 // WebThemeEngine does not handle border rounded corner and background image 185 // WebThemeEngine does not handle border rounded corner and background image
186 // so return true to draw CSS border and background. 186 // so return true to draw CSS border and background.
187 if (o.styleRef().hasBorderRadius() || o.styleRef().hasBackgroundImage()) 187 if (o.styleRef().hasBorderRadius() || o.styleRef().hasBackgroundImage())
188 return true; 188 return true;
189 189
190 ControlPart part = o.styleRef().appearance(); 190 ControlPart part = o.styleRef().appearance();
191 191
192 WebThemeEngine::ExtraParams extraParams; 192 WebThemeEngine::ExtraParams extraParams;
193 extraParams.textField.isTextArea = part == TextAreaPart; 193 extraParams.textField.isTextArea = part == TextAreaPart;
194 extraParams.textField.isListbox = part == ListboxPart; 194 extraParams.textField.isListbox = part == ListboxPart;
195 195
196 WebCanvas* canvas = i.context->canvas(); 196 WebCanvas* canvas = i.context.canvas();
197 197
198 Color backgroundColor = o.resolveColor(CSSPropertyBackgroundColor); 198 Color backgroundColor = o.resolveColor(CSSPropertyBackgroundColor);
199 extraParams.textField.backgroundColor = backgroundColor.rgb(); 199 extraParams.textField.backgroundColor = backgroundColor.rgb();
200 200
201 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartTextFi eld, getWebThemeState(o), WebRect(rect), &extraParams); 201 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartTextFi eld, getWebThemeState(o), WebRect(rect), &extraParams);
202 return false; 202 return false;
203 } 203 }
204 204
205 bool ThemePainterDefault::paintMenuList(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) 205 bool ThemePainterDefault::paintMenuList(const LayoutObject& o, const PaintInfo& i, const IntRect& rect)
206 { 206 {
(...skipping 13 matching lines...) Expand all
220 220
221 // If we have a background image, don't fill the content area to expose the 221 // If we have a background image, don't fill the content area to expose the
222 // parent's background. Also, we shouldn't fill the content area if the 222 // parent's background. Also, we shouldn't fill the content area if the
223 // alpha of the color is 0. The API of Windows GDI ignores the alpha. 223 // alpha of the color is 0. The API of Windows GDI ignores the alpha.
224 // FIXME: the normal Aura theme doesn't care about this, so we should 224 // FIXME: the normal Aura theme doesn't care about this, so we should
225 // investigate if we really need fillContentArea. 225 // investigate if we really need fillContentArea.
226 extraParams.menuList.fillContentArea = !o.styleRef().hasBackgroundImage() && backgroundColor.alpha(); 226 extraParams.menuList.fillContentArea = !o.styleRef().hasBackgroundImage() && backgroundColor.alpha();
227 227
228 setupMenuListArrow(box, rect, extraParams); 228 setupMenuListArrow(box, rect, extraParams);
229 229
230 WebCanvas* canvas = i.context->canvas(); 230 WebCanvas* canvas = i.context.canvas();
231 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartMenuLi st, getWebThemeState(o), WebRect(rect), &extraParams); 231 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartMenuLi st, getWebThemeState(o), WebRect(rect), &extraParams);
232 return false; 232 return false;
233 } 233 }
234 234
235 bool ThemePainterDefault::paintMenuListButton(const LayoutObject& o, const Paint Info& i, const IntRect& rect) 235 bool ThemePainterDefault::paintMenuListButton(const LayoutObject& o, const Paint Info& i, const IntRect& rect)
236 { 236 {
237 if (!o.isBox()) 237 if (!o.isBox())
238 return false; 238 return false;
239 239
240 WebThemeEngine::ExtraParams extraParams; 240 WebThemeEngine::ExtraParams extraParams;
241 extraParams.menuList.hasBorder = false; 241 extraParams.menuList.hasBorder = false;
242 extraParams.menuList.hasBorderRadius = o.styleRef().hasBorderRadius(); 242 extraParams.menuList.hasBorderRadius = o.styleRef().hasBorderRadius();
243 extraParams.menuList.backgroundColor = Color::transparent; 243 extraParams.menuList.backgroundColor = Color::transparent;
244 extraParams.menuList.fillContentArea = false; 244 extraParams.menuList.fillContentArea = false;
245 setupMenuListArrow(toLayoutBox(o), rect, extraParams); 245 setupMenuListArrow(toLayoutBox(o), rect, extraParams);
246 246
247 WebCanvas* canvas = i.context->canvas(); 247 WebCanvas* canvas = i.context.canvas();
248 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartMenuLi st, getWebThemeState(o), WebRect(rect), &extraParams); 248 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartMenuLi st, getWebThemeState(o), WebRect(rect), &extraParams);
249 return false; 249 return false;
250 } 250 }
251 251
252 void ThemePainterDefault::setupMenuListArrow(const LayoutBox& box, const IntRect & rect, WebThemeEngine::ExtraParams& extraParams) 252 void ThemePainterDefault::setupMenuListArrow(const LayoutBox& box, const IntRect & rect, WebThemeEngine::ExtraParams& extraParams)
253 { 253 {
254 const int right = rect.x() + rect.width(); 254 const int right = rect.x() + rect.width();
255 const int middle = rect.y() + rect.height() / 2; 255 const int middle = rect.y() + rect.height() / 2;
256 256
257 extraParams.menuList.arrowY = middle; 257 extraParams.menuList.arrowY = middle;
(...skipping 12 matching lines...) Expand all
270 ? rect.x() + arrowPadding * box.styleRef().effectiveZoom() 270 ? rect.x() + arrowPadding * box.styleRef().effectiveZoom()
271 : right - (arrowSize + arrowPadding) * box.styleRef().effectiveZoom( ); 271 : right - (arrowSize + arrowPadding) * box.styleRef().effectiveZoom( );
272 extraParams.menuList.arrowSize = arrowSize * box.styleRef().effectiveZoo m(); 272 extraParams.menuList.arrowSize = arrowSize * box.styleRef().effectiveZoo m();
273 } 273 }
274 extraParams.menuList.arrowColor = box.resolveColor(CSSPropertyColor).rgb(); 274 extraParams.menuList.arrowColor = box.resolveColor(CSSPropertyColor).rgb();
275 } 275 }
276 276
277 bool ThemePainterDefault::paintSliderTrack(const LayoutObject& o, const PaintInf o& i, const IntRect& rect) 277 bool ThemePainterDefault::paintSliderTrack(const LayoutObject& o, const PaintInf o& i, const IntRect& rect)
278 { 278 {
279 WebThemeEngine::ExtraParams extraParams; 279 WebThemeEngine::ExtraParams extraParams;
280 WebCanvas* canvas = i.context->canvas(); 280 WebCanvas* canvas = i.context.canvas();
281 extraParams.slider.vertical = o.styleRef().appearance() == SliderVerticalPar t; 281 extraParams.slider.vertical = o.styleRef().appearance() == SliderVerticalPar t;
282 282
283 paintSliderTicks(o, i, rect); 283 paintSliderTicks(o, i, rect);
284 284
285 // FIXME: Mock theme doesn't handle zoomed sliders. 285 // FIXME: Mock theme doesn't handle zoomed sliders.
286 float zoomLevel = useMockTheme() ? 1 : o.styleRef().effectiveZoom(); 286 float zoomLevel = useMockTheme() ? 1 : o.styleRef().effectiveZoom();
287 GraphicsContextStateSaver stateSaver(*i.context, false); 287 GraphicsContextStateSaver stateSaver(i.context, false);
288 IntRect unzoomedRect = rect; 288 IntRect unzoomedRect = rect;
289 if (zoomLevel != 1) { 289 if (zoomLevel != 1) {
290 stateSaver.save(); 290 stateSaver.save();
291 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 291 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
292 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 292 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
293 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 293 i.context.translate(unzoomedRect.x(), unzoomedRect.y());
294 i.context->scale(zoomLevel, zoomLevel); 294 i.context.scale(zoomLevel, zoomLevel);
295 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 295 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y());
296 } 296 }
297 297
298 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartSlider Track, getWebThemeState(o), WebRect(unzoomedRect), &extraParams); 298 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartSlider Track, getWebThemeState(o), WebRect(unzoomedRect), &extraParams);
299 299
300 return false; 300 return false;
301 } 301 }
302 302
303 bool ThemePainterDefault::paintSliderThumb(const LayoutObject& o, const PaintInf o& i, const IntRect& rect) 303 bool ThemePainterDefault::paintSliderThumb(const LayoutObject& o, const PaintInf o& i, const IntRect& rect)
304 { 304 {
305 WebThemeEngine::ExtraParams extraParams; 305 WebThemeEngine::ExtraParams extraParams;
306 WebCanvas* canvas = i.context->canvas(); 306 WebCanvas* canvas = i.context.canvas();
307 extraParams.slider.vertical = o.styleRef().appearance() == SliderThumbVertic alPart; 307 extraParams.slider.vertical = o.styleRef().appearance() == SliderThumbVertic alPart;
308 extraParams.slider.inDrag = LayoutTheme::isPressed(o); 308 extraParams.slider.inDrag = LayoutTheme::isPressed(o);
309 309
310 // FIXME: Mock theme doesn't handle zoomed sliders. 310 // FIXME: Mock theme doesn't handle zoomed sliders.
311 float zoomLevel = useMockTheme() ? 1 : o.styleRef().effectiveZoom(); 311 float zoomLevel = useMockTheme() ? 1 : o.styleRef().effectiveZoom();
312 GraphicsContextStateSaver stateSaver(*i.context, false); 312 GraphicsContextStateSaver stateSaver(i.context, false);
313 IntRect unzoomedRect = rect; 313 IntRect unzoomedRect = rect;
314 if (zoomLevel != 1) { 314 if (zoomLevel != 1) {
315 stateSaver.save(); 315 stateSaver.save();
316 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 316 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
317 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 317 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
318 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 318 i.context.translate(unzoomedRect.x(), unzoomedRect.y());
319 i.context->scale(zoomLevel, zoomLevel); 319 i.context.scale(zoomLevel, zoomLevel);
320 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 320 i.context.translate(-unzoomedRect.x(), -unzoomedRect.y());
321 } 321 }
322 322
323 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartSlider Thumb, getWebThemeState(o), WebRect(unzoomedRect), &extraParams); 323 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartSlider Thumb, getWebThemeState(o), WebRect(unzoomedRect), &extraParams);
324 return false; 324 return false;
325 } 325 }
326 326
327 bool ThemePainterDefault::paintInnerSpinButton(const LayoutObject& o, const Pain tInfo& i, const IntRect& rect) 327 bool ThemePainterDefault::paintInnerSpinButton(const LayoutObject& o, const Pain tInfo& i, const IntRect& rect)
328 { 328 {
329 WebThemeEngine::ExtraParams extraParams; 329 WebThemeEngine::ExtraParams extraParams;
330 WebCanvas* canvas = i.context->canvas(); 330 WebCanvas* canvas = i.context.canvas();
331 extraParams.innerSpin.spinUp = (LayoutTheme::controlStatesForLayoutObject(o) & SpinUpControlState); 331 extraParams.innerSpin.spinUp = (LayoutTheme::controlStatesForLayoutObject(o) & SpinUpControlState);
332 extraParams.innerSpin.readOnly = LayoutTheme::isReadOnlyControl(o); 332 extraParams.innerSpin.readOnly = LayoutTheme::isReadOnlyControl(o);
333 333
334 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartInnerS pinButton, getWebThemeState(o), WebRect(rect), &extraParams); 334 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartInnerS pinButton, getWebThemeState(o), WebRect(rect), &extraParams);
335 return false; 335 return false;
336 } 336 }
337 337
338 bool ThemePainterDefault::paintProgressBar(const LayoutObject& o, const PaintInf o& i, const IntRect& rect) 338 bool ThemePainterDefault::paintProgressBar(const LayoutObject& o, const PaintInf o& i, const IntRect& rect)
339 { 339 {
340 if (!o.isProgress()) 340 if (!o.isProgress())
341 return true; 341 return true;
342 342
343 const LayoutProgress& layoutProgress = toLayoutProgress(o); 343 const LayoutProgress& layoutProgress = toLayoutProgress(o);
344 IntRect valueRect = progressValueRectFor(layoutProgress, rect); 344 IntRect valueRect = progressValueRectFor(layoutProgress, rect);
345 345
346 WebThemeEngine::ExtraParams extraParams; 346 WebThemeEngine::ExtraParams extraParams;
347 extraParams.progressBar.determinate = layoutProgress.isDeterminate(); 347 extraParams.progressBar.determinate = layoutProgress.isDeterminate();
348 extraParams.progressBar.valueRectX = valueRect.x(); 348 extraParams.progressBar.valueRectX = valueRect.x();
349 extraParams.progressBar.valueRectY = valueRect.y(); 349 extraParams.progressBar.valueRectY = valueRect.y();
350 extraParams.progressBar.valueRectWidth = valueRect.width(); 350 extraParams.progressBar.valueRectWidth = valueRect.width();
351 extraParams.progressBar.valueRectHeight = valueRect.height(); 351 extraParams.progressBar.valueRectHeight = valueRect.height();
352 352
353 DirectionFlippingScope scope(o, i, rect); 353 DirectionFlippingScope scope(o, i, rect);
354 WebCanvas* canvas = i.context->canvas(); 354 WebCanvas* canvas = i.context.canvas();
355 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartProgre ssBar, getWebThemeState(o), WebRect(rect), &extraParams); 355 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartProgre ssBar, getWebThemeState(o), WebRect(rect), &extraParams);
356 return false; 356 return false;
357 } 357 }
358 358
359 bool ThemePainterDefault::paintTextArea(const LayoutObject& o, const PaintInfo& i, const IntRect& r) 359 bool ThemePainterDefault::paintTextArea(const LayoutObject& o, const PaintInfo& i, const IntRect& r)
360 { 360 {
361 return paintTextField(o, i, r); 361 return paintTextField(o, i, r);
362 } 362 }
363 363
364 bool ThemePainterDefault::paintSearchField(const LayoutObject& o, const PaintInf o& i, const IntRect& r) 364 bool ThemePainterDefault::paintSearchField(const LayoutObject& o, const PaintInf o& i, const IntRect& r)
(...skipping 18 matching lines...) Expand all
383 // Calculate cancel button's coordinates relative to the input element. 383 // Calculate cancel button's coordinates relative to the input element.
384 // Center the button vertically. Round up though, so if it has to be one pi xel off-center, it will 384 // Center the button vertically. Round up though, so if it has to be one pi xel off-center, it will
385 // be one pixel closer to the bottom of the field. This tends to look bette r with the text. 385 // be one pixel closer to the bottom of the field. This tends to look bette r with the text.
386 LayoutRect cancelButtonRect(cancelButtonObject.offsetFromAncestorContainer(& inputLayoutBox).width(), 386 LayoutRect cancelButtonRect(cancelButtonObject.offsetFromAncestorContainer(& inputLayoutBox).width(),
387 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2, 387 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
388 cancelButtonSize, cancelButtonSize); 388 cancelButtonSize, cancelButtonSize);
389 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj ect, cancelButtonRect, r); 389 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj ect, cancelButtonRect, r);
390 390
391 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa ncel"))); 391 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa ncel")));
392 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s earchCancelPressed"))); 392 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s earchCancelPressed")));
393 paintInfo.context->drawImage(LayoutTheme::isPressed(cancelButtonObject) ? ca ncelPressedImage : cancelImage, paintingRect); 393 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) ? can celPressedImage : cancelImage, paintingRect);
394 return false; 394 return false;
395 } 395 }
396 396
397 bool ThemePainterDefault::paintSearchFieldResultsDecoration(const LayoutObject& magnifierObject, const PaintInfo& paintInfo, const IntRect& r) 397 bool ThemePainterDefault::paintSearchFieldResultsDecoration(const LayoutObject& magnifierObject, const PaintInfo& paintInfo, const IntRect& r)
398 { 398 {
399 // Get the layoutObject of <input> element. 399 // Get the layoutObject of <input> element.
400 if (!magnifierObject.node()) 400 if (!magnifierObject.node())
401 return false; 401 return false;
402 Node* input = magnifierObject.node()->shadowHost(); 402 Node* input = magnifierObject.node()->shadowHost();
403 const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : magn ifierObject; 403 const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : magn ifierObject;
404 if (!baseLayoutObject.isBox()) 404 if (!baseLayoutObject.isBox())
405 return false; 405 return false;
406 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); 406 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject);
407 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); 407 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect();
408 408
409 // Make sure the scaled decoration stays square and will fit in its parent's box. 409 // Make sure the scaled decoration stays square and will fit in its parent's box.
410 LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<Layout Unit>(inputContentBox.height(), r.height())); 410 LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<Layout Unit>(inputContentBox.height(), r.height()));
411 // Calculate decoration's coordinates relative to the input element. 411 // Calculate decoration's coordinates relative to the input element.
412 // Center the decoration vertically. Round up though, so if it has to be on e pixel off-center, it will 412 // Center the decoration vertically. Round up though, so if it has to be on e pixel off-center, it will
413 // be one pixel closer to the bottom of the field. This tends to look bette r with the text. 413 // be one pixel closer to the bottom of the field. This tends to look bette r with the text.
414 LayoutRect magnifierRect(magnifierObject.offsetFromAncestorContainer(&inputL ayoutBox).width(), 414 LayoutRect magnifierRect(magnifierObject.offsetFromAncestorContainer(&inputL ayoutBox).width(),
415 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2 , 415 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2 ,
416 magnifierSize, magnifierSize); 416 magnifierSize, magnifierSize);
417 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, magnifierObject , magnifierRect, r); 417 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, magnifierObject , magnifierRect, r);
418 418
419 DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searc hMagnifier"))); 419 DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searc hMagnifier")));
420 paintInfo.context->drawImage(magnifierImage, paintingRect); 420 paintInfo.context.drawImage(magnifierImage, paintingRect);
421 return false; 421 return false;
422 } 422 }
423 423
424 } // namespace blink 424 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ThemePainter.cpp ('k') | third_party/WebKit/Source/core/paint/ThemePainterMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698