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

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

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

Powered by Google App Engine
This is Rietveld 408576698