[webkit-changes] [WebKit/WebKit] c1ac96: Use references during Masonry Layout.

Sammy Gill noreply at github.com
Fri Dec 9 08:33:07 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c1ac9659b7aedcc68107ae695e5637c740550354
      https://github.com/WebKit/WebKit/commit/c1ac9659b7aedcc68107ae695e5637c740550354
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2022-12-09 (Fri, 09 Dec 2022)

  Changed paths:
    M Source/WebCore/rendering/GridMasonryLayout.cpp
    M Source/WebCore/rendering/GridMasonryLayout.h

  Log Message:
  -----------
  Use references during Masonry Layout.
https://bugs.webkit.org/show_bug.cgi?id=248504
rdar://102789603

Reviewed by Brent Fulgham.

Instead of passing around pointers everywhere during Masonry, we can
instead use a reference to them whenever we pass them from one of
our data structures to a method that is going to do something related
to layout with it. This way we can avoid null checking everywhere and
only do it when we start trying to position the item inside the grid.

In the few remaining scenarios where we actually need to perform a
null check we can also use a debug assert since having a nullptr
at this point would be very unexpected.

* Source/WebCore/rendering/GridMasonryLayout.cpp:
(WebCore::GridMasonryLayout::collectMasonryItems):
(WebCore::GridMasonryLayout::addItemsToFirstTrack):
(WebCore::GridMasonryLayout::placeItemsWithDefiniteGridAxisPosition):
(WebCore::GridMasonryLayout::placeItemsWithIndefiniteGridAxisPosition):
(WebCore::GridMasonryLayout::setItemGridAxisContainingBlockToGridArea):
(WebCore::GridMasonryLayout::insertIntoGridAndLayoutItem):
(WebCore::GridMasonryLayout::masonryAxisMarginBoxForItem):
(WebCore::GridMasonryLayout::updateRunningPositions):
(WebCore::GridMasonryLayout::updateItemOffset):
(WebCore::GridMasonryLayout::nextMasonryPositionForItem):
(WebCore::GridMasonryLayout::hasDefiniteGridAxisPosition const):
* Source/WebCore/rendering/GridMasonryLayout.h:

Canonical link: https://commits.webkit.org/257631@main




More information about the webkit-changes mailing list