aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-14 22:46:16 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-02-14 22:46:16 +0000
commitaf119e2e31de85654fb7b2e5a2c7e724231131fd (patch)
tree1bccbb4e3c39e0ec1ef352f813dcd47902ab4ea1
parent8633926143d8ec22a5efe8093c070d395e60dae1 (diff)
parente603f07d98d35d59b35d454dbc719e3a13b7f480 (diff)
downloadsupport-af119e2e31de85654fb7b2e5a2c7e724231131fd.tar.gz
Merge "Merge cherrypicks of ['android-review.googlesource.com/2962173'] into androidx-compose-release." into androidx-compose-release
-rw-r--r--compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCacheTest.kt28
-rw-r--r--compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCache.kt2
2 files changed, 30 insertions, 0 deletions
diff --git a/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCacheTest.kt b/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCacheTest.kt
index 9cd1aabccd3..6a51fcabf79 100644
--- a/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCacheTest.kt
+++ b/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCacheTest.kt
@@ -69,6 +69,34 @@ class MultiParagraphLayoutCacheTest {
}
@Test
+ fun intrinsicHeight_invalidates() {
+ val fontSize = 20.sp
+ val text = "Hello"
+ val spanStyle = SpanStyle(fontSize = fontSize, fontFamily = fontFamily)
+ val annotatedString = AnnotatedString(text, spanStyle)
+ val textDelegate = MultiParagraphLayoutCache(
+ text = annotatedString,
+ style = TextStyle.Default,
+ fontFamilyResolver = fontFamilyResolver,
+ ).also {
+ it.density = density
+ }
+
+ val original = textDelegate.intrinsicHeight(20, LayoutDirection.Ltr)
+ textDelegate.update(AnnotatedString("Longer\ntext\ngoes\nhere\n\n\n."),
+ TextStyle.Default,
+ fontFamilyResolver,
+ TextOverflow.Visible,
+ true,
+ Int.MAX_VALUE,
+ -1,
+ null
+ )
+ val after = textDelegate.intrinsicHeight(20, LayoutDirection.Ltr)
+ assertThat(original).isLessThan(after)
+ }
+
+ @Test
fun maxIntrinsicWidth_getter() {
with(density) {
val fontSize = 20.sp
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCache.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCache.kt
index f9bb08d791d..accb3b5dfed 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCache.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCache.kt
@@ -337,6 +337,8 @@ internal class MultiParagraphLayoutCache(
private fun markDirty() {
paragraphIntrinsics = null
layoutCache = null
+ cachedIntrinsicHeight = -1
+ cachedIntrinsicHeightInputWidth = -1
}
/**