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/TablePainter.h" | 5 #include "core/paint/TablePainter.h" |
6 | 6 |
7 #include "core/layout/LayoutTable.h" | 7 #include "core/layout/LayoutTable.h" |
8 #include "core/layout/LayoutTableSection.h" | 8 #include "core/layout/LayoutTableSection.h" |
9 #include "core/style/CollapsedBorderValue.h" | 9 #include "core/style/CollapsedBorderValue.h" |
10 #include "core/paint/BoxClipper.h" | 10 #include "core/paint/BoxClipper.h" |
11 #include "core/paint/BoxPainter.h" | 11 #include "core/paint/BoxPainter.h" |
12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 12 #include "core/paint/LayoutObjectDrawingRecorder.h" |
13 #include "core/paint/ObjectPainter.h" | 13 #include "core/paint/ObjectPainter.h" |
14 #include "core/paint/PaintInfo.h" | 14 #include "core/paint/PaintInfo.h" |
15 #include "core/paint/ScopeRecorder.h" | 15 #include "core/paint/ScopeRecorder.h" |
16 #include "core/paint/TableSectionPainter.h" | 16 #include "core/paint/TableSectionPainter.h" |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 void TablePainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) | 20 void TablePainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) |
21 { | 21 { |
22 PaintPhase paintPhase = paintInfo.phase; | 22 PaintPhase paintPhase = paintInfo.phase; |
23 if ((paintPhase == PaintPhaseSelfBlockBackground || paintPhase == PaintPhase
BlockBackground) && m_layoutTable.hasBoxDecorationBackground() && m_layoutTable.
style()->visibility() == VISIBLE) | 23 |
| 24 if (shouldPaintSelfBlockBackground(paintPhase)) { |
24 paintBoxDecorationBackground(paintInfo, paintOffset); | 25 paintBoxDecorationBackground(paintInfo, paintOffset); |
| 26 if (paintPhase == PaintPhaseSelfBlockBackgroundOnly) |
| 27 return; |
| 28 } |
25 | 29 |
26 if (paintPhase == PaintPhaseMask) { | 30 if (paintPhase == PaintPhaseMask) { |
27 paintMask(paintInfo, paintOffset); | 31 paintMask(paintInfo, paintOffset); |
28 return; | 32 return; |
29 } | 33 } |
30 | 34 |
31 // We're done. We don't bother painting any children. | 35 if (paintPhase != PaintPhaseSelfOutlineOnly) { |
32 if (paintPhase == PaintPhaseSelfBlockBackground) | 36 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); |
33 return; | 37 paintInfoForDescendants.updatePaintingRootForChildren(&m_layoutTable); |
34 | 38 |
35 // We don't paint our own background, but we do let the kids paint their bac
kgrounds. | 39 for (LayoutObject* child = m_layoutTable.firstChild(); child; child = ch
ild->nextSibling()) { |
36 if (paintPhase == PaintPhaseDescendantBlockBackgrounds) | 40 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() &&
(child->isTableSection() || child->isTableCaption())) { |
37 paintPhase = PaintPhaseBlockBackground; | 41 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChil
d(toLayoutBox(child), paintOffset); |
| 42 child->paint(paintInfoForDescendants, childPoint); |
| 43 } |
| 44 } |
38 | 45 |
39 PaintInfo info(paintInfo); | 46 if (m_layoutTable.collapseBorders() && shouldPaintDescendantBlockBackgro
unds(paintPhase) && m_layoutTable.style()->visibility() == VISIBLE) { |
40 info.phase = paintPhase; | 47 // Using our cached sorted styles, we then do individual passes, |
41 info.updatePaintingRootForChildren(&m_layoutTable); | 48 // painting each style of border from lowest precedence to highest p
recedence. |
42 | 49 LayoutTable::CollapsedBorderValues collapsedBorders = m_layoutTable.
collapsedBorders(); |
43 for (LayoutObject* child = m_layoutTable.firstChild(); child; child = child-
>nextSibling()) { | 50 size_t count = collapsedBorders.size(); |
44 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() && (ch
ild->isTableSection() || child->isTableCaption())) { | 51 for (size_t i = 0; i < count; ++i) { |
45 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChild(to
LayoutBox(child), paintOffset); | 52 for (LayoutTableSection* section = m_layoutTable.bottomSection()
; section; section = m_layoutTable.sectionAbove(section)) { |
46 child->paint(info, childPoint); | 53 LayoutPoint childPoint = m_layoutTable.flipForWritingModeFor
Child(section, paintOffset); |
47 } | 54 TableSectionPainter(*section).paintCollapsedBorders(paintInf
oForDescendants, childPoint, collapsedBorders[i]); |
48 } | 55 } |
49 | |
50 if (m_layoutTable.collapseBorders() && paintPhase == PaintPhaseBlockBackgrou
nd && m_layoutTable.style()->visibility() == VISIBLE) { | |
51 // Using our cached sorted styles, we then do individual passes, | |
52 // painting each style of border from lowest precedence to highest prece
dence. | |
53 LayoutTable::CollapsedBorderValues collapsedBorders = m_layoutTable.coll
apsedBorders(); | |
54 size_t count = collapsedBorders.size(); | |
55 for (size_t i = 0; i < count; ++i) { | |
56 for (LayoutTableSection* section = m_layoutTable.bottomSection(); se
ction; section = m_layoutTable.sectionAbove(section)) { | |
57 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChil
d(section, paintOffset); | |
58 TableSectionPainter(*section).paintCollapsedBorders(info, childP
oint, collapsedBorders[i]); | |
59 } | 56 } |
60 } | 57 } |
61 } | 58 } |
62 | 59 |
63 // Paint outline. | 60 if (shouldPaintSelfOutline(paintPhase)) |
64 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline)
&& m_layoutTable.style()->hasOutline() && m_layoutTable.style()->visibility() =
= VISIBLE) | |
65 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); | 61 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); |
66 } | 62 } |
67 | 63 |
68 void TablePainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, cons
t LayoutPoint& paintOffset) | 64 void TablePainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, cons
t LayoutPoint& paintOffset) |
69 { | 65 { |
70 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTable)) | 66 if (!m_layoutTable.hasBoxDecorationBackground() || m_layoutTable.style()->vi
sibility() != VISIBLE || !paintInfo.shouldPaintWithinRoot(&m_layoutTable)) |
71 return; | 67 return; |
72 | 68 |
73 LayoutRect rect(paintOffset, m_layoutTable.size()); | 69 LayoutRect rect(paintOffset, m_layoutTable.size()); |
74 m_layoutTable.subtractCaptionRect(rect); | 70 m_layoutTable.subtractCaptionRect(rect); |
75 BoxPainter(m_layoutTable).paintBoxDecorationBackgroundWithRect(paintInfo, pa
intOffset, rect); | 71 BoxPainter(m_layoutTable).paintBoxDecorationBackgroundWithRect(paintInfo, pa
intOffset, rect); |
76 } | 72 } |
77 | 73 |
78 void TablePainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& pain
tOffset) | 74 void TablePainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& pain
tOffset) |
79 { | 75 { |
80 if (m_layoutTable.style()->visibility() != VISIBLE || paintInfo.phase != Pai
ntPhaseMask) | 76 if (m_layoutTable.style()->visibility() != VISIBLE || paintInfo.phase != Pai
ntPhaseMask) |
81 return; | 77 return; |
82 | 78 |
83 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutTable, paintInfo.phase, paintOffset)) | 79 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutTable, paintInfo.phase, paintOffset)) |
84 return; | 80 return; |
85 | 81 |
86 LayoutRect rect(paintOffset, m_layoutTable.size()); | 82 LayoutRect rect(paintOffset, m_layoutTable.size()); |
87 m_layoutTable.subtractCaptionRect(rect); | 83 m_layoutTable.subtractCaptionRect(rect); |
88 | 84 |
89 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, paint
Info.phase, rect, paintOffset); | 85 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, paint
Info.phase, rect, paintOffset); |
90 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); | 86 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); |
91 } | 87 } |
92 | 88 |
93 } // namespace blink | 89 } // namespace blink |
OLD | NEW |