Skip to content

Commit

Permalink
fix: fix assertion when cross render-object tree access size property.
Browse files Browse the repository at this point in the history
  • Loading branch information
andycall committed Sep 5, 2023
1 parent 7b170f8 commit 83f479b
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions webf/lib/src/rendering/logic_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,24 @@ class LogicInlineBox {
return childOffsetY;
}

double get width => renderObject.size.width;
double get width {
if (renderObject is RenderBoxModel) {
return (renderObject as RenderBoxModel).boxSize!.width;
}
return 0.0;
}

double get height => renderObject.size.height;
double get height {
if (renderObject is RenderBoxModel) {
return (renderObject as RenderBoxModel).boxSize!.height;
}
return 0.0;
}

Size _getInlineBoxScrollableSize() {
Size scrollableSize = renderObject.size;
Size scrollableSize = Size.zero;
if (renderObject is RenderBoxModel) {
scrollableSize = (renderObject as RenderBoxModel).boxSize!;
RenderStyle childRenderStyle = (renderObject as RenderBoxModel).renderStyle;
CSSOverflowType overflowX = childRenderStyle.effectiveOverflowX;
CSSOverflowType overflowY = childRenderStyle.effectiveOverflowY;
Expand Down Expand Up @@ -146,7 +157,7 @@ class LogicInlineBox {
if (renderObject is RenderTextBox) {
lineHeight = (renderObject as RenderTextBox).renderStyle.lineHeight;
} else if(renderObject is RenderReplaced) {
return renderObject.size.height;
return (renderObject as RenderReplaced).boxSize!.height;
} else if (renderObject is RenderBoxModel) {
lineHeight = (renderObject as RenderBoxModel).renderStyle.lineHeight;
} else if (renderObject is RenderPositionPlaceholder) {
Expand Down Expand Up @@ -610,12 +621,13 @@ class LogicLineBox {
for (int i = 0; i < inlineBoxes.length; i++) {
LogicInlineBox box = inlineBoxes[i];
RenderBox render = box.renderObject;
double runChildMainSize = box.renderObject.size.width;
double runChildMainSize = 0;
if (render is RenderTextBox) {
runChildMainSize = render.minContentWidth;
}
// Should add horizontal margin of child to the main axis auto size of parent.
if (render is RenderBoxModel) {
runChildMainSize = render.boxSize!.width;
double childMarginLeft = render.renderStyle.marginLeft.computedValue;
double childMarginRight = render.renderStyle.marginRight.computedValue;
runChildMainSize += childMarginLeft + childMarginRight;
Expand All @@ -631,10 +643,13 @@ class LogicLineBox {
LogicInlineBox box = inlineBoxes[i];
RenderBox render = box.renderObject;

double runChildCrossSize = render.size.height;
double runChildCrossSize = 0;
if (render is RenderTextBox && box is LogicTextInlineBox) {
runChildCrossSize = box.logicRect.height;
} else if (render is RenderBoxModel) {
runChildCrossSize = render.boxSize!.height;
}

if (runChildCrossSize > runCrossExtent) {
runCrossExtent = runChildCrossSize;
}
Expand Down

0 comments on commit 83f479b

Please sign in to comment.