Back out "ReactViewGroup post-conversion cleanup"

Summary: Backing out the stack since a same crash that previously effected many apps appeared again, and there are changes soon landing that will add more conflicts.

Reviewed By: Abbondanzo

Differential Revision: D63493334

fbshipit-source-id: 175fc7b5b69aa2874c867e460ab102bb077a7cd8
This commit is contained in:
Nick Gerleman
2024-09-26 15:50:26 -07:00
committed by Facebook GitHub Bot
parent 1dcaf823f5
commit a886a2fa05
4 changed files with 65 additions and 54 deletions
@@ -4742,7 +4742,6 @@ public final class com/facebook/react/uimanager/ReactInvalidPropertyException :
public abstract interface class com/facebook/react/uimanager/ReactOverflowView {
public abstract fun getOverflow ()Ljava/lang/String;
public abstract fun setOverflow (Ljava/lang/String;)V
}
public abstract interface class com/facebook/react/uimanager/ReactOverflowViewWithInset : com/facebook/react/uimanager/ReactOverflowView {
@@ -0,0 +1,25 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.uimanager;
import android.view.View;
import androidx.annotation.Nullable;
/**
* Interface that should be implemented by {@link View} subclasses that support {@code overflow}
* style. This allows the overflow information to be used by {@link TouchTargetHelper} to determine
* if a View is touchable.
*/
public interface ReactOverflowView {
/**
* Gets the overflow state of a view. If set, this should be one of {@link ViewProps#HIDDEN},
* {@link ViewProps#VISIBLE} or {@link ViewProps#SCROLL}.
*/
@Nullable
String getOverflow();
}
@@ -1,23 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.uimanager
/**
* Interface that should be implemented by [View] subclasses that support `overflow` style. This
* allows the overflow information to be used by [TouchTargetHelper] to determine if a View is
* touchable.
*/
public interface ReactOverflowView {
/**
* The overflow state of a view. If set, this should be one of:
* - [ViewProps.HIDDEN],
* - [ViewProps.VISIBLE]
* - [ViewProps.SCROLL].
*/
public var overflow: String?
}
@@ -127,16 +127,9 @@ public open class ReactViewGroup(context: Context) :
private var childrenLayoutChangeListener: ChildrenLayoutChangeListener? = null
private var onInterceptTouchEventListener: OnInterceptTouchEventListener? = null
private var needsOffscreenAlphaCompositing = false
private var _drawingOrderHelper: ViewGroupDrawingOrderHelper? = null
private var backfaceOpacity = 1f
private var backfaceVisibility: String? = "visible"
private var _drawingOrderHelper: ViewGroupDrawingOrderHelper? = null
private val drawingOrderHelper: ViewGroupDrawingOrderHelper
get() =
_drawingOrderHelper ?: ViewGroupDrawingOrderHelper(this).also { _drawingOrderHelper = it }
init {
initView()
}
/**
* Set all default values here as opposed to in the constructor or field defaults. It is important
@@ -165,7 +158,9 @@ public open class ReactViewGroup(context: Context) :
val children = allChildren
val listener = childrenLayoutChangeListener
if (children != null && listener != null) {
children.forEach { child -> child?.removeOnLayoutChangeListener(listener) }
for (i in 0 until allChildrenCount) {
children[i]?.removeOnLayoutChangeListener(listener)
}
}
// Set default field values
@@ -180,6 +175,16 @@ public open class ReactViewGroup(context: Context) :
resetPointerEvents()
}
private val drawingOrderHelper: ViewGroupDrawingOrderHelper
get() {
return _drawingOrderHelper
?: ViewGroupDrawingOrderHelper(this).also { _drawingOrderHelper = it }
}
init {
initView()
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
MeasureSpecAssertions.assertExplicitMeasureSpec(widthMeasureSpec, heightMeasureSpec)
setMeasuredDimension(
@@ -330,7 +335,9 @@ public open class ReactViewGroup(context: Context) :
val clippingRect = checkNotNull(_clippingRect)
val children = checkNotNull(allChildren)
val listener = checkNotNull(childrenLayoutChangeListener)
children.forEach { child -> child?.removeOnLayoutChangeListener(listener) }
for (i in 0 until allChildrenCount) {
children[i]?.removeOnLayoutChangeListener(listener)
}
getDrawingRect(clippingRect)
updateClippingToRect(clippingRect)
allChildren = null
@@ -628,7 +635,9 @@ public open class ReactViewGroup(context: Context) :
internal open fun removeAllViewsWithSubviewClippingEnabled(): Unit {
Assertions.assertCondition(_removeClippedSubviews)
val children = checkNotNull(allChildren)
children.forEach { child -> child?.removeOnLayoutChangeListener(childrenLayoutChangeListener) }
for (i in 0 until allChildrenCount) {
children[i]?.removeOnLayoutChangeListener(childrenLayoutChangeListener)
}
removeAllViewsInLayout()
allChildrenCount = 0
}
@@ -705,22 +714,23 @@ public open class ReactViewGroup(context: Context) :
protected open fun getBackgroundColor(): Int =
BackgroundStyleApplicator.getBackgroundColor(this) ?: DEFAULT_BACKGROUND_COLOR
override var overflow: String?
get() =
when (_overflow) {
Overflow.HIDDEN -> "hidden"
Overflow.SCROLL -> "scroll"
Overflow.VISIBLE -> "visible"
// TODO: convert to val
public open fun setOverflow(overflow: String?): Unit {
_overflow =
if (overflow == null) {
Overflow.VISIBLE
} else {
Overflow.fromString(overflow) ?: Overflow.VISIBLE
}
set(value) {
_overflow =
if (value == null) {
Overflow.VISIBLE
} else {
Overflow.fromString(value) ?: Overflow.VISIBLE
}
invalidate()
}
invalidate()
}
override fun getOverflow(): String? =
when (_overflow) {
Overflow.HIDDEN -> "hidden"
Overflow.SCROLL -> "scroll"
Overflow.VISIBLE -> "visible"
}
override fun setOverflowInset(left: Int, top: Int, right: Int, bottom: Int) {
if (needsIsolatedLayer() &&
@@ -758,8 +768,8 @@ public open class ReactViewGroup(context: Context) :
canvas.saveLayer(
overflowInset.left.toFloat(),
overflowInset.top.toFloat(),
(width - overflowInset.right).toFloat(),
(height - overflowInset.bottom).toFloat(),
(width + -overflowInset.right).toFloat(),
(height + -overflowInset.bottom).toFloat(),
null)
super.draw(canvas)
canvas.restore()
@@ -790,8 +800,8 @@ public open class ReactViewGroup(context: Context) :
canvas.saveLayer(
overflowInset.left.toFloat(),
overflowInset.top.toFloat(),
(width - overflowInset.right).toFloat(),
(height - overflowInset.bottom).toFloat(),
(width + -overflowInset.right).toFloat(),
(height + -overflowInset.bottom).toFloat(),
p)
}
}