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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 LayoutRect paintRect = m_renderBox.borderBoxRect(); | 47 LayoutRect paintRect = m_renderBox.borderBoxRect(); |
48 paintRect.moveBy(paintOffset); | 48 paintRect.moveBy(paintOffset); |
49 paintBoxDecorationBackgroundWithRect(paintInfo, paintOffset, paintRect); | 49 paintBoxDecorationBackgroundWithRect(paintInfo, paintOffset, paintRect); |
50 } | 50 } |
51 | 51 |
52 void BoxPainter::paintBoxDecorationBackgroundWithRect(PaintInfo& paintInfo, cons
t LayoutPoint& paintOffset, const LayoutRect& paintRect) | 52 void BoxPainter::paintBoxDecorationBackgroundWithRect(PaintInfo& paintInfo, cons
t LayoutPoint& paintOffset, const LayoutRect& paintRect) |
53 { | 53 { |
54 RenderStyle* style = m_renderBox.style(); | 54 RenderStyle* style = m_renderBox.style(); |
55 BoxDecorationData boxDecorationData(*style, m_renderBox.canRenderBorderImage
(), m_renderBox.backgroundHasOpaqueTopLayer(), paintInfo.context); | 55 BoxDecorationData boxDecorationData(*style, m_renderBox.canRenderBorderImage
(), m_renderBox.backgroundHasOpaqueTopLayer(), paintInfo.context); |
56 | 56 |
57 IntRect snappedPaintRect(pixelSnappedIntRect(paintRect)); | 57 LayoutRect bounds; |
58 // The document element is specified to paint its background infinitely. | 58 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
59 DrawingRecorder recorder(paintInfo.context, &m_renderBox, paintInfo.phase, | 59 if (m_renderBox.isDocumentElement()) { |
60 m_renderBox.isDocumentElement() ? m_renderBox.view()->backgroundRect(&m_
renderBox) : snappedPaintRect); | 60 // The document element is specified to paint its background infinit
ely. |
61 | 61 bounds = m_renderBox.view()->backgroundRect(&m_renderBox); |
| 62 } else { |
| 63 // Use the visual overflow rect here, because it will include overfl
ow introduced by the theme. |
| 64 bounds = m_renderBox.visualOverflowRect(); |
| 65 bounds.moveBy(paintOffset); |
| 66 } |
| 67 } |
| 68 DrawingRecorder recorder(paintInfo.context, &m_renderBox, paintInfo.phase, b
ounds); |
62 | 69 |
63 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have | 70 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have |
64 // custom shadows of their own. | 71 // custom shadows of their own. |
65 if (!m_renderBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee
dAvoidance())) | 72 if (!m_renderBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee
dAvoidance())) |
66 paintBoxShadow(paintInfo, paintRect, style, Normal); | 73 paintBoxShadow(paintInfo, paintRect, style, Normal); |
67 | 74 |
68 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); | 75 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); |
69 if (boxDecorationData.bleedAvoidance() == BackgroundBleedClipBackground) { | 76 if (boxDecorationData.bleedAvoidance() == BackgroundBleedClipBackground) { |
70 stateSaver.save(); | 77 stateSaver.save(); |
71 RoundedRect border = style->getRoundedBorderFor(paintRect); | 78 RoundedRect border = style->getRoundedBorderFor(paintRect); |
72 paintInfo.context->clipRoundedRect(border); | 79 paintInfo.context->clipRoundedRect(border); |
73 } | 80 } |
74 | 81 |
75 // If we have a native theme appearance, paint that before painting our back
ground. | 82 // If we have a native theme appearance, paint that before painting our back
ground. |
76 // The theme will tell us whether or not we should also paint the CSS backgr
ound. | 83 // The theme will tell us whether or not we should also paint the CSS backgr
ound. |
| 84 IntRect snappedPaintRect(pixelSnappedIntRect(paintRect)); |
77 bool themePainted = boxDecorationData.hasAppearance && !RenderTheme::theme()
.paint(&m_renderBox, paintInfo, snappedPaintRect); | 85 bool themePainted = boxDecorationData.hasAppearance && !RenderTheme::theme()
.paint(&m_renderBox, paintInfo, snappedPaintRect); |
78 if (!themePainted) { | 86 if (!themePainted) { |
79 if (boxDecorationData.bleedAvoidance() == BackgroundBleedBackgroundOverB
order) | 87 if (boxDecorationData.bleedAvoidance() == BackgroundBleedBackgroundOverB
order) |
80 paintBorder(m_renderBox, paintInfo, paintRect, style, boxDecorationD
ata.bleedAvoidance()); | 88 paintBorder(m_renderBox, paintInfo, paintRect, style, boxDecorationD
ata.bleedAvoidance()); |
81 | 89 |
82 paintBackground(paintInfo, paintRect, boxDecorationData.backgroundColor,
boxDecorationData.bleedAvoidance()); | 90 paintBackground(paintInfo, paintRect, boxDecorationData.backgroundColor,
boxDecorationData.bleedAvoidance()); |
83 | 91 |
84 if (boxDecorationData.hasAppearance) | 92 if (boxDecorationData.hasAppearance) |
85 RenderTheme::theme().paintDecorations(&m_renderBox, paintInfo, snapp
edPaintRect); | 93 RenderTheme::theme().paintDecorations(&m_renderBox, paintInfo, snapp
edPaintRect); |
86 } | 94 } |
(...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 | 2160 |
2153 FloatPoint secondQuad[4]; | 2161 FloatPoint secondQuad[4]; |
2154 secondQuad[0] = quad[0]; | 2162 secondQuad[0] = quad[0]; |
2155 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); | 2163 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); |
2156 secondQuad[2] = quad[2]; | 2164 secondQuad[2] = quad[2]; |
2157 secondQuad[3] = quad[3]; | 2165 secondQuad[3] = quad[3]; |
2158 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); | 2166 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); |
2159 } | 2167 } |
2160 | 2168 |
2161 } // namespace blink | 2169 } // namespace blink |
OLD | NEW |