Pass reason for measure pass along with measurecallbackend event (#566)
Summary: Pull Request resolved: https://github.com/facebook/litho/pull/566 Pull Request resolved: https://github.com/facebook/react-native/pull/25702 Pass reason for each measure callback to the flipper plugin Reviewed By: davidaurelio Differential Revision: D16221771 fbshipit-source-id: 2e72e1ebb3c7e633d189e7a7a81d655ac9531e51
This commit is contained in:
committed by
Facebook Github Bot
parent
5e40e4b682
commit
e6dfe04388
@@ -9,7 +9,7 @@ cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
||||
file(GLOB yogacore_SRC yoga/*.cpp)
|
||||
file(GLOB_RECURSE yogacore_SRC yoga/*.cpp)
|
||||
add_library(yogacore STATIC ${yogacore_SRC})
|
||||
|
||||
target_link_libraries(yogacore android log)
|
||||
|
40
java/com/facebook/yoga/LayoutPassReason.java
Normal file
40
java/com/facebook/yoga/LayoutPassReason.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
package com.facebook.yoga;
|
||||
|
||||
public enum LayoutPassReason {
|
||||
INITIAL(0),
|
||||
MEASURE(1),
|
||||
ABS_MEASURE(2),
|
||||
FLEX(3),
|
||||
ABS_LAYOUT(4),
|
||||
STRETCH(5),
|
||||
MULTILINE_STRETCH(6);
|
||||
|
||||
private final int mIntValue;
|
||||
|
||||
LayoutPassReason(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static LayoutPassReason fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return INITIAL;
|
||||
case 1: return MEASURE;
|
||||
case 2: return ABS_MEASURE;
|
||||
case 3: return FLEX;
|
||||
case 4: return ABS_LAYOUT;
|
||||
case 5: return STRETCH;
|
||||
case 6: return MULTILINE_STRETCH;
|
||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -938,7 +938,7 @@ bool YGLayoutNodeInternal(
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
const bool performLayout,
|
||||
const char* reason,
|
||||
const LayoutPassReason reason,
|
||||
const YGConfigRef config,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
@@ -1364,7 +1364,7 @@ static void YGNodeComputeFlexBasisForChild(
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
false,
|
||||
"measure",
|
||||
kMeasureChild,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
@@ -1492,7 +1492,7 @@ static void YGNodeAbsoluteLayoutChild(
|
||||
childWidth,
|
||||
childHeight,
|
||||
false,
|
||||
"abs-measure",
|
||||
kAbsMeasureChild,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
@@ -1514,7 +1514,7 @@ static void YGNodeAbsoluteLayoutChild(
|
||||
childWidth,
|
||||
childHeight,
|
||||
true,
|
||||
"abs-layout",
|
||||
kAbsLayout,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
@@ -1588,7 +1588,8 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
void* const layoutContext,
|
||||
const LayoutPassReason reason) {
|
||||
YGAssertWithNode(
|
||||
node,
|
||||
node->hasMeasureFunc(),
|
||||
@@ -1652,7 +1653,8 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||
innerHeight,
|
||||
heightMeasureMode,
|
||||
measuredSize.width,
|
||||
measuredSize.height});
|
||||
measuredSize.height,
|
||||
reason});
|
||||
|
||||
node->setLayoutMeasuredDimension(
|
||||
YGNodeBoundAxis(
|
||||
@@ -2185,7 +2187,7 @@ static float YGDistributeFreeSpaceSecondPass(
|
||||
availableInnerWidth,
|
||||
availableInnerHeight,
|
||||
performLayout && !requiresStretchLayout,
|
||||
"flex",
|
||||
kFlex,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
@@ -2653,7 +2655,8 @@ static void YGNodelayoutImpl(
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
const uint32_t generationCount,
|
||||
const LayoutPassReason reason) {
|
||||
YGAssertWithNode(
|
||||
node,
|
||||
YGFloatIsUndefined(availableWidth)
|
||||
@@ -2722,7 +2725,8 @@ static void YGNodelayoutImpl(
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
reason);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3117,7 +3121,7 @@ static void YGNodelayoutImpl(
|
||||
availableInnerWidth,
|
||||
availableInnerHeight,
|
||||
true,
|
||||
"stretch",
|
||||
kStretch,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
@@ -3327,7 +3331,7 @@ static void YGNodelayoutImpl(
|
||||
availableInnerWidth,
|
||||
availableInnerHeight,
|
||||
true,
|
||||
"multiline-stretch",
|
||||
kMultilineStretch,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
@@ -3704,7 +3708,7 @@ bool YGLayoutNodeInternal(
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
const bool performLayout,
|
||||
const char* reason,
|
||||
const LayoutPassReason reason,
|
||||
const YGConfigRef config,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
@@ -3831,7 +3835,7 @@ bool YGLayoutNodeInternal(
|
||||
availableHeight,
|
||||
cachedResults->computedWidth,
|
||||
cachedResults->computedHeight,
|
||||
reason);
|
||||
LayoutPassReason(reason));
|
||||
}
|
||||
} else {
|
||||
if (gPrintChanges) {
|
||||
@@ -3853,7 +3857,7 @@ bool YGLayoutNodeInternal(
|
||||
YGMeasureModeName(heightMeasureMode, performLayout),
|
||||
availableWidth,
|
||||
availableHeight,
|
||||
reason);
|
||||
LayoutPassToString(reason));
|
||||
}
|
||||
|
||||
YGNodelayoutImpl(
|
||||
@@ -3870,7 +3874,8 @@ bool YGLayoutNodeInternal(
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
generationCount,
|
||||
reason);
|
||||
|
||||
if (gPrintChanges) {
|
||||
Log::log(
|
||||
@@ -3891,7 +3896,7 @@ bool YGLayoutNodeInternal(
|
||||
YGMeasureModeName(heightMeasureMode, performLayout),
|
||||
layout->measuredDimensions[YGDimensionWidth],
|
||||
layout->measuredDimensions[YGDimensionHeight],
|
||||
reason);
|
||||
LayoutPassToString(reason));
|
||||
}
|
||||
|
||||
layout->lastOwnerDirection = ownerDirection;
|
||||
@@ -4121,7 +4126,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
true,
|
||||
"initial",
|
||||
kInitial,
|
||||
node->getConfig(),
|
||||
markerData,
|
||||
layoutContext,
|
||||
@@ -4171,7 +4176,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
true,
|
||||
"initial",
|
||||
kInitial,
|
||||
nodeWithoutLegacyFlag->getConfig(),
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
|
@@ -12,6 +12,27 @@
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
|
||||
const char* LayoutPassToString(const LayoutPassReason value) {
|
||||
switch (value) {
|
||||
case kInitial:
|
||||
return "initial";
|
||||
case kMeasureChild:
|
||||
return "measure";
|
||||
case kAbsMeasureChild:
|
||||
return "abs_measure";
|
||||
case kFlex:
|
||||
return "flex";
|
||||
case kAbsLayout:
|
||||
return "abs_layout";
|
||||
case kStretch:
|
||||
return "stretch";
|
||||
case kMultilineStretch:
|
||||
return "multiline_stretch";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct Node {
|
||||
|
@@ -32,6 +32,18 @@ struct LayoutData {
|
||||
int measureCallbacks;
|
||||
};
|
||||
|
||||
enum LayoutPassReason : int {
|
||||
kInitial = 0,
|
||||
kMeasureChild = 1,
|
||||
kAbsMeasureChild = 2,
|
||||
kFlex = 3,
|
||||
kAbsLayout = 4,
|
||||
kStretch = 5,
|
||||
kMultilineStretch = 6
|
||||
};
|
||||
|
||||
const char* LayoutPassToString(const LayoutPassReason value);
|
||||
|
||||
struct Event {
|
||||
enum Type {
|
||||
NodeAllocation,
|
||||
@@ -114,6 +126,7 @@ struct Event::TypedData<Event::MeasureCallbackEnd> {
|
||||
YGMeasureMode heightMeasureMode;
|
||||
float measuredWidth;
|
||||
float measuredHeight;
|
||||
const LayoutPassReason reason;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
Reference in New Issue
Block a user