|
@@ -259,7 +259,7 @@ end;
|
|
|
|
|
|
procedure TFLNodeLayouter.Apply;
|
|
|
var
|
|
|
- MaxWidth, MaxHeight, aClientWidth, aClientHeight: TFresnelLength;
|
|
|
+ MaxWidth, MaxHeight, AvailWidth, AvailHeight: TFresnelLength;
|
|
|
Size: TFreIntrinsicContentSize;
|
|
|
HasMaxWidth, HasMaxHeight: Boolean;
|
|
|
El: TFresnelElement;
|
|
@@ -299,44 +299,44 @@ begin
|
|
|
aClientBox.Bottom-=Node.ScrollGutterBottom;
|
|
|
El.UsedClientBox:=aClientBox;
|
|
|
|
|
|
- aClientWidth:=MaxWidth;
|
|
|
+ AvailWidth:=MaxWidth;
|
|
|
if HasMaxWidth then
|
|
|
- aClientWidth:=aClientWidth-Node.ScrollGutterLeft-Node.ScrollGutterRight;
|
|
|
- aClientHeight:=MaxHeight;
|
|
|
+ AvailWidth:=AvailWidth-Node.ScrollGutterLeft-Node.ScrollGutterRight;
|
|
|
+ AvailHeight:=MaxHeight;
|
|
|
if HasMaxHeight then
|
|
|
- aClientHeight:=aClientHeight-Node.ScrollGutterTop-Node.ScrollGutterBottom;
|
|
|
+ AvailHeight:=AvailHeight-Node.ScrollGutterTop-Node.ScrollGutterBottom;
|
|
|
|
|
|
{$IFDEF VerboseFresnelScrolling}
|
|
|
- writeln('TFLNodeLayouter.Apply "',Node.Element.Name,'" CanScrollX=',Node.CanScrollX,' CanScrollY=',Node.CanScrollY,' MaxSize=',FloatToCSSStr(MaxWidth),'x',FloatToCSSStr(MaxHeight),' Client=',FloatToCSSStr(aClientWidth),'x',FloatToCSSStr(aClientHeight));
|
|
|
+ writeln('TFLNodeLayouter.Apply "',Node.Element.Name,'" CanScrollX=',Node.CanScrollX,' CanScrollY=',Node.CanScrollY,' MaxSize=',FloatToCSSStr(MaxWidth),'x',FloatToCSSStr(MaxHeight),' Available=',FloatToCSSStr(aClientWidth),'x',FloatToCSSStr(aClientHeight));
|
|
|
{$ENDIF}
|
|
|
- Size:=ComputeLayoutContent(flmMax,aClientWidth,aClientHeight,true);
|
|
|
+ Size:=ComputeLayoutContent(flmMax,AvailWidth,AvailHeight,true);
|
|
|
{$IFDEF VerboseFresnelScrolling}
|
|
|
writeln('TFLNodeLayouter.Apply "',Node.Element.Name,'" Size: ',FloatToCSSStr(Size.Width),'x',FloatToCSSStr(Size.Height),' Scroll: ',FloatToCSSStr(Size.ScrollWidth),'x',FloatToCSSStr(Size.ScrollWidth));
|
|
|
{$ENDIF}
|
|
|
if IsNan(Node.Width) then
|
|
|
begin
|
|
|
Node.Width:=Size.Width;
|
|
|
- if Node.Width>aClientWidth then
|
|
|
- Node.Width:=aClientWidth;
|
|
|
+ if Node.Width>AvailWidth then
|
|
|
+ Node.Width:=AvailWidth;
|
|
|
end;
|
|
|
if IsNan(Node.Height) then
|
|
|
begin
|
|
|
Node.Height:=Node.FitHeight(Size.Height);
|
|
|
- if Node.Height>aClientHeight then
|
|
|
- Node.Height:=aClientHeight;
|
|
|
+ if Node.Height>AvailHeight then
|
|
|
+ Node.Height:=AvailHeight;
|
|
|
end;
|
|
|
- Node.ScrollWidth:=Max(Size.ScrollWidth,aClientWidth);
|
|
|
- Node.ScrollHeight:=Max(Size.ScrollHeight,aClientHeight);
|
|
|
+ Node.ScrollWidth:=Max(Size.ScrollWidth,AvailWidth);
|
|
|
+ Node.ScrollHeight:=Max(Size.ScrollHeight,AvailHeight);
|
|
|
{$IFDEF VerboseFresnelScrolling}
|
|
|
writeln('TFLNodeLayouter.Apply "',Node.Element.Name,'" ScrollSize: ',FloatToCSSStr(Node.ScrollWidth),'x',FloatToCSSStr(Node.ScrollHeight),' Width=',FloatToCSSStr(Node.Width),' Height=',FloatToCSSStr(Node.Height));
|
|
|
{$ENDIF}
|
|
|
|
|
|
if Node.ScrollbarWidth<>CSSRegistry.kwNone then
|
|
|
begin
|
|
|
- if (Node.ScrollWidth>aClientWidth)
|
|
|
+ if (Node.ScrollWidth>AvailWidth)
|
|
|
and (El.ComputedOverflowX in [CSSRegistry.kwScroll,CSSRegistry.kwAuto]) then
|
|
|
Include(Node.Flags,flfScrollbarHorizontal);
|
|
|
- if (Node.ScrollHeight>aClientHeight)
|
|
|
+ if (Node.ScrollHeight>AvailHeight)
|
|
|
and (El.ComputedOverflowY in [CSSRegistry.kwScroll,CSSRegistry.kwAuto]) then
|
|
|
Include(Node.Flags,flfScrollbarVertical);
|
|
|
end;
|
|
@@ -490,7 +490,6 @@ var
|
|
|
if not GetCachedLayoutSize(CurMode,CurMaxWidth,CurMaxHeight,false,Result) then
|
|
|
begin
|
|
|
Result:=ComputeLayoutContent(CurMode,CurMaxWidth,CurMaxHeight,false);
|
|
|
- Result:=Default(TFreIntrinsicContentSize);
|
|
|
AddCachedLayoutSize(CurMode,CurMaxWidth,CurMaxHeight,false,Result);
|
|
|
end;
|
|
|
if AddGutter then begin
|
|
@@ -543,7 +542,6 @@ var
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
- aSize: TFresnelPoint;
|
|
|
OldNeedVert: Boolean;
|
|
|
begin
|
|
|
case aMode of
|
|
@@ -561,8 +559,12 @@ begin
|
|
|
aWithScroll:=false;
|
|
|
end;
|
|
|
|
|
|
+ //writeln('TFLNodeLayouter.GetIntrinsicContentSize ',Node.Element.Name,' ',aMode,' ',FloatToCSSStr(aMaxWidth),' ',FloatToCSSStr(aMaxHeight));
|
|
|
if GetCachedLayoutSize(aMode,aMaxWidth,aMaxHeight,aWithScroll,Result) then
|
|
|
+ begin
|
|
|
+ //writeln('TFLNodeLayouter.GetIntrinsicContentSize FromCache: ',Result.ToString);
|
|
|
exit;
|
|
|
+ end;
|
|
|
|
|
|
Done:=false;
|
|
|
if aWithScroll then
|
|
@@ -618,6 +620,7 @@ begin
|
|
|
if not Done then
|
|
|
begin
|
|
|
Result:=ComputeLayoutContent(aMode,aMaxWidth,aMaxHeight,false);
|
|
|
+ //writeln('TFLNodeLayouter.GetIntrinsicContentSize ',Node.Element.Name,' ',aMode,' ',FloatToCSSStr(aMaxWidth),' ',FloatToCSSStr(aMaxHeight),' Computed=',Result.ToString);
|
|
|
end;
|
|
|
AddCachedLayoutSize(aMode,aMaxWidth,aMaxHeight,aWithScroll,Result);
|
|
|
end;
|
|
@@ -1277,7 +1280,7 @@ begin
|
|
|
begin
|
|
|
ChildPrefSize:=ChildEl.GetIntrinsicContentSize(aMode,CurSpace,NaN);
|
|
|
//if ChildEl.Name='CaptionLabel' then
|
|
|
- writeln('TFLFlowLayouter.ComputeLayoutContent ',ChildEl.GetPath,' MaxWidth=',FloatToCSSStr(CurSpace),' Preferred=',ChildPrefSize.ToString,' ChildPadBorderX=',FloatToCSSStr(ChildPadBorderX),' ChildPadBorderY=',FloatToCSSStr(ChildPadBorderY));
|
|
|
+ //writeln('TFLFlowLayouter.ComputeLayoutContent ',ChildEl.GetPath,' MaxWidth=',FloatToCSSStr(CurSpace),' Preferred=',ChildPrefSize.ToString,' ChildPadBorderX=',FloatToCSSStr(ChildPadBorderX),' ChildPadBorderY=',FloatToCSSStr(ChildPadBorderY),' Commit=',Commit);
|
|
|
// apply min, max
|
|
|
if IsNan(ChildWidth) then
|
|
|
begin
|
|
@@ -1956,7 +1959,7 @@ var
|
|
|
ChildNode: TUsedLayoutNode;
|
|
|
ChildEl: TFresnelElement;
|
|
|
NewLeft, NewTop, FrameLeft, FrameRight, FrameTop, FrameBottom: TFresnelLength;
|
|
|
- aBorderBox, aContentBox: TFresnelRect;
|
|
|
+ aBorderBox, aContentBox, aClientBox: TFresnelRect;
|
|
|
begin
|
|
|
for i:=0 to FLineItems.Count-1 do
|
|
|
begin
|
|
@@ -2004,10 +2007,14 @@ begin
|
|
|
aContentBox.Bottom:=aContentBox.Top+Item.ContentBoxHeight;
|
|
|
aBorderBox.Right:=aContentBox.Right+FrameRight;
|
|
|
aBorderBox.Bottom:=aContentBox.Bottom+FrameBottom;
|
|
|
+ aClientBox.Left:=aBorderBox.Left+ChildNode.PaddingLeft;
|
|
|
+ aClientBox.Top:=aBorderBox.Top+ChildNode.PaddingTop;
|
|
|
+ aClientBox.Right:=aBorderBox.Right-ChildNode.PaddingRight;
|
|
|
+ aClientBox.Bottom:=aBorderBox.Bottom-ChildNode.PaddingBottom;
|
|
|
|
|
|
ChildEl.UsedBorderBox:=aBorderBox;
|
|
|
ChildEl.UsedContentBox:=aContentBox;
|
|
|
- ChildEl.UsedClientBox:=aContentBox;
|
|
|
+ ChildEl.UsedClientBox:=aClientBox;
|
|
|
ChildNode.Left:=NewLeft;
|
|
|
ChildNode.Top:=NewTop;
|
|
|
ChildNode.Right:=aBorderBox.Right+ChildNode.MarginRight;
|
|
@@ -2043,51 +2050,61 @@ begin
|
|
|
writeln('TFLLineLayouter.PlaceAbsoluteItem ',ChildEl.GetPath,' ',aMode,' Commit=',Commit,' Left=',FloatToCSSStr(ChildNode.Left),',Top=',FloatToCSSStr(ChildNode.Top),',Right=',FloatToCSSStr(ChildNode.Right),',Bottom=',FloatToCSSStr(ChildNode.Bottom),' Width=',FloatToCSSStr(ChildNode.Width),' Height=',FloatToCSSStr(ChildNode.Height),' Default=',FloatToCSSStr(DefaultPos.X),',',FloatToCSSStr(DefaultPos.Y));
|
|
|
writeln('TFLLineLayouter.PlaceAbsoluteItem ',CSSRegistry.Keywords[ChildEl.ComputedDisplayOutside],' ',CSSRegistry.Keywords[ChildEl.ComputedDisplayInside],' Style=',ChildEl.Style);
|
|
|
{$ENDIF}
|
|
|
+ FrameLeft:=ChildNode.MarginLeft+ChildNode.BorderLeft+ChildNode.PaddingLeft;
|
|
|
+ FrameRight:=ChildNode.PaddingRight+ChildNode.BorderRight+ChildNode.MarginRight;
|
|
|
+ FrameTop:=ChildNode.MarginTop+ChildNode.BorderTop+ChildNode.PaddingTop;
|
|
|
+ FrameBottom:=ChildNode.PaddingBottom+ChildNode.BorderBottom+ChildNode.MarginBottom;
|
|
|
+
|
|
|
NewLeft:=ChildNode.Left;
|
|
|
NewTop:=ChildNode.Top;
|
|
|
NewRight:=ChildNode.Right;
|
|
|
NewBottom:=ChildNode.Bottom;
|
|
|
+ if aMode=flmMax then
|
|
|
+ begin
|
|
|
+ NewWidth:=ChildNode.Width;
|
|
|
+ NewHeight:=ChildNode.Height;
|
|
|
+
|
|
|
+ if IsNan(NewWidth) and not IsNan(aMaxWidth)
|
|
|
+ and not IsNan(NewLeft) and not IsNan(NewRight) then
|
|
|
+ NewWidth:=aMaxWidth-NewLeft-NewRight-FrameLeft-FrameRight;
|
|
|
+ if IsNan(NewHeight) and not IsNan(aMaxHeight)
|
|
|
+ and not IsNan(NewTop) and not IsNan(NewBottom) then
|
|
|
+ NewHeight:=aMaxHeight-NewTop-NewBottom-FrameTop-FrameBottom;
|
|
|
+ end else begin
|
|
|
+ NewWidth:=NaN;
|
|
|
+ NewHeight:=NaN;
|
|
|
+ end;
|
|
|
+
|
|
|
p.X:=NaN;
|
|
|
if IsNan(NewLeft) and IsNan(NewRight) then
|
|
|
begin
|
|
|
+ // no left or right => use default static position
|
|
|
p:=ChildEl.GetContainerOffset;
|
|
|
NewLeft:=p.X+DefaultPos.X;
|
|
|
end;
|
|
|
if IsNan(NewTop) and IsNan(NewBottom) then
|
|
|
begin
|
|
|
+ // no top or bottom => use default static position
|
|
|
if IsNan(p.X) then
|
|
|
p:=ChildEl.GetContainerOffset;
|
|
|
NewTop:=p.y+DefaultPos.Y;
|
|
|
end;
|
|
|
|
|
|
+ // Note: The DeductUsedLengths has already computed based solely on css values.
|
|
|
+
|
|
|
if aMode=flmMax then
|
|
|
begin
|
|
|
- NewWidth:=ChildNode.Width;
|
|
|
- NewHeight:=ChildNode.Height;
|
|
|
- end else begin
|
|
|
- NewWidth:=NaN;
|
|
|
- NewHeight:=NaN;
|
|
|
+ if IsNan(aMaxWidth) then
|
|
|
+ aMaxWidth:=ChildNode.MaxWidth;
|
|
|
+ if IsNan(aMaxHeight) then
|
|
|
+ aMaxHeight:=ChildNode.MaxHeight;
|
|
|
end;
|
|
|
-
|
|
|
- // Note: The DeductUsedLengths has already computed simple cases
|
|
|
- // e.g. given container's width and child's left and right => child's width
|
|
|
-
|
|
|
- aMaxWidth:=NewWidth;
|
|
|
- aMaxHeight:=NewHeight;
|
|
|
- if IsNan(aMaxWidth) then
|
|
|
- aMaxWidth:=ChildNode.MaxWidth;
|
|
|
- if IsNan(aMaxHeight) then
|
|
|
- aMaxHeight:=ChildNode.MaxHeight;
|
|
|
Size:=ChildEl.GetIntrinsicContentSize(aMode,aMaxWidth,aMaxHeight);
|
|
|
if IsNan(NewWidth) then
|
|
|
NewWidth:=ChildNode.FitWidth(Size.Width);
|
|
|
if IsNan(NewHeight) then
|
|
|
NewHeight:=ChildNode.FitHeight(Size.Height);
|
|
|
|
|
|
- FrameLeft:=ChildNode.MarginLeft+ChildNode.BorderLeft+ChildNode.PaddingLeft;
|
|
|
- FrameRight:=ChildNode.PaddingRight+ChildNode.BorderRight+ChildNode.MarginRight;
|
|
|
- FrameTop:=ChildNode.MarginTop+ChildNode.BorderTop+ChildNode.PaddingTop;
|
|
|
- FrameBottom:=ChildNode.PaddingBottom+ChildNode.BorderBottom+ChildNode.MarginBottom;
|
|
|
if IsNan(NewLeft) then
|
|
|
begin
|
|
|
if IsNan(aMaxWidth) or IsNan(NewRight) then
|
|
@@ -2095,6 +2112,13 @@ begin
|
|
|
else
|
|
|
NewLeft:=aMaxWidth-NewRight-NewWidth-FrameLeft-FrameRight;
|
|
|
end;
|
|
|
+ if IsNan(NewRight) then
|
|
|
+ begin
|
|
|
+ if IsNan(aMaxWidth) then
|
|
|
+ NewRight:=0
|
|
|
+ else
|
|
|
+ NewRight:=aMaxWidth-NewWidth-FrameLeft-FrameRight-NewLeft;
|
|
|
+ end;
|
|
|
if IsNan(NewTop) then
|
|
|
begin
|
|
|
if IsNan(aMaxHeight) or IsNan(NewBottom) then
|
|
@@ -2104,9 +2128,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
// compute right, bottom of marginbox
|
|
|
- Result.Width:=FrameLeft+NewWidth+FrameRight;
|
|
|
- if not IsNan(NewLeft) then
|
|
|
- Result.Width:=Result.Width+NewLeft;
|
|
|
+ Result.Width:=NewLeft+FrameLeft+NewWidth+FrameRight;
|
|
|
if not IsNan(NewRight) then
|
|
|
Result.Width:=Result.Width+NewRight;
|
|
|
Result.ScrollWidth:=Result.Width;
|
|
@@ -2143,19 +2165,26 @@ begin
|
|
|
ChildNode.Width:=NewWidth;
|
|
|
ChildNode.Height:=NewHeight;
|
|
|
|
|
|
+ // used borderbox
|
|
|
r.Left:=NewLeft+ChildNode.MarginLeft;
|
|
|
r.Top:=NewTop+ChildNode.MarginTop;
|
|
|
r.Right:=NewLeft+FrameLeft+NewWidth+FrameRight-ChildNode.MarginRight;
|
|
|
r.Bottom:=NewTop+FrameTop+NewHeight+FrameBottom-ChildNode.MarginBottom;
|
|
|
ChildEl.UsedBorderBox:=r;
|
|
|
|
|
|
+ // used clientbox
|
|
|
+ r.Left:=r.Left+ChildNode.PaddingLeft;
|
|
|
+ r.Right:=r.Right-ChildNode.PaddingRight;
|
|
|
+ r.Top:=r.Top+ChildNode.PaddingTop;
|
|
|
+ r.Bottom:=r.Bottom-ChildNode.PaddingBottom;
|
|
|
+ ChildEl.UsedClientBox:=r;
|
|
|
+
|
|
|
// used contentbox
|
|
|
r.Left:=NewLeft+FrameLeft;
|
|
|
r.Top:=NewTop+FrameTop;
|
|
|
r.Right:=r.Left+NewWidth;
|
|
|
r.Bottom:=R.Top+NewHeight;
|
|
|
ChildEl.UsedContentBox:=r;
|
|
|
- ChildEl.UsedClientBox:=r;
|
|
|
|
|
|
{$IFDEF VerboseFresnelPlacing}
|
|
|
writeln('TFLLineLayouter.PlaceAbsoluteItem '+ChildEl.GetPath+' BorderBox='+ChildEl.UsedBorderBox.ToString);
|