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