Changes between Initial Version and Version 1 of CSSContainIntrinsicSize

Dec 20, 2022 1:50:25 PM (19 months ago)



  • CSSContainIntrinsicSize

    v1 v1  
     2= contain-intrinsic-size =
     4Per [1],
     5> These properties allow elements with size containment to specify an explicit intrinsic inner size, causing the box to size as if its in-flow content totals to a width and height matching the specified explicit intrinsic inner size (rather than sizing as if it were empty).
     7The implementation is roughly split into two parts:
     8* Get the size from the contain-intrinsic-* properties as an explicit intrinsic inner size.
     9* Make the sizecontainment box sizing as if its content is the explicit intrinsic inner size.
     11== The explicit intrinsic inner size ==
     12  The part has landed in [2].
     13  * Added `explicitIntrinsicInnerLogicalWidth/Height()` to RenderBox.h, it gets the value of `contain-intrinsic-*` from RenderStyle.
     14  * To handle the logicalWidth, in `computeIntrinsicLogicalWidths`, the intrinsic size of sizeContainment was zero, now it is explicitIntrinsicInnerLogicalWidth() if existing. We need to handle every `computeIntrinsicLogicalWidths()` in the code.
     15  * To handle the logicalWidth, in `updateLogicalHeight()`, sizeContainment was treated as if there is no content, now it added explicitIntrinsicInnerLogicalHeight() if existing.
     16== The size from the contain-intrinsic-* properties ==
     17  === Value `none` and value `length` ===
     18    These two values are simple, for `none`, there is nothing to do, for `length`, we need to set the value to RenderStyle.
     19  === Value `auto length` ===
     20    The explicit intrinsic inner size is its last remembered size if any, if no, then it is the value of `length`.
     21    ==== The last remembered size ====
     22    Per [3], the last remembered size is the size when the element is not size-contained. The value is determined when ResizeObserver events are determined and delivered.
     23    * The last remembered size is related to Element, we add `RefPtr<ResizeObserverSize> m_lastRememberedSize` to `ElementRareData`. See the implementation in [4].
     24    * Create a ResizeObserver to handle the last remembered size. See the implementation in [5].
     25      - To create a specific ResizeObserver, we need to create a callback to handle the last remembered size, it is `CallbackForContainIntrinsicSize`, which removes or saves LastRememberedSize to the target.
     26      - Document will create and own `m_resizeObserverForContainIntrinsicSize` if there is an element with `contain-intrinsic-size: auto length`.
     27      - In `RenderTreeUpdater::updateElementRenderer`, it will observe the element if it is with `contain-intrinsic-size: auto length`, if not unobserve it.
     28      - When `deliverResizeObservations`, the LastRememberedSize will be saved.