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

Side by Side Diff: third_party/WebKit/Source/core/paint/ThemePainterMac.mm

Issue 2331443002: Mac: adjust sizes of progress bars to be equal to painted size. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeMac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google, Inc. 3 * Copyright (C) 2008, 2009 Google, Inc.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 [popupButton setControlView:nil]; 190 [popupButton setControlView:nil];
191 191
192 return false; 192 return false;
193 } 193 }
194 194
195 bool ThemePainterMac::paintProgressBar(const LayoutObject& layoutObject, const P aintInfo& paintInfo, const IntRect& rect) 195 bool ThemePainterMac::paintProgressBar(const LayoutObject& layoutObject, const P aintInfo& paintInfo, const IntRect& rect)
196 { 196 {
197 if (!layoutObject.isProgress()) 197 if (!layoutObject.isProgress())
198 return true; 198 return true;
199 199
200 float zoomLevel = layoutObject.styleRef().effectiveZoom();
201 NSControlSize controlSize = m_layoutTheme.controlSizeForFont(layoutObject.st yleRef());
202 IntSize size = m_layoutTheme.progressBarSizes()[controlSize];
203 size.setHeight(size.height() * zoomLevel);
204 size.setWidth(rect.width());
205
206 // Now inflate it to account for the shadow.
207 IntRect inflatedRect = rect;
208 if (rect.height() <= m_layoutTheme.minimumProgressBarHeight(layoutObject.sty leRef()))
209 inflatedRect = ThemeMac::inflateRect(inflatedRect, size, m_layoutTheme.p rogressBarMargins(controlSize), zoomLevel);
210
211 const LayoutProgress& layoutProgress = toLayoutProgress(layoutObject); 200 const LayoutProgress& layoutProgress = toLayoutProgress(layoutObject);
212 HIThemeTrackDrawInfo trackInfo; 201 HIThemeTrackDrawInfo trackInfo;
213 trackInfo.version = 0; 202 trackInfo.version = 0;
203 NSControlSize controlSize = m_layoutTheme.controlSizeForFont(layoutObject.st yleRef());
214 if (controlSize == NSRegularControlSize) 204 if (controlSize == NSRegularControlSize)
215 trackInfo.kind = layoutProgress.position() < 0 ? kThemeLargeIndeterminat eBar : kThemeLargeProgressBar; 205 trackInfo.kind = layoutProgress.position() < 0 ? kThemeLargeIndeterminat eBar : kThemeLargeProgressBar;
216 else 206 else
217 trackInfo.kind = layoutProgress.position() < 0 ? kThemeMediumIndetermina teBar : kThemeMediumProgressBar; 207 trackInfo.kind = layoutProgress.position() < 0 ? kThemeMediumIndetermina teBar : kThemeMediumProgressBar;
218 208
219 trackInfo.bounds = IntRect(IntPoint(), inflatedRect.size()); 209 trackInfo.bounds = IntRect(IntPoint(), rect.size());
220 trackInfo.min = 0; 210 trackInfo.min = 0;
221 trackInfo.max = std::numeric_limits<SInt32>::max(); 211 trackInfo.max = std::numeric_limits<SInt32>::max();
222 trackInfo.value = lround(layoutProgress.position() * nextafter(trackInfo.max , 0)); 212 trackInfo.value = lround(layoutProgress.position() * nextafter(trackInfo.max , 0));
223 trackInfo.trackInfo.progress.phase = lround(layoutProgress.animationProgress () * nextafter(LayoutThemeMac::progressAnimationNumFrames, 0)); 213 trackInfo.trackInfo.progress.phase = lround(layoutProgress.animationProgress () * nextafter(LayoutThemeMac::progressAnimationNumFrames, 0));
224 trackInfo.attributes = kThemeTrackHorizontal; 214 trackInfo.attributes = kThemeTrackHorizontal;
225 trackInfo.enableState = LayoutTheme::isActive(layoutObject) ? kThemeTrackAct ive : kThemeTrackInactive; 215 trackInfo.enableState = LayoutTheme::isActive(layoutObject) ? kThemeTrackAct ive : kThemeTrackInactive;
226 trackInfo.reserved = 0; 216 trackInfo.reserved = 0;
227 trackInfo.filler1 = 0; 217 trackInfo.filler1 = 0;
228 218
229 std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(inflatedRect. size()); 219 std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(rect.size());
230 if (!imageBuffer) 220 if (!imageBuffer)
231 return true; 221 return true;
232 222
233 IntRect clipRect = IntRect(IntPoint(), inflatedRect.size()); 223 IntRect clipRect = IntRect(IntPoint(), rect.size());
234 LocalCurrentGraphicsContext localContext(imageBuffer->canvas(), 1, clipRect) ; 224 LocalCurrentGraphicsContext localContext(imageBuffer->canvas(), 1, clipRect) ;
235 CGContextRef cgContext = localContext.cgContext(); 225 CGContextRef cgContext = localContext.cgContext();
236 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal); 226 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
237 227
238 GraphicsContextStateSaver stateSaver(paintInfo.context); 228 GraphicsContextStateSaver stateSaver(paintInfo.context);
239 229
240 if (!layoutProgress.styleRef().isLeftToRightDirection()) { 230 if (!layoutProgress.styleRef().isLeftToRightDirection()) {
241 paintInfo.context.translate(2 * inflatedRect.x() + inflatedRect.width(), 0); 231 paintInfo.context.translate(2 * rect.x() + rect.width(), 0);
242 paintInfo.context.scale(-1, 1); 232 paintInfo.context.scale(-1, 1);
243 } 233 }
244 234
245 if (!paintInfo.context.contextDisabled()) 235 if (!paintInfo.context.contextDisabled())
246 imageBuffer->draw(paintInfo.context, FloatRect(inflatedRect.location(), FloatSize(imageBuffer->size())), nullptr, SkXfermode::kSrcOver_Mode); 236 imageBuffer->draw(paintInfo.context, FloatRect(rect.location(), FloatSiz e(imageBuffer->size())), nullptr, SkXfermode::kSrcOver_Mode);
247 return false; 237 return false;
248 } 238 }
249 239
250 bool ThemePainterMac::paintMenuListButton(const LayoutObject& o, const PaintInfo & paintInfo, const IntRect& r) 240 bool ThemePainterMac::paintMenuListButton(const LayoutObject& o, const PaintInfo & paintInfo, const IntRect& r)
251 { 241 {
252 IntRect bounds = IntRect(r.x() + o.styleRef().borderLeftWidth(), 242 IntRect bounds = IntRect(r.x() + o.styleRef().borderLeftWidth(),
253 r.y() + o.styleRef().borderTopWidth(), 243 r.y() + o.styleRef().borderTopWidth(),
254 r.width() - o.styleRef().borderLeftWidth() - o.styl eRef().borderRightWidth(), 244 r.width() - o.styleRef().borderLeftWidth() - o.styl eRef().borderRightWidth(),
255 r.height() - o.styleRef().borderTopWidth() - o.styl eRef().borderBottomWidth()); 245 r.height() - o.styleRef().borderTopWidth() - o.styl eRef().borderBottomWidth());
256 // Since we actually know the size of the control here, we restrict the font 246 // Since we actually know the size of the control here, we restrict the font
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 paintInfo.context.rotate(deg2rad(-45.0)); 538 paintInfo.context.rotate(deg2rad(-45.0));
549 paintInfo.context.translate(-centerX, -centerY); 539 paintInfo.context.translate(-centerX, -centerY);
550 540
551 paintInfo.context.setFillColor(fillColor); 541 paintInfo.context.setFillColor(fillColor);
552 paintInfo.context.fillEllipse(unzoomedRect); 542 paintInfo.context.fillEllipse(unzoomedRect);
553 543
554 return false; 544 return false;
555 } 545 }
556 546
557 } // namespace blink 547 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeMac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698