Skip to content

Commit 78f60b5

Browse files
committed
Revert "Fix: propagate elements metrics to their shadow nodes (#2802)"
This reverts commit 27eb9b0.
1 parent 1702acb commit 78f60b5

16 files changed

+59
-254
lines changed

android/src/main/java/com/horcrux/svg/GroupView.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import android.graphics.Region;
2020
import android.os.Build;
2121
import android.view.View;
22-
import com.facebook.react.bridge.Arguments;
2322
import com.facebook.react.bridge.Dynamic;
2423
import com.facebook.react.bridge.ReactContext;
2524
import com.facebook.react.bridge.ReadableMap;
2625
import com.facebook.react.bridge.ReadableType;
27-
import com.facebook.react.bridge.WritableMap;
2826
import java.util.ArrayList;
2927
import javax.annotation.Nullable;
3028

@@ -342,20 +340,4 @@ void resetProperties() {
342340
}
343341
}
344342
}
345-
346-
@Override
347-
public void updateShadowNodeMetrics() {
348-
SvgView svgView = this.getSvgView();
349-
350-
if (this.stateWrapper == null || svgView == null) {
351-
return;
352-
}
353-
354-
WritableMap map = Arguments.createMap();
355-
map.putDouble("x", 0);
356-
map.putDouble("y", 0);
357-
map.putDouble("width", svgView.getCanvasWidth() / mScale);
358-
map.putDouble("height", svgView.getCanvasHeight() / mScale);
359-
this.stateWrapper.updateState(map);
360-
}
361343
}

android/src/main/java/com/horcrux/svg/RenderableView.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import com.facebook.react.bridge.ReadableType;
3434
import com.facebook.react.bridge.WritableMap;
3535
import com.facebook.react.touch.ReactHitSlopView;
36-
import com.facebook.react.uimanager.PointerEvents;
3736
import com.facebook.react.uimanager.events.RCTEventEmitter;
37+
import com.facebook.react.uimanager.PointerEvents;
3838
import java.lang.reflect.Field;
3939
import java.util.ArrayList;
4040
import java.util.regex.Matcher;
@@ -103,8 +103,10 @@ public abstract class RenderableView extends VirtualView implements ReactHitSlop
103103

104104
public void onReceiveNativeEvent() {
105105
WritableMap event = Arguments.createMap();
106-
ReactContext reactContext = (ReactContext) getContext();
107-
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topSvgLayout", event);
106+
ReactContext reactContext = (ReactContext)getContext();
107+
reactContext
108+
.getJSModule(RCTEventEmitter.class)
109+
.receiveEvent(getId(), "topSvgLayout", event);
108110
}
109111

110112
@Nullable String mFilter;
@@ -498,8 +500,6 @@ void render(Canvas canvas, Paint paint, float opacity) {
498500
} else {
499501
draw(canvas, paint, opacity);
500502
}
501-
502-
this.updateShadowNodeMetrics();
503503
}
504504

505505
@Override
@@ -823,19 +823,4 @@ void resetProperties() {
823823
private boolean hasOwnProperty(String propName) {
824824
return mAttributeList != null && mAttributeList.contains(propName);
825825
}
826-
827-
protected void updateShadowNodeMetrics() {
828-
RectF clientRect = this.getClientRect();
829-
830-
if (this.stateWrapper == null || clientRect == null) {
831-
return;
832-
}
833-
834-
WritableMap map = Arguments.createMap();
835-
map.putDouble("x", clientRect.left / mScale);
836-
map.putDouble("y", clientRect.top / mScale);
837-
map.putDouble("width", clientRect.width() / mScale);
838-
map.putDouble("height", clientRect.height() / mScale);
839-
this.stateWrapper.updateState(map);
840-
}
841826
}

android/src/main/java/com/horcrux/svg/RenderableViewManager.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@
6767
import android.util.SparseArray;
6868
import android.view.View;
6969
import android.view.ViewGroup;
70-
71-
import androidx.annotation.NonNull;
72-
7370
import com.facebook.react.bridge.Dynamic;
7471
import com.facebook.react.bridge.JavaOnlyMap;
7572
import com.facebook.react.bridge.ReadableArray;
@@ -81,8 +78,6 @@
8178
import com.facebook.react.uimanager.MatrixMathHelper;
8279
import com.facebook.react.uimanager.PixelUtil;
8380
import com.facebook.react.uimanager.PointerEvents;
84-
import com.facebook.react.uimanager.ReactStylesDiffMap;
85-
import com.facebook.react.uimanager.StateWrapper;
8681
import com.facebook.react.uimanager.ThemedReactContext;
8782
import com.facebook.react.uimanager.TransformHelper;
8883
import com.facebook.react.uimanager.ViewGroupManager;
@@ -171,12 +166,6 @@ protected ViewManagerDelegate getDelegate() {
171166
return mDelegate;
172167
}
173168

174-
@Override
175-
public Object updateState(@NonNull VirtualView view, ReactStylesDiffMap props, StateWrapper stateWrapper) {
176-
view.setStateWrapper(stateWrapper);
177-
return super.updateState(view, props, stateWrapper);
178-
}
179-
180169
static class RenderableShadowNode extends LayoutShadowNode {
181170

182171
@SuppressWarnings({"unused", "EmptyMethod"})

android/src/main/java/com/horcrux/svg/VirtualView.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import com.facebook.react.common.ReactConstants;
2222
import com.facebook.react.uimanager.DisplayMetricsHolder;
2323
import com.facebook.react.uimanager.PointerEvents;
24-
import com.facebook.react.uimanager.StateWrapper;
2524
import com.facebook.react.uimanager.UIManagerHelper;
2625
import com.facebook.react.uimanager.events.EventDispatcher;
2726
import com.facebook.react.views.view.ReactViewGroup;
2827
import com.horcrux.svg.events.SvgOnLayoutEvent;
28+
2929
import java.util.ArrayList;
3030
import javax.annotation.Nullable;
3131

@@ -84,7 +84,6 @@ public abstract class VirtualView extends ReactViewGroup {
8484
private float canvasHeight = -1;
8585
private float canvasWidth = -1;
8686
private GlyphContext glyphContext;
87-
protected @Nullable StateWrapper stateWrapper = null;
8887

8988
Path mPath;
9089
Path mFillPath;
@@ -107,10 +106,6 @@ public void setPointerEvents(PointerEvents pointerEvents) {
107106
mPointerEvents = pointerEvents;
108107
}
109108

110-
public void setStateWrapper(@Nullable StateWrapper stateWrapper) {
111-
this.stateWrapper = stateWrapper;
112-
}
113-
114109
@Override
115110
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
116111
super.onInitializeAccessibilityNodeInfo(info);
@@ -254,7 +249,7 @@ int saveAndSetupCanvas(Canvas canvas, Matrix ctm) {
254249
int count = canvas.save();
255250
mCTM.set(mMatrix);
256251
canvas.concat(mCTM);
257-
mCTM.postConcat(ctm);
252+
mCTM.preConcat(ctm);
258253
mCTMInvertible = mCTM.invert(mInvCTM);
259254
return count;
260255
}
@@ -442,19 +437,15 @@ public SvgView getSvgView() {
442437

443438
double relativeOnWidth(SVGLength length) {
444439
SvgView svg = getSvgView();
445-
if (length.unit == SVGLength.UnitType.PERCENTAGE
446-
&& svg != null
447-
&& svg.getViewBox().width() != 0) {
440+
if (length.unit == SVGLength.UnitType.PERCENTAGE && svg != null && svg.getViewBox().width() != 0) {
448441
return relativeOn(length, svg.getViewBox().width());
449442
}
450443
return relativeOn(length, getCanvasWidth());
451444
}
452445

453446
double relativeOnHeight(SVGLength length) {
454447
SvgView svg = getSvgView();
455-
if (length.unit == SVGLength.UnitType.PERCENTAGE
456-
&& svg != null
457-
&& svg.getViewBox().height() != 0) {
448+
if (length.unit == SVGLength.UnitType.PERCENTAGE && svg != null && svg.getViewBox().height() != 0) {
458449
return relativeOn(length, svg.getViewBox().height());
459450
}
460451
return relativeOn(length, getCanvasHeight());

apple/Elements/RNSVGGroup.mm

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#import <react/renderer/components/view/conversions.h>
1717
#import <rnsvg/RNSVGComponentDescriptors.h>
1818
#import "RNSVGFabricConversions.h"
19-
#import "RNSVGRenderUtils.h"
2019
#endif // RCT_NEW_ARCH_ENABLED
2120

2221
@implementation RNSVGGroup {
@@ -309,16 +308,6 @@ - (void)resetProperties
309308
}];
310309
}
311310

312-
#ifdef RCT_NEW_ARCH_ENABLED
313-
- (void)updateShadowNodeMetrics
314-
{
315-
auto statePtr = [self state];
316-
if (statePtr) {
317-
statePtr->updateState(RNSVGLayoutableState(0, 0, [self getCanvasWidth], [self getCanvasHeight]));
318-
}
319-
}
320-
#endif
321-
322311
@end
323312

324313
#ifdef RCT_NEW_ARCH_ENABLED

apple/RNSVGRenderable.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
#import "RNSVGNode.h"
1717
#import "RNSVGVectorEffect.h"
1818

19-
#ifdef RCT_NEW_ARCH_ENABLED
20-
#import <rnsvg/RNSVGComponentDescriptors.h>
21-
22-
using namespace facebook::react;
23-
#endif
24-
2519
@interface RNSVGRenderable : RNSVGNode
2620

2721
@property (class) RNSVGRenderable *contextElement;
@@ -42,10 +36,6 @@ using namespace facebook::react;
4236
@property (nonatomic, assign) CGPathRef hitArea;
4337
@property (nonatomic, strong) NSString *filter;
4438

45-
#ifdef RCT_NEW_ARCH_ENABLED
46-
- (facebook::react::RNSVGRenderableShadowNode::ConcreteState::Shared)state;
47-
#endif
48-
4939
- (void)setColor:(RNSVGColor *)color;
5040

5141
- (void)setHitArea:(CGPathRef)path;
@@ -58,8 +48,4 @@ using namespace facebook::react;
5848

5949
- (CGColor *)getCurrentColor;
6050

61-
#ifdef RCT_NEW_ARCH_ENABLED
62-
- (void)updateShadowNodeMetrics;
63-
#endif
64-
6551
@end

apple/RNSVGRenderable.mm

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ @implementation RNSVGRenderable {
2626
CGFloat *_strokeDashArrayData;
2727
CGPathRef _srcHitPath;
2828
RNSVGRenderable *_caller;
29-
30-
#ifdef RCT_NEW_ARCH_ENABLED
31-
RNSVGRenderableShadowNode::ConcreteState::Shared _state;
32-
#endif
3329
}
3430

3531
static RNSVGRenderable *_contextElement;
@@ -247,11 +243,6 @@ - (void)prepareForRecycle
247243
_filter = nil;
248244
_caller = nil;
249245
}
250-
251-
- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState
252-
{
253-
_state = std::static_pointer_cast<const RNSVGRenderableShadowNode::ConcreteState>(state);
254-
}
255246
#endif // RCT_NEW_ARCH_ENABLED
256247

257248
UInt32 saturate(CGFloat value)
@@ -441,9 +432,6 @@ - (void)renderTo:(CGContextRef)context rect:(CGRect)rect
441432
CGContextRestoreGState(context);
442433

443434
[self renderMarkers:context path:self.path rect:&rect];
444-
#ifdef RCT_NEW_ARCH_ENABLED
445-
[self updateShadowNodeMetrics];
446-
#endif
447435
}
448436

449437
- (void)prepareStrokeDash:(NSUInteger)count strokeDasharray:(NSArray<RNSVGLength *> *)strokeDasharray
@@ -785,17 +773,4 @@ - (CGColor *)getCurrentColor
785773
return nil;
786774
}
787775

788-
#ifdef RCT_NEW_ARCH_ENABLED
789-
- (void)updateShadowNodeMetrics
790-
{
791-
if (_state) {
792-
_state->updateState(RNSVGLayoutableState(self.clientRect.origin.x, self.clientRect.origin.y, self.clientRect.size.width, self.clientRect.size.height));
793-
}
794-
}
795-
796-
- (RNSVGRenderableShadowNode::ConcreteState::Shared)state {
797-
return _state;
798-
}
799-
#endif
800-
801776
@end

common/cpp/react/renderer/components/rnsvg/RNSVGComponentDescriptor.h

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

0 commit comments

Comments
 (0)