Skip to content

Commit fe1bcf1

Browse files
George MountGerrit Code Review
authored andcommitted
Revert "Stop adding minimumTouchTargetSize to clipped touch bounds"
This reverts commit 6b9bc53. Reason for revert: b/482394033 Bug: 479577752 Change-Id: Ifbf6c2bc1df4b11801cec3dad544f865798fee6a
1 parent 6b9bc53 commit fe1bcf1

6 files changed

Lines changed: 8 additions & 140 deletions

File tree

‎compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/AccessibilityNodeInspector.kt‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ import androidx.compose.ui.geometry.isSpecified
8686
import androidx.compose.ui.graphics.ClipOp
8787
import androidx.compose.ui.graphics.Color
8888
import androidx.compose.ui.graphics.Path
89-
import androidx.compose.ui.graphics.PathOperation
9089
import androidx.compose.ui.graphics.TransformOrigin
9190
import androidx.compose.ui.graphics.asComposePath
9291
import androidx.compose.ui.graphics.drawscope.ContentDrawScope
@@ -132,7 +131,6 @@ import androidx.compose.ui.unit.dp
132131
import androidx.compose.ui.unit.offset
133132
import androidx.compose.ui.unit.round
134133
import androidx.compose.ui.unit.toOffset
135-
import androidx.compose.ui.unit.toRect
136134
import androidx.compose.ui.unit.toSize
137135
import androidx.compose.ui.util.fastFirstOrNull
138136
import androidx.compose.ui.util.fastForEach
@@ -321,10 +319,6 @@ private class DrawSelectionOverlayModifierNode(val state: AccessibilityNodeInspe
321319
private val lazyPath: Path
322320
get() = _path ?: Path().also { _path = it }
323321

324-
private var _boundsPath: Path? = null
325-
private val lazyBoundsPath: Path
326-
get() = _boundsPath ?: Path().also { _boundsPath = it }
327-
328322
private var _androidPath: AndroidPath? = null
329323
private val lazyAndroidPath: AndroidPath
330324
get() = _androidPath ?: AndroidPath().also { _androidPath = it }
@@ -423,12 +417,7 @@ private class DrawSelectionOverlayModifierNode(val state: AccessibilityNodeInspe
423417
}
424418
else -> return null
425419
}
426-
427-
val boundsPath = lazyBoundsPath
428-
boundsPath.rewind()
429-
val bounds = boundsInScreen.toRect().run { translate(-topLeft) }
430-
boundsPath.addRect(bounds)
431-
return path.apply { op(path, boundsPath, PathOperation.Intersect) }
420+
return path
432421
}
433422

434423
private fun LayoutCoordinates.screenToLocal(rect: IntRect): IntRect {

‎compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import androidx.compose.foundation.demos.text.SoftwareKeyboardControllerDemo
2323
import androidx.compose.integration.demos.common.ActivityDemo
2424
import androidx.compose.integration.demos.common.ComposableDemo
2525
import androidx.compose.integration.demos.common.DemoCategory
26-
import androidx.compose.ui.demos.accessibility.AccessibilityClippingDemo
2726
import androidx.compose.ui.demos.accessibility.AccessibilityShapeOffscreenDemo
2827
import androidx.compose.ui.demos.accessibility.LinearProgressIndicatorDemo
2928
import androidx.compose.ui.demos.accessibility.NestedContainersFalseDemo
@@ -344,7 +343,6 @@ val AccessibilityDemos =
344343
ComposableDemo("Dual LTR and RTL Scene") { SimpleRtlLayoutDemo() },
345344
ComposableDemo("Scrolling Tooltip scene") { SampleScrollingTooltipScreen() },
346345
ComposableDemo("Accessibility Shapes") { AccessibilityShapeOffscreenDemo() },
347-
ComposableDemo("Accessibility Clipping Demo") { AccessibilityClippingDemo() },
348346
),
349347
)
350348

‎compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/accessibility/AccessibilityClippingDemo.kt‎

Lines changed: 0 additions & 78 deletions
This file was deleted.

‎compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/accessibility/AccessibilityShapesDemo.kt‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
package androidx.compose.ui.demos.accessibility
1818

1919
import androidx.compose.foundation.background
20-
import androidx.compose.foundation.border
2120
import androidx.compose.foundation.horizontalScroll
2221
import androidx.compose.foundation.layout.Arrangement
2322
import androidx.compose.foundation.layout.Box
2423
import androidx.compose.foundation.layout.Column
2524
import androidx.compose.foundation.layout.Row
26-
import androidx.compose.foundation.layout.fillMaxSize
2725
import androidx.compose.foundation.layout.padding
2826
import androidx.compose.foundation.layout.requiredSize
2927
import androidx.compose.foundation.rememberScrollState
@@ -44,13 +42,11 @@ import androidx.compose.ui.unit.dp
4442

4543
@Composable
4644
fun AccessibilityShapeOffscreenDemo() {
47-
Column(
48-
Modifier.fillMaxSize().padding(16.dp),
49-
verticalArrangement = Arrangement.spacedBy(16.dp),
50-
) {
45+
Column(Modifier.padding(vertical = 16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
5146
Text(
5247
"Scroll a shape off screen and then use the a11y inspector on it " +
53-
"to see if the a11y view of the shape matches its actual shape."
48+
"to see if the a11y view of the shape matches its actual shape.",
49+
Modifier.padding(horizontal = 16.dp),
5450
)
5551

5652
@Composable
@@ -63,7 +59,7 @@ fun AccessibilityShapeOffscreenDemo() {
6359
}
6460

6561
Column(
66-
Modifier.border(1.dp, Color.LightGray).horizontalScroll(rememberScrollState()),
62+
Modifier.horizontalScroll(rememberScrollState()),
6763
verticalArrangement = Arrangement.spacedBy(16.dp),
6864
) {
6965
RepeatedLayoutRow(RectangleShape)

‎compose/ui/ui/src/androidDeviceTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ import androidx.compose.runtime.setValue
112112
import androidx.compose.testutils.expectError
113113
import androidx.compose.ui.AndroidComposeViewAccessibilityDelegateCompatTest.Companion.AccessibilityEventComparator
114114
import androidx.compose.ui.draw.alpha
115-
import androidx.compose.ui.draw.clipToBounds
116115
import androidx.compose.ui.draw.shadow
117116
import androidx.compose.ui.focus.FocusRequester
118117
import androidx.compose.ui.focus.focusRequester
@@ -152,7 +151,6 @@ import androidx.compose.ui.semantics.getOrNull
152151
import androidx.compose.ui.semantics.hideFromAccessibility
153152
import androidx.compose.ui.semantics.isSensitiveData
154153
import androidx.compose.ui.semantics.isTraversalGroup
155-
import androidx.compose.ui.semantics.onClick
156154
import androidx.compose.ui.semantics.pageUp
157155
import androidx.compose.ui.semantics.paneTitle
158156
import androidx.compose.ui.semantics.role
@@ -4540,43 +4538,6 @@ class AndroidAccessibilityTest {
45404538
assertThat(rect.height()).isEqualTo(150)
45414539
}
45424540

4543-
// Regression test for b/479577752
4544-
@Test
4545-
fun testChildBounds_clippedToParentBounds_whenParentLargerThanMinTouchTarget() {
4546-
// When parent's size (100) is larger than minimum touch target (48),
4547-
// and the child bounds are larger than the parent's (200),
4548-
// child bounds should be clipped to parent's actual bounds (100),
4549-
// not parent bounds + half min touch target (100 + 24 = 124).
4550-
setContent {
4551-
// density = 1f so that we don't have to convert at all.
4552-
CompositionLocalProvider(LocalDensity provides Density(1f)) {
4553-
Box(Modifier.size(200.dp).background(Color.Black.copy(alpha = 0.1f))) {
4554-
// Constraining and clipping parent
4555-
Box(Modifier.requiredSize(100.dp).clipToBounds()) {
4556-
// Semantically clickable and clipped child
4557-
Box(
4558-
Modifier.wrapContentSize(Alignment.TopStart, unbounded = true)
4559-
.requiredSize(200.dp)
4560-
.background(Color.Blue)
4561-
// onClick needed to go down the touch bounds path.
4562-
.semantics { onClick { true } }
4563-
.testTag(tag)
4564-
)
4565-
}
4566-
}
4567-
}
4568-
}
4569-
4570-
val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
4571-
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
4572-
val rect = Rect().also { info.getBoundsInScreen(it) }
4573-
4574-
// Child should be clipped to parent's 100px.
4575-
// The regression size for 48 minTouchTarget would be 124.
4576-
assertThat(rect.width()).isEqualTo(100)
4577-
assertThat(rect.height()).isEqualTo(100)
4578-
}
4579-
45804541
@Test
45814542
fun testSemanticsHitTest_unimportantTraversalProperties() {
45824543
// Arrange.

‎compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/NodeCoordinator.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,9 @@ internal abstract class NodeCoordinator(override val layoutNode: LayoutNode) :
12701270
if (layer != null) {
12711271
if (isClipping) {
12721272
if (clipToMinimumTouchTargetSize) {
1273-
val (horz, vert) = calculateMinimumTouchTargetPadding(minimumTouchTargetSize)
1273+
val minTouch = minimumTouchTargetSize
1274+
val horz = minTouch.width / 2f
1275+
val vert = minTouch.height / 2f
12741276
bounds.intersect(
12751277
-horz,
12761278
-vert,

0 commit comments

Comments
 (0)