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

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

Issue 948343003: Move rendering/RenderGrid to layout/LayoutGrid (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/GridPainter.h ('k') | Source/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/PaintInfo.h" 9 #include "core/layout/PaintInfo.h"
9 #include "core/paint/BlockPainter.h" 10 #include "core/paint/BlockPainter.h"
10 #include "core/rendering/RenderGrid.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn it start, LayoutUnit end) 14 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn it start, LayoutUnit end)
15 { 15 {
16 // This function does a binary search over the coordinates. 16 // This function does a binary search over the coordinates.
17 // This doesn't work with grid items overflowing their grid areas, but that is managed with m_gridItemsOverflowingGridArea. 17 // This doesn't work with grid items overflowing their grid areas, but that is managed with m_gridItemsOverflowingGridArea.
18 18
19 size_t startGridAreaIndex = std::upper_bound(coordinates.begin(), coordinate s.end() - 1, start) - coordinates.begin(); 19 size_t startGridAreaIndex = std::upper_bound(coordinates.begin(), coordinate s.end() - 1, start) - coordinates.begin();
20 if (startGridAreaIndex > 0) 20 if (startGridAreaIndex > 0)
(...skipping 12 matching lines...) Expand all
33 { 33 {
34 if (firstChild.first->style()->order() != secondChild.first->style()->or der()) 34 if (firstChild.first->style()->order() != secondChild.first->style()->or der())
35 return firstChild.first->style()->order() < secondChild.first->style ()->order(); 35 return firstChild.first->style()->order() < secondChild.first->style ()->order();
36 36
37 return firstChild.second < secondChild.second; 37 return firstChild.second < secondChild.second;
38 } 38 }
39 }; 39 };
40 40
41 void GridPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset) 41 void GridPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset)
42 { 42 {
43 ASSERT(!m_renderGrid.needsLayout()); 43 ASSERT(!m_layoutGrid.needsLayout());
44 ASSERT_WITH_SECURITY_IMPLICATION(!m_renderGrid.gridIsDirty()); 44 ASSERT_WITH_SECURITY_IMPLICATION(!m_layoutGrid.gridIsDirty());
45 45
46 LayoutRect localPaintInvalidationRect = paintInfo.rect; 46 LayoutRect localPaintInvalidationRect = paintInfo.rect;
47 localPaintInvalidationRect.moveBy(-paintOffset); 47 localPaintInvalidationRect.moveBy(-paintOffset);
48 48
49 GridSpan dirtiedColumns = dirtiedGridAreas(m_renderGrid.columnPositions(), l ocalPaintInvalidationRect.x(), localPaintInvalidationRect.maxX()); 49 GridSpan dirtiedColumns = dirtiedGridAreas(m_layoutGrid.columnPositions(), l ocalPaintInvalidationRect.x(), localPaintInvalidationRect.maxX());
50 GridSpan dirtiedRows = dirtiedGridAreas(m_renderGrid.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 (GridSpan::iterator row = dirtiedRows.begin(); row != dirtiedRows.end(); ++row) {
55 for (GridSpan::iterator column = dirtiedColumns.begin(); column != dirti edColumns.end(); ++column) { 55 for (GridSpan::iterator column = dirtiedColumns.begin(); column != dirti edColumns.end(); ++column) {
56 const Vector<LayoutBox*, 1>& children = m_renderGrid.gridCell(row.to Int(), column.toInt()); 56 const Vector<LayoutBox*, 1>& children = m_layoutGrid.gridCell(row.to Int(), column.toInt());
57 for (auto* child : children) 57 for (auto* child : children)
58 gridItemsToBePainted.append(std::make_pair(child, m_renderGrid.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_renderGrid.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_renderGrid.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_renderGrid).paintChild(*current, paintInfo, paintOffset); 79 BlockPainter(m_layoutGrid).paintChild(*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 | « Source/core/paint/GridPainter.h ('k') | Source/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698