Index: Source/core/rendering/RenderGrid.cpp |
diff --git a/Source/core/rendering/RenderGrid.cpp b/Source/core/rendering/RenderGrid.cpp |
index c68a38e806b46ec32173c3d9a6a4f32e92080af7..40f2d1e2ac51956f535803cef84a2da8f2d36154 100644 |
--- a/Source/core/rendering/RenderGrid.cpp |
+++ b/Source/core/rendering/RenderGrid.cpp |
@@ -26,6 +26,7 @@ |
#include "config.h" |
#include "core/rendering/RenderGrid.h" |
+#include "core/paint/GridPainter.h" |
#include "core/rendering/RenderLayer.h" |
#include "core/rendering/RenderView.h" |
#include "core/rendering/TextAutosizer.h" |
@@ -1379,80 +1380,9 @@ LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox& child) const |
return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child)); |
} |
-static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUnit start, LayoutUnit end) |
-{ |
- // This function does a binary search over the coordinates. |
- // This doesn't work with grid items overflowing their grid areas, but that is managed with m_gridItemsOverflowingGridArea. |
- |
- size_t startGridAreaIndex = std::upper_bound(coordinates.begin(), coordinates.end() - 1, start) - coordinates.begin(); |
- if (startGridAreaIndex > 0) |
- --startGridAreaIndex; |
- |
- size_t endGridAreaIndex = std::upper_bound(coordinates.begin() + startGridAreaIndex, coordinates.end() - 1, end) - coordinates.begin(); |
- if (endGridAreaIndex > 0) |
- --endGridAreaIndex; |
- |
- return GridSpan(startGridAreaIndex, endGridAreaIndex); |
-} |
- |
-class GridItemsSorter { |
-public: |
- bool operator()(const std::pair<RenderBox*, size_t>& firstChild, const std::pair<RenderBox*, size_t>& secondChild) const |
- { |
- if (firstChild.first->style()->order() != secondChild.first->style()->order()) |
- return firstChild.first->style()->order() < secondChild.first->style()->order(); |
- |
- return firstChild.second < secondChild.second; |
- } |
-}; |
- |
void RenderGrid::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
{ |
- ASSERT_WITH_SECURITY_IMPLICATION(!gridIsDirty()); |
- |
- LayoutRect localPaintInvalidationRect = paintInfo.rect; |
- localPaintInvalidationRect.moveBy(-paintOffset); |
- |
- GridSpan dirtiedColumns = dirtiedGridAreas(m_columnPositions, localPaintInvalidationRect.x(), localPaintInvalidationRect.maxX()); |
- GridSpan dirtiedRows = dirtiedGridAreas(m_rowPositions, localPaintInvalidationRect.y(), localPaintInvalidationRect.maxY()); |
- |
- Vector<std::pair<RenderBox*, size_t> > gridItemsToBePainted; |
- |
- for (GridSpan::iterator row = dirtiedRows.begin(); row != dirtiedRows.end(); ++row) { |
- for (GridSpan::iterator column = dirtiedColumns.begin(); column != dirtiedColumns.end(); ++column) { |
- const Vector<RenderBox*, 1>& children = m_grid[row.toInt()][column.toInt()]; |
- for (size_t j = 0; j < children.size(); ++j) |
- gridItemsToBePainted.append(std::make_pair(children[j], m_gridItemsIndexesMap.get(children[j]))); |
- } |
- } |
- |
- for (Vector<RenderBox*>::const_iterator it = m_gridItemsOverflowingGridArea.begin(); it != m_gridItemsOverflowingGridArea.end(); ++it) { |
- if ((*it)->frameRect().intersects(localPaintInvalidationRect)) |
- gridItemsToBePainted.append(std::make_pair(*it, m_gridItemsIndexesMap.get(*it))); |
- } |
- |
- // Sort grid items following order-modified document order. |
- // See http://www.w3.org/TR/css-flexbox/#order-modified-document-order |
- std::stable_sort(gridItemsToBePainted.begin(), gridItemsToBePainted.end(), GridItemsSorter()); |
- |
- RenderBox* previous = 0; |
- for (Vector<std::pair<RenderBox*, size_t> >::const_iterator it = gridItemsToBePainted.begin(); it != gridItemsToBePainted.end(); ++it) { |
- // We might have duplicates because of spanning children are included in all cells they span. |
- // Skip them here to avoid painting items several times. |
- RenderBox* current = (*it).first; |
- if (current == previous) |
- continue; |
- |
- paintChild(current, paintInfo, paintOffset); |
- previous = current; |
- } |
-} |
- |
-void RenderGrid::paintChild(RenderBox* child, PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
-{ |
- LayoutPoint childPoint = flipForWritingModeForChild(child, paintOffset); |
- if (!child->hasSelfPaintingLayer() && !child->isFloating()) |
- child->paint(paintInfo, childPoint); |
+ GridPainter(*this).paintChildren(paintInfo, paintOffset); |
} |
const char* RenderGrid::renderName() const |