Implement standard interface for toggling experimental features
Reviewed By: gkassabli Differential Revision: D4174260 fbshipit-source-id: ad3667183810c02833fba9a1276f89286e848fcd
This commit is contained in:
parent
a2cafb062e
commit
307871e854
|
@ -2512,3 +2512,13 @@ void CSSLog(CSSLogLevel level, const char *format, ...) {
|
|||
gLogger(level, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static bool experimentalFeatures[CSSExperimentalFeatureCount];
|
||||
|
||||
void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled) {
|
||||
experimentalFeatures[feature] = enabled;
|
||||
}
|
||||
|
||||
bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature) {
|
||||
return experimentalFeatures[feature];
|
||||
}
|
||||
|
|
|
@ -123,6 +123,10 @@ typedef enum CSSLogLevel {
|
|||
CSSLogLevelVerbose,
|
||||
} CSSLogLevel;
|
||||
|
||||
typedef enum CSSExperimentalFeature {
|
||||
CSSExperimentalFeatureCount,
|
||||
} CSSExperimentalFeature;
|
||||
|
||||
typedef struct CSSNode *CSSNodeRef;
|
||||
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
|
||||
float width,
|
||||
|
@ -238,4 +242,7 @@ CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction);
|
|||
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
|
||||
WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...);
|
||||
|
||||
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled);
|
||||
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature);
|
||||
|
||||
CSS_EXTERN_C_END
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSExperimentalFeature {
|
||||
}
|
|
@ -40,6 +40,20 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
|||
jni_CSSLayoutSetLogger(logger);
|
||||
}
|
||||
|
||||
private static native void jni_CSSLayoutSetExperimentalFeatureEnabled(
|
||||
int feature,
|
||||
boolean enabled);
|
||||
public static void setExperimentalFeatureEnabled(
|
||||
CSSExperimentalFeature feature,
|
||||
boolean enabled) {
|
||||
jni_CSSLayoutSetExperimentalFeatureEnabled(feature.ordinal(), enabled);
|
||||
}
|
||||
|
||||
private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature);
|
||||
public static boolean isExperimentalFeatureEnabled(CSSExperimentalFeature feature) {
|
||||
return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.ordinal());
|
||||
}
|
||||
|
||||
private CSSNode mParent;
|
||||
private List<CSSNode> mChildren;
|
||||
private MeasureFunction mMeasureFunction;
|
||||
|
|
|
@ -105,6 +105,14 @@ void jni_CSSLog(alias_ref<jclass> clazz, jint level, jstring message) {
|
|||
Environment::current()->ReleaseStringUTFChars(message, nMessage);
|
||||
}
|
||||
|
||||
void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature, jboolean enabled) {
|
||||
CSSLayoutSetExperimentalFeatureEnabled(static_cast<CSSExperimentalFeature>(feature), enabled);
|
||||
}
|
||||
|
||||
jboolean jni_CSSLayoutIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
|
||||
return CSSLayoutIsExperimentalFeatureEnabled(static_cast<CSSExperimentalFeature>(feature));
|
||||
}
|
||||
|
||||
jint jni_CSSNodeGetInstanceCount(alias_ref<jclass> clazz) {
|
||||
return CSSNodeGetInstanceCount();
|
||||
}
|
||||
|
@ -291,6 +299,8 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
|||
CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutSetLogger),
|
||||
CSSMakeNativeMethod(jni_CSSLog),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutSetExperimentalFeatureEnabled),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutIsExperimentalFeatureEnabled),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2512,3 +2512,13 @@ void CSSLog(CSSLogLevel level, const char *format, ...) {
|
|||
gLogger(level, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static bool experimentalFeatures[CSSExperimentalFeatureCount];
|
||||
|
||||
void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled) {
|
||||
experimentalFeatures[feature] = enabled;
|
||||
}
|
||||
|
||||
bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature) {
|
||||
return experimentalFeatures[feature];
|
||||
}
|
||||
|
|
|
@ -123,6 +123,10 @@ typedef enum CSSLogLevel {
|
|||
CSSLogLevelVerbose,
|
||||
} CSSLogLevel;
|
||||
|
||||
typedef enum CSSExperimentalFeature {
|
||||
CSSExperimentalFeatureCount,
|
||||
} CSSExperimentalFeature;
|
||||
|
||||
typedef struct CSSNode *CSSNodeRef;
|
||||
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
|
||||
float width,
|
||||
|
@ -238,4 +242,7 @@ CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction);
|
|||
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
|
||||
WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...);
|
||||
|
||||
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled);
|
||||
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature);
|
||||
|
||||
CSS_EXTERN_C_END
|
||||
|
|
Loading…
Reference in New Issue