| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo
, const LayoutPoint& paintOffset, const LayoutRect& paintRect) | 71 void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo
, const LayoutPoint& paintOffset, const LayoutRect& paintRect) |
| 72 { | 72 { |
| 73 const ComputedStyle& style = m_layoutBox.styleRef(); | 73 const ComputedStyle& style = m_layoutBox.styleRef(); |
| 74 | 74 |
| 75 // FIXME: For now we don't have notification on media buffered range change
from media player | 75 // FIXME: For now we don't have notification on media buffered range change
from media player |
| 76 // and miss paint invalidation on buffered range change. crbug.com/484288. | 76 // and miss paint invalidation on buffered range change. crbug.com/484288. |
| 77 Optional<DisplayItemCacheSkipper> cacheSkipper; | 77 Optional<DisplayItemCacheSkipper> cacheSkipper; |
| 78 if (style.appearance() == MediaSliderPart) | 78 if (style.appearance() == MediaSliderPart) |
| 79 cacheSkipper.emplace(paintInfo.context); | 79 cacheSkipper.emplace(paintInfo.context); |
| 80 | 80 |
| 81 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, DisplayItem::BoxDecorationBackground, paintOffset)) | 81 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, DisplayItem::BoxDecorationBackground)) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, Display
Item::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset), paintOffse
t); | 84 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, Display
Item::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset)); |
| 85 | 85 |
| 86 BoxDecorationData boxDecorationData(m_layoutBox); | 86 BoxDecorationData boxDecorationData(m_layoutBox); |
| 87 | 87 |
| 88 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have | 88 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have |
| 89 // custom shadows of their own. | 89 // custom shadows of their own. |
| 90 if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee
dAvoidance)) | 90 if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee
dAvoidance)) |
| 91 paintBoxShadow(paintInfo, paintRect, style, Normal); | 91 paintBoxShadow(paintInfo, paintRect, style, Normal); |
| 92 | 92 |
| 93 GraphicsContextStateSaver stateSaver(paintInfo.context, false); | 93 GraphicsContextStateSaver stateSaver(paintInfo.context, false); |
| 94 if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) { | 94 if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) { |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 context.endLayer(); | 481 context.endLayer(); |
| 482 context.endLayer(); | 482 context.endLayer(); |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 | 485 |
| 486 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 486 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
| 487 { | 487 { |
| 488 if (m_layoutBox.style()->visibility() != VISIBLE || paintInfo.phase != Paint
PhaseMask) | 488 if (m_layoutBox.style()->visibility() != VISIBLE || paintInfo.phase != Paint
PhaseMask) |
| 489 return; | 489 return; |
| 490 | 490 |
| 491 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, paintInfo.phase, paintOffset)) | 491 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, paintInfo.phase)) |
| 492 return; | 492 return; |
| 493 | 493 |
| 494 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); | 494 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); |
| 495 visualOverflowRect.moveBy(paintOffset); | 495 visualOverflowRect.moveBy(paintOffset); |
| 496 | 496 |
| 497 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, paintIn
fo.phase, visualOverflowRect, paintOffset); | 497 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, paintIn
fo.phase, visualOverflowRect); |
| 498 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); | 498 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); |
| 499 paintMaskImages(paintInfo, paintRect); | 499 paintMaskImages(paintInfo, paintRect); |
| 500 } | 500 } |
| 501 | 501 |
| 502 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p
aintRect) | 502 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p
aintRect) |
| 503 { | 503 { |
| 504 // Figure out if we need to push a transparency layer to render our mask. | 504 // Figure out if we need to push a transparency layer to render our mask. |
| 505 bool pushTransparencyLayer = false; | 505 bool pushTransparencyLayer = false; |
| 506 bool compositedMask = m_layoutBox.hasLayer() && m_layoutBox.layer()->hasComp
ositedMask(); | 506 bool compositedMask = m_layoutBox.hasLayer() && m_layoutBox.layer()->hasComp
ositedMask(); |
| 507 bool flattenCompositingLayers = paintInfo.getGlobalPaintFlags() & GlobalPain
tFlattenCompositingLayers; | 507 bool flattenCompositingLayers = paintInfo.getGlobalPaintFlags() & GlobalPain
tFlattenCompositingLayers; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 534 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) | 534 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) |
| 535 { | 535 { |
| 536 ASSERT(paintInfo.phase == PaintPhaseClippingMask); | 536 ASSERT(paintInfo.phase == PaintPhaseClippingMask); |
| 537 | 537 |
| 538 if (m_layoutBox.style()->visibility() != VISIBLE) | 538 if (m_layoutBox.style()->visibility() != VISIBLE) |
| 539 return; | 539 return; |
| 540 | 540 |
| 541 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint
sIntoOwnBacking) | 541 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint
sIntoOwnBacking) |
| 542 return; | 542 return; |
| 543 | 543 |
| 544 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, paintInfo.phase, paintOffset)) | 544 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, paintInfo.phase)) |
| 545 return; | 545 return; |
| 546 | 546 |
| 547 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox.
size())); | 547 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox.
size())); |
| 548 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutBox,
paintInfo.phase, paintRect, paintOffset); | 548 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutBox,
paintInfo.phase, paintRect); |
| 549 paintInfo.context.fillRect(paintRect, Color::black); | 549 paintInfo.context.fillRect(paintRect, Color::black); |
| 550 } | 550 } |
| 551 | 551 |
| 552 InterpolationQuality BoxPainter::chooseInterpolationQuality(const LayoutObject&
obj, Image* image, const void* layer, const LayoutSize& size) | 552 InterpolationQuality BoxPainter::chooseInterpolationQuality(const LayoutObject&
obj, Image* image, const void* layer, const LayoutSize& size) |
| 553 { | 553 { |
| 554 return ImageQualityController::imageQualityController()->chooseInterpolation
Quality(obj, image, layer, size); | 554 return ImageQualityController::imageQualityController()->chooseInterpolation
Quality(obj, image, layer, size); |
| 555 } | 555 } |
| 556 | 556 |
| 557 bool BoxPainter::paintNinePieceImage(const LayoutBoxModelObject& obj, GraphicsCo
ntext& graphicsContext, const LayoutRect& rect, const ComputedStyle& style, cons
t NinePieceImage& ninePieceImage, SkXfermode::Mode op) | 557 bool BoxPainter::paintNinePieceImage(const LayoutBoxModelObject& obj, GraphicsCo
ntext& graphicsContext, const LayoutRect& rect, const ComputedStyle& style, cons
t NinePieceImage& ninePieceImage, SkXfermode::Mode op) |
| 558 { | 558 { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 690 } |
| 691 } | 691 } |
| 692 | 692 |
| 693 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 693 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
| 694 { | 694 { |
| 695 return document.printing() && style.getPrintColorAdjust() == PrintColorAdjus
tEconomy | 695 return document.printing() && style.getPrintColorAdjust() == PrintColorAdjus
tEconomy |
| 696 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 696 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
| 697 } | 697 } |
| 698 | 698 |
| 699 } // namespace blink | 699 } // namespace blink |
| OLD | NEW |