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

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

Issue 1137513003: Apply bleed-avoidance insets _after_ constraining the border (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: One more TE. Created 5 years, 7 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 | « Source/core/paint/BoxPainter.h ('k') | Source/core/style/ComputedStyle.h » ('j') | 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/BoxPainter.h" 6 #include "core/paint/BoxPainter.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/html/HTMLFrameOwnerElement.h" 10 #include "core/html/HTMLFrameOwnerElement.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 FloatSize shadowOffset(boxShadow.x(), boxShadow.y()); 257 FloatSize shadowOffset(boxShadow.x(), boxShadow.y());
258 context->setShadow(shadowOffset, boxShadow.blur(), 258 context->setShadow(shadowOffset, boxShadow.blur(),
259 boxShadow.color().resolve(obj.resolveColor(CSSPropertyColor)), 259 boxShadow.color().resolve(obj.resolveColor(CSSPropertyColor)),
260 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::Shad owIgnoresAlpha); 260 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::Shad owIgnoresAlpha);
261 return; 261 return;
262 } 262 }
263 } 263 }
264 264
265 FloatRoundedRect BoxPainter::getBackgroundRoundedRect(LayoutObject& obj, const L ayoutRect& borderRect, 265 FloatRoundedRect BoxPainter::getBackgroundRoundedRect(LayoutObject& obj, const L ayoutRect& borderRect,
266 InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight, 266 InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
267 bool includeLogicalLeftEdge, bool includeLogicalRightEdge, const FloatRectOu tsets* insets) 267 bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
268 { 268 {
269 FloatRoundedRect border = obj.style()->getRoundedBorderFor(borderRect, inclu deLogicalLeftEdge, 269 FloatRoundedRect border = obj.style()->getRoundedBorderFor(borderRect, inclu deLogicalLeftEdge, includeLogicalRightEdge);
270 includeLogicalRightEdge, insets);
271 if (box && (box->nextLineBox() || box->prevLineBox())) { 270 if (box && (box->nextLineBox() || box->prevLineBox())) {
272 FloatRoundedRect segmentBorder = obj.style()->getRoundedBorderFor(Layout Rect(0, 0, inlineBoxWidth, inlineBoxHeight), 271 FloatRoundedRect segmentBorder = obj.style()->getRoundedBorderFor(Layout Rect(0, 0, inlineBoxWidth, inlineBoxHeight),
273 includeLogicalLeftEdge, includeLogicalRightEdge, insets); 272 includeLogicalLeftEdge, includeLogicalRightEdge);
274 border.setRadii(segmentBorder.radii()); 273 border.setRadii(segmentBorder.radii());
275 } 274 }
276
277 return border; 275 return border;
278 } 276 }
279 277
280 FloatRoundedRect BoxPainter::backgroundRoundedRectAdjustedForBleedAvoidance(Layo utObject& obj, 278 FloatRoundedRect BoxPainter::backgroundRoundedRectAdjustedForBleedAvoidance(Layo utObject& obj,
281 const LayoutRect& borderRect, BackgroundBleedAvoidance bleedAvoidance, Inlin eFlowBox* box, 279 const LayoutRect& borderRect, BackgroundBleedAvoidance bleedAvoidance, Inlin eFlowBox* box,
282 const LayoutSize& boxSize, bool includeLogicalLeftEdge, bool includeLogicalR ightEdge) 280 const LayoutSize& boxSize, bool includeLogicalLeftEdge, bool includeLogicalR ightEdge)
283 { 281 {
284 if (bleedAvoidance == BackgroundBleedShrinkBackground) { 282 if (bleedAvoidance == BackgroundBleedShrinkBackground) {
285 // Inset the background rect by a "safe" amount: 1/2 border-width for op aque border styles, 283 // Inset the background rect by a "safe" amount: 1/2 border-width for op aque border styles,
286 // 1/6 border-width for double borders. 284 // 1/6 border-width for double borders.
(...skipping 11 matching lines...) Expand all
298 break; 296 break;
299 } 297 }
300 } 298 }
301 299
302 FloatRectOutsets insets( 300 FloatRectOutsets insets(
303 -fractionalInset * edges[BSTop].width, 301 -fractionalInset * edges[BSTop].width,
304 -fractionalInset * edges[BSRight].width, 302 -fractionalInset * edges[BSRight].width,
305 -fractionalInset * edges[BSBottom].width, 303 -fractionalInset * edges[BSBottom].width,
306 -fractionalInset * edges[BSLeft].width); 304 -fractionalInset * edges[BSLeft].width);
307 305
308 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), b oxSize.height(), 306 FloatRoundedRect backgroundRoundedRect = getBackgroundRoundedRect(obj, b orderRect, box, boxSize.width(), boxSize.height(),
309 includeLogicalLeftEdge, includeLogicalRightEdge, &insets); 307 includeLogicalLeftEdge, includeLogicalRightEdge);
308 FloatRect insetRect(backgroundRoundedRect.rect());
309 insetRect.expand(insets);
310 FloatRoundedRect::Radii insetRadii(backgroundRoundedRect.radii());
311 insetRadii.shrink(-insets.top(), -insets.bottom(), -insets.left(), -inse ts.right());
312 return FloatRoundedRect(insetRect, insetRadii);
310 } 313 }
311 if (bleedAvoidance == BackgroundBleedBackgroundOverBorder) 314 if (bleedAvoidance == BackgroundBleedBackgroundOverBorder)
312 return obj.style()->getRoundedInnerBorderFor(borderRect, includeLogicalL eftEdge, includeLogicalRightEdge); 315 return obj.style()->getRoundedInnerBorderFor(borderRect, includeLogicalL eftEdge, includeLogicalRightEdge);
313 316
314 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), boxSi ze.height(), includeLogicalLeftEdge, includeLogicalRightEdge); 317 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), boxSi ze.height(), includeLogicalLeftEdge, includeLogicalRightEdge);
315 } 318 }
316 319
317 void BoxPainter::paintFillLayerExtended(LayoutBoxModelObject& obj, const PaintIn fo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& r ect, 320 void BoxPainter::paintFillLayerExtended(LayoutBoxModelObject& obj, const PaintIn fo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& r ect,
318 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, SkXfermode::Mode op, LayoutObject* backgroundObject, bool skipBaseCo lor) 321 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, SkXfermode::Mode op, LayoutObject* backgroundObject, bool skipBaseCo lor)
319 { 322 {
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 2297
2295 FloatPoint secondQuad[4]; 2298 FloatPoint secondQuad[4];
2296 secondQuad[0] = quad[0]; 2299 secondQuad[0] = quad[0];
2297 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); 2300 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy);
2298 secondQuad[2] = quad[2]; 2301 secondQuad[2] = quad[2];
2299 secondQuad[3] = quad[3]; 2302 secondQuad[3] = quad[3];
2300 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); 2303 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches);
2301 } 2304 }
2302 2305
2303 } // namespace blink 2306 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/BoxPainter.h ('k') | Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698