| 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 "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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 context->setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooper
Builder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha, DrawSh
adowOnly); | 664 context->setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooper
Builder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha, DrawSh
adowOnly); |
| 665 | 665 |
| 666 if (hasBorderRadius) { | 666 if (hasBorderRadius) { |
| 667 FloatRoundedRect influenceRect(pixelSnappedIntRect(LayoutRect(sh
adowRect)), border.radii()); | 667 FloatRoundedRect influenceRect(pixelSnappedIntRect(LayoutRect(sh
adowRect)), border.radii()); |
| 668 float changeAmount = 2 * shadowBlur + shadowSpread; | 668 float changeAmount = 2 * shadowBlur + shadowSpread; |
| 669 if (changeAmount >= 0) | 669 if (changeAmount >= 0) |
| 670 influenceRect.expandRadii(changeAmount); | 670 influenceRect.expandRadii(changeAmount); |
| 671 else | 671 else |
| 672 influenceRect.shrinkRadii(-changeAmount); | 672 influenceRect.shrinkRadii(-changeAmount); |
| 673 | 673 |
| 674 // TODO: support non-integer shadows - crbug.com/334829 | |
| 675 FloatRoundedRect roundedFillRect = border; | 674 FloatRoundedRect roundedFillRect = border; |
| 676 roundedFillRect.inflate(shadowSpread); | 675 roundedFillRect.inflate(shadowSpread); |
| 677 | 676 |
| 678 if (shadowSpread >= 0) | 677 if (shadowSpread >= 0) |
| 679 roundedFillRect.expandRadii(shadowSpread); | 678 roundedFillRect.expandRadii(shadowSpread); |
| 680 else | 679 else |
| 681 roundedFillRect.shrinkRadii(-shadowSpread); | 680 roundedFillRect.shrinkRadii(-shadowSpread); |
| 682 if (!roundedFillRect.isRenderable()) | 681 if (!roundedFillRect.isRenderable()) |
| 683 roundedFillRect.adjustRadii(); | 682 roundedFillRect.adjustRadii(); |
| 684 roundedFillRect.constrainRadii(); | 683 roundedFillRect.constrainRadii(); |
| 685 context->fillRoundedRect(roundedFillRect, Color::black); | 684 context->fillRoundedRect(roundedFillRect, Color::black); |
| 686 } else { | 685 } else { |
| 687 context->fillRect(fillRect, Color::black); | 686 context->fillRect(fillRect, Color::black); |
| 688 } | 687 } |
| 689 } else { | 688 } else { |
| 690 // The inset shadow case. | 689 // The inset shadow case. |
| 691 GraphicsContext::Edges clippedEdges = GraphicsContext::NoEdge; | 690 GraphicsContext::Edges clippedEdges = GraphicsContext::NoEdge; |
| 692 if (!includeLogicalLeftEdge) { | 691 if (!includeLogicalLeftEdge) { |
| 693 if (isHorizontal) | 692 if (isHorizontal) |
| 694 clippedEdges |= GraphicsContext::LeftEdge; | 693 clippedEdges |= GraphicsContext::LeftEdge; |
| 695 else | 694 else |
| 696 clippedEdges |= GraphicsContext::TopEdge; | 695 clippedEdges |= GraphicsContext::TopEdge; |
| 697 } | 696 } |
| 698 if (!includeLogicalRightEdge) { | 697 if (!includeLogicalRightEdge) { |
| 699 if (isHorizontal) | 698 if (isHorizontal) |
| 700 clippedEdges |= GraphicsContext::RightEdge; | 699 clippedEdges |= GraphicsContext::RightEdge; |
| 701 else | 700 else |
| 702 clippedEdges |= GraphicsContext::BottomEdge; | 701 clippedEdges |= GraphicsContext::BottomEdge; |
| 703 } | 702 } |
| 704 // TODO: support non-integer shadows - crbug.com/334828 | 703 context->drawInnerShadow(border, shadowColor, shadowOffset, shadowBl
ur, shadowSpread, clippedEdges); |
| 705 context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowO
ffset), shadowBlur, shadowSpread, clippedEdges); | |
| 706 } | 704 } |
| 707 } | 705 } |
| 708 } | 706 } |
| 709 | 707 |
| 710 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 708 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
| 711 { | 709 { |
| 712 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy | 710 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy |
| 713 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 711 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
| 714 } | 712 } |
| 715 | 713 |
| 716 } // namespace blink | 714 } // namespace blink |
| OLD | NEW |