|
@@ -300,8 +300,10 @@ type
|
|
TComputeEvent = procedure(Desc: TFresnelElementAttrDesc; El: TFresnelElement;
|
|
TComputeEvent = procedure(Desc: TFresnelElementAttrDesc; El: TFresnelElement;
|
|
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;
|
|
public
|
|
public
|
|
OnCompute: TComputeEvent; // removes unknown/invalid values, substitutes calc(), converts to base unit (px)
|
|
OnCompute: TComputeEvent; // removes unknown/invalid values, substitutes calc(), converts to base unit (px)
|
|
|
|
+ OnAsString: TGetAsStringEvent; // returns value of shorthand (e.g. font or margin-block)
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TFresnelCSSAttrDesc }
|
|
{ TFresnelCSSAttrDesc }
|
|
@@ -388,19 +390,40 @@ type
|
|
TopLeft, TopRight, BottomLeft, BottomRight: TFresnelCSSAttribute; const Found: TCSSStringArray);
|
|
TopLeft, TopRight, BottomLeft, BottomRight: TFresnelCSSAttribute; const Found: TCSSStringArray);
|
|
|
|
|
|
// split shorthands
|
|
// split shorthands
|
|
- procedure SplitOverflow(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
- procedure SplitBorderWidth(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
|
|
+ procedure SplitBackground(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
+ procedure SplitBackgroundPosition(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitBorderColor(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitBorderColor(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
- procedure SplitBorderStyle(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
procedure SplitBorderLeftRightTopBottom(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual; // also fcaBorder
|
|
procedure SplitBorderLeftRightTopBottom(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual; // also fcaBorder
|
|
procedure SplitBorderRadius(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitBorderRadius(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
+ procedure SplitBorderStyle(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
+ procedure SplitBorderWidth(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitFont(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual; // todo systemfont
|
|
procedure SplitFont(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual; // todo systemfont
|
|
procedure SplitMargin(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitMargin(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitMarginBlock(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitMarginBlock(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitMarginInline(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitMarginInline(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
+ procedure SplitOverflow(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitPadding(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
procedure SplitPadding(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
- procedure SplitBackgroundPosition(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
- procedure SplitBackground(Resolver: TCSSBaseResolver; var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray); virtual;
|
|
|
|
|
|
+
|
|
|
|
+ // get computed attribute as string
|
|
|
|
+ function GetBackground(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorder(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorderColor(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorderSide(El: TFresnelElement; Side: TFresnelCSSSide): string; virtual;
|
|
|
|
+ function GetBorderLeft(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorderRight(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorderTop(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorderBottom(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorderStyle(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorderRadius(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetBorderWidth(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetSideLengths(El: TFresnelElement; LeftAttr: TFresnelCSSAttribute): string; virtual;
|
|
|
|
+ function GetFont(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetFontSize(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetMargin(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetMarginBlock(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetMarginInline(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetOverflow(El: TFresnelElement): string; virtual;
|
|
|
|
+ function GetPadding(El: TFresnelElement): string; virtual;
|
|
public
|
|
public
|
|
// keywords
|
|
// keywords
|
|
const
|
|
const
|
|
@@ -606,7 +629,9 @@ type
|
|
// 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 CompProps: TFresnelCSSAttributeArray): TFresnelCSSAttrDesc; virtual; overload;
|
|
|
|
|
|
+ const OnSplit: TCSSAttributeDesc.TSplitShorthandEvent;
|
|
|
|
+ const OnAsString: TFresnelElementAttrDesc.TGetAsStringEvent;
|
|
|
|
+ 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;
|
|
// register pseudo classes
|
|
// register pseudo classes
|
|
function AddFresnelPseudoClass(Pseudo: TFresnelCSSPseudoClass): TFresnelCSSPseudoClassDesc; virtual; overload;
|
|
function AddFresnelPseudoClass(Pseudo: TFresnelCSSPseudoClass): TFresnelCSSPseudoClassDesc; virtual; overload;
|
|
@@ -792,6 +817,8 @@ type
|
|
function ConvertCSSValueToPixel(IsHorizontal: boolean; const Value: string): TFresnelLength; virtual;
|
|
function ConvertCSSValueToPixel(IsHorizontal: boolean; const Value: string): TFresnelLength; virtual;
|
|
procedure ComputeDisplay; virtual;
|
|
procedure ComputeDisplay; virtual;
|
|
procedure ComputePosition; virtual;
|
|
procedure ComputePosition; virtual;
|
|
|
|
+ function ComputeAttribute(aDesc: TCSSAttributeDesc; var aValue: String): TCSSAttributeValue.TState; virtual;
|
|
|
|
+ function GetShorthandSpaceSeparated(AttrDesc: TCSSAttributeDesc): string;
|
|
protected
|
|
protected
|
|
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
|
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
|
procedure SetParentComponent(Value: TComponent); override;
|
|
procedure SetParentComponent(Value: TComponent); override;
|
|
@@ -854,12 +881,13 @@ type
|
|
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;
|
|
- function GetComputedCSSShorthand(AttrID: TCSSNumericalID): string; virtual;
|
|
|
|
|
|
+ function GetComputedCSSKeyword(AttrID: TCSSNumericalID; const AllowedKeywords: TCSSNumericalIDArray): TCSSNumericalID; virtual;
|
|
function GetComputedBorderWidth(Attr: TFresnelCSSAttribute): TFresnelLength; virtual;
|
|
function GetComputedBorderWidth(Attr: TFresnelCSSAttribute): TFresnelLength; virtual;
|
|
function GetComputedBorderRadius(Corner: TFresnelCSSCorner): TFresnelPoint; virtual; // on fail returns 0
|
|
function GetComputedBorderRadius(Corner: TFresnelCSSCorner): TFresnelPoint; virtual; // on fail returns 0
|
|
function GetComputedColor(Attr: TFresnelCSSAttribute; const CurrentColor: TFPColor): TFPColor; virtual; // on fail returns transparent
|
|
function GetComputedColor(Attr: TFresnelCSSAttribute; const CurrentColor: TFPColor): TFPColor; virtual; // on fail returns transparent
|
|
function GetComputedKeyword(Attr: TFresnelCSSAttribute; const AllowedKeywords: TCSSNumericalIDArray): TCSSNumericalID; virtual;
|
|
function GetComputedKeyword(Attr: TFresnelCSSAttribute; const AllowedKeywords: TCSSNumericalIDArray): TCSSNumericalID; virtual;
|
|
- function GetComputedCSSKeyword(AttrID: TCSSNumericalID; const AllowedKeywords: TCSSNumericalIDArray): TCSSNumericalID; virtual;
|
|
|
|
|
|
+ procedure GetComputedMarginBlockStartEndAttr(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
|
|
function GetComputedImage(Attr: TFresnelCSSAttribute): TFresnelCSSBackgroundInfo; virtual; // on fail returns nil
|
|
function GetComputedImage(Attr: TFresnelCSSAttribute): TFresnelCSSBackgroundInfo; virtual; // on fail returns nil
|
|
function GetComputedLinearGradient(const LGParams: string): TFresnelCSSLinearGradient; virtual; // on fail returns nil
|
|
function GetComputedLinearGradient(const LGParams: string): TFresnelCSSLinearGradient; virtual; // on fail returns nil
|
|
@@ -2520,6 +2548,218 @@ begin
|
|
fcaPaddingTop,fcaPaddingRight,fcaPaddingBottom,fcaPaddingLeft,Found);
|
|
fcaPaddingTop,fcaPaddingRight,fcaPaddingBottom,fcaPaddingLeft,Found);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TFresnelCSSRegistry.GetBackground(El: TFresnelElement): string;
|
|
|
|
+begin
|
|
|
|
+ Result:='';
|
|
|
|
+ // todo
|
|
|
|
+ if El=nil then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorder(El: TFresnelElement): string;
|
|
|
|
+var
|
|
|
|
+ aLeft, aRight, aTop, aBottom: String;
|
|
|
|
+begin
|
|
|
|
+ aLeft:=GetBorderSide(El,ffsLeft);
|
|
|
|
+ aRight:=GetBorderSide(El,ffsRight);
|
|
|
|
+ aTop:=GetBorderSide(El,ffsTop);
|
|
|
|
+ aBottom:=GetBorderSide(El,ffsBottom);
|
|
|
|
+
|
|
|
|
+ if (aLeft=aRight) and (aLeft=aTop) and (aLeft=aBottom) then
|
|
|
|
+ Result:=aLeft
|
|
|
|
+ else
|
|
|
|
+ Result:='';
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderColor(El: TFresnelElement): string;
|
|
|
|
+var
|
|
|
|
+ aLeft, aRight, aTop, aBottom: String;
|
|
|
|
+begin
|
|
|
|
+ aLeft:=El.GetComputedString(fcaBorderLeftColor);
|
|
|
|
+ aRight:=El.GetComputedString(fcaBorderRightColor);
|
|
|
|
+ aTop:=El.GetComputedString(fcaBorderTopColor);
|
|
|
|
+ aBottom:=El.GetComputedString(fcaBorderBottomColor);
|
|
|
|
+
|
|
|
|
+ if aLeft='' then aLeft:='currentcolor';
|
|
|
|
+ if aRight='' then aRight:='currentcolor';
|
|
|
|
+ if aTop='' then aTop:='currentcolor';
|
|
|
|
+ if aBottom='' then aBottom:='currentcolor';
|
|
|
|
+
|
|
|
|
+ Result:=aTop+' '+aRight+' '+aBottom+' '+aLeft;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderSide(El: TFresnelElement; Side: TFresnelCSSSide): string;
|
|
|
|
+var
|
|
|
|
+ aColor, aStyle, aWidth: String;
|
|
|
|
+begin
|
|
|
|
+ aColor:=El.GetComputedString(TFresnelCSSAttribute(ord(fcaBorderLeftColor)+ord(Side)));
|
|
|
|
+ if aColor='' then aColor:='currentcolor';
|
|
|
|
+ aStyle:=El.GetComputedString(TFresnelCSSAttribute(ord(fcaBorderLeftStyle)+ord(Side)));
|
|
|
|
+ if aStyle='' then aStyle:='none';
|
|
|
|
+ aWidth:=El.GetComputedString(TFresnelCSSAttribute(ord(fcaBorderLeftWidth)+ord(Side)));
|
|
|
|
+ if aWidth='' then aWidth:='0';
|
|
|
|
+
|
|
|
|
+ Result:=aColor+' '+aStyle+' '+aWidth;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderLeft(El: TFresnelElement): string;
|
|
|
|
+begin
|
|
|
|
+ Result:=GetBorderSide(El,ffsLeft);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderRight(El: TFresnelElement): string;
|
|
|
|
+begin
|
|
|
|
+ Result:=GetBorderSide(El,ffsRight);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderTop(El: TFresnelElement): string;
|
|
|
|
+begin
|
|
|
|
+ Result:=GetBorderSide(El,ffsTop);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderBottom(El: TFresnelElement): string;
|
|
|
|
+begin
|
|
|
|
+ Result:=GetBorderSide(El,ffsBottom);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderWidth(El: TFresnelElement): string;
|
|
|
|
+begin
|
|
|
|
+ Result:=GetSideLengths(El,fcaBorderLeftWidth);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetSideLengths(El: TFresnelElement; LeftAttr: TFresnelCSSAttribute
|
|
|
|
+ ): string;
|
|
|
|
+var
|
|
|
|
+ Sides: array[TFresnelCSSSide] of TFresnelLength;
|
|
|
|
+ Side: TFresnelCSSSide;
|
|
|
|
+begin
|
|
|
|
+ for Side in TFresnelCSSSide do
|
|
|
|
+ Sides[Side]:=El.GetComputedLength(TFresnelCSSAttribute(ord(LeftAttr)+ord(Side)));
|
|
|
|
+
|
|
|
|
+ Result:=FloatToCSSPx(Sides[ffsTop])
|
|
|
|
+ +' '+FloatToCSSPx(Sides[ffsRight])
|
|
|
|
+ +' '+FloatToCSSPx(Sides[ffsBottom])
|
|
|
|
+ +' '+FloatToCSSPx(Sides[ffsLeft]);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetFont(El: TFresnelElement): string;
|
|
|
|
+
|
|
|
|
+ procedure Add(const aValue, aDefault: string);
|
|
|
|
+ begin
|
|
|
|
+ if aValue='' then exit;
|
|
|
|
+ if aValue=aDefault then exit;
|
|
|
|
+
|
|
|
|
+ if Result>'' then
|
|
|
|
+ Result+=' '+aValue
|
|
|
|
+ else
|
|
|
|
+ Result:=aValue;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ aSize, aWeight, aLineHeight: TFresnelLength;
|
|
|
|
+ aFamily, aStyle, aVariant: String;
|
|
|
|
+begin
|
|
|
|
+ Result:='';
|
|
|
|
+
|
|
|
|
+ aSize:=El.Font.GetSize;
|
|
|
|
+ aFamily:=El.Font.GetFamily;
|
|
|
|
+ aStyle:=El.Font.GetStyle;
|
|
|
|
+
|
|
|
|
+ aVariant:=El.Font.GetVariant;
|
|
|
|
+ case aVariant of
|
|
|
|
+ 'normal','small-caps': ; // only these are allowed in font shorthand
|
|
|
|
+ else aVariant:='';
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ aWeight:=El.Font.GetWeight;
|
|
|
|
+ // todo font-width, must be a single keyword
|
|
|
|
+ aLineHeight:=El.GetComputedLength(fcaLineHeight);
|
|
|
|
+
|
|
|
|
+ // style, variant and weight must preced size
|
|
|
|
+ Add(aStyle,FresnelAttrs[fcaFontStyle].InitialValue);
|
|
|
|
+ Add(aVariant,FresnelAttrs[fcaFontVariant].InitialValue);
|
|
|
|
+ Add(FloatToCSSStr(aWeight),'');
|
|
|
|
+
|
|
|
|
+ // font-size/line-height
|
|
|
|
+ Add(FloatToCSSStr(aSize),'');
|
|
|
|
+ Result+='/'+FloatToCSSStr(aLineHeight);
|
|
|
|
+
|
|
|
|
+ Add(aFamily,'');
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetFontSize(El: TFresnelElement): string;
|
|
|
|
+begin
|
|
|
|
+ Result:=FloatToCSSPx(El.GetComputedFontSize);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetMargin(El: TFresnelElement): string;
|
|
|
|
+var
|
|
|
|
+ Margins: array[TFresnelCSSSide] of TFresnelLength;
|
|
|
|
+ Side: TFresnelCSSSide;
|
|
|
|
+begin
|
|
|
|
+ for Side in TFresnelCSSSide do
|
|
|
|
+ Margins[Side]:=El.GetComputedLength(TFresnelCSSAttribute(ord(fcaMarginLeft)+ord(Side)));
|
|
|
|
+
|
|
|
|
+ Result:=FloatToCSSPx(Margins[ffsTop])+' '+FloatToCSSPx(Margins[ffsRight])
|
|
|
|
+ +' '+FloatToCSSPx(Margins[ffsBottom])+' '+FloatToCSSPx(Margins[ffsLeft]);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetMarginBlock(El: TFresnelElement): string;
|
|
|
|
+var
|
|
|
|
+ aStartAttr, aEndAttr: TFresnelCSSAttribute;
|
|
|
|
+ aStart, aEnd: TFresnelLength;
|
|
|
|
+begin
|
|
|
|
+ El.GetComputedMarginBlockStartEndAttr(aStartAttr,aEndAttr);
|
|
|
|
+ aStart:=El.GetComputedLength(aStartAttr);
|
|
|
|
+ aEnd:=El.GetComputedLength(aEndAttr);
|
|
|
|
+ Result:=FloatToCSSPx(aStart)+' '+FloatToCSSPx(aEnd);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetMarginInline(El: TFresnelElement): string;
|
|
|
|
+var
|
|
|
|
+ aStartAttr, aEndAttr: TFresnelCSSAttribute;
|
|
|
|
+ aStart, aEnd: TFresnelLength;
|
|
|
|
+begin
|
|
|
|
+ El.GetComputedMarginInlineStartEndAttr(aStartAttr,aEndAttr);
|
|
|
|
+ aStart:=El.GetComputedLength(aStartAttr);
|
|
|
|
+ aEnd:=El.GetComputedLength(aEndAttr);
|
|
|
|
+ Result:=FloatToCSSPx(aStart)+' '+FloatToCSSPx(aEnd);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderStyle(El: TFresnelElement): string;
|
|
|
|
+var
|
|
|
|
+ aLeft, aRight, aTop, aBottom: String;
|
|
|
|
+begin
|
|
|
|
+ aLeft:=El.GetComputedString(fcaBorderLeftStyle);
|
|
|
|
+ aRight:=El.GetComputedString(fcaBorderRightStyle);
|
|
|
|
+ aTop:=El.GetComputedString(fcaBorderTopStyle);
|
|
|
|
+ aBottom:=El.GetComputedString(fcaBorderBottomStyle);
|
|
|
|
+
|
|
|
|
+ if aLeft='' then aLeft:='none';
|
|
|
|
+ if aRight='' then aRight:='none';
|
|
|
|
+ if aTop='' then aTop:='none';
|
|
|
|
+ if aBottom='' then aBottom:='none';
|
|
|
|
+
|
|
|
|
+ Result:=aTop+' '+aRight+' '+aBottom+' '+aLeft;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetBorderRadius(El: TFresnelElement): string;
|
|
|
|
+var
|
|
|
|
+ aCorner: TFresnelCSSCorner;
|
|
|
|
+ Radii: array[TFresnelCSSCorner] of TFresnelPoint;
|
|
|
|
+begin
|
|
|
|
+ for aCorner in TFresnelCSSCorner do
|
|
|
|
+ Radii[aCorner]:=El.GetComputedBorderRadius(aCorner);
|
|
|
|
+
|
|
|
|
+ Result:=FloatToCSSPx(Radii[fcsTopLeft].X)
|
|
|
|
+ +' '+FloatToCSSPx(Radii[fcsTopRight].X)
|
|
|
|
+ +' '+FloatToCSSPx(Radii[fcsBottomRight].X)
|
|
|
|
+ +' '+FloatToCSSPx(Radii[fcsBottomLeft].X)
|
|
|
|
+ +' / '+FloatToCSSPx(Radii[fcsTopLeft].Y)
|
|
|
|
+ +' '+FloatToCSSPx(Radii[fcsTopRight].Y)
|
|
|
|
+ +' '+FloatToCSSPx(Radii[fcsBottomRight].Y)
|
|
|
|
+ +' '+FloatToCSSPx(Radii[fcsBottomLeft].Y);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TFresnelCSSRegistry.SplitBackgroundPosition(Resolver: TCSSBaseResolver;
|
|
procedure TFresnelCSSRegistry.SplitBackgroundPosition(Resolver: TCSSBaseResolver;
|
|
var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray);
|
|
var AttrIDs: TCSSNumericalIDArray; var Values: TCSSStringArray);
|
|
var
|
|
var
|
|
@@ -2568,6 +2808,26 @@ begin
|
|
Values[8]:=aSize;
|
|
Values[8]:=aSize;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TFresnelCSSRegistry.GetOverflow(El: TFresnelElement): string;
|
|
|
|
+var
|
|
|
|
+ X, Y: String;
|
|
|
|
+begin
|
|
|
|
+ X:=El.GetComputedString(fcaOverflowX);
|
|
|
|
+ Y:=El.GetComputedString(fcaOverflowY);
|
|
|
|
+ if X>'' then
|
|
|
|
+ begin
|
|
|
|
+ Result:=X;
|
|
|
|
+ if (Y>'') and (X<>Y) then
|
|
|
|
+ Result+=' '+Y;
|
|
|
|
+ end else
|
|
|
|
+ Result:=Y;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TFresnelCSSRegistry.GetPadding(El: TFresnelElement): string;
|
|
|
|
+begin
|
|
|
|
+ Result:=GetSideLengths(El,fcaPaddingLeft);
|
|
|
|
+end;
|
|
|
|
+
|
|
constructor TFresnelCSSRegistry.Create;
|
|
constructor TFresnelCSSRegistry.Create;
|
|
begin
|
|
begin
|
|
Attribute_ClassOf:=TFresnelCSSAttrDesc;
|
|
Attribute_ClassOf:=TFresnelCSSAttrDesc;
|
|
@@ -2775,7 +3035,7 @@ begin
|
|
AddFresnelLonghand(fcaOverflowY,false,@CheckOverflowXY,'visible');
|
|
AddFresnelLonghand(fcaOverflowY,false,@CheckOverflowXY,'visible');
|
|
Chk_OverflowXY_KeywordIDs:=[kwVisible,kwHidden,kwClip,kwScroll,kwAuto];
|
|
Chk_OverflowXY_KeywordIDs:=[kwVisible,kwHidden,kwClip,kwScroll,kwAuto];
|
|
|
|
|
|
- AddFresnelShorthand(fcaOverflow,@CheckOverflowXY,@SplitOverflow,[fcaOverflowX,fcaOverflowY]);
|
|
|
|
|
|
+ AddFresnelShorthand(fcaOverflow,@CheckOverflowXY,@SplitOverflow,@GetOverflow,[fcaOverflowX,fcaOverflowY]);
|
|
|
|
|
|
// clear
|
|
// clear
|
|
AddFresnelLonghand(fcaClear,false,@CheckClear);
|
|
AddFresnelLonghand(fcaClear,false,@CheckClear);
|
|
@@ -2817,7 +3077,7 @@ begin
|
|
Chk_BorderWidth_Dim.AllowFrac:=true;
|
|
Chk_BorderWidth_Dim.AllowFrac:=true;
|
|
Chk_BorderWidth_Dim.AllowedKeywordIDs:=[kwThin,kwMedium,kwThick];
|
|
Chk_BorderWidth_Dim.AllowedKeywordIDs:=[kwThin,kwMedium,kwThick];
|
|
|
|
|
|
- AddFresnelShorthand(fcaBorderWidth,@CheckBorderWidth,@SplitBorderWidth,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorderWidth,@CheckBorderWidth,@SplitBorderWidth,@GetBorderWidth,
|
|
[fcaBorderLeftWidth,fcaBorderRightWidth,fcaBorderTopWidth,fcaBorderBottomWidth]);
|
|
[fcaBorderLeftWidth,fcaBorderRightWidth,fcaBorderTopWidth,fcaBorderBottomWidth]);
|
|
|
|
|
|
// border-color
|
|
// border-color
|
|
@@ -2826,7 +3086,7 @@ begin
|
|
AddFresnelLonghand(fcaBorderTopColor,false,@CheckColor,'currentcolor');
|
|
AddFresnelLonghand(fcaBorderTopColor,false,@CheckColor,'currentcolor');
|
|
AddFresnelLonghand(fcaBorderBottomColor,false,@CheckColor,'currentcolor');
|
|
AddFresnelLonghand(fcaBorderBottomColor,false,@CheckColor,'currentcolor');
|
|
|
|
|
|
- AddFresnelShorthand(fcaBorderColor,@CheckColor,@SplitBorderColor,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorderColor,@CheckColor,@SplitBorderColor,@GetBorderColor,
|
|
[fcaBorderLeftColor,fcaBorderRightColor,fcaBorderTopColor,fcaBorderBottomColor]);
|
|
[fcaBorderLeftColor,fcaBorderRightColor,fcaBorderTopColor,fcaBorderBottomColor]);
|
|
|
|
|
|
// border-style
|
|
// border-style
|
|
@@ -2836,21 +3096,21 @@ begin
|
|
AddFresnelLonghand(fcaBorderBottomStyle,false,@CheckBorderStyle);
|
|
AddFresnelLonghand(fcaBorderBottomStyle,false,@CheckBorderStyle);
|
|
Chk_BorderStyle_KeywordIDs:=[kwNone,kwHidden,kwDotted,kwDashed,kwSolid,kwDouble,kwGroove,kwRidge,kwInset,kwOutset];
|
|
Chk_BorderStyle_KeywordIDs:=[kwNone,kwHidden,kwDotted,kwDashed,kwSolid,kwDouble,kwGroove,kwRidge,kwInset,kwOutset];
|
|
|
|
|
|
- AddFresnelShorthand(fcaBorderStyle,@CheckBorderStyle,@SplitBorderStyle,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorderStyle,@CheckBorderStyle,@SplitBorderStyle,@GetBorderStyle,
|
|
[fcaBorderLeftStyle,fcaBorderRightStyle,fcaBorderTopStyle,fcaBorderBottomStyle]);
|
|
[fcaBorderLeftStyle,fcaBorderRightStyle,fcaBorderTopStyle,fcaBorderBottomStyle]);
|
|
|
|
|
|
// border-left, -right, -top, -bottom
|
|
// border-left, -right, -top, -bottom
|
|
- AddFresnelShorthand(fcaBorderLeft,@CheckBorder,@SplitBorderLeftRightTopBottom,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorderLeft,@CheckBorder,@SplitBorderLeftRightTopBottom,@GetBorderLeft,
|
|
[fcaBorderLeftWidth,fcaBorderLeftStyle,fcaBorderLeftColor]);
|
|
[fcaBorderLeftWidth,fcaBorderLeftStyle,fcaBorderLeftColor]);
|
|
- AddFresnelShorthand(fcaBorderRight,@CheckBorder,@SplitBorderLeftRightTopBottom,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorderRight,@CheckBorder,@SplitBorderLeftRightTopBottom,@GetBorderRight,
|
|
[fcaBorderRightWidth,fcaBorderRightStyle,fcaBorderRightColor]);
|
|
[fcaBorderRightWidth,fcaBorderRightStyle,fcaBorderRightColor]);
|
|
- AddFresnelShorthand(fcaBorderTop,@CheckBorder,@SplitBorderLeftRightTopBottom,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorderTop,@CheckBorder,@SplitBorderLeftRightTopBottom,@GetBorderTop,
|
|
[fcaBorderTopWidth,fcaBorderTopStyle,fcaBorderTopColor]);
|
|
[fcaBorderTopWidth,fcaBorderTopStyle,fcaBorderTopColor]);
|
|
- AddFresnelShorthand(fcaBorderBottom,@CheckBorder,@SplitBorderLeftRightTopBottom,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorderBottom,@CheckBorder,@SplitBorderLeftRightTopBottom,@GetBorderBottom,
|
|
[fcaBorderBottomWidth,fcaBorderBottomStyle,fcaBorderBottomColor]);
|
|
[fcaBorderBottomWidth,fcaBorderBottomStyle,fcaBorderBottomColor]);
|
|
|
|
|
|
// border: shorthand for all 12 border-[left,right,top,bottom]-[widht,style,color]
|
|
// border: shorthand for all 12 border-[left,right,top,bottom]-[widht,style,color]
|
|
- AddFresnelShorthand(fcaBorder,@CheckBorder,@SplitBorderLeftRightTopBottom,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorder,@CheckBorder,@SplitBorderLeftRightTopBottom,@GetBorder,
|
|
[fcaBorderWidth,fcaBorderStyle,fcaBorderColor, // overrides these shorthands too
|
|
[fcaBorderWidth,fcaBorderStyle,fcaBorderColor, // overrides these shorthands too
|
|
fcaBorderLeftWidth,fcaBorderLeftStyle,fcaBorderLeftColor,
|
|
fcaBorderLeftWidth,fcaBorderLeftStyle,fcaBorderLeftColor,
|
|
fcaBorderRightWidth,fcaBorderRightStyle,fcaBorderRightColor,
|
|
fcaBorderRightWidth,fcaBorderRightStyle,fcaBorderRightColor,
|
|
@@ -2864,7 +3124,7 @@ begin
|
|
AddFresnelLonghand(fcaBorderBottomRightRadius,false,@CheckBorderRadius);
|
|
AddFresnelLonghand(fcaBorderBottomRightRadius,false,@CheckBorderRadius);
|
|
Chk_BorderRadius_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_BorderRadius_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_BorderRadius_Dim.AllowFrac:=true;
|
|
Chk_BorderRadius_Dim.AllowFrac:=true;
|
|
- AddFresnelShorthand(fcaBorderRadius,@CheckBorderRadius,@SplitBorderRadius,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBorderRadius,@CheckBorderRadius,@SplitBorderRadius,@GetBorderRadius,
|
|
[fcaBorderTopLeftRadius,fcaBorderTopRightRadius,fcaBorderBottomLeftRadius,fcaBorderBottomRightRadius]);
|
|
[fcaBorderTopLeftRadius,fcaBorderTopRightRadius,fcaBorderBottomLeftRadius,fcaBorderBottomRightRadius]);
|
|
|
|
|
|
// float
|
|
// float
|
|
@@ -2880,7 +3140,8 @@ begin
|
|
AddFresnelLonghand(fcaFontKerning,true,@CheckFontKerning,'auto');
|
|
AddFresnelLonghand(fcaFontKerning,true,@CheckFontKerning,'auto');
|
|
Chk_FontKerning_KeywordIDs:=[kwAuto,kwNormal,kwNone];
|
|
Chk_FontKerning_KeywordIDs:=[kwAuto,kwNormal,kwNone];
|
|
// font-size
|
|
// font-size
|
|
- AddFresnelLonghand(fcaFontSize,true,@CheckFontSize,'medium');
|
|
|
|
|
|
+ Desc:=AddFresnelLonghand(fcaFontSize,true,@CheckFontSize,'medium');
|
|
|
|
+ Desc.OnAsString:=@GetFontSize;
|
|
Chk_FontSize_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_FontSize_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_FontSize_Dim.AllowFrac:=true;
|
|
Chk_FontSize_Dim.AllowFrac:=true;
|
|
Chk_FontSize_Dim.AllowedKeywordIDs:=[kwXXSmall,kwXSmall,kwSmall,kwSmaller,kwMedium,
|
|
Chk_FontSize_Dim.AllowedKeywordIDs:=[kwXXSmall,kwXSmall,kwSmall,kwSmaller,kwMedium,
|
|
@@ -2908,7 +3169,7 @@ begin
|
|
Chk_LineHeight_Dim.AllowFrac:=true;
|
|
Chk_LineHeight_Dim.AllowFrac:=true;
|
|
|
|
|
|
// font
|
|
// font
|
|
- AddFresnelShorthand(fcaFont,@CheckFont,@SplitFont,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaFont,@CheckFont,@SplitFont,@GetFont,
|
|
[fcaFontFamily,fcaFontSize,fcaFontStyle,fcaFontVariant,fcaFontWeight,fcaLineHeight]);
|
|
[fcaFontFamily,fcaFontSize,fcaFontStyle,fcaFontVariant,fcaFontWeight,fcaLineHeight]);
|
|
|
|
|
|
// text-shadow
|
|
// text-shadow
|
|
@@ -2928,19 +3189,19 @@ begin
|
|
Chk_Margin_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_Margin_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_Margin_Dim.AllowFrac:=true;
|
|
Chk_Margin_Dim.AllowFrac:=true;
|
|
Chk_Margin_Dim.AllowNegative:=true;
|
|
Chk_Margin_Dim.AllowNegative:=true;
|
|
- AddFresnelShorthand(fcaMargin,@CheckMargin,@SplitMargin,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaMargin,@CheckMargin,@SplitMargin,@GetMargin,
|
|
[fcaMarginLeft,fcaMarginRight,fcaMarginTop,fcaMarginBottom]);
|
|
[fcaMarginLeft,fcaMarginRight,fcaMarginTop,fcaMarginBottom]);
|
|
|
|
|
|
// margin-block
|
|
// margin-block
|
|
AddFresnelLonghand(fcaMarginBlockEnd,false,@CheckMargin,'0');
|
|
AddFresnelLonghand(fcaMarginBlockEnd,false,@CheckMargin,'0');
|
|
AddFresnelLonghand(fcaMarginBlockStart,false,@CheckMargin,'0');
|
|
AddFresnelLonghand(fcaMarginBlockStart,false,@CheckMargin,'0');
|
|
- AddFresnelShorthand(fcaMarginBlock,@CheckMargin,@SplitMarginBlock,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaMarginBlock,@CheckMargin,@SplitMarginBlock,@GetMarginBlock,
|
|
[fcaMarginBlockStart,fcaMarginBlockEnd]);
|
|
[fcaMarginBlockStart,fcaMarginBlockEnd]);
|
|
|
|
|
|
// margin-inline
|
|
// margin-inline
|
|
AddFresnelLonghand(fcaMarginInlineEnd,false,@CheckMargin,'0');
|
|
AddFresnelLonghand(fcaMarginInlineEnd,false,@CheckMargin,'0');
|
|
AddFresnelLonghand(fcaMarginInlineStart,false,@CheckMargin,'0');
|
|
AddFresnelLonghand(fcaMarginInlineStart,false,@CheckMargin,'0');
|
|
- AddFresnelShorthand(fcaMarginInline,@CheckMargin,@SplitMarginInline,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaMarginInline,@CheckMargin,@SplitMarginInline,@GetMarginInline,
|
|
[fcaMarginInlineStart,fcaMarginInlineEnd]);
|
|
[fcaMarginInlineStart,fcaMarginInlineEnd]);
|
|
|
|
|
|
// opacity
|
|
// opacity
|
|
@@ -2955,7 +3216,7 @@ begin
|
|
AddFresnelLonghand(fcaPaddingBottom,false,@CheckPadding,'0');
|
|
AddFresnelLonghand(fcaPaddingBottom,false,@CheckPadding,'0');
|
|
Chk_Padding_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_Padding_Dim.AllowedUnits:=cuAllLengthsAndPercent;
|
|
Chk_Padding_Dim.AllowFrac:=true;
|
|
Chk_Padding_Dim.AllowFrac:=true;
|
|
- AddFresnelShorthand(fcaPadding,@CheckPadding,@SplitPadding,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaPadding,@CheckPadding,@SplitPadding,@GetPadding,
|
|
[fcaPaddingLeft,fcaPaddingRight,fcaPaddingTop,fcaPaddingBottom]);
|
|
[fcaPaddingLeft,fcaPaddingRight,fcaPaddingTop,fcaPaddingBottom]);
|
|
|
|
|
|
// opacity
|
|
// opacity
|
|
@@ -3000,7 +3261,7 @@ begin
|
|
Chk_BackgroundSize_Dim.AllowFrac:=true;
|
|
Chk_BackgroundSize_Dim.AllowFrac:=true;
|
|
|
|
|
|
// background
|
|
// background
|
|
- AddFresnelShorthand(fcaBackground,@CheckBackground,@SplitBackground,
|
|
|
|
|
|
+ AddFresnelShorthand(fcaBackground,@CheckBackground,@SplitBackground,@GetBackground,
|
|
[fcaBackgroundAttachment,fcaBackgroundClip,fcaBackgroundColor,fcaBackgroundImage,
|
|
[fcaBackgroundAttachment,fcaBackgroundClip,fcaBackgroundColor,fcaBackgroundImage,
|
|
fcaBackgroundOrigin,fcaBackgroundRepeat,fcaBackgroundSize,fcaBackgroundPosition,
|
|
fcaBackgroundOrigin,fcaBackgroundRepeat,fcaBackgroundSize,fcaBackgroundPosition,
|
|
fcaBackgroundPositionX,fcaBackgroundPositionY]);
|
|
fcaBackgroundPositionX,fcaBackgroundPositionY]);
|
|
@@ -3033,7 +3294,8 @@ end;
|
|
|
|
|
|
function TFresnelCSSRegistry.AddFresnelShorthand(Attr: TFresnelCSSAttribute;
|
|
function TFresnelCSSRegistry.AddFresnelShorthand(Attr: TFresnelCSSAttribute;
|
|
const OnCheck: TCSSAttributeDesc.TCheckEvent; const OnSplit: TCSSAttributeDesc.
|
|
const OnCheck: TCSSAttributeDesc.TCheckEvent; const OnSplit: TCSSAttributeDesc.
|
|
- TSplitShorthandEvent; const CompProps: TFresnelCSSAttributeArray): TFresnelCSSAttrDesc;
|
|
|
|
|
|
+ TSplitShorthandEvent; const OnAsString: TFresnelElementAttrDesc.TGetAsStringEvent;
|
|
|
|
+ const CompProps: TFresnelCSSAttributeArray): TFresnelCSSAttrDesc;
|
|
var
|
|
var
|
|
i: Integer;
|
|
i: Integer;
|
|
AttrDesc: TFresnelCSSAttrDesc;
|
|
AttrDesc: TFresnelCSSAttrDesc;
|
|
@@ -3042,6 +3304,7 @@ begin
|
|
raise EFresnel.Create('20240712135716');
|
|
raise EFresnel.Create('20240712135716');
|
|
Result:=AddFresnelAttr(Attr,false,OnCheck);
|
|
Result:=AddFresnelAttr(Attr,false,OnCheck);
|
|
Result.OnSplitShorthand:=OnSplit;
|
|
Result.OnSplitShorthand:=OnSplit;
|
|
|
|
+ Result.OnAsString:=OnAsString;
|
|
SetLength(Result.CompProps,length(CompProps));
|
|
SetLength(Result.CompProps,length(CompProps));
|
|
for i:=0 to high(CompProps) do
|
|
for i:=0 to high(CompProps) do
|
|
begin
|
|
begin
|
|
@@ -4175,37 +4438,65 @@ function TFresnelElement.GetCSSString(AttrID: TCSSNumericalID; Compute: boolean;
|
|
var
|
|
var
|
|
AttrDesc: TCSSAttributeDesc;
|
|
AttrDesc: TCSSAttributeDesc;
|
|
|
|
|
|
- procedure DoCompute;
|
|
|
|
|
|
+ procedure UseInitialValue;
|
|
|
|
+ var
|
|
|
|
+ aState: TCSSAttributeValue.TState;
|
|
begin
|
|
begin
|
|
- if not (AttrDesc is TFresnelCSSAttrDesc) then exit;
|
|
|
|
|
|
+ Complete:=false;
|
|
|
|
+ Result:=AttrDesc.InitialValue;
|
|
|
|
+ if Compute then
|
|
|
|
+ begin
|
|
|
|
+ aState:=ComputeAttribute(AttrDesc,Result);
|
|
|
|
+ Complete:=aState=cavsComputed;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
var
|
|
var
|
|
i: Integer;
|
|
i: Integer;
|
|
aValue: TCSSAttributeValue;
|
|
aValue: TCSSAttributeValue;
|
|
|
|
+ ElAttrDesc: TFresnelElementAttrDesc;
|
|
|
|
+ aState: TCSSAttributeValue.TState;
|
|
begin
|
|
begin
|
|
Complete:=true;
|
|
Complete:=true;
|
|
|
|
|
|
AttrDesc:=Resolver.GetAttributeDesc(AttrID);
|
|
AttrDesc:=Resolver.GetAttributeDesc(AttrID);
|
|
if AttrDesc=nil then
|
|
if AttrDesc=nil then
|
|
exit('');
|
|
exit('');
|
|
- if length(AttrDesc.CompProps)>0 then
|
|
|
|
|
|
+
|
|
|
|
+ if Compute and (AttrDesc is TFresnelElementAttrDesc) then
|
|
begin
|
|
begin
|
|
- Result:=GetComputedCSSShorthand(AttrID);
|
|
|
|
- exit;
|
|
|
|
|
|
+ ElAttrDesc:=TFresnelElementAttrDesc(AttrDesc);
|
|
|
|
+ if Assigned(ElAttrDesc.OnAsString) then
|
|
|
|
+ begin
|
|
|
|
+ // shorthand
|
|
|
|
+ Result:=ElAttrDesc.OnAsString(Self);
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
if FCSSValues<>nil then
|
|
if FCSSValues<>nil then
|
|
begin
|
|
begin
|
|
i:=FCSSValues.IndexOf(AttrID);
|
|
i:=FCSSValues.IndexOf(AttrID);
|
|
- aValue:=FCSSValues.Values[i];
|
|
|
|
- if (i>=0) and (aValue.State<>cavsInvalid) then
|
|
|
|
|
|
+ if (i>=0) then
|
|
begin
|
|
begin
|
|
- Complete:=aValue.State=cavsComputed;
|
|
|
|
- Result:=aValue.Value;
|
|
|
|
- if Compute then
|
|
|
|
- DoCompute;
|
|
|
|
- exit;
|
|
|
|
|
|
+ aValue:=FCSSValues.Values[i];
|
|
|
|
+ aState:=aValue.State;
|
|
|
|
+ if aState<>cavsInvalid then
|
|
|
|
+ begin
|
|
|
|
+ // element has value
|
|
|
|
+ Complete:=aState=cavsComputed;
|
|
|
|
+ if Compute and not Complete then
|
|
|
|
+ begin
|
|
|
|
+ aState:=ComputeAttribute(AttrDesc,FCSSValues.Values[i].Value);
|
|
|
|
+ aValue.State:=aState;
|
|
|
|
+ Complete:=aState=cavsComputed;
|
|
|
|
+ end;
|
|
|
|
+ if aState<>cavsInvalid then
|
|
|
|
+ begin
|
|
|
|
+ Result:=aValue.Value;
|
|
|
|
+ if Result>'' then exit;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
if AttrDesc.All then
|
|
if AttrDesc.All then
|
|
@@ -4219,10 +4510,7 @@ begin
|
|
end;
|
|
end;
|
|
CSSKeywordInitial:
|
|
CSSKeywordInitial:
|
|
begin
|
|
begin
|
|
- Complete:=false;
|
|
|
|
- Result:=AttrDesc.InitialValue;
|
|
|
|
- if Compute then
|
|
|
|
- DoCompute;
|
|
|
|
|
|
+ UseInitialValue;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
CSSKeywordUnset,
|
|
CSSKeywordUnset,
|
|
@@ -4235,12 +4523,8 @@ begin
|
|
// use default
|
|
// use default
|
|
if AttrDesc.Inherits and (Parent<>nil) then
|
|
if AttrDesc.Inherits and (Parent<>nil) then
|
|
Result:=Parent.GetCSSString(AttrID,true,Complete)
|
|
Result:=Parent.GetCSSString(AttrID,true,Complete)
|
|
- else begin
|
|
|
|
- Complete:=false;
|
|
|
|
- Result:=AttrDesc.InitialValue;
|
|
|
|
- if Compute then
|
|
|
|
- DoCompute;
|
|
|
|
- end;
|
|
|
|
|
|
+ else
|
|
|
|
+ UseInitialValue;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TFresnelElement.GetComputedLength(Attr: TFresnelCSSAttribute; UseNaNOnFail: boolean
|
|
function TFresnelElement.GetComputedLength(Attr: TFresnelCSSAttribute; UseNaNOnFail: boolean
|
|
@@ -4350,14 +4634,13 @@ begin
|
|
Result:=GetComputedCSSString(AttrID);
|
|
Result:=GetComputedCSSString(AttrID);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TFresnelElement.GetComputedCSSShorthand(AttrID: TCSSNumericalID): string;
|
|
|
|
|
|
+function TFresnelElement.GetShorthandSpaceSeparated(AttrDesc: TCSSAttributeDesc): string;
|
|
var
|
|
var
|
|
- AttrDesc, SubDesc: TCSSAttributeDesc;
|
|
|
|
|
|
+ SubDesc: TCSSAttributeDesc;
|
|
i: Integer;
|
|
i: Integer;
|
|
s: String;
|
|
s: String;
|
|
begin
|
|
begin
|
|
Result:='';
|
|
Result:='';
|
|
- AttrDesc:=Resolver.GetAttributeDesc(AttrID);
|
|
|
|
if AttrDesc=nil then exit;
|
|
if AttrDesc=nil then exit;
|
|
for i:=0 to length(AttrDesc.CompProps)-1 do
|
|
for i:=0 to length(AttrDesc.CompProps)-1 do
|
|
begin
|
|
begin
|
|
@@ -4654,6 +4937,20 @@ begin
|
|
Result:=GetComputedCSSKeyword(CSSRegistry.FresnelAttrs[Attr].Index,AllowedKeywords);
|
|
Result:=GetComputedCSSKeyword(CSSRegistry.FresnelAttrs[Attr].Index,AllowedKeywords);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TFresnelElement.GetComputedMarginBlockStartEndAttr(out aStartAttr,
|
|
|
|
+ aEndAttr: TFresnelCSSAttribute);
|
|
|
|
+begin
|
|
|
|
+ aStartAttr:=fcaMarginLeft;
|
|
|
|
+ aEndAttr:=fcaMarginRight;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TFresnelElement.GetComputedMarginInlineStartEndAttr(out aStartAttr,
|
|
|
|
+ aEndAttr: TFresnelCSSAttribute);
|
|
|
|
+begin
|
|
|
|
+ aStartAttr:=fcaMarginLeft;
|
|
|
|
+ aEndAttr:=fcaMarginRight;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TFresnelElement.GetComputedCSSKeyword(AttrID: TCSSNumericalID;
|
|
function TFresnelElement.GetComputedCSSKeyword(AttrID: TCSSNumericalID;
|
|
const AllowedKeywords: TCSSNumericalIDArray): TCSSNumericalID;
|
|
const AllowedKeywords: TCSSNumericalIDArray): TCSSNumericalID;
|
|
var
|
|
var
|
|
@@ -4968,6 +5265,7 @@ function TFresnelElement.GetFont: IFresnelFont;
|
|
var
|
|
var
|
|
s: String;
|
|
s: String;
|
|
aComp: TCSSResCompValue;
|
|
aComp: TCSSResCompValue;
|
|
|
|
+ Complete: boolean;
|
|
begin
|
|
begin
|
|
if fesFontDescValid in FStates then
|
|
if fesFontDescValid in FStates then
|
|
exit(FFont);
|
|
exit(FFont);
|
|
@@ -4980,7 +5278,7 @@ begin
|
|
FFontDesc.Kerning:=GetComputedString(fcaFontKerning);
|
|
FFontDesc.Kerning:=GetComputedString(fcaFontKerning);
|
|
|
|
|
|
FFontDesc.Size:=FresnelDefaultFontSize;
|
|
FFontDesc.Size:=FresnelDefaultFontSize;
|
|
- s:=GetComputedString(fcaFontSize);
|
|
|
|
|
|
+ s:=GetCSSString(CSSRegistry.FresnelAttrs[fcaFontSize].Index,false,Complete);
|
|
if Parent<>nil then
|
|
if Parent<>nil then
|
|
begin
|
|
begin
|
|
aComp.EndP:=PChar(s);
|
|
aComp.EndP:=PChar(s);
|
|
@@ -5307,6 +5605,25 @@ begin
|
|
FPosition:=GetComputedKeyword(fcaPosition,CSSRegistry.Chk_Position_KeywordIDs);
|
|
FPosition:=GetComputedKeyword(fcaPosition,CSSRegistry.Chk_Position_KeywordIDs);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TFresnelElement.ComputeAttribute(aDesc: TCSSAttributeDesc; var aValue: String
|
|
|
|
+ ): TCSSAttributeValue.TState;
|
|
|
|
+var
|
|
|
|
+ ElAttrDesc: TFresnelElementAttrDesc;
|
|
|
|
+begin
|
|
|
|
+ if aValue='' then exit(cavsInvalid);
|
|
|
|
+
|
|
|
|
+ Result:=cavsComputed;
|
|
|
|
+
|
|
|
|
+ if aDesc is TFresnelElementAttrDesc then
|
|
|
|
+ begin
|
|
|
|
+ ElAttrDesc:=TFresnelElementAttrDesc(aDesc);
|
|
|
|
+ if ElAttrDesc.OnCompute<>nil then
|
|
|
|
+ begin
|
|
|
|
+
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
class function TFresnelElement.GetCSSTypeStyle: TCSSString;
|
|
class function TFresnelElement.GetCSSTypeStyle: TCSSString;
|
|
begin
|
|
begin
|
|
Result:='';
|
|
Result:='';
|