Chromium Code Reviews| 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 (m_layoutTable.collapseBorders() && | 47 if (shouldPaintDescendantBlockBackgrounds(paintPhase)) |
| 48 shouldPaintDescendantBlockBackgrounds(paintPhase) && | 48 paintCollapsedBorders(paintInfoForDescendants, paintOffset); |
| 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 } | |
| 66 } | 49 } |
| 67 | 50 |
| 68 if (shouldPaintSelfOutline(paintPhase)) | 51 if (shouldPaintSelfOutline(paintPhase)) |
| 69 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); | 52 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); |
| 70 } | 53 } |
| 71 | 54 |
| 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 if (paintInfo.context.getPaintController().clientCacheIsValid( | |
|
wkorman
2016/11/03 05:26:13
This looks like the first call of clientCacheIsVal
Xianzhu
2016/11/03 16:06:13
Done.
| |
| 64 m_layoutTable) && | |
| 65 collapsedBorders.lastPaintResult != FullyPainted && | |
| 66 collapsedBorders.lastPaintRect != paintInfo.cullRect()) | |
| 67 m_layoutTable.setDisplayItemsUncached(); | |
| 68 | |
| 69 if (!DrawingRecorder::useCachedDrawingIfPossible( | |
| 70 paintInfo.context, m_layoutTable, | |
| 71 DisplayItem::kTableCollapsedBorders)) { | |
| 72 DrawingRecorder recorder( | |
| 73 paintInfo.context, m_layoutTable, DisplayItem::kTableCollapsedBorders, | |
| 74 FloatRect(LayoutRect(paintOffset, m_layoutTable.size()))); | |
| 75 | |
| 76 // Using our cached sorted styles, we then do individual passes, painting | |
| 77 // each style of border from lowest precedence to highest precedence. | |
| 78 PaintResult paintResult = FullyPainted; | |
| 79 for (const auto& borderValue : collapsedBorders.values) { | |
| 80 for (LayoutTableSection* section = m_layoutTable.bottomSection(); section; | |
| 81 section = m_layoutTable.sectionAbove(section)) { | |
| 82 LayoutPoint childPoint = | |
| 83 m_layoutTable.flipForWritingModeForChild(section, paintOffset); | |
| 84 if (TableSectionPainter(*section).paintCollapsedBorders( | |
| 85 paintInfo, childPoint, borderValue) == | |
| 86 MayBeClippedByPaintDirtyRect) | |
| 87 paintResult = MayBeClippedByPaintDirtyRect; | |
| 88 } | |
| 89 } | |
| 90 collapsedBorders.lastPaintResult = paintResult; | |
| 91 collapsedBorders.lastPaintRect = paintInfo.cullRect(); | |
| 92 } | |
| 93 } | |
| 94 | |
| 72 void TablePainter::paintBoxDecorationBackground( | 95 void TablePainter::paintBoxDecorationBackground( |
| 73 const PaintInfo& paintInfo, | 96 const PaintInfo& paintInfo, |
| 74 const LayoutPoint& paintOffset) { | 97 const LayoutPoint& paintOffset) { |
| 75 if (!m_layoutTable.hasBoxDecorationBackground() || | 98 if (!m_layoutTable.hasBoxDecorationBackground() || |
| 76 m_layoutTable.style()->visibility() != EVisibility::Visible) | 99 m_layoutTable.style()->visibility() != EVisibility::Visible) |
| 77 return; | 100 return; |
| 78 | 101 |
| 79 LayoutRect rect(paintOffset, m_layoutTable.size()); | 102 LayoutRect rect(paintOffset, m_layoutTable.size()); |
| 80 m_layoutTable.subtractCaptionRect(rect); | 103 m_layoutTable.subtractCaptionRect(rect); |
| 81 BoxPainter(m_layoutTable) | 104 BoxPainter(m_layoutTable) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 94 | 117 |
| 95 LayoutRect rect(paintOffset, m_layoutTable.size()); | 118 LayoutRect rect(paintOffset, m_layoutTable.size()); |
| 96 m_layoutTable.subtractCaptionRect(rect); | 119 m_layoutTable.subtractCaptionRect(rect); |
| 97 | 120 |
| 98 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, | 121 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, |
| 99 paintInfo.phase, rect); | 122 paintInfo.phase, rect); |
| 100 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); | 123 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); |
| 101 } | 124 } |
| 102 | 125 |
| 103 } // namespace blink | 126 } // namespace blink |
| OLD | NEW |