Przeglądaj źródła

TFresnelElement: combined ComputeBaseAttributes and added ComputedOverflowX, ComputedOverflowY, ComputedFloat

mattias 6 miesięcy temu
rodzic
commit
deba992bef
2 zmienionych plików z 42 dodań i 76 usunięć
  1. 41 75
      src/base/fresnel.dom.pas
  2. 1 1
      src/base/fresnel.layouter.pas

+ 41 - 75
src/base/fresnel.dom.pas

@@ -1036,6 +1036,9 @@ type
     FBeforeRender: TNotifyEvent;
     FComputedBoxSizing: TCSSNumericalID;
     FComputedDirection: TCSSNumericalID;
+    FComputedFloat: TCSSNumericalID;
+    FComputedOverflowX: TCSSNumericalID;
+    FComputedOverflowY: TCSSNumericalID;
     FComputedVisibility: TCSSNumericalID;
     FComputedWritingMode: TCSSNumericalID;
     FFont: IFresnelFont;
@@ -1092,12 +1095,7 @@ type
     // compute
     procedure UnsetValue(AttrID: TCSSNumericalID); virtual;
     function ConvertCSSValueToPixel(IsHorizontal: boolean; const Value: string; UseNaNOnFail: boolean): TFresnelLength; virtual;
-    procedure ComputeBoxSizing; virtual;
-    procedure ComputeDirection; virtual;
-    procedure ComputeDisplay; virtual;
-    procedure ComputePosition; virtual;
-    procedure ComputeVisibility; virtual;
-    procedure ComputeWritingMode; virtual;
+    procedure ComputeBaseAttributes; virtual;
     function ComputeAttribute(aDesc: TCSSAttributeDesc; var aValue: String): TCSSAttributeValue.TState; virtual;
     function GetShorthandSpaceSeparated(AttrDesc: TCSSAttributeDesc): string;
   protected
@@ -1216,6 +1214,9 @@ type
     property ComputedDirection: TCSSNumericalID read FComputedDirection;
     property ComputedDisplayInside: TCSSNumericalID read FComputedDisplayInside; // none, flow, flow-root, flex, etc
     property ComputedDisplayOutside: TCSSNumericalID read FComputedDisplayOutside; // none, block, inline
+    property ComputedFloat: TCSSNumericalID read FComputedFloat;
+    property ComputedOverflowX: TCSSNumericalID read FComputedOverflowX;
+    property ComputedOverflowY: TCSSNumericalID read FComputedOverflowY;
     property ComputedPosition: TCSSNumericalID read FComputedPosition;
     property ComputedVisibility: TCSSNumericalID read FComputedVisibility;
     property ComputedWritingMode: TCSSNumericalID read FComputedWritingMode;
@@ -4537,17 +4538,13 @@ end;
 
 function TFresnelCSSRegistry.GetOverflow(El: TFresnelElement): string;
 var
-  X, Y: String;
+  X, Y: TCSSNumericalID;
 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;
+  X:=El.ComputedOverflowX;
+  Y:=El.ComputedOverflowY;
+  Result:=CSSRegistry.Keywords[X];
+  if X<>Y then
+    Result:=Result+' '+CSSRegistry.Keywords[Y];
 end;
 
 function TFresnelCSSRegistry.GetPadding(El: TFresnelElement): string;
@@ -7102,8 +7099,6 @@ function TFresnelElement.IsBlockFormattingContext: boolean;
 // BFC
 // contain internal and external floats
 // surpress margin collapsing
-var
-  aOverflow, aFloat: String;
 begin
   if Parent=nil then
     exit(true);
@@ -7129,18 +7124,13 @@ begin
     exit(true);
   end;
 
-  aOverflow:=ComputedAttribute[fcaOverflow];
-  case aOverflow of
-  'visible',
-  'clip': exit(true);
-  end;
+  if ComputedOverflowX in [CSSRegistry.kwVisible,CSSRegistry.kwClip] then
+    exit(true);
+  if ComputedOverflowY in [CSSRegistry.kwVisible,CSSRegistry.kwClip] then
+    exit(true);
 
-  aFloat:=ComputedAttribute[fcaFloat];
-  case aFloat of
-  '', 'none': ;
-  else
+  if ComputedFloat<>CSSRegistry.kwNone then
     exit(true);
-  end;
 
   Result:=false;
 end;
@@ -8104,23 +8094,7 @@ begin
   Result:=aComp.Float*GetPixPerUnit(aComp.FloatUnit,IsHorizontal);
 end;
 
-procedure TFresnelElement.ComputeBoxSizing;
-begin
-  if fesPseudoElement in FStates then
-    FComputedVisibility:=CSSRegistry.kwContentBox
-  else
-    FComputedBoxSizing:=GetComputedKeyword(fcaBoxSizing,CSSRegistry.Chk_BoxSizing_KeywordIDs);
-end;
-
-procedure TFresnelElement.ComputeDirection;
-begin
-  if fesPseudoElement in FStates then
-    FComputedVisibility:=CSSRegistry.kwLTR
-  else
-    FComputedDirection:=GetComputedKeyword(fcaDirection,CSSRegistry.Chk_Direction_KeywordIDs);
-end;
-
-procedure TFresnelElement.ComputeDisplay;
+procedure TFresnelElement.ComputeBaseAttributes;
 var
   Complete: boolean;
   aValue: String;
@@ -8129,7 +8103,20 @@ var
 begin
   FComputedDisplayInside:=CSSIDNone;
   FComputedDisplayOutside:=CSSIDNone;
-  if (FComputedVisibility=CSSRegistry.kwCollapse) or (fesPseudoElement in FStates) then
+  FComputedDirection:=GetComputedKeyword(fcaDirection,CSSRegistry.Chk_Direction_KeywordIDs);
+  FComputedWritingMode:=GetComputedKeyword(fcaWritingMode,CSSRegistry.Chk_WritingMode_KeywordIDs);
+  FComputedVisibility:=CSSRegistry.kwHidden;
+
+  FComputedBoxSizing:=CSSRegistry.kwContentBox;
+  FComputedPosition:=CSSRegistry.kwStatic;
+  FComputedOverflowX:=CSSRegistry.kwVisible;
+  FComputedOverflowY:=CSSRegistry.kwVisible;
+  FComputedFloat:=CSSRegistry.kwNone;
+
+  if fesPseudoElement in FStates then exit;
+
+  FComputedVisibility:=GetComputedKeyword(fcaVisibility,CSSRegistry.Chk_Visible_KeywordIDs);
+  if FComputedVisibility=CSSRegistry.kwCollapse then
     exit;
 
   aValue:=GetCSSString(CSSRegistry.FresnelAttrs[fcaDisplay].Index,false,Complete);
@@ -8192,30 +8179,14 @@ begin
   end;
   if (FComputedDisplayInside=CSSIDNone) and (FComputedDisplayOutside>CSSIDNone) then
     FComputedDisplayInside:=CSSRegistry.kwFlow;
-end;
-
-procedure TFresnelElement.ComputePosition;
-begin
-  if fesPseudoElement in FStates then
-    FComputedVisibility:=CSSRegistry.kwStatic
-  else
-    FComputedPosition:=GetComputedKeyword(fcaPosition,CSSRegistry.Chk_Position_KeywordIDs);
-end;
 
-procedure TFresnelElement.ComputeVisibility;
-begin
-  if fesPseudoElement in FStates then
-    FComputedVisibility:=CSSRegistry.kwHidden
-  else
-    FComputedVisibility:=GetComputedKeyword(fcaVisibility,CSSRegistry.Chk_Visible_KeywordIDs);
-end;
-
-procedure TFresnelElement.ComputeWritingMode;
-begin
-  if fesPseudoElement in FStates then
-    FComputedVisibility:=CSSRegistry.kwHorizontalTB
-  else
-    FComputedWritingMode:=GetComputedKeyword(fcaWritingMode,CSSRegistry.Chk_WritingMode_KeywordIDs);
+  if FComputedVisibility=CSSRegistry.kwCollapse then
+    exit;
+  FComputedBoxSizing:=GetComputedKeyword(fcaBoxSizing,CSSRegistry.Chk_BoxSizing_KeywordIDs);
+  FComputedPosition:=GetComputedKeyword(fcaPosition,CSSRegistry.Chk_Position_KeywordIDs);
+  FComputedOverflowX:=GetComputedKeyword(fcaOverflowX,CSSRegistry.Chk_OverflowXY_KeywordIDs);
+  FComputedOverflowY:=GetComputedKeyword(fcaOverflowY,CSSRegistry.Chk_OverflowXY_KeywordIDs);
+  FComputedFloat:=GetComputedKeyword(fcaFloat,CSSRegistry.Chk_Float_KeywordIDs);
 end;
 
 function TFresnelElement.ComputeAttribute(aDesc: TCSSAttributeDesc; var aValue: String
@@ -8518,12 +8489,7 @@ begin
     end;
   end;
 
-  ComputeVisibility;
-  ComputeDisplay;
-  ComputePosition;
-  ComputeBoxSizing;
-  ComputeDirection;
-  ComputeWritingMode;
+  ComputeBaseAttributes;
 end;
 
 procedure TFresnelElement.ComputeCSSAfterLayoutNode(Layouter: TFresnelLayouter);

+ 1 - 1
src/base/fresnel.layouter.pas

@@ -70,7 +70,7 @@ type
     destructor Destroy; override;
   end;
 
-  { TFLLineLayouter - abstract base node layouter for }
+  { TFLLineLayouter - abstract base node layouter for TFLFlowLayouter and TFLFlexLayouter }
 
   TFLLineLayouter = class(TFLNodeLayouter)
   protected