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

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

Issue 2386033002: Scale focus outline thickness with zoom level. (Closed)
Patch Set: return if outline width is 0 Created 4 years, 2 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/ObjectPainter.h" 5 #include "core/paint/ObjectPainter.h"
6 6
7 #include "core/layout/LayoutBlock.h" 7 #include "core/layout/LayoutBlock.h"
8 #include "core/layout/LayoutInline.h" 8 #include "core/layout/LayoutInline.h"
9 #include "core/layout/LayoutObject.h" 9 #include "core/layout/LayoutObject.h"
10 #include "core/layout/LayoutTheme.h" 10 #include "core/layout/LayoutTheme.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 path.lineTo(quad[3]); 210 path.lineTo(quad[3]);
211 SkPaint paint(context.fillPaint()); 211 SkPaint paint(context.fillPaint());
212 paint.setAntiAlias(antialias); 212 paint.setAntiAlias(antialias);
213 paint.setColor(color.rgb()); 213 paint.setColor(color.rgb());
214 214
215 context.drawPath(path, paint); 215 context.drawPath(path, paint);
216 } 216 }
217 217
218 } // namespace 218 } // namespace
219 219
220 float ObjectPainter::getOutlineStrokeWidth(const ComputedStyle& style) {
221 #if OS(MACOSX)
222 return style.outlineWidth();
chrishtr 2016/10/07 21:14:21 Why this special case? Also, it apears there is t
Bret 2016/10/08 01:32:40 This is the same case, just moved around. See my o
223 #else
224 // Draw an outline with thickness in proportion to the zoom level, but never
225 // less than 1 pixel so that it remains visible.
226 return std::max(style.effectiveZoom(), 1.f);
227 #endif
228 }
229
220 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, 230 void ObjectPainter::paintOutline(const PaintInfo& paintInfo,
221 const LayoutPoint& paintOffset) { 231 const LayoutPoint& paintOffset) {
222 ASSERT(shouldPaintSelfOutline(paintInfo.phase)); 232 ASSERT(shouldPaintSelfOutline(paintInfo.phase));
223 233
224 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); 234 const ComputedStyle& styleToUse = m_layoutObject.styleRef();
225 if (!styleToUse.hasOutline() || 235 if (!styleToUse.hasOutline() ||
226 styleToUse.visibility() != EVisibility::Visible) 236 styleToUse.visibility() != EVisibility::Visible)
227 return; 237 return;
228 238
229 // Only paint the focus ring by hand if the theme isn't able to draw the focus 239 // Only paint the focus ring by hand if the theme isn't able to draw the focus
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 IntRect unitedOutlineRect = unionRectEvenIfEmpty(pixelSnappedOutlineRects); 273 IntRect unitedOutlineRect = unionRectEvenIfEmpty(pixelSnappedOutlineRects);
264 IntRect bounds = unitedOutlineRect; 274 IntRect bounds = unitedOutlineRect;
265 bounds.inflate(m_layoutObject.styleRef().outlineOutsetExtent()); 275 bounds.inflate(m_layoutObject.styleRef().outlineOutsetExtent());
266 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, 276 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject,
267 paintInfo.phase, bounds); 277 paintInfo.phase, bounds);
268 278
269 Color color = 279 Color color =
270 m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColor); 280 m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColor);
271 if (styleToUse.outlineStyleIsAuto()) { 281 if (styleToUse.outlineStyleIsAuto()) {
272 paintInfo.context.drawFocusRing(pixelSnappedOutlineRects, 282 paintInfo.context.drawFocusRing(pixelSnappedOutlineRects,
273 styleToUse.outlineWidth(), 283 getOutlineStrokeWidth(styleToUse),
274 styleToUse.outlineOffset(), color); 284 styleToUse.outlineOffset(), color);
275 return; 285 return;
276 } 286 }
277 287
278 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { 288 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) {
279 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, 289 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse,
280 color); 290 color);
281 return; 291 return;
282 } 292 }
283 paintComplexOutline(paintInfo.context, pixelSnappedOutlineRects, styleToUse, 293 paintComplexOutline(paintInfo.context, pixelSnappedOutlineRects, styleToUse,
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 m_layoutObject.paint(info, paintOffset); 697 m_layoutObject.paint(info, paintOffset);
688 info.phase = PaintPhaseFloat; 698 info.phase = PaintPhaseFloat;
689 m_layoutObject.paint(info, paintOffset); 699 m_layoutObject.paint(info, paintOffset);
690 info.phase = PaintPhaseForeground; 700 info.phase = PaintPhaseForeground;
691 m_layoutObject.paint(info, paintOffset); 701 m_layoutObject.paint(info, paintOffset);
692 info.phase = PaintPhaseOutline; 702 info.phase = PaintPhaseOutline;
693 m_layoutObject.paint(info, paintOffset); 703 m_layoutObject.paint(info, paintOffset);
694 } 704 }
695 705
696 } // namespace blink 706 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698