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/FieldsetPainter.h" | 6 #include "core/paint/FieldsetPainter.h" |
7 | 7 |
8 #include "core/layout/LayoutFieldset.h" | 8 #include "core/layout/LayoutFieldset.h" |
9 #include "core/paint/BoxDecorationData.h" | 9 #include "core/paint/BoxDecorationData.h" |
10 #include "core/paint/BoxPainter.h" | 10 #include "core/paint/BoxPainter.h" |
11 #include "core/paint/LayoutObjectDrawingRecorder.h" | 11 #include "core/paint/LayoutObjectDrawingRecorder.h" |
12 #include "core/paint/PaintInfo.h" | 12 #include "core/paint/PaintInfo.h" |
13 #include "platform/graphics/GraphicsContextStateSaver.h" | 13 #include "platform/graphics/GraphicsContextStateSaver.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 void FieldsetPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, c
onst LayoutPoint& paintOffset) | 17 void FieldsetPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, c
onst LayoutPoint& paintOffset) |
18 { | 18 { |
19 if (!paintInfo.shouldPaintWithinRoot(&m_layoutFieldset)) | 19 if (!paintInfo.shouldPaintWithinRoot(&m_layoutFieldset)) |
20 return; | 20 return; |
21 | 21 |
22 LayoutRect paintRect(paintOffset, m_layoutFieldset.size()); | 22 LayoutRect paintRect(paintOffset, m_layoutFieldset.size()); |
23 LayoutBox* legend = m_layoutFieldset.findInFlowLegend(); | 23 LayoutBox* legend = m_layoutFieldset.findInFlowLegend(); |
24 if (!legend) | 24 if (!legend) |
25 return BoxPainter(m_layoutFieldset).paintBoxDecorationBackground(paintIn
fo, paintOffset); | 25 return BoxPainter(m_layoutFieldset).paintBoxDecorationBackground(paintIn
fo, paintOffset); |
26 | 26 |
27 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutFieldset, paintInfo.phase, paintOffset)) | 27 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutFieldset, paintInfo.phase, paintOffset)) |
28 return; | 28 return; |
29 | 29 |
30 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e | 30 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e |
31 // cases the legend is embedded in the right and bottom borders respectively
. | 31 // cases the legend is embedded in the right and bottom borders respectively
. |
32 // https://bugs.webkit.org/show_bug.cgi?id=47236 | 32 // https://bugs.webkit.org/show_bug.cgi?id=47236 |
33 if (m_layoutFieldset.style()->isHorizontalWritingMode()) { | 33 if (m_layoutFieldset.style()->isHorizontalWritingMode()) { |
34 LayoutUnit yOff = (legend->location().y() > 0) ? LayoutUnit() : (legend-
>size().height() - m_layoutFieldset.borderTop()) / 2; | 34 LayoutUnit yOff = (legend->location().y() > 0) ? LayoutUnit() : (legend-
>size().height() - m_layoutFieldset.borderTop()) / 2; |
35 paintRect.setHeight(paintRect.height() - yOff); | 35 paintRect.setHeight(paintRect.height() - yOff); |
36 paintRect.setY(paintRect.y() + yOff); | 36 paintRect.setY(paintRect.y() + yOff); |
37 } else { | 37 } else { |
38 LayoutUnit xOff = (legend->location().x() > 0) ? LayoutUnit() : (legend-
>size().width() - m_layoutFieldset.borderLeft()) / 2; | 38 LayoutUnit xOff = (legend->location().x() > 0) ? LayoutUnit() : (legend-
>size().width() - m_layoutFieldset.borderLeft()) / 2; |
39 paintRect.setWidth(paintRect.width() - xOff); | 39 paintRect.setWidth(paintRect.width() - xOff); |
40 paintRect.setX(paintRect.x() + xOff); | 40 paintRect.setX(paintRect.x() + xOff); |
41 } | 41 } |
42 | 42 |
43 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFieldset, p
aintInfo.phase, paintRect, paintOffset); | 43 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFieldset, pa
intInfo.phase, paintRect, paintOffset); |
44 BoxDecorationData boxDecorationData(m_layoutFieldset); | 44 BoxDecorationData boxDecorationData(m_layoutFieldset); |
45 | 45 |
46 if (boxDecorationData.bleedAvoidance == BackgroundBleedNone) | 46 if (boxDecorationData.bleedAvoidance == BackgroundBleedNone) |
47 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutFieldset.styleR
ef(), Normal); | 47 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutFieldset.styleR
ef(), Normal); |
48 BoxPainter(m_layoutFieldset).paintFillLayers(paintInfo, boxDecorationData.ba
ckgroundColor, m_layoutFieldset.style()->backgroundLayers(), paintRect); | 48 BoxPainter(m_layoutFieldset).paintFillLayers(paintInfo, boxDecorationData.ba
ckgroundColor, m_layoutFieldset.style()->backgroundLayers(), paintRect); |
49 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutFieldset.styleRef()
, Inset); | 49 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutFieldset.styleRef()
, Inset); |
50 | 50 |
51 if (!boxDecorationData.hasBorderDecoration) | 51 if (!boxDecorationData.hasBorderDecoration) |
52 return; | 52 return; |
53 | 53 |
54 // Create a clipping region around the legend and paint the border as normal | 54 // Create a clipping region around the legend and paint the border as normal |
55 GraphicsContext* graphicsContext = paintInfo.context; | 55 GraphicsContext& graphicsContext = paintInfo.context; |
56 GraphicsContextStateSaver stateSaver(*graphicsContext); | 56 GraphicsContextStateSaver stateSaver(graphicsContext); |
57 | 57 |
58 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e | 58 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e |
59 // cases the legend is embedded in the right and bottom borders respectively
. | 59 // cases the legend is embedded in the right and bottom borders respectively
. |
60 // https://bugs.webkit.org/show_bug.cgi?id=47236 | 60 // https://bugs.webkit.org/show_bug.cgi?id=47236 |
61 if (m_layoutFieldset.style()->isHorizontalWritingMode()) { | 61 if (m_layoutFieldset.style()->isHorizontalWritingMode()) { |
62 LayoutUnit clipTop = paintRect.y(); | 62 LayoutUnit clipTop = paintRect.y(); |
63 LayoutUnit clipHeight = max(static_cast<LayoutUnit>(m_layoutFieldset.sty
le()->borderTopWidth()), legend->size().height() - ((legend->size().height() - m
_layoutFieldset.borderTop()) / 2)); | 63 LayoutUnit clipHeight = max(static_cast<LayoutUnit>(m_layoutFieldset.sty
le()->borderTopWidth()), legend->size().height() - ((legend->size().height() - m
_layoutFieldset.borderTop()) / 2)); |
64 graphicsContext->clipOut(pixelSnappedIntRect(paintRect.x() + legend->loc
ation().x(), clipTop, legend->size().width(), clipHeight)); | 64 graphicsContext.clipOut(pixelSnappedIntRect(paintRect.x() + legend->loca
tion().x(), clipTop, legend->size().width(), clipHeight)); |
65 } else { | 65 } else { |
66 LayoutUnit clipLeft = paintRect.x(); | 66 LayoutUnit clipLeft = paintRect.x(); |
67 LayoutUnit clipWidth = max(static_cast<LayoutUnit>(m_layoutFieldset.styl
e()->borderLeftWidth()), legend->size().width()); | 67 LayoutUnit clipWidth = max(static_cast<LayoutUnit>(m_layoutFieldset.styl
e()->borderLeftWidth()), legend->size().width()); |
68 graphicsContext->clipOut(pixelSnappedIntRect(clipLeft, paintRect.y() + l
egend->location().y(), clipWidth, legend->size().height())); | 68 graphicsContext.clipOut(pixelSnappedIntRect(clipLeft, paintRect.y() + le
gend->location().y(), clipWidth, legend->size().height())); |
69 } | 69 } |
70 | 70 |
71 BoxPainter::paintBorder(m_layoutFieldset, paintInfo, paintRect, m_layoutFiel
dset.styleRef()); | 71 BoxPainter::paintBorder(m_layoutFieldset, paintInfo, paintRect, m_layoutFiel
dset.styleRef()); |
72 } | 72 } |
73 | 73 |
74 void FieldsetPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& p
aintOffset) | 74 void FieldsetPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& p
aintOffset) |
75 { | 75 { |
76 if (m_layoutFieldset.style()->visibility() != VISIBLE || paintInfo.phase !=
PaintPhaseMask) | 76 if (m_layoutFieldset.style()->visibility() != VISIBLE || paintInfo.phase !=
PaintPhaseMask) |
77 return; | 77 return; |
78 | 78 |
79 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutFieldset.size()); | 79 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutFieldset.size()); |
80 LayoutBox* legend = m_layoutFieldset.findInFlowLegend(); | 80 LayoutBox* legend = m_layoutFieldset.findInFlowLegend(); |
81 if (!legend) | 81 if (!legend) |
82 return BoxPainter(m_layoutFieldset).paintMask(paintInfo, paintOffset); | 82 return BoxPainter(m_layoutFieldset).paintMask(paintInfo, paintOffset); |
83 | 83 |
84 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutFieldset, paintInfo.phase, paintOffset)) | 84 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutFieldset, paintInfo.phase, paintOffset)) |
85 return; | 85 return; |
86 | 86 |
87 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e | 87 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e |
88 // cases the legend is embedded in the right and bottom borders respectively
. | 88 // cases the legend is embedded in the right and bottom borders respectively
. |
89 // https://bugs.webkit.org/show_bug.cgi?id=47236 | 89 // https://bugs.webkit.org/show_bug.cgi?id=47236 |
90 if (m_layoutFieldset.style()->isHorizontalWritingMode()) { | 90 if (m_layoutFieldset.style()->isHorizontalWritingMode()) { |
91 LayoutUnit yOff = (legend->location().y() > 0) ? LayoutUnit() : (legend-
>size().height() - m_layoutFieldset.borderTop()) / 2; | 91 LayoutUnit yOff = (legend->location().y() > 0) ? LayoutUnit() : (legend-
>size().height() - m_layoutFieldset.borderTop()) / 2; |
92 paintRect.expand(0, -yOff); | 92 paintRect.expand(0, -yOff); |
93 paintRect.move(0, yOff); | 93 paintRect.move(0, yOff); |
94 } else { | 94 } else { |
95 LayoutUnit xOff = (legend->location().x() > 0) ? LayoutUnit() : (legend-
>size().width() - m_layoutFieldset.borderLeft()) / 2; | 95 LayoutUnit xOff = (legend->location().x() > 0) ? LayoutUnit() : (legend-
>size().width() - m_layoutFieldset.borderLeft()) / 2; |
96 paintRect.expand(-xOff, 0); | 96 paintRect.expand(-xOff, 0); |
97 paintRect.move(xOff, 0); | 97 paintRect.move(xOff, 0); |
98 } | 98 } |
99 | 99 |
100 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFieldset, p
aintInfo.phase, paintRect, paintOffset); | 100 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFieldset, pa
intInfo.phase, paintRect, paintOffset); |
101 BoxPainter(m_layoutFieldset).paintMaskImages(paintInfo, paintRect); | 101 BoxPainter(m_layoutFieldset).paintMaskImages(paintInfo, paintRect); |
102 } | 102 } |
103 | 103 |
104 } // namespace blink | 104 } // namespace blink |
OLD | NEW |