|
@@ -769,6 +769,7 @@ type
|
|
|
FParent: TFresnelElement;
|
|
|
FStyle: string;
|
|
|
FStyleElement: TCSSRuleElement;
|
|
|
+ FViewPort: TFresnelViewport;
|
|
|
procedure SetCSSClasses(const AValue: TStrings); virtual;
|
|
|
procedure SetParent(const AValue: TFresnelElement); virtual;
|
|
|
procedure SetStyle(AValue: string); virtual;
|
|
@@ -781,7 +782,6 @@ type
|
|
|
function CSSReadNextValue(const aValue: string; var p: integer): string; // read e.g. url("bla")
|
|
|
function CSSReadNextToken(const aValue: string; var p: integer): string; // read e.g. linear-gradient without the brackets
|
|
|
function GetDPI(IsHorizontal: boolean): TFresnelLength; virtual;
|
|
|
- function GetViewport: TFresnelViewport; virtual;
|
|
|
procedure SetViewportConnected(AValue: boolean); virtual;
|
|
|
function GetFont: IFresnelFont; virtual;
|
|
|
procedure FPOObservedChanged(ASender: TObject; Operation: TFPObservedOperation; Data: Pointer); virtual;
|
|
@@ -890,6 +890,7 @@ type
|
|
|
// font
|
|
|
property Font: IFresnelFont read GetFont write FFont;
|
|
|
property ViewportConnected: boolean read GetViewportConnected write SetViewportConnected; // true for example if using a Font of Viewport
|
|
|
+ property Viewport: TFresnelViewport read FViewPort;
|
|
|
published
|
|
|
property CSSClasses: TStrings read FCSSClasses write SetCSSClasses;
|
|
|
property Style: string read FStyle write SetStyle;
|
|
@@ -3379,7 +3380,9 @@ begin
|
|
|
if AComponent=FLayouter then
|
|
|
FLayouter:=nil
|
|
|
else if AComponent=FResolver then
|
|
|
- FResolver:=nil;
|
|
|
+ FResolver:=nil
|
|
|
+ else if AComponent=FViewPort then
|
|
|
+ FViewPort:=nil;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -3456,7 +3459,11 @@ var
|
|
|
//writeln('Traverse ',El.ClassName,' CSSTypeName=',El.CSSTypeName);
|
|
|
El.DOMIndex:=CurDomIndex;
|
|
|
inc(CurDomIndex);
|
|
|
- El.FResolver:=Resolver;
|
|
|
+ if El<>Self then
|
|
|
+ begin
|
|
|
+ El.FResolver:=Resolver;
|
|
|
+ El.FViewPort:=Self;
|
|
|
+ end;
|
|
|
El.ComputeStyleElement;
|
|
|
El.ComputeCSSValues;
|
|
|
|
|
@@ -3830,16 +3837,18 @@ begin
|
|
|
begin
|
|
|
ViewportConnected:=false;
|
|
|
FResolver:=nil;
|
|
|
- FParent.FChildren.Remove(Self);
|
|
|
- FParent.DomChanged;
|
|
|
+ FViewPort:=nil;
|
|
|
+ Parent.FChildren.Remove(Self);
|
|
|
+ Parent.DomChanged;
|
|
|
end;
|
|
|
FParent:=AValue;
|
|
|
if FParent<>nil then
|
|
|
begin
|
|
|
- FParent.FChildren.Add(Self);
|
|
|
+ Parent.FChildren.Add(Self);
|
|
|
FreeNotification(FParent);
|
|
|
- FResolver:=FParent.Resolver;
|
|
|
- FParent.DomChanged;
|
|
|
+ FResolver:=Parent.Resolver;
|
|
|
+ FViewPort:=Parent.FViewPort;
|
|
|
+ Parent.DomChanged;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -4152,17 +4161,6 @@ begin
|
|
|
Result:=FresnelDefaultDPI;
|
|
|
end;
|
|
|
|
|
|
-function TFresnelElement.GetViewport: TFresnelViewport;
|
|
|
-var
|
|
|
- El: TFresnelElement;
|
|
|
-begin
|
|
|
- El:=GetRoot;
|
|
|
- if El is TFresnelViewport then
|
|
|
- Result:=TFresnelViewport(El)
|
|
|
- else
|
|
|
- Result:=nil;
|
|
|
-end;
|
|
|
-
|
|
|
function TFresnelElement.GetCSSString(AttrID: TCSSNumericalID; Compute: boolean; out
|
|
|
Complete: boolean): string;
|
|
|
var
|
|
@@ -4389,7 +4387,7 @@ end;
|
|
|
|
|
|
function TFresnelElement.GetMaxWidthIntrinsicContentBox: TFresnelLength;
|
|
|
begin
|
|
|
- Result:=GetViewport.MaxPreferredWidth;
|
|
|
+ Result:=Viewport.MaxPreferredWidth;
|
|
|
end;
|
|
|
|
|
|
function TFresnelElement.GetMaxWidthContentBox: TFresnelLength;
|
|
@@ -4400,7 +4398,7 @@ begin
|
|
|
case aValue of
|
|
|
'',
|
|
|
'auto': Result:=GetMaxWidthIntrinsicContentBox;
|
|
|
- 'max-content': Result:=GetPreferredContentBox_MaxWidth(GetViewport.MaxPreferredWidth).X;
|
|
|
+ 'max-content': Result:=GetPreferredContentBox_MaxWidth(Viewport.MaxPreferredWidth).X;
|
|
|
'min-content': Result:=GetMinWidthIntrinsicContentBox;
|
|
|
else
|
|
|
Result:=GetComputedLength(fcaMaxWidth,false);
|
|
@@ -4435,7 +4433,7 @@ begin
|
|
|
case aValue of
|
|
|
'',
|
|
|
'auto': Result:=GetMinWidthIntrinsicContentBox;
|
|
|
- 'max-content': Result:=GetPreferredContentBox_MaxWidth(GetViewport.MaxPreferredWidth).X;
|
|
|
+ 'max-content': Result:=GetPreferredContentBox_MaxWidth(Viewport.MaxPreferredWidth).X;
|
|
|
'min-content': Result:=GetMinWidthIntrinsicContentBox;
|
|
|
else
|
|
|
Result:=GetComputedLength(fcaMinWidth,false);
|
|
@@ -4502,9 +4500,9 @@ begin
|
|
|
Result:=El.GetComputedLength(fcaHeight,UseNaNOnFail);
|
|
|
end else begin
|
|
|
if IsHorizontal then
|
|
|
- Result:=GetViewport.Width
|
|
|
+ Result:=Viewport.Width
|
|
|
else
|
|
|
- Result:=GetViewport.Height;
|
|
|
+ Result:=Viewport.Height;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -4786,35 +4784,35 @@ begin
|
|
|
case anUnit of
|
|
|
cuNone: ;
|
|
|
cu_px: ;
|
|
|
- cu_cm: Result:=GetViewport.DPI[IsHorizontal]/2.54;
|
|
|
- cu_mm: Result:=GetViewport.DPI[IsHorizontal]/25.4;
|
|
|
- cu_Q: Result:=GetViewport.DPI[IsHorizontal]/101.6;
|
|
|
- cu_in: Result:=GetViewport.DPI[IsHorizontal];
|
|
|
- cu_pt: Result:=GetViewport.DPI[IsHorizontal]/72; // 1pt = 1/72 in
|
|
|
- cu_pc: Result:=GetViewport.DPI[IsHorizontal]/6; // 1pc = 12 pt
|
|
|
+ cu_cm: Result:=Viewport.DPI[IsHorizontal]/2.54;
|
|
|
+ cu_mm: Result:=Viewport.DPI[IsHorizontal]/25.4;
|
|
|
+ cu_Q: Result:=Viewport.DPI[IsHorizontal]/101.6;
|
|
|
+ cu_in: Result:=Viewport.DPI[IsHorizontal];
|
|
|
+ cu_pt: Result:=Viewport.DPI[IsHorizontal]/72; // 1pt = 1/72 in
|
|
|
+ cu_pc: Result:=Viewport.DPI[IsHorizontal]/6; // 1pc = 12 pt
|
|
|
// relative to element's font
|
|
|
cu_em: Result:=GetComputedFontSize; // todo
|
|
|
cu_ex: Result:=GetComputedFontSize/2; // todo
|
|
|
cu_cap: Result:=GetComputedFontSize; // todo
|
|
|
cu_ch: Result:=GetComputedFontSize; // todo
|
|
|
// relative to root's font
|
|
|
- cu_rem: Result:=GetViewport.GetComputedFontSize; // todo
|
|
|
- cu_rex: Result:=GetViewport.GetComputedFontSize/2; // todo
|
|
|
- cu_rcap: Result:=GetViewport.GetComputedFontSize; // todo
|
|
|
- cu_rchh: Result:=GetViewport.GetComputedFontSize; // todo
|
|
|
+ cu_rem: Result:=Viewport.GetComputedFontSize; // todo
|
|
|
+ cu_rex: Result:=Viewport.GetComputedFontSize/2; // todo
|
|
|
+ cu_rcap: Result:=Viewport.GetComputedFontSize; // todo
|
|
|
+ cu_rchh: Result:=Viewport.GetComputedFontSize; // todo
|
|
|
// relative to default viewport size
|
|
|
- cu_vw,cu_svw,cu_lvw,cu_dvw: Result:=GetViewport.Width/100;
|
|
|
- cu_vh,cu_svh,cu_lvh,cu_dvh: Result:=GetViewport.Height/100;
|
|
|
+ cu_vw,cu_svw,cu_lvw,cu_dvw: Result:=Viewport.Width/100;
|
|
|
+ cu_vh,cu_svh,cu_lvh,cu_dvh: Result:=Viewport.Height/100;
|
|
|
cu_vmax,cu_svmax,cu_lvmax,cu_dvmax:
|
|
|
- if GetViewport.Width>GetViewport.Height then
|
|
|
- Result:=GetViewport.Width/100
|
|
|
+ if Viewport.Width>Viewport.Height then
|
|
|
+ Result:=Viewport.Width/100
|
|
|
else
|
|
|
- Result:=GetViewport.Height/100;
|
|
|
+ Result:=Viewport.Height/100;
|
|
|
cu_vmin,cu_svmin,cu_lvmin,cu_dvmin:
|
|
|
- if GetViewport.Width<GetViewport.Height then
|
|
|
- Result:=GetViewport.Width/100
|
|
|
+ if Viewport.Width<Viewport.Height then
|
|
|
+ Result:=Viewport.Width/100
|
|
|
else
|
|
|
- Result:=GetViewport.Height/100;
|
|
|
+ Result:=Viewport.Height/100;
|
|
|
else
|
|
|
raise Exception.Create('css unit not supported: '+CSSUnitNames[anUnit]);
|
|
|
end;
|
|
@@ -4850,7 +4848,7 @@ function TFresnelElement.GetFont: IFresnelFont;
|
|
|
aFont: IFresnelFont;
|
|
|
begin
|
|
|
Result:=FresnelDefaultFontSize;
|
|
|
- aFont:=GetViewport.GetFont;
|
|
|
+ aFont:=Viewport.GetFont;
|
|
|
if aFont<>nil then
|
|
|
Result:=aFont.GetSize;
|
|
|
end;
|
|
@@ -4923,14 +4921,12 @@ function TFresnelElement.GetFont: IFresnelFont;
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
- aViewPort: TFresnelViewport;
|
|
|
s: String;
|
|
|
aComp: TCSSResCompValue;
|
|
|
begin
|
|
|
if fesFontDescValid in FStates then
|
|
|
exit(FFont);
|
|
|
Include(FStates,fesFontDescValid);
|
|
|
- aViewPort:=GetViewport;
|
|
|
|
|
|
FFontDesc.Family:=GetComputedString(fcaFontFamily);
|
|
|
FFontDesc.Style:=GetComputedString(fcaFontStyle);
|
|
@@ -4973,8 +4969,8 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
- if FFontDesc.Size<aViewPort.FontMinSize then
|
|
|
- FFontDesc.Size:=aViewPort.FontMinSize;
|
|
|
+ if FFontDesc.Size<ViewPort.FontMinSize then
|
|
|
+ FFontDesc.Size:=ViewPort.FontMinSize;
|
|
|
|
|
|
s:=GetComputedString(fcaFontWeight);
|
|
|
case s of
|
|
@@ -4999,7 +4995,7 @@ begin
|
|
|
FFont:=nil;
|
|
|
end;
|
|
|
|
|
|
- FFont:=aViewPort.AllocateFont(FFontDesc);
|
|
|
+ FFont:=ViewPort.AllocateFont(FFontDesc);
|
|
|
Result:=FFont;
|
|
|
if FFont<>nil then
|
|
|
ViewportConnected:=true;
|