|
@@ -356,9 +356,14 @@ type
|
|
var Value: string; // returns empty for invalid
|
|
var Value: string; // returns empty for invalid
|
|
out Complete: boolean) of object;
|
|
out Complete: boolean) of object;
|
|
TGetAsStringEvent = function(El: TFresnelElement): string of object;
|
|
TGetAsStringEvent = function(El: TFresnelElement): string of object;
|
|
|
|
+ TGetLength = function(const aComp: TCSSResCompValue; El: TFresnelElement;
|
|
|
|
+ NoChildren: boolean{true=dont use child values}
|
|
|
|
+ ): TFresnelLength of object;
|
|
public
|
|
public
|
|
- OnCompute: TComputeEvent; // removes unknown/invalid values, substitutes calc(), converts to base unit (px)
|
|
|
|
|
|
+ LengthHorizontal: boolean; // // e.g. what dpi to use
|
|
OnAsString: TGetAsStringEvent; // returns value of shorthand (e.g. font or margin-block)
|
|
OnAsString: TGetAsStringEvent; // returns value of shorthand (e.g. font or margin-block)
|
|
|
|
+ OnCompute: TComputeEvent; // removes unknown/invalid values, substitutes calc(), converts to base unit (px)
|
|
|
|
+ OnGetLength: TGetLength; // resolve special length: cuPercent to 100% pixels and keyword to pixel
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TFresnelCSSAttrDesc }
|
|
{ TFresnelCSSAttrDesc }
|
|
@@ -535,6 +540,10 @@ type
|
|
function GetPlaceItems(El: TFresnelElement): string; virtual;
|
|
function GetPlaceItems(El: TFresnelElement): string; virtual;
|
|
function GetPlaceSelf(El: TFresnelElement): string; virtual;
|
|
function GetPlaceSelf(El: TFresnelElement): string; virtual;
|
|
|
|
|
|
|
|
+ // get length
|
|
|
|
+ function GetLength_ContainerContentWidth(const aComp: TCSSResCompValue; El: TFresnelElement; NoChildren: boolean): TFresnelLength; virtual;
|
|
|
|
+ function GetLength_ContainerContentHeight(const aComp: TCSSResCompValue; El: TFresnelElement; NoChildren: boolean): TFresnelLength; virtual;
|
|
|
|
+ function GetLength_BorderWidth(const aComp: TCSSResCompValue; El: TFresnelElement; NoChildren: boolean): TFresnelLength; virtual;
|
|
public
|
|
public
|
|
// keywords
|
|
// keywords
|
|
const
|
|
const
|
|
@@ -823,16 +832,33 @@ type
|
|
constructor Create;
|
|
constructor Create;
|
|
procedure Init; override;
|
|
procedure Init; override;
|
|
// register attributes
|
|
// register attributes
|
|
- function AddFresnelAttr(Attr: TFresnelCSSAttribute; aInherits: boolean; const OnCheck: TCSSAttributeDesc.TCheckEvent): TFresnelCSSAttrDesc; virtual; overload;
|
|
|
|
|
|
+ function AddFresnelAttr(Attr: TFresnelCSSAttribute; aInherits: boolean;
|
|
|
|
+ const OnCheck: TCSSAttributeDesc.TCheckEvent): TFresnelCSSAttrDesc; virtual; overload;
|
|
function AddFresnelShorthand(Attr: TFresnelCSSAttribute; const OnCheck: TCSSAttributeDesc.TCheckEvent;
|
|
function AddFresnelShorthand(Attr: TFresnelCSSAttribute; const OnCheck: TCSSAttributeDesc.TCheckEvent;
|
|
const OnSplit: TCSSAttributeDesc.TSplitShorthandEvent;
|
|
const OnSplit: TCSSAttributeDesc.TSplitShorthandEvent;
|
|
const OnAsString: TFresnelElementAttrDesc.TGetAsStringEvent;
|
|
const OnAsString: TFresnelElementAttrDesc.TGetAsStringEvent;
|
|
const CompProps: TFresnelCSSAttributeArray): TFresnelCSSAttrDesc; virtual; overload;
|
|
const CompProps: TFresnelCSSAttributeArray): TFresnelCSSAttrDesc; virtual; overload;
|
|
- function AddFresnelLonghand(Attr: TFresnelCSSAttribute; Inherits: boolean; const OnCheck: TCSSAttributeDesc.TCheckEvent; const InitialValue: TCSSString = ''): TFresnelCSSAttrDesc; virtual; overload;
|
|
|
|
|
|
+ function AddFresnelLonghand(Attr: TFresnelCSSAttribute; Inherits: boolean;
|
|
|
|
+ const OnCheck: TCSSAttributeDesc.TCheckEvent;
|
|
|
|
+ const InitialValue: TCSSString = ''): TFresnelCSSAttrDesc; virtual; overload;
|
|
|
|
+ function AddFresnelLonghandLength(Attr: TFresnelCSSAttribute; Inherits: boolean;
|
|
|
|
+ const OnCheck: TCSSAttributeDesc.TCheckEvent;
|
|
|
|
+ Horizontal: boolean;
|
|
|
|
+ const InitialValue: TCSSString = '';
|
|
|
|
+ const OnGetLength: TFresnelElementAttrDesc.TGetLength = nil
|
|
|
|
+ ): TFresnelCSSAttrDesc; virtual; overload;
|
|
// register pseudo classes
|
|
// register pseudo classes
|
|
function AddFresnelPseudoClass(Pseudo: TFresnelCSSPseudoClass): TFresnelCSSPseudoClassDesc; virtual; overload;
|
|
function AddFresnelPseudoClass(Pseudo: TFresnelCSSPseudoClass): TFresnelCSSPseudoClassDesc; virtual; overload;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ TFresnelLayoutMode = (
|
|
|
|
+ flmMinWidth,
|
|
|
|
+ flmMinHeight,
|
|
|
|
+ flmMaxWidth,
|
|
|
|
+ flmMaxHeight
|
|
|
|
+ );
|
|
|
|
+ TFresnelLayoutModes = set of TFresnelLayoutMode;
|
|
|
|
+
|
|
{ TFresnelLayoutNode }
|
|
{ TFresnelLayoutNode }
|
|
|
|
|
|
TFresnelLayoutNode = class(TComponent)
|
|
TFresnelLayoutNode = class(TComponent)
|
|
@@ -844,10 +870,59 @@ type
|
|
function GetNodes(Index: integer): TFresnelLayoutNode;
|
|
function GetNodes(Index: integer): TFresnelLayoutNode;
|
|
procedure SetElement(const AValue: TFresnelElement);
|
|
procedure SetElement(const AValue: TFresnelElement);
|
|
procedure SetParent(const AValue: TFresnelLayoutNode);
|
|
procedure SetParent(const AValue: TFresnelLayoutNode);
|
|
|
|
+ protected
|
|
|
|
+ FContainerContentHeight: TFresnelLength;
|
|
|
|
+ FContainerContentHeightValid: boolean;
|
|
|
|
+ FContainerContentWidth: TFresnelLength;
|
|
|
|
+ FContainerContentWidthValid: boolean;
|
|
public
|
|
public
|
|
|
|
+ Container: TFresnelElement;
|
|
|
|
+ SkipLayout: boolean; // e.g. element or ancestor display:none or visibility=collapse
|
|
|
|
+ SkipRendering: boolean; // e.g. element or ancestor display:none or visibility<>visible
|
|
|
|
+ SubParent: boolean; // a node in between: has children but no Layouter, e.g. span
|
|
|
|
+
|
|
|
|
+ // used values
|
|
|
|
+ ZIndex: TFresnelLength;
|
|
|
|
+ BorderLeft: TFresnelLength;
|
|
|
|
+ BorderRight: TFresnelLength;
|
|
|
|
+ BorderTop: TFresnelLength;
|
|
|
|
+ BorderBottom: TFresnelLength;
|
|
|
|
+ PaddingLeft: TFresnelLength;
|
|
|
|
+ PaddingRight: TFresnelLength;
|
|
|
|
+ PaddingTop: TFresnelLength;
|
|
|
|
+ PaddingBottom: TFresnelLength;
|
|
|
|
+ MarginLeft: TFresnelLength;
|
|
|
|
+ MarginRight: TFresnelLength;
|
|
|
|
+ MarginTop: TFresnelLength;
|
|
|
|
+ MarginBottom: TFresnelLength;
|
|
|
|
+ LineHeight: TFresnelLength;
|
|
|
|
+
|
|
|
|
+ // attributes depending on position:
|
|
|
|
+ // static: left, top, right, bottom are ignored
|
|
|
|
+ // relative: relative to layout position. left 10px moves 10px to the right, right 10px moves 10px to the left
|
|
|
|
+ // absolute: relative to container's contentbox. left 10px moves 10px to the right, right 10px moves 10px to the left
|
|
|
|
+ // fixed: as absolute, except relative to viewport
|
|
|
|
+ // sticky: as relative, except to container's non-scrolled contentbox
|
|
|
|
+ Left: TFresnelLength;
|
|
|
|
+ Top: TFresnelLength;
|
|
|
|
+ Right: TFresnelLength;
|
|
|
|
+ Bottom: TFresnelLength;
|
|
|
|
+
|
|
|
|
+ // content-boxed:
|
|
|
|
+ Width: TFresnelLength;
|
|
|
|
+ Height: TFresnelLength;
|
|
|
|
+ MinWidth: TFresnelLength;
|
|
|
|
+ MinHeight: TFresnelLength;
|
|
|
|
+ MaxWidth: TFresnelLength;
|
|
|
|
+ MaxHeight: TFresnelLength;
|
|
|
|
+
|
|
constructor Create(AOwner: TComponent); override;
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
|
|
+ function GetIntrinsicContentSize(aMode: TFresnelLayoutMode; aMaxWidth: TFresnelLength = NaN; aMaxHeight: TFresnelLength = NaN): TFresnelPoint; virtual; // ignoring min|max-height
|
|
function GetRoot: TFresnelLayoutNode;
|
|
function GetRoot: TFresnelLayoutNode;
|
|
|
|
+ function FitWidth(aWidth: TFresnelLength): TFresnelLength;
|
|
|
|
+ function FitHeight(aHeight: TFresnelLength): TFresnelLength;
|
|
|
|
+ procedure ResetUsedLengths; virtual;
|
|
{$IF FPC_FULLVERSION>=30301}
|
|
{$IF FPC_FULLVERSION>=30301}
|
|
procedure SortNodes(const Compare: TListSortComparer_Context; Context: Pointer = nil); virtual;
|
|
procedure SortNodes(const Compare: TListSortComparer_Context; Context: Pointer = nil); virtual;
|
|
{$ELSE}
|
|
{$ELSE}
|
|
@@ -858,31 +933,27 @@ type
|
|
property NodeCount: integer read GetNodeCount;
|
|
property NodeCount: integer read GetNodeCount;
|
|
property Nodes[Index: integer]: TFresnelLayoutNode read GetNodes;
|
|
property Nodes[Index: integer]: TFresnelLayoutNode read GetNodes;
|
|
end;
|
|
end;
|
|
- TFLLayoutNode = TFresnelLayoutNode;
|
|
|
|
- TFresnelLayoutElDataClass = class of TFresnelLayoutNode;
|
|
|
|
|
|
+ TFresnelLayoutNodeClass = class of TFresnelLayoutNode;
|
|
|
|
|
|
{ TFresnelLayouter }
|
|
{ TFresnelLayouter }
|
|
|
|
|
|
TFresnelLayouter = class(TComponent)
|
|
TFresnelLayouter = class(TComponent)
|
|
public
|
|
public
|
|
- procedure Apply(aViewport: TFresnelViewport); virtual; abstract;
|
|
|
|
- procedure ComputeCSSLayoutNode(El: TFresnelElement); virtual; abstract;
|
|
|
|
- procedure ComputedChildrenCSS(El: TFresnelElement); virtual; abstract;
|
|
|
|
|
|
+ procedure Apply; virtual; abstract;
|
|
end;
|
|
end;
|
|
TFLLayouter = TFresnelLayouter;
|
|
TFLLayouter = TFresnelLayouter;
|
|
TFresnelLayouterClass = class of TFresnelLayouter;
|
|
TFresnelLayouterClass = class of TFresnelLayouter;
|
|
|
|
|
|
{ IFresnelFont }
|
|
{ IFresnelFont }
|
|
|
|
|
|
- IFresnelFont = interface
|
|
|
|
- ['{6B53C662-5598-419B-996B-7E839271B64E}']
|
|
|
|
|
|
+ IFresnelFont = interface ['{6B53C662-5598-419B-996B-7E839271B64E}']
|
|
function GetFamily: string;
|
|
function GetFamily: string;
|
|
function GetKerning: TFresnelCSSKerning;
|
|
function GetKerning: TFresnelCSSKerning;
|
|
function GetSize: TFresnelLength; // in pixel
|
|
function GetSize: TFresnelLength; // in pixel
|
|
function GetStyle: string;
|
|
function GetStyle: string;
|
|
function GetVariant: string;
|
|
function GetVariant: string;
|
|
function GetWeight: TFresnelLength; // 0..750
|
|
function GetWeight: TFresnelLength; // 0..750
|
|
- function GetWidth: TFresnelLength; // in percent
|
|
|
|
|
|
+ function GetWidth: TFresnelLength; // 1 = default
|
|
function TextSize(const aText: string): TFresnelPoint;
|
|
function TextSize(const aText: string): TFresnelPoint;
|
|
function TextSizeMaxWidth(const aText: string; MaxWidth: TFresnelLength): TFresnelPoint;
|
|
function TextSizeMaxWidth(const aText: string; MaxWidth: TFresnelLength): TFresnelPoint;
|
|
function GetTool: TObject;
|
|
function GetTool: TObject;
|
|
@@ -923,7 +994,7 @@ type
|
|
Style: string;
|
|
Style: string;
|
|
Variant_: string;
|
|
Variant_: string;
|
|
Weight: TFresnelLength; // 100..750
|
|
Weight: TFresnelLength; // 100..750
|
|
- Width: TFresnelLength; // in percent
|
|
|
|
|
|
+ Width: TFresnelLength; // 1 = default
|
|
function Compare(const Desc: TFresnelFontDesc): integer;
|
|
function Compare(const Desc: TFresnelFontDesc): integer;
|
|
class function CompareDescriptors(const A, B: TFresnelFontDesc): integer; static;
|
|
class function CompareDescriptors(const A, B: TFresnelFontDesc): integer; static;
|
|
end;
|
|
end;
|
|
@@ -961,9 +1032,7 @@ type
|
|
private
|
|
private
|
|
FAfterRender: TNotifyEvent;
|
|
FAfterRender: TNotifyEvent;
|
|
FBeforeRender: TNotifyEvent;
|
|
FBeforeRender: TNotifyEvent;
|
|
- FComputedBorderBox: TFresnelRect;
|
|
|
|
FComputedBoxSizing: TCSSNumericalID;
|
|
FComputedBoxSizing: TCSSNumericalID;
|
|
- FComputedContentBox: TFresnelRect;
|
|
|
|
FComputedDirection: TCSSNumericalID;
|
|
FComputedDirection: TCSSNumericalID;
|
|
FComputedVisibility: TCSSNumericalID;
|
|
FComputedVisibility: TCSSNumericalID;
|
|
FComputedWritingMode: TCSSNumericalID;
|
|
FComputedWritingMode: TCSSNumericalID;
|
|
@@ -978,6 +1047,8 @@ type
|
|
// Todo: change to dictionary to reduce mem footprint
|
|
// Todo: change to dictionary to reduce mem footprint
|
|
FStandardEvents : Array[0..evtLastEvent] of TEventHandlerItem;
|
|
FStandardEvents : Array[0..evtLastEvent] of TEventHandlerItem;
|
|
FEventDispatcher : TFresnelEventDispatcher;
|
|
FEventDispatcher : TFresnelEventDispatcher;
|
|
|
|
+ FUsedBorderBox: TFresnelRect;
|
|
|
|
+ FUsedContentBox: TFresnelRect;
|
|
function GetNodeCount: integer;
|
|
function GetNodeCount: integer;
|
|
function GetNodes(Index: integer): TFresnelElement;
|
|
function GetNodes(Index: integer): TFresnelElement;
|
|
function GetViewportConnected: boolean;
|
|
function GetViewportConnected: boolean;
|
|
@@ -1030,7 +1101,7 @@ type
|
|
procedure SetParentComponent(Value: TComponent); override;
|
|
procedure SetParentComponent(Value: TComponent); override;
|
|
procedure ChildDestroying(El: TFresnelElement); virtual;
|
|
procedure ChildDestroying(El: TFresnelElement); virtual;
|
|
procedure DoRender({%H-}aRenderer: IFresnelRenderer); virtual;
|
|
procedure DoRender({%H-}aRenderer: IFresnelRenderer); virtual;
|
|
- { IFResnelRenderable }
|
|
|
|
|
|
+ { IFresnelRenderable }
|
|
Procedure BeforeRender;
|
|
Procedure BeforeRender;
|
|
Procedure AfterRender;
|
|
Procedure AfterRender;
|
|
Procedure Render(aRenderer : IFresnelRenderer);
|
|
Procedure Render(aRenderer : IFresnelRenderer);
|
|
@@ -1080,10 +1151,12 @@ type
|
|
// CSS computed attributes
|
|
// CSS computed attributes
|
|
procedure ComputeStyleElement; virtual; // parse inline style
|
|
procedure ComputeStyleElement; virtual; // parse inline style
|
|
procedure ComputeCSSValues; virtual; // call resolver to collect CSS values and resolve shorthands
|
|
procedure ComputeCSSValues; virtual; // call resolver to collect CSS values and resolve shorthands
|
|
- procedure ComputeCSSAfterLayoutNode(Layouter: TFresnelLayouter); virtual; // after layouter node, before layouter traverse children
|
|
|
|
|
|
+ procedure ComputeCSSAfterLayoutNode(Layouter: TFresnelLayouter); virtual; // called after layouter node, before layouter traverse children
|
|
function GetCSSString(AttrID: TCSSNumericalID; Compute: boolean; out Complete: boolean): string; virtual;
|
|
function GetCSSString(AttrID: TCSSNumericalID; Compute: boolean; out Complete: boolean): string; virtual;
|
|
- function GetComputedLength(Attr: TFresnelCSSAttribute; UseNaNOnFail: boolean = false): TFresnelLength; virtual; overload;
|
|
|
|
- function GetComputedLength(const aComp: TCSSResCompValue; Attr: TFresnelCSSAttribute; UseNaNOnFail: boolean = false): TFresnelLength; virtual; overload;
|
|
|
|
|
|
+ function GetComputedLength(Attr: TFresnelCSSAttribute; UseNaNOnFail: boolean = false; NoChildren: boolean = false): TFresnelLength; virtual; overload;
|
|
|
|
+ function GetComputedLength(AttrID: TCSSNumericalID; UseNaNOnFail: boolean = false; NoChildren: boolean = false): TFresnelLength; virtual; overload;
|
|
|
|
+ function GetComputedLength(const aComp: TCSSResCompValue; AttrID: TCSSNumericalID;
|
|
|
|
+ UseNaNOnFail: boolean = false; NoChildren: boolean = false): TFresnelLength; virtual; overload;
|
|
function GetComputedString(Attr: TFresnelCSSAttribute): string; virtual;
|
|
function GetComputedString(Attr: TFresnelCSSAttribute): string; virtual;
|
|
function GetComputedCSSString(AttrID: TCSSNumericalID): string; virtual; overload;
|
|
function GetComputedCSSString(AttrID: TCSSNumericalID): string; virtual; overload;
|
|
function GetComputedCSSString(const AttrName: string): string; overload;
|
|
function GetComputedCSSString(const AttrName: string): string; overload;
|
|
@@ -1098,6 +1171,7 @@ type
|
|
function GetComputedAlignContent(out SubKW: TCSSNumericalID): TCSSNumericalID; virtual;
|
|
function GetComputedAlignContent(out SubKW: TCSSNumericalID): TCSSNumericalID; virtual;
|
|
function GetComputedAlignItems(out SubKW: TCSSNumericalID): TCSSNumericalID; virtual;
|
|
function GetComputedAlignItems(out SubKW: TCSSNumericalID): TCSSNumericalID; virtual;
|
|
function GetComputedAlignSelf(out SubKW: TCSSNumericalID): TCSSNumericalID; virtual;
|
|
function GetComputedAlignSelf(out SubKW: TCSSNumericalID): TCSSNumericalID; virtual;
|
|
|
|
+ function GetComputedBackgroundOrigin: TCSSNumericalID; virtual;
|
|
procedure GetComputedMarginBlockStartEndAttr(out aStartAttr, aEndAttr: TFresnelCSSAttribute); virtual;
|
|
procedure GetComputedMarginBlockStartEndAttr(out aStartAttr, aEndAttr: TFresnelCSSAttribute); virtual;
|
|
procedure GetComputedMarginInlineStartEndAttr(out aStartAttr, aEndAttr: TFresnelCSSAttribute); virtual;
|
|
procedure GetComputedMarginInlineStartEndAttr(out aStartAttr, aEndAttr: TFresnelCSSAttribute); virtual;
|
|
function GetComputedTextShadow(out aOffsetX, aOffsetY, aRadius: TFresnelLength; out aColor: TFPColor): boolean; virtual; // on fail returns 0
|
|
function GetComputedTextShadow(out aOffsetX, aOffsetY, aRadius: TFresnelLength; out aColor: TFPColor): boolean; virtual; // on fail returns 0
|
|
@@ -1108,9 +1182,7 @@ type
|
|
procedure SetComputedCSSString(Attr: TFresnelCSSAttribute; const Value: string); virtual;
|
|
procedure SetComputedCSSString(Attr: TFresnelCSSAttribute; const Value: string); virtual;
|
|
procedure WriteComputedAttributes(Title: string);
|
|
procedure WriteComputedAttributes(Title: string);
|
|
property ComputedAttribute[Attr: TFresnelCSSAttribute]: string read GetComputedString write SetComputedCSSString;
|
|
property ComputedAttribute[Attr: TFresnelCSSAttribute]: string read GetComputedString write SetComputedCSSString;
|
|
- property ComputedBorderBox: TFresnelRect read FComputedBorderBox write FComputedBorderBox; // relative to layout parent
|
|
|
|
property ComputedBoxSizing: TCSSNumericalID read FComputedBoxSizing;
|
|
property ComputedBoxSizing: TCSSNumericalID read FComputedBoxSizing;
|
|
- property ComputedContentBox: TFresnelRect read FComputedContentBox write FComputedContentBox; // relative to layout parent
|
|
|
|
property ComputedDirection: TCSSNumericalID read FComputedDirection;
|
|
property ComputedDirection: TCSSNumericalID read FComputedDirection;
|
|
property ComputedDisplayInside: TCSSNumericalID read FComputedDisplayInside;
|
|
property ComputedDisplayInside: TCSSNumericalID read FComputedDisplayInside;
|
|
property ComputedDisplayOutside: TCSSNumericalID read FComputedDisplayOutside;
|
|
property ComputedDisplayOutside: TCSSNumericalID read FComputedDisplayOutside;
|
|
@@ -1120,24 +1192,20 @@ type
|
|
// CSS pseudo classes
|
|
// CSS pseudo classes
|
|
property CSSPseudoClass[Pseudo: TFresnelCSSPseudoClass]: boolean read GetCSSPseudoClass write SetCSSPseudoClass;
|
|
property CSSPseudoClass[Pseudo: TFresnelCSSPseudoClass]: boolean read GetCSSPseudoClass write SetCSSPseudoClass;
|
|
// layouter
|
|
// layouter
|
|
- function GetMaxWidthIntrinsicContentBox: TFresnelLength; virtual; // this element, excluding children, ignoring max-width
|
|
|
|
- function GetMaxWidthContentBox: TFresnelLength; virtual; // this element, excluding children
|
|
|
|
- function GetMaxWidthBorderBox: TFresnelLength; virtual; // this element, excluding children
|
|
|
|
- function GetMinWidthIntrinsicContentBox: TFresnelLength; virtual; // this element, excluding children, ignoring min-width
|
|
|
|
- function GetMinWidthContentBox: TFresnelLength; virtual; // this element, excluding children
|
|
|
|
- function GetMinWidthBorderBox: TFresnelLength; virtual; // this element, excluding children
|
|
|
|
- function GetPreferredContentBox_MaxWidth(MaxWidth: TFresnelLength): TFresnelPoint; virtual; // this element, excluding children, cannot be NaN
|
|
|
|
- function GetPreferredBorderBox_MaxWidth(MaxWidth: TFresnelLength): TFresnelPoint; virtual; // this element, excluding children, cannot be NaN
|
|
|
|
- function GetBlockContainer: TFresnelElement; virtual;
|
|
|
|
- function GetBlockContainerWH(IsHorizontal: boolean; UseNaNOnFail: boolean): TFresnelLength; virtual;
|
|
|
|
|
|
+ function GetIntrinsicContentSize(aMode: TFresnelLayoutMode; aMaxWidth: TFresnelLength = NaN; aMaxHeight: TFresnelLength = NaN): TFresnelPoint; virtual; // ignoring min|max-height
|
|
|
|
+ function GetContainer: TFresnelElement; virtual;
|
|
|
|
+ function GetContainerContentWidth(UseNaNOnFail: boolean): TFresnelLength; virtual; // used value
|
|
|
|
+ function GetContainerContentHeight(UseNaNOnFail: boolean): TFresnelLength; virtual; // used value
|
|
function IsBlockFormattingContext: boolean; virtual;
|
|
function IsBlockFormattingContext: boolean; virtual;
|
|
property DOMIndex: integer read FDOMIndex write FDOMIndex;
|
|
property DOMIndex: integer read FDOMIndex write FDOMIndex;
|
|
property LayoutNode: TFresnelLayoutNode read FLayoutNode write FLayoutNode;
|
|
property LayoutNode: TFresnelLayoutNode read FLayoutNode write FLayoutNode;
|
|
|
|
+ property UsedBorderBox: TFresnelRect read FUsedBorderBox write FUsedBorderBox; // relative to layout parent's used contentbox
|
|
|
|
+ property UsedContentBox: TFresnelRect read FUsedContentBox write FUsedContentBox; // relative to layout parent's used contentbox
|
|
// renderer
|
|
// renderer
|
|
function GetBoundingClientRect: TFresnelRect; virtual;
|
|
function GetBoundingClientRect: TFresnelRect; virtual;
|
|
property Rendered: boolean read FRendered write FRendered;
|
|
property Rendered: boolean read FRendered write FRendered;
|
|
- property RenderedBorderBox: TFresnelRect read FRenderedBorderBox write FRenderedBorderBox; // relative to layout parent
|
|
|
|
- property RenderedContentBox: TFresnelRect read FRenderedContentBox write FRenderedContentBox; // relative to layout parent
|
|
|
|
|
|
+ property RenderedBorderBox: TFresnelRect read FRenderedBorderBox write FRenderedBorderBox; // relative to layout parent's rendered contentbox
|
|
|
|
+ property RenderedContentBox: TFresnelRect read FRenderedContentBox write FRenderedContentBox; // relative to layout parent's rendered contentbox
|
|
// Events
|
|
// Events
|
|
function AddEventListener(aID : TEventID; aHandler : TFresnelEventHandler) : Integer;
|
|
function AddEventListener(aID : TEventID; aHandler : TFresnelEventHandler) : Integer;
|
|
Function AddEventListener(Const aName: TEventName; aHandler : TFresnelEventHandler) : Integer;
|
|
Function AddEventListener(Const aName: TEventName; aHandler : TFresnelEventHandler) : Integer;
|
|
@@ -1166,6 +1234,13 @@ type
|
|
TFresnelElementClass = class of TFresnelElement;
|
|
TFresnelElementClass = class of TFresnelElement;
|
|
TFresnelElementArray = array of TFresnelElement;
|
|
TFresnelElementArray = array of TFresnelElement;
|
|
|
|
|
|
|
|
+ { TReplacedElement - base class for elements with special content and no child elements, e.g. label, video }
|
|
|
|
+
|
|
|
|
+ TReplacedElement = class(TFresnelElement)
|
|
|
|
+ public
|
|
|
|
+ function AcceptChildrenAtDesignTime: boolean; override;
|
|
|
|
+ end;
|
|
|
|
+
|
|
TFresnelViewportLength = (
|
|
TFresnelViewportLength = (
|
|
vlFontMinSize,
|
|
vlFontMinSize,
|
|
vlDPIHorizontal,
|
|
vlDPIHorizontal,
|
|
@@ -1201,14 +1276,12 @@ type
|
|
FScrollbarWidth: array[boolean] of TFresnelLength;
|
|
FScrollbarWidth: array[boolean] of TFresnelLength;
|
|
FHeight: TFresnelLength;
|
|
FHeight: TFresnelLength;
|
|
FWidth: TFresnelLength;
|
|
FWidth: TFresnelLength;
|
|
- FMaxPreferredWidth: TFresnelLength;
|
|
|
|
procedure CSSResolverLog(Sender: TObject; Entry: TCSSResolverLogEntry);
|
|
procedure CSSResolverLog(Sender: TObject; Entry: TCSSResolverLogEntry);
|
|
protected
|
|
protected
|
|
class var FFresnelEventsRegistered: boolean;
|
|
class var FFresnelEventsRegistered: boolean;
|
|
protected
|
|
protected
|
|
function GetDPI(IsHorizontal: boolean): TFresnelLength; override;
|
|
function GetDPI(IsHorizontal: boolean): TFresnelLength; override;
|
|
function GetHeight: TFresnelLength; virtual;
|
|
function GetHeight: TFresnelLength; virtual;
|
|
- function GetMaxPreferredWidth: TFresnelLength; virtual;
|
|
|
|
function GetScrollbarWidth(IsHorizontal: boolean): TFresnelLength; virtual;
|
|
function GetScrollbarWidth(IsHorizontal: boolean): TFresnelLength; virtual;
|
|
function GetVPLength(l: TFresnelViewportLength): TFresnelLength; virtual;
|
|
function GetVPLength(l: TFresnelViewportLength): TFresnelLength; virtual;
|
|
function GetWidth: TFresnelLength; virtual;
|
|
function GetWidth: TFresnelLength; virtual;
|
|
@@ -1220,7 +1293,6 @@ type
|
|
procedure SetDPI(IsHorizontal: boolean; const AValue: TFresnelLength);
|
|
procedure SetDPI(IsHorizontal: boolean; const AValue: TFresnelLength);
|
|
procedure SetFontMinSize(const AValue: TFresnelLength); virtual;
|
|
procedure SetFontMinSize(const AValue: TFresnelLength); virtual;
|
|
procedure SetHeight(AValue: TFresnelLength); virtual;
|
|
procedure SetHeight(AValue: TFresnelLength); virtual;
|
|
- procedure SetMaxPreferredWidth(const AValue: TFresnelLength); virtual;
|
|
|
|
procedure SetScrollbarWidth(IsHorizontal: boolean;
|
|
procedure SetScrollbarWidth(IsHorizontal: boolean;
|
|
const AValue: TFresnelLength); virtual;
|
|
const AValue: TFresnelLength); virtual;
|
|
procedure SetStylesheet(AValue: TStrings); virtual;
|
|
procedure SetStylesheet(AValue: TStrings); virtual;
|
|
@@ -1253,7 +1325,6 @@ type
|
|
property StylesheetStamp: TCSSNumericalID read FStylesheetStamp;
|
|
property StylesheetStamp: TCSSNumericalID read FStylesheetStamp;
|
|
property Width: TFresnelLength read GetWidth write SetWidth;
|
|
property Width: TFresnelLength read GetWidth write SetWidth;
|
|
property Height: TFresnelLength read GetHeight write SetHeight;
|
|
property Height: TFresnelLength read GetHeight write SetHeight;
|
|
- property MaxPreferredWidth: TFresnelLength read GetMaxPreferredWidth write SetMaxPreferredWidth;
|
|
|
|
property Layouter: TFresnelLayouter read FLayouter write FLayouter;
|
|
property Layouter: TFresnelLayouter read FLayouter write FLayouter;
|
|
property FontEngine: TFresnelFontEngine read FFontEngine write FFontEngine;
|
|
property FontEngine: TFresnelFontEngine read FFontEngine write FFontEngine;
|
|
property OnDomChanged: TNotifyEvent read FOnDomChanged write FOnDomChanged;
|
|
property OnDomChanged: TNotifyEvent read FOnDomChanged write FOnDomChanged;
|
|
@@ -4385,6 +4456,42 @@ begin
|
|
Result:=anAlign+' '+aJustify;
|
|
Result:=anAlign+' '+aJustify;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TFresnelCSSRegistry.GetLength_ContainerContentWidth(const aComp: TCSSResCompValue;
|
|
|
|
+ El: TFresnelElement; NoChildren: boolean): TFresnelLength;
|
|
|
|
+begin
|
|
|
|
+ if (aComp.Kind=rvkFloat) and (aComp.FloatUnit=cuPercent) then
|
|
|
|
+ Result:=El.GetContainerContentWidth(true)
|
|
|
|
+ else
|
|
|
|
+ Result:=NaN;
|
|
|
|
+ if NoChildren then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetLength_ContainerContentHeight(const aComp: TCSSResCompValue;
|
|
|
|
+ El: TFresnelElement; NoChildren: boolean): TFresnelLength;
|
|
|
|
+begin
|
|
|
|
+ if (aComp.Kind=rvkFloat) and (aComp.FloatUnit=cuPercent) then
|
|
|
|
+ Result:=El.GetContainerContentHeight(true)
|
|
|
|
+ else
|
|
|
|
+ Result:=NaN;
|
|
|
|
+ if NoChildren then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetLength_BorderWidth(const aComp: TCSSResCompValue;
|
|
|
|
+ El: TFresnelElement; NoChildren: boolean): TFresnelLength;
|
|
|
|
+begin
|
|
|
|
+ case aComp.Kind of
|
|
|
|
+ rvkKeyword:
|
|
|
|
+ case aComp.KeywordID of
|
|
|
|
+ kwThin: exit(0.5);
|
|
|
|
+ kwMedium: exit(1);
|
|
|
|
+ kwThick: exit(2);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ Result:=NaN;
|
|
|
|
+ if NoChildren then ;
|
|
|
|
+ if El=nil then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TFresnelCSSRegistry.RoundFontWidth(aWidth: TFresnelLength): TFontWidthName;
|
|
function TFresnelCSSRegistry.RoundFontWidth(aWidth: TFresnelLength): TFontWidthName;
|
|
var
|
|
var
|
|
fw: TFontWidthName;
|
|
fw: TFontWidthName;
|
|
@@ -4654,10 +4761,10 @@ begin
|
|
kwBothInline,kwBothBlock,kwBoth];
|
|
kwBothInline,kwBothBlock,kwBoth];
|
|
|
|
|
|
// top, right, bottom, left
|
|
// top, right, bottom, left
|
|
- AddFresnelLonghand(fcaTop,false,@CheckLeftTopRightBottom,'auto');
|
|
|
|
- AddFresnelLonghand(fcaRight,false,@CheckLeftTopRightBottom,'auto');
|
|
|
|
- AddFresnelLonghand(fcaBottom,false,@CheckLeftTopRightBottom,'auto');
|
|
|
|
- AddFresnelLonghand(fcaLeft,false,@CheckLeftTopRightBottom,'auto');
|
|
|
|
|
|
+ AddFresnelLonghandLength(fcaTop,false,@CheckLeftTopRightBottom,false,'auto',@GetLength_ContainerContentHeight);
|
|
|
|
+ AddFresnelLonghandLength(fcaRight,false,@CheckLeftTopRightBottom,true,'auto',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaBottom,false,@CheckLeftTopRightBottom,false,'auto',@GetLength_ContainerContentHeight);
|
|
|
|
+ AddFresnelLonghandLength(fcaLeft,false,@CheckLeftTopRightBottom,true,'auto',@GetLength_ContainerContentWidth);
|
|
with Chk_LeftTopRightBottom_Dim do begin
|
|
with Chk_LeftTopRightBottom_Dim do begin
|
|
AllowedUnits:=cuAllLengthsAndPercent;
|
|
AllowedUnits:=cuAllLengthsAndPercent;
|
|
AllowNegative:=true;
|
|
AllowNegative:=true;
|
|
@@ -4666,23 +4773,23 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
// width, height
|
|
// width, height
|
|
- AddFresnelLonghand(fcaWidth,false,@CheckWidthHeight,'auto');
|
|
|
|
- AddFresnelLonghand(fcaHeight,false,@CheckWidthHeight,'auto');
|
|
|
|
|
|
+ AddFresnelLonghandLength(fcaWidth,false,@CheckWidthHeight,true,'auto',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaHeight,false,@CheckWidthHeight,false,'auto',@GetLength_ContainerContentHeight);
|
|
Chk_WidthHeight_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_WidthHeight_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_WidthHeight_Dim.AllowFrac:=true;
|
|
Chk_WidthHeight_Dim.AllowFrac:=true;
|
|
Chk_WidthHeight_Dim.AllowedKeywordIDs:=[kwAuto,kwFitContent,kwMinContent,kwMaxContent];
|
|
Chk_WidthHeight_Dim.AllowedKeywordIDs:=[kwAuto,kwFitContent,kwMinContent,kwMaxContent];
|
|
|
|
|
|
// min-width, max-width, min-height, max-height
|
|
// min-width, max-width, min-height, max-height
|
|
- AddFresnelLonghand(fcaMinWidth,false,@CheckWidthHeight,'auto');
|
|
|
|
- AddFresnelLonghand(fcaMaxWidth,false,@CheckWidthHeight,'auto');
|
|
|
|
- AddFresnelLonghand(fcaMinHeight,false,@CheckWidthHeight,'auto');
|
|
|
|
- AddFresnelLonghand(fcaMaxHeight,false,@CheckWidthHeight,'auto');
|
|
|
|
|
|
+ AddFresnelLonghandLength(fcaMinWidth,false,@CheckWidthHeight,true,'auto',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaMaxWidth,false,@CheckWidthHeight,false,'auto',@GetLength_ContainerContentHeight);
|
|
|
|
+ AddFresnelLonghandLength(fcaMinHeight,false,@CheckWidthHeight,true,'auto',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaMaxHeight,false,@CheckWidthHeight,false,'auto',@GetLength_ContainerContentHeight);
|
|
|
|
|
|
// border-width
|
|
// border-width
|
|
- AddFresnelLonghand(fcaBorderTopWidth,false,@CheckBorderWidth,'medium');
|
|
|
|
- AddFresnelLonghand(fcaBorderRightWidth,false,@CheckBorderWidth,'medium');
|
|
|
|
- AddFresnelLonghand(fcaBorderBottomWidth,false,@CheckBorderWidth,'medium');
|
|
|
|
- AddFresnelLonghand(fcaBorderLeftWidth,false,@CheckBorderWidth,'medium');
|
|
|
|
|
|
+ AddFresnelLonghandLength(fcaBorderTopWidth,false,@CheckBorderWidth,false,'medium',@GetLength_BorderWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaBorderRightWidth,false,@CheckBorderWidth,true,'medium',@GetLength_BorderWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaBorderBottomWidth,false,@CheckBorderWidth,false,'medium',@GetLength_BorderWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaBorderLeftWidth,false,@CheckBorderWidth,true,'medium',@GetLength_BorderWidth);
|
|
Chk_BorderWidth_Dim.AllowedUnits:=cuAllLengths;
|
|
Chk_BorderWidth_Dim.AllowedUnits:=cuAllLengths;
|
|
Chk_BorderWidth_Dim.AllowFrac:=true;
|
|
Chk_BorderWidth_Dim.AllowFrac:=true;
|
|
Chk_BorderWidth_Dim.AllowedKeywordIDs:=[kwThin,kwMedium,kwThick];
|
|
Chk_BorderWidth_Dim.AllowedKeywordIDs:=[kwThin,kwMedium,kwThick];
|
|
@@ -4799,11 +4906,11 @@ begin
|
|
Chk_TextShadow_Radius_Dim.AllowedUnits:=cuAllLengths;
|
|
Chk_TextShadow_Radius_Dim.AllowedUnits:=cuAllLengths;
|
|
Chk_TextShadow_Radius_Dim.AllowFrac:=true;
|
|
Chk_TextShadow_Radius_Dim.AllowFrac:=true;
|
|
|
|
|
|
- // margin
|
|
|
|
- AddFresnelLonghand(fcaMarginTop,false,@CheckMargin,'0');
|
|
|
|
- AddFresnelLonghand(fcaMarginRight,false,@CheckMargin,'0');
|
|
|
|
- AddFresnelLonghand(fcaMarginBottom,false,@CheckMargin,'0');
|
|
|
|
- AddFresnelLonghand(fcaMarginLeft,false,@CheckMargin,'0');
|
|
|
|
|
|
+ // margin, Note: % uses container's width even for top and bottom
|
|
|
|
+ AddFresnelLonghandLength(fcaMarginTop,false,@CheckMargin,false,'0',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaMarginRight,false,@CheckMargin,true,'0',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaMarginBottom,false,@CheckMargin,false,'0',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaMarginLeft,false,@CheckMargin,true,'0',@GetLength_ContainerContentWidth);
|
|
Chk_Margin_Dim.AllowedKeywordIDs:=[kwAuto];
|
|
Chk_Margin_Dim.AllowedKeywordIDs:=[kwAuto];
|
|
Chk_Margin_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_Margin_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_Margin_Dim.AllowFrac:=true;
|
|
Chk_Margin_Dim.AllowFrac:=true;
|
|
@@ -4828,11 +4935,11 @@ begin
|
|
Chk_Opacity_Dim.AllowedUnits:=[cuNone,cuPercent];
|
|
Chk_Opacity_Dim.AllowedUnits:=[cuNone,cuPercent];
|
|
Chk_Opacity_Dim.AllowFrac:=true;
|
|
Chk_Opacity_Dim.AllowFrac:=true;
|
|
|
|
|
|
- // padding
|
|
|
|
- AddFresnelLonghand(fcaPaddingTop,false,@CheckPadding,'0');
|
|
|
|
- AddFresnelLonghand(fcaPaddingRight,false,@CheckPadding,'0');
|
|
|
|
- AddFresnelLonghand(fcaPaddingBottom,false,@CheckPadding,'0');
|
|
|
|
- AddFresnelLonghand(fcaPaddingLeft,false,@CheckPadding,'0');
|
|
|
|
|
|
+ // padding, Note: % uses container's width even for top and bottom
|
|
|
|
+ AddFresnelLonghandLength(fcaPaddingTop,false,@CheckPadding,false,'0',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaPaddingRight,false,@CheckPadding,true,'0',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaPaddingBottom,false,@CheckPadding,false,'0',@GetLength_ContainerContentWidth);
|
|
|
|
+ AddFresnelLonghandLength(fcaPaddingLeft,false,@CheckPadding,true,'0',@GetLength_ContainerContentWidth);
|
|
Chk_Padding_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_Padding_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_Padding_Dim.AllowFrac:=true;
|
|
Chk_Padding_Dim.AllowFrac:=true;
|
|
AddFresnelShorthand(fcaPadding,@CheckPadding,@SplitPadding,@GetPadding,
|
|
AddFresnelShorthand(fcaPadding,@CheckPadding,@SplitPadding,@GetPadding,
|
|
@@ -4855,13 +4962,13 @@ begin
|
|
// background-origin
|
|
// background-origin
|
|
AddFresnelLonghand(fcaBackgroundOrigin,false,@CheckBackgroundOrigin,'padding-box');
|
|
AddFresnelLonghand(fcaBackgroundOrigin,false,@CheckBackgroundOrigin,'padding-box');
|
|
Chk_BackgroundOrigin_KeywordIDs:=[kwContentBox,kwPaddingBox,kwBorderBox];
|
|
Chk_BackgroundOrigin_KeywordIDs:=[kwContentBox,kwPaddingBox,kwBorderBox];
|
|
- // background-position-x
|
|
|
|
- AddFresnelLonghand(fcaBackgroundPositionX,false,@CheckBackgroundPositionXY,'0%');
|
|
|
|
|
|
+ // background-position-x, % depends on background-origin
|
|
|
|
+ AddFresnelLonghandLength(fcaBackgroundPositionX,false,@CheckBackgroundPositionXY,true,'0%');
|
|
Chk_BackgroundPositionX_Dim.AllowedKeywordIDs:=[kwLeft,kwCenter,kwRight];
|
|
Chk_BackgroundPositionX_Dim.AllowedKeywordIDs:=[kwLeft,kwCenter,kwRight];
|
|
Chk_BackgroundPositionX_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_BackgroundPositionX_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_BackgroundPositionX_Dim.AllowFrac:=true;
|
|
Chk_BackgroundPositionX_Dim.AllowFrac:=true;
|
|
// background-position-y
|
|
// background-position-y
|
|
- AddFresnelLonghand(fcaBackgroundPositionY,false,@CheckBackgroundPositionXY,'0%');
|
|
|
|
|
|
+ AddFresnelLonghandLength(fcaBackgroundPositionY,false,@CheckBackgroundPositionXY,false,'0%');
|
|
Chk_BackgroundPositionY_Dim.AllowedKeywordIDs:=[kwTop,kwCenter,kwBottom];
|
|
Chk_BackgroundPositionY_Dim.AllowedKeywordIDs:=[kwTop,kwCenter,kwBottom];
|
|
Chk_BackgroundPositionY_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_BackgroundPositionY_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_BackgroundPositionY_Dim.AllowFrac:=true;
|
|
Chk_BackgroundPositionY_Dim.AllowFrac:=true;
|
|
@@ -4973,14 +5080,13 @@ begin
|
|
AddFresnelShorthand(fcaPlaceSelf,@CheckPlaceSelf,@SplitPlaceSelf,@GetPlaceSelf,
|
|
AddFresnelShorthand(fcaPlaceSelf,@CheckPlaceSelf,@SplitPlaceSelf,@GetPlaceSelf,
|
|
[fcaAlignSelf,fcaJustifySelf]);
|
|
[fcaAlignSelf,fcaJustifySelf]);
|
|
|
|
|
|
-
|
|
|
|
// column-gap
|
|
// column-gap
|
|
- AddFresnelLonghand(fcaColumnGap,false,@CheckColumnRowGap,'normal');
|
|
|
|
|
|
+ AddFresnelLonghandLength(fcaColumnGap,false,@CheckColumnRowGap,true,'normal',@GetLength_ContainerContentWidth);
|
|
|
|
+ // row-gap
|
|
|
|
+ AddFresnelLonghandLength(fcaRowGap,false,@CheckColumnRowGap,false,'normal',@GetLength_ContainerContentHeight);
|
|
Chk_ColumnRowGap_Dim.AllowedKeywordIDs:=[kwNormal];
|
|
Chk_ColumnRowGap_Dim.AllowedKeywordIDs:=[kwNormal];
|
|
Chk_ColumnRowGap_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_ColumnRowGap_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_ColumnRowGap_Dim.AllowFrac:=true;
|
|
Chk_ColumnRowGap_Dim.AllowFrac:=true;
|
|
- // column-row
|
|
|
|
- AddFresnelLonghand(fcaRowGap,false,@CheckColumnRowGap,'normal');
|
|
|
|
// gap
|
|
// gap
|
|
AddFresnelShorthand(fcaGap,@CheckGap,@SplitGap,@GetGap,[fcaColumnGap,fcaRowGap]);
|
|
AddFresnelShorthand(fcaGap,@CheckGap,@SplitGap,@GetGap,[fcaColumnGap,fcaRowGap]);
|
|
|
|
|
|
@@ -4995,6 +5101,7 @@ function TFresnelCSSRegistry.AddFresnelAttr(Attr: TFresnelCSSAttribute;
|
|
begin
|
|
begin
|
|
Result:=TFresnelCSSAttrDesc(AddAttribute(FresnelCSSAttributeNames[Attr],'',aInherits,true,TFresnelCSSAttrDesc));
|
|
Result:=TFresnelCSSAttrDesc(AddAttribute(FresnelCSSAttributeNames[Attr],'',aInherits,true,TFresnelCSSAttrDesc));
|
|
Result.Attr:=Attr;
|
|
Result.Attr:=Attr;
|
|
|
|
+ Result.LengthHorizontal:=true;
|
|
Result.OnCheck:=OnCheck;
|
|
Result.OnCheck:=OnCheck;
|
|
FresnelAttrs[Attr]:=Result;
|
|
FresnelAttrs[Attr]:=Result;
|
|
end;
|
|
end;
|
|
@@ -5030,6 +5137,16 @@ begin
|
|
Result.InitialValue:=InitialValue;
|
|
Result.InitialValue:=InitialValue;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TFresnelCSSRegistry.AddFresnelLonghandLength(Attr: TFresnelCSSAttribute;
|
|
|
|
+ Inherits: boolean; const OnCheck: TCSSAttributeDesc.TCheckEvent; Horizontal: boolean;
|
|
|
|
+ const InitialValue: TCSSString; const OnGetLength: TFresnelElementAttrDesc.TGetLength
|
|
|
|
+ ): TFresnelCSSAttrDesc;
|
|
|
|
+begin
|
|
|
|
+ Result:=AddFresnelLonghand(Attr,Inherits,OnCheck,InitialValue);
|
|
|
|
+ Result.LengthHorizontal:=Horizontal;
|
|
|
|
+ Result.OnGetLength:=OnGetLength;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TFresnelCSSRegistry.SplitLonghandSides(var AttrIDs: TCSSNumericalIDArray;
|
|
procedure TFresnelCSSRegistry.SplitLonghandSides(var AttrIDs: TCSSNumericalIDArray;
|
|
var Values: TCSSStringArray; Top, Right, Bottom, Left: TFresnelCSSAttribute;
|
|
var Values: TCSSStringArray; Top, Right, Bottom, Left: TFresnelCSSAttribute;
|
|
const Found: TCSSStringArray);
|
|
const Found: TCSSStringArray);
|
|
@@ -5160,6 +5277,16 @@ begin
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TFresnelLayoutNode.GetIntrinsicContentSize(aMode: TFresnelLayoutMode;
|
|
|
|
+ aMaxWidth: TFresnelLength; aMaxHeight: TFresnelLength): TFresnelPoint;
|
|
|
|
+begin
|
|
|
|
+ Result.X:=0;
|
|
|
|
+ Result.Y:=0;
|
|
|
|
+ if aMode=flmMaxHeight then ;
|
|
|
|
+ if IsNan(aMaxWidth) then ;
|
|
|
|
+ if IsNan(aMaxHeight) then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TFresnelLayoutNode.GetRoot: TFresnelLayoutNode;
|
|
function TFresnelLayoutNode.GetRoot: TFresnelLayoutNode;
|
|
begin
|
|
begin
|
|
Result:=Self;
|
|
Result:=Self;
|
|
@@ -5167,6 +5294,66 @@ begin
|
|
Result:=Result.Parent;
|
|
Result:=Result.Parent;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TFresnelLayoutNode.FitWidth(aWidth: TFresnelLength): TFresnelLength;
|
|
|
|
+begin
|
|
|
|
+ Result:=aWidth;
|
|
|
|
+ if not IsNan(MinWidth) then
|
|
|
|
+ begin
|
|
|
|
+ if not IsNan(MaxWidth) then
|
|
|
|
+ Result:=MinWidth
|
|
|
|
+ else if (not IsNan(Result)) and (Result<MinWidth) then
|
|
|
|
+ Result:=MinWidth;
|
|
|
|
+ end else if (not IsNan(MaxWidth)) and (not IsNan(Result)) and (Result>MaxWidth) then
|
|
|
|
+ Result:=MaxWidth;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelLayoutNode.FitHeight(aHeight: TFresnelLength): TFresnelLength;
|
|
|
|
+begin
|
|
|
|
+ Result:=aHeight;
|
|
|
|
+ if not IsNan(MinHeight) then
|
|
|
|
+ begin
|
|
|
|
+ if not IsNan(MaxHeight) then
|
|
|
|
+ Result:=MinHeight
|
|
|
|
+ else if (not IsNan(Result)) and (Result<MinHeight) then
|
|
|
|
+ Result:=MinHeight;
|
|
|
|
+ end else if (not IsNan(MaxHeight)) and (not IsNan(Result)) and (Result>MaxHeight) then
|
|
|
|
+ Result:=MaxHeight;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TFresnelLayoutNode.ResetUsedLengths;
|
|
|
|
+begin
|
|
|
|
+ BorderLeft:=0;
|
|
|
|
+ BorderRight:=0;
|
|
|
|
+ BorderTop:=0;
|
|
|
|
+ BorderBottom:=0;
|
|
|
|
+ PaddingLeft:=0;
|
|
|
|
+ PaddingRight:=0;
|
|
|
|
+ PaddingTop:=0;
|
|
|
|
+ PaddingBottom:=0;
|
|
|
|
+ MarginLeft:=0;
|
|
|
|
+ MarginRight:=0;
|
|
|
|
+ MarginTop:=0;
|
|
|
|
+ MarginBottom:=0;
|
|
|
|
+ LineHeight:=0;
|
|
|
|
+
|
|
|
|
+ Left:=NaN;
|
|
|
|
+ Top:=NaN;
|
|
|
|
+ Right:=NaN;
|
|
|
|
+ Bottom:=NaN;
|
|
|
|
+
|
|
|
|
+ Width:=NaN;
|
|
|
|
+ Height:=NaN;
|
|
|
|
+ MinWidth:=NaN;
|
|
|
|
+ MinHeight:=NaN;
|
|
|
|
+ MaxWidth:=NaN;
|
|
|
|
+ MaxHeight:=NaN;
|
|
|
|
+
|
|
|
|
+ FContainerContentHeightValid:=false;
|
|
|
|
+ FContainerContentHeight:=NaN;
|
|
|
|
+ FContainerContentWidthValid:=false;
|
|
|
|
+ FContainerContentWidth:=NaN;
|
|
|
|
+end;
|
|
|
|
+
|
|
{$IF FPC_FULLVERSION>=30301}
|
|
{$IF FPC_FULLVERSION>=30301}
|
|
procedure TFresnelLayoutNode.SortNodes(
|
|
procedure TFresnelLayoutNode.SortNodes(
|
|
const Compare: TListSortComparer_Context; Context: Pointer);
|
|
const Compare: TListSortComparer_Context; Context: Pointer);
|
|
@@ -5230,11 +5417,6 @@ begin
|
|
Result:=FHeight;
|
|
Result:=FHeight;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TFresnelViewport.GetMaxPreferredWidth: TFresnelLength;
|
|
|
|
-begin
|
|
|
|
- Result:=FMaxPreferredWidth;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
function TFresnelViewport.GetVPLength(l: TFresnelViewportLength
|
|
function TFresnelViewport.GetVPLength(l: TFresnelViewportLength
|
|
): TFresnelLength;
|
|
): TFresnelLength;
|
|
begin
|
|
begin
|
|
@@ -5365,12 +5547,6 @@ begin
|
|
DomChanged;
|
|
DomChanged;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TFresnelViewport.SetMaxPreferredWidth(const AValue: TFresnelLength);
|
|
|
|
-begin
|
|
|
|
- if AValue=FMaxPreferredWidth then exit;
|
|
|
|
- FMaxPreferredWidth:=AValue;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
procedure TFresnelViewport.SetScrollbarWidth(IsHorizontal: boolean;
|
|
procedure TFresnelViewport.SetScrollbarWidth(IsHorizontal: boolean;
|
|
const AValue: TFresnelLength);
|
|
const AValue: TFresnelLength);
|
|
begin
|
|
begin
|
|
@@ -5436,21 +5612,6 @@ var
|
|
TraverseCSS(El.Nodes[i]);
|
|
TraverseCSS(El.Nodes[i]);
|
|
end;
|
|
end;
|
|
|
|
|
|
- procedure TraverseLayout(El: TFresnelElement);
|
|
|
|
- var
|
|
|
|
- i: Integer;
|
|
|
|
- begin
|
|
|
|
- // create or free layout nodes
|
|
|
|
- Layouter.ComputeCSSLayoutNode(El);
|
|
|
|
- El.ComputeCSSAfterLayoutNode(Layouter);
|
|
|
|
- //El.WriteComputedAttributes('TFresnelViewport.ApplyCSS');
|
|
|
|
-
|
|
|
|
- for i:=0 to El.NodeCount-1 do
|
|
|
|
- TraverseLayout(El.Nodes[i]);
|
|
|
|
-
|
|
|
|
- Layouter.ComputedChildrenCSS(El);
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
begin
|
|
begin
|
|
//writeln('TFresnelViewport.ApplyCSS ',Name,' Width=',FloatToCSSStr(Width),',Height=',FloatToCSSStr(Height));
|
|
//writeln('TFresnelViewport.ApplyCSS ',Name,' Width=',FloatToCSSStr(Width),',Height=',FloatToCSSStr(Height));
|
|
DomModified:=false;
|
|
DomModified:=false;
|
|
@@ -5463,7 +5624,7 @@ begin
|
|
CurDomIndex:=0;
|
|
CurDomIndex:=0;
|
|
TraverseCSS(Self);
|
|
TraverseCSS(Self);
|
|
// layout
|
|
// layout
|
|
- TraverseLayout(Self);
|
|
|
|
|
|
+ Layouter.Apply;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TFresnelViewport.DomChanged;
|
|
procedure TFresnelViewport.DomChanged;
|
|
@@ -5638,7 +5799,6 @@ begin
|
|
inherited Create(AOwner);
|
|
inherited Create(AOwner);
|
|
FViewPort:=Self;
|
|
FViewPort:=Self;
|
|
FWidth:=800;
|
|
FWidth:=800;
|
|
- FMaxPreferredWidth:=100000;
|
|
|
|
FHeight:=600;
|
|
FHeight:=600;
|
|
FDPI[false]:=FresnelDefaultDPI;
|
|
FDPI[false]:=FresnelDefaultDPI;
|
|
FDPI[true]:=FresnelDefaultDPI;
|
|
FDPI[true]:=FresnelDefaultDPI;
|
|
@@ -6236,70 +6396,78 @@ begin
|
|
UseInitialValue;
|
|
UseInitialValue;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TFresnelElement.GetComputedLength(Attr: TFresnelCSSAttribute; UseNaNOnFail: boolean
|
|
|
|
- ): TFresnelLength;
|
|
|
|
|
|
+function TFresnelElement.GetComputedLength(Attr: TFresnelCSSAttribute; UseNaNOnFail: boolean;
|
|
|
|
+ NoChildren: boolean): TFresnelLength;
|
|
var
|
|
var
|
|
- s: String;
|
|
|
|
- aComp: TCSSResCompValue;
|
|
|
|
AttrID: TCSSNumericalID;
|
|
AttrID: TCSSNumericalID;
|
|
|
|
+begin
|
|
|
|
+ AttrID:=CSSRegistry.FresnelAttrs[Attr].Index;
|
|
|
|
+ Result:=GetComputedLength(AttrID,UseNaNOnFail,NoChildren);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelElement.GetComputedLength(AttrID: TCSSNumericalID; UseNaNOnFail: boolean;
|
|
|
|
+ NoChildren: boolean): TFresnelLength;
|
|
|
|
+var
|
|
|
|
+ s: String;
|
|
Complete: boolean;
|
|
Complete: boolean;
|
|
|
|
+ aComp: TCSSResCompValue;
|
|
begin
|
|
begin
|
|
if UseNaNOnFail then
|
|
if UseNaNOnFail then
|
|
Result:=NaN
|
|
Result:=NaN
|
|
else
|
|
else
|
|
Result:=0;
|
|
Result:=0;
|
|
|
|
|
|
- AttrID:=CSSRegistry.FresnelAttrs[Attr].Index;
|
|
|
|
- s:=GetCSSString(AttrID,true,Complete);
|
|
|
|
|
|
+ s:=GetCSSString(AttrID,not NoChildren,Complete);
|
|
if s='' then exit;
|
|
if s='' then exit;
|
|
|
|
|
|
aComp.EndP:=PChar(s);
|
|
aComp.EndP:=PChar(s);
|
|
if (not Resolver.ReadComp(aComp)) or (aComp.Kind<>rvkFloat) then
|
|
if (not Resolver.ReadComp(aComp)) or (aComp.Kind<>rvkFloat) then
|
|
exit;
|
|
exit;
|
|
- Result:=GetComputedLength(aComp,Attr);
|
|
|
|
|
|
+ Result:=GetComputedLength(aComp,AttrID,UseNaNOnFail,NoChildren);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TFresnelElement.GetComputedLength(const aComp: TCSSResCompValue;
|
|
|
|
- Attr: TFresnelCSSAttribute; UseNaNOnFail: boolean): TFresnelLength;
|
|
|
|
|
|
+function TFresnelElement.GetComputedLength(const aComp: TCSSResCompValue; AttrID: TCSSNumericalID;
|
|
|
|
+ UseNaNOnFail: boolean; NoChildren: boolean): TFresnelLength;
|
|
|
|
|
|
- function GetIsHorizontal: boolean;
|
|
|
|
|
|
+ function ResolveSpecial(var aResult: TFresnelLength): boolean;
|
|
|
|
+ var
|
|
|
|
+ Desc: TCSSAttributeDesc;
|
|
|
|
+ ElDesc: TFresnelElementAttrDesc;
|
|
begin
|
|
begin
|
|
- Result:=Attr in [
|
|
|
|
- fcaLeft,
|
|
|
|
- fcaRight,
|
|
|
|
- fcaMinWidth,
|
|
|
|
- fcaMaxWidth,
|
|
|
|
- fcaWidth,
|
|
|
|
- fcaBorderLeftWidth,
|
|
|
|
- fcaBorderRightWidth,
|
|
|
|
- fcaMarginLeft,
|
|
|
|
- fcaMarginRight,
|
|
|
|
- fcaMarginTop, // margin-top, -bottom percentage uses the container width
|
|
|
|
- fcaMarginBottom,
|
|
|
|
- fcaPaddingLeft,
|
|
|
|
- fcaPaddingRight,
|
|
|
|
- fcaPaddingTop, // padding-top, -bottom percentage uses the container width
|
|
|
|
- fcaPaddingBottom,
|
|
|
|
- fcaBackgroundPositionX,
|
|
|
|
- fcaBackgroundSize,
|
|
|
|
- fcaColumnGap];
|
|
|
|
|
|
+ Result:=false;
|
|
|
|
+ Desc:=CSSRegistry.Attributes[AttrID];
|
|
|
|
+ if Desc is TFresnelElementAttrDesc then
|
|
|
|
+ begin
|
|
|
|
+ ElDesc:=TFresnelElementAttrDesc(Desc);
|
|
|
|
+ if ElDesc.OnGetLength<>nil then
|
|
|
|
+ begin
|
|
|
|
+ aResult:=ElDesc.OnGetLength(aComp,Self,NoChildren);
|
|
|
|
+ if not IsNan(aResult) then
|
|
|
|
+ exit(true);
|
|
|
|
+ if not UseNaNOnFail then
|
|
|
|
+ aResult:=0;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
var
|
|
var
|
|
- IsHorizontal: Boolean;
|
|
|
|
|
|
+ Desc: TCSSAttributeDesc;
|
|
|
|
+ Horizontal: Boolean;
|
|
begin
|
|
begin
|
|
if UseNaNOnFail then
|
|
if UseNaNOnFail then
|
|
Result:=NaN
|
|
Result:=NaN
|
|
else
|
|
else
|
|
Result:=0;
|
|
Result:=0;
|
|
- if (aComp.Kind<>rvkFloat) or IsNan(aComp.Float) then
|
|
|
|
|
|
+ if (aComp.Kind<>rvkFloat) then
|
|
|
|
+ begin
|
|
|
|
+ ResolveSpecial(Result);
|
|
exit;
|
|
exit;
|
|
|
|
+ end;
|
|
case aComp.FloatUnit of
|
|
case aComp.FloatUnit of
|
|
cuNone:
|
|
cuNone:
|
|
if aComp.Float=0 then
|
|
if aComp.Float=0 then
|
|
- begin
|
|
|
|
- exit(aComp.Float);
|
|
|
|
- end else begin
|
|
|
|
|
|
+ exit(0)
|
|
|
|
+ else begin
|
|
// number without unit is not allowed for pixel length
|
|
// number without unit is not allowed for pixel length
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
@@ -6307,34 +6475,16 @@ begin
|
|
exit(aComp.Float);
|
|
exit(aComp.Float);
|
|
cuPercent:
|
|
cuPercent:
|
|
begin
|
|
begin
|
|
- case Attr of
|
|
|
|
- fcaLeft,fcaRight,fcaWidth,fcaMinWidth,fcaMaxWidth:
|
|
|
|
- Result:=GetBlockContainerWH(true,UseNaNOnFail);
|
|
|
|
- fcaTop,fcaBottom,fcaHeight,fcaMinHeight,fcaMaxHeight:
|
|
|
|
- Result:=GetBlockContainerWH(false,UseNaNOnFail);
|
|
|
|
- else
|
|
|
|
- IsHorizontal:=GetIsHorizontal;
|
|
|
|
- if IsHorizontal then
|
|
|
|
- Result:=GetComputedLength(fcaWidth,UseNaNOnFail)
|
|
|
|
- else
|
|
|
|
- Result:=GetComputedLength(fcaHeight,UseNaNOnFail);
|
|
|
|
- end;
|
|
|
|
- if IsNan(Result) then
|
|
|
|
- begin
|
|
|
|
- if UseNaNOnFail then
|
|
|
|
- Result:=NaN
|
|
|
|
- else
|
|
|
|
- Result:=0;
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
|
|
+ if not ResolveSpecial(Result) then exit;
|
|
Result:=aComp.Float*Result/100;
|
|
Result:=aComp.Float*Result/100;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
if not (aComp.FloatUnit in cuAllLengths) then
|
|
if not (aComp.FloatUnit in cuAllLengths) then
|
|
exit;
|
|
exit;
|
|
- IsHorizontal:=GetIsHorizontal;
|
|
|
|
- Result:=aComp.Float*GetPixPerUnit(aComp.FloatUnit,IsHorizontal);
|
|
|
|
|
|
+ Desc:=CSSRegistry.Attributes[AttrID];
|
|
|
|
+ Horizontal:=(Desc is TFresnelElementAttrDesc) and TFresnelElementAttrDesc(Desc).LengthHorizontal;
|
|
|
|
+ Result:=aComp.Float*GetPixPerUnit(aComp.FloatUnit,Horizontal);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TFresnelElement.GetComputedString(Attr: TFresnelCSSAttribute): string;
|
|
function TFresnelElement.GetComputedString(Attr: TFresnelCSSAttribute): string;
|
|
@@ -6419,102 +6569,13 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TFresnelElement.GetMaxWidthIntrinsicContentBox: TFresnelLength;
|
|
|
|
-begin
|
|
|
|
- Result:=Viewport.MaxPreferredWidth;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TFresnelElement.GetMaxWidthContentBox: TFresnelLength;
|
|
|
|
-var
|
|
|
|
- aValue: String;
|
|
|
|
-begin
|
|
|
|
- aValue:=ComputedAttribute[fcaMinWidth];
|
|
|
|
- case aValue of
|
|
|
|
- '',
|
|
|
|
- 'auto': Result:=GetMaxWidthIntrinsicContentBox;
|
|
|
|
- 'max-content': Result:=GetPreferredContentBox_MaxWidth(Viewport.MaxPreferredWidth).X;
|
|
|
|
- 'min-content': Result:=GetMinWidthIntrinsicContentBox;
|
|
|
|
- else
|
|
|
|
- Result:=GetComputedLength(fcaMaxWidth,false);
|
|
|
|
- end;
|
|
|
|
- if Result<0 then
|
|
|
|
- Result:=0;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TFresnelElement.GetMaxWidthBorderBox: TFresnelLength;
|
|
|
|
-begin
|
|
|
|
- Result:=GetMinWidthContentBox;
|
|
|
|
- if IsNan(Result) or (Result<0) then
|
|
|
|
- Result:=0;
|
|
|
|
- // border and padding cannot be negative
|
|
|
|
- Result:=GetComputedLength(fcaBorderLeftWidth,false)
|
|
|
|
- +GetComputedLength(fcaBorderRightWidth,false)
|
|
|
|
- +GetComputedLength(fcaPaddingLeft,false)
|
|
|
|
- +GetComputedLength(fcaPaddingRight,false)
|
|
|
|
- +Result;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TFresnelElement.GetMinWidthIntrinsicContentBox: TFresnelLength;
|
|
|
|
-begin
|
|
|
|
- Result:=0;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TFresnelElement.GetMinWidthContentBox: TFresnelLength;
|
|
|
|
-var
|
|
|
|
- aValue: String;
|
|
|
|
-begin
|
|
|
|
- aValue:=ComputedAttribute[fcaMinWidth];
|
|
|
|
- case aValue of
|
|
|
|
- '',
|
|
|
|
- 'auto': Result:=GetMinWidthIntrinsicContentBox;
|
|
|
|
- 'max-content': Result:=GetPreferredContentBox_MaxWidth(Viewport.MaxPreferredWidth).X;
|
|
|
|
- 'min-content': Result:=GetMinWidthIntrinsicContentBox;
|
|
|
|
- else
|
|
|
|
- Result:=GetComputedLength(fcaMinWidth,false);
|
|
|
|
- end;
|
|
|
|
- if Result<0 then
|
|
|
|
- Result:=0;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TFresnelElement.GetMinWidthBorderBox: TFresnelLength;
|
|
|
|
-begin
|
|
|
|
- Result:=GetMinWidthContentBox;
|
|
|
|
- if IsNan(Result) or (Result<0) then
|
|
|
|
- Result:=0;
|
|
|
|
- // border and padding cannot be negative
|
|
|
|
- Result:=GetComputedLength(fcaBorderLeft,false)
|
|
|
|
- +GetComputedLength(fcaBorderRight,false)
|
|
|
|
- +GetComputedLength(fcaPaddingLeft,false)
|
|
|
|
- +GetComputedLength(fcaPaddingRight,false);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TFresnelElement.GetPreferredContentBox_MaxWidth(
|
|
|
|
- MaxWidth: TFresnelLength): TFresnelPoint;
|
|
|
|
-begin
|
|
|
|
- Result:=default(TFresnelPoint);
|
|
|
|
- if MaxWidth=0 then ;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TFresnelElement.GetPreferredBorderBox_MaxWidth(MaxWidth: TFresnelLength
|
|
|
|
- ): TFresnelPoint;
|
|
|
|
-var
|
|
|
|
- ExtraWidth, ExtraHeight: TFresnelLength;
|
|
|
|
|
|
+function TFresnelElement.GetIntrinsicContentSize(aMode: TFresnelLayoutMode;
|
|
|
|
+ aMaxWidth: TFresnelLength; aMaxHeight: TFresnelLength): TFresnelPoint;
|
|
begin
|
|
begin
|
|
- // border and padding cannot be negative
|
|
|
|
- ExtraWidth:=GetComputedLength(fcaBorderLeft,false)
|
|
|
|
- +GetComputedLength(fcaBorderRight,false)
|
|
|
|
- +GetComputedLength(fcaPaddingLeft,false)
|
|
|
|
- +GetComputedLength(fcaPaddingRight,false);
|
|
|
|
- ExtraHeight:=GetComputedLength(fcaBorderTop,false)
|
|
|
|
- +GetComputedLength(fcaBorderBottom,false)
|
|
|
|
- +GetComputedLength(fcaPaddingTop,false)
|
|
|
|
- +GetComputedLength(fcaPaddingBottom,false);
|
|
|
|
- Result:=GetPreferredContentBox_MaxWidth(Max(0,MaxWidth-ExtraWidth));
|
|
|
|
- Result.X:=Result.X+ExtraWidth;
|
|
|
|
- Result.Y:=Result.Y+ExtraHeight;
|
|
|
|
|
|
+ Result:=LayoutNode.GetIntrinsicContentSize(aMode,aMaxWidth,aMaxHeight);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TFresnelElement.GetBlockContainer: TFresnelElement;
|
|
|
|
|
|
+function TFresnelElement.GetContainer: TFresnelElement;
|
|
begin
|
|
begin
|
|
case ComputedPosition of
|
|
case ComputedPosition of
|
|
CSSRegistry.kwAbsolute:
|
|
CSSRegistry.kwAbsolute:
|
|
@@ -6552,25 +6613,34 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TFresnelElement.GetBlockContainerWH(IsHorizontal: boolean; UseNaNOnFail: boolean
|
|
|
|
- ): TFresnelLength;
|
|
|
|
|
|
+function TFresnelElement.GetContainerContentWidth(UseNaNOnFail: boolean): TFresnelLength;
|
|
var
|
|
var
|
|
El: TFresnelElement;
|
|
El: TFresnelElement;
|
|
begin
|
|
begin
|
|
- // e.g. 'width' uses width of block container
|
|
|
|
- El:=GetBlockContainer;
|
|
|
|
|
|
+ El:=LayoutNode.Container;
|
|
if El<>nil then
|
|
if El<>nil then
|
|
begin
|
|
begin
|
|
- if IsHorizontal then
|
|
|
|
- Result:=El.GetComputedLength(fcaWidth,UseNaNOnFail)
|
|
|
|
- else
|
|
|
|
- Result:=El.GetComputedLength(fcaHeight,UseNaNOnFail);
|
|
|
|
- end else begin
|
|
|
|
- if IsHorizontal then
|
|
|
|
- Result:=Viewport.Width
|
|
|
|
- else
|
|
|
|
- Result:=Viewport.Height;
|
|
|
|
- end;
|
|
|
|
|
|
+ Result:=El.LayoutNode.Width;
|
|
|
|
+ if not UseNaNOnFail and IsNan(Result) then Result:=0;
|
|
|
|
+ end else if UseNaNOnFail then
|
|
|
|
+ Result:=NaN
|
|
|
|
+ else
|
|
|
|
+ Result:=0;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelElement.GetContainerContentHeight(UseNaNOnFail: boolean): TFresnelLength;
|
|
|
|
+var
|
|
|
|
+ El: TFresnelElement;
|
|
|
|
+begin
|
|
|
|
+ El:=LayoutNode.Container;
|
|
|
|
+ if El<>nil then
|
|
|
|
+ begin
|
|
|
|
+ Result:=El.LayoutNode.Height;
|
|
|
|
+ if not UseNaNOnFail and IsNan(Result) then Result:=0;
|
|
|
|
+ end else if UseNaNOnFail then
|
|
|
|
+ Result:=NaN
|
|
|
|
+ else
|
|
|
|
+ Result:=0;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TFresnelElement.IsBlockFormattingContext: boolean;
|
|
function TFresnelElement.IsBlockFormattingContext: boolean;
|
|
@@ -6589,15 +6659,14 @@ begin
|
|
exit(true);
|
|
exit(true);
|
|
end;
|
|
end;
|
|
|
|
|
|
- if ComputedDisplayOutside in [CSSIDNone,CSSRegistry.kwNone] then
|
|
|
|
- exit(false);
|
|
|
|
-
|
|
|
|
case ComputedDisplayOutside of
|
|
case ComputedDisplayOutside of
|
|
|
|
+ CSSIDNone,
|
|
|
|
+ CSSRegistry.kwNone: exit(false);
|
|
CSSRegistry.kwBlock: exit(true);
|
|
CSSRegistry.kwBlock: exit(true);
|
|
end;
|
|
end;
|
|
|
|
|
|
case ComputedDisplayInside of
|
|
case ComputedDisplayInside of
|
|
- //CSSRegistry.kwtable,
|
|
|
|
|
|
+ //CSSRegistry.kwTable,
|
|
CSSRegistry.kwFlex,
|
|
CSSRegistry.kwFlex,
|
|
CSSRegistry.kwGrid,
|
|
CSSRegistry.kwGrid,
|
|
//CSSRegistry.kwRuby,
|
|
//CSSRegistry.kwRuby,
|
|
@@ -6832,6 +6901,12 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TFresnelElement.GetComputedBackgroundOrigin: TCSSNumericalID;
|
|
|
|
+begin
|
|
|
|
+ Result:=GetComputedCSSKeyword(CSSRegistry.FresnelAttrs[fcaBackgroundOrigin].Index,
|
|
|
|
+ CSSRegistry.Chk_BackgroundOrigin_KeywordIDs);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TFresnelElement.GetComputedMarginBlockStartEndAttr(out aStartAttr,
|
|
procedure TFresnelElement.GetComputedMarginBlockStartEndAttr(out aStartAttr,
|
|
aEndAttr: TFresnelCSSAttribute);
|
|
aEndAttr: TFresnelCSSAttribute);
|
|
begin
|
|
begin
|
|
@@ -7364,6 +7439,9 @@ end;
|
|
|
|
|
|
procedure TFresnelElement.BeforeRender;
|
|
procedure TFresnelElement.BeforeRender;
|
|
begin
|
|
begin
|
|
|
|
+ FRenderedBorderBox:=FUsedBorderBox;
|
|
|
|
+ FRenderedContentBox:=FUsedContentBox;
|
|
|
|
+
|
|
If Assigned(FBeforeRender) then
|
|
If Assigned(FBeforeRender) then
|
|
FBeforeRender(Self);
|
|
FBeforeRender(Self);
|
|
end;
|
|
end;
|
|
@@ -7906,7 +7984,14 @@ end;
|
|
|
|
|
|
procedure TFresnelElement.ComputeCSSAfterLayoutNode(Layouter: TFresnelLayouter);
|
|
procedure TFresnelElement.ComputeCSSAfterLayoutNode(Layouter: TFresnelLayouter);
|
|
begin
|
|
begin
|
|
|
|
+ if Layouter<>nil then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+{ TReplacedElement }
|
|
|
|
|
|
|
|
+function TReplacedElement.AcceptChildrenAtDesignTime: boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=false;
|
|
end;
|
|
end;
|
|
|
|
|
|
initialization
|
|
initialization
|