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

Side by Side Diff: Source/core/layout/svg/SVGLayoutSupport.cpp

Issue 1165393005: Add helper for computing outset for 'outline' (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | Source/core/paint/InlinePainter.cpp » ('j') | 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) 2007, 2008 Rob Buis <buis@kde.org> 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. All rights reserved. 5 * Copyright (C) 2009 Google, Inc. All rights reserved.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 namespace blink { 45 namespace blink {
46 46
47 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) 47 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect)
48 { 48 {
49 if (rect.isEmpty()) 49 if (rect.isEmpty())
50 return LayoutRect(); 50 return LayoutRect();
51 return LayoutRect(enclosingIntRect(rect)); 51 return LayoutRect(enclosingIntRect(rect));
52 } 52 }
53 53
54 static void inflateWithOutlineIfNeeded(FloatRect& paintInvalidationRect, const C omputedStyle& style)
55 {
56 if (!style.hasOutline())
57 return;
58 int outlineSize = 0;
59 if (style.outlineStyleIsAuto())
60 outlineSize = GraphicsContext::focusRingOutsetExtent(style.outlineOffset (), style.outlineWidth());
61 else
62 outlineSize = style.outlineSize();
63 paintInvalidationRect.inflate(outlineSize);
64 }
65
66 LayoutRect SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(const Layou tObject& object, const LayoutBoxModelObject* paintInvalidationContainer, const P aintInvalidationState* paintInvalidationState) 54 LayoutRect SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(const Layou tObject& object, const LayoutBoxModelObject* paintInvalidationContainer, const P aintInvalidationState* paintInvalidationState)
67 { 55 {
68 // Return early for any cases where we don't actually paint 56 // Return early for any cases where we don't actually paint
69 if (object.style()->visibility() != VISIBLE && !object.enclosingLayer()->has VisibleContent()) 57 if (object.styleRef().visibility() != VISIBLE && !object.enclosingLayer()->h asVisibleContent())
70 return LayoutRect(); 58 return LayoutRect();
71 59
72 FloatRect paintInvalidationRect = object.paintInvalidationRectInLocalCoordin ates(); 60 FloatRect paintInvalidationRect = object.paintInvalidationRectInLocalCoordin ates();
73 inflateWithOutlineIfNeeded(paintInvalidationRect, object.styleRef()); 61 if (int outlineOutset = object.styleRef().outlineOutset())
62 paintInvalidationRect.inflate(outlineOutset);
74 63
75 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) { 64 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) {
76 // Compute accumulated SVG transform and apply to local paint rect. 65 // Compute accumulated SVG transform and apply to local paint rect.
77 AffineTransform transform = paintInvalidationState->svgTransform() * obj ect.localToParentTransform(); 66 AffineTransform transform = paintInvalidationState->svgTransform() * obj ect.localToParentTransform();
78 // FIXME: These are quirks carried forward from the old paint invalidati on infrastructure. 67 // FIXME: These are quirks carried forward from the old paint invalidati on infrastructure.
79 LayoutRect rect = enclosingIntRectIfNotEmpty(transform.mapRect(paintInva lidationRect)); 68 LayoutRect rect = enclosingIntRectIfNotEmpty(transform.mapRect(paintInva lidationRect));
80 // Offset by SVG root paint offset and apply clipping as needed. 69 // Offset by SVG root paint offset and apply clipping as needed.
81 rect.move(paintInvalidationState->paintOffset()); 70 rect.move(paintInvalidationState->paintOffset());
82 if (paintInvalidationState->isClipped()) 71 if (paintInvalidationState->isClipped())
83 rect.intersect(paintInvalidationState->clipRect()); 72 rect.intersect(paintInvalidationState->clipRect());
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 455
467 // FIXME: trying to compute a device space transform at record time is wrong . All clients 456 // FIXME: trying to compute a device space transform at record time is wrong . All clients
468 // should be updated to avoid relying on this information, and the method sh ould be removed. 457 // should be updated to avoid relying on this information, and the method sh ould be removed.
469 AffineTransform ctm = deprecatedCalculateTransformToLayer(layoutObject) * cu rrentContentTransformation(); 458 AffineTransform ctm = deprecatedCalculateTransformToLayer(layoutObject) * cu rrentContentTransformation();
470 ctm.scale(layoutObject->document().frameHost()->deviceScaleFactor()); 459 ctm.scale(layoutObject->document().frameHost()->deviceScaleFactor());
471 460
472 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2)); 461 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2));
473 } 462 }
474 463
475 } 464 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/paint/InlinePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698