| 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 "core/paint/FrameSetPainter.h" | 5 #include "core/paint/FrameSetPainter.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLFrameSetElement.h" | 7 #include "core/html/HTMLFrameSetElement.h" |
| 8 #include "core/layout/LayoutFrameSet.h" | 8 #include "core/layout/LayoutFrameSet.h" |
| 9 #include "core/paint/LayoutObjectDrawingRecorder.h" | 9 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 10 #include "core/paint/PaintInfo.h" | 10 #include "core/paint/PaintInfo.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 static Color borderFillColor() { | 22 static Color borderFillColor() { |
| 23 return Color(208, 208, 208); | 23 return Color(208, 208, 208); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void FrameSetPainter::paintColumnBorder(const PaintInfo& paintInfo, | 26 void FrameSetPainter::paintColumnBorder(const PaintInfo& paintInfo, |
| 27 const IntRect& borderRect) { | 27 const IntRect& borderRect) { |
| 28 if (!paintInfo.cullRect().intersectsCullRect(borderRect)) | 28 if (!paintInfo.cullRect().intersectsCullRect(borderRect)) |
| 29 return; | 29 return; |
| 30 | 30 |
| 31 // FIXME: We should do something clever when borders from distinct framesets m
eet at a join. | 31 // FIXME: We should do something clever when borders from distinct framesets |
| 32 // meet at a join. |
| 32 | 33 |
| 33 // Fill first. | 34 // Fill first. |
| 34 GraphicsContext& context = paintInfo.context; | 35 GraphicsContext& context = paintInfo.context; |
| 35 context.fillRect(borderRect, m_layoutFrameSet.frameSet()->hasBorderColor() | 36 context.fillRect(borderRect, m_layoutFrameSet.frameSet()->hasBorderColor() |
| 36 ? m_layoutFrameSet.resolveColor( | 37 ? m_layoutFrameSet.resolveColor( |
| 37 CSSPropertyBorderLeftColor) | 38 CSSPropertyBorderLeftColor) |
| 38 : borderFillColor()); | 39 : borderFillColor()); |
| 39 | 40 |
| 40 // Now stroke the edges but only if we have enough room to paint both edges wi
th a little | 41 // Now stroke the edges but only if we have enough room to paint both edges |
| 41 // bit of the fill color showing through. | 42 // with a little bit of the fill color showing through. |
| 42 if (borderRect.width() >= 3) { | 43 if (borderRect.width() >= 3) { |
| 43 context.fillRect( | 44 context.fillRect( |
| 44 IntRect(borderRect.location(), IntSize(1, borderRect.height())), | 45 IntRect(borderRect.location(), IntSize(1, borderRect.height())), |
| 45 borderStartEdgeColor()); | 46 borderStartEdgeColor()); |
| 46 context.fillRect(IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y()), | 47 context.fillRect(IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y()), |
| 47 IntSize(1, borderRect.height())), | 48 IntSize(1, borderRect.height())), |
| 48 borderEndEdgeColor()); | 49 borderEndEdgeColor()); |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 | 52 |
| 52 void FrameSetPainter::paintRowBorder(const PaintInfo& paintInfo, | 53 void FrameSetPainter::paintRowBorder(const PaintInfo& paintInfo, |
| 53 const IntRect& borderRect) { | 54 const IntRect& borderRect) { |
| 54 // FIXME: We should do something clever when borders from distinct framesets m
eet at a join. | 55 // FIXME: We should do something clever when borders from distinct framesets |
| 56 // meet at a join. |
| 55 | 57 |
| 56 // Fill first. | 58 // Fill first. |
| 57 GraphicsContext& context = paintInfo.context; | 59 GraphicsContext& context = paintInfo.context; |
| 58 context.fillRect(borderRect, m_layoutFrameSet.frameSet()->hasBorderColor() | 60 context.fillRect(borderRect, m_layoutFrameSet.frameSet()->hasBorderColor() |
| 59 ? m_layoutFrameSet.resolveColor( | 61 ? m_layoutFrameSet.resolveColor( |
| 60 CSSPropertyBorderLeftColor) | 62 CSSPropertyBorderLeftColor) |
| 61 : borderFillColor()); | 63 : borderFillColor()); |
| 62 | 64 |
| 63 // Now stroke the edges but only if we have enough room to paint both edges wi
th a little | 65 // Now stroke the edges but only if we have enough room to paint both edges |
| 64 // bit of the fill color showing through. | 66 // with a little bit of the fill color showing through. |
| 65 if (borderRect.height() >= 3) { | 67 if (borderRect.height() >= 3) { |
| 66 context.fillRect( | 68 context.fillRect( |
| 67 IntRect(borderRect.location(), IntSize(borderRect.width(), 1)), | 69 IntRect(borderRect.location(), IntSize(borderRect.width(), 1)), |
| 68 borderStartEdgeColor()); | 70 borderStartEdgeColor()); |
| 69 context.fillRect(IntRect(IntPoint(borderRect.x(), borderRect.maxY() - 1), | 71 context.fillRect(IntRect(IntPoint(borderRect.x(), borderRect.maxY() - 1), |
| 70 IntSize(borderRect.width(), 1)), | 72 IntSize(borderRect.width(), 1)), |
| 71 borderEndEdgeColor()); | 73 borderEndEdgeColor()); |
| 72 } | 74 } |
| 73 } | 75 } |
| 74 | 76 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void FrameSetPainter::paintChildren(const PaintInfo& paintInfo, | 129 void FrameSetPainter::paintChildren(const PaintInfo& paintInfo, |
| 128 const LayoutPoint& adjustedPaintOffset) { | 130 const LayoutPoint& adjustedPaintOffset) { |
| 129 // Paint only those children that fit in the grid. | 131 // Paint only those children that fit in the grid. |
| 130 // Remaining frames are "hidden". | 132 // Remaining frames are "hidden". |
| 131 // See also LayoutFrameSet::positionFrames. | 133 // See also LayoutFrameSet::positionFrames. |
| 132 LayoutObject* child = m_layoutFrameSet.firstChild(); | 134 LayoutObject* child = m_layoutFrameSet.firstChild(); |
| 133 size_t rows = m_layoutFrameSet.rows().m_sizes.size(); | 135 size_t rows = m_layoutFrameSet.rows().m_sizes.size(); |
| 134 size_t cols = m_layoutFrameSet.columns().m_sizes.size(); | 136 size_t cols = m_layoutFrameSet.columns().m_sizes.size(); |
| 135 for (size_t r = 0; r < rows; r++) { | 137 for (size_t r = 0; r < rows; r++) { |
| 136 for (size_t c = 0; c < cols; c++) { | 138 for (size_t c = 0; c < cols; c++) { |
| 137 // Self-painting layers are painted during the PaintLayer paint recursion,
not LayoutObject. | 139 // Self-painting layers are painted during the PaintLayer paint recursion, |
| 140 // not LayoutObject. |
| 138 if (!child->isBoxModelObject() || | 141 if (!child->isBoxModelObject() || |
| 139 !toLayoutBoxModelObject(child)->hasSelfPaintingLayer()) | 142 !toLayoutBoxModelObject(child)->hasSelfPaintingLayer()) |
| 140 child->paint(paintInfo, adjustedPaintOffset); | 143 child->paint(paintInfo, adjustedPaintOffset); |
| 141 child = child->nextSibling(); | 144 child = child->nextSibling(); |
| 142 if (!child) | 145 if (!child) |
| 143 return; | 146 return; |
| 144 } | 147 } |
| 145 } | 148 } |
| 146 } | 149 } |
| 147 | 150 |
| 148 void FrameSetPainter::paint(const PaintInfo& paintInfo, | 151 void FrameSetPainter::paint(const PaintInfo& paintInfo, |
| 149 const LayoutPoint& paintOffset) { | 152 const LayoutPoint& paintOffset) { |
| 150 if (paintInfo.phase != PaintPhaseForeground) | 153 if (paintInfo.phase != PaintPhaseForeground) |
| 151 return; | 154 return; |
| 152 | 155 |
| 153 LayoutObject* child = m_layoutFrameSet.firstChild(); | 156 LayoutObject* child = m_layoutFrameSet.firstChild(); |
| 154 if (!child) | 157 if (!child) |
| 155 return; | 158 return; |
| 156 | 159 |
| 157 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutFrameSet.location(); | 160 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutFrameSet.location(); |
| 158 paintChildren(paintInfo, adjustedPaintOffset); | 161 paintChildren(paintInfo, adjustedPaintOffset); |
| 159 paintBorders(paintInfo, adjustedPaintOffset); | 162 paintBorders(paintInfo, adjustedPaintOffset); |
| 160 } | 163 } |
| 161 | 164 |
| 162 } // namespace blink | 165 } // namespace blink |
| OLD | NEW |