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

Side by Side Diff: Source/core/paint/InlinePainter.cpp

Issue 1201753003: Apply outline-offset on all edges (not just top/left) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/paint/inline/outline-offset.html ('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 // 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 "config.h" 5 #include "config.h"
6 #include "core/paint/InlinePainter.h" 6 #include "core/paint/InlinePainter.h"
7 7
8 #include "core/layout/LayoutBlock.h" 8 #include "core/layout/LayoutBlock.h"
9 #include "core/layout/LayoutInline.h" 9 #include "core/layout/LayoutInline.h"
10 #include "core/layout/LayoutTheme.h" 10 #include "core/layout/LayoutTheme.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo lor.blue()); 92 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo lor.blue());
93 } 93 }
94 94
95 for (unsigned i = 1; i < rects.size() - 1; i++) 95 for (unsigned i = 1; i < rects.size() - 1; i++)
96 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects .at(i), rects.at(i + 1), outlineColor); 96 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects .at(i), rects.at(i + 1), outlineColor);
97 97
98 if (useTransparencyLayer) 98 if (useTransparencyLayer)
99 graphicsContext->endLayer(); 99 graphicsContext->endLayer();
100 } 100 }
101 101
102 static IntRect pixelSnappedOutsetPaintRect(const LayoutRect& baseRect, const Lay outPoint& paintOffset, int outset)
103 {
104 LayoutRect box(baseRect);
105 box.moveBy(paintOffset);
106 box.inflate(outset);
107 return pixelSnappedIntRect(box);
108 }
109
102 void InlinePainter::paintOutlineForLine(GraphicsContext* graphicsContext, const LayoutPoint& paintOffset, 110 void InlinePainter::paintOutlineForLine(GraphicsContext* graphicsContext, const LayoutPoint& paintOffset,
103 const LayoutRect& lastline, const LayoutRect& thisline, const LayoutRect& ne xtline, const Color outlineColor) 111 const LayoutRect& lastline, const LayoutRect& thisline, const LayoutRect& ne xtline, const Color outlineColor)
104 { 112 {
105 const ComputedStyle& styleToUse = m_layoutInline.styleRef(); 113 const ComputedStyle& styleToUse = m_layoutInline.styleRef();
106 int outlineWidth = styleToUse.outlineWidth(); 114 int outlineWidth = styleToUse.outlineWidth();
107 EBorderStyle outlineStyle = styleToUse.outlineStyle(); 115 EBorderStyle outlineStyle = styleToUse.outlineStyle();
108 116
109 int offset = m_layoutInline.style()->outlineOffset(); 117 int offset = m_layoutInline.style()->outlineOffset();
110 118
111 LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOff set.y() + thisline.y() - offset), 119 IntRect pixelSnappedBox = pixelSnappedOutsetPaintRect(thisline, paintOffset, offset);
112 LayoutSize(thisline.width() + offset, thisline.height() + offset));
113
114 IntRect pixelSnappedBox = pixelSnappedIntRect(box);
115 if (pixelSnappedBox.width() < 0 || pixelSnappedBox.height() < 0) 120 if (pixelSnappedBox.width() < 0 || pixelSnappedBox.height() < 0)
116 return; 121 return;
117 // Note that we use IntRect below for working with solely x/width values, si mplifying logic at cost of a bit of memory. 122 // Note that we use IntRect below for working with solely x/width values, si mplifying logic at cost of a bit of memory.
118 IntRect pixelSnappedLastLine = pixelSnappedIntRect(paintOffset.x() + lastlin e.x() - offset, 0, lastline.width() + offset, 0); 123 IntRect pixelSnappedLastLine = pixelSnappedOutsetPaintRect(lastline, paintOf fset, offset);
119 IntRect pixelSnappedNextLine = pixelSnappedIntRect(paintOffset.x() + nextlin e.x() - offset, 0, nextline.width() + offset, 0); 124 IntRect pixelSnappedNextLine = pixelSnappedOutsetPaintRect(nextline, paintOf fset, offset);
120 125
121 const int fallbackMaxOutlineX = std::numeric_limits<int>::max(); 126 const int fallbackMaxOutlineX = std::numeric_limits<int>::max();
122 const int fallbackMinOutlineX = std::numeric_limits<int>::min(); 127 const int fallbackMinOutlineX = std::numeric_limits<int>::min();
123 128
124 // left edge 129 // left edge
125 ObjectPainter::drawLineForBoxSide(graphicsContext, 130 ObjectPainter::drawLineForBoxSide(graphicsContext,
126 pixelSnappedBox.x() - outlineWidth, 131 pixelSnappedBox.x() - outlineWidth,
127 pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0), 132 pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
128 pixelSnappedBox.x(), 133 pixelSnappedBox.x(),
129 pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline .x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0), 134 pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline .x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 pixelSnappedBox.maxX() + outlineWidth, 216 pixelSnappedBox.maxX() + outlineWidth,
212 pixelSnappedBox.maxY() + outlineWidth, 217 pixelSnappedBox.maxY() + outlineWidth,
213 BSBottom, outlineColor, outlineStyle, 218 BSBottom, outlineColor, outlineStyle,
214 outlineWidth, 219 outlineWidth,
215 outlineWidth, 220 outlineWidth,
216 false); 221 false);
217 } 222 }
218 } 223 }
219 224
220 } // namespace blink 225 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/paint/inline/outline-offset.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698