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