28
28
import com .facebook .react .touch .OnInterceptTouchEventListener ;
29
29
import com .facebook .react .touch .ReactHitSlopView ;
30
30
import com .facebook .react .touch .ReactInterceptingViewGroup ;
31
+ import com .facebook .react .uimanager .IllegalViewOperationException ;
31
32
import com .facebook .react .uimanager .MeasureSpecAssertions ;
32
33
import com .facebook .react .uimanager .PointerEvents ;
33
34
import com .facebook .react .uimanager .ReactClippingViewGroup ;
34
35
import com .facebook .react .uimanager .ReactClippingViewGroupHelper ;
35
36
import com .facebook .react .uimanager .ReactPointerEventsView ;
36
37
import com .facebook .react .uimanager .ReactZIndexedViewGroup ;
38
+ import com .facebook .react .uimanager .RootView ;
39
+ import com .facebook .react .uimanager .RootViewUtil ;
37
40
import com .facebook .react .uimanager .ViewGroupDrawingOrderHelper ;
38
41
import com .facebook .yoga .YogaConstants ;
39
42
import javax .annotation .Nullable ;
@@ -657,6 +660,24 @@ private void updateBackgroundDrawable(Drawable drawable) {
657
660
658
661
@ Override
659
662
protected void dispatchDraw (Canvas canvas ) {
663
+ try {
664
+ dispatchOverflowDraw (canvas );
665
+ super .dispatchDraw (canvas );
666
+ } catch (StackOverflowError e ) {
667
+ // Adding special exception management for StackOverflowError for logging purposes.
668
+ // This will be removed in the future.
669
+ RootView rootView = RootViewUtil .getRootView (ReactViewGroup .this );
670
+ IllegalViewOperationException wrappedException =
671
+ new IllegalViewOperationException ("StackOverflowError" , e );
672
+ if (rootView != null ) {
673
+ rootView .handleException (wrappedException );
674
+ } else {
675
+ throw wrappedException ;
676
+ }
677
+ }
678
+ }
679
+
680
+ private void dispatchOverflowDraw (Canvas canvas ) {
660
681
if (mOverflow != null ) {
661
682
switch (mOverflow ) {
662
683
case "visible" :
@@ -674,9 +695,9 @@ protected void dispatchDraw(Canvas canvas) {
674
695
final RectF borderWidth = mReactBackgroundDrawable .getDirectionAwareBorderInsets ();
675
696
676
697
if (borderWidth .top > 0
677
- || borderWidth .left > 0
678
- || borderWidth .bottom > 0
679
- || borderWidth .right > 0 ) {
698
+ || borderWidth .left > 0
699
+ || borderWidth .bottom > 0
700
+ || borderWidth .right > 0 ) {
680
701
left += borderWidth .left ;
681
702
top += borderWidth .top ;
682
703
right -= borderWidth .right ;
@@ -685,32 +706,32 @@ protected void dispatchDraw(Canvas canvas) {
685
706
686
707
final float borderRadius = mReactBackgroundDrawable .getFullBorderRadius ();
687
708
float topLeftBorderRadius =
688
- mReactBackgroundDrawable .getBorderRadiusOrDefaultTo (
689
- borderRadius , ReactViewBackgroundDrawable .BorderRadiusLocation .TOP_LEFT );
709
+ mReactBackgroundDrawable .getBorderRadiusOrDefaultTo (
710
+ borderRadius , ReactViewBackgroundDrawable .BorderRadiusLocation .TOP_LEFT );
690
711
float topRightBorderRadius =
691
- mReactBackgroundDrawable .getBorderRadiusOrDefaultTo (
692
- borderRadius , ReactViewBackgroundDrawable .BorderRadiusLocation .TOP_RIGHT );
712
+ mReactBackgroundDrawable .getBorderRadiusOrDefaultTo (
713
+ borderRadius , ReactViewBackgroundDrawable .BorderRadiusLocation .TOP_RIGHT );
693
714
float bottomLeftBorderRadius =
694
- mReactBackgroundDrawable .getBorderRadiusOrDefaultTo (
695
- borderRadius , ReactViewBackgroundDrawable .BorderRadiusLocation .BOTTOM_LEFT );
715
+ mReactBackgroundDrawable .getBorderRadiusOrDefaultTo (
716
+ borderRadius , ReactViewBackgroundDrawable .BorderRadiusLocation .BOTTOM_LEFT );
696
717
float bottomRightBorderRadius =
697
- mReactBackgroundDrawable .getBorderRadiusOrDefaultTo (
698
- borderRadius , ReactViewBackgroundDrawable .BorderRadiusLocation .BOTTOM_RIGHT );
718
+ mReactBackgroundDrawable .getBorderRadiusOrDefaultTo (
719
+ borderRadius , ReactViewBackgroundDrawable .BorderRadiusLocation .BOTTOM_RIGHT );
699
720
700
721
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR1 ) {
701
722
final boolean isRTL = mLayoutDirection == View .LAYOUT_DIRECTION_RTL ;
702
723
float topStartBorderRadius =
703
- mReactBackgroundDrawable .getBorderRadius (
704
- ReactViewBackgroundDrawable .BorderRadiusLocation .TOP_START );
724
+ mReactBackgroundDrawable .getBorderRadius (
725
+ ReactViewBackgroundDrawable .BorderRadiusLocation .TOP_START );
705
726
float topEndBorderRadius =
706
- mReactBackgroundDrawable .getBorderRadius (
707
- ReactViewBackgroundDrawable .BorderRadiusLocation .TOP_END );
727
+ mReactBackgroundDrawable .getBorderRadius (
728
+ ReactViewBackgroundDrawable .BorderRadiusLocation .TOP_END );
708
729
float bottomStartBorderRadius =
709
- mReactBackgroundDrawable .getBorderRadius (
710
- ReactViewBackgroundDrawable .BorderRadiusLocation .BOTTOM_START );
730
+ mReactBackgroundDrawable .getBorderRadius (
731
+ ReactViewBackgroundDrawable .BorderRadiusLocation .BOTTOM_START );
711
732
float bottomEndBorderRadius =
712
- mReactBackgroundDrawable .getBorderRadius (
713
- ReactViewBackgroundDrawable .BorderRadiusLocation .BOTTOM_END );
733
+ mReactBackgroundDrawable .getBorderRadius (
734
+ ReactViewBackgroundDrawable .BorderRadiusLocation .BOTTOM_END );
714
735
715
736
if (I18nUtil .getInstance ().doLeftAndRightSwapInRTL (getContext ())) {
716
737
if (YogaConstants .isUndefined (topStartBorderRadius )) {
@@ -730,27 +751,27 @@ protected void dispatchDraw(Canvas canvas) {
730
751
}
731
752
732
753
final float directionAwareTopLeftRadius =
733
- isRTL ? topEndBorderRadius : topStartBorderRadius ;
754
+ isRTL ? topEndBorderRadius : topStartBorderRadius ;
734
755
final float directionAwareTopRightRadius =
735
- isRTL ? topStartBorderRadius : topEndBorderRadius ;
756
+ isRTL ? topStartBorderRadius : topEndBorderRadius ;
736
757
final float directionAwareBottomLeftRadius =
737
- isRTL ? bottomEndBorderRadius : bottomStartBorderRadius ;
758
+ isRTL ? bottomEndBorderRadius : bottomStartBorderRadius ;
738
759
final float directionAwareBottomRightRadius =
739
- isRTL ? bottomStartBorderRadius : bottomEndBorderRadius ;
760
+ isRTL ? bottomStartBorderRadius : bottomEndBorderRadius ;
740
761
741
762
topLeftBorderRadius = directionAwareTopLeftRadius ;
742
763
topRightBorderRadius = directionAwareTopRightRadius ;
743
764
bottomLeftBorderRadius = directionAwareBottomLeftRadius ;
744
765
bottomRightBorderRadius = directionAwareBottomRightRadius ;
745
766
} else {
746
767
final float directionAwareTopLeftRadius =
747
- isRTL ? topEndBorderRadius : topStartBorderRadius ;
768
+ isRTL ? topEndBorderRadius : topStartBorderRadius ;
748
769
final float directionAwareTopRightRadius =
749
- isRTL ? topStartBorderRadius : topEndBorderRadius ;
770
+ isRTL ? topStartBorderRadius : topEndBorderRadius ;
750
771
final float directionAwareBottomLeftRadius =
751
- isRTL ? bottomEndBorderRadius : bottomStartBorderRadius ;
772
+ isRTL ? bottomEndBorderRadius : bottomStartBorderRadius ;
752
773
final float directionAwareBottomRightRadius =
753
- isRTL ? bottomStartBorderRadius : bottomEndBorderRadius ;
774
+ isRTL ? bottomStartBorderRadius : bottomEndBorderRadius ;
754
775
755
776
if (!YogaConstants .isUndefined (directionAwareTopLeftRadius )) {
756
777
topLeftBorderRadius = directionAwareTopLeftRadius ;
@@ -771,27 +792,27 @@ protected void dispatchDraw(Canvas canvas) {
771
792
}
772
793
773
794
if (topLeftBorderRadius > 0
774
- || topRightBorderRadius > 0
775
- || bottomRightBorderRadius > 0
776
- || bottomLeftBorderRadius > 0 ) {
795
+ || topRightBorderRadius > 0
796
+ || bottomRightBorderRadius > 0
797
+ || bottomLeftBorderRadius > 0 ) {
777
798
if (mPath == null ) {
778
799
mPath = new Path ();
779
800
}
780
801
781
802
mPath .rewind ();
782
803
mPath .addRoundRect (
783
- new RectF (left , top , right , bottom ),
784
- new float [] {
785
- Math .max (topLeftBorderRadius - borderWidth .left , 0 ),
786
- Math .max (topLeftBorderRadius - borderWidth .top , 0 ),
787
- Math .max (topRightBorderRadius - borderWidth .right , 0 ),
788
- Math .max (topRightBorderRadius - borderWidth .top , 0 ),
789
- Math .max (bottomRightBorderRadius - borderWidth .right , 0 ),
790
- Math .max (bottomRightBorderRadius - borderWidth .bottom , 0 ),
791
- Math .max (bottomLeftBorderRadius - borderWidth .left , 0 ),
792
- Math .max (bottomLeftBorderRadius - borderWidth .bottom , 0 ),
793
- },
794
- Path .Direction .CW );
804
+ new RectF (left , top , right , bottom ),
805
+ new float []{
806
+ Math .max (topLeftBorderRadius - borderWidth .left , 0 ),
807
+ Math .max (topLeftBorderRadius - borderWidth .top , 0 ),
808
+ Math .max (topRightBorderRadius - borderWidth .right , 0 ),
809
+ Math .max (topRightBorderRadius - borderWidth .top , 0 ),
810
+ Math .max (bottomRightBorderRadius - borderWidth .right , 0 ),
811
+ Math .max (bottomRightBorderRadius - borderWidth .bottom , 0 ),
812
+ Math .max (bottomLeftBorderRadius - borderWidth .left , 0 ),
813
+ Math .max (bottomLeftBorderRadius - borderWidth .bottom , 0 ),
814
+ },
815
+ Path .Direction .CW );
795
816
canvas .clipPath (mPath );
796
817
} else {
797
818
canvas .clipRect (new RectF (left , top , right , bottom ));
@@ -802,6 +823,5 @@ protected void dispatchDraw(Canvas canvas) {
802
823
break ;
803
824
}
804
825
}
805
- super .dispatchDraw (canvas );
806
826
}
807
827
}
0 commit comments