|
9 | 9 |
|
10 | 10 | #include <cxxreact/TraceSection.h> |
11 | 11 | #include <react/debug/react_native_assert.h> |
12 | | -#include <react/featureflags/ReactNativeFeatureFlags.h> |
13 | 12 | #include <react/renderer/uimanager/UIManager.h> |
14 | 13 |
|
15 | 14 | namespace facebook::react { |
@@ -213,78 +212,6 @@ Size SurfaceHandler::measure( |
213 | 212 | return rootShadowNode->getLayoutMetrics().frame.size; |
214 | 213 | } |
215 | 214 |
|
216 | | -std::shared_ptr<const ShadowNode> SurfaceHandler::dirtyMeasurableNodesRecursive( |
217 | | - std::shared_ptr<const ShadowNode> node) const { |
218 | | - const auto nodeHasChildren = !node->getChildren().empty(); |
219 | | - const auto isMeasurableYogaNode = |
220 | | - node->getTraits().check(ShadowNodeTraits::Trait::MeasurableYogaNode); |
221 | | - |
222 | | - // Node is not measurable and has no children, its layout will not be affected |
223 | | - if (!nodeHasChildren && !isMeasurableYogaNode) { |
224 | | - return nullptr; |
225 | | - } |
226 | | - |
227 | | - std::shared_ptr<const std::vector<std::shared_ptr<const ShadowNode>>> |
228 | | - newChildren = ShadowNodeFragment::childrenPlaceholder(); |
229 | | - |
230 | | - if (nodeHasChildren) { |
231 | | - std::shared_ptr<std::vector<std::shared_ptr<const ShadowNode>>> |
232 | | - newChildrenMutable = nullptr; |
233 | | - for (size_t i = 0; i < node->getChildren().size(); i++) { |
234 | | - const auto& child = node->getChildren()[i]; |
235 | | - |
236 | | - if (const auto& layoutableNode = |
237 | | - std::dynamic_pointer_cast<const YogaLayoutableShadowNode>( |
238 | | - child)) { |
239 | | - auto newChild = dirtyMeasurableNodesRecursive(layoutableNode); |
240 | | - |
241 | | - if (newChild != nullptr) { |
242 | | - if (newChildrenMutable == nullptr) { |
243 | | - newChildrenMutable = std::make_shared< |
244 | | - std::vector<std::shared_ptr<const ShadowNode>>>( |
245 | | - node->getChildren()); |
246 | | - newChildren = newChildrenMutable; |
247 | | - } |
248 | | - |
249 | | - (*newChildrenMutable)[i] = newChild; |
250 | | - } |
251 | | - } |
252 | | - } |
253 | | - |
254 | | - // Node is not measurable and its children were not dirtied, its layout will |
255 | | - // not be affected |
256 | | - if (!isMeasurableYogaNode && newChildrenMutable == nullptr) { |
257 | | - return nullptr; |
258 | | - } |
259 | | - } |
260 | | - |
261 | | - const auto newNode = node->getComponentDescriptor().cloneShadowNode( |
262 | | - *node, |
263 | | - { |
264 | | - .children = newChildren, |
265 | | - // Preserve the original state of the node |
266 | | - .state = node->getState(), |
267 | | - }); |
268 | | - |
269 | | - if (isMeasurableYogaNode) { |
270 | | - std::static_pointer_cast<YogaLayoutableShadowNode>(newNode)->dirtyLayout(); |
271 | | - } |
272 | | - |
273 | | - return newNode; |
274 | | -} |
275 | | - |
276 | | -void SurfaceHandler::dirtyMeasurableNodes(ShadowNode& root) const { |
277 | | - for (const auto& child : root.getChildren()) { |
278 | | - if (const auto& layoutableNode = |
279 | | - std::dynamic_pointer_cast<const YogaLayoutableShadowNode>(child)) { |
280 | | - const auto newChild = dirtyMeasurableNodesRecursive(layoutableNode); |
281 | | - if (newChild != nullptr) { |
282 | | - root.replaceChild(*child, newChild); |
283 | | - } |
284 | | - } |
285 | | - } |
286 | | -} |
287 | | - |
288 | 215 | void SurfaceHandler::constraintLayout( |
289 | 216 | const LayoutConstraints& layoutConstraints, |
290 | 217 | const LayoutContext& layoutContext) const { |
@@ -315,19 +242,8 @@ void SurfaceHandler::constraintLayout( |
315 | 242 | link_.shadowTree && "`link_.shadowTree` must not be null."); |
316 | 243 | link_.shadowTree->commit( |
317 | 244 | [&](const RootShadowNode& oldRootShadowNode) { |
318 | | - auto newRoot = oldRootShadowNode.clone( |
| 245 | + return oldRootShadowNode.clone( |
319 | 246 | propsParserContext, layoutConstraints, layoutContext); |
320 | | - |
321 | | - // Dirty all measurable nodes when the fontSizeMultiplier changes to |
322 | | - // trigger re-measurement. |
323 | | - if (ReactNativeFeatureFlags::enableFontScaleChangesUpdatingLayout() && |
324 | | - layoutContext.fontSizeMultiplier != |
325 | | - oldRootShadowNode.getConcreteProps() |
326 | | - .layoutContext.fontSizeMultiplier) { |
327 | | - dirtyMeasurableNodes(*newRoot); |
328 | | - } |
329 | | - |
330 | | - return newRoot; |
331 | 247 | }, |
332 | 248 | {/* default commit options */}); |
333 | 249 | } |
|
0 commit comments