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/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 28 matching lines...) Expand all Loading... | |
39 } | 39 } |
40 }; | 40 }; |
41 | 41 |
42 void GridPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset) | 42 void GridPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset) |
43 { | 43 { |
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 Vector<LayoutUnit> columnPositions = m_layoutGrid.columnPositions(); |
50 if (!m_layoutGrid.styleRef().isLeftToRightDirection()) { | |
51 // Translate columnPositions in RTL as we need the physical coordinates of the columns in order to call dirtiedGridAreas(). | |
52 for (size_t i = 0; i < columnPositions.size(); i++) | |
53 columnPositions[i] = m_layoutGrid.translateRTLCoordinate(columnPosit ions[i]); | |
cbiesinger
2016/04/12 20:07:51
Why not make this translation inside of dirtiedGri
Manuel Rego
2016/04/13 08:42:55
Because we only need to do it for columns, not for
| |
54 // We change the order of tracks in columnPositions, as in RTL the leftm ost track will be the last one. | |
55 std::sort(columnPositions.begin(), columnPositions.end()); | |
56 } | |
57 | |
58 GridSpan dirtiedColumns = dirtiedGridAreas(columnPositions, localPaintInvali dationRect.x(), localPaintInvalidationRect.maxX()); | |
50 GridSpan dirtiedRows = dirtiedGridAreas(m_layoutGrid.rowPositions(), localPa intInvalidationRect.y(), localPaintInvalidationRect.maxY()); | 59 GridSpan dirtiedRows = dirtiedGridAreas(m_layoutGrid.rowPositions(), localPa intInvalidationRect.y(), localPaintInvalidationRect.maxY()); |
51 | 60 |
61 if (!m_layoutGrid.styleRef().isLeftToRightDirection()) { | |
62 // As we changed the order of tracks previously, we need to swap the dir tied columns in RTL. | |
63 size_t lastLine = columnPositions.size() - 1; | |
64 dirtiedColumns = GridSpan::translatedDefiniteGridSpan(lastLine - dirtied Columns.endLine(), lastLine - dirtiedColumns.startLine()); | |
65 } | |
66 | |
52 Vector<std::pair<LayoutBox*, size_t>> gridItemsToBePainted; | 67 Vector<std::pair<LayoutBox*, size_t>> gridItemsToBePainted; |
53 | 68 |
54 for (const auto& row : dirtiedRows) { | 69 for (const auto& row : dirtiedRows) { |
55 for (const auto& column : dirtiedColumns) { | 70 for (const auto& column : dirtiedColumns) { |
56 const Vector<LayoutBox*, 1>& children = m_layoutGrid.gridCell(row, c olumn); | 71 const Vector<LayoutBox*, 1>& children = m_layoutGrid.gridCell(row, c olumn); |
57 for (auto* child : children) | 72 for (auto* child : children) |
58 gridItemsToBePainted.append(std::make_pair(child, m_layoutGrid.p aintIndexForGridItem(child))); | 73 gridItemsToBePainted.append(std::make_pair(child, m_layoutGrid.p aintIndexForGridItem(child))); |
59 } | 74 } |
60 } | 75 } |
61 | 76 |
(...skipping 13 matching lines...) Expand all Loading... | |
75 LayoutBox* current = gridItemAndPaintIndex.first; | 90 LayoutBox* current = gridItemAndPaintIndex.first; |
76 if (current == previous) | 91 if (current == previous) |
77 continue; | 92 continue; |
78 | 93 |
79 BlockPainter(m_layoutGrid).paintAllChildPhasesAtomically(*current, paint Info, paintOffset); | 94 BlockPainter(m_layoutGrid).paintAllChildPhasesAtomically(*current, paint Info, paintOffset); |
80 previous = current; | 95 previous = current; |
81 } | 96 } |
82 } | 97 } |
83 | 98 |
84 } // namespace blink | 99 } // namespace blink |
OLD | NEW |