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