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/FrameSetPainter.h" | 6 #include "core/paint/FrameSetPainter.h" |
7 | 7 |
8 #include "core/html/HTMLFrameSetElement.h" | 8 #include "core/html/HTMLFrameSetElement.h" |
9 #include "core/layout/LayoutFrameSet.h" | 9 #include "core/layout/LayoutFrameSet.h" |
10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 context->fillRect(borderRect, m_layoutFrameSet.frameSet()->hasBorderColor() ? m_layoutFrameSet.resolveColor(CSSPropertyBorderLeftColor) : borderFillColor()) ; | 55 context->fillRect(borderRect, m_layoutFrameSet.frameSet()->hasBorderColor() ? m_layoutFrameSet.resolveColor(CSSPropertyBorderLeftColor) : borderFillColor()) ; |
56 | 56 |
57 // Now stroke the edges but only if we have enough room to paint both edges with a little | 57 // Now stroke the edges but only if we have enough room to paint both edges with a little |
58 // bit of the fill color showing through. | 58 // bit of the fill color showing through. |
59 if (borderRect.height() >= 3) { | 59 if (borderRect.height() >= 3) { |
60 context->fillRect(IntRect(borderRect.location(), IntSize(m_layoutFrameSe t.size().width(), 1)), borderStartEdgeColor()); | 60 context->fillRect(IntRect(borderRect.location(), IntSize(m_layoutFrameSe t.size().width(), 1)), borderStartEdgeColor()); |
61 context->fillRect(IntRect(IntPoint(borderRect.x(), borderRect.maxY() - 1 ), IntSize(m_layoutFrameSet.size().width(), 1)), borderEndEdgeColor()); | 61 context->fillRect(IntRect(IntPoint(borderRect.x(), borderRect.maxY() - 1 ), IntSize(m_layoutFrameSet.size().width(), 1)), borderEndEdgeColor()); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 static bool shouldPaintBorderAfter(const LayoutFrameSet::GridAxis& axis, size_t index) | |
66 { | |
67 // Should not paint a border after the last frame along the axis. | |
68 return index + 1 < axis.m_sizes.size() && axis.m_allowBorder[index + 1]; | |
chrishtr
2015/06/05 18:57:27
Why index + 1 < axis.m_sizes.size() and not index
fs
2015/06/05 19:18:46
index is in [0, size()-1], so the latter will alwa
| |
69 } | |
70 | |
65 void FrameSetPainter::paintBorders(const PaintInfo& paintInfo, const LayoutPoint & adjustedPaintOffset) | 71 void FrameSetPainter::paintBorders(const PaintInfo& paintInfo, const LayoutPoint & adjustedPaintOffset) |
66 { | 72 { |
67 LayoutRect adjustedFrameRect(adjustedPaintOffset, m_layoutFrameSet.size()); | 73 LayoutRect adjustedFrameRect(adjustedPaintOffset, m_layoutFrameSet.size()); |
68 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFrameSet, p aintInfo.phase, adjustedFrameRect); | 74 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFrameSet, p aintInfo.phase, adjustedFrameRect); |
69 if (recorder.canUseCachedDrawing()) | 75 if (recorder.canUseCachedDrawing()) |
70 return; | 76 return; |
71 | 77 |
78 LayoutUnit borderThickness = m_layoutFrameSet.frameSet()->border(); | |
79 if (!borderThickness) | |
80 return; | |
81 | |
72 LayoutObject* child = m_layoutFrameSet.firstChild(); | 82 LayoutObject* child = m_layoutFrameSet.firstChild(); |
73 size_t rows = m_layoutFrameSet.rows().m_sizes.size(); | 83 size_t rows = m_layoutFrameSet.rows().m_sizes.size(); |
74 size_t cols = m_layoutFrameSet.columns().m_sizes.size(); | 84 size_t cols = m_layoutFrameSet.columns().m_sizes.size(); |
75 LayoutUnit borderThickness = m_layoutFrameSet.frameSet()->border(); | |
76 LayoutUnit yPos = 0; | 85 LayoutUnit yPos = 0; |
77 for (size_t r = 0; r < rows; r++) { | 86 for (size_t r = 0; r < rows; r++) { |
78 LayoutUnit xPos = 0; | 87 LayoutUnit xPos = 0; |
79 for (size_t c = 0; c < cols; c++) { | 88 for (size_t c = 0; c < cols; c++) { |
80 xPos += m_layoutFrameSet.columns().m_sizes[c]; | 89 xPos += m_layoutFrameSet.columns().m_sizes[c]; |
81 if (borderThickness && m_layoutFrameSet.columns().m_allowBorder[c + 1]) { | 90 if (shouldPaintBorderAfter(m_layoutFrameSet.columns(), c)) { |
82 paintColumnBorder(paintInfo, pixelSnappedIntRect( | 91 paintColumnBorder(paintInfo, pixelSnappedIntRect( |
83 LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffs et.y() + yPos, borderThickness, m_layoutFrameSet.size().height()))); | 92 LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffs et.y() + yPos, borderThickness, m_layoutFrameSet.size().height()))); |
84 xPos += borderThickness; | 93 xPos += borderThickness; |
85 } | 94 } |
86 child = child->nextSibling(); | 95 child = child->nextSibling(); |
87 if (!child) | 96 if (!child) |
88 return; | 97 return; |
89 } | 98 } |
90 yPos += m_layoutFrameSet.rows().m_sizes[r]; | 99 yPos += m_layoutFrameSet.rows().m_sizes[r]; |
91 if (borderThickness && m_layoutFrameSet.rows().m_allowBorder[r + 1]) { | 100 if (shouldPaintBorderAfter(m_layoutFrameSet.rows(), r)) { |
92 paintRowBorder(paintInfo, pixelSnappedIntRect( | 101 paintRowBorder(paintInfo, pixelSnappedIntRect( |
93 LayoutRect(adjustedPaintOffset.x(), adjustedPaintOffset.y() + yP os, m_layoutFrameSet.size().width(), borderThickness))); | 102 LayoutRect(adjustedPaintOffset.x(), adjustedPaintOffset.y() + yP os, m_layoutFrameSet.size().width(), borderThickness))); |
94 yPos += borderThickness; | 103 yPos += borderThickness; |
95 } | 104 } |
96 } | 105 } |
97 } | 106 } |
98 | 107 |
99 void FrameSetPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoin t& adjustedPaintOffset) | 108 void FrameSetPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoin t& adjustedPaintOffset) |
100 { | 109 { |
101 // Paint only those children that fit in the grid. | 110 // Paint only those children that fit in the grid. |
(...skipping 20 matching lines...) Expand all Loading... | |
122 LayoutObject* child = m_layoutFrameSet.firstChild(); | 131 LayoutObject* child = m_layoutFrameSet.firstChild(); |
123 if (!child) | 132 if (!child) |
124 return; | 133 return; |
125 | 134 |
126 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutFrameSet.location(); | 135 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutFrameSet.location(); |
127 paintChildren(paintInfo, adjustedPaintOffset); | 136 paintChildren(paintInfo, adjustedPaintOffset); |
128 paintBorders(paintInfo, adjustedPaintOffset); | 137 paintBorders(paintInfo, adjustedPaintOffset); |
129 } | 138 } |
130 | 139 |
131 } // namespace blink | 140 } // namespace blink |
OLD | NEW |