| 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 20 matching lines...) Expand all Loading... |
| 31 #include "platform/geometry/LayoutRectOutsets.h" | 31 #include "platform/geometry/LayoutRectOutsets.h" |
| 32 #include "platform/graphics/GraphicsContextStateSaver.h" | 32 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 33 #include "platform/graphics/paint/CompositingDisplayItem.h" | 33 #include "platform/graphics/paint/CompositingDisplayItem.h" |
| 34 #include "wtf/Optional.h" | 34 #include "wtf/Optional.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 void BoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffse
t) | 38 void BoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffse
t) |
| 39 { | 39 { |
| 40 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBox.location(); | 40 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBox.location(); |
| 41 // default implementation. Just pass paint through to the children | 41 // Default implementation. Just pass paint through to the children. |
| 42 PaintInfo childInfo(paintInfo); | 42 PaintInfo childInfo(paintInfo); |
| 43 childInfo.updatePaintingRootForChildren(&m_layoutBox); | |
| 44 for (LayoutObject* child = m_layoutBox.slowFirstChild(); child; child = chil
d->nextSibling()) | 43 for (LayoutObject* child = m_layoutBox.slowFirstChild(); child; child = chil
d->nextSibling()) |
| 45 child->paint(childInfo, adjustedPaintOffset); | 44 child->paint(childInfo, adjustedPaintOffset); |
| 46 } | 45 } |
| 47 | 46 |
| 48 void BoxPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const
LayoutPoint& paintOffset) | 47 void BoxPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const
LayoutPoint& paintOffset) |
| 49 { | 48 { |
| 50 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox)) | |
| 51 return; | |
| 52 | |
| 53 LayoutRect paintRect = m_layoutBox.borderBoxRect(); | 49 LayoutRect paintRect = m_layoutBox.borderBoxRect(); |
| 54 paintRect.moveBy(paintOffset); | 50 paintRect.moveBy(paintOffset); |
| 55 paintBoxDecorationBackgroundWithRect(paintInfo, paintOffset, paintRect); | 51 paintBoxDecorationBackgroundWithRect(paintInfo, paintOffset, paintRect); |
| 56 } | 52 } |
| 57 | 53 |
| 58 LayoutRect BoxPainter::boundsForDrawingRecorder(const LayoutPoint& paintOffset) | 54 LayoutRect BoxPainter::boundsForDrawingRecorder(const LayoutPoint& paintOffset) |
| 59 { | 55 { |
| 60 // Use the visual overflow rect here, because it will include overflow intro
duced by the theme. | 56 // Use the visual overflow rect here, because it will include overflow intro
duced by the theme. |
| 61 LayoutRect bounds = m_layoutBox.visualOverflowRect(); | 57 LayoutRect bounds = m_layoutBox.visualOverflowRect(); |
| 62 bounds.moveBy(paintOffset); | 58 bounds.moveBy(paintOffset); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 obj.paint(info, scrolledPaintRect.location() - localOffset); | 479 obj.paint(info, scrolledPaintRect.location() - localOffset); |
| 484 } | 480 } |
| 485 | 481 |
| 486 context.endLayer(); | 482 context.endLayer(); |
| 487 context.endLayer(); | 483 context.endLayer(); |
| 488 } | 484 } |
| 489 } | 485 } |
| 490 | 486 |
| 491 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 487 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
| 492 { | 488 { |
| 493 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 489 if (m_layoutBox.style()->visibility() != VISIBLE || paintInfo.phase != Paint
PhaseMask) |
| 494 return; | 490 return; |
| 495 | 491 |
| 496 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, paintInfo.phase, paintOffset)) | 492 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, paintInfo.phase, paintOffset)) |
| 497 return; | 493 return; |
| 498 | 494 |
| 499 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); | 495 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); |
| 500 visualOverflowRect.moveBy(paintOffset); | 496 visualOverflowRect.moveBy(paintOffset); |
| 501 | 497 |
| 502 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, paintIn
fo.phase, visualOverflowRect, paintOffset); | 498 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, paintIn
fo.phase, visualOverflowRect, paintOffset); |
| 503 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); | 499 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 533 } | 529 } |
| 534 | 530 |
| 535 if (pushTransparencyLayer) | 531 if (pushTransparencyLayer) |
| 536 paintInfo.context.endLayer(); | 532 paintInfo.context.endLayer(); |
| 537 } | 533 } |
| 538 | 534 |
| 539 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) | 535 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) |
| 540 { | 536 { |
| 541 ASSERT(paintInfo.phase == PaintPhaseClippingMask); | 537 ASSERT(paintInfo.phase == PaintPhaseClippingMask); |
| 542 | 538 |
| 543 if (!paintInfo.shouldPaintWithinRoot(&m_layoutBox) || m_layoutBox.style()->v
isibility() != VISIBLE) | 539 if (m_layoutBox.style()->visibility() != VISIBLE) |
| 544 return; | 540 return; |
| 545 | 541 |
| 546 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint
sIntoOwnBacking) | 542 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint
sIntoOwnBacking) |
| 547 return; | 543 return; |
| 548 | 544 |
| 549 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, paintInfo.phase, paintOffset)) | 545 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutBox, paintInfo.phase, paintOffset)) |
| 550 return; | 546 return; |
| 551 | 547 |
| 552 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox.
size())); | 548 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox.
size())); |
| 553 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutBox,
paintInfo.phase, paintRect, paintOffset); | 549 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutBox,
paintInfo.phase, paintRect, paintOffset); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 } | 691 } |
| 696 } | 692 } |
| 697 | 693 |
| 698 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 694 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
| 699 { | 695 { |
| 700 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy | 696 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy |
| 701 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 697 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
| 702 } | 698 } |
| 703 | 699 |
| 704 } // namespace blink | 700 } // namespace blink |
| OLD | NEW |