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

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: revise for xianzhu's comment 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
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());
chrishtr 2015/06/03 18:15:15 Why the changes in this file?
trchen 2015/06/03 23:15:24 There is an over-paint with column border. Without
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 void FrameSetPainter::paintBorders(const PaintInfo& paintInfo, const LayoutPoint & adjustedPaintOffset) 65 void FrameSetPainter::paintBorders(const PaintInfo& paintInfo, const LayoutPoint & adjustedPaintOffset)
66 { 66 {
67 LayoutRect adjustedFrameRect(adjustedPaintOffset, m_layoutFrameSet.size()); 67 LayoutRect adjustedFrameRect(adjustedPaintOffset, m_layoutFrameSet.size());
68 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFrameSet, p aintInfo.phase, adjustedFrameRect); 68 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFrameSet, p aintInfo.phase, adjustedFrameRect);
69 if (recorder.canUseCachedDrawing()) 69 if (recorder.canUseCachedDrawing())
70 return; 70 return;
71 71
72 LayoutObject* child = m_layoutFrameSet.firstChild(); 72 LayoutObject* child = m_layoutFrameSet.firstChild();
73 size_t rows = m_layoutFrameSet.rows().m_sizes.size(); 73 size_t rows = m_layoutFrameSet.rows().m_sizes.size();
74 size_t cols = m_layoutFrameSet.columns().m_sizes.size(); 74 size_t cols = m_layoutFrameSet.columns().m_sizes.size();
75 LayoutUnit borderThickness = m_layoutFrameSet.frameSet()->border(); 75 LayoutUnit borderThickness = m_layoutFrameSet.frameSet()->border();
76 LayoutUnit yPos = 0; 76 LayoutUnit yPos = 0;
77 for (size_t r = 0; r < rows; r++) { 77 for (size_t r = 0; r < rows; r++) {
78 LayoutUnit xPos = 0; 78 LayoutUnit xPos = 0;
79 for (size_t c = 0; c < cols; c++) { 79 for (size_t c = 0; c < cols; c++) {
80 xPos += m_layoutFrameSet.columns().m_sizes[c]; 80 xPos += m_layoutFrameSet.columns().m_sizes[c];
81 if (borderThickness && m_layoutFrameSet.columns().m_allowBorder[c + 1]) { 81 if (borderThickness && m_layoutFrameSet.columns().m_allowBorder[c + 1]) {
82 paintColumnBorder(paintInfo, pixelSnappedIntRect( 82 paintColumnBorder(paintInfo, pixelSnappedIntRect(
83 LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffs et.y() + yPos, borderThickness, m_layoutFrameSet.size().height()))); 83 LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffs et.y() + yPos, borderThickness, m_layoutFrameSet.size().height() - yPos)));
84 xPos += borderThickness; 84 xPos += borderThickness;
85 } 85 }
86 child = child->nextSibling(); 86 child = child->nextSibling();
87 if (!child) 87 if (!child)
88 return; 88 return;
89 } 89 }
90 yPos += m_layoutFrameSet.rows().m_sizes[r]; 90 yPos += m_layoutFrameSet.rows().m_sizes[r];
91 if (borderThickness && m_layoutFrameSet.rows().m_allowBorder[r + 1]) { 91 if (borderThickness && m_layoutFrameSet.rows().m_allowBorder[r + 1]) {
92 paintRowBorder(paintInfo, pixelSnappedIntRect( 92 paintRowBorder(paintInfo, pixelSnappedIntRect(
93 LayoutRect(adjustedPaintOffset.x(), adjustedPaintOffset.y() + yP os, m_layoutFrameSet.size().width(), borderThickness))); 93 LayoutRect(adjustedPaintOffset.x(), adjustedPaintOffset.y() + yP os, m_layoutFrameSet.size().width(), borderThickness)));
(...skipping 28 matching lines...) Expand all
122 LayoutObject* child = m_layoutFrameSet.firstChild(); 122 LayoutObject* child = m_layoutFrameSet.firstChild();
123 if (!child) 123 if (!child)
124 return; 124 return;
125 125
126 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutFrameSet.location(); 126 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutFrameSet.location();
127 paintChildren(paintInfo, adjustedPaintOffset); 127 paintChildren(paintInfo, adjustedPaintOffset);
128 paintBorders(paintInfo, adjustedPaintOffset); 128 paintBorders(paintInfo, adjustedPaintOffset);
129 } 129 }
130 130
131 } // namespace blink 131 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698