From dc45383979615c4450a396c321ab71a660241421 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 20 Nov 2026 17:13:22 +0000 Subject: [PATCH 1/3] Keep the child-cloning loop on the layout fast path --- yoga/node/Node.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/yoga/node/Node.cpp b/yoga/node/Node.cpp index 2cbe841625..912b00b252 100644 --- a/yoga/node/Node.cpp +++ b/yoga/node/Node.cpp @@ -418,11 +418,26 @@ void Node::clearChildren() { // Other Methods void Node::cloneChildrenIfNeeded() { - for (size_t i = 0; i < children_.size(); i++) { - cloneChildIfNeeded(i); + size_t i = 0; + for (Node*& child : children_) { + if (child->getOwner() != this) { + child = resolveRef(config_->cloneNode(child, this, i)); + child->setOwner(this); + + if (child->style().display() == Display::Contents) [[unlikely]] { + // The contents node's children are treated as children of the + // contents node's parent for layout purposes, so they need + // to be cloned as well. + child->cloneChildrenIfNeeded(); + } else if (child->hasContentsChildren()) [[unlikely]] { + child->cloneContentsChildrenIfNeeded(); + } + } + i += 1; } } +// cloneChildrenIfNeeded keeps its own copy: every layout runs it per child. void Node::cloneChildIfNeeded(size_t index) { Node*& child = children_[index]; if (child->getOwner() == this) { From 00277def635937753b936e2a891741a145629e58 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 20 Nov 2026 17:20:05 +0000 Subject: [PATCH 2/3] Update GoogleTest for Clang 21 compatibility --- tests/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c48bfb9fb0..8674f796da 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,7 +4,7 @@ # LICENSE file in the root directory of this source tree. -cmake_minimum_required(VERSION 3.13...3.26) +cmake_minimum_required(VERSION 3.16...3.26) project(tests) set(CMAKE_VERBOSE_MAKEFILE on) @@ -17,7 +17,7 @@ include(${YOGA_ROOT}/cmake/project-defaults.cmake) # Fetch GTest FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip + URL https://github.com/google/googletest/archive/refs/tags/v1.18.0.zip ) FetchContent_MakeAvailable(googletest) From f5943bafc061de1c457cf7b23d8de1f0eb637fa8 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 20 Nov 2026 17:28:04 +0000 Subject: [PATCH 3/3] Restore the original child-cloning loop --- yoga/node/Node.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/yoga/node/Node.cpp b/yoga/node/Node.cpp index 912b00b252..2cbe841625 100644 --- a/yoga/node/Node.cpp +++ b/yoga/node/Node.cpp @@ -418,26 +418,11 @@ void Node::clearChildren() { // Other Methods void Node::cloneChildrenIfNeeded() { - size_t i = 0; - for (Node*& child : children_) { - if (child->getOwner() != this) { - child = resolveRef(config_->cloneNode(child, this, i)); - child->setOwner(this); - - if (child->style().display() == Display::Contents) [[unlikely]] { - // The contents node's children are treated as children of the - // contents node's parent for layout purposes, so they need - // to be cloned as well. - child->cloneChildrenIfNeeded(); - } else if (child->hasContentsChildren()) [[unlikely]] { - child->cloneContentsChildrenIfNeeded(); - } - } - i += 1; + for (size_t i = 0; i < children_.size(); i++) { + cloneChildIfNeeded(i); } } -// cloneChildrenIfNeeded keeps its own copy: every layout runs it per child. void Node::cloneChildIfNeeded(size_t index) { Node*& child = children_[index]; if (child->getOwner() == this) {