diff --git a/Libraries/Wrapper/RCTWrapperView.m b/Libraries/Wrapper/RCTWrapperView.m index fc045f58e22..cbc0a9e1b31 100644 --- a/Libraries/Wrapper/RCTWrapperView.m +++ b/Libraries/Wrapper/RCTWrapperView.m @@ -76,7 +76,7 @@ [super invalidateIntrinsicContentSize]; // Setting `intrinsicContentSize` dirties the Yoga node and - // enforce Yoga to call `measureContent` function (backed to `measureBlock`). + // enforce Yoga to call `measure` function (backed to `measureBlock`). [_bridge.uiManager setIntrinsicContentSize:self.intrinsicContentSize forView:self]; } diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index c96763a3928..b7b2ad07790 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -36,12 +36,6 @@ using namespace facebook::react; -static LayoutContext RCTCurrentLayoutContext() { - return { - .pointScaleFactor = RCTScreenScale(), - }; -} - @interface RCTSurfacePresenter () @end @@ -74,7 +68,6 @@ static LayoutContext RCTCurrentLayoutContext() { _observers = [NSMutableArray array]; _scheduler = [self _createScheduler]; - } return self; @@ -142,7 +135,7 @@ static LayoutContext RCTCurrentLayoutContext() { surface:(RCTFabricSurface *)surface { std::shared_lock lock(_schedulerMutex); - LayoutContext layoutContext = RCTCurrentLayoutContext(); + LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()}; LayoutConstraints layoutConstraints = {.minimumSize = RCTSizeFromCGSize(minimumSize), .maximumSize = RCTSizeFromCGSize(maximumSize)}; return [_scheduler measureSurfaceWithLayoutConstraints:layoutConstraints @@ -153,7 +146,7 @@ static LayoutContext RCTCurrentLayoutContext() { - (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RCTFabricSurface *)surface { std::shared_lock lock(_schedulerMutex); - LayoutContext layoutContext = RCTCurrentLayoutContext(); + LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()}; LayoutConstraints layoutConstraints = {.minimumSize = RCTSizeFromCGSize(minimumSize), .maximumSize = RCTSizeFromCGSize(maximumSize)}; [_scheduler constraintSurfaceLayoutWithLayoutConstraints:layoutConstraints @@ -262,7 +255,7 @@ static LayoutContext RCTCurrentLayoutContext() { tag:surface.rootTag]; }); - LayoutContext layoutContext = RCTCurrentLayoutContext(); + LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()}; LayoutConstraints layoutConstraints = {.minimumSize = RCTSizeFromCGSize(surface.minimumSize), .maximumSize = RCTSizeFromCGSize(surface.maximumSize)}; diff --git a/ReactCommon/fabric/components/slider/SliderShadowNode.cpp b/ReactCommon/fabric/components/slider/SliderShadowNode.cpp index aa195b776df..488fe566783 100644 --- a/ReactCommon/fabric/components/slider/SliderShadowNode.cpp +++ b/ReactCommon/fabric/components/slider/SliderShadowNode.cpp @@ -83,7 +83,7 @@ ImageSource SliderShadowNode::getThumbImageSource() const { #pragma mark - LayoutableShadowNode -Size SliderShadowNode::measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const { +Size SliderShadowNode::measure(LayoutConstraints layoutConstraints) const { if (SliderMeasurementsManager::shouldMeasureSlider()) { return measurementsManager_->measure(getSurfaceId(), layoutConstraints); } diff --git a/ReactCommon/fabric/components/slider/SliderShadowNode.h b/ReactCommon/fabric/components/slider/SliderShadowNode.h index 13cedd0ce17..dc44d5c96b1 100644 --- a/ReactCommon/fabric/components/slider/SliderShadowNode.h +++ b/ReactCommon/fabric/components/slider/SliderShadowNode.h @@ -40,7 +40,7 @@ class SliderShadowNode final : public ConcreteViewShadowNode< #pragma mark - LayoutableShadowNode - Size measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const override; + Size measure(LayoutConstraints layoutConstraints) const override; void layout(LayoutContext layoutContext) override; private: diff --git a/ReactCommon/fabric/components/switch/androidswitch/AndroidSwitchShadowNode.cpp b/ReactCommon/fabric/components/switch/androidswitch/AndroidSwitchShadowNode.cpp index 0a443fc0643..b717418afd6 100644 --- a/ReactCommon/fabric/components/switch/androidswitch/AndroidSwitchShadowNode.cpp +++ b/ReactCommon/fabric/components/switch/androidswitch/AndroidSwitchShadowNode.cpp @@ -21,9 +21,8 @@ void AndroidSwitchShadowNode::setAndroidSwitchMeasurementsManager( #pragma mark - LayoutableShadowNode -Size AndroidSwitchShadowNode::measureContent( - LayoutConstraints layoutConstraints, - LayoutContext layoutContext) const { +Size AndroidSwitchShadowNode::measure( + LayoutConstraints layoutConstraints) const { return measurementsManager_->measure(getSurfaceId(), layoutConstraints); } diff --git a/ReactCommon/fabric/components/switch/androidswitch/AndroidSwitchShadowNode.h b/ReactCommon/fabric/components/switch/androidswitch/AndroidSwitchShadowNode.h index 70517418a10..66df81a2a49 100644 --- a/ReactCommon/fabric/components/switch/androidswitch/AndroidSwitchShadowNode.h +++ b/ReactCommon/fabric/components/switch/androidswitch/AndroidSwitchShadowNode.h @@ -11,7 +11,6 @@ #include #include -#include #include namespace facebook { @@ -36,7 +35,7 @@ class AndroidSwitchShadowNode final : public ConcreteViewShadowNode< #pragma mark - LayoutableShadowNode - Size measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const override; + Size measure(LayoutConstraints layoutConstraints) const override; private: std::shared_ptr measurementsManager_; diff --git a/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp b/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp index 04b64d81289..ad7570c97b6 100644 --- a/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp +++ b/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp @@ -56,8 +56,9 @@ void ParagraphShadowNode::updateStateIfNeeded() { #pragma mark - LayoutableShadowNode -Size ParagraphShadowNode::measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const { +Size ParagraphShadowNode::measure(LayoutConstraints layoutConstraints) const { AttributedString attributedString = getAttributedString(); + if (attributedString.isEmpty()) { return layoutConstraints.clamp({0, 0}); } diff --git a/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.h b/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.h index 4c28dc820e1..c6513462cf9 100644 --- a/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.h +++ b/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.h @@ -59,7 +59,7 @@ class ParagraphShadowNode : public ConcreteViewShadowNode< #pragma mark - LayoutableShadowNode void layout(LayoutContext layoutContext) override; - Size measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const override; + Size measure(LayoutConstraints layoutConstraints) const override; private: /* diff --git a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputShadowNode.cpp b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputShadowNode.cpp index fefac135877..daba6efc7bb 100644 --- a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputShadowNode.cpp +++ b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputShadowNode.cpp @@ -153,9 +153,8 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() { #pragma mark - LayoutableShadowNode -Size AndroidTextInputShadowNode::measureContent( - LayoutConstraints layoutConstraints, - LayoutContext layoutContext) const { +Size AndroidTextInputShadowNode::measure( + LayoutConstraints layoutConstraints) const { // Layout is called right after measure. // Measure is marked as `const`, and `layout` is not; so State can be updated // during layout, but not during `measure`. If State is out-of-date in layout, diff --git a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputShadowNode.h b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputShadowNode.h index 25071d46bb1..288545367b8 100644 --- a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputShadowNode.h +++ b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputShadowNode.h @@ -49,7 +49,7 @@ class AndroidTextInputShadowNode : public ConcreteViewShadowNode< #pragma mark - LayoutableShadowNode - Size measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const override; + Size measure(LayoutConstraints layoutConstraints) const override; void layout(LayoutContext layoutContext) override; private: diff --git a/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.cpp b/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.cpp index 4116ab16f40..5678cfc9b24 100644 --- a/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.cpp +++ b/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.cpp @@ -55,7 +55,6 @@ AttributedString TextInputShadowNode::getAttributedString() const { attributedString.appendAttributedString( BaseTextShadowNode::getAttributedString(textAttributes, *this)); - return attributedString; } @@ -79,7 +78,7 @@ void TextInputShadowNode::updateStateIfNeeded() { #pragma mark - LayoutableShadowNode -Size TextInputShadowNode::measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const { +Size TextInputShadowNode::measure(LayoutConstraints layoutConstraints) const { return textLayoutManager_->measure( attributedStringBoxToMeasure(), getConcreteProps().getEffectiveParagraphAttributes(), diff --git a/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.h b/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.h index fe975de277d..435e5b7da9f 100644 --- a/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.h +++ b/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.h @@ -47,7 +47,7 @@ class TextInputShadowNode : public ConcreteViewShadowNode< #pragma mark - LayoutableShadowNode - Size measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const override; + Size measure(LayoutConstraints layoutConstraints) const override; void layout(LayoutContext layoutContext) override; private: diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp index 71ddc9c5fbc..0c87c9094ec 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp @@ -359,8 +359,7 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector( break; } - auto size = shadowNodeRawPtr->measureContent({minimumSize, maximumSize}, - *static_cast(layoutContext)); + auto size = shadowNodeRawPtr->measure({minimumSize, maximumSize}); return YGSize{yogaFloatFromFloat(size.width), yogaFloatFromFloat(size.height)}; diff --git a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp index 515f3004dea..16346746658 100644 --- a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp +++ b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp @@ -156,7 +156,7 @@ LayoutableShadowNode::getLayoutableChildNodes() const { return layoutableChildren; } -Size LayoutableShadowNode::measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const { +Size LayoutableShadowNode::measure(LayoutConstraints layoutConstraints) const { return Size(); } diff --git a/ReactCommon/fabric/core/layout/LayoutableShadowNode.h b/ReactCommon/fabric/core/layout/LayoutableShadowNode.h index 279d9c4a8f8..f19ec6e4419 100644 --- a/ReactCommon/fabric/core/layout/LayoutableShadowNode.h +++ b/ReactCommon/fabric/core/layout/LayoutableShadowNode.h @@ -66,7 +66,7 @@ class LayoutableShadowNode : public ShadowNode { * given constrains and relying on possible layout. * Default implementation returns zero size. */ - virtual Size measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const; + virtual Size measure(LayoutConstraints layoutConstraints) const; /* * Computes layout recursively. diff --git a/ReactCommon/fabric/core/shadownode/ShadowNodeTraits.h b/ReactCommon/fabric/core/shadownode/ShadowNodeTraits.h index abd5b093b11..46ad563d712 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNodeTraits.h +++ b/ReactCommon/fabric/core/shadownode/ShadowNodeTraits.h @@ -54,7 +54,7 @@ class ShadowNodeTraits { // leaf. LeafYogaNode = 1 << 10, - // Inherits `LayoutableShadowNode` and calls `measureContent()`. + // Inherits `LayoutableShadowNode` and calls `measure()`. HasMeasure = 1 << 11, // Internal to `ShadowNode`; do not use it outside.