Use fbsource clang-format config
Summary: This mirrors the clang-format config used by fbsource to Yoga. They are pretty similar, except for an annoying habit where Yoga's previous forced small functions in headers to be a a single line, so you would get a combination of multiline and single line functions next to each other which are hard to read. That is what motivated this change. It also enforces header ordering (yay). I don't think we have any side-effect causing headers, so this should be safe. Reviewed By: yungsters Differential Revision: D49248994 fbshipit-source-id: 66998395e7c0158ff9d9fb1bee44e8401bdd8f21
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9d21e3e300
commit
f9c2c27d33
@@ -1,61 +1,3 @@
|
|||||||
Language: Cpp
|
|
||||||
AccessModifierOffset: -2
|
|
||||||
AlignAfterOpenBracket: AlwaysBreak
|
|
||||||
AlignConsecutiveAssignments: false
|
|
||||||
AlignConsecutiveDeclarations: false
|
|
||||||
AlignEscapedNewlines: Left
|
|
||||||
AlignOperands: false
|
|
||||||
AlignTrailingComments: false
|
|
||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
|
||||||
AllowShortBlocksOnASingleLine: false
|
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
|
||||||
AllowShortLoopsOnASingleLine: true
|
|
||||||
AlwaysBreakAfterReturnType: None
|
|
||||||
AlwaysBreakBeforeMultilineStrings: true
|
|
||||||
AlwaysBreakTemplateDeclarations: Yes
|
|
||||||
BinPackArguments: false
|
|
||||||
BinPackParameters: false
|
|
||||||
BreakBeforeBinaryOperators: false
|
|
||||||
BreakBeforeBraces: Attach
|
|
||||||
BreakBeforeTernaryOperators: true
|
|
||||||
BreakConstructorInitializers: BeforeColon
|
|
||||||
BreakInheritanceList: BeforeColon
|
|
||||||
BreakStringLiterals: true
|
|
||||||
ColumnLimit: 80
|
|
||||||
CompactNamespaces: false
|
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
|
||||||
ConstructorInitializerIndentWidth: 4
|
|
||||||
ContinuationIndentWidth: 4
|
|
||||||
Cpp11BracedListStyle: true
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
FixNamespaceComments: true
|
|
||||||
IndentCaseLabels: true
|
|
||||||
IndentPPDirectives: None
|
|
||||||
IndentWidth: 2
|
|
||||||
IndentWrappedFunctionNames: false
|
|
||||||
MaxEmptyLinesToKeep: 1
|
|
||||||
NamespaceIndentation: None
|
|
||||||
PenaltyReturnTypeOnItsOwnLine: 2000
|
|
||||||
PointerAlignment: Left
|
|
||||||
ReflowComments: true
|
|
||||||
SortIncludes: false
|
|
||||||
SortUsingDeclarations: true
|
|
||||||
SpaceAfterCStyleCast: true
|
|
||||||
SpaceAfterTemplateKeyword: true
|
|
||||||
SpaceBeforeAssignmentOperators: true
|
|
||||||
SpaceBeforeCpp11BracedList: false
|
|
||||||
SpaceBeforeCtorInitializerColon: true
|
|
||||||
SpaceBeforeInheritanceColon: true
|
|
||||||
SpaceBeforeParens: ControlStatements
|
|
||||||
SpaceBeforeRangeBasedForLoopColon: true
|
|
||||||
SpaceInEmptyParentheses: false
|
|
||||||
SpacesBeforeTrailingComments: 1
|
|
||||||
Standard: Cpp11
|
|
||||||
UseTab: Never
|
|
||||||
---
|
|
||||||
Language: ObjC
|
|
||||||
AccessModifierOffset: -1
|
AccessModifierOffset: -1
|
||||||
AlignAfterOpenBracket: AlwaysBreak
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
AlignConsecutiveMacros: false
|
AlignConsecutiveMacros: false
|
||||||
@@ -165,4 +107,3 @@ Standard: Latest
|
|||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseCRLF: false
|
UseCRLF: false
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
...
|
|
||||||
|
@@ -47,10 +47,8 @@ static int __compareDoubles(const void* a, const void* b) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __printBenchmarkResult(
|
static void
|
||||||
char* name,
|
__printBenchmarkResult(char* name, clock_t start, clock_t* endTimes) {
|
||||||
clock_t start,
|
|
||||||
clock_t* endTimes) {
|
|
||||||
double timesInMs[NUM_REPETITIONS];
|
double timesInMs[NUM_REPETITIONS];
|
||||||
double mean = 0;
|
double mean = 0;
|
||||||
clock_t lastEnd = start;
|
clock_t lastEnd = start;
|
||||||
|
@@ -82,7 +82,9 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ScopedGlobalRef() { reset(); }
|
~ScopedGlobalRef() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the currently held reference and reassigns a new one to the
|
* Deletes the currently held reference and reassigns a new one to the
|
||||||
@@ -111,12 +113,16 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns the underlying JNI global reference.
|
* Returns the underlying JNI global reference.
|
||||||
*/
|
*/
|
||||||
T get() const { return mGlobalRef; }
|
T get() const {
|
||||||
|
return mGlobalRef;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the underlying JNI reference is not NULL.
|
* Returns true if the underlying JNI reference is not NULL.
|
||||||
*/
|
*/
|
||||||
operator bool() const { return mGlobalRef != NULL; }
|
operator bool() const {
|
||||||
|
return mGlobalRef != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ScopedGlobalRef(const ScopedGlobalRef& ref) = delete;
|
ScopedGlobalRef(const ScopedGlobalRef& ref) = delete;
|
||||||
ScopedGlobalRef& operator=(const ScopedGlobalRef& other) = delete;
|
ScopedGlobalRef& operator=(const ScopedGlobalRef& other) = delete;
|
||||||
|
@@ -81,7 +81,9 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ScopedLocalRef() { reset(); }
|
~ScopedLocalRef() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the currently held reference and reassigns a new one to the
|
* Deletes the currently held reference and reassigns a new one to the
|
||||||
@@ -110,12 +112,16 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns the underlying JNI local reference.
|
* Returns the underlying JNI local reference.
|
||||||
*/
|
*/
|
||||||
T get() const { return mLocalRef; }
|
T get() const {
|
||||||
|
return mLocalRef;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the underlying JNI reference is not NULL.
|
* Returns true if the underlying JNI reference is not NULL.
|
||||||
*/
|
*/
|
||||||
operator bool() const { return mLocalRef != NULL; }
|
operator bool() const {
|
||||||
|
return mLocalRef != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ScopedLocalRef(const ScopedLocalRef& ref) = delete;
|
ScopedLocalRef(const ScopedLocalRef& ref) = delete;
|
||||||
ScopedLocalRef& operator=(const ScopedLocalRef& other) = delete;
|
ScopedLocalRef& operator=(const ScopedLocalRef& other) = delete;
|
||||||
|
@@ -48,14 +48,18 @@ public:
|
|||||||
YGNodeSetContext(node, context.asVoidPtr);
|
YGNodeSetContext(node, context.asVoidPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has(Edge edge) { return (edges_ & edge) == edge; }
|
bool has(Edge edge) {
|
||||||
|
return (edges_ & edge) == edge;
|
||||||
|
}
|
||||||
|
|
||||||
YGNodeEdges& add(Edge edge) {
|
YGNodeEdges& add(Edge edge) {
|
||||||
edges_ |= edge;
|
edges_ |= edge;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get() { return edges_; }
|
int get() {
|
||||||
|
return edges_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct YogaValue {
|
struct YogaValue {
|
||||||
|
@@ -5,16 +5,16 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "jni.h"
|
|
||||||
#include "YGJNIVanilla.h"
|
#include "YGJNIVanilla.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "YGJNI.h"
|
|
||||||
#include "common.h"
|
|
||||||
#include "YGJTypesVanilla.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "YogaJniException.h"
|
|
||||||
#include "LayoutContext.h"
|
#include "LayoutContext.h"
|
||||||
|
#include "YGJNI.h"
|
||||||
|
#include "YGJTypesVanilla.h"
|
||||||
|
#include "YogaJniException.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "jni.h"
|
||||||
|
|
||||||
#include <yoga/Yoga-internal.h>
|
#include <yoga/Yoga-internal.h>
|
||||||
#include <yoga/bits/BitCast.h>
|
#include <yoga/bits/BitCast.h>
|
||||||
@@ -39,10 +39,8 @@ static jlong jni_YGConfigNewJNI(JNIEnv* /*env*/, jobject /*obj*/) {
|
|||||||
return reinterpret_cast<jlong>(YGConfigNew());
|
return reinterpret_cast<jlong>(YGConfigNew());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jni_YGConfigFreeJNI(
|
static void
|
||||||
JNIEnv* /*env*/,
|
jni_YGConfigFreeJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
||||||
jobject /*obj*/,
|
|
||||||
jlong nativePointer) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
// unique_ptr will destruct the underlying global_ref, if present.
|
// unique_ptr will destruct the underlying global_ref, if present.
|
||||||
auto context = std::unique_ptr<ScopedGlobalRef<jobject>>{
|
auto context = std::unique_ptr<ScopedGlobalRef<jobject>>{
|
||||||
@@ -191,10 +189,8 @@ static void jni_YGConfigSetLoggerJNI(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jni_YGNodeDeallocateJNI(
|
static void
|
||||||
JNIEnv* /*env*/,
|
jni_YGNodeDeallocateJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
||||||
jobject /*obj*/,
|
|
||||||
jlong nativePointer) {
|
|
||||||
if (nativePointer == 0) {
|
if (nativePointer == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -202,10 +198,8 @@ static void jni_YGNodeDeallocateJNI(
|
|||||||
YGNodeDeallocate(node);
|
YGNodeDeallocate(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jni_YGNodeResetJNI(
|
static void
|
||||||
JNIEnv* /*env*/,
|
jni_YGNodeResetJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
||||||
jobject /*obj*/,
|
|
||||||
jlong nativePointer) {
|
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
void* context = YGNodeGetContext(node);
|
void* context = YGNodeGetContext(node);
|
||||||
YGNodeReset(node);
|
YGNodeReset(node);
|
||||||
@@ -269,10 +263,8 @@ static void jni_YGNodeRemoveChildJNI(
|
|||||||
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGTransferLayoutOutputsRecursive(
|
static void
|
||||||
JNIEnv* env,
|
YGTransferLayoutOutputsRecursive(JNIEnv* env, jobject thiz, YGNodeRef root) {
|
||||||
jobject thiz,
|
|
||||||
YGNodeRef root) {
|
|
||||||
if (!YGNodeGetHasNewLayout(root)) {
|
if (!YGNodeGetHasNewLayout(root)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -356,7 +348,6 @@ static void jni_YGNodeCalculateLayoutJNI(
|
|||||||
jfloat height,
|
jfloat height,
|
||||||
jlongArray nativePointers,
|
jlongArray nativePointers,
|
||||||
jobjectArray javaNodes) {
|
jobjectArray javaNodes) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PtrJNodeMapVanilla* layoutContext = nullptr;
|
PtrJNodeMapVanilla* layoutContext = nullptr;
|
||||||
auto map = PtrJNodeMapVanilla{};
|
auto map = PtrJNodeMapVanilla{};
|
||||||
@@ -389,10 +380,8 @@ static void jni_YGNodeCalculateLayoutJNI(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jni_YGNodeMarkDirtyJNI(
|
static void
|
||||||
JNIEnv* /*env*/,
|
jni_YGNodeMarkDirtyJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
||||||
jobject /*obj*/,
|
|
||||||
jlong nativePointer) {
|
|
||||||
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
|
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,10 +392,8 @@ static void jni_YGNodeMarkDirtyAndPropagateToDescendantsJNI(
|
|||||||
YGNodeMarkDirtyAndPropagateToDescendants(_jlong2YGNodeRef(nativePointer));
|
YGNodeMarkDirtyAndPropagateToDescendants(_jlong2YGNodeRef(nativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean jni_YGNodeIsDirtyJNI(
|
static jboolean
|
||||||
JNIEnv* /*env*/,
|
jni_YGNodeIsDirtyJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
||||||
jobject /*obj*/,
|
|
||||||
jlong nativePointer) {
|
|
||||||
return (jboolean)YGNodeIsDirty(_jlong2YGNodeRef(nativePointer));
|
return (jboolean)YGNodeIsDirty(_jlong2YGNodeRef(nativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,10 +691,8 @@ static void jni_YGNodeSetHasBaselineFuncJNI(
|
|||||||
hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
|
hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jni_YGNodePrintJNI(
|
static void
|
||||||
JNIEnv* /*env*/,
|
jni_YGNodePrintJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
||||||
jobject /*obj*/,
|
|
||||||
jlong nativePointer) {
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
YGNodePrint(
|
YGNodePrint(
|
||||||
@@ -718,10 +703,8 @@ static void jni_YGNodePrintJNI(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static jlong jni_YGNodeCloneJNI(
|
static jlong
|
||||||
JNIEnv* /*env*/,
|
jni_YGNodeCloneJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
||||||
jobject /*obj*/,
|
|
||||||
jlong nativePointer) {
|
|
||||||
auto node = _jlong2YGNodeRef(nativePointer);
|
auto node = _jlong2YGNodeRef(nativePointer);
|
||||||
const YGNodeRef clonedYogaNode = YGNodeClone(node);
|
const YGNodeRef clonedYogaNode = YGNodeClone(node);
|
||||||
YGNodeSetContext(clonedYogaNode, YGNodeGetContext(node));
|
YGNodeSetContext(clonedYogaNode, YGNodeGetContext(node));
|
||||||
@@ -928,9 +911,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetWidthAutoJNI",
|
{"jni_YGNodeStyleSetWidthAutoJNI",
|
||||||
"(J)V",
|
"(J)V",
|
||||||
(void*)jni_YGNodeStyleSetWidthAutoJNI},
|
(void*)jni_YGNodeStyleSetWidthAutoJNI},
|
||||||
{"jni_YGNodeStyleGetHeightJNI",
|
{"jni_YGNodeStyleGetHeightJNI", "(J)J", (void*)jni_YGNodeStyleGetHeightJNI},
|
||||||
"(J)J",
|
|
||||||
(void*) jni_YGNodeStyleGetHeightJNI},
|
|
||||||
{"jni_YGNodeStyleSetHeightJNI",
|
{"jni_YGNodeStyleSetHeightJNI",
|
||||||
"(JF)V",
|
"(JF)V",
|
||||||
(void*)jni_YGNodeStyleSetHeightJNI},
|
(void*)jni_YGNodeStyleSetHeightJNI},
|
||||||
|
@@ -5,9 +5,9 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "YogaJniException.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "YogaJniException.h"
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
namespace facebook::yoga::vanillajni {
|
namespace facebook::yoga::vanillajni {
|
||||||
|
@@ -76,11 +76,8 @@ DEFINE_CALL_METHOD_FOR_PRIMITIVE_INTERFACE(void, Void) {
|
|||||||
assertNoPendingJniException(env);
|
assertNoPendingJniException(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedLocalRef<jobject> callStaticObjectMethod(
|
ScopedLocalRef<jobject>
|
||||||
JNIEnv* env,
|
callStaticObjectMethod(JNIEnv* env, jclass clazz, jmethodID methodId, ...) {
|
||||||
jclass clazz,
|
|
||||||
jmethodID methodId,
|
|
||||||
...) {
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, methodId);
|
va_start(args, methodId);
|
||||||
jobject result = env->CallStaticObjectMethodV(clazz, methodId, args);
|
jobject result = env->CallStaticObjectMethodV(clazz, methodId, args);
|
||||||
|
@@ -59,11 +59,8 @@ DEFINE_CALL_METHOD_FOR_PRIMITIVE_INTERFACE(void, Void);
|
|||||||
DEFINE_CALL_METHOD_FOR_PRIMITIVE_INTERFACE(jlong, Long);
|
DEFINE_CALL_METHOD_FOR_PRIMITIVE_INTERFACE(jlong, Long);
|
||||||
DEFINE_CALL_METHOD_FOR_PRIMITIVE_INTERFACE(jfloat, Float);
|
DEFINE_CALL_METHOD_FOR_PRIMITIVE_INTERFACE(jfloat, Float);
|
||||||
|
|
||||||
ScopedLocalRef<jobject> callStaticObjectMethod(
|
ScopedLocalRef<jobject>
|
||||||
JNIEnv* env,
|
callStaticObjectMethod(JNIEnv* env, jclass clazz, jmethodID methodId, ...);
|
||||||
jclass clazz,
|
|
||||||
jmethodID methodId,
|
|
||||||
...);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a local or a global reference, this method creates a new global
|
* Given a local or a global reference, this method creates a new global
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "corefunctions.h"
|
#include "corefunctions.h"
|
||||||
#include "macros.h"
|
|
||||||
#include "YogaJniException.h"
|
#include "YogaJniException.h"
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
namespace facebook::yoga::vanillajni {
|
namespace facebook::yoga::vanillajni {
|
||||||
|
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
|
|
||||||
friend class Node;
|
friend class Node;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#include "./Node.h"
|
|
||||||
#include "./Layout.h"
|
|
||||||
#include "./Size.h"
|
|
||||||
#include "./Config.h"
|
#include "./Config.h"
|
||||||
|
#include "./Layout.h"
|
||||||
|
#include "./Node.h"
|
||||||
|
#include "./Size.h"
|
||||||
|
|
||||||
static YGSize globalMeasureFunc(
|
static YGSize globalMeasureFunc(
|
||||||
YGNodeConstRef nodeRef,
|
YGNodeConstRef nodeRef,
|
||||||
|
@@ -12,19 +12,16 @@
|
|||||||
#include <emscripten/bind.h>
|
#include <emscripten/bind.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
|
#include "./Config.h"
|
||||||
#include "./Layout.h"
|
#include "./Layout.h"
|
||||||
#include "./Size.h"
|
#include "./Size.h"
|
||||||
#include "./Value.h"
|
#include "./Value.h"
|
||||||
#include "./Config.h"
|
|
||||||
|
|
||||||
class MeasureCallback {
|
class MeasureCallback {
|
||||||
public:
|
public:
|
||||||
virtual ~MeasureCallback() {}
|
virtual ~MeasureCallback() {}
|
||||||
virtual Size measure(
|
virtual Size
|
||||||
float width,
|
measure(float width, int widthMode, float height, int heightMode) = 0;
|
||||||
int widthMode,
|
|
||||||
float height,
|
|
||||||
int heightMode) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MeasureCallbackWrapper : public emscripten::wrapper<MeasureCallback> {
|
class MeasureCallbackWrapper : public emscripten::wrapper<MeasureCallback> {
|
||||||
@@ -44,11 +41,12 @@ public:
|
|||||||
class DirtiedCallbackWrapper : public emscripten::wrapper<DirtiedCallback> {
|
class DirtiedCallbackWrapper : public emscripten::wrapper<DirtiedCallback> {
|
||||||
public:
|
public:
|
||||||
EMSCRIPTEN_WRAPPER(DirtiedCallbackWrapper);
|
EMSCRIPTEN_WRAPPER(DirtiedCallbackWrapper);
|
||||||
void dirtied() { return call<void>("dirtied"); }
|
void dirtied() {
|
||||||
|
return call<void>("dirtied");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Node {
|
class Node {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Node* createDefault(void);
|
static Node* createDefault(void);
|
||||||
static Node* createWithConfig(Config* config);
|
static Node* createWithConfig(Config* config);
|
||||||
|
@@ -5,14 +5,14 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "./Node.h"
|
#include "./Config.h"
|
||||||
#include "./Layout.h"
|
#include "./Layout.h"
|
||||||
|
#include "./Node.h"
|
||||||
#include "./Size.h"
|
#include "./Size.h"
|
||||||
#include "./Value.h"
|
#include "./Value.h"
|
||||||
#include "./Config.h"
|
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
#include <emscripten/bind.h>
|
#include <emscripten/bind.h>
|
||||||
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
using namespace emscripten;
|
using namespace emscripten;
|
||||||
|
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
#define YOGA_COMPACT_VALUE_TEST
|
#define YOGA_COMPACT_VALUE_TEST
|
||||||
|
|
||||||
#include <yoga/style/CompactValue.h>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#include <yoga/style/CompactValue.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
using facebook::yoga::CompactValue;
|
using facebook::yoga::CompactValue;
|
||||||
|
@@ -6,9 +6,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <yoga/event/event.h>
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/Yoga.h>
|
||||||
|
#include <yoga/event/event.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -50,7 +50,9 @@ class EventTest : public ::testing::Test {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static std::vector<EventArgs> events;
|
static std::vector<EventArgs> events;
|
||||||
static EventArgs& lastEvent() { return events.back(); }
|
static EventArgs& lastEvent() {
|
||||||
|
return events.back();
|
||||||
|
}
|
||||||
void TearDown() override;
|
void TearDown() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <yoga/YGValue.h>
|
||||||
#include <yoga/numeric/Comparison.h>
|
#include <yoga/numeric/Comparison.h>
|
||||||
#include <yoga/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
#include <yoga/YGValue.h>
|
|
||||||
|
|
||||||
using namespace facebook;
|
using namespace facebook;
|
||||||
using namespace facebook::yoga;
|
using namespace facebook::yoga;
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <yoga/bits/NumericBitfield.h>
|
#include <yoga/bits/NumericBitfield.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
@@ -8,10 +8,8 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
static float _baseline(
|
static float
|
||||||
YGNodeConstRef node,
|
_baseline(YGNodeConstRef node, const float /*width*/, const float /*height*/) {
|
||||||
const float /*width*/,
|
|
||||||
const float /*height*/) {
|
|
||||||
float* baseline = (float*)YGNodeGetContext(node);
|
float* baseline = (float*)YGNodeGetContext(node);
|
||||||
return *baseline;
|
return *baseline;
|
||||||
}
|
}
|
||||||
|
@@ -645,7 +645,6 @@ static YGSize _measure_90_10(
|
|||||||
YGMeasureMode /*widthMode*/,
|
YGMeasureMode /*widthMode*/,
|
||||||
float /*height*/,
|
float /*height*/,
|
||||||
YGMeasureMode /*heightMode*/) {
|
YGMeasureMode /*heightMode*/) {
|
||||||
|
|
||||||
return YGSize{90, 10};
|
return YGSize{90, 10};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,7 +654,6 @@ static YGSize _measure_100_100(
|
|||||||
YGMeasureMode /*widthMode*/,
|
YGMeasureMode /*widthMode*/,
|
||||||
float /*height*/,
|
float /*height*/,
|
||||||
YGMeasureMode /*heightMode*/) {
|
YGMeasureMode /*heightMode*/) {
|
||||||
|
|
||||||
return YGSize{100, 100};
|
return YGSize{100, 100};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
#include <yoga/Yoga-internal.h>
|
#include <yoga/Yoga-internal.h>
|
||||||
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
TEST(YogaTest, rounding_value) {
|
TEST(YogaTest, rounding_value) {
|
||||||
// Test that whole numbers are rounded to whole despite ceil/floor flags
|
// Test that whole numbers are rounded to whole despite ceil/floor flags
|
||||||
|
@@ -5,11 +5,11 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
#include <yoga/style/Style.h>
|
#include <yoga/style/Style.h>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#define ACCESSOR_TESTS_1(NAME, X) \
|
#define ACCESSOR_TESTS_1(NAME, X) \
|
||||||
style.NAME() = X; \
|
style.NAME() = X; \
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
#include "TestUtil.h"
|
#include "TestUtil.h"
|
||||||
|
|
||||||
#include <yoga/node/Node.h>
|
|
||||||
#include <yoga/event/event.h>
|
#include <yoga/event/event.h>
|
||||||
|
#include <yoga/node/Node.h>
|
||||||
|
|
||||||
namespace facebook::yoga::test {
|
namespace facebook::yoga::test {
|
||||||
|
|
||||||
@@ -20,7 +20,6 @@ void yogaEventSubscriber(
|
|||||||
YGNodeConstRef /*node*/,
|
YGNodeConstRef /*node*/,
|
||||||
Event::Type eventType,
|
Event::Type eventType,
|
||||||
const Event::Data& /*eventData*/) {
|
const Event::Data& /*eventData*/) {
|
||||||
|
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
case Event::NodeAllocation:
|
case Event::NodeAllocation:
|
||||||
nodeInstanceCount++;
|
nodeInstanceCount++;
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
#include <yoga/Yoga-internal.h>
|
#include <yoga/Yoga-internal.h>
|
||||||
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#include <yoga/algorithm/Cache.h>
|
#include <yoga/algorithm/Cache.h>
|
||||||
#include <yoga/algorithm/CalculateLayout.h>
|
#include <yoga/algorithm/CalculateLayout.h>
|
||||||
|
42
yoga/Yoga.h
42
yoga/Yoga.h
@@ -71,10 +71,8 @@ YG_EXPORT YGNodeRef YGNodeGetChild(YGNodeRef node, size_t index);
|
|||||||
YG_EXPORT YGNodeRef YGNodeGetOwner(YGNodeRef node);
|
YG_EXPORT YGNodeRef YGNodeGetOwner(YGNodeRef node);
|
||||||
YG_EXPORT YGNodeRef YGNodeGetParent(YGNodeRef node);
|
YG_EXPORT YGNodeRef YGNodeGetParent(YGNodeRef node);
|
||||||
YG_EXPORT size_t YGNodeGetChildCount(YGNodeConstRef node);
|
YG_EXPORT size_t YGNodeGetChildCount(YGNodeConstRef node);
|
||||||
YG_EXPORT void YGNodeSetChildren(
|
YG_EXPORT void
|
||||||
YGNodeRef owner,
|
YGNodeSetChildren(YGNodeRef owner, const YGNodeRef* children, size_t count);
|
||||||
const YGNodeRef* children,
|
|
||||||
size_t count);
|
|
||||||
|
|
||||||
YG_EXPORT void YGNodeSetIsReferenceBaseline(
|
YG_EXPORT void YGNodeSetIsReferenceBaseline(
|
||||||
YGNodeRef node,
|
YGNodeRef node,
|
||||||
@@ -197,41 +195,29 @@ YG_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis);
|
|||||||
YG_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node);
|
YG_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node);
|
YG_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetPosition(
|
YG_EXPORT void
|
||||||
YGNodeRef node,
|
YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float position);
|
||||||
YGEdge edge,
|
YG_EXPORT void
|
||||||
float position);
|
YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float position);
|
||||||
YG_EXPORT void YGNodeStyleSetPositionPercent(
|
|
||||||
YGNodeRef node,
|
|
||||||
YGEdge edge,
|
|
||||||
float position);
|
|
||||||
YG_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge);
|
YG_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin);
|
YG_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin);
|
||||||
YG_EXPORT void YGNodeStyleSetMarginPercent(
|
YG_EXPORT void
|
||||||
YGNodeRef node,
|
YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float margin);
|
||||||
YGEdge edge,
|
|
||||||
float margin);
|
|
||||||
YG_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge);
|
YG_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge);
|
YG_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetPadding(
|
YG_EXPORT void
|
||||||
YGNodeRef node,
|
YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float padding);
|
||||||
YGEdge edge,
|
YG_EXPORT void
|
||||||
float padding);
|
YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float padding);
|
||||||
YG_EXPORT void YGNodeStyleSetPaddingPercent(
|
|
||||||
YGNodeRef node,
|
|
||||||
YGEdge edge,
|
|
||||||
float padding);
|
|
||||||
YG_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge);
|
YG_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border);
|
YG_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border);
|
||||||
YG_EXPORT float YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge);
|
YG_EXPORT float YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetGap(
|
YG_EXPORT void
|
||||||
YGNodeRef node,
|
YGNodeStyleSetGap(YGNodeRef node, YGGutter gutter, float gapLength);
|
||||||
YGGutter gutter,
|
|
||||||
float gapLength);
|
|
||||||
YG_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
|
YG_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width);
|
YG_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width);
|
||||||
|
@@ -16,7 +16,6 @@ namespace facebook::yoga {
|
|||||||
|
|
||||||
float calculateBaseline(const yoga::Node* node) {
|
float calculateBaseline(const yoga::Node* node) {
|
||||||
if (node->hasBaselineFunc()) {
|
if (node->hasBaselineFunc()) {
|
||||||
|
|
||||||
Event::publish<Event::NodeBaselineStart>(node);
|
Event::publish<Event::NodeBaselineStart>(node);
|
||||||
|
|
||||||
const float baseline = node->baseline(
|
const float baseline = node->baseline(
|
||||||
|
@@ -2603,7 +2603,6 @@ bool calculateLayoutInternal(
|
|||||||
layout->lastOwnerDirection = ownerDirection;
|
layout->lastOwnerDirection = ownerDirection;
|
||||||
|
|
||||||
if (cachedResults == nullptr) {
|
if (cachedResults == nullptr) {
|
||||||
|
|
||||||
layoutMarkerData.maxMeasureCache = std::max(
|
layoutMarkerData.maxMeasureCache = std::max(
|
||||||
layoutMarkerData.maxMeasureCache,
|
layoutMarkerData.maxMeasureCache,
|
||||||
layout->nextCachedMeasurementsIndex + 1u);
|
layout->nextCachedMeasurementsIndex + 1u);
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <bitset>
|
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
@@ -8,8 +8,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h>
|
||||||
|
|
||||||
|
@@ -69,10 +69,8 @@ public:
|
|||||||
va_list args) const;
|
va_list args) const;
|
||||||
|
|
||||||
void setCloneNodeCallback(YGCloneNodeFunc cloneNode);
|
void setCloneNodeCallback(YGCloneNodeFunc cloneNode);
|
||||||
YGNodeRef cloneNode(
|
YGNodeRef
|
||||||
YGNodeConstRef node,
|
cloneNode(YGNodeConstRef node, YGNodeConstRef owner, size_t childIndex) const;
|
||||||
YGNodeConstRef owner,
|
|
||||||
size_t childIndex) const;
|
|
||||||
|
|
||||||
static const Config& getDefault();
|
static const Config& getDefault();
|
||||||
|
|
||||||
|
@@ -8,8 +8,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
#include <yoga/node/Node.h>
|
|
||||||
#include <yoga/config/Config.h>
|
#include <yoga/config/Config.h>
|
||||||
|
#include <yoga/node/Node.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h>
|
||||||
#include <yoga/node/Node.h>
|
|
||||||
#include <yoga/config/Config.h>
|
#include <yoga/config/Config.h>
|
||||||
|
#include <yoga/node/Node.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
@@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <array>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include <yoga/bits/NumericBitfield.h>
|
#include <yoga/bits/NumericBitfield.h>
|
||||||
#include <yoga/numeric/FloatOptional.h>
|
|
||||||
#include <yoga/node/CachedMeasurement.h>
|
#include <yoga/node/CachedMeasurement.h>
|
||||||
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
@@ -60,11 +60,17 @@ public:
|
|||||||
flags_.direction = static_cast<uint32_t>(direction) & 0x03;
|
flags_.direction = static_cast<uint32_t>(direction) & 0x03;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hadOverflow() const { return flags_.hadOverflow; }
|
bool hadOverflow() const {
|
||||||
void setHadOverflow(bool hadOverflow) { flags_.hadOverflow = hadOverflow; }
|
return flags_.hadOverflow;
|
||||||
|
}
|
||||||
|
void setHadOverflow(bool hadOverflow) {
|
||||||
|
flags_.hadOverflow = hadOverflow;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(LayoutResults layout) const;
|
bool operator==(LayoutResults layout) const;
|
||||||
bool operator!=(LayoutResults layout) const { return !(*this == layout); }
|
bool operator!=(LayoutResults layout) const {
|
||||||
|
return !(*this == layout);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
110
yoga/node/Node.h
110
yoga/node/Node.h
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <cstdint>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
@@ -82,60 +82,98 @@ public:
|
|||||||
Node& operator=(const Node&) = delete;
|
Node& operator=(const Node&) = delete;
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
void* getContext() const { return context_; }
|
void* getContext() const {
|
||||||
|
return context_;
|
||||||
|
}
|
||||||
|
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
bool getHasNewLayout() const { return flags_.hasNewLayout; }
|
bool getHasNewLayout() const {
|
||||||
|
return flags_.hasNewLayout;
|
||||||
|
}
|
||||||
|
|
||||||
YGNodeType getNodeType() const {
|
YGNodeType getNodeType() const {
|
||||||
return static_cast<YGNodeType>(flags_.nodeType);
|
return static_cast<YGNodeType>(flags_.nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasMeasureFunc() const noexcept { return measureFunc_ != nullptr; }
|
bool hasMeasureFunc() const noexcept {
|
||||||
|
return measureFunc_ != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
YGSize measure(float, YGMeasureMode, float, YGMeasureMode);
|
YGSize measure(float, YGMeasureMode, float, YGMeasureMode);
|
||||||
|
|
||||||
bool hasBaselineFunc() const noexcept { return baselineFunc_ != nullptr; }
|
bool hasBaselineFunc() const noexcept {
|
||||||
|
return baselineFunc_ != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
float baseline(float width, float height) const;
|
float baseline(float width, float height) const;
|
||||||
|
|
||||||
bool hasErrata(YGErrata errata) const { return config_->hasErrata(errata); }
|
bool hasErrata(YGErrata errata) const {
|
||||||
|
return config_->hasErrata(errata);
|
||||||
|
}
|
||||||
|
|
||||||
YGDirtiedFunc getDirtiedFunc() const { return dirtiedFunc_; }
|
YGDirtiedFunc getDirtiedFunc() const {
|
||||||
|
return dirtiedFunc_;
|
||||||
|
}
|
||||||
|
|
||||||
// For Performance reasons passing as reference.
|
// For Performance reasons passing as reference.
|
||||||
Style& getStyle() { return style_; }
|
Style& getStyle() {
|
||||||
|
return style_;
|
||||||
|
}
|
||||||
|
|
||||||
const Style& getStyle() const { return style_; }
|
const Style& getStyle() const {
|
||||||
|
return style_;
|
||||||
|
}
|
||||||
|
|
||||||
// For Performance reasons passing as reference.
|
// For Performance reasons passing as reference.
|
||||||
LayoutResults& getLayout() { return layout_; }
|
LayoutResults& getLayout() {
|
||||||
|
return layout_;
|
||||||
|
}
|
||||||
|
|
||||||
const LayoutResults& getLayout() const { return layout_; }
|
const LayoutResults& getLayout() const {
|
||||||
|
return layout_;
|
||||||
|
}
|
||||||
|
|
||||||
size_t getLineIndex() const { return lineIndex_; }
|
size_t getLineIndex() const {
|
||||||
|
return lineIndex_;
|
||||||
|
}
|
||||||
|
|
||||||
bool isReferenceBaseline() const { return flags_.isReferenceBaseline; }
|
bool isReferenceBaseline() const {
|
||||||
|
return flags_.isReferenceBaseline;
|
||||||
|
}
|
||||||
|
|
||||||
// returns the Node that owns this Node. An owner is used to identify
|
// returns the Node that owns this Node. An owner is used to identify
|
||||||
// the YogaTree that a Node belongs to. This method will return the parent
|
// the YogaTree that a Node belongs to. This method will return the parent
|
||||||
// of the Node when a Node only belongs to one YogaTree or nullptr when
|
// of the Node when a Node only belongs to one YogaTree or nullptr when
|
||||||
// the Node is shared between two or more YogaTrees.
|
// the Node is shared between two or more YogaTrees.
|
||||||
Node* getOwner() const { return owner_; }
|
Node* getOwner() const {
|
||||||
|
return owner_;
|
||||||
|
}
|
||||||
|
|
||||||
// Deprecated, use getOwner() instead.
|
// Deprecated, use getOwner() instead.
|
||||||
Node* getParent() const { return getOwner(); }
|
Node* getParent() const {
|
||||||
|
return getOwner();
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<Node*>& getChildren() const { return children_; }
|
const std::vector<Node*>& getChildren() const {
|
||||||
|
return children_;
|
||||||
|
}
|
||||||
|
|
||||||
Node* getChild(size_t index) const { return children_.at(index); }
|
Node* getChild(size_t index) const {
|
||||||
|
return children_.at(index);
|
||||||
|
}
|
||||||
|
|
||||||
size_t getChildCount() const { return children_.size(); }
|
size_t getChildCount() const {
|
||||||
|
return children_.size();
|
||||||
|
}
|
||||||
|
|
||||||
const Config* getConfig() const { return config_; }
|
const Config* getConfig() const {
|
||||||
|
return config_;
|
||||||
|
}
|
||||||
|
|
||||||
bool isDirty() const { return flags_.isDirty; }
|
bool isDirty() const {
|
||||||
|
return flags_.isDirty;
|
||||||
|
}
|
||||||
|
|
||||||
std::array<YGValue, 2> getResolvedDimensions() const {
|
std::array<YGValue, 2> getResolvedDimensions() const {
|
||||||
return resolvedDimensions_;
|
return resolvedDimensions_;
|
||||||
@@ -200,9 +238,13 @@ public:
|
|||||||
const;
|
const;
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
void setContext(void* context) { context_ = context; }
|
void setContext(void* context) {
|
||||||
|
context_ = context;
|
||||||
|
}
|
||||||
|
|
||||||
void setPrintFunc(YGPrintFunc printFunc) { printFunc_ = printFunc; }
|
void setPrintFunc(YGPrintFunc printFunc) {
|
||||||
|
printFunc_ = printFunc;
|
||||||
|
}
|
||||||
|
|
||||||
void setHasNewLayout(bool hasNewLayout) {
|
void setHasNewLayout(bool hasNewLayout) {
|
||||||
flags_.hasNewLayout = hasNewLayout;
|
flags_.hasNewLayout = hasNewLayout;
|
||||||
@@ -218,21 +260,33 @@ public:
|
|||||||
baselineFunc_ = baseLineFunc;
|
baselineFunc_ = baseLineFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) { dirtiedFunc_ = dirtiedFunc; }
|
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
|
||||||
|
dirtiedFunc_ = dirtiedFunc;
|
||||||
|
}
|
||||||
|
|
||||||
void setStyle(const Style& style) { style_ = style; }
|
void setStyle(const Style& style) {
|
||||||
|
style_ = style;
|
||||||
|
}
|
||||||
|
|
||||||
void setLayout(const LayoutResults& layout) { layout_ = layout; }
|
void setLayout(const LayoutResults& layout) {
|
||||||
|
layout_ = layout;
|
||||||
|
}
|
||||||
|
|
||||||
void setLineIndex(size_t lineIndex) { lineIndex_ = lineIndex; }
|
void setLineIndex(size_t lineIndex) {
|
||||||
|
lineIndex_ = lineIndex;
|
||||||
|
}
|
||||||
|
|
||||||
void setIsReferenceBaseline(bool isReferenceBaseline) {
|
void setIsReferenceBaseline(bool isReferenceBaseline) {
|
||||||
flags_.isReferenceBaseline = isReferenceBaseline;
|
flags_.isReferenceBaseline = isReferenceBaseline;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOwner(Node* owner) { owner_ = owner; }
|
void setOwner(Node* owner) {
|
||||||
|
owner_ = owner;
|
||||||
|
}
|
||||||
|
|
||||||
void setChildren(const std::vector<Node*>& children) { children_ = children; }
|
void setChildren(const std::vector<Node*>& children) {
|
||||||
|
children_ = children;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: rvalue override for setChildren
|
// TODO: rvalue override for setChildren
|
||||||
|
|
||||||
|
@@ -21,9 +21,13 @@ public:
|
|||||||
constexpr FloatOptional() = default;
|
constexpr FloatOptional() = default;
|
||||||
|
|
||||||
// returns the wrapped value, or a value x with YGIsUndefined(x) == true
|
// returns the wrapped value, or a value x with YGIsUndefined(x) == true
|
||||||
constexpr float unwrap() const { return value_; }
|
constexpr float unwrap() const {
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
|
||||||
bool isUndefined() const { return std::isnan(value_); }
|
bool isUndefined() const {
|
||||||
|
return std::isnan(value_);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// operators take FloatOptional by value, as it is a 32bit value
|
// operators take FloatOptional by value, as it is a 32bit value
|
||||||
|
@@ -136,7 +136,9 @@ public:
|
|||||||
repr_ != ZERO_BITS_PERCENT && std::isnan(yoga::bit_cast<float>(repr_)));
|
repr_ != ZERO_BITS_PERCENT && std::isnan(yoga::bit_cast<float>(repr_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAuto() const noexcept { return repr_ == AUTO_BITS; }
|
bool isAuto() const noexcept {
|
||||||
|
return repr_ == AUTO_BITS;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t repr_;
|
uint32_t repr_;
|
||||||
@@ -152,7 +154,9 @@ private:
|
|||||||
|
|
||||||
constexpr CompactValue(uint32_t data) noexcept : repr_(data) {}
|
constexpr CompactValue(uint32_t data) noexcept : repr_(data) {}
|
||||||
|
|
||||||
VISIBLE_FOR_TESTING uint32_t repr() { return repr_; }
|
VISIBLE_FOR_TESTING uint32_t repr() {
|
||||||
|
return repr_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <yoga/style/Style.h>
|
|
||||||
#include <yoga/numeric/Comparison.h>
|
#include <yoga/numeric/Comparison.h>
|
||||||
|
#include <yoga/style/Style.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
@@ -37,7 +37,9 @@ public:
|
|||||||
struct BitfieldRef {
|
struct BitfieldRef {
|
||||||
Style& style;
|
Style& style;
|
||||||
uint8_t offset;
|
uint8_t offset;
|
||||||
operator T() const { return getEnumData<T>(style.flags, offset); }
|
operator T() const {
|
||||||
|
return getEnumData<T>(style.flags, offset);
|
||||||
|
}
|
||||||
BitfieldRef<T>& operator=(T x) {
|
BitfieldRef<T>& operator=(T x) {
|
||||||
setEnumData<T>(style.flags, offset, x);
|
setEnumData<T>(style.flags, offset, x);
|
||||||
return *this;
|
return *this;
|
||||||
@@ -47,7 +49,9 @@ public:
|
|||||||
template <typename T, T Style::*Prop>
|
template <typename T, T Style::*Prop>
|
||||||
struct Ref {
|
struct Ref {
|
||||||
Style& style;
|
Style& style;
|
||||||
operator T() const { return style.*Prop; }
|
operator T() const {
|
||||||
|
return style.*Prop;
|
||||||
|
}
|
||||||
Ref<T, Prop>& operator=(T value) {
|
Ref<T, Prop>& operator=(T value) {
|
||||||
style.*Prop = value;
|
style.*Prop = value;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -59,8 +63,12 @@ public:
|
|||||||
struct Ref {
|
struct Ref {
|
||||||
Style& style;
|
Style& style;
|
||||||
Idx idx;
|
Idx idx;
|
||||||
operator CompactValue() const { return (style.*Prop)[idx]; }
|
operator CompactValue() const {
|
||||||
operator YGValue() const { return (style.*Prop)[idx]; }
|
return (style.*Prop)[idx];
|
||||||
|
}
|
||||||
|
operator YGValue() const {
|
||||||
|
return (style.*Prop)[idx];
|
||||||
|
}
|
||||||
Ref& operator=(CompactValue value) {
|
Ref& operator=(CompactValue value) {
|
||||||
(style.*Prop)[idx] = value;
|
(style.*Prop)[idx] = value;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -72,9 +80,15 @@ public:
|
|||||||
style.*Prop = values;
|
style.*Prop = values;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
operator const Values<Idx>&() const { return style.*Prop; }
|
operator const Values<Idx>&() const {
|
||||||
Ref operator[](Idx idx) { return {style, idx}; }
|
return style.*Prop;
|
||||||
CompactValue operator[](Idx idx) const { return (style.*Prop)[idx]; }
|
}
|
||||||
|
Ref operator[](Idx idx) {
|
||||||
|
return {style, idx};
|
||||||
|
}
|
||||||
|
CompactValue operator[](Idx idx) const {
|
||||||
|
return (style.*Prop)[idx];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Style() {
|
Style() {
|
||||||
@@ -128,7 +142,9 @@ public:
|
|||||||
YGDirection direction() const {
|
YGDirection direction() const {
|
||||||
return getEnumData<YGDirection>(flags, directionOffset);
|
return getEnumData<YGDirection>(flags, directionOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGDirection> direction() { return {*this, directionOffset}; }
|
BitfieldRef<YGDirection> direction() {
|
||||||
|
return {*this, directionOffset};
|
||||||
|
}
|
||||||
|
|
||||||
YGFlexDirection flexDirection() const {
|
YGFlexDirection flexDirection() const {
|
||||||
return getEnumData<YGFlexDirection>(flags, flexdirectionOffset);
|
return getEnumData<YGFlexDirection>(flags, flexdirectionOffset);
|
||||||
@@ -147,17 +163,23 @@ public:
|
|||||||
YGAlign alignContent() const {
|
YGAlign alignContent() const {
|
||||||
return getEnumData<YGAlign>(flags, alignContentOffset);
|
return getEnumData<YGAlign>(flags, alignContentOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGAlign> alignContent() { return {*this, alignContentOffset}; }
|
BitfieldRef<YGAlign> alignContent() {
|
||||||
|
return {*this, alignContentOffset};
|
||||||
|
}
|
||||||
|
|
||||||
YGAlign alignItems() const {
|
YGAlign alignItems() const {
|
||||||
return getEnumData<YGAlign>(flags, alignItemsOffset);
|
return getEnumData<YGAlign>(flags, alignItemsOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGAlign> alignItems() { return {*this, alignItemsOffset}; }
|
BitfieldRef<YGAlign> alignItems() {
|
||||||
|
return {*this, alignItemsOffset};
|
||||||
|
}
|
||||||
|
|
||||||
YGAlign alignSelf() const {
|
YGAlign alignSelf() const {
|
||||||
return getEnumData<YGAlign>(flags, alignSelfOffset);
|
return getEnumData<YGAlign>(flags, alignSelfOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGAlign> alignSelf() { return {*this, alignSelfOffset}; }
|
BitfieldRef<YGAlign> alignSelf() {
|
||||||
|
return {*this, alignSelfOffset};
|
||||||
|
}
|
||||||
|
|
||||||
YGPositionType positionType() const {
|
YGPositionType positionType() const {
|
||||||
return getEnumData<YGPositionType>(flags, positionTypeOffset);
|
return getEnumData<YGPositionType>(flags, positionTypeOffset);
|
||||||
@@ -166,62 +188,118 @@ public:
|
|||||||
return {*this, positionTypeOffset};
|
return {*this, positionTypeOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
YGWrap flexWrap() const { return getEnumData<YGWrap>(flags, flexWrapOffset); }
|
YGWrap flexWrap() const {
|
||||||
BitfieldRef<YGWrap> flexWrap() { return {*this, flexWrapOffset}; }
|
return getEnumData<YGWrap>(flags, flexWrapOffset);
|
||||||
|
}
|
||||||
|
BitfieldRef<YGWrap> flexWrap() {
|
||||||
|
return {*this, flexWrapOffset};
|
||||||
|
}
|
||||||
|
|
||||||
YGOverflow overflow() const {
|
YGOverflow overflow() const {
|
||||||
return getEnumData<YGOverflow>(flags, overflowOffset);
|
return getEnumData<YGOverflow>(flags, overflowOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGOverflow> overflow() { return {*this, overflowOffset}; }
|
BitfieldRef<YGOverflow> overflow() {
|
||||||
|
return {*this, overflowOffset};
|
||||||
|
}
|
||||||
|
|
||||||
YGDisplay display() const {
|
YGDisplay display() const {
|
||||||
return getEnumData<YGDisplay>(flags, displayOffset);
|
return getEnumData<YGDisplay>(flags, displayOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGDisplay> display() { return {*this, displayOffset}; }
|
BitfieldRef<YGDisplay> display() {
|
||||||
|
return {*this, displayOffset};
|
||||||
|
}
|
||||||
|
|
||||||
FloatOptional flex() const { return flex_; }
|
FloatOptional flex() const {
|
||||||
Ref<FloatOptional, &Style::flex_> flex() { return {*this}; }
|
return flex_;
|
||||||
|
}
|
||||||
|
Ref<FloatOptional, &Style::flex_> flex() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
FloatOptional flexGrow() const { return flexGrow_; }
|
FloatOptional flexGrow() const {
|
||||||
Ref<FloatOptional, &Style::flexGrow_> flexGrow() { return {*this}; }
|
return flexGrow_;
|
||||||
|
}
|
||||||
|
Ref<FloatOptional, &Style::flexGrow_> flexGrow() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
FloatOptional flexShrink() const { return flexShrink_; }
|
FloatOptional flexShrink() const {
|
||||||
Ref<FloatOptional, &Style::flexShrink_> flexShrink() { return {*this}; }
|
return flexShrink_;
|
||||||
|
}
|
||||||
|
Ref<FloatOptional, &Style::flexShrink_> flexShrink() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
CompactValue flexBasis() const { return flexBasis_; }
|
CompactValue flexBasis() const {
|
||||||
Ref<CompactValue, &Style::flexBasis_> flexBasis() { return {*this}; }
|
return flexBasis_;
|
||||||
|
}
|
||||||
|
Ref<CompactValue, &Style::flexBasis_> flexBasis() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
const Edges& margin() const { return margin_; }
|
const Edges& margin() const {
|
||||||
IdxRef<YGEdge, &Style::margin_> margin() { return {*this}; }
|
return margin_;
|
||||||
|
}
|
||||||
|
IdxRef<YGEdge, &Style::margin_> margin() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
const Edges& position() const { return position_; }
|
const Edges& position() const {
|
||||||
IdxRef<YGEdge, &Style::position_> position() { return {*this}; }
|
return position_;
|
||||||
|
}
|
||||||
|
IdxRef<YGEdge, &Style::position_> position() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
const Edges& padding() const { return padding_; }
|
const Edges& padding() const {
|
||||||
IdxRef<YGEdge, &Style::padding_> padding() { return {*this}; }
|
return padding_;
|
||||||
|
}
|
||||||
|
IdxRef<YGEdge, &Style::padding_> padding() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
const Edges& border() const { return border_; }
|
const Edges& border() const {
|
||||||
IdxRef<YGEdge, &Style::border_> border() { return {*this}; }
|
return border_;
|
||||||
|
}
|
||||||
|
IdxRef<YGEdge, &Style::border_> border() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
const Gutters& gap() const { return gap_; }
|
const Gutters& gap() const {
|
||||||
IdxRef<YGGutter, &Style::gap_> gap() { return {*this}; }
|
return gap_;
|
||||||
|
}
|
||||||
|
IdxRef<YGGutter, &Style::gap_> gap() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
const Dimensions& dimensions() const { return dimensions_; }
|
const Dimensions& dimensions() const {
|
||||||
IdxRef<YGDimension, &Style::dimensions_> dimensions() { return {*this}; }
|
return dimensions_;
|
||||||
|
}
|
||||||
|
IdxRef<YGDimension, &Style::dimensions_> dimensions() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
|
|
||||||
const Dimensions& minDimensions() const { return minDimensions_; }
|
const Dimensions& minDimensions() const {
|
||||||
|
return minDimensions_;
|
||||||
|
}
|
||||||
IdxRef<YGDimension, &Style::minDimensions_> minDimensions() {
|
IdxRef<YGDimension, &Style::minDimensions_> minDimensions() {
|
||||||
return {*this};
|
return {*this};
|
||||||
}
|
}
|
||||||
|
|
||||||
const Dimensions& maxDimensions() const { return maxDimensions_; }
|
const Dimensions& maxDimensions() const {
|
||||||
|
return maxDimensions_;
|
||||||
|
}
|
||||||
IdxRef<YGDimension, &Style::maxDimensions_> maxDimensions() {
|
IdxRef<YGDimension, &Style::maxDimensions_> maxDimensions() {
|
||||||
return {*this};
|
return {*this};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
FloatOptional aspectRatio() const { return aspectRatio_; }
|
FloatOptional aspectRatio() const {
|
||||||
Ref<FloatOptional, &Style::aspectRatio_> aspectRatio() { return {*this}; }
|
return aspectRatio_;
|
||||||
|
}
|
||||||
|
Ref<FloatOptional, &Style::aspectRatio_> aspectRatio() {
|
||||||
|
return {*this};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
YG_EXPORT bool operator==(const Style& lhs, const Style& rhs);
|
YG_EXPORT bool operator==(const Style& lhs, const Style& rhs);
|
||||||
|
Reference in New Issue
Block a user