LayoutNG 기본

LayoutNG

LayoutAlgorithm 코드 분석
   - input : NGLayoutParams
    - 레이아웃을 수행해야하는 node
    - 레이아웃 결과물을 담을 수 있는 객체들
     (ConstraintsSpace, FragmentGeometry(border, padding, scroll), break token 생성 여부 등)
   - output : NGLayoutResult
    - 실제 fragments (NGPhysicalFragments)
    - 계산된 box 사이즈 (intrinsic_block_size_)
    - Dirty check에 사용되는 차지하는 영역 정보 
     (NGConstraintsSpace: wrap mode를 위한 exclusion space, out of flow 여부 등의 정보를 포함)

Input of NGLayoutAlgorithm

1. NGConstraintSpace

NGExclusionSpace

- NG에서 도입된 제외구역으로 이구역에는 자식 레이아웃이 들어갈수가 없다.
- 여기서 Derived 된 ConstraintSpace를 Layout Oppertunity라고 하고 자식에게 전달하는 용도로 쓰임

2. NGLayoutInputNode

3. NGBreakToken

Output of NGLayoutAlgorithm

1. NGLayoutResult

NGPhysicalFragment

- 멤버 변수로 해당 layoutObject, PhysicalSize size_, break_token_ 등이 있다.
- Fragment에서 position 정보를 들고 있지 않다. 부모 fragment로부터 상대적인 위치는 NGLink에서 저장하고 있다.
- NGPhysicalFragment->Children()을 호출해 NGLink 객체를 얻을 수 있다.

NGLink

- 멤버 변수로 해당 fragment, offset을 들고 있다. 
- Fragment 자체에는 위치 정보가 없으므로 배치에 관계없이 전체 프래그먼트 하위 트리를 재사용하고 캐시할 수 있다.
- 예를 들어, 2개의 ColumnBox를 child로 갖고 있는 NGPhysicalBoxFragment가 있고, 해당 Box의 Children()을 호출하면 2개의 NGLink 배열이 있다.
- 각 NGLink는 해당 fragment와 offset 정보를 들고 있다. 

NGPhysicalBoxFragment

class CORE_EXPORT NGPhysicalBoxFragment final : public NGPhysicalFragment {
 public:
  	static scoped_refptr<const NGPhysicalBoxFragment> Create(
 	 NGBoxFragmentBuilder* builder,
 	 WritingMode block_or_line_writing_mode);
		... 	
  	LayoutUnit baseline_;
  	LayoutUnit last_baseline_;
 	 NGInkOverflow ink_overflow_;
  	NGLink children_[];