Skip to content
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 @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1ee723a105e7d14a01f92469bad94888>>
* @generated SignedSource<<3ee5c6b643fa4065a8168ebbb19d4efc>>
*/

/**
Expand Down Expand Up @@ -66,12 +66,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun disableMountItemReorderingAndroid(): Boolean = accessor.disableMountItemReorderingAndroid()

/**
* Disable some workarounds for old Android versions in TextLayoutManager logic for retrieving attachment metrics
*/
@JvmStatic
public fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean = accessor.disableOldAndroidAttachmentMetricsWorkarounds()

/**
* Force disable subview clipping for ReactViewGroup on Android
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<934d187fb9928a20d4a442977c7f90b2>>
* @generated SignedSource<<0c88c86f3085fa7c319b0c0a60102057>>
*/

/**
Expand All @@ -26,7 +26,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var disableEarlyViewCommandExecutionCache: Boolean? = null
private var disableImageViewPreallocationAndroidCache: Boolean? = null
private var disableMountItemReorderingAndroidCache: Boolean? = null
private var disableOldAndroidAttachmentMetricsWorkaroundsCache: Boolean? = null
private var disableSubviewClippingAndroidCache: Boolean? = null
private var disableTextLayoutManagerCacheAndroidCache: Boolean? = null
private var disableViewPreallocationAndroidCache: Boolean? = null
Expand Down Expand Up @@ -161,15 +160,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean {
var cached = disableOldAndroidAttachmentMetricsWorkaroundsCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.disableOldAndroidAttachmentMetricsWorkarounds()
disableOldAndroidAttachmentMetricsWorkaroundsCache = cached
}
return cached
}

override fun disableSubviewClippingAndroid(): Boolean {
var cached = disableSubviewClippingAndroidCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9eaa1bfee243767cc98b9477fc391c37>>
* @generated SignedSource<<ca442b740e44e6eea6a8227f00fa1f99>>
*/

/**
Expand Down Expand Up @@ -40,8 +40,6 @@ public object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic public external fun disableMountItemReorderingAndroid(): Boolean

@DoNotStrip @JvmStatic public external fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean

@DoNotStrip @JvmStatic public external fun disableSubviewClippingAndroid(): Boolean

@DoNotStrip @JvmStatic public external fun disableTextLayoutManagerCacheAndroid(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<51a5be93dbaf0000664d6ff482bdc18c>>
* @generated SignedSource<<15272e1b6cbbcb03b08f453e9cdfccb1>>
*/

/**
Expand Down Expand Up @@ -35,8 +35,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun disableMountItemReorderingAndroid(): Boolean = false

override fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean = true

override fun disableSubviewClippingAndroid(): Boolean = false

override fun disableTextLayoutManagerCacheAndroid(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<503f34acc5cf8a0755cef1ca8b72e7e5>>
* @generated SignedSource<<2a0f4c8afaa630631d09e804776197a2>>
*/

/**
Expand All @@ -30,7 +30,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var disableEarlyViewCommandExecutionCache: Boolean? = null
private var disableImageViewPreallocationAndroidCache: Boolean? = null
private var disableMountItemReorderingAndroidCache: Boolean? = null
private var disableOldAndroidAttachmentMetricsWorkaroundsCache: Boolean? = null
private var disableSubviewClippingAndroidCache: Boolean? = null
private var disableTextLayoutManagerCacheAndroidCache: Boolean? = null
private var disableViewPreallocationAndroidCache: Boolean? = null
Expand Down Expand Up @@ -171,16 +170,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}

override fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean {
var cached = disableOldAndroidAttachmentMetricsWorkaroundsCache
if (cached == null) {
cached = currentProvider.disableOldAndroidAttachmentMetricsWorkarounds()
accessedFeatureFlags.add("disableOldAndroidAttachmentMetricsWorkarounds")
disableOldAndroidAttachmentMetricsWorkaroundsCache = cached
}
return cached
}

override fun disableSubviewClippingAndroid(): Boolean {
var cached = disableSubviewClippingAndroidCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d301449edc583e49d5660ea5d5f80929>>
* @generated SignedSource<<6346af0ed92119faadaec2b5b08b34d1>>
*/

/**
Expand Down Expand Up @@ -35,8 +35,6 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun disableMountItemReorderingAndroid(): Boolean

@DoNotStrip public fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean

@DoNotStrip public fun disableSubviewClippingAndroid(): Boolean

@DoNotStrip public fun disableTextLayoutManagerCacheAndroid(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,63 +1307,22 @@ internal object TextLayoutManager {
} else {
val placeholderWidth = placeholder.width.toFloat()
val placeholderHeight = placeholder.height.toFloat()

// Calculate if the direction of the placeholder character is Right-To-Left.
val isRtlChar = layout.isRtlCharAt(start)
val isRtlParagraph = layout.getParagraphDirection(line) == Layout.DIR_RIGHT_TO_LEFT
var placeholderLeftPosition: Float
// There's a bug on Samsung devices where calling getPrimaryHorizontal on
// the last offset in the layout will result in an endless loop. Work around
// this bug by avoiding getPrimaryHorizontal in that case.
if (
!ReactNativeFeatureFlags.disableOldAndroidAttachmentMetricsWorkarounds() &&
start == text.length - 1
) {
val endsWithNewLine = text.length > 0 && text[layout.getLineEnd(line) - 1] == '\n'
val lineWidth = if (endsWithNewLine) layout.getLineMax(line) else layout.getLineWidth(line)
placeholderLeftPosition =
if (
isRtlParagraph // Equivalent to `layout.getLineLeft(line)` but `getLineLeft` returns
// incorrect
// values when the paragraph is RTL and `setSingleLine(true)`.
)
( // Equivalent to `layout.getLineLeft(line)` but `getLineLeft` returns
// incorrect
// values when the paragraph is RTL and `setSingleLine(true)`.
calculatedWidth - lineWidth)
else (layout.getLineRight(line) - placeholderWidth)
} else {
// The direction of the paragraph may not be exactly the direction the string is
// heading
// in at the
// position of the placeholder. So, if the direction of the character is the same
// as the
// paragraph
// use primary, secondary otherwise.
val characterAndParagraphDirectionMatch = isRtlParagraph == isRtlChar
placeholderLeftPosition =
if (characterAndParagraphDirectionMatch) layout.getPrimaryHorizontal(start)
else layout.getSecondaryHorizontal(start)
if (
!ReactNativeFeatureFlags.disableOldAndroidAttachmentMetricsWorkarounds() &&
isRtlParagraph &&
!isRtlChar
) {
// Adjust `placeholderLeftPosition` to work around an Android bug.
// The bug is when the paragraph is RTL and `setSingleLine(true)`, some layout
// methods such as `getPrimaryHorizontal`, `getSecondaryHorizontal`, and
// `getLineRight` return incorrect values. Their return values seem to be off
// by the same number of pixels so subtracting these values cancels out the
// error.
//
// The result is equivalent to bugless versions of
// `getPrimaryHorizontal`/`getSecondaryHorizontal`.
placeholderLeftPosition =
calculatedWidth - (layout.getLineRight(line) - placeholderLeftPosition)
}
if (isRtlChar) {
placeholderLeftPosition -= placeholderWidth
}

// The direction of the paragraph may not be exactly the direction the string is heading in at
// the position of the placeholder. So, if the direction of the character is the same as the
// paragraph use primary, secondary otherwise.
val characterAndParagraphDirectionMatch = isRtlParagraph == isRtlChar
var placeholderLeftPosition =
if (characterAndParagraphDirectionMatch) layout.getPrimaryHorizontal(start)
else layout.getSecondaryHorizontal(start)
if (isRtlChar) {
placeholderLeftPosition -= placeholderWidth
}

// Vertically align the inline view to the baseline of the line of text.
val placeholderTopPosition = layout.getLineBaseline(line) - placeholderHeight

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<bedfbd46022e1f5f29c7f6331ef99688>>
* @generated SignedSource<<49089fe126ce14edaf58fbf8a942330f>>
*/

/**
Expand Down Expand Up @@ -75,12 +75,6 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}

bool disableOldAndroidAttachmentMetricsWorkarounds() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("disableOldAndroidAttachmentMetricsWorkarounds");
return method(javaProvider_);
}

bool disableSubviewClippingAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("disableSubviewClippingAndroid");
Expand Down Expand Up @@ -589,11 +583,6 @@ bool JReactNativeFeatureFlagsCxxInterop::disableMountItemReorderingAndroid(
return ReactNativeFeatureFlags::disableMountItemReorderingAndroid();
}

bool JReactNativeFeatureFlagsCxxInterop::disableOldAndroidAttachmentMetricsWorkarounds(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::disableOldAndroidAttachmentMetricsWorkarounds();
}

bool JReactNativeFeatureFlagsCxxInterop::disableSubviewClippingAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::disableSubviewClippingAndroid();
Expand Down Expand Up @@ -1038,9 +1027,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"disableMountItemReorderingAndroid",
JReactNativeFeatureFlagsCxxInterop::disableMountItemReorderingAndroid),
makeNativeMethod(
"disableOldAndroidAttachmentMetricsWorkarounds",
JReactNativeFeatureFlagsCxxInterop::disableOldAndroidAttachmentMetricsWorkarounds),
makeNativeMethod(
"disableSubviewClippingAndroid",
JReactNativeFeatureFlagsCxxInterop::disableSubviewClippingAndroid),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<dfdba04bf07b35c5f49c1ac20b13a33a>>
* @generated SignedSource<<06dbf870e1f4fe12a401c8688e6474e3>>
*/

/**
Expand Down Expand Up @@ -48,9 +48,6 @@ class JReactNativeFeatureFlagsCxxInterop
static bool disableMountItemReorderingAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool disableOldAndroidAttachmentMetricsWorkarounds(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool disableSubviewClippingAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9e57bf3807cda945c78dd6d3229908a0>>
* @generated SignedSource<<cde6583036fe361451901aa616751ae2>>
*/

/**
Expand Down Expand Up @@ -50,10 +50,6 @@ bool ReactNativeFeatureFlags::disableMountItemReorderingAndroid() {
return getAccessor().disableMountItemReorderingAndroid();
}

bool ReactNativeFeatureFlags::disableOldAndroidAttachmentMetricsWorkarounds() {
return getAccessor().disableOldAndroidAttachmentMetricsWorkarounds();
}

bool ReactNativeFeatureFlags::disableSubviewClippingAndroid() {
return getAccessor().disableSubviewClippingAndroid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<7583b49b28e083ae22b538fdce205d43>>
* @generated SignedSource<<67d07e991ed29af6fbab27d8af527e0e>>
*/

/**
Expand Down Expand Up @@ -69,11 +69,6 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool disableMountItemReorderingAndroid();

/**
* Disable some workarounds for old Android versions in TextLayoutManager logic for retrieving attachment metrics
*/
RN_EXPORT static bool disableOldAndroidAttachmentMetricsWorkarounds();

/**
* Force disable subview clipping for ReactViewGroup on Android
*/
Expand Down
Loading
Loading