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

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

Issue 2465983002: Rename "paint invalidation rect" etc. to "visual rect". (Closed)
Patch Set: - Created 4 years, 1 month 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 "core/paint/GridPainter.h" 5 #include "core/paint/GridPainter.h"
6 6
7 #include "core/layout/LayoutGrid.h" 7 #include "core/layout/LayoutGrid.h"
8 #include "core/paint/BlockPainter.h" 8 #include "core/paint/BlockPainter.h"
9 #include "core/paint/PaintInfo.h" 9 #include "core/paint/PaintInfo.h"
10 #include <algorithm> 10 #include <algorithm>
(...skipping 30 matching lines...) Expand all
41 static inline bool compareOrderModifiedDocumentOrder( 41 static inline bool compareOrderModifiedDocumentOrder(
42 const std::pair<LayoutBox*, size_t>& firstItem, 42 const std::pair<LayoutBox*, size_t>& firstItem,
43 const std::pair<LayoutBox*, size_t>& secondItem) { 43 const std::pair<LayoutBox*, size_t>& secondItem) {
44 return firstItem.second < secondItem.second; 44 return firstItem.second < secondItem.second;
45 } 45 }
46 46
47 void GridPainter::paintChildren(const PaintInfo& paintInfo, 47 void GridPainter::paintChildren(const PaintInfo& paintInfo,
48 const LayoutPoint& paintOffset) { 48 const LayoutPoint& paintOffset) {
49 ASSERT(!m_layoutGrid.needsLayout()); 49 ASSERT(!m_layoutGrid.needsLayout());
50 50
51 LayoutRect localPaintInvalidationRect = 51 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect);
52 LayoutRect(paintInfo.cullRect().m_rect); 52 localVisualRect.moveBy(-paintOffset);
53 localPaintInvalidationRect.moveBy(-paintOffset);
54 53
55 Vector<LayoutUnit> columnPositions = m_layoutGrid.columnPositions(); 54 Vector<LayoutUnit> columnPositions = m_layoutGrid.columnPositions();
56 if (!m_layoutGrid.styleRef().isLeftToRightDirection()) { 55 if (!m_layoutGrid.styleRef().isLeftToRightDirection()) {
57 // Translate columnPositions in RTL as we need the physical coordinates of 56 // Translate columnPositions in RTL as we need the physical coordinates of
58 // the columns in order to call dirtiedGridAreas(). 57 // the columns in order to call dirtiedGridAreas().
59 for (size_t i = 0; i < columnPositions.size(); i++) 58 for (size_t i = 0; i < columnPositions.size(); i++)
60 columnPositions[i] = 59 columnPositions[i] =
61 m_layoutGrid.translateRTLCoordinate(columnPositions[i]); 60 m_layoutGrid.translateRTLCoordinate(columnPositions[i]);
62 // We change the order of tracks in columnPositions, as in RTL the leftmost 61 // We change the order of tracks in columnPositions, as in RTL the leftmost
63 // track will be the last one. 62 // track will be the last one.
64 std::sort(columnPositions.begin(), columnPositions.end()); 63 std::sort(columnPositions.begin(), columnPositions.end());
65 } 64 }
66 65
67 GridSpan dirtiedColumns = 66 GridSpan dirtiedColumns = dirtiedGridAreas(
68 dirtiedGridAreas(columnPositions, localPaintInvalidationRect.x(), 67 columnPositions, localVisualRect.x(), localVisualRect.maxX());
69 localPaintInvalidationRect.maxX()); 68 GridSpan dirtiedRows = dirtiedGridAreas(
70 GridSpan dirtiedRows = dirtiedGridAreas(m_layoutGrid.rowPositions(), 69 m_layoutGrid.rowPositions(), localVisualRect.y(), localVisualRect.maxY());
71 localPaintInvalidationRect.y(),
72 localPaintInvalidationRect.maxY());
73 70
74 if (!m_layoutGrid.styleRef().isLeftToRightDirection()) { 71 if (!m_layoutGrid.styleRef().isLeftToRightDirection()) {
75 // As we changed the order of tracks previously, we need to swap the dirtied 72 // As we changed the order of tracks previously, we need to swap the dirtied
76 // columns in RTL. 73 // columns in RTL.
77 size_t lastLine = columnPositions.size() - 1; 74 size_t lastLine = columnPositions.size() - 1;
78 dirtiedColumns = GridSpan::translatedDefiniteGridSpan( 75 dirtiedColumns = GridSpan::translatedDefiniteGridSpan(
79 lastLine - dirtiedColumns.endLine(), 76 lastLine - dirtiedColumns.endLine(),
80 lastLine - dirtiedColumns.startLine()); 77 lastLine - dirtiedColumns.startLine());
81 } 78 }
82 79
83 Vector<std::pair<LayoutBox*, size_t>> gridItemsToBePainted; 80 Vector<std::pair<LayoutBox*, size_t>> gridItemsToBePainted;
84 81
85 for (const auto& row : dirtiedRows) { 82 for (const auto& row : dirtiedRows) {
86 for (const auto& column : dirtiedColumns) { 83 for (const auto& column : dirtiedColumns) {
87 const Vector<LayoutBox*, 1>& children = 84 const Vector<LayoutBox*, 1>& children =
88 m_layoutGrid.gridCell(row, column); 85 m_layoutGrid.gridCell(row, column);
89 for (auto* child : children) 86 for (auto* child : children)
90 gridItemsToBePainted.append( 87 gridItemsToBePainted.append(
91 std::make_pair(child, m_layoutGrid.paintIndexForGridItem(child))); 88 std::make_pair(child, m_layoutGrid.paintIndexForGridItem(child)));
92 } 89 }
93 } 90 }
94 91
95 for (auto* item : m_layoutGrid.itemsOverflowingGridArea()) { 92 for (auto* item : m_layoutGrid.itemsOverflowingGridArea()) {
96 if (item->frameRect().intersects(localPaintInvalidationRect)) 93 if (item->frameRect().intersects(localVisualRect))
97 gridItemsToBePainted.append( 94 gridItemsToBePainted.append(
98 std::make_pair(item, m_layoutGrid.paintIndexForGridItem(item))); 95 std::make_pair(item, m_layoutGrid.paintIndexForGridItem(item)));
99 } 96 }
100 97
101 std::stable_sort(gridItemsToBePainted.begin(), gridItemsToBePainted.end(), 98 std::stable_sort(gridItemsToBePainted.begin(), gridItemsToBePainted.end(),
102 compareOrderModifiedDocumentOrder); 99 compareOrderModifiedDocumentOrder);
103 100
104 LayoutBox* previous = 0; 101 LayoutBox* previous = 0;
105 for (const auto& gridItemAndPaintIndex : gridItemsToBePainted) { 102 for (const auto& gridItemAndPaintIndex : gridItemsToBePainted) {
106 // We might have duplicates because of spanning children are included in all 103 // We might have duplicates because of spanning children are included in all
107 // cells they span. Skip them here to avoid painting items several times. 104 // cells they span. Skip them here to avoid painting items several times.
108 LayoutBox* current = gridItemAndPaintIndex.first; 105 LayoutBox* current = gridItemAndPaintIndex.first;
109 if (current == previous) 106 if (current == previous)
110 continue; 107 continue;
111 108
112 BlockPainter(m_layoutGrid) 109 BlockPainter(m_layoutGrid)
113 .paintAllChildPhasesAtomically(*current, paintInfo, paintOffset); 110 .paintAllChildPhasesAtomically(*current, paintInfo, paintOffset);
114 previous = current; 111 previous = current;
115 } 112 }
116 } 113 }
117 114
118 } // namespace blink 115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698