Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: third_party/WebKit/Source/core/paint/GridPainter.cpp

Issue 1500433003: [css-grid] Get rid of GridResolvedPosition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change operators overloaded in GridSpanIterator Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.cpp ('k') | third_party/WebKit/Source/core/style/GridCoordinate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698