Texture - code reading

Updated
Sep 30, 2021 1:58 PM
Created
Apr 22, 2021 12:45 AM
Tags
Texture (AsyncDisplayKit)

How Texture calculates Layout

protocol ASLayoutElement

  • class ASDisplayNode conforms
  • class ASLayoutSpec conforms

ASLayoutElement has

  • set of layoutThatFits
  • set of calculateLayoutThatFits

  • layoutThatFits is entry point to start laying out.
  • calculateLayoutThatFits would be called from layoutThatFits

for example

  • layoutThatFits
    • calculateLayoutThatFits
      • layoutThatFits
        • calculateLayoutThatFits
          • recursively

So, calculateLayoutThatFits gives us to chance to customize layout.

How Texture applies the layout

ASDisplayNode._layoutSublayouts applies the calculated layout to its view or layer.

Memo

  • setNeedsLayout
    • invalidateCalculatedLayout
      • layoutVersion++
  • _layoutSublayouts
    • set frame to node.frame

  • ASTextNode.attributedText
    • setNeedsLayout
      • __setNeedsLayout

image

  • _u_setNeedsLayoutFromAbove

  • _locked_constrainedSizeForLayoutPass
    • returns a constrained size from layout pass

how to turn on as_log_verbose?