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

Unified Diff: Source/core/paint/InlinePainter.cpp

Issue 1163913002: Improve outline bounds estimation in InlinePainter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix continuation outlines. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/paint/InlinePainter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/InlinePainter.cpp
diff --git a/Source/core/paint/InlinePainter.cpp b/Source/core/paint/InlinePainter.cpp
index bcbe040b8e0f38611a26d5f989ab4ad9305c5c99..d7cb3e9218b09776ce78c75cbda654eadc3eb5d7 100644
--- a/Source/core/paint/InlinePainter.cpp
+++ b/Source/core/paint/InlinePainter.cpp
@@ -29,6 +29,26 @@ void InlinePainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
LineBoxListPainter(*m_layoutInline.lineBoxes()).paint(&m_layoutInline, paintInfo, paintOffset);
}
+LayoutRect InlinePainter::outlinePaintRect(const Vector<LayoutRect>& outlineRects, const LayoutPoint& paintOffset) const
+{
+ const ComputedStyle& style = m_layoutInline.styleRef();
+ int outlineOutset;
+ if (style.outlineStyleIsAuto())
+ outlineOutset = GraphicsContext::focusRingOutsetExtent(style.outlineOffset(), style.outlineWidth());
+ else
+ outlineOutset = style.outlineSize();
+ LayoutRect outlineRect;
+ for (const LayoutRect& rect : outlineRects) {
+ LayoutRect inflatedRect(rect);
+ // Inflate the individual rects instead of the union, to avoid losing
+ // rects which have degenerate width/height (== isEmpty() true.)
+ inflatedRect.inflate(outlineOutset);
+ outlineRect.unite(inflatedRect);
+ }
+ outlineRect.moveBy(paintOffset);
+ return outlineRect;
+}
+
void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
const ComputedStyle& styleToUse = m_layoutInline.styleRef();
@@ -39,11 +59,8 @@ void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint&
if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutInline)) {
Vector<LayoutRect> focusRingRects;
m_layoutInline.addFocusRingRects(focusRingRects, paintOffset);
- LayoutRect focusRingBoundingRect;
- for (const auto& rect : focusRingRects)
- focusRingBoundingRect.unite(rect);
- LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, paintInfo.phase, focusRingBoundingRect);
+ LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, paintInfo.phase, outlinePaintRect(focusRingRects, LayoutPoint()));
if (recorder.canUseCachedDrawing())
return;
@@ -70,16 +87,7 @@ void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint&
Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutlineColor);
bool useTransparencyLayer = outlineColor.hasAlpha();
- int outlineWidth = styleToUse.outlineWidth();
- LayoutRect bounds;
- for (const auto& rect : rects) {
- LayoutRect rectCopy(rect);
- rectCopy.expand(LayoutSize(outlineWidth, outlineWidth));
- bounds.unite(rectCopy);
- }
- bounds.moveBy(paintOffset);
-
- LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, paintInfo.phase, bounds);
+ LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, paintInfo.phase, outlinePaintRect(rects, paintOffset));
if (recorder.canUseCachedDrawing())
return;
« no previous file with comments | « Source/core/paint/InlinePainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698