@@ -853,25 +853,9 @@ class SemanticsObject {
853853 hasIdentityTransform &&
854854 verticalContainerAdjustment == 0.0 &&
855855 horizontalContainerAdjustment == 0.0 ) {
856- if (isDesktop) {
857- element.style
858- ..removeProperty ('transform-origin' )
859- ..removeProperty ('transform' );
860- } else {
861- element.style
862- ..removeProperty ('top' )
863- ..removeProperty ('left' );
864- }
856+ _resetElementOffsets (element);
865857 if (containerElement != null ) {
866- if (isDesktop) {
867- containerElement.style
868- ..removeProperty ('transform-origin' )
869- ..removeProperty ('transform' );
870- } else {
871- containerElement.style
872- ..removeProperty ('top' )
873- ..removeProperty ('left' );
874- }
858+ _resetElementOffsets (containerElement);
875859 }
876860 return ;
877861 }
@@ -905,11 +889,15 @@ class SemanticsObject {
905889 effectiveTransformIsIdentity = false ;
906890 }
907891
908- if (! effectiveTransformIsIdentity) {
892+ if (! effectiveTransformIsIdentity || isMacOrIOS) {
893+ if (effectiveTransformIsIdentity) {
894+ effectiveTransform = Matrix4 .identity ();
895+ }
909896 if (isDesktop) {
910897 element.style
911898 ..transformOrigin = '0 0 0'
912- ..transform = matrix4ToCssTransform (effectiveTransform);
899+ ..transform = (effectiveTransformIsIdentity ? 'translate(0px 0px 0px)'
900+ : matrix4ToCssTransform (effectiveTransform));
913901 } else {
914902 // Mobile screen readers observed to have errors while calculating the
915903 // semantics focus borders if css `transform` properties are used.
@@ -927,20 +915,13 @@ class SemanticsObject {
927915 ..height = '${rect .height }px' ;
928916 }
929917 } else {
918+ _resetElementOffsets (element);
930919 // TODO: https://github.com/flutter/flutter/issues/73347
931- if (isDesktop) {
932- element.style
933- ..removeProperty ('transform-origin' )
934- ..removeProperty ('transform' );
935- } else {
936- element.style
937- ..removeProperty ('top' )
938- ..removeProperty ('left' );
939- }
940920 }
941921
942922 if (containerElement != null ) {
943923 if (! hasZeroRectOffset ||
924+ isMacOrIOS ||
944925 verticalContainerAdjustment != 0.0 ||
945926 horizontalContainerAdjustment != 0.0 ) {
946927 final double translateX = - _rect! .left + horizontalContainerAdjustment;
@@ -955,15 +936,33 @@ class SemanticsObject {
955936 ..left = '${translateX }px' ;
956937 }
957938 } else {
958- if (isDesktop) {
959- containerElement.style
960- ..removeProperty ('transform-origin' )
961- ..removeProperty ('transform' );
962- } else {
963- containerElement.style
964- ..removeProperty ('top' )
965- ..removeProperty ('left' );
966- }
939+ _resetElementOffsets (containerElement);
940+ }
941+ }
942+ }
943+
944+ // On Mac OS and iOS, VoiceOver requires left=0 top=0 value to correctly
945+ // handle order. See https://github.com/flutter/flutter/issues/73347.
946+ static void _resetElementOffsets (html.Element element) {
947+ if (isMacOrIOS) {
948+ if (isDesktop) {
949+ element.style
950+ ..transformOrigin = '0 0 0'
951+ ..transform = 'translate(0px, 0px)' ;
952+ } else {
953+ element.style
954+ ..top = '0px'
955+ ..left = '0px' ;
956+ }
957+ } else {
958+ if (isDesktop) {
959+ element.style
960+ ..removeProperty ('transform-origin' )
961+ ..removeProperty ('transform' );
962+ } else {
963+ element.style
964+ ..removeProperty ('top' )
965+ ..removeProperty ('left' );
967966 }
968967 }
969968 }
0 commit comments