Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: Remove YGConfigGetInstanceCount #39369

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
NSString *const RCTBaseTextShadowViewEmbeddedShadowViewAttributeName =
@"RCTBaseTextShadowViewEmbeddedShadowViewAttributeName";

static void RCTInlineViewYogaNodeDirtied(YGNodeRef node)
static void RCTInlineViewYogaNodeDirtied(YGNodeConstRef node)
{
// An inline view (a view nested inside of a text node) does not have a parent
// in the Yoga tree. Consequently, we have to manually propagate the inline
Expand Down
10 changes: 7 additions & 3 deletions packages/react-native/Libraries/Text/Text/RCTTextShadowView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,12 @@ - (CGFloat)lastBaselineForSize:(CGSize)size
return size.height + maximumDescender;
}

static YGSize
RCTTextShadowViewMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
static YGSize RCTTextShadowViewMeasure(
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode)
{
CGSize maximumSize = (CGSize){
widthMode == YGMeasureModeUndefined ? CGFLOAT_MAX : RCTCoreGraphicsFloatFromYogaFloat(width),
Expand Down Expand Up @@ -402,7 +406,7 @@ - (CGFloat)lastBaselineForSize:(CGSize)size
RCTYogaFloatFromCoreGraphicsFloat(size.height + epsilon)};
}

static float RCTTextShadowViewBaseline(YGNodeRef node, const float width, const float height)
static float RCTTextShadowViewBaseline(YGNodeConstRef node, const float width, const float height)
{
RCTTextShadowView *shadowTextView = (__bridge RCTTextShadowView *)YGNodeGetContext(node);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ - (CGFloat)lastBaselineForSize:(CGSize)size
}

static YGSize RCTBaseTextInputShadowViewMeasure(
YGNodeRef node,
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
Expand Down Expand Up @@ -302,7 +302,7 @@ static YGSize RCTBaseTextInputShadowViewMeasure(
RCTYogaFloatFromCoreGraphicsFloat(measuredSize.width), RCTYogaFloatFromCoreGraphicsFloat(measuredSize.height)};
}

static float RCTTextInputShadowViewBaseline(YGNodeRef node, const float width, const float height)
static float RCTTextInputShadowViewBaseline(YGNodeConstRef node, const float width, const float height)
{
RCTBaseTextInputShadowView *shadowTextView = (__bridge RCTBaseTextInputShadowView *)YGNodeGetContext(node);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
}

static YGSize RCTWrapperShadowViewMeasure(
YGNodeRef node,
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/Views/RCTShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ + (YGConfigRef)yogaConfig

// YogaNode API

static void RCTPrint(YGNodeRef node)
static void RCTPrint(YGNodeConstRef node)
{
RCTShadowView *shadowView = (__bridge RCTShadowView *)YGNodeGetContext(node);
printf("%s(%lld), ", shadowView.viewName.UTF8String, (long long)shadowView.reactTag.integerValue);
Expand Down Expand Up @@ -568,7 +568,7 @@ - (void)setSize:(CGSize)size
// IntrinsicContentSize

static inline YGSize
RCTShadowViewMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
RCTShadowViewMeasure(YGNodeConstRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
{
RCTShadowView *shadowView = (__bridge RCTShadowView *)YGNodeGetContext(node);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace facebook::yoga;
using namespace facebook::yoga::vanillajni;

static inline ScopedLocalRef<jobject> YGNodeJobject(
YGNodeRef node,
YGNodeConstRef node,
void* layoutContext) {
return reinterpret_cast<PtrJNodeMapVanilla*>(layoutContext)->ref(node);
}
Expand Down Expand Up @@ -138,8 +138,8 @@ static jlong jni_YGNodeNewWithConfigJNI(
}

static int YGJNILogFunc(
const YGConfigRef config,
const YGNodeRef /*node*/,
const YGConfigConstRef config,
const YGNodeConstRef /*node*/,
YGLogLevel level,
void* /*layoutContext*/,
const char* format,
Expand Down Expand Up @@ -362,7 +362,7 @@ static void YGTransferLayoutOutputsRecursive(

YGNodeSetHasNewLayout(root, false);

for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
for (size_t i = 0; i < YGNodeGetChildCount(root); i++) {
YGTransferLayoutOutputsRecursive(
env, thiz, YGNodeGetChild(root, i), layoutContext);
}
Expand Down Expand Up @@ -639,7 +639,7 @@ static void jni_YGNodeStyleSetBorderJNI(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(border));
}

static void YGTransferLayoutDirection(YGNodeRef node, jobject javaNode) {
static void YGTransferLayoutDirection(YGNodeConstRef node, jobject javaNode) {
// Don't change this field name without changing the name of the field in
// Database.java
JNIEnv* env = getCurrentEnv();
Expand All @@ -655,7 +655,7 @@ static void YGTransferLayoutDirection(YGNodeRef node, jobject javaNode) {
}

static YGSize YGJNIMeasureFunc(
YGNodeRef node,
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
Expand Down Expand Up @@ -700,7 +700,7 @@ static void jni_YGNodeSetHasMeasureFuncJNI(
}

static float YGJNIBaselineFunc(
YGNodeRef node,
YGNodeConstRef node,
float width,
float height,
void* layoutContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
namespace facebook::react {

static int FabricDefaultYogaLog(
const YGConfigRef /*unused*/,
const YGNodeRef /*unused*/,
const YGConfigConstRef /*unused*/,
const YGNodeConstRef /*unused*/,
YGLogLevel level,
const char* format,
va_list args) {
Expand Down Expand Up @@ -190,9 +190,7 @@ void YogaLayoutableShadowNode::appendYogaChild(
ensureYogaChildrenLookFine();

yogaLayoutableChildren_.push_back(childNode);
yogaNode_.insertChild(
&childNode->yogaNode_,
static_cast<uint32_t>(yogaNode_.getChildren().size()));
yogaNode_.insertChild(&childNode->yogaNode_, yogaNode_.getChildren().size());

ensureYogaChildrenLookFine();
}
Expand All @@ -219,7 +217,7 @@ void YogaLayoutableShadowNode::adoptYogaChild(size_t index) {
auto clonedChildNode = childNode.clone({});

// Replace the child node with a newly cloned one in the children list.
replaceChild(childNode, clonedChildNode, static_cast<int>(index));
replaceChild(childNode, clonedChildNode, static_cast<int32_t>(index));
}

ensureYogaChildrenLookFine();
Expand Down Expand Up @@ -513,7 +511,7 @@ YGErrata YogaLayoutableShadowNode::resolveErrata(YGErrata defaultErrata) const {
}

YogaLayoutableShadowNode& YogaLayoutableShadowNode::cloneChildInPlace(
int32_t layoutableChildIndex) {
size_t layoutableChildIndex) {
ensureUnsealed();

const auto& childNode = *yogaLayoutableChildren_[layoutableChildIndex];
Expand All @@ -525,7 +523,8 @@ YogaLayoutableShadowNode& YogaLayoutableShadowNode::cloneChildInPlace(
ShadowNodeFragment::childrenPlaceholder(),
childNode.getState()});

replaceChild(childNode, clonedChildNode, layoutableChildIndex);
replaceChild(
childNode, clonedChildNode, static_cast<int32_t>(layoutableChildIndex));
return static_cast<YogaLayoutableShadowNode&>(*clonedChildNode);
}

Expand Down Expand Up @@ -787,18 +786,18 @@ Rect YogaLayoutableShadowNode::getContentBounds() const {

#pragma mark - Yoga Connectors

YGNode* YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(
YGNode* /*oldYogaNode*/,
YGNode* parentYogaNode,
int childIndex) {
YGNodeRef YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(
YGNodeConstRef /*oldYogaNode*/,
YGNodeConstRef parentYogaNode,
size_t childIndex) {
SystraceSection s("YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector");

auto& parentNode = shadowNodeFromContext(parentYogaNode);
return &parentNode.cloneChildInPlace(childIndex).yogaNode_;
}

YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
YGNode* yogaNode,
YGNodeConstRef yogaNode,
float width,
YGMeasureMode widthMode,
float height,
Expand Down Expand Up @@ -845,7 +844,7 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
}

YogaLayoutableShadowNode& YogaLayoutableShadowNode::shadowNodeFromContext(
YGNodeRef yogaNode) {
YGNodeConstRef yogaNode) {
return traitCast<YogaLayoutableShadowNode&>(
*static_cast<ShadowNode*>(YGNodeGetContext(yogaNode)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,23 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode {
/**
* Replcaes a child with a mutable clone of itself, returning the clone.
*/
YogaLayoutableShadowNode& cloneChildInPlace(int32_t layoutableChildIndex);
YogaLayoutableShadowNode& cloneChildInPlace(size_t layoutableChildIndex);

static yoga::Config& initializeYogaConfig(
yoga::Config& config,
YGConfigRef previousConfig = nullptr);
static YGNodeRef yogaNodeCloneCallbackConnector(
YGNodeRef oldYogaNode,
YGNodeRef parentYogaNode,
int childIndex);
YGNodeConstRef oldYogaNode,
YGNodeConstRef parentYogaNode,
size_t childIndex);
static YGSize yogaNodeMeasureCallbackConnector(
YGNodeRef yogaNode,
YGNodeConstRef yogaNode,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode);
static YogaLayoutableShadowNode& shadowNodeFromContext(YGNodeRef yogaNode);
static YogaLayoutableShadowNode& shadowNodeFromContext(
YGNodeConstRef yogaNode);

#pragma mark - RTL Legacy Autoflip

Expand Down
Loading