Skip to content

Commit 1e254b5

Browse files
NickGerlemanmeta-codesync[bot]
authored andcommitted
CSS Grid 2/9: Grid layout algorithm
Summary: Add the core grid layout computation and integrate it into the layout dispatcher. Includes: - AutoPlacement.h: auto-placement algorithm for grid items - GridLayout.h/cpp: grid layout entry point - TrackSizing.h: track sizing algorithm - CalculateLayout.cpp: grid dispatch block and #include - CMakeLists.txt: add algorithm/grid/*.cpp glob - React Native mirror of all C++ changes Differential Revision: D93946253
1 parent 9be0b3b commit 1e254b5

6 files changed

Lines changed: 3214 additions & 1 deletion

File tree

packages/react-native/ReactCommon/yoga/yoga/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ include(${YOGA_ROOT}/cmake/project-defaults.cmake)
2020

2121
file(GLOB SOURCES CONFIGURE_DEPENDS
2222
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
23-
${CMAKE_CURRENT_SOURCE_DIR}/**/*.cpp)
23+
${CMAKE_CURRENT_SOURCE_DIR}/**/*.cpp
24+
${CMAKE_CURRENT_SOURCE_DIR}/algorithm/grid/*.cpp)
2425

2526
add_library(yogacore STATIC ${SOURCES})
2627

packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <yoga/algorithm/PixelGrid.h>
2525
#include <yoga/algorithm/SizingMode.h>
2626
#include <yoga/algorithm/TrailingPosition.h>
27+
#include <yoga/algorithm/grid/GridLayout.h>
2728
#include <yoga/debug/AssertFatal.h>
2829
#include <yoga/debug/Log.h>
2930
#include <yoga/event/event.h>
@@ -1375,6 +1376,24 @@ static void calculateLayoutImpl(
13751376
// current node as they will not be traversed
13761377
cleanupContentsNodesRecursively(node);
13771378

1379+
if (node->style().display() == Display::Grid) {
1380+
calculateGridLayoutInternal(
1381+
node,
1382+
availableWidth,
1383+
availableHeight,
1384+
ownerDirection,
1385+
widthSizingMode,
1386+
heightSizingMode,
1387+
ownerWidth,
1388+
ownerHeight,
1389+
performLayout,
1390+
reason,
1391+
layoutMarkerData,
1392+
depth,
1393+
generationCount);
1394+
return;
1395+
}
1396+
13781397
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
13791398
const FlexDirection mainAxis =
13801399
resolveDirection(node->style().flexDirection(), direction);

0 commit comments

Comments
 (0)