mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ReadableNativeMap -> ReadableMap
Summary: This diff refactors JNI methods used by the Binding.cpp class in order to use ReadableMap instead of ReadableNativeMap This will be helpful to provide a different implementation of ReadableMap from C++ Reviewed By: shergin Differential Revision: D14077762 fbshipit-source-id: 595b0c2d3a2d6070112257b65c1141a8af36f0e1
This commit is contained in:
committed by
Facebook Github Bot
parent
1ec9325bae
commit
959fdf6049
@@ -47,7 +47,7 @@ public class ReadableNativeMap extends NativeMap implements ReadableMap {
|
||||
if (mLocalMap != null) {
|
||||
return mLocalMap;
|
||||
}
|
||||
// Check and when necessary get keys atomicaly
|
||||
// Check and when necessary get keys atomically
|
||||
synchronized (this) {
|
||||
if (mKeys == null) {
|
||||
mKeys = Assertions.assertNotNull(importKeys());
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.facebook.react.bridge.NativeMap;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
@@ -52,7 +52,6 @@ import com.facebook.react.fabric.mounting.mountitems.UpdateLayoutMountItem;
|
||||
import com.facebook.react.fabric.mounting.mountitems.UpdateLocalDataMountItem;
|
||||
import com.facebook.react.fabric.mounting.mountitems.UpdatePropsMountItem;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.uimanager.IllegalViewOperationException;
|
||||
import com.facebook.react.uimanager.ReactRootViewTagGenerator;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.ViewManagerPropertyUpdater;
|
||||
@@ -230,13 +229,13 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressWarnings("unused")
|
||||
private MountItem updatePropsMountItem(int reactTag, ReadableNativeMap map) {
|
||||
private MountItem updatePropsMountItem(int reactTag, ReadableMap map) {
|
||||
return new UpdatePropsMountItem(reactTag, map);
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressWarnings("unused")
|
||||
private MountItem updateLocalDataMountItem(int reactTag, ReadableNativeMap newLocalData) {
|
||||
private MountItem updateLocalDataMountItem(int reactTag, ReadableMap newLocalData) {
|
||||
return new UpdateLocalDataMountItem(reactTag, newLocalData);
|
||||
}
|
||||
|
||||
@@ -256,8 +255,8 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
@SuppressWarnings("unused")
|
||||
private long measure(
|
||||
String componentName,
|
||||
ReadableNativeMap localData,
|
||||
ReadableNativeMap props,
|
||||
ReadableMap localData,
|
||||
ReadableMap props,
|
||||
int minWidth,
|
||||
int maxWidth,
|
||||
int minHeight,
|
||||
|
||||
@@ -121,6 +121,10 @@ void Binding::uninstallFabricUIManager() {
|
||||
javaUIManager_ = nullptr;
|
||||
}
|
||||
|
||||
inline local_ref<ReadableMap::javaobject> castReadableMap(local_ref<ReadableNativeMap::javaobject> nativeMap) {
|
||||
return make_local(reinterpret_cast<ReadableMap::javaobject>(nativeMap.get()));
|
||||
}
|
||||
|
||||
//TODO: this method will be removed when binding for components are code-gen
|
||||
local_ref<JString> getPlatformComponentName(const ShadowView &shadowView) {
|
||||
local_ref<JString> componentName;
|
||||
@@ -173,11 +177,10 @@ local_ref<JMountItem::javaobject> createUpdatePropsMountItem(const jni::global_r
|
||||
// TODO: move props from map to a typed object.
|
||||
auto newProps = shadowView.props->rawProps;
|
||||
|
||||
local_ref<ReadableNativeMap::jhybridobject> readableMap = ReadableNativeMap::newObjectCxxArgs(newProps);
|
||||
|
||||
local_ref<ReadableMap::javaobject> readableMap = castReadableMap(ReadableNativeMap::newObjectCxxArgs(newProps));
|
||||
static auto updatePropsInstruction =
|
||||
jni::findClassStatic(UIManagerJavaDescriptor)
|
||||
->getMethod<alias_ref<JMountItem>(jint,ReadableNativeMap::javaobject)>("updatePropsMountItem");
|
||||
->getMethod<alias_ref<JMountItem>(jint,ReadableMap::javaobject)>("updatePropsMountItem");
|
||||
|
||||
return updatePropsInstruction(javaUIManager,
|
||||
mutation.newChildShadowView.tag,
|
||||
@@ -217,7 +220,7 @@ local_ref<JMountItem::javaobject> createInsertMountItem(const jni::global_ref<jo
|
||||
local_ref<JMountItem::javaobject> createUpdateLocalData(const jni::global_ref<jobject> &javaUIManager, const ShadowViewMutation &mutation) {
|
||||
static auto updateLocalDataInstruction =
|
||||
jni::findClassStatic(UIManagerJavaDescriptor)
|
||||
->getMethod<alias_ref<JMountItem>(jint, ReadableNativeMap::javaobject)>("updateLocalDataMountItem");
|
||||
->getMethod<alias_ref<JMountItem>(jint, ReadableMap::javaobject)>("updateLocalDataMountItem");
|
||||
|
||||
auto localData = mutation.newChildShadowView.localData;
|
||||
|
||||
@@ -225,9 +228,9 @@ local_ref<JMountItem::javaobject> createUpdateLocalData(const jni::global_ref<jo
|
||||
if (localData) {
|
||||
newLocalData = localData->getDynamic();
|
||||
}
|
||||
local_ref<ReadableNativeMap::jhybridobject> readableMap = ReadableNativeMap::newObjectCxxArgs(newLocalData);
|
||||
|
||||
return updateLocalDataInstruction(javaUIManager, mutation.newChildShadowView.tag, readableMap.get());
|
||||
local_ref<ReadableNativeMap::jhybridobject> readableNativeMap = ReadableNativeMap::newObjectCxxArgs(newLocalData);
|
||||
return updateLocalDataInstruction(javaUIManager, mutation.newChildShadowView.tag, castReadableMap(readableNativeMap).get());
|
||||
}
|
||||
|
||||
local_ref<JMountItem::javaobject> createRemoveMountItem(const jni::global_ref<jobject> &javaUIManager, const ShadowViewMutation &mutation) {
|
||||
|
||||
@@ -13,16 +13,15 @@ import android.support.annotation.UiThread;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import com.facebook.react.fabric.FabricUIManager;
|
||||
import com.facebook.react.fabric.jsi.EventEmitterWrapper;
|
||||
import com.facebook.react.fabric.mounting.mountitems.MountItem;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.bridge.SoftAssertions;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.fabric.FabricUIManager;
|
||||
import com.facebook.react.fabric.jsi.EventEmitterWrapper;
|
||||
import com.facebook.react.fabric.mounting.mountitems.MountItem;
|
||||
import com.facebook.react.uimanager.IllegalViewOperationException;
|
||||
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
||||
import com.facebook.react.uimanager.RootView;
|
||||
@@ -288,8 +287,8 @@ public class MountingManager {
|
||||
public long measure(
|
||||
ReactContext context,
|
||||
String componentName,
|
||||
ReadableNativeMap localData,
|
||||
ReadableNativeMap props,
|
||||
ReadableMap localData,
|
||||
ReadableMap props,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class UpdateLocalDataMountItem implements MountItem {
|
||||
private final int mReactTag;
|
||||
private final ReadableMap mNewLocalData;
|
||||
|
||||
public UpdateLocalDataMountItem(int reactTag, ReadableNativeMap newLocalData) {
|
||||
public UpdateLocalDataMountItem(int reactTag, ReadableMap newLocalData) {
|
||||
mReactTag = reactTag;
|
||||
mNewLocalData = newLocalData;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.facebook.react.bridge.BaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.touch.JSResponderHandler;
|
||||
import com.facebook.react.touch.ReactInterceptingViewGroup;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
@@ -215,8 +215,8 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
|
||||
public long measure(
|
||||
ReactContext context,
|
||||
ReadableNativeMap localData,
|
||||
ReadableNativeMap props,
|
||||
ReadableMap localData,
|
||||
ReadableMap props,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
|
||||
+20
-30
@@ -1,18 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.views.text;
|
||||
|
||||
import android.text.Layout;
|
||||
import android.text.Spannable;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
@@ -30,8 +27,7 @@ import javax.annotation.Nullable;
|
||||
public class ReactTextViewManager
|
||||
extends ReactTextAnchorViewManager<ReactTextView, ReactTextShadowNode> {
|
||||
|
||||
@VisibleForTesting
|
||||
public static final String REACT_CLASS = "RCTText";
|
||||
@VisibleForTesting public static final String REACT_CLASS = "RCTText";
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -70,11 +66,12 @@ public class ReactTextViewManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object updateLocalData(ReactTextView view, ReactStylesDiffMap props, ReactStylesDiffMap localData) {
|
||||
public Object updateLocalData(
|
||||
ReactTextView view, ReactStylesDiffMap props, ReactStylesDiffMap localData) {
|
||||
ReadableMap attributedString = localData.getMap("attributedString");
|
||||
|
||||
Spannable spanned = TextLayoutManager.getOrCreateSpannableForText(view.getContext(),
|
||||
attributedString);
|
||||
Spannable spanned =
|
||||
TextLayoutManager.getOrCreateSpannableForText(view.getContext(), attributedString);
|
||||
view.setSpanned(spanned);
|
||||
|
||||
TextAttributeProps textViewProps = new TextAttributeProps(props);
|
||||
@@ -82,18 +79,16 @@ public class ReactTextViewManager
|
||||
// TODO add textBreakStrategy prop into local Data
|
||||
int textBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY;
|
||||
|
||||
return
|
||||
new ReactTextUpdate(
|
||||
return new ReactTextUpdate(
|
||||
spanned,
|
||||
-1, // TODO add this into local Data?
|
||||
false, // TODO add this into local Data
|
||||
-1, // TODO add this into local Data?
|
||||
false, // TODO add this into local Data
|
||||
textViewProps.getStartPadding(),
|
||||
textViewProps.getTopPadding(),
|
||||
textViewProps.getEndPadding(),
|
||||
textViewProps.getBottomPadding(),
|
||||
textViewProps.getTextAlign(),
|
||||
textBreakStrategy
|
||||
);
|
||||
textBreakStrategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,20 +97,15 @@ public class ReactTextViewManager
|
||||
}
|
||||
|
||||
public long measure(
|
||||
ReactContext context,
|
||||
ReadableNativeMap localData,
|
||||
ReadableNativeMap props,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode) {
|
||||
ReactContext context,
|
||||
ReadableMap localData,
|
||||
ReadableMap props,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode) {
|
||||
|
||||
return TextLayoutManager.measureText(context,
|
||||
localData,
|
||||
props,
|
||||
width,
|
||||
widthMode,
|
||||
height,
|
||||
heightMode);
|
||||
return TextLayoutManager.measureText(
|
||||
context, localData, props, width, widthMode, height, heightMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.util.LruCache;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
||||
import com.facebook.yoga.YogaConstants;
|
||||
@@ -208,8 +207,8 @@ public class TextLayoutManager {
|
||||
|
||||
public static long measureText(
|
||||
ReactContext context,
|
||||
ReadableNativeMap attributedString,
|
||||
ReadableNativeMap paragraphAttributes,
|
||||
ReadableMap attributedString,
|
||||
ReadableMap paragraphAttributes,
|
||||
float width,
|
||||
YogaMeasureMode widthYogaMeasureMode,
|
||||
float height,
|
||||
|
||||
Reference in New Issue
Block a user