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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo
, const LayoutPoint& paintOffset, const LayoutRect& paintRect) | 79 void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo
, const LayoutPoint& paintOffset, const LayoutRect& paintRect) |
80 { | 80 { |
81 const ComputedStyle& style = m_layoutBox.styleRef(); | 81 const ComputedStyle& style = m_layoutBox.styleRef(); |
82 | 82 |
83 // FIXME: For now we don't have notification on media buffered range change
from media player | 83 // FIXME: For now we don't have notification on media buffered range change
from media player |
84 // and miss paint invalidation on buffered range change. crbug.com/484288. | 84 // and miss paint invalidation on buffered range change. crbug.com/484288. |
85 Optional<DisplayItemCacheSkipper> cacheSkipper; | 85 Optional<DisplayItemCacheSkipper> cacheSkipper; |
86 if (style.appearance() == MediaSliderPart) | 86 if (style.appearance() == MediaSliderPart) |
87 cacheSkipper.emplace(*paintInfo.context); | 87 cacheSkipper.emplace(*paintInfo.context); |
88 | 88 |
89 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutBox, DisplayItem::BoxDecorationBackground)) | 89 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutBox, DisplayItem::BoxDecorationBackground, paintOffset)) |
90 return; | 90 return; |
91 | 91 |
92 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBox, Displa
yItem::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset)); | 92 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBox, Displa
yItem::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset), paintOffs
et); |
93 | 93 |
94 BoxDecorationData boxDecorationData(m_layoutBox); | 94 BoxDecorationData boxDecorationData(m_layoutBox); |
95 | 95 |
96 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have | 96 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have |
97 // custom shadows of their own. | 97 // custom shadows of their own. |
98 if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee
dAvoidance)) | 98 if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee
dAvoidance)) |
99 paintBoxShadow(paintInfo, paintRect, style, Normal); | 99 paintBoxShadow(paintInfo, paintRect, style, Normal); |
100 | 100 |
101 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); | 101 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); |
102 if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) { | 102 if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 context->endLayer(); | 504 context->endLayer(); |
505 context->endLayer(); | 505 context->endLayer(); |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 509 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
510 { | 510 { |
511 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 511 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) |
512 return; | 512 return; |
513 | 513 |
514 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutBox, paintInfo.phase)) | 514 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutBox, paintInfo.phase, paintOffset)) |
515 return; | 515 return; |
516 | 516 |
517 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); | 517 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); |
518 visualOverflowRect.moveBy(paintOffset); | 518 visualOverflowRect.moveBy(paintOffset); |
519 | 519 |
520 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBox, paintI
nfo.phase, visualOverflowRect); | 520 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBox, paintI
nfo.phase, visualOverflowRect, paintOffset); |
521 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); | 521 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); |
522 paintMaskImages(paintInfo, paintRect); | 522 paintMaskImages(paintInfo, paintRect); |
523 } | 523 } |
524 | 524 |
525 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p
aintRect) | 525 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p
aintRect) |
526 { | 526 { |
527 // Figure out if we need to push a transparency layer to render our mask. | 527 // Figure out if we need to push a transparency layer to render our mask. |
528 bool pushTransparencyLayer = false; | 528 bool pushTransparencyLayer = false; |
529 bool compositedMask = m_layoutBox.hasLayer() && m_layoutBox.layer()->hasComp
ositedMask(); | 529 bool compositedMask = m_layoutBox.hasLayer() && m_layoutBox.layer()->hasComp
ositedMask(); |
530 bool flattenCompositingLayers = paintInfo.globalPaintFlags() & GlobalPaintFl
attenCompositingLayers; | 530 bool flattenCompositingLayers = paintInfo.globalPaintFlags() & GlobalPaintFl
attenCompositingLayers; |
(...skipping 26 matching lines...) Expand all Loading... |
557 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) | 557 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) |
558 { | 558 { |
559 ASSERT(paintInfo.phase == PaintPhaseClippingMask); | 559 ASSERT(paintInfo.phase == PaintPhaseClippingMask); |
560 | 560 |
561 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE) | 561 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE) |
562 return; | 562 return; |
563 | 563 |
564 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint
sIntoOwnBacking) | 564 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint
sIntoOwnBacking) |
565 return; | 565 return; |
566 | 566 |
567 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutBox, paintInfo.phase)) | 567 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutBox, paintInfo.phase, paintOffset)) |
568 return; | 568 return; |
569 | 569 |
570 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox.
size())); | 570 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox.
size())); |
571 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layoutBox,
paintInfo.phase, paintRect); | 571 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layoutBox,
paintInfo.phase, paintRect, paintOffset); |
572 paintInfo.context->fillRect(paintRect, Color::black); | 572 paintInfo.context->fillRect(paintRect, Color::black); |
573 } | 573 } |
574 | 574 |
575 InterpolationQuality BoxPainter::chooseInterpolationQuality(LayoutObject& obj, G
raphicsContext* context, Image* image, const void* layer, const LayoutSize& size
) | 575 InterpolationQuality BoxPainter::chooseInterpolationQuality(LayoutObject& obj, G
raphicsContext* context, Image* image, const void* layer, const LayoutSize& size
) |
576 { | 576 { |
577 return ImageQualityController::imageQualityController()->chooseInterpolation
Quality(context, &obj, image, layer, size); | 577 return ImageQualityController::imageQualityController()->chooseInterpolation
Quality(context, &obj, image, layer, size); |
578 } | 578 } |
579 | 579 |
580 bool BoxPainter::paintNinePieceImage(LayoutBoxModelObject& obj, GraphicsContext*
graphicsContext, const LayoutRect& rect, const ComputedStyle& style, const Nine
PieceImage& ninePieceImage, SkXfermode::Mode op) | 580 bool BoxPainter::paintNinePieceImage(LayoutBoxModelObject& obj, GraphicsContext*
graphicsContext, const LayoutRect& rect, const ComputedStyle& style, const Nine
PieceImage& ninePieceImage, SkXfermode::Mode op) |
581 { | 581 { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 } | 762 } |
763 } | 763 } |
764 | 764 |
765 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 765 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
766 { | 766 { |
767 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy | 767 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy |
768 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 768 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
769 } | 769 } |
770 | 770 |
771 } // namespace blink | 771 } // namespace blink |
OLD | NEW |