Skip to content

Commit

Permalink
Deletes code related to deprecated layout inspector timeline feature
Browse files Browse the repository at this point in the history
Summary: Deletes code related to deprecated layout inspector timeline feature

Differential Revision: D55418203

fbshipit-source-id: e3447732c6e73a960f3052a0bda9017cda789dc8
  • Loading branch information
adityasharat authored and facebook-github-bot committed Mar 27, 2024
1 parent 01c5450 commit aa9b281
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 300 deletions.
52 changes: 0 additions & 52 deletions litho-core/src/main/java/com/facebook/litho/ComponentTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public class ComponentTree

private boolean mInAttach = false;

@Nullable private final ComponentTreeTimeMachine mTimeMachine;
@Nullable private final ComponentTreeDebugEventsSubscriber mDebugEventsSubscriber;

@GuardedBy("this")
Expand Down Expand Up @@ -414,11 +413,6 @@ protected ComponentTree(Builder builder) {
}
}

if (LithoDebugConfigurations.isTimelineEnabled) {
mTimeMachine = new DebugComponentTreeTimeMachine(this);
} else {
mTimeMachine = null;
}
if (ComponentsConfiguration.enableRefactorLithoLifecycleProvider) {
mLifecycleProvider = builder.mLifecycleProvider;
} else {
Expand Down Expand Up @@ -2382,7 +2376,6 @@ && isCompatibleSpec(layoutState, mWidthSpec, mHeightSpec)) {
if (localTreeState != null) {
final TreeState treeState = mTreeState;
if (treeState != null) { // we could have been released
saveRevision(rootComponent, treeState, treePropContainer, source, extraAttribution);
treeState.commitLayoutState(localTreeState);
treeState.bindEventAndTriggerHandlers(createdEventHandlers, scopedSpecComponentInfos);
}
Expand Down Expand Up @@ -2846,51 +2839,6 @@ private void onMoveToStateDestroy() {
}
}

/** This should only be used by Flipper. */
@Nullable
ComponentTreeTimeMachine getTimeMachine() {
return mTimeMachine;
}

private void saveRevision(
Component root,
TreeState treeState,
@Nullable TreePropContainer treePropContainer,
@RenderSource int source,
@Nullable String attribution) {
if (mTimeMachine != null) {
final TreeState frozenTreeState = new TreeState(treeState);
mTimeMachine.storeRevision(root, frozenTreeState, treePropContainer, source, attribution);
}
}

/**
* Similar to {@link ComponentTree#setRoot(Component)}. This method allows setting a new root with
* cached {@link TreePropContainer} and {@link StateHandler}.
*
* <p>It is used to enable time-travelling through external editors such as Flipper.
*/
@UiThread
protected synchronized void applyRevision(ComponentTreeTimeMachine.Revision revision) {
ThreadUtils.assertMainThread();

mTreeState = revision.getTreeState();
mRootTreePropContainer = revision.getTreePropContainer();

setRootAndSizeSpecInternal(
revision.getRoot(),
SIZE_UNINITIALIZED,
SIZE_UNINITIALIZED,
false /* isAsync */,
null /* output */,
RenderSource.RELOAD_PREVIOUS_STATE,
INVALID_LAYOUT_VERSION,
null,
null,
false,
true);
}

/**
* In this approach we are attempting to start the layout calculation using the Choreographer
* frame callbacks system.
Expand Down

This file was deleted.

23 changes: 7 additions & 16 deletions litho-core/src/main/java/com/facebook/litho/DebugComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ private constructor(
private val y: Int,
private val xOffset: Int,
private val yOffset: Int,
val componentTreeTimeMachine: ComponentTreeTimeMachine?,
) {

interface Overrider {
Expand Down Expand Up @@ -160,7 +159,7 @@ private constructor(
result.getYForChildAtIndex(0),
xFromRoot,
yFromRoot,
null)
)
listOfNotNull(component)
}
else -> getChildren(result, xFromRoot, yFromRoot)
Expand All @@ -173,7 +172,7 @@ private constructor(
if (index < 0) {
return emptyList()
}
val component = getInstance(result, index, x, y, xOffset, yOffset, null)
val component = getInstance(result, index, x, y, xOffset, yOffset)
return listOfNotNull(component)
}

Expand Down Expand Up @@ -346,7 +345,6 @@ private constructor(
y: Int,
xOffset: Int,
yOffset: Int,
timeMachine: ComponentTreeTimeMachine?,
): DebugComponent? {
val node = result.node
val context = result.context
Expand All @@ -355,7 +353,6 @@ private constructor(
}
val componentKey = node.getGlobalKeyAt(componentIndex)
return DebugComponent(
componentTreeTimeMachine = timeMachine,
globalKey = generateGlobalKey(context, componentKey),
result = result,
node = result.node,
Expand All @@ -370,18 +367,14 @@ private constructor(

@JvmStatic
fun getRootInstance(view: BaseMountingView): DebugComponent? =
getRootInstance(
view.currentLayoutState,
if (view is LithoView) view.componentTree?.timeMachine else null)
getRootInstance(view.currentLayoutState)

fun getRootInstance(componentTree: ComponentTree?): DebugComponent? =
if (componentTree == null) null
else getRootInstance(componentTree.mainThreadLayoutState, componentTree.timeMachine)
if (componentTree == null) null else getRootInstance(componentTree.mainThreadLayoutState)

@JvmStatic
fun getRootInstance(
layoutState: LayoutState?,
timeMachine: ComponentTreeTimeMachine?
): DebugComponent? {
val root = layoutState?.rootLayoutResult
if (root == null || root is NullLithoLayoutResult) {
Expand All @@ -390,16 +383,14 @@ private constructor(
check(root is LithoLayoutResult) { "Expected root to be a LithoLayoutResult" }
val node = root.node
val outerWrapperComponentIndex = (node.componentCount - 1).coerceAtLeast(0)
return getInstance(root, outerWrapperComponentIndex, 0, 0, 0, 0, timeMachine)?.apply {
isRoot = true
}
return getInstance(root, outerWrapperComponentIndex, 0, 0, 0, 0)?.apply { isRoot = true }
}

@JvmStatic
fun getInstance(result: LithoLayoutResult, x: Int, y: Int): DebugComponent? {
val rootNode = result.node
val outerWrapperComponentIndex = (rootNode.componentCount - 1).coerceAtLeast(0)
return getInstance(result, outerWrapperComponentIndex, x, y, 0, 0, null)
return getInstance(result, outerWrapperComponentIndex, x, y, 0, 0)
}

/**
Expand Down Expand Up @@ -503,7 +494,7 @@ private constructor(
result.getYForChildAtIndex(i),
xOffset,
yOffset,
null)
)
?.let { add(it) }
}
}
Expand Down
3 changes: 0 additions & 3 deletions litho-core/src/main/java/com/facebook/litho/LayoutState.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public static boolean isFromSyncLayout(@RenderSource int source) {
case RenderSource.SET_ROOT_SYNC:
case RenderSource.UPDATE_STATE_SYNC:
case RenderSource.SET_SIZE_SPEC_SYNC:
case RenderSource.RELOAD_PREVIOUS_STATE:
return true;
default:
return false;
Expand Down Expand Up @@ -298,8 +297,6 @@ static String layoutSourceToString(@RenderSource int source) {
return "measure_setSizeSpecAsync";
case RenderSource.TEST:
return "test";
case RenderSource.RELOAD_PREVIOUS_STATE:
return "reloadState";
case RenderSource.NONE:
return "none";
default:
Expand Down
4 changes: 1 addition & 3 deletions litho-core/src/main/java/com/facebook/litho/RenderSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import androidx.annotation.IntDef
RenderSource.UPDATE_STATE_SYNC,
RenderSource.UPDATE_STATE_ASYNC,
RenderSource.MEASURE_SET_SIZE_SPEC,
RenderSource.MEASURE_SET_SIZE_SPEC_ASYNC,
RenderSource.RELOAD_PREVIOUS_STATE)
RenderSource.MEASURE_SET_SIZE_SPEC_ASYNC)
annotation class RenderSource {
companion object {
const val TEST = -2
Expand All @@ -42,7 +41,6 @@ annotation class RenderSource {
const val UPDATE_STATE_ASYNC = 5
const val MEASURE_SET_SIZE_SPEC = 6
const val MEASURE_SET_SIZE_SPEC_ASYNC = 7
const val RELOAD_PREVIOUS_STATE = 8
}
}

Expand Down
Loading

0 comments on commit aa9b281

Please sign in to comment.