/*
 * Copyright 2014-present Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.facebook.litho.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Indicates that the annotated parameter's value should be equivalent to the named output set in
 * {@link OnCreateLayoutWithSizeSpec}.
 */
@Retention(RetentionPolicy.RUNTIME)
public @interface FromPreviousCreateLayout {}

@@ -735,115 +735,1894 @@
 %0A * 
-Indicates that the annotated parameter's value should be equivalent to the named output set in%0A * %7B@link On
+Annotates that the argument's value should be set to the named inter-stage output from the %7B@link%0A * OnCreateLayoutWithSizeSpec%7D lifecycle method. The name and type of the argument must match with%0A * the inter-stage output requested. This inter-stage output is different from the other because%0A * this %7B@link OnShouldCreateLayoutWithNewSizeSpec%7D is called in subsequent layout calculations when%0A * the framework has a cached layout to reuse.%0A *%0A * %3Cp%3E%3Cem%3E%3Cb%3EThis can be used in:%3C/b%3E%3C/em%3E%0A *%0A * %3Cul%3E%0A *   %3Cli%3E%7B@link OnShouldCreateLayoutWithNewSizeSpec%7D%0A * %3C/ul%3E%0A *%0A * %3Cp%3EThe annotation processor will validate this and other invariants in the API at build time.%0A *%0A * %3Cp%3EFor example: %3Cbr%3E%0A *%0A * %3Cpre%3E%3Ccode%3E%7B@literal @LayoutSpec%7D%0A * class MyComponentSpec %7B%0A *%0A *  %7B@literal @OnCreateLayoutWithSizeSpec%7D%0A *   static Component onCreateLayoutWithSizeSpec(%0A *       ComponentContext c,%0A *       int widthSpec,%0A *       int heightSpec) %7B%0A *%0A *     final Component textComponent =%0A *         Text.create(c).textSizeSp(16).text(%22Some text to measure.%22).build();%0A *%0A *     // UNSPECIFIED sizeSpecs will measure the text as being one line only,%0A *     // having unlimited width.%0A *     final Size textOutputSize = new Size();%0A *     textComponent.measure(%0A *         c,%0A *         SizeSpec.makeSizeSpec(0, UNSPECIFIED),%0A *         SizeSpec.makeSizeSpec(0, UNSPECIFIED),%0A *         textOutputSize);%0A *%0A *     // Small component to use in case textComponent does not fit within the current layout.%0A *     final Component imageComponent = Image.create(c).drawableRes(R.drawable.ic_launcher).build();%0A *%0A *     // Assuming SizeSpec.getMode(widthSpec) == EXACTLY or AT_MOST.%0A *     final int layoutWidth = SizeSpec.getSize(widthSpec);%0A *     final boolean textFits = (textOutputSize.width &lt;= layoutWidth);%0A *%0A *     return textFits ? textComponent : imageComponent;%0A *   %7D%0A *%0A *  %7B@literal @OnShould
 Crea
@@ -2625,32 +2625,35 @@
 CreateLayoutWith
+New
 SizeSpec%7D.%0A */%0A@
@@ -2645,17 +2645,580 @@
 izeSpec%7D
-.
+%0A *   static boolean onShouldCreateLayoutWithNewSizeSpec(%0A *       ComponentContext context,%0A *       int newWidthSpec,%0A *       int newHeightSpec,%0A *      %7B@literal @FromPreviousCreateLayout%7D int textWidth,  // Get the output value%0A *      %7B@literal @FromPreviousCreateLayout%7D boolean didItFit) %7B%0A *%0A *     final int newLayoutWidth = SizeSpec.getSize(newWidthSpec);%0A *     final boolean doesItStillFit = (textWidth &lt;= newLayoutWidth);%0A *%0A *     // false if it still fits or if still doesn't fit%0A *     return doesItStillFit %5E didItFit;%0A *   %7D%0A * %7D%3C/code%3E%3C/pre%3E
 %0A */%0A@Re

Add JavaDoc for FromCreateLayout