Skip to content

Commit 083f895

Browse files
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 0752485 commit 083f895

7 files changed

Lines changed: 3215 additions & 2 deletions

File tree

javascript/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.13...3.26)
77
set(CMAKE_VERBOSE_MAKEFILE on)
88
project(yoga)
99

10-
file(GLOB SOURCES CONFIGURE_DEPENDS
10+
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
1111
${CMAKE_CURRENT_SOURCE_DIR}/../yoga/*.cpp
1212
${CMAKE_CURRENT_SOURCE_DIR}/../yoga/**/*.cpp
1313
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)

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

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>
@@ -1418,6 +1419,24 @@ static void calculateLayoutImpl(
14181419
// current node as they will not be traversed
14191420
cleanupContentsNodesRecursively(node);
14201421

1422+
if (node->style().display() == Display::Grid) {
1423+
calculateGridLayoutInternal(
1424+
node,
1425+
availableWidth,
1426+
availableHeight,
1427+
ownerDirection,
1428+
widthSizingMode,
1429+
heightSizingMode,
1430+
ownerWidth,
1431+
ownerHeight,
1432+
performLayout,
1433+
reason,
1434+
layoutMarkerData,
1435+
depth,
1436+
generationCount);
1437+
return;
1438+
}
1439+
14211440
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
14221441
const FlexDirection mainAxis =
14231442
resolveDirection(node->style().flexDirection(), direction);

0 commit comments

Comments
 (0)