| 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)) |
| 90 return; |
| 91 |
| 89 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBox, Displa
yItem::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset)); | 92 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBox, Displa
yItem::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset)); |
| 90 if (recorder.canUseCachedDrawing()) | |
| 91 return; | |
| 92 | 93 |
| 93 BoxDecorationData boxDecorationData(m_layoutBox); | 94 BoxDecorationData boxDecorationData(m_layoutBox); |
| 94 | 95 |
| 95 // 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 |
| 96 // custom shadows of their own. | 97 // custom shadows of their own. |
| 97 if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee
dAvoidance)) | 98 if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee
dAvoidance)) |
| 98 paintBoxShadow(paintInfo, paintRect, style, Normal); | 99 paintBoxShadow(paintInfo, paintRect, style, Normal); |
| 99 | 100 |
| 100 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); | 101 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); |
| 101 if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) { | 102 if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 context->endLayer(); | 505 context->endLayer(); |
| 505 context->endLayer(); | 506 context->endLayer(); |
| 506 } | 507 } |
| 507 } | 508 } |
| 508 | 509 |
| 509 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 510 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
| 510 { | 511 { |
| 511 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 512 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) |
| 512 return; | 513 return; |
| 513 | 514 |
| 515 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutBox, paintInfo.phase)) |
| 516 return; |
| 517 |
| 514 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); | 518 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); |
| 515 visualOverflowRect.moveBy(paintOffset); | 519 visualOverflowRect.moveBy(paintOffset); |
| 516 | 520 |
| 517 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBox, paintI
nfo.phase, visualOverflowRect); | 521 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBox, paintI
nfo.phase, visualOverflowRect); |
| 518 if (recorder.canUseCachedDrawing()) | |
| 519 return; | |
| 520 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); | 522 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); |
| 521 paintMaskImages(paintInfo, paintRect); | 523 paintMaskImages(paintInfo, paintRect); |
| 522 } | 524 } |
| 523 | 525 |
| 524 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p
aintRect) | 526 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p
aintRect) |
| 525 { | 527 { |
| 526 // Figure out if we need to push a transparency layer to render our mask. | 528 // Figure out if we need to push a transparency layer to render our mask. |
| 527 bool pushTransparencyLayer = false; | 529 bool pushTransparencyLayer = false; |
| 528 bool compositedMask = m_layoutBox.hasLayer() && m_layoutBox.layer()->hasComp
ositedMask(); | 530 bool compositedMask = m_layoutBox.hasLayer() && m_layoutBox.layer()->hasComp
ositedMask(); |
| 529 bool flattenCompositingLayers = m_layoutBox.view()->frameView() && m_layoutB
ox.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; | 531 bool flattenCompositingLayers = m_layoutBox.view()->frameView() && m_layoutB
ox.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 556 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) | 558 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) |
| 557 { | 559 { |
| 558 ASSERT(paintInfo.phase == PaintPhaseClippingMask); | 560 ASSERT(paintInfo.phase == PaintPhaseClippingMask); |
| 559 | 561 |
| 560 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE) | 562 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE) |
| 561 return; | 563 return; |
| 562 | 564 |
| 563 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint
sIntoOwnBacking) | 565 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint
sIntoOwnBacking) |
| 564 return; | 566 return; |
| 565 | 567 |
| 568 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutBox, paintInfo.phase)) |
| 569 return; |
| 570 |
| 566 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox.
size())); | 571 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox.
size())); |
| 567 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layoutBox,
paintInfo.phase, paintRect); | 572 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layoutBox,
paintInfo.phase, paintRect); |
| 568 if (drawingRecorder.canUseCachedDrawing()) | |
| 569 return; | |
| 570 | |
| 571 paintInfo.context->fillRect(paintRect, Color::black); | 573 paintInfo.context->fillRect(paintRect, Color::black); |
| 572 } | 574 } |
| 573 | 575 |
| 574 // Return the amount of space to leave between image tiles for the background-re
peat: space property. | 576 // Return the amount of space to leave between image tiles for the background-re
peat: space property. |
| 575 static inline int getSpaceBetweenImageTiles(int areaSize, int tileSize) | 577 static inline int getSpaceBetweenImageTiles(int areaSize, int tileSize) |
| 576 { | 578 { |
| 577 int numberOfTiles = areaSize / tileSize; | 579 int numberOfTiles = areaSize / tileSize; |
| 578 int space = -1; | 580 int space = -1; |
| 579 | 581 |
| 580 if (numberOfTiles > 1) { | 582 if (numberOfTiles > 1) { |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 } | 1047 } |
| 1046 } | 1048 } |
| 1047 | 1049 |
| 1048 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 1050 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
| 1049 { | 1051 { |
| 1050 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy | 1052 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy |
| 1051 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 1053 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
| 1052 } | 1054 } |
| 1053 | 1055 |
| 1054 } // namespace blink | 1056 } // namespace blink |
| OLD | NEW |