Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a158b81

Browse files
author
nturgut
committed
fixing positions with wrong a11y borders screenreader-on/mobile browsers
1 parent 53b93ba commit a158b81

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/web_ui/lib/src/engine/semantics/semantics.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,11 @@ class SemanticsObject {
882882
}
883883

884884
if (!effectiveTransformIsIdentity) {
885+
final Position2D position2d =
886+
matrix4ToCssTransformForSemantics(effectiveTransform);
885887
element.style
886-
..transformOrigin = '0 0 0'
887-
..transform = matrix4ToCssTransform(effectiveTransform);
888+
..top = position2d.top
889+
..left = position2d.left;
888890
} else {
889891
element.style
890892
..removeProperty('transform-origin')

lib/web_ui/lib/src/engine/util.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ String matrix4ToCssTransform(Matrix4 matrix) {
5555
return float64ListToCssTransform(matrix.storage);
5656
}
5757

58+
/// Converts [matrix] to CSS top/left values.
59+
Position2D matrix4ToCssTransformForSemantics(Matrix4 matrix) {
60+
return float64ListToCss2dPositionSemantics(matrix.storage);
61+
}
62+
5863
/// Applies a transform to the [element].
5964
///
6065
/// See [float64ListToCssTransform] for details on how the CSS value is chosen.
@@ -86,6 +91,19 @@ String float64ListToCssTransform(Float32List matrix) {
8691
}
8792
}
8893

94+
/// Converts [matrix] to coordinates on 2 dimensional space.
95+
///
96+
/// Only used by semantics node styling calculations, since semantics
97+
/// node does not receive 3D transforms, only tx and ty values of the matrix
98+
/// is used.
99+
Position2D float64ListToCss2dPositionSemantics(Float32List matrix) {
100+
assert(transformKindOf(matrix) != TransformKind.transform2d);
101+
assert(matrix.length == 16);
102+
final Float32List m = matrix;
103+
print('top left: ${matrix[13]} ${matrix[12]} semantics');
104+
return Position2D('${matrix[13]}px', '${matrix[12]}px');
105+
}
106+
89107
/// The kind of effect a transform matrix performs.
90108
enum TransformKind {
91109
/// No effect.
@@ -573,3 +591,15 @@ int clampInt(int value, int min, int max) {
573591
return value;
574592
}
575593
}
594+
595+
/// Position of a node in 2 dimensional space.
596+
class Position2D {
597+
/// The position on y-axis.
598+
final String top;
599+
600+
/// The position on x-axis.
601+
final String left;
602+
603+
/// Position2D default constructor.
604+
Position2D(this.top, this.left);
605+
}

0 commit comments

Comments
 (0)