| 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" |
| 11 #include "core/layout/LayoutBox.h" | 11 #include "core/layout/LayoutBox.h" |
| 12 #include "core/layout/LayoutBoxModelObject.h" | 12 #include "core/layout/LayoutBoxModelObject.h" |
| 13 #include "core/layout/LayoutObject.h" | 13 #include "core/layout/LayoutObject.h" |
| 14 #include "core/layout/LayoutTable.h" | 14 #include "core/layout/LayoutTable.h" |
| 15 #include "core/layout/LayoutTheme.h" | 15 #include "core/layout/LayoutTheme.h" |
| 16 #include "core/layout/compositing/CompositedLayerMapping.h" | 16 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 17 #include "core/layout/line/RootInlineBox.h" | 17 #include "core/layout/line/RootInlineBox.h" |
| 18 #include "core/style/BorderEdge.h" | 18 #include "core/style/BorderEdge.h" |
| 19 #include "core/style/ShadowList.h" | 19 #include "core/style/ShadowList.h" |
| 20 #include "core/paint/BackgroundImageGeometry.h" | 20 #include "core/paint/BackgroundImageGeometry.h" |
| 21 #include "core/paint/BoxBorderPainter.h" | 21 #include "core/paint/BoxBorderPainter.h" |
| 22 #include "core/paint/BoxDecorationData.h" | 22 #include "core/paint/BoxDecorationData.h" |
| 23 #include "core/paint/LayoutObjectDrawingRecorder.h" | 23 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 24 #include "core/paint/NinePieceImagePainter.h" | 24 #include "core/paint/NinePieceImagePainter.h" |
| 25 #include "core/paint/ObjectPainter.h" |
| 25 #include "core/paint/PaintInfo.h" | 26 #include "core/paint/PaintInfo.h" |
| 26 #include "core/paint/PaintLayer.h" | 27 #include "core/paint/PaintLayer.h" |
| 27 #include "core/paint/RoundedInnerRectClipper.h" | 28 #include "core/paint/RoundedInnerRectClipper.h" |
| 28 #include "core/paint/ScrollRecorder.h" | 29 #include "core/paint/ScrollRecorder.h" |
| 29 #include "core/paint/ThemePainter.h" | 30 #include "core/paint/ThemePainter.h" |
| 30 #include "platform/LengthFunctions.h" | 31 #include "platform/LengthFunctions.h" |
| 31 #include "platform/geometry/LayoutPoint.h" | 32 #include "platform/geometry/LayoutPoint.h" |
| 32 #include "platform/geometry/LayoutRectOutsets.h" | 33 #include "platform/geometry/LayoutRectOutsets.h" |
| 33 #include "platform/graphics/GraphicsContextStateSaver.h" | 34 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 34 #include "platform/graphics/paint/CompositingDisplayItem.h" | 35 #include "platform/graphics/paint/CompositingDisplayItem.h" |
| 35 #include "wtf/Optional.h" | 36 #include "wtf/Optional.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 bool isPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( | 42 bool isPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( |
| 42 const LayoutBoxModelObject* obj, | 43 const LayoutBoxModelObject* obj, |
| 43 const PaintInfo& paintInfo) { | 44 const PaintInfo& paintInfo) { |
| 44 return paintInfo.paintFlags() & PaintLayerPaintingOverflowContents && | 45 return paintInfo.paintFlags() & PaintLayerPaintingOverflowContents && |
| 45 !(paintInfo.paintFlags() & | 46 !(paintInfo.paintFlags() & |
| 46 PaintLayerPaintingCompositingBackgroundPhase) && | 47 PaintLayerPaintingCompositingBackgroundPhase) && |
| 47 obj == paintInfo.paintContainer(); | 48 obj == paintInfo.paintContainer(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 } // namespace | 51 } // namespace |
| 51 | 52 |
| 52 void BoxPainter::paint(const PaintInfo& paintInfo, | 53 void BoxPainter::paint(const PaintInfo& paintInfo, |
| 53 const LayoutPoint& paintOffset) { | 54 const LayoutPoint& paintOffset) { |
| 54 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBox.location(); | 55 ObjectPainter(m_layoutBox).checkPaintOffset(paintInfo, paintOffset); |
| 55 // Default implementation. Just pass paint through to the children. | 56 // Default implementation. Just pass paint through to the children. |
| 57 paintChildren(paintInfo, paintOffset + m_layoutBox.location()); |
| 58 } |
| 59 |
| 60 void BoxPainter::paintChildren(const PaintInfo& paintInfo, |
| 61 const LayoutPoint& paintOffset) { |
| 56 PaintInfo childInfo(paintInfo); | 62 PaintInfo childInfo(paintInfo); |
| 57 for (LayoutObject* child = m_layoutBox.slowFirstChild(); child; | 63 for (LayoutObject* child = m_layoutBox.slowFirstChild(); child; |
| 58 child = child->nextSibling()) | 64 child = child->nextSibling()) |
| 59 child->paint(childInfo, adjustedPaintOffset); | 65 child->paint(childInfo, paintOffset); |
| 60 } | 66 } |
| 61 | 67 |
| 62 void BoxPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, | 68 void BoxPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, |
| 63 const LayoutPoint& paintOffset) { | 69 const LayoutPoint& paintOffset) { |
| 64 LayoutRect paintRect; | 70 LayoutRect paintRect; |
| 65 Optional<ScrollRecorder> scrollRecorder; | 71 Optional<ScrollRecorder> scrollRecorder; |
| 66 if (isPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( | 72 if (isPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( |
| 67 &m_layoutBox, paintInfo)) { | 73 &m_layoutBox, paintInfo)) { |
| 68 // For the case where we are painting the background into the scrolling | 74 // For the case where we are painting the background into the scrolling |
| 69 // contents layer of a composited scroller we need to include the entire | 75 // contents layer of a composited scroller we need to include the entire |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy( | 1050 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy( |
| 1045 const ComputedStyle& style, | 1051 const ComputedStyle& style, |
| 1046 const Document& document) { | 1052 const Document& document) { |
| 1047 return document.printing() && | 1053 return document.printing() && |
| 1048 style.getPrintColorAdjust() == PrintColorAdjustEconomy && | 1054 style.getPrintColorAdjust() == PrintColorAdjustEconomy && |
| 1049 (!document.settings() || | 1055 (!document.settings() || |
| 1050 !document.settings()->shouldPrintBackgrounds()); | 1056 !document.settings()->shouldPrintBackgrounds()); |
| 1051 } | 1057 } |
| 1052 | 1058 |
| 1053 } // namespace blink | 1059 } // namespace blink |
| OLD | NEW |