| 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)) | 27 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, 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 // TODO(chrishtr): pixel-snapping here is likely wrong. | 43 // TODO(chrishtr): pixel-snapping here is likely wrong. |
| 44 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFieldset, p
aintInfo.phase, paintRect); | 44 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFieldset, p
aintInfo.phase, paintRect, paintOffset); |
| 45 BoxDecorationData boxDecorationData(m_layoutFieldset); | 45 BoxDecorationData boxDecorationData(m_layoutFieldset); |
| 46 | 46 |
| 47 if (boxDecorationData.bleedAvoidance == BackgroundBleedNone) | 47 if (boxDecorationData.bleedAvoidance == BackgroundBleedNone) |
| 48 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutFieldset.styleR
ef(), Normal); | 48 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutFieldset.styleR
ef(), Normal); |
| 49 BoxPainter(m_layoutFieldset).paintFillLayers(paintInfo, boxDecorationData.ba
ckgroundColor, m_layoutFieldset.style()->backgroundLayers(), paintRect); | 49 BoxPainter(m_layoutFieldset).paintFillLayers(paintInfo, boxDecorationData.ba
ckgroundColor, m_layoutFieldset.style()->backgroundLayers(), paintRect); |
| 50 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutFieldset.styleRef()
, Inset); | 50 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutFieldset.styleRef()
, Inset); |
| 51 | 51 |
| 52 if (!boxDecorationData.hasBorderDecoration) | 52 if (!boxDecorationData.hasBorderDecoration) |
| 53 return; | 53 return; |
| 54 | 54 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 void FieldsetPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& p
aintOffset) | 75 void FieldsetPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& p
aintOffset) |
| 76 { | 76 { |
| 77 if (m_layoutFieldset.style()->visibility() != VISIBLE || paintInfo.phase !=
PaintPhaseMask) | 77 if (m_layoutFieldset.style()->visibility() != VISIBLE || paintInfo.phase !=
PaintPhaseMask) |
| 78 return; | 78 return; |
| 79 | 79 |
| 80 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutFieldset.size()); | 80 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutFieldset.size()); |
| 81 LayoutBox* legend = m_layoutFieldset.findInFlowLegend(); | 81 LayoutBox* legend = m_layoutFieldset.findInFlowLegend(); |
| 82 if (!legend) | 82 if (!legend) |
| 83 return BoxPainter(m_layoutFieldset).paintMask(paintInfo, paintOffset); | 83 return BoxPainter(m_layoutFieldset).paintMask(paintInfo, paintOffset); |
| 84 | 84 |
| 85 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutFieldset, paintInfo.phase)) | 85 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutFieldset, paintInfo.phase, paintOffset)) |
| 86 return; | 86 return; |
| 87 | 87 |
| 88 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e | 88 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e |
| 89 // cases the legend is embedded in the right and bottom borders respectively
. | 89 // cases the legend is embedded in the right and bottom borders respectively
. |
| 90 // https://bugs.webkit.org/show_bug.cgi?id=47236 | 90 // https://bugs.webkit.org/show_bug.cgi?id=47236 |
| 91 if (m_layoutFieldset.style()->isHorizontalWritingMode()) { | 91 if (m_layoutFieldset.style()->isHorizontalWritingMode()) { |
| 92 LayoutUnit yOff = (legend->location().y() > 0) ? LayoutUnit() : (legend-
>size().height() - m_layoutFieldset.borderTop()) / 2; | 92 LayoutUnit yOff = (legend->location().y() > 0) ? LayoutUnit() : (legend-
>size().height() - m_layoutFieldset.borderTop()) / 2; |
| 93 paintRect.expand(0, -yOff); | 93 paintRect.expand(0, -yOff); |
| 94 paintRect.move(0, yOff); | 94 paintRect.move(0, yOff); |
| 95 } else { | 95 } else { |
| 96 LayoutUnit xOff = (legend->location().x() > 0) ? LayoutUnit() : (legend-
>size().width() - m_layoutFieldset.borderLeft()) / 2; | 96 LayoutUnit xOff = (legend->location().x() > 0) ? LayoutUnit() : (legend-
>size().width() - m_layoutFieldset.borderLeft()) / 2; |
| 97 paintRect.expand(-xOff, 0); | 97 paintRect.expand(-xOff, 0); |
| 98 paintRect.move(xOff, 0); | 98 paintRect.move(xOff, 0); |
| 99 } | 99 } |
| 100 | 100 |
| 101 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFieldset, p
aintInfo.phase, paintRect); | 101 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFieldset, p
aintInfo.phase, paintRect, paintOffset); |
| 102 BoxPainter(m_layoutFieldset).paintMaskImages(paintInfo, paintRect); | 102 BoxPainter(m_layoutFieldset).paintMaskImages(paintInfo, paintRect); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace blink | 105 } // namespace blink |
| OLD | NEW |