in packages/core/src/rendering/render-object.ts [206:308]
protected setupYogaNode() {
assert(this.yogaNode)
if (this.yogaMeasure) {
this.yogaNode.setMeasureFunc(this.yogaMeasure)
}
// 同步样式到 yogaNode
const { style } = this
if (style.has('flexBasis')) {
this.handleFlexBasisChange(style.flexBasis)
}
if (style.has('flexGrow')) {
this.handleFlexGrowChange(style.flexGrow)
}
if (style.has('flexShrink')) {
this.handleFlexShrinkChange(style.flexShrink)
}
if (style.has('width')) {
this.handleWidthChange(style.width)
}
if (style.has('height')) {
this.handleHeightChange(style.height)
}
if (style.has('minWidth')) {
this.handleMinWidthChange(style.minWidth)
}
if (style.has('minHeight')) {
this.handleMinHeightChange(style.minHeight)
}
if (style.has('maxWidth')) {
this.handleMaxWidthChange(style.maxWidth)
}
if (style.has('maxHeight')) {
this.handleMaxHeightChange(style.maxHeight)
}
if (style.has('paddingTop')) {
this.handlePaddingTopChange(style.paddingTop)
}
if (style.has('paddingRight')) {
this.handlePaddingRightChange(style.paddingRight)
}
if (style.has('paddingBottom')) {
this.handlePaddingBottomChange(style.paddingBottom)
}
if (style.has('paddingLeft')) {
this.handlePaddingLeftChange(style.paddingLeft)
}
if (style.has('marginTop')) {
this.handleMarginTopChange(style.marginTop)
}
if (style.has('marginRight')) {
this.handleMarginRightChange(style.marginRight)
}
if (style.has('marginBottom')) {
this.handleMarginBottomChange(style.marginBottom)
}
if (style.has('marginLeft')) {
this.handleMarginLeftChange(style.marginLeft)
}
if (style.has('display')) {
this.handleDisplayChange(style.display)
}
if (style.has('position')) {
this.handlePositionChange(style.position)
}
if (style.has('right')) {
this.handleRightChange(style.right)
}
if (style.has('bottom')) {
this.handleBottomChange(style.bottom)
}
// 追踪变更
style.on('flexBasis', this.handleFlexBasisChange, this)
style.on('flexGrow', this.handleFlexGrowChange, this)
style.on('flexShrink', this.handleFlexShrinkChange, this)
// width 和 height 样式在 handleWidthChange 中已经追踪,这里无需重复追踪
// style.on('width', this.handleWidthChange, this)
// style.on('height', this.handleHeightChange, this)
style.on('minWidth', this.handleMinWidthChange, this)
style.on('minHeight', this.handleMinHeightChange, this)
style.on('maxWidth', this.handleMaxWidthChange, this)
style.on('maxHeight', this.handleMaxHeightChange, this)
style.on('paddingTop', this.handlePaddingTopChange, this)
style.on('paddingLeft', this.handlePaddingLeftChange, this)
style.on('paddingRight', this.handlePaddingRightChange, this)
style.on('paddingBottom', this.handlePaddingBottomChange, this)
style.on('marginTop', this.handleMarginTopChange, this)
style.on('marginLeft', this.handleMarginLeftChange, this)
style.on('marginRight', this.handleMarginRightChange, this)
style.on('marginBottom', this.handleMarginBottomChange, this)
style.on('position', this.handlePositionChange, this)
style.on('right', this.handleRightChange, this)
style.on('bottom', this.handleBottomChange, this)
// style.on('display', this.handleDisplayChange, this)
// let childIndex = 0
// this.visitChildren(child => {
// if (child.yogaNode) {
// this.yogaNode!.insertChild(child.yogaNode, childIndex++)
// }
// })
}