OLD | NEW |
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/BoxPainter.h" | 5 #include "core/paint/BoxPainter.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
9 #include "core/html/HTMLFrameOwnerElement.h" | 9 #include "core/html/HTMLFrameOwnerElement.h" |
10 #include "core/layout/ImageQualityController.h" | 10 #include "core/layout/ImageQualityController.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 223 } |
224 | 224 |
225 FloatRoundedRect BoxPainter::getBackgroundRoundedRect(const LayoutObject& obj, c
onst LayoutRect& borderRect, | 225 FloatRoundedRect BoxPainter::getBackgroundRoundedRect(const LayoutObject& obj, c
onst LayoutRect& borderRect, |
226 const InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHei
ght, | 226 const InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHei
ght, |
227 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) | 227 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) |
228 { | 228 { |
229 FloatRoundedRect border = obj.style()->getRoundedBorderFor(borderRect, inclu
deLogicalLeftEdge, includeLogicalRightEdge); | 229 FloatRoundedRect border = obj.style()->getRoundedBorderFor(borderRect, inclu
deLogicalLeftEdge, includeLogicalRightEdge); |
230 if (box && (box->nextLineBox() || box->prevLineBox())) { | 230 if (box && (box->nextLineBox() || box->prevLineBox())) { |
231 FloatRoundedRect segmentBorder = obj.style()->getRoundedBorderFor(Layout
Rect(0, 0, inlineBoxWidth, inlineBoxHeight), | 231 FloatRoundedRect segmentBorder = obj.style()->getRoundedBorderFor(Layout
Rect(0, 0, inlineBoxWidth, inlineBoxHeight), |
232 includeLogicalLeftEdge, includeLogicalRightEdge); | 232 includeLogicalLeftEdge, includeLogicalRightEdge); |
233 border.setRadii(segmentBorder.radii()); | 233 border.setRadii(segmentBorder.getRadii()); |
234 } | 234 } |
235 return border; | 235 return border; |
236 } | 236 } |
237 | 237 |
238 FloatRoundedRect BoxPainter::backgroundRoundedRectAdjustedForBleedAvoidance(cons
t LayoutObject& obj, | 238 FloatRoundedRect BoxPainter::backgroundRoundedRectAdjustedForBleedAvoidance(cons
t LayoutObject& obj, |
239 const LayoutRect& borderRect, BackgroundBleedAvoidance bleedAvoidance, const
InlineFlowBox* box, | 239 const LayoutRect& borderRect, BackgroundBleedAvoidance bleedAvoidance, const
InlineFlowBox* box, |
240 const LayoutSize& boxSize, bool includeLogicalLeftEdge, bool includeLogicalR
ightEdge) | 240 const LayoutSize& boxSize, bool includeLogicalLeftEdge, bool includeLogicalR
ightEdge) |
241 { | 241 { |
242 if (bleedAvoidance == BackgroundBleedShrinkBackground) { | 242 if (bleedAvoidance == BackgroundBleedShrinkBackground) { |
243 // Inset the background rect by a "safe" amount: 1/2 border-width for op
aque border styles, | 243 // Inset the background rect by a "safe" amount: 1/2 border-width for op
aque border styles, |
(...skipping 16 matching lines...) Expand all Loading... |
260 FloatRectOutsets insets( | 260 FloatRectOutsets insets( |
261 -fractionalInset * edges[BSTop].width, | 261 -fractionalInset * edges[BSTop].width, |
262 -fractionalInset * edges[BSRight].width, | 262 -fractionalInset * edges[BSRight].width, |
263 -fractionalInset * edges[BSBottom].width, | 263 -fractionalInset * edges[BSBottom].width, |
264 -fractionalInset * edges[BSLeft].width); | 264 -fractionalInset * edges[BSLeft].width); |
265 | 265 |
266 FloatRoundedRect backgroundRoundedRect = getBackgroundRoundedRect(obj, b
orderRect, box, boxSize.width(), boxSize.height(), | 266 FloatRoundedRect backgroundRoundedRect = getBackgroundRoundedRect(obj, b
orderRect, box, boxSize.width(), boxSize.height(), |
267 includeLogicalLeftEdge, includeLogicalRightEdge); | 267 includeLogicalLeftEdge, includeLogicalRightEdge); |
268 FloatRect insetRect(backgroundRoundedRect.rect()); | 268 FloatRect insetRect(backgroundRoundedRect.rect()); |
269 insetRect.expand(insets); | 269 insetRect.expand(insets); |
270 FloatRoundedRect::Radii insetRadii(backgroundRoundedRect.radii()); | 270 FloatRoundedRect::Radii insetRadii(backgroundRoundedRect.getRadii()); |
271 insetRadii.shrink(-insets.top(), -insets.bottom(), -insets.left(), -inse
ts.right()); | 271 insetRadii.shrink(-insets.top(), -insets.bottom(), -insets.left(), -inse
ts.right()); |
272 return FloatRoundedRect(insetRect, insetRadii); | 272 return FloatRoundedRect(insetRect, insetRadii); |
273 } | 273 } |
274 | 274 |
275 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), boxSi
ze.height(), includeLogicalLeftEdge, includeLogicalRightEdge); | 275 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), boxSi
ze.height(), includeLogicalLeftEdge, includeLogicalRightEdge); |
276 } | 276 } |
277 | 277 |
278 void BoxPainter::paintFillLayer(const LayoutBoxModelObject& obj, const PaintInfo
& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& rec
t, BackgroundBleedAvoidance bleedAvoidance, const InlineFlowBox* box, const Layo
utSize& boxSize, SkXfermode::Mode op, const LayoutObject* backgroundObject) | 278 void BoxPainter::paintFillLayer(const LayoutBoxModelObject& obj, const PaintInfo
& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& rec
t, BackgroundBleedAvoidance bleedAvoidance, const InlineFlowBox* box, const Layo
utSize& boxSize, SkXfermode::Mode op, const LayoutObject* backgroundObject) |
279 { | 279 { |
280 GraphicsContext& context = paintInfo.context; | 280 GraphicsContext& context = paintInfo.context; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 | 644 |
645 if (!rectToClipOut.isEmpty()) | 645 if (!rectToClipOut.isEmpty()) |
646 context.clipOut(rectToClipOut); | 646 context.clipOut(rectToClipOut); |
647 } | 647 } |
648 } | 648 } |
649 | 649 |
650 // Draw only the shadow. | 650 // Draw only the shadow. |
651 context.setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooperB
uilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha, DrawSha
dowOnly); | 651 context.setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooperB
uilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha, DrawSha
dowOnly); |
652 | 652 |
653 if (hasBorderRadius) { | 653 if (hasBorderRadius) { |
654 FloatRoundedRect influenceRect(pixelSnappedIntRect(LayoutRect(sh
adowRect)), border.radii()); | 654 FloatRoundedRect influenceRect(pixelSnappedIntRect(LayoutRect(sh
adowRect)), border.getRadii()); |
655 float changeAmount = 2 * shadowBlur + shadowSpread; | 655 float changeAmount = 2 * shadowBlur + shadowSpread; |
656 if (changeAmount >= 0) | 656 if (changeAmount >= 0) |
657 influenceRect.expandRadii(changeAmount); | 657 influenceRect.expandRadii(changeAmount); |
658 else | 658 else |
659 influenceRect.shrinkRadii(-changeAmount); | 659 influenceRect.shrinkRadii(-changeAmount); |
660 | 660 |
661 FloatRoundedRect roundedFillRect = border; | 661 FloatRoundedRect roundedFillRect = border; |
662 roundedFillRect.inflate(shadowSpread); | 662 roundedFillRect.inflate(shadowSpread); |
663 | 663 |
664 if (shadowSpread >= 0) | 664 if (shadowSpread >= 0) |
(...skipping 27 matching lines...) Expand all Loading... |
692 } | 692 } |
693 } | 693 } |
694 | 694 |
695 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 695 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
696 { | 696 { |
697 return document.printing() && style.getPrintColorAdjust() == PrintColorAdjus
tEconomy | 697 return document.printing() && style.getPrintColorAdjust() == PrintColorAdjus
tEconomy |
698 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 698 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
699 } | 699 } |
700 | 700 |
701 } // namespace blink | 701 } // namespace blink |
OLD | NEW |