Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: Source/core/paint/FrameSetPainter.cpp

Issue 1145993002: Refactor root element background painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase, adding back TestExpectation Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/DisplayItemListPaintTest.cpp ('k') | Source/core/paint/ViewPainter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 34
35 // FIXME: We should do something clever when borders from distinct framesets meet at a join. 35 // FIXME: We should do something clever when borders from distinct framesets meet at a join.
36 36
37 // Fill first. 37 // Fill first.
38 GraphicsContext* context = paintInfo.context; 38 GraphicsContext* context = paintInfo.context;
39 context->fillRect(borderRect, m_layoutFrameSet.frameSet()->hasBorderColor() ? m_layoutFrameSet.resolveColor(CSSPropertyBorderLeftColor) : borderFillColor()) ; 39 context->fillRect(borderRect, m_layoutFrameSet.frameSet()->hasBorderColor() ? m_layoutFrameSet.resolveColor(CSSPropertyBorderLeftColor) : borderFillColor()) ;
40 40
41 // Now stroke the edges but only if we have enough room to paint both edges with a little 41 // Now stroke the edges but only if we have enough room to paint both edges with a little
42 // bit of the fill color showing through. 42 // bit of the fill color showing through.
43 if (borderRect.width() >= 3) { 43 if (borderRect.width() >= 3) {
44 context->fillRect(IntRect(borderRect.location(), IntSize(1, m_layoutFram eSet.size().height())), borderStartEdgeColor()); 44 context->fillRect(IntRect(borderRect.location(), IntSize(1, borderRect.h eight())), borderStartEdgeColor());
45 context->fillRect(IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y() ), IntSize(1, m_layoutFrameSet.size().height())), borderEndEdgeColor()); 45 context->fillRect(IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y() ), IntSize(1, borderRect.height())), borderEndEdgeColor());
46 } 46 }
47 } 47 }
48 48
49 void FrameSetPainter::paintRowBorder(const PaintInfo& paintInfo, const IntRect& borderRect) 49 void FrameSetPainter::paintRowBorder(const PaintInfo& paintInfo, const IntRect& borderRect)
50 { 50 {
51 // FIXME: We should do something clever when borders from distinct framesets meet at a join. 51 // FIXME: We should do something clever when borders from distinct framesets meet at a join.
52 52
53 // Fill first. 53 // Fill first.
54 GraphicsContext* context = paintInfo.context; 54 GraphicsContext* context = paintInfo.context;
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(borderRect.widt h(), 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(borderRect.width(), 1)), borderEndEdgeColor());
62 } 62 }
63 } 63 }
64 64
65 static bool shouldPaintBorderAfter(const LayoutFrameSet::GridAxis& axis, size_t index) 65 static bool shouldPaintBorderAfter(const LayoutFrameSet::GridAxis& axis, size_t index)
66 { 66 {
67 // Should not paint a border after the last frame along the axis. 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]; 68 return index + 1 < axis.m_sizes.size() && axis.m_allowBorder[index + 1];
69 } 69 }
70 70
71 void FrameSetPainter::paintBorders(const PaintInfo& paintInfo, const LayoutPoint & adjustedPaintOffset) 71 void FrameSetPainter::paintBorders(const PaintInfo& paintInfo, const LayoutPoint & adjustedPaintOffset)
(...skipping 10 matching lines...) Expand all
82 LayoutObject* child = m_layoutFrameSet.firstChild(); 82 LayoutObject* child = m_layoutFrameSet.firstChild();
83 size_t rows = m_layoutFrameSet.rows().m_sizes.size(); 83 size_t rows = m_layoutFrameSet.rows().m_sizes.size();
84 size_t cols = m_layoutFrameSet.columns().m_sizes.size(); 84 size_t cols = m_layoutFrameSet.columns().m_sizes.size();
85 LayoutUnit yPos = 0; 85 LayoutUnit yPos = 0;
86 for (size_t r = 0; r < rows; r++) { 86 for (size_t r = 0; r < rows; r++) {
87 LayoutUnit xPos = 0; 87 LayoutUnit xPos = 0;
88 for (size_t c = 0; c < cols; c++) { 88 for (size_t c = 0; c < cols; c++) {
89 xPos += m_layoutFrameSet.columns().m_sizes[c]; 89 xPos += m_layoutFrameSet.columns().m_sizes[c];
90 if (shouldPaintBorderAfter(m_layoutFrameSet.columns(), c)) { 90 if (shouldPaintBorderAfter(m_layoutFrameSet.columns(), c)) {
91 paintColumnBorder(paintInfo, pixelSnappedIntRect( 91 paintColumnBorder(paintInfo, pixelSnappedIntRect(
92 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() - yPos)));
93 xPos += borderThickness; 93 xPos += borderThickness;
94 } 94 }
95 child = child->nextSibling(); 95 child = child->nextSibling();
96 if (!child) 96 if (!child)
97 return; 97 return;
98 } 98 }
99 yPos += m_layoutFrameSet.rows().m_sizes[r]; 99 yPos += m_layoutFrameSet.rows().m_sizes[r];
100 if (shouldPaintBorderAfter(m_layoutFrameSet.rows(), r)) { 100 if (shouldPaintBorderAfter(m_layoutFrameSet.rows(), r)) {
101 paintRowBorder(paintInfo, pixelSnappedIntRect( 101 paintRowBorder(paintInfo, pixelSnappedIntRect(
102 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)));
(...skipping 28 matching lines...) Expand all
131 LayoutObject* child = m_layoutFrameSet.firstChild(); 131 LayoutObject* child = m_layoutFrameSet.firstChild();
132 if (!child) 132 if (!child)
133 return; 133 return;
134 134
135 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutFrameSet.location(); 135 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutFrameSet.location();
136 paintChildren(paintInfo, adjustedPaintOffset); 136 paintChildren(paintInfo, adjustedPaintOffset);
137 paintBorders(paintInfo, adjustedPaintOffset); 137 paintBorders(paintInfo, adjustedPaintOffset);
138 } 138 }
139 139
140 } // namespace blink 140 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/DisplayItemListPaintTest.cpp ('k') | Source/core/paint/ViewPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698