| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 const PaintInfo& paintInfo, | 511 const PaintInfo& paintInfo, |
| 512 const FillLayerInfo& info, | 512 const FillLayerInfo& info, |
| 513 const FillLayer& layer, | 513 const FillLayer& layer, |
| 514 const LayoutRect& rect, | 514 const LayoutRect& rect, |
| 515 BackgroundBleedAvoidance bleedAvoidance, | 515 BackgroundBleedAvoidance bleedAvoidance, |
| 516 const InlineFlowBox* box, | 516 const InlineFlowBox* box, |
| 517 const LayoutSize& boxSize, | 517 const LayoutSize& boxSize, |
| 518 SkBlendMode op, | 518 SkBlendMode op, |
| 519 const LayoutObject* backgroundObject, | 519 const LayoutObject* backgroundObject, |
| 520 Optional<BackgroundImageGeometry>& geometry) { | 520 Optional<BackgroundImageGeometry>& geometry) { |
| 521 // Painting a background image from an ancestor onto a cell is a complex case. |
| 522 if (obj.isTableCell() && backgroundObject && !backgroundObject->isTableCell()) |
| 523 return false; |
| 521 // Complex cases not handled on the fast path. | 524 // Complex cases not handled on the fast path. |
| 522 if (!info.isBottomLayer || !info.isBorderFill || | 525 if (!info.isBottomLayer || !info.isBorderFill || |
| 523 info.isClippedWithLocalScrolling) | 526 info.isClippedWithLocalScrolling) |
| 524 return false; | 527 return false; |
| 525 | 528 |
| 526 // Transparent layer, nothing to paint. | 529 // Transparent layer, nothing to paint. |
| 527 if (!info.shouldPaintColor && !info.shouldPaintImage) | 530 if (!info.shouldPaintColor && !info.shouldPaintImage) |
| 528 return true; | 531 return true; |
| 529 | 532 |
| 530 // When the layer has an image, figure out whether it is covered by a single | 533 // When the layer has an image, figure out whether it is covered by a single |
| 531 // tile. | 534 // tile. |
| 532 FloatRect imageTile; | 535 FloatRect imageTile; |
| 533 if (info.shouldPaintImage) { | 536 if (info.shouldPaintImage) { |
| 534 DCHECK(!geometry); | 537 DCHECK(!geometry); |
| 535 geometry.emplace(); | 538 geometry.emplace(); |
| 536 geometry->calculate(obj, paintInfo.paintContainer(), | 539 geometry->calculate(obj, backgroundObject, paintInfo.paintContainer(), |
| 537 paintInfo.getGlobalPaintFlags(), layer, rect); | 540 paintInfo.getGlobalPaintFlags(), layer, rect); |
| 538 | 541 |
| 539 if (!geometry->destRect().isEmpty()) { | 542 if (!geometry->destRect().isEmpty()) { |
| 540 // The tile is too small. | 543 // The tile is too small. |
| 541 if (geometry->tileSize().width() < rect.width() || | 544 if (geometry->tileSize().width() < rect.width() || |
| 542 geometry->tileSize().height() < rect.height()) | 545 geometry->tileSize().height() < rect.height()) |
| 543 return false; | 546 return false; |
| 544 | 547 |
| 545 imageTile = Image::computeTileContaining( | 548 imageTile = Image::computeTileContaining( |
| 546 FloatPoint(geometry->destRect().location()), | 549 FloatPoint(geometry->destRect().location()), |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 // painting area. | 739 // painting area. |
| 737 if (info.isBottomLayer && info.color.alpha() && info.shouldPaintColor) { | 740 if (info.isBottomLayer && info.color.alpha() && info.shouldPaintColor) { |
| 738 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); | 741 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); |
| 739 context.fillRect(backgroundRect, info.color); | 742 context.fillRect(backgroundRect, info.color); |
| 740 } | 743 } |
| 741 | 744 |
| 742 // no progressive loading of the background image | 745 // no progressive loading of the background image |
| 743 if (info.shouldPaintImage) { | 746 if (info.shouldPaintImage) { |
| 744 if (!geometry) { | 747 if (!geometry) { |
| 745 geometry.emplace(); | 748 geometry.emplace(); |
| 746 geometry->calculate(obj, paintInfo.paintContainer(), | 749 geometry->calculate(obj, backgroundObject, paintInfo.paintContainer(), |
| 747 paintInfo.getGlobalPaintFlags(), bgLayer, | 750 paintInfo.getGlobalPaintFlags(), bgLayer, |
| 748 scrolledPaintRect); | 751 scrolledPaintRect); |
| 749 } else { | 752 } else { |
| 750 // The geometry was calculated in paintFastBottomLayer(). | 753 // The geometry was calculated in paintFastBottomLayer(). |
| 751 DCHECK(info.isBottomLayer && info.isBorderFill && | 754 DCHECK(info.isBottomLayer && info.isBorderFill && |
| 752 !info.isClippedWithLocalScrolling); | 755 !info.isClippedWithLocalScrolling); |
| 753 } | 756 } |
| 754 | 757 |
| 755 if (!geometry->destRect().isEmpty()) { | 758 if (!geometry->destRect().isEmpty()) { |
| 756 const ImagePaintContext imageContext(obj, context, bgLayer, *info.image, | 759 const ImagePaintContext imageContext(obj, context, bgLayer, *info.image, |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy( | 1082 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy( |
| 1080 const ComputedStyle& style, | 1083 const ComputedStyle& style, |
| 1081 const Document& document) { | 1084 const Document& document) { |
| 1082 return document.printing() && | 1085 return document.printing() && |
| 1083 style.printColorAdjust() == EPrintColorAdjust::kEconomy && | 1086 style.printColorAdjust() == EPrintColorAdjust::kEconomy && |
| 1084 (!document.settings() || | 1087 (!document.settings() || |
| 1085 !document.settings()->getShouldPrintBackgrounds()); | 1088 !document.settings()->getShouldPrintBackgrounds()); |
| 1086 } | 1089 } |
| 1087 | 1090 |
| 1088 } // namespace blink | 1091 } // namespace blink |
| OLD | NEW |