| 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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 for (LayoutObject* child = m_layoutTable.firstChild(); child; | 37 for (LayoutObject* child = m_layoutTable.firstChild(); child; |
| 38 child = child->nextSibling()) { | 38 child = child->nextSibling()) { |
| 39 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() && | 39 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() && |
| 40 (child->isTableSection() || child->isTableCaption())) { | 40 (child->isTableSection() || child->isTableCaption())) { |
| 41 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChild( | 41 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChild( |
| 42 toLayoutBox(child), paintOffset); | 42 toLayoutBox(child), paintOffset); |
| 43 child->paint(paintInfoForDescendants, childPoint); | 43 child->paint(paintInfoForDescendants, childPoint); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 if (shouldPaintDescendantBlockBackgrounds(paintPhase)) | 47 if (m_layoutTable.collapseBorders() && |
| 48 paintCollapsedBorders(paintInfoForDescendants, paintOffset); | 48 shouldPaintDescendantBlockBackgrounds(paintPhase) && |
| 49 m_layoutTable.style()->visibility() == EVisibility::Visible) { |
| 50 // Using our cached sorted styles, we then do individual passes, |
| 51 // painting each style of border from lowest precedence to highest |
| 52 // precedence. |
| 53 LayoutTable::CollapsedBorderValues collapsedBorders = |
| 54 m_layoutTable.collapsedBorders(); |
| 55 size_t count = collapsedBorders.size(); |
| 56 for (size_t i = 0; i < count; ++i) { |
| 57 for (LayoutTableSection* section = m_layoutTable.bottomSection(); |
| 58 section; section = m_layoutTable.sectionAbove(section)) { |
| 59 LayoutPoint childPoint = |
| 60 m_layoutTable.flipForWritingModeForChild(section, paintOffset); |
| 61 TableSectionPainter(*section).paintCollapsedBorders( |
| 62 paintInfoForDescendants, childPoint, collapsedBorders[i]); |
| 63 } |
| 64 } |
| 65 } |
| 49 } | 66 } |
| 50 | 67 |
| 51 if (shouldPaintSelfOutline(paintPhase)) | 68 if (shouldPaintSelfOutline(paintPhase)) |
| 52 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); | 69 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); |
| 53 } | 70 } |
| 54 | 71 |
| 55 void TablePainter::paintCollapsedBorders(const PaintInfo& paintInfo, | |
| 56 const LayoutPoint& paintOffset) { | |
| 57 if (!m_layoutTable.hasCollapsedBorders() || | |
| 58 m_layoutTable.style()->visibility() != EVisibility::Visible) | |
| 59 return; | |
| 60 | |
| 61 LayoutTable::CollapsedBordersInfo& collapsedBorders = | |
| 62 m_layoutTable.getCollapsedBordersInfo(); | |
| 63 | |
| 64 // Normally we don't clip individual display items by paint dirty rect | |
| 65 // (aka interest rect), to keep display items independent with paint dirty | |
| 66 // rect so we can just depend on paint invalidation status to repaint them. | |
| 67 // However, the collapsed border display item may be too big to contain all | |
| 68 // collapsed borders in a huge table, so we clip it to paint dirty rect. | |
| 69 // We need to invalidate the display item if the previous paint is clipped | |
| 70 // and the paint dirty rect changed. | |
| 71 if (collapsedBorders.lastPaintResult != FullyPainted && | |
| 72 collapsedBorders.lastPaintRect != paintInfo.cullRect()) | |
| 73 m_layoutTable.setDisplayItemsUncached(); | |
| 74 | |
| 75 if (DrawingRecorder::useCachedDrawingIfPossible( | |
| 76 paintInfo.context, m_layoutTable, | |
| 77 DisplayItem::kTableCollapsedBorders)) | |
| 78 return; | |
| 79 | |
| 80 DrawingRecorder recorder( | |
| 81 paintInfo.context, m_layoutTable, DisplayItem::kTableCollapsedBorders, | |
| 82 FloatRect(LayoutRect(paintOffset, m_layoutTable.size()))); | |
| 83 | |
| 84 // Using our cached sorted styles, we then do individual passes, painting | |
| 85 // each style of border from lowest precedence to highest precedence. | |
| 86 PaintResult paintResult = FullyPainted; | |
| 87 for (const auto& borderValue : collapsedBorders.values) { | |
| 88 for (LayoutTableSection* section = m_layoutTable.bottomSection(); section; | |
| 89 section = m_layoutTable.sectionAbove(section)) { | |
| 90 LayoutPoint childPoint = | |
| 91 m_layoutTable.flipForWritingModeForChild(section, paintOffset); | |
| 92 if (TableSectionPainter(*section).paintCollapsedBorders( | |
| 93 paintInfo, childPoint, borderValue) == | |
| 94 MayBeClippedByPaintDirtyRect) | |
| 95 paintResult = MayBeClippedByPaintDirtyRect; | |
| 96 } | |
| 97 } | |
| 98 collapsedBorders.lastPaintResult = paintResult; | |
| 99 collapsedBorders.lastPaintRect = paintInfo.cullRect(); | |
| 100 } | |
| 101 | |
| 102 void TablePainter::paintBoxDecorationBackground( | 72 void TablePainter::paintBoxDecorationBackground( |
| 103 const PaintInfo& paintInfo, | 73 const PaintInfo& paintInfo, |
| 104 const LayoutPoint& paintOffset) { | 74 const LayoutPoint& paintOffset) { |
| 105 if (!m_layoutTable.hasBoxDecorationBackground() || | 75 if (!m_layoutTable.hasBoxDecorationBackground() || |
| 106 m_layoutTable.style()->visibility() != EVisibility::Visible) | 76 m_layoutTable.style()->visibility() != EVisibility::Visible) |
| 107 return; | 77 return; |
| 108 | 78 |
| 109 LayoutRect rect(paintOffset, m_layoutTable.size()); | 79 LayoutRect rect(paintOffset, m_layoutTable.size()); |
| 110 m_layoutTable.subtractCaptionRect(rect); | 80 m_layoutTable.subtractCaptionRect(rect); |
| 111 BoxPainter(m_layoutTable) | 81 BoxPainter(m_layoutTable) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 124 | 94 |
| 125 LayoutRect rect(paintOffset, m_layoutTable.size()); | 95 LayoutRect rect(paintOffset, m_layoutTable.size()); |
| 126 m_layoutTable.subtractCaptionRect(rect); | 96 m_layoutTable.subtractCaptionRect(rect); |
| 127 | 97 |
| 128 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, | 98 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, |
| 129 paintInfo.phase, rect); | 99 paintInfo.phase, rect); |
| 130 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); | 100 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); |
| 131 } | 101 } |
| 132 | 102 |
| 133 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |