Skip to content

Commit

Permalink
[masonry] Expose grid items positions and sizes to Web Inspector
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267736
rdar://problem/121219933

Reviewed by Sammy Gill.

Masonry differs from Grid in only having one axis. This does not allow simple drawing
straight lines. The Web Inspector can instead draw boxes around each item, which this patch
is exposing in a simpler format.

This patch is not exclusive to masonry and can be used for all returning all grid items
layout rects.

* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::gridItemsLayoutRects):
* Source/WebCore/rendering/RenderGrid.h:

Canonical link: https://commits.webkit.org/273232@main
  • Loading branch information
stwrt committed Jan 19, 2024
1 parent c46dee2 commit 3816458
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/WebCore/rendering/RenderGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,16 @@ LayoutUnit RenderGrid::masonryContentSize() const
return m_masonryLayout.gridContentSize();
}

Vector<LayoutRect> RenderGrid::gridItemsLayoutRects()
{
Vector<LayoutRect> items;

for (RenderBox* child = currentGrid().orderIterator().first(); child; child = currentGrid().orderIterator().next())
items.append(child->frameRect());

return items;
}

void RenderGrid::performGridItemsPreLayout(const GridTrackSizingAlgorithm& algorithm, const ShouldUpdateGridAreaLogicalSize shouldUpdateGridAreaLogicalSize) const
{
ASSERT(!algorithm.grid().needsItemsPlacement());
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/RenderGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class RenderGrid final : public RenderBlock {
LayoutUnit gridGap(GridTrackSizingDirection, std::optional<LayoutUnit> availableSize) const;

LayoutUnit masonryContentSize() const;
Vector<LayoutRect> gridItemsLayoutRects();
private:
friend class GridTrackSizingAlgorithm;
friend class GridMasonryLayout;
Expand Down

0 comments on commit 3816458

Please sign in to comment.