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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/GridPainter.h" | 6 #include "core/paint/GridPainter.h" |
7 | 7 |
8 #include "core/layout/LayoutGrid.h" | 8 #include "core/layout/LayoutGrid.h" |
9 #include "core/paint/BlockPainter.h" | 9 #include "core/paint/BlockPainter.h" |
10 #include "core/paint/PaintInfo.h" | 10 #include "core/paint/PaintInfo.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 ASSERT(!m_layoutGrid.needsLayout()); | 44 ASSERT(!m_layoutGrid.needsLayout()); |
45 | 45 |
46 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re
ct); | 46 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re
ct); |
47 localPaintInvalidationRect.moveBy(-paintOffset); | 47 localPaintInvalidationRect.moveBy(-paintOffset); |
48 | 48 |
49 GridSpan dirtiedColumns = dirtiedGridAreas(m_layoutGrid.columnPositions(), l
ocalPaintInvalidationRect.x(), localPaintInvalidationRect.maxX()); | 49 GridSpan dirtiedColumns = dirtiedGridAreas(m_layoutGrid.columnPositions(), l
ocalPaintInvalidationRect.x(), localPaintInvalidationRect.maxX()); |
50 GridSpan dirtiedRows = dirtiedGridAreas(m_layoutGrid.rowPositions(), localPa
intInvalidationRect.y(), localPaintInvalidationRect.maxY()); | 50 GridSpan dirtiedRows = dirtiedGridAreas(m_layoutGrid.rowPositions(), localPa
intInvalidationRect.y(), localPaintInvalidationRect.maxY()); |
51 | 51 |
52 Vector<std::pair<LayoutBox*, size_t>> gridItemsToBePainted; | 52 Vector<std::pair<LayoutBox*, size_t>> gridItemsToBePainted; |
53 | 53 |
54 for (GridSpan::iterator row = dirtiedRows.begin(); row != dirtiedRows.end();
++row) { | 54 for (const auto& row : dirtiedRows) { |
55 for (GridSpan::iterator column = dirtiedColumns.begin(); column != dirti
edColumns.end(); ++column) { | 55 for (const auto& column : dirtiedColumns) { |
56 const Vector<LayoutBox*, 1>& children = m_layoutGrid.gridCell(row.to
Int(), column.toInt()); | 56 const Vector<LayoutBox*, 1>& children = m_layoutGrid.gridCell(row, c
olumn); |
57 for (auto* child : children) | 57 for (auto* child : children) |
58 gridItemsToBePainted.append(std::make_pair(child, m_layoutGrid.p
aintIndexForGridItem(child))); | 58 gridItemsToBePainted.append(std::make_pair(child, m_layoutGrid.p
aintIndexForGridItem(child))); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 for (auto* item: m_layoutGrid.itemsOverflowingGridArea()) { | 62 for (auto* item: m_layoutGrid.itemsOverflowingGridArea()) { |
63 if (item->frameRect().intersects(localPaintInvalidationRect)) | 63 if (item->frameRect().intersects(localPaintInvalidationRect)) |
64 gridItemsToBePainted.append(std::make_pair(item, m_layoutGrid.paintI
ndexForGridItem(item))); | 64 gridItemsToBePainted.append(std::make_pair(item, m_layoutGrid.paintI
ndexForGridItem(item))); |
65 } | 65 } |
66 | 66 |
67 // Sort grid items following order-modified document order. | 67 // Sort grid items following order-modified document order. |
68 // See http://www.w3.org/TR/css-flexbox/#order-modified-document-order | 68 // See http://www.w3.org/TR/css-flexbox/#order-modified-document-order |
69 std::stable_sort(gridItemsToBePainted.begin(), gridItemsToBePainted.end(), G
ridItemsSorter()); | 69 std::stable_sort(gridItemsToBePainted.begin(), gridItemsToBePainted.end(), G
ridItemsSorter()); |
70 | 70 |
71 LayoutBox* previous = 0; | 71 LayoutBox* previous = 0; |
72 for (const auto& gridItemAndPaintIndex : gridItemsToBePainted) { | 72 for (const auto& gridItemAndPaintIndex : gridItemsToBePainted) { |
73 // We might have duplicates because of spanning children are included in
all cells they span. | 73 // We might have duplicates because of spanning children are included in
all cells they span. |
74 // Skip them here to avoid painting items several times. | 74 // Skip them here to avoid painting items several times. |
75 LayoutBox* current = gridItemAndPaintIndex.first; | 75 LayoutBox* current = gridItemAndPaintIndex.first; |
76 if (current == previous) | 76 if (current == previous) |
77 continue; | 77 continue; |
78 | 78 |
79 BlockPainter(m_layoutGrid).paintChildAsInlineBlock(*current, paintInfo,
paintOffset); | 79 BlockPainter(m_layoutGrid).paintChildAsInlineBlock(*current, paintInfo,
paintOffset); |
80 previous = current; | 80 previous = current; |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 } // namespace blink | 84 } // namespace blink |
OLD | NEW |