CSS2Properties.Mod 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397
  1. MODULE CSS2Properties; (** Stefan Walthert *)
  2. (** AUTHOR "swalthert"; PURPOSE ""; *)
  3. IMPORT
  4. DynamicStrings, XMLObjects, CSS2, WMWindowManager, WMGraphics,
  5. Raster, GfxImages, GfxFonts, Gfx;
  6. CONST
  7. (** Colors *)
  8. Aqua* = LONGINT(0FF00FFFFH);
  9. Black* =LONGINT( 0FF000000H);
  10. Blue* = LONGINT(0FF0000FFH);
  11. Fuchsia* = LONGINT(0FFFF00FFH);
  12. Gray* = LONGINT(0FF808080H);
  13. Green* =LONGINT( 0FF008000H);
  14. Lime* = LONGINT(0FF00FF00H);
  15. Maroon* = LONGINT(0FF800000H);
  16. Navy* = LONGINT(0FF000080H);
  17. Olive* =LONGINT( 0FF808000H);
  18. Purple* = LONGINT(0FF800080H);
  19. Red* = LONGINT(0FFFF0000H);
  20. Silver* = LONGINT(0FFC0C0C0H);
  21. Teal* = LONGINT(0FF008080H);
  22. White* = LONGINT(0FFFFFFFFH);
  23. Yellow* = LONGINT(0FFFFFF00H);
  24. Transparent* = 00000000H;
  25. (** font-size: <absolute-size> *)
  26. XXSmall* = 0; XSmall* = 1; Small* = 2; Medium* = 3; Large* = 4; XLarge* = 5; XXLarge* = 6;
  27. (** font-size: <relative-size> *)
  28. Larger* = 7; Smaller* = 8;
  29. (** Ident.type *)
  30. None* = 1;
  31. Inherit* = 2;
  32. Normal* = 3;
  33. Auto* = 4;
  34. (** background-position *)
  35. Top* = 5; Center* = 6; Bottom* = 7; Left* = 8; Right* = 9;
  36. (** background-repeat *)
  37. Repeat* = 5; NoRepeat* = 6;
  38. (** border-collapse *)
  39. Collapse* = 5; Separate* = 6;
  40. (** border-style *)
  41. Hidden* = 6; Dotted* = 7; Dashed* = 8; Solid* = 9; Double* = 10; Groove* = 11; Ridge* = 12; Inset* = 13; Outset* = 14;
  42. (** border-width *)
  43. Thin* = 5; Thick* = 7;
  44. (** bottom, left, right, top *)
  45. StaticPosition* = 5;
  46. (** clear *)
  47. Clear* = 5;
  48. (** content *)
  49. OpenQuote* = 5; CloseQuote* = 6; NoOpenQuote* = 7; NoCloseQuote* = 8;
  50. (** cursor *)
  51. Crosshair* = 5; Default* = 6; Pointer* = 7; Move* = 8;
  52. EResize* = 9; NEResize* = 10; NWResize* = 11; NResize* = 12; SEResize* = 13; SWResize* = 14; SResize* = 15;
  53. WResize* = 16; Text* = 17; Wait* = 18; Help* = 19;
  54. (** direction *)
  55. Ltr* = 5; Rtl* = 6;
  56. (** display *)
  57. Inline* = 3; Block* = 4; ListItem* = 5; RunIn* = 6; Compact* = 7; Marker* = 8;
  58. Table* = 9; InlineTable* = 10; TableRowGroup* = 11; TableHeaderGroup* = 12; TableFooterGroup* = 13; TableRow* = 14;
  59. TableColumnGroup* = 15; TableColumn* = 16; TableCell* = 17; TableCaption* = 18;
  60. (** empty-cells *)
  61. Show* = 5; Hide* = 6;
  62. (** font *)
  63. Caption* = 5; Icon* = 6; Menu* = 7; MessageBox* = 8; SmallCaption* = 9; StatusBar* = 10;
  64. (** font-stretch *)
  65. Wider* = 5; Narrower* = 6; UltraCondensed* = 7; ExtraCondensed* = 8; Condensed* = 9; SemiCondensed* = 10;
  66. SemiExpanded* = 11; Expanded* = 12; ExtraExpanded* = 13; UltraExpanded* = 14;
  67. (** font-style *)
  68. Italic* = 5; Oblique* = 6;
  69. (** font-variant *)
  70. SmallCaps* = 5;
  71. (** font-weight *)
  72. Bold* = 5; Bolder* = 6; Lighter* = 7;
  73. (** list-style-position *)
  74. Inside* = 5; Outside* = 6;
  75. (** list-style-type *)
  76. Disc* = 5; Circle* = 6; Square* = 7; Decimal* = 8; DecimalLeadingZero* = 9; LowerRoman* = 10; UpperRoman* = 11;
  77. LowerGreek* = 12; LowerAlpha* = 13; LowerLatin* = 14; UpperAlpha* = 15; UpperLatin* = 16;
  78. Hebrew* = 17; Armenian* = 18; Georgian* = 19; CjkIdeographic* = 20;
  79. Hiragana* = 21; Katakana* = 22; HiraganaIroha* = 23; KatakanaIroha* = 24;
  80. (* (** marks *)
  81. Crop* = 120; Cross* = 121; *)
  82. (** outline-color *)
  83. Invert* = 122;
  84. (** overflow, visibility *)
  85. Visible* = 7;
  86. (** position, background-attachment *)
  87. Static* = 5; Relative* = 6; Absolute* = 7; Fixed* = 8; Scroll* = 9;
  88. (** text-align *)
  89. Justify* = 10;
  90. (** text-decoration *)
  91. Underline* = 5; Overline* = 6; LineThrough* = 7; Blink* = 8;
  92. (** text-transform *)
  93. Capitalize* = 5; Uppercase* = 6; Lowercase* = 7;
  94. (** unicodeBidi *)
  95. Embed* = 5; BidiOverride* = 6;
  96. (** vertical-align *)
  97. Baseline* = 8; Sub* = 9; Super* = 10; TextTop* = 11; Middle* = 12; TextBottom* = 13;
  98. (** white-space *)
  99. Pre* = 5; Nowrap* = 6;
  100. (* dummy auto *)
  101. DummyAuto = 0;
  102. VAR
  103. AbsoluteFontSizes: ARRAY 7 OF SHORTINT;
  104. defaultColor*: LONGINT;
  105. defaultCursor*, crosshairCursor*, pointerCursor*, moveCursor*, eResizeCursor*, neResizeCursor*, nwResizeCursor*,
  106. nResizeCursor*, seResizeCursor*, swResizeCursor*, sResizeCursor*, wResizeCursor*, textCursor*, waitCursor*,
  107. helpCursor* : WMWindowManager.PointerInfo;
  108. defaultFont*, captionFont*, iconFont*, menuFont*, messageBoxFont*, smallCaptionFont*, statusBarFont*: GfxFonts.Font;
  109. thinBorder*, mediumBorder*, thickBorder*: LONGREAL;
  110. TYPE
  111. String = CSS2.String;
  112. TYPE
  113. Value* = RECORD specified: CSS2.Term END;
  114. Color* = RECORD (Value) computed*: RECORD r*, g*, b*, a*: CHAR END END;
  115. TRBLColor* = RECORD
  116. top*, right*, bottom*, left*: Color
  117. END;
  118. Ident* = RECORD (Value) computed*: SHORTINT END;
  119. TRBLIdent* = RECORD
  120. top*, right*, bottom*, left*: Ident
  121. END;
  122. Dim* = RECORD (Value) computed*: LONGREAL END;
  123. OrientDim* = RECORD
  124. horizontal*, vertical*: Dim
  125. END;
  126. TRBLDim* = RECORD
  127. top*, right*, bottom*, left*: Dim
  128. END;
  129. Bool* = RECORD (Value) computed*: BOOLEAN END;
  130. Img* = RECORD (Value) computed*: GfxImages.Image END;
  131. Cursor* = RECORD specified: XMLObjects.Collection; computed*: WMWindowManager.PointerInfo END;
  132. Font* = RECORD (Value) computed*: GfxFonts.Font END;
  133. ImgTerm = OBJECT (CSS2.Term)
  134. VAR img: GfxImages.Image
  135. END ImgTerm;
  136. AllMediaProperties* = OBJECT
  137. VAR
  138. parent: AllMediaProperties;
  139. replaced, generated: BOOLEAN;
  140. (* content*, *) counterIncrement*, counterReset*, display*: Ident;
  141. PROCEDURE & Init*;
  142. BEGIN
  143. parent := SELF;
  144. Initialize()
  145. END Init;
  146. PROCEDURE SetParent*(parent: AllMediaProperties);
  147. BEGIN
  148. SELF.parent := parent
  149. END SetParent;
  150. PROCEDURE GetValue*(name: ARRAY OF CHAR): CSS2.Declaration;
  151. VAR declaration: CSS2.Declaration;
  152. BEGIN
  153. NEW(declaration); declaration.SetProperty(name);
  154. IF name = "content" THEN
  155. ELSIF name = "counter-increment" THEN
  156. ELSIF name = "counter-reset" THEN
  157. ELSIF name = "display" THEN
  158. declaration.AddTerm(display.specified)
  159. ELSE
  160. declaration := NIL
  161. END;
  162. RETURN declaration
  163. END GetValue;
  164. PROCEDURE SetValue*(declaration: CSS2.Declaration);
  165. VAR s: String; terms: XMLObjects.Enumerator; c: ANY; term1: CSS2.Term;
  166. BEGIN
  167. s := declaration.GetProperty();
  168. terms := declaration.GetTerms();
  169. c := terms.GetNext();
  170. IF c = NIL THEN RETURN END;
  171. term1 := c(CSS2.Term);
  172. IF s^ = "content" THEN
  173. ELSIF s^ = "counter-increment" THEN
  174. ELSIF s^ = "counter-reset" THEN
  175. ELSIF s^ = "display" THEN
  176. IF ~SetNil(display.specified, term1) & ~SetIdentOrInherit(display.specified, term1) & ~SetNone(display.specified, term1) THEN
  177. IF term1.IsStringIdent("inline") THEN display.specified := ChangeToIdent(Inline)
  178. ELSIF term1.IsStringIdent("block") THEN display.specified := ChangeToIdent(Block)
  179. ELSIF term1.IsStringIdent("list-item") THEN display.specified := ChangeToIdent(ListItem)
  180. ELSIF term1.IsStringIdent("run-in") THEN display.specified := ChangeToIdent(RunIn)
  181. ELSIF term1.IsStringIdent("compact") THEN display.specified := ChangeToIdent(Compact)
  182. ELSIF term1.IsStringIdent("marker") THEN display.specified := ChangeToIdent(Marker)
  183. ELSIF term1.IsStringIdent("table") THEN display.specified := ChangeToIdent(Table)
  184. ELSIF term1.IsStringIdent("inline-table") THEN display.specified := ChangeToIdent(InlineTable)
  185. ELSIF term1.IsStringIdent("table-row-group") THEN display.specified := ChangeToIdent(TableRowGroup)
  186. ELSIF term1.IsStringIdent("table-header-group") THEN display.specified := ChangeToIdent(TableHeaderGroup)
  187. ELSIF term1.IsStringIdent("table-footer-group") THEN display.specified := ChangeToIdent(TableFooterGroup)
  188. ELSIF term1.IsStringIdent("table-row") THEN display.specified := ChangeToIdent(TableRow)
  189. ELSIF term1.IsStringIdent("table-column-group") THEN display.specified := ChangeToIdent(TableColumnGroup)
  190. ELSIF term1.IsStringIdent("table-column") THEN display.specified := ChangeToIdent(TableColumn)
  191. ELSIF term1.IsStringIdent("table-cell") THEN display.specified := ChangeToIdent(TableCell)
  192. ELSIF term1.IsStringIdent("table-caption") THEN display.specified := ChangeToIdent(TableCaption)
  193. END
  194. END
  195. ELSE
  196. END
  197. END SetValue;
  198. PROCEDURE Initialize*;
  199. BEGIN
  200. display.computed := Inline; display.specified := NIL
  201. END Initialize;
  202. PROCEDURE ComputeValues*;
  203. BEGIN
  204. ComputeIdent(display, parent.display)
  205. END ComputeValues;
  206. PROCEDURE IsBlockLevelElement*(): BOOLEAN;
  207. BEGIN
  208. RETURN display.computed IN {Block, ListItem, Compact, RunIn, Table, TableCell}
  209. END IsBlockLevelElement;
  210. PROCEDURE IsInlineLevelElement*(): BOOLEAN;
  211. BEGIN
  212. RETURN display.computed IN {Inline, InlineTable, Compact}
  213. END IsInlineLevelElement;
  214. END AllMediaProperties;
  215. VisualProperties* = OBJECT (AllMediaProperties)
  216. VAR
  217. dimensionChanged-: BOOLEAN;
  218. containingBlock: RECORD
  219. width, height: LONGREAL
  220. END;
  221. ppi*: LONGREAL;
  222. backgroundAttachment*: Bool; (* Scroll = TRUE, Fixed = FALSE *)
  223. backgroundColor*: Color;
  224. backgroundImage*: Img;
  225. backgroundPosition*: OrientDim;
  226. backgroundRepeat*: RECORD horizontal*, vertical*: Bool END; (* Repeat = TRUE, NoRepeat = FALSE *)
  227. borderCollapse*: Bool; (* Collapse = TRUE, Separate = FALSE *)
  228. borderSpacing*: OrientDim;
  229. borderColor*: TRBLColor;
  230. borderStyle*: TRBLIdent;
  231. borderWidth*, margin*, padding*: TRBLDim;
  232. top*, right*, bottom*, left*: Dim;
  233. height*, width*, maxHeight*, maxWidth*, minHeight*, minWidth*: Dim;
  234. captionSide*: Ident;
  235. clear*: RECORD left*, right*: Bool END; (* Clear = TRUE, None = FALSE *)
  236. clip*: TRBLDim;
  237. color*: Color;
  238. cursor*: Cursor;
  239. direction*: Bool; (* Ltr = TRUE, Rtl = FALSE *)
  240. emptyCells*: Bool; (* Show = TRUE, Hide = FALSE *)
  241. float*: Ident;
  242. font*: Font;
  243. fontSize*: Dim;
  244. fontFamily*, fontSizeAdjust*, fontStyle*, fontWeight*: CSS2.Term;
  245. fontStretch*: Ident;
  246. fontVariant*: Bool; (* Normal = TRUE, Smallcaps = FALSE *)
  247. letterSpacing*, wordSpacing*: Dim;
  248. lineHeight*: Dim;
  249. listStyleImage*: Img;
  250. listStylePosition*: Bool; (* Outside = TRUE, Inside = FALSE *)
  251. listStyleType*: Ident;
  252. markerOffset*: Dim;
  253. outlineColor*: Color; (* Invert = Transparent *)
  254. outlineStyle*: Ident;
  255. outlineWidth*: Dim;
  256. overflow*: Ident;
  257. position*: Ident;
  258. quotes*: RECORD (Value) END;
  259. tableLayout*: Bool; (* Auto = TRUE, Fixed = FALSE *)
  260. textAlign*: Ident;
  261. textDecoration*: RECORD (Value) computed*: SET END;
  262. textIndent*: Dim;
  263. textShadow*: RECORD (Value) END;
  264. textTransform*: Ident;
  265. unicodeBidi*: Ident;
  266. verticalAlign*: RECORD (Value) computedLength*: LONGREAL; computed*: SHORTINT END;
  267. visibility*: Ident;
  268. whiteSpace*: Ident;
  269. zIndex*: RECORD (Value) computed*: LONGINT END; (* Auto = -1 *)
  270. PROCEDURE &Init*;
  271. BEGIN
  272. Init^();
  273. ppi := 91.44
  274. END Init;
  275. PROCEDURE SetParent*(parent: AllMediaProperties);
  276. BEGIN
  277. IF parent IS VisualProperties THEN SetParent^(parent) END
  278. END SetParent;
  279. PROCEDURE GetValue*(name: ARRAY OF CHAR): CSS2.Declaration;
  280. VAR declaration: CSS2.Declaration; term1: CSS2.Term;
  281. BEGIN
  282. NEW(declaration); declaration.SetProperty(name);
  283. IF name = "background-attachment" THEN
  284. declaration.AddTerm(backgroundAttachment.specified)
  285. ELSIF name = "background-color" THEN
  286. declaration.AddTerm(backgroundColor.specified)
  287. ELSIF name = "background-image" THEN
  288. declaration.AddTerm(backgroundImage.specified)
  289. ELSIF name = "background-position" THEN
  290. declaration.AddTerm(backgroundPosition.horizontal.specified);
  291. declaration.AddTerm(backgroundPosition.vertical.specified)
  292. ELSIF name = "background-repeat" THEN
  293. IF (backgroundRepeat.horizontal.specified # NIL) & backgroundRepeat.horizontal.specified.IsIdent(NoRepeat)
  294. & (backgroundRepeat.vertical.specified # NIL) & backgroundRepeat.vertical.specified.IsIdent(NoRepeat) THEN
  295. ChangeToStringIdent(term1, "no-repeat")
  296. ELSIF (backgroundRepeat.horizontal.specified # NIL) & backgroundRepeat.horizontal.specified.IsIdent(Repeat)
  297. & (backgroundRepeat.vertical.specified # NIL) & backgroundRepeat.vertical.specified.IsIdent(NoRepeat) THEN
  298. ChangeToStringIdent(term1, "repeat-x")
  299. ELSIF (backgroundRepeat.horizontal.specified # NIL) & backgroundRepeat.horizontal.specified.IsIdent(NoRepeat)
  300. & (backgroundRepeat.vertical.specified # NIL) & backgroundRepeat.vertical.specified.IsIdent(Repeat) THEN
  301. ChangeToStringIdent(term1, "repeat-y")
  302. ELSIF (backgroundRepeat.horizontal.specified # NIL) & backgroundRepeat.horizontal.specified.IsIdent(Repeat)
  303. & (backgroundRepeat.vertical.specified # NIL) & backgroundRepeat.vertical.specified.IsIdent(Repeat) THEN
  304. ChangeToStringIdent(term1, "repeat")
  305. END;
  306. declaration.AddTerm(term1)
  307. ELSIF name = "border" THEN
  308. declaration.AddTerm(borderWidth.top.specified);
  309. declaration.AddTerm(borderStyle.top.specified);
  310. declaration.AddTerm(borderColor.top.specified)
  311. ELSIF name = "border-collapse" THEN
  312. declaration.AddTerm(borderCollapse.specified)
  313. ELSIF name = "border-color" THEN
  314. declaration.AddTerm(borderColor.top.specified);
  315. declaration.AddTerm(borderColor.right.specified);
  316. declaration.AddTerm(borderColor.bottom.specified);
  317. declaration.AddTerm(borderColor.left.specified)
  318. ELSIF name = "border-spacing" THEN
  319. declaration.AddTerm(borderSpacing.horizontal.specified);
  320. declaration.AddTerm(borderSpacing.vertical.specified)
  321. ELSIF name = "border-style" THEN
  322. declaration.AddTerm(borderStyle.top.specified);
  323. declaration.AddTerm(borderStyle.right.specified);
  324. declaration.AddTerm(borderStyle.bottom.specified);
  325. declaration.AddTerm(borderStyle.left.specified)
  326. ELSIF name = "border-top" THEN
  327. declaration.AddTerm(borderWidth.top.specified);
  328. declaration.AddTerm(borderStyle.top.specified);
  329. declaration.AddTerm(borderColor.top.specified)
  330. ELSIF name = "border-right" THEN
  331. declaration.AddTerm(borderWidth.right.specified);
  332. declaration.AddTerm(borderStyle.right.specified);
  333. declaration.AddTerm(borderColor.right.specified)
  334. ELSIF name = "border-bottom" THEN
  335. declaration.AddTerm(borderWidth.bottom.specified);
  336. declaration.AddTerm(borderStyle.bottom.specified);
  337. declaration.AddTerm(borderColor.bottom.specified)
  338. ELSIF name = "border-left" THEN
  339. declaration.AddTerm(borderWidth.left.specified);
  340. declaration.AddTerm(borderStyle.left.specified);
  341. declaration.AddTerm(borderColor.left.specified)
  342. ELSIF name = "border-top-color" THEN
  343. declaration.AddTerm(borderColor.top.specified)
  344. ELSIF name = "border-right-color" THEN
  345. declaration.AddTerm(borderColor.right.specified)
  346. ELSIF name = "border-bottom-color" THEN
  347. declaration.AddTerm(borderColor.bottom.specified)
  348. ELSIF name = "border-left-color" THEN
  349. declaration.AddTerm(borderColor.left.specified)
  350. ELSIF name = "border-top-style" THEN
  351. declaration.AddTerm(borderStyle.top.specified)
  352. ELSIF name = "border-right-style" THEN
  353. declaration.AddTerm(borderStyle.right.specified)
  354. ELSIF name = "border-bottom-style" THEN
  355. declaration.AddTerm(borderStyle.bottom.specified)
  356. ELSIF name = "border-left-style" THEN
  357. declaration.AddTerm(borderStyle.left.specified)
  358. ELSIF name = "border-top-width" THEN
  359. declaration.AddTerm(borderWidth.top.specified)
  360. ELSIF name = "border-right-width" THEN
  361. declaration.AddTerm(borderWidth.right.specified)
  362. ELSIF name = "border-bottom-width" THEN
  363. declaration.AddTerm(borderWidth.bottom.specified)
  364. ELSIF name = "border-left-width" THEN
  365. declaration.AddTerm(borderWidth.left.specified)
  366. ELSIF name = "border-width" THEN
  367. declaration.AddTerm(borderWidth.top.specified);
  368. declaration.AddTerm(borderWidth.right.specified);
  369. declaration.AddTerm(borderWidth.bottom.specified);
  370. declaration.AddTerm(borderWidth.left.specified)
  371. ELSIF name = "bottom" THEN
  372. declaration.AddTerm(bottom.specified)
  373. ELSIF name = "caption-side" THEN
  374. declaration.AddTerm(captionSide.specified)
  375. ELSIF name = "clear" THEN
  376. IF clear.left.specified.IsIdent(None) & clear.left.specified.IsIdent(None) THEN
  377. ChangeToStringIdent(term1, "none")
  378. ELSIF clear.left.specified.IsIdent(Clear) & clear.left.specified.IsIdent(None) THEN
  379. ChangeToStringIdent(term1, "left")
  380. ELSIF clear.left.specified.IsIdent(None) & clear.left.specified.IsIdent(Clear) THEN
  381. ChangeToStringIdent(term1, "right")
  382. ELSIF clear.left.specified.IsIdent(Clear) & clear.left.specified.IsIdent(Clear) THEN
  383. ChangeToStringIdent(term1, "both")
  384. ELSE
  385. END;
  386. declaration.AddTerm(term1)
  387. ELSIF name = "clip" THEN
  388. (* declaration.AddTerm(.specified)*)
  389. ELSIF name = "color" THEN
  390. declaration.AddTerm(color.specified)
  391. ELSIF name = "cursor" THEN
  392. ELSIF name = "direction" THEN
  393. declaration.AddTerm(direction.specified)
  394. ELSIF name = "empty-cells" THEN
  395. declaration.AddTerm(emptyCells.specified)
  396. ELSIF name = "float" THEN
  397. declaration.AddTerm(float.specified)
  398. ELSIF name = "font" THEN
  399. declaration.AddTerm(font.specified);
  400. declaration.AddTerm(fontStyle);
  401. declaration.AddTerm(fontVariant.specified);
  402. declaration.AddTerm(fontWeight);
  403. IF fontSize.specified # NIL THEN
  404. fontSize.specified.SetOperator(CSS2.Slash); declaration.AddTerm(fontSize.specified)
  405. END;
  406. declaration.AddTerm(lineHeight.specified);
  407. declaration.AddTerm(fontFamily)
  408. ELSIF name = "font-family" THEN
  409. declaration.AddTerm(fontFamily)
  410. ELSIF name = "font-size" THEN
  411. declaration.AddTerm(fontSize.specified)
  412. ELSIF name = "font-size-adjust" THEN
  413. declaration.AddTerm(fontSizeAdjust)
  414. ELSIF name = "font-stretch" THEN
  415. declaration.AddTerm(fontStretch.specified)
  416. ELSIF name = "font-style" THEN
  417. declaration.AddTerm(fontStyle)
  418. ELSIF name = "font-variant" THEN
  419. declaration.AddTerm(fontVariant.specified)
  420. ELSIF name = "font-weight" THEN
  421. declaration.AddTerm(fontWeight)
  422. ELSIF name = "height" THEN
  423. declaration.AddTerm(height.specified)
  424. ELSIF name = "left" THEN
  425. declaration.AddTerm(left.specified)
  426. ELSIF name = "letter-spacing" THEN
  427. declaration.AddTerm(letterSpacing.specified)
  428. ELSIF name = "line-height" THEN
  429. declaration.AddTerm(lineHeight.specified)
  430. ELSIF name = "list-style" THEN
  431. declaration.AddTerm(listStyleType.specified);
  432. declaration.AddTerm(listStylePosition.specified);
  433. declaration.AddTerm(listStyleImage.specified)
  434. ELSIF name = "list-style-image" THEN
  435. declaration.AddTerm(listStyleImage.specified)
  436. ELSIF name = "list-style-position" THEN
  437. declaration.AddTerm(listStylePosition.specified)
  438. ELSIF name = "list-style-type" THEN
  439. declaration.AddTerm(listStyleType.specified)
  440. ELSIF name = "margin" THEN
  441. declaration.AddTerm(margin.top.specified);
  442. declaration.AddTerm(margin.right.specified);
  443. declaration.AddTerm(margin.bottom.specified);
  444. declaration.AddTerm(margin.left.specified)
  445. ELSIF name = "margin-top" THEN
  446. declaration.AddTerm(margin.top.specified)
  447. ELSIF name = "margin-right" THEN
  448. declaration.AddTerm(margin.right.specified)
  449. ELSIF name = "margin-bottom" THEN
  450. declaration.AddTerm(margin.bottom.specified)
  451. ELSIF name = "margin-left" THEN
  452. declaration.AddTerm(margin.left.specified)
  453. ELSIF name = "marker-offset" THEN
  454. declaration.AddTerm(markerOffset.specified)
  455. ELSIF name = "max-height" THEN
  456. declaration.AddTerm(maxHeight.specified)
  457. ELSIF name = "max-width" THEN
  458. declaration.AddTerm(maxWidth.specified)
  459. ELSIF name = "min-height" THEN
  460. declaration.AddTerm(minHeight.specified)
  461. ELSIF name = "min-width" THEN
  462. declaration.AddTerm(minWidth.specified)
  463. ELSIF name = "outline" THEN
  464. declaration.AddTerm(outlineColor.specified);
  465. declaration.AddTerm(outlineStyle.specified);
  466. declaration.AddTerm(outlineWidth.specified)
  467. ELSIF name = "outline-color" THEN
  468. declaration.AddTerm(outlineColor.specified)
  469. ELSIF name = "outline-style" THEN
  470. declaration.AddTerm(outlineStyle.specified)
  471. ELSIF name = "outline-width" THEN
  472. declaration.AddTerm(outlineWidth.specified)
  473. ELSIF name = "overflow" THEN
  474. declaration.AddTerm(overflow.specified)
  475. ELSIF name = "padding" THEN
  476. declaration.AddTerm(padding.top.specified);
  477. declaration.AddTerm(padding.right.specified);
  478. declaration.AddTerm(padding.bottom.specified);
  479. declaration.AddTerm(padding.left.specified)
  480. ELSIF name = "padding-top" THEN
  481. declaration.AddTerm(padding.top.specified)
  482. ELSIF name = "padding-right" THEN
  483. declaration.AddTerm(padding.right.specified)
  484. ELSIF name = "padding-bottom" THEN
  485. declaration.AddTerm(padding.bottom.specified)
  486. ELSIF name = "padding-left" THEN
  487. declaration.AddTerm(padding.left.specified)
  488. ELSIF name = "position" THEN
  489. declaration.AddTerm(position.specified)
  490. ELSIF name = "quotes" THEN
  491. ELSIF name = "right" THEN
  492. declaration.AddTerm(right.specified)
  493. ELSIF name = "table-layout" THEN
  494. declaration.AddTerm(tableLayout.specified)
  495. ELSIF name = "text-align" THEN
  496. declaration.AddTerm(textAlign.specified)
  497. ELSIF name = "text-decoration" THEN
  498. ELSIF name = "text-indent" THEN
  499. declaration.AddTerm(textIndent.specified)
  500. ELSIF name = "text-shadow" THEN
  501. ELSIF name = "text-transform" THEN
  502. declaration.AddTerm(textTransform.specified)
  503. ELSIF name = "top" THEN
  504. declaration.AddTerm(top.specified)
  505. ELSIF name = "unicode-bidi" THEN
  506. declaration.AddTerm(unicodeBidi.specified)
  507. ELSIF name = "vertical-align" THEN
  508. declaration.AddTerm(verticalAlign.specified)
  509. ELSIF name = "visibility" THEN
  510. declaration.AddTerm(visibility.specified)
  511. ELSIF name = "white-space" THEN
  512. declaration.AddTerm(whiteSpace.specified)
  513. ELSIF name = "width" THEN
  514. declaration.AddTerm(width.specified)
  515. ELSIF name = "word-spacing" THEN
  516. declaration.AddTerm(wordSpacing.specified)
  517. ELSIF name = "z-index" THEN
  518. declaration.AddTerm(zIndex.specified)
  519. ELSE
  520. declaration := GetValue^(name)
  521. END;
  522. RETURN declaration
  523. END GetValue;
  524. PROCEDURE SetValue*(declaration: CSS2.Declaration);
  525. VAR s: String; terms: XMLObjects.Enumerator; c: ANY;
  526. term1, term2, term3, term4, term5, term6: CSS2.Term; i: LONGINT; imgTerm: ImgTerm;
  527. BEGIN
  528. s := declaration.GetProperty();
  529. terms := declaration.GetTerms();
  530. c := terms.GetNext();
  531. IF c # NIL THEN term1 := c(CSS2.Term) ELSE term1 := NIL END;
  532. IF terms.HasMoreElements() THEN c := terms.GetNext(); term2 := c(CSS2.Term);
  533. IF terms.HasMoreElements() THEN c := terms.GetNext(); term3 := c(CSS2.Term);
  534. IF terms.HasMoreElements() THEN c := terms.GetNext(); term4 := c(CSS2.Term)
  535. END
  536. END
  537. END;
  538. IF s^ = "background-attachment" THEN
  539. IF ~SetNil(backgroundAttachment.specified, term1) & ~SetIdentOrInherit(backgroundAttachment.specified, term1) THEN
  540. IF term1.IsStringIdent("scroll") THEN backgroundAttachment.specified := ChangeToIdent(Scroll)
  541. ELSIF term1.IsStringIdent("fixed") THEN backgroundAttachment.specified := ChangeToIdent(Fixed)
  542. END
  543. END
  544. ELSIF s^ = "background-color" THEN
  545. SetColor(backgroundColor.specified, term1, FALSE)
  546. ELSIF s^ = "background-image" THEN
  547. IF ~SetNil(backgroundImage.specified, term1) & ~SetIdentOrInherit(backgroundImage.specified, term1)
  548. & ~SetNone(backgroundImage.specified, term1) THEN
  549. IF term1.GetType() = CSS2.URI THEN
  550. s := term1.GetStringVal();
  551. NEW(imgTerm); imgTerm.img := WMGraphics.LoadImage(s^, TRUE);
  552. IF imgTerm.img # NIL THEN
  553. backgroundImage.specified := imgTerm; declaration.RemoveTerm(term1); declaration.AddTerm(imgTerm)
  554. END
  555. ELSIF term1 IS ImgTerm THEN backgroundImage.specified := term1
  556. END
  557. END
  558. ELSIF s^ = "background-position" THEN
  559. IF ~SetNil(backgroundPosition.horizontal.specified, term1) & ~SetNil(backgroundPosition.vertical.specified, term1)
  560. & ~SetIdentOrInherit(backgroundPosition.horizontal.specified, term1)
  561. & ~SetIdentOrInherit(backgroundPosition.vertical.specified, term1) THEN
  562. IF term2 = NIL THEN
  563. NEW(term2); term2.SetType(CSS2.Percent); term2.SetRealVal(0.5)
  564. END;
  565. IF term1.IsStringIdent("top") OR term1.IsStringIdent("bottom") THEN
  566. term3 := term1; term1 := term2; term2 := term3 (* swap term1, term2 *)
  567. END;
  568. IF backgroundPosition.horizontal.specified = NIL THEN NEW(backgroundPosition.horizontal.specified) END;
  569. IF term1.IsStringIdent("left") THEN
  570. backgroundPosition.horizontal.specified.SetType(CSS2.Percent); backgroundPosition.horizontal.specified.SetRealVal(0.0)
  571. ELSIF term1.IsStringIdent("center") THEN
  572. backgroundPosition.horizontal.specified.SetType(CSS2.Percent); backgroundPosition.horizontal.specified.SetRealVal(0.5)
  573. ELSIF term1.IsStringIdent("right") THEN
  574. backgroundPosition.horizontal.specified.SetType(CSS2.Percent);
  575. backgroundPosition.horizontal.specified.SetRealVal(1.0)
  576. ELSIF term1.IsLength() OR (term1.GetType() = CSS2.Percent) THEN
  577. backgroundPosition.horizontal.specified := term1
  578. END;
  579. IF backgroundPosition.vertical.specified = NIL THEN NEW(backgroundPosition.vertical.specified) END;
  580. IF term2.IsStringIdent("top") THEN
  581. backgroundPosition.vertical.specified.SetType(CSS2.Percent); backgroundPosition.vertical.specified.SetRealVal(0.0)
  582. ELSIF term2.IsStringIdent("center") THEN
  583. backgroundPosition.vertical.specified.SetType(CSS2.Percent); backgroundPosition.vertical.specified.SetRealVal(0.5)
  584. ELSIF term2.IsStringIdent("bottom") THEN
  585. backgroundPosition.vertical.specified.SetType(CSS2.Percent); backgroundPosition.vertical.specified.SetRealVal(1.0)
  586. ELSIF term2.IsLength() OR (term2.GetType() = CSS2.Percent) THEN
  587. backgroundPosition.vertical.specified := term2
  588. END
  589. END
  590. ELSIF s^ = "background-repeat" THEN
  591. IF term1 = NIL THEN
  592. backgroundRepeat.horizontal.specified := NIL; backgroundRepeat.vertical.specified := NIL
  593. ELSIF term1.IsStringIdent("inherit") THEN
  594. backgroundRepeat.horizontal.specified := ChangeToIdent(Inherit);
  595. backgroundRepeat.vertical.specified := ChangeToIdent(Inherit)
  596. ELSIF term1.IsStringIdent("repeat") THEN
  597. backgroundRepeat.horizontal.specified := ChangeToIdent(Repeat);
  598. backgroundRepeat.vertical.specified := ChangeToIdent(Repeat)
  599. ELSIF term1.IsStringIdent("repeat-x") THEN
  600. backgroundRepeat.horizontal.specified := ChangeToIdent(Repeat);
  601. backgroundRepeat.vertical.specified := ChangeToIdent(NoRepeat)
  602. ELSIF term1.IsStringIdent("repeat-y") THEN
  603. backgroundRepeat.horizontal.specified := ChangeToIdent(NoRepeat);
  604. backgroundRepeat.vertical.specified := ChangeToIdent(Repeat)
  605. ELSIF term1.IsStringIdent("no-repeat") THEN
  606. backgroundRepeat.horizontal.specified := ChangeToIdent(NoRepeat);
  607. backgroundRepeat.vertical.specified := ChangeToIdent(NoRepeat)
  608. END
  609. ELSIF s^ = "border" THEN
  610. IF term1.IsStringIdent("inherit") THEN
  611. borderWidth.top.specified := ChangeToIdent(Inherit);
  612. borderWidth.right.specified := ChangeToIdent(Inherit);
  613. borderWidth.bottom.specified := ChangeToIdent(Inherit);
  614. borderWidth.left.specified := ChangeToIdent(Inherit);
  615. borderStyle.top.specified := ChangeToIdent(Inherit);
  616. borderStyle.right.specified := ChangeToIdent(Inherit);
  617. borderStyle.bottom.specified := ChangeToIdent(Inherit);
  618. borderStyle.left.specified := ChangeToIdent(Inherit);
  619. borderColor.top.specified := ChangeToIdent(Inherit);
  620. borderColor.right.specified := ChangeToIdent(Inherit);
  621. borderColor.bottom.specified := ChangeToIdent(Inherit);
  622. borderColor.left.specified := ChangeToIdent(Inherit)
  623. ELSE
  624. IF IsBorderWidth(term1) THEN
  625. BorderWidth(borderWidth.top.specified, term1);
  626. BorderWidth(borderWidth.right.specified, term1);
  627. BorderWidth(borderWidth.bottom.specified, term1);
  628. BorderWidth(borderWidth.left.specified, term1);
  629. term1 := term2
  630. END;
  631. IF IsBorderStyle(term1) THEN
  632. BorderStyle(borderStyle.top.specified, term1);
  633. BorderStyle(borderStyle.right.specified, term1);
  634. BorderStyle(borderStyle.bottom.specified, term1);
  635. BorderStyle(borderStyle.left.specified, term1);
  636. term1 := term2
  637. END;
  638. IF (term1 # NIL) THEN
  639. SetColor(borderColor.top.specified, term1, FALSE);
  640. SetColor(borderColor.right.specified, term1, FALSE);
  641. SetColor(borderColor.bottom.specified, term1, FALSE);
  642. SetColor(borderColor.left.specified, term1, FALSE)
  643. ELSE
  644. borderColor.top.specified := color.specified;
  645. borderColor.right.specified := color.specified;
  646. borderColor.bottom.specified := color.specified;
  647. borderColor.left.specified := color.specified
  648. END
  649. END
  650. ELSIF s^ = "border-collapse" THEN
  651. IF ~SetNil(borderCollapse.specified, term1) & ~SetIdentOrInherit(borderCollapse.specified, term1) THEN
  652. IF term1.IsStringIdent("collapse") THEN borderCollapse.specified := ChangeToIdent(Collapse)
  653. ELSIF term1.IsStringIdent("separate") THEN borderCollapse.specified := ChangeToIdent(Separate)
  654. END
  655. END
  656. ELSIF s^ = "border-color" THEN
  657. SetColor(borderColor.top.specified, term1, FALSE);
  658. IF term2 # NIL THEN
  659. SetColor(borderColor.right.specified, term2, FALSE);
  660. IF term3 # NIL THEN
  661. SetColor(borderColor.bottom.specified, term3, FALSE);
  662. IF term4 # NIL THEN
  663. SetColor(borderColor.left.specified, term4, FALSE)
  664. ELSE
  665. SetColor(borderColor.left.specified, term2, FALSE)
  666. END
  667. ELSE
  668. SetColor(borderColor.bottom.specified, term1, FALSE);
  669. SetColor(borderColor.left.specified, term2, FALSE)
  670. END
  671. ELSE
  672. SetColor(borderColor.right.specified, term1, FALSE);
  673. SetColor(borderColor.bottom.specified, term1, FALSE);
  674. SetColor(borderColor.left.specified, term1, FALSE)
  675. END
  676. ELSIF s^ = "border-spacing" THEN
  677. IF term1 = NIL THEN
  678. borderSpacing.horizontal.specified := NIL; borderSpacing.vertical.specified := NIL
  679. ELSIF term1.IsStringIdent("inherit") THEN
  680. borderSpacing.horizontal.specified := ChangeToIdent(Inherit);
  681. borderSpacing.vertical.specified := ChangeToIdent(Inherit)
  682. ELSE
  683. IF term1.IsLength() THEN
  684. borderSpacing.horizontal.specified := term1;
  685. IF term2 = NIL THEN term2 := term1 END;
  686. IF term2.IsLength() THEN
  687. borderSpacing.vertical.specified := term2
  688. END
  689. END
  690. END
  691. ELSIF s^ = "border-style" THEN
  692. BorderStyle(borderStyle.top.specified, term1);
  693. IF term2 # NIL THEN
  694. BorderStyle(borderStyle.right.specified, term2);
  695. IF term3 # NIL THEN
  696. BorderStyle(borderStyle.bottom.specified, term3);
  697. IF term4 # NIL THEN
  698. BorderStyle(borderStyle.left.specified, term4)
  699. ELSE
  700. BorderStyle(borderStyle.left.specified, term2)
  701. END
  702. ELSE
  703. BorderStyle(borderStyle.bottom.specified, term1);
  704. BorderStyle(borderStyle.left.specified, term2)
  705. END
  706. ELSE
  707. BorderStyle(borderStyle.right.specified, term1);
  708. BorderStyle(borderStyle.bottom.specified, term1);
  709. BorderStyle(borderStyle.left.specified, term1)
  710. END
  711. ELSIF s^ = "border-top" THEN
  712. IF term1.IsStringIdent("inherit") THEN
  713. borderWidth.top.specified := ChangeToIdent(Inherit);
  714. borderStyle.top.specified := ChangeToIdent(Inherit);
  715. borderColor.top.specified := ChangeToIdent(Inherit)
  716. ELSE
  717. IF IsBorderWidth(term1) THEN
  718. BorderWidth(borderWidth.top.specified, term1);
  719. term1 := term2
  720. END;
  721. IF IsBorderStyle(term1) THEN
  722. BorderStyle(borderStyle.top.specified, term1);
  723. term1 := term2
  724. END;
  725. IF (term1 # NIL) THEN
  726. SetColor(borderColor.top.specified, term1, FALSE)
  727. ELSE
  728. borderColor.top.specified := color.specified
  729. END
  730. END
  731. ELSIF s^ = "border-right" THEN
  732. IF term1.IsStringIdent("inherit") THEN
  733. borderWidth.right.specified := ChangeToIdent(Inherit);
  734. borderStyle.right.specified := ChangeToIdent(Inherit);
  735. borderColor.right.specified := ChangeToIdent(Inherit)
  736. ELSE
  737. IF IsBorderWidth(term1) THEN
  738. BorderWidth(borderWidth.right.specified, term1);
  739. term1 := term2
  740. END;
  741. IF IsBorderWidth(term1) THEN
  742. BorderStyle(borderStyle.right.specified, term1);
  743. term1 := term2
  744. END;
  745. IF (term1 # NIL) THEN
  746. SetColor(borderColor.right.specified, term1, FALSE)
  747. ELSE
  748. borderColor.right.specified := color.specified
  749. END
  750. END
  751. ELSIF s^ = "border-bottom" THEN
  752. IF term1.IsStringIdent("inherit") THEN
  753. borderWidth.bottom.specified := ChangeToIdent(Inherit);
  754. borderStyle.bottom.specified := ChangeToIdent(Inherit);
  755. borderColor.bottom.specified := ChangeToIdent(Inherit)
  756. ELSE
  757. IF IsBorderWidth(term1) THEN
  758. BorderWidth(borderWidth.bottom.specified, term1);
  759. term1 := term2
  760. END;
  761. IF IsBorderWidth(term1) THEN
  762. BorderStyle(borderStyle.bottom.specified, term1);
  763. term1 := term2
  764. END;
  765. IF (term1 # NIL) THEN
  766. SetColor(borderColor.bottom.specified, term1, FALSE)
  767. ELSE
  768. borderColor.bottom.specified := color.specified
  769. END
  770. END
  771. ELSIF s^ = "border-left" THEN
  772. IF term1.IsStringIdent("inherit") THEN
  773. borderWidth.left.specified := ChangeToIdent(Inherit);
  774. borderStyle.left.specified := ChangeToIdent(Inherit);
  775. borderColor.left.specified := ChangeToIdent(Inherit)
  776. ELSE
  777. IF IsBorderWidth(term1) THEN
  778. BorderWidth(borderWidth.left.specified, term1);
  779. term1 := term2
  780. END;
  781. IF IsBorderWidth(term1) THEN
  782. BorderStyle(borderStyle.left.specified, term1);
  783. term1 := term2
  784. END;
  785. IF (term1 # NIL) THEN
  786. SetColor(borderColor.left.specified, term1, FALSE)
  787. ELSE
  788. borderColor.left.specified := color.specified
  789. END
  790. END
  791. ELSIF s^ = "border-top-color" THEN
  792. SetColor(borderColor.top.specified, term1, FALSE)
  793. ELSIF s^ = "border-right-color" THEN
  794. SetColor(borderColor.right.specified, term1, FALSE)
  795. ELSIF s^ = "border-bottom-color" THEN
  796. SetColor(borderColor.bottom.specified, term1, FALSE)
  797. ELSIF s^ = "border-left-color" THEN
  798. SetColor(borderColor.left.specified, term1, FALSE)
  799. ELSIF s^ = "border-top-style" THEN
  800. BorderStyle(borderStyle.top.specified, term1)
  801. ELSIF s^ = "border-right-style" THEN
  802. BorderStyle(borderStyle.right.specified, term1)
  803. ELSIF s^ = "border-bottom-style" THEN
  804. BorderStyle(borderStyle.bottom.specified, term1)
  805. ELSIF s^ = "border-left-style" THEN
  806. BorderStyle(borderStyle.left.specified, term1)
  807. ELSIF s^ = "border-top-width" THEN
  808. BorderWidth(borderWidth.top.specified, term1)
  809. ELSIF s^ = "border-right-width" THEN
  810. BorderWidth(borderWidth.right.specified, term1)
  811. ELSIF s^ = "border-bottom-width" THEN
  812. BorderWidth(borderWidth.bottom.specified, term1)
  813. ELSIF s^ = "border-left-width" THEN
  814. BorderWidth(borderWidth.left.specified, term1)
  815. ELSIF s^ = "border-width" THEN
  816. BorderWidth(borderWidth.top.specified, term1);
  817. IF term2 # NIL THEN
  818. BorderWidth(borderWidth.right.specified, term2);
  819. IF term3 # NIL THEN
  820. BorderWidth(borderWidth.bottom.specified, term3);
  821. IF term4 # NIL THEN
  822. BorderWidth(borderWidth.left.specified, term4)
  823. ELSE
  824. BorderWidth(borderWidth.left.specified, term2)
  825. END
  826. ELSE
  827. BorderWidth(borderWidth.bottom.specified, term1);
  828. BorderWidth(borderWidth.left.specified, term2)
  829. END
  830. ELSE
  831. BorderWidth(borderWidth.right.specified, term1);
  832. BorderWidth(borderWidth.bottom.specified, term1);
  833. BorderWidth(borderWidth.left.specified, term1)
  834. END
  835. ELSIF s^ = "bottom" THEN
  836. BoxOffset(bottom.specified, term1)
  837. ELSIF s^ = "caption-side" THEN
  838. IF ~SetNil(captionSide.specified, term1) & ~SetIdentOrInherit(captionSide.specified, term1) THEN
  839. IF term1.IsStringIdent("top") THEN captionSide.specified := ChangeToIdent(Top)
  840. ELSIF term1.IsStringIdent("bottom") THEN captionSide.specified := ChangeToIdent(Bottom)
  841. ELSIF term1.IsStringIdent("left") THEN captionSide.specified := ChangeToIdent(Left)
  842. ELSIF term1.IsStringIdent("right") THEN captionSide.specified := ChangeToIdent(Right)
  843. END
  844. END
  845. ELSIF s^ = "clear" THEN
  846. IF term1 = NIL THEN
  847. clear.left.specified := NIL; clear.right.specified := NIL
  848. ELSIF term1.IsStringIdent("inherit") THEN
  849. clear.left.specified := ChangeToIdent(Inherit); clear.right.specified := ChangeToIdent(Inherit)
  850. ELSIF term1.IsStringIdent("none") THEN
  851. clear.left.specified := ChangeToIdent(None); clear.right.specified := ChangeToIdent(None)
  852. ELSIF term1.IsStringIdent("left") THEN
  853. clear.left.specified := ChangeToIdent(Clear); clear.right.specified := ChangeToIdent(None)
  854. ELSIF term1.IsStringIdent("right") THEN
  855. clear.left.specified := ChangeToIdent(None); clear.right.specified := ChangeToIdent(Clear)
  856. ELSIF term1.IsStringIdent("both") THEN
  857. clear.left.specified := ChangeToIdent(Clear); clear.right.specified := ChangeToIdent(Clear)
  858. END
  859. ELSIF s^ = "clip" THEN
  860. IF term1 = NIL THEN
  861. clip.top.specified := NIL; clip.right.specified := NIL; clip.bottom.specified := NIL; clip.left.specified := NIL
  862. ELSIF term1.IsStringIdent("inherit") THEN
  863. clip.top.specified := ChangeToIdent(Inherit); clip.right.specified := ChangeToIdent(Inherit);
  864. clip.bottom.specified := ChangeToIdent(Inherit); clip.left.specified := ChangeToIdent(Inherit)
  865. ELSIF term1.IsStringIdent("auto") THEN
  866. clip.top.specified := ChangeToPixel(0.0); clip.right.specified := ChangeToPixel(0.0);
  867. clip.bottom.specified := ChangeToPixel(0.0); clip.left.specified := ChangeToPixel(0.0)
  868. ELSIF term1.GetType() = CSS2.Function THEN
  869. s := term1.GetStringVal();
  870. IF s^ = "rect" THEN
  871. terms := term1.GetTerms();
  872. IF terms.HasMoreElements() THEN c := terms.GetNext(); term1 := c(CSS2.Term);
  873. IF terms.HasMoreElements() THEN c := terms.GetNext(); term2 := c(CSS2.Term);
  874. IF terms.HasMoreElements() THEN c := terms.GetNext(); term3 := c(CSS2.Term);
  875. IF terms.HasMoreElements() THEN c := terms.GetNext(); term4 := c(CSS2.Term);
  876. IF term1.IsStringIdent("auto") THEN clip.top.specified := ChangeToPixel(0.0)
  877. ELSIF term1.IsLength() THEN clip.top.specified := term1
  878. END;
  879. IF term2.IsStringIdent("auto") THEN clip.right.specified := ChangeToPixel(0.0)
  880. ELSIF term2.IsLength() THEN clip.right.specified := term2
  881. END;
  882. IF term3.IsStringIdent("auto") THEN clip.bottom.specified := ChangeToPixel(0.0)
  883. ELSIF term3.IsLength() THEN clip.bottom.specified := term3
  884. END;
  885. IF term4.IsStringIdent("auto") THEN clip.left.specified := ChangeToPixel(0.0)
  886. ELSIF term4.IsLength() THEN clip.left.specified := term4
  887. END
  888. END
  889. END
  890. END
  891. END
  892. END
  893. END
  894. ELSIF s^ = "color" THEN
  895. SetColor(color.specified, term1, FALSE)
  896. ELSIF s^ = "cursor" THEN
  897. IF ~SetNilCollection(cursor.specified, term1) & ~SetIdentOrInheritCollection(cursor.specified, term1) THEN
  898. IF term1.IsStringIdent("auto") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, Auto)
  899. ELSIF term1.IsStringIdent("crosshair") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, Crosshair)
  900. ELSIF term1.IsStringIdent("default") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, Default)
  901. ELSIF term1.IsStringIdent("pointer") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, Pointer)
  902. ELSIF term1.IsStringIdent("move") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, Move)
  903. ELSIF term1.IsStringIdent("e-resize") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, EResize)
  904. ELSIF term1.IsStringIdent("ne-resize") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, NEResize)
  905. ELSIF term1.IsStringIdent("nw-resize") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, NWResize)
  906. ELSIF term1.IsStringIdent("n-resize") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, NResize)
  907. ELSIF term1.IsStringIdent("se-resize") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, SEResize)
  908. ELSIF term1.IsStringIdent("sw-resize") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, SWResize)
  909. ELSIF term1.IsStringIdent("s-resize") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, SResize)
  910. ELSIF term1.IsStringIdent("w-resize") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, WResize)
  911. ELSIF term1.IsStringIdent("text") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, Text)
  912. ELSIF term1.IsStringIdent("wait") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, Wait )
  913. ELSIF term1.IsStringIdent("help") THEN cursor.specified := NIL; ChangeToIdentCollection(cursor.specified, Help)
  914. ELSIF term1.GetType() = CSS2.URI THEN
  915. terms := declaration.GetTerms();
  916. WHILE terms.HasMoreElements() DO
  917. c := terms.GetNext();
  918. IF c(CSS2.Term).GetIntVal() = CSS2.URI THEN cursor.specified.Add(c) END
  919. END
  920. END
  921. END
  922. ELSIF s^ = "direction" THEN
  923. IF ~SetNil(direction.specified, term1) & ~SetIdentOrInherit(direction.specified, term1) THEN
  924. IF term1.IsStringIdent("ltr") THEN direction.specified := ChangeToIdent(Ltr)
  925. ELSIF term1.IsStringIdent("rtl") THEN direction.specified := ChangeToIdent(Rtl)
  926. END
  927. END
  928. ELSIF s^ = "empty-cells" THEN
  929. IF ~SetNil(emptyCells.specified, term1) & ~SetIdentOrInherit(emptyCells.specified, term1) THEN
  930. IF term1.IsStringIdent("show") THEN emptyCells.specified := ChangeToIdent(Show)
  931. ELSIF term1.IsStringIdent("hide") THEN emptyCells.specified := ChangeToIdent(Hide)
  932. END
  933. END
  934. ELSIF s^ = "float" THEN
  935. IF ~SetNil(float.specified, term1) & ~SetIdentOrInherit(float.specified, term1) & ~SetNone(float.specified, term1) THEN
  936. IF term1.IsStringIdent("left") THEN float.specified := ChangeToIdent(Left)
  937. ELSIF term1.IsStringIdent("right") THEN float.specified := ChangeToIdent(Right)
  938. END
  939. END
  940. ELSIF s^ = "font" THEN
  941. IF ~SetNil(font.specified, term1) & ~SetIdentOrInherit(font.specified, term1) THEN
  942. IF term1.IsStringIdent("caption") THEN font.specified := ChangeToIdent(Caption)
  943. ELSIF term1.IsStringIdent("icon") THEN font.specified := ChangeToIdent(Icon)
  944. ELSIF term1.IsStringIdent("menu") THEN font.specified := ChangeToIdent(Menu)
  945. ELSIF term1.IsStringIdent("message-box") THEN font.specified := ChangeToIdent(MessageBox)
  946. ELSIF term1.IsStringIdent("small-caption") THEN font.specified := ChangeToIdent(SmallCaption)
  947. ELSIF term1.IsStringIdent("status-bar") THEN font.specified := ChangeToIdent(StatusBar)
  948. ELSE
  949. END
  950. END
  951. ELSIF s^ = "font-family" THEN
  952. IF ~SetNil(fontFamily, term1) & ~SetIdentOrInherit(fontFamily, term1) THEN
  953. fontFamily := term1
  954. END
  955. ELSIF s^ = "font-size" THEN
  956. IF ~SetNil(fontSize.specified, term1) & ~SetIdentOrInherit(fontSize.specified, term1) THEN
  957. IF term1.GetType() = CSS2.StringIdent THEN
  958. NEW(fontSize.specified); fontSize.specified.SetType(CSS2.IntDimension); fontSize.specified.SetUnit(CSS2.pt);
  959. IF term1.IsStringIdent("xx-small") THEN fontSize.specified.SetIntVal(AbsoluteFontSizes[XXSmall])
  960. ELSIF term1.IsStringIdent("x-small") THEN fontSize.specified.SetIntVal(AbsoluteFontSizes[XSmall])
  961. ELSIF term1.IsStringIdent("small") THEN fontSize.specified.SetIntVal(AbsoluteFontSizes[Small])
  962. ELSIF term1.IsStringIdent("medium") THEN fontSize.specified.SetIntVal(AbsoluteFontSizes[Medium])
  963. ELSIF term1.IsStringIdent("large") THEN fontSize.specified.SetIntVal(AbsoluteFontSizes[Large])
  964. ELSIF term1.IsStringIdent("x-large") THEN fontSize.specified.SetIntVal(AbsoluteFontSizes[XLarge])
  965. ELSIF term1.IsStringIdent("xx-large") THEN fontSize.specified.SetIntVal(AbsoluteFontSizes[XXLarge])
  966. ELSIF term1.IsStringIdent("larger") THEN fontSize.specified := ChangeToIdent(Larger)
  967. ELSIF term1.IsStringIdent("smaller") THEN fontSize.specified := ChangeToIdent(Smaller)
  968. END
  969. ELSIF term1.IsLength() OR (term1.GetType() = CSS2.Percent) THEN fontSize.specified := term1
  970. END
  971. END
  972. ELSIF s^ = "font-size-adjust" THEN
  973. IF ~SetIdentOrInherit(fontSizeAdjust, term1) & ~SetNone(fontSizeAdjust, term1) THEN
  974. IF term1.GetType() IN {CSS2.IntNumber, CSS2.RealNumber} THEN fontSizeAdjust := term1
  975. END
  976. END
  977. ELSIF s^ = "font-stretch" THEN
  978. IF ~SetNil(fontStretch.specified, term1) & ~SetIdentOrInherit(fontStretch.specified, term1) THEN
  979. IF term1.IsStringIdent("normal") THEN fontStretch.specified := ChangeToIdent(Normal)
  980. ELSIF term1.IsStringIdent("wider") THEN fontStretch.specified := ChangeToIdent(Wider)
  981. ELSIF term1.IsStringIdent("narrower") THEN fontStretch.specified := ChangeToIdent(Narrower)
  982. ELSIF term1.IsStringIdent("ultra-condensed") THEN fontStretch.specified := ChangeToIdent(UltraCondensed)
  983. ELSIF term1.IsStringIdent("extra-condensed") THEN fontStretch.specified := ChangeToIdent(ExtraCondensed)
  984. ELSIF term1.IsStringIdent("condensed") THEN fontStretch.specified := ChangeToIdent(Condensed)
  985. ELSIF term1.IsStringIdent("semi-condensed") THEN fontStretch.specified := ChangeToIdent(SemiCondensed)
  986. ELSIF term1.IsStringIdent("semi-expanded") THEN fontStretch.specified := ChangeToIdent(SemiExpanded)
  987. ELSIF term1.IsStringIdent("expanded") THEN fontStretch.specified := ChangeToIdent(Expanded)
  988. ELSIF term1.IsStringIdent("extra-expanded") THEN fontStretch.specified := ChangeToIdent(ExtraExpanded)
  989. ELSIF term1.IsStringIdent("ultra-expanded") THEN fontStretch.specified := ChangeToIdent(UltraExpanded)
  990. END
  991. END
  992. ELSIF s^ = "font-style" THEN
  993. IF ~SetNil(fontStyle, term1) & ~SetIdentOrInherit(fontStyle, term1) THEN
  994. IF term1.IsStringIdent("normal") THEN fontStyle := ChangeToIdent(Normal)
  995. ELSIF term1.IsStringIdent("italic") THEN fontStyle := ChangeToIdent(Italic)
  996. ELSIF term1.IsStringIdent("oblique") THEN fontStyle := ChangeToIdent(Oblique)
  997. END
  998. END
  999. ELSIF s^ = "font-variant" THEN
  1000. IF ~SetNil(fontVariant.specified, term1) & ~SetIdentOrInherit(fontVariant.specified, term1) THEN
  1001. IF term1.IsStringIdent("normal") THEN fontVariant.specified := ChangeToIdent(Normal)
  1002. ELSIF term1.IsStringIdent("small-caps") THEN fontVariant.specified := ChangeToIdent(SmallCaps)
  1003. END
  1004. END
  1005. ELSIF s^ = "font-weight" THEN
  1006. IF ~SetNil(fontWeight, term1) & ~SetIdentOrInherit(fontWeight, term1) THEN
  1007. IF term1.IsStringIdent("normal") THEN
  1008. NEW(fontWeight); fontWeight.SetType(CSS2.IntNumber); fontWeight.SetIntVal(400);
  1009. ELSIF term1.IsStringIdent("bold") THEN
  1010. NEW(fontWeight); fontWeight.SetType(CSS2.IntNumber); fontWeight.SetIntVal(700);
  1011. ELSIF term1.IsStringIdent("bolder") THEN fontWeight := ChangeToIdent(Bolder)
  1012. ELSIF term1.IsStringIdent("lighter") THEN fontWeight := ChangeToIdent(Lighter)
  1013. ELSIF term1.GetType() = CSS2.IntNumber THEN
  1014. i := term1.GetIntVal();
  1015. IF (i = 100) OR (i = 200) OR (i = 300) OR (i = 400) OR (i = 500)
  1016. OR (i = 600) OR (i = 700) OR (i = 800) OR (i = 900) THEN
  1017. fontWeight := term1
  1018. END
  1019. END
  1020. END
  1021. ELSIF s^ = "height" THEN
  1022. IF ~SetNil(height.specified, term1) & ~SetIdentOrInherit(height.specified, term1) THEN
  1023. IF term1.IsStringIdent("auto") THEN height.specified := ChangeToIdent(Auto)
  1024. ELSIF term1.IsLength() OR (term1.GetType() = CSS2.Percent) THEN
  1025. height.specified := term1
  1026. END
  1027. END
  1028. ELSIF s^ = "left" THEN
  1029. BoxOffset(left.specified, term1)
  1030. ELSIF s^ = "letter-spacing" THEN
  1031. IF ~SetNil(letterSpacing.specified, term1) & ~SetIdentOrInherit(letterSpacing.specified, term1) THEN
  1032. IF term1.IsStringIdent("normal") THEN letterSpacing.specified := ChangeToPixel(0.0)
  1033. ELSIF term1.IsLength() THEN letterSpacing.specified := term1
  1034. END
  1035. END
  1036. ELSIF s^ = "line-height" THEN
  1037. IF ~SetNil(lineHeight.specified, term1) & ~SetIdentOrInherit(lineHeight.specified, term1) THEN
  1038. IF term1.IsStringIdent("normal") THEN lineHeight.specified := ChangeToIdent(Normal)
  1039. ELSIF term1.IsLength() OR (term1.GetType() IN {CSS2.IntNumber, CSS2.RealNumber})
  1040. OR (term1.GetType() = CSS2.Percent) THEN
  1041. lineHeight.specified := term1
  1042. END
  1043. END
  1044. ELSIF s^ = "list-style" THEN
  1045. IF term1.IsStringIdent("inherit") THEN
  1046. listStyleImage.specified := ChangeToIdent(Inherit);
  1047. listStylePosition.specified := ChangeToIdent(Inherit);
  1048. listStyleType.specified := ChangeToIdent(Inherit)
  1049. ELSIF term1.IsStringIdent("none") THEN
  1050. listStyleImage.specified := NIL;
  1051. listStyleType.specified := NIL
  1052. ELSE
  1053. IF term1.GetType() = CSS2.URI THEN
  1054. term4 := term1
  1055. ELSIF term1.IsStringIdent("inside") OR term1.IsStringIdent("outside") THEN
  1056. term5 := term1
  1057. ELSE
  1058. term6 := term1
  1059. END;
  1060. IF term2 # NIL THEN
  1061. IF (term2.GetType() = CSS2.URI) & (term4 = NIL) THEN
  1062. term4 := term2
  1063. ELSIF (term2.IsStringIdent("inside") OR term2.IsStringIdent("outside")) & (term5 = NIL) THEN
  1064. term5 := term2
  1065. ELSIF term6 = NIL THEN
  1066. term6 := term2
  1067. END;
  1068. IF term3 # NIL THEN
  1069. IF (term3.GetType() = CSS2.URI) & (term4 = NIL) THEN
  1070. term4 := term3
  1071. ELSIF (term3.IsStringIdent("inside") OR term3.IsStringIdent("outside")) & (term5 = NIL) THEN
  1072. term5 := term3
  1073. ELSIF term6 = NIL THEN
  1074. term6 := term3
  1075. END
  1076. END
  1077. END;
  1078. IF term4 # NIL THEN ListStyleImage(listStyleImage.specified, term4) END;
  1079. IF term5 # NIL THEN ListStylePosition(listStylePosition.specified, term5) END;
  1080. IF term6 # NIL THEN ListStyleType(listStyleType.specified, term6) END
  1081. END
  1082. ELSIF s^ = "list-style-image" THEN
  1083. ListStyleImage(listStyleImage.specified, term1)
  1084. ELSIF s^ = "list-style-position" THEN
  1085. ListStylePosition(listStylePosition.specified, term1)
  1086. ELSIF s^ = "list-style-type" THEN
  1087. ListStyleType(listStyleType.specified, term1)
  1088. ELSIF s^ = "margin" THEN
  1089. MarginWidth(margin.top.specified, term1);
  1090. IF term2 # NIL THEN
  1091. MarginWidth(margin.right.specified, term2);
  1092. MarginWidth(margin.left.specified, term2);
  1093. IF term3 # NIL THEN
  1094. MarginWidth(margin.bottom.specified, term3);
  1095. IF term4 # NIL THEN
  1096. MarginWidth(margin.left.specified, term4)
  1097. ELSE
  1098. MarginWidth(margin.left.specified, term2)
  1099. END
  1100. ELSE
  1101. MarginWidth(margin.bottom.specified, term1)
  1102. END
  1103. ELSE
  1104. MarginWidth(margin.right.specified, term1);
  1105. MarginWidth(margin.bottom.specified, term1);
  1106. MarginWidth(margin.left.specified, term1)
  1107. END
  1108. ELSIF s^ = "margin-top" THEN
  1109. MarginWidth(margin.top.specified, term1)
  1110. ELSIF s^ = "margin-right" THEN
  1111. MarginWidth(margin.right.specified, term1)
  1112. ELSIF s^ = "margin-bottom" THEN
  1113. MarginWidth(margin.bottom.specified, term1)
  1114. ELSIF s^ = "margin-left" THEN
  1115. MarginWidth(margin.left.specified, term1)
  1116. ELSIF s^ = "marker-offset" THEN
  1117. IF ~SetNil(markerOffset.specified, term1) & ~SetIdentOrInherit(markerOffset.specified, term1) THEN
  1118. IF term1.IsStringIdent("auto") THEN markerOffset.specified := ChangeToPixel(0.0)
  1119. ELSIF term1.IsLength() THEN markerOffset.specified := term1
  1120. END
  1121. END
  1122. ELSIF s^ = "marks" THEN (* not implemented *)
  1123. ELSIF s^ = "max-height" THEN
  1124. MaxDimension(maxHeight.specified, term1)
  1125. ELSIF s^ = "max-width" THEN
  1126. MaxDimension(maxWidth.specified, term1)
  1127. ELSIF s^ = "min-height" THEN
  1128. MinDimension(minHeight.specified, term1)
  1129. ELSIF s^ = "min-width" THEN
  1130. MinDimension(minWidth.specified, term1)
  1131. ELSIF s^ = "outline" THEN
  1132. IF term1.IsStringIdent("inherit") THEN
  1133. outlineColor.specified := ChangeToIdent(Inherit);
  1134. outlineStyle.specified := ChangeToIdent(Inherit);
  1135. outlineWidth.specified := ChangeToIdent(Inherit)
  1136. ELSE
  1137. IF IsBorderStyle(term1) THEN term5 := term1
  1138. ELSIF IsBorderWidth(term1) THEN term6 := term1
  1139. ELSE term4 := term1
  1140. END;
  1141. IF term2 # NIL THEN
  1142. IF IsBorderStyle(term2) & (term5 = NIL) THEN term5 := term2
  1143. ELSIF IsBorderWidth(term2) & (term6 = NIL) THEN term6 := term2
  1144. ELSIF term4 = NIL THEN term4 := term2
  1145. END;
  1146. IF term3 # NIL THEN
  1147. IF IsBorderStyle(term3) & (term5 = NIL) THEN term5 := term3
  1148. ELSIF IsBorderWidth(term3) & (term6 = NIL) THEN term6 := term3
  1149. ELSIF term4 = NIL THEN term4 := term3
  1150. END
  1151. END
  1152. END;
  1153. IF term4 # NIL THEN
  1154. IF term4.IsStringIdent("invert") THEN SetColor(outlineColor.specified, term4, TRUE)
  1155. END
  1156. END;
  1157. IF term5 # NIL THEN BorderStyle(outlineStyle.specified, term5) END;
  1158. IF term6 # NIL THEN BorderWidth(outlineWidth.specified, term6) END
  1159. END
  1160. ELSIF s^ = "outline-color" THEN
  1161. SetColor(outlineColor.specified, term1, TRUE)
  1162. ELSIF s^ = "outline-style" THEN
  1163. IF (term1 # NIL) & term1.IsStringIdent("hidden") THEN
  1164. outlineStyle.specified := ChangeToIdent(Hidden)
  1165. ELSE
  1166. BorderStyle(outlineStyle.specified, term1)
  1167. END
  1168. ELSIF s^ = "outline-width" THEN
  1169. BorderWidth(outlineWidth.specified, term1)
  1170. ELSIF s^ = "overflow" THEN
  1171. IF ~SetNil(overflow.specified, term1) & ~SetIdentOrInherit(overflow.specified, term1) THEN
  1172. IF term1.IsStringIdent("visible") THEN overflow.specified := ChangeToIdent(Visible)
  1173. ELSIF term1.IsStringIdent("hidden") THEN overflow.specified := ChangeToIdent(Hidden)
  1174. ELSIF term1.IsStringIdent("scroll") THEN overflow.specified := ChangeToIdent(Scroll)
  1175. ELSIF term1.IsStringIdent("auto") THEN overflow.specified := ChangeToIdent(Auto)
  1176. END
  1177. END
  1178. ELSIF s^ = "padding" THEN
  1179. PaddingWidth(padding.top.specified, term1);
  1180. IF term2 # NIL THEN
  1181. PaddingWidth(padding.right.specified, term2);
  1182. PaddingWidth(padding.left.specified, term2);
  1183. IF term3 # NIL THEN
  1184. PaddingWidth(padding.bottom.specified, term3);
  1185. IF term4 # NIL THEN
  1186. PaddingWidth(padding.left.specified, term4)
  1187. ELSE
  1188. PaddingWidth(padding.left.specified, term2)
  1189. END
  1190. ELSE
  1191. PaddingWidth(padding.bottom.specified, term1)
  1192. END
  1193. ELSE
  1194. PaddingWidth(padding.right.specified, term1);
  1195. PaddingWidth(padding.bottom.specified, term1);
  1196. PaddingWidth(padding.left.specified, term1)
  1197. END
  1198. ELSIF s^ = "padding-top" THEN
  1199. PaddingWidth(padding.top.specified, term1)
  1200. ELSIF s^ = "padding-right" THEN
  1201. PaddingWidth(padding.right.specified, term1)
  1202. ELSIF s^ = "padding-bottom" THEN
  1203. PaddingWidth(padding.bottom.specified, term1)
  1204. ELSIF s^ = "padding-left" THEN
  1205. PaddingWidth(padding.left.specified, term1)
  1206. ELSIF s^ = "position" THEN
  1207. IF ~SetNil(position.specified, term1) & ~SetIdentOrInherit(position.specified, term1) THEN
  1208. IF term1.IsStringIdent("static") THEN position.specified := ChangeToIdent(Static)
  1209. ELSIF term1.IsStringIdent("relative") THEN position.specified := ChangeToIdent(Relative)
  1210. ELSIF term1.IsStringIdent("absolute") THEN position.specified := ChangeToIdent(Absolute)
  1211. ELSIF term1.IsStringIdent("fixed") THEN position.specified := ChangeToIdent(Fixed)
  1212. END
  1213. END
  1214. ELSIF s^ = "quotes" THEN
  1215. ELSIF s^ = "right" THEN
  1216. BoxOffset(right.specified, term1)
  1217. ELSIF s^ = "table-layout" THEN
  1218. IF ~SetNil(tableLayout.specified, term1) & ~SetIdentOrInherit(tableLayout.specified, term1) THEN
  1219. IF term1.IsStringIdent("auto") THEN tableLayout.specified := ChangeToIdent(Auto)
  1220. ELSIF term1.IsStringIdent("fixed") THEN tableLayout.specified := ChangeToIdent(Fixed)
  1221. END
  1222. END
  1223. ELSIF s^ = "text-align" THEN
  1224. IF ~SetNil(textAlign.specified, term1) & ~SetIdentOrInherit(textAlign.specified, term1) THEN
  1225. IF term1.IsStringIdent("left") THEN textAlign.specified := ChangeToIdent(Left)
  1226. ELSIF term1.IsStringIdent("right") THEN textAlign.specified := ChangeToIdent(Right)
  1227. ELSIF term1.IsStringIdent("center") THEN textAlign.specified := ChangeToIdent(Center)
  1228. ELSIF term1.IsStringIdent("justify") THEN textAlign.specified := ChangeToIdent(Justify)
  1229. ELSIF term1.GetType() = CSS2.StringVal THEN textAlign.specified := term1
  1230. END
  1231. END
  1232. ELSIF s^ = "text-decoration" THEN
  1233. IF ~SetNil(textDecoration.specified, term1) & ~SetIdentOrInherit(textDecoration.specified, term1)
  1234. & ~SetNone(textDecoration.specified, term1) THEN
  1235. END
  1236. ELSIF s^ = "text-indent" THEN
  1237. IF ~SetNil(textIndent.specified, term1) & ~SetIdentOrInherit(textIndent.specified, term1) THEN
  1238. IF term1.IsLength() OR (term1.GetType() = CSS2.Percent) THEN
  1239. textIndent.specified := term1
  1240. END
  1241. END
  1242. ELSIF s^ = "text-shadow" THEN
  1243. ELSIF s^ = "text-transform" THEN
  1244. IF ~SetNil(textTransform.specified, term1) & ~SetIdentOrInherit(textTransform.specified, term1) THEN
  1245. IF term1.IsStringIdent("capitalize") THEN textTransform.specified := ChangeToIdent(Capitalize)
  1246. ELSIF term1.IsStringIdent("uppercase") THEN textTransform.specified := ChangeToIdent(Uppercase)
  1247. ELSIF term1.IsStringIdent("lowercase") THEN textTransform.specified := ChangeToIdent(Lowercase)
  1248. END
  1249. END
  1250. ELSIF s^ = "top" THEN
  1251. BoxOffset(top.specified, term1)
  1252. ELSIF s^ = "unicode-bidi" THEN
  1253. IF ~SetNil(unicodeBidi.specified, term1) & ~SetIdentOrInherit(unicodeBidi.specified, term1) THEN
  1254. IF term1.IsStringIdent("normal") THEN unicodeBidi.specified := ChangeToIdent(Normal)
  1255. ELSIF term1.IsStringIdent("embed") THEN unicodeBidi.specified := ChangeToIdent(Embed)
  1256. ELSIF term1.IsStringIdent("bidi-override") THEN unicodeBidi.specified := ChangeToIdent(BidiOverride)
  1257. END
  1258. END
  1259. ELSIF s^ = "vertical-align" THEN
  1260. IF ~SetNil(verticalAlign.specified, term1) & ~SetIdentOrInherit(verticalAlign.specified, term1) THEN
  1261. IF term1.IsStringIdent("baseline") THEN verticalAlign.specified := ChangeToIdent(Baseline)
  1262. ELSIF term1.IsStringIdent("sub") THEN verticalAlign.specified := ChangeToIdent(Sub)
  1263. ELSIF term1.IsStringIdent("super") THEN verticalAlign.specified := ChangeToIdent(Super)
  1264. ELSIF term1.IsStringIdent("top") THEN verticalAlign.specified := ChangeToIdent(Top)
  1265. ELSIF term1.IsStringIdent("text-top") THEN verticalAlign.specified := ChangeToIdent(TextTop)
  1266. ELSIF term1.IsStringIdent("middle") THEN verticalAlign.specified := ChangeToIdent(Middle)
  1267. ELSIF term1.IsStringIdent("bottom") THEN verticalAlign.specified := ChangeToIdent(Bottom)
  1268. ELSIF term1.IsStringIdent("text-bottom") THEN verticalAlign.specified := ChangeToIdent(TextBottom)
  1269. ELSIF term1.IsLength() OR (term1.GetType() = CSS2.Percent) THEN
  1270. verticalAlign.specified := term1
  1271. END
  1272. END
  1273. ELSIF s^ = "visibility" THEN
  1274. IF ~SetNil(visibility.specified, term1) & ~SetIdentOrInherit(visibility.specified, term1) THEN
  1275. IF term1.IsStringIdent("visible") THEN visibility.specified := ChangeToIdent(Visible); dimensionChanged := TRUE
  1276. ELSIF term1.IsStringIdent("hidden") THEN visibility.specified := ChangeToIdent(Hidden); dimensionChanged := TRUE
  1277. ELSIF term1.IsStringIdent("collapse") THEN visibility.specified := ChangeToIdent(Collapse); dimensionChanged := TRUE
  1278. END
  1279. END
  1280. ELSIF s^ = "white-space" THEN
  1281. IF ~SetNil(whiteSpace.specified, term1) & ~SetIdentOrInherit(whiteSpace.specified, term1) THEN
  1282. IF term1.IsStringIdent("normal") THEN whiteSpace.specified := ChangeToIdent(Normal)
  1283. ELSIF term1.IsStringIdent("pre") THEN whiteSpace.specified := ChangeToIdent(Pre)
  1284. ELSIF term1.IsStringIdent("nowrap") THEN whiteSpace.specified := ChangeToIdent(Nowrap)
  1285. END
  1286. END
  1287. ELSIF s^ = "width" THEN
  1288. IF ~SetNil(width.specified, term1) & ~SetIdentOrInherit(width.specified, term1) THEN
  1289. IF term1.IsStringIdent("auto") THEN width.specified := ChangeToIdent(Auto)
  1290. ELSIF term1.IsLength() OR (term1.GetType() = CSS2.Percent) THEN
  1291. width.specified := term1
  1292. END
  1293. END
  1294. ELSIF s^ = "word-spacing" THEN
  1295. IF ~SetNil(wordSpacing.specified, term1) & ~SetIdentOrInherit(wordSpacing.specified, term1) THEN
  1296. IF term1.IsStringIdent("normal") THEN wordSpacing.specified := ChangeToPixel(0.0)
  1297. ELSIF term1.IsLength() THEN wordSpacing.specified := term1
  1298. END
  1299. END
  1300. ELSIF s^ = "z-index" THEN
  1301. IF ~SetNil(zIndex.specified, term1) & ~SetIdentOrInherit(zIndex.specified, term1) THEN
  1302. IF term1.IsStringIdent("auto") THEN zIndex.specified := ChangeToIdent(Auto)
  1303. ELSIF term1.GetType() = CSS2.IntNumber THEN zIndex.specified := term1
  1304. END
  1305. END
  1306. ELSE
  1307. SetValue^(declaration)
  1308. END
  1309. END SetValue;
  1310. PROCEDURE Initialize*;
  1311. BEGIN
  1312. Initialize^();
  1313. backgroundAttachment.computed := TRUE;
  1314. IF parent # SELF THEN
  1315. WITH parent: VisualProperties DO
  1316. color.computed := parent.color.computed;
  1317. borderCollapse.computed := parent.borderCollapse.computed;
  1318. borderSpacing.horizontal.computed := parent.borderSpacing.horizontal.computed;
  1319. borderSpacing.vertical.computed := parent.borderSpacing.vertical.computed;
  1320. captionSide.computed := parent.captionSide.computed;
  1321. cursor.computed := parent.cursor.computed;
  1322. direction.computed := parent.direction.computed;
  1323. emptyCells.computed := parent.emptyCells.computed;
  1324. font.computed := parent.font.computed;
  1325. fontSize.computed := parent.fontSize.computed;
  1326. fontStretch.computed := parent.fontStretch.computed;
  1327. fontVariant.computed := parent.fontVariant.computed;
  1328. letterSpacing.computed := parent.letterSpacing.computed;
  1329. wordSpacing.computed := parent.wordSpacing.computed;
  1330. lineHeight.computed := parent.lineHeight.computed;
  1331. listStyleImage.computed := parent.listStyleImage.computed;
  1332. listStylePosition.computed := parent.listStylePosition.computed;
  1333. listStyleType.computed := parent.listStyleType.computed;
  1334. (* quotes.computed := parent.quotes.computed; *)
  1335. textAlign.computed := parent.textAlign.computed;
  1336. textIndent.computed := parent.textIndent.computed;
  1337. textTransform.computed := parent.textTransform.computed;
  1338. whiteSpace.computed := parent.whiteSpace.computed
  1339. END
  1340. ELSE
  1341. CSS2.IntToRGBA(defaultColor, color.computed.r, color.computed.g, color.computed.b, color.computed.a);
  1342. borderCollapse.computed := TRUE;
  1343. borderSpacing.horizontal.computed := 0.0; borderSpacing.vertical.computed := 0.0;
  1344. captionSide.computed := Top;
  1345. cursor.computed := defaultCursor;
  1346. direction.computed := TRUE;
  1347. emptyCells.computed := TRUE;
  1348. font.computed := defaultFont;
  1349. fontSize.computed := AbsoluteFontSizes[Medium];
  1350. fontStretch.computed := Normal;
  1351. fontVariant.computed := TRUE;
  1352. letterSpacing.computed := 0.0;
  1353. wordSpacing.computed := 0.0;
  1354. lineHeight.computed := 1.2 * (font.computed.ymax - font.computed.ymin);
  1355. listStyleImage.computed := NIL;
  1356. listStylePosition.computed := TRUE;
  1357. listStyleType.computed := Disc;
  1358. (* quotes.computed := ; *)
  1359. textAlign.computed := Left;
  1360. textIndent.computed := 0.0;
  1361. textTransform.computed := None;
  1362. whiteSpace.computed := Normal;
  1363. END;
  1364. color.specified := NIL;
  1365. borderCollapse.specified := NIL; borderSpacing.horizontal.specified := NIL; borderSpacing.vertical.specified := NIL;
  1366. captionSide.specified := NIL;
  1367. cursor.specified := NIL;
  1368. direction.specified := NIL;
  1369. emptyCells.specified := NIL;
  1370. font.specified := NIL; fontSize.specified := NIL; fontStretch.specified := NIL; fontVariant.specified := NIL;
  1371. letterSpacing.specified := NIL; wordSpacing.specified := NIL;
  1372. lineHeight.specified := NIL;
  1373. listStyleImage.specified := NIL; listStylePosition.specified := NIL; listStyleType.specified := NIL;
  1374. (* quotes.specified := NIL; *)
  1375. textAlign.specified := NIL; textIndent.specified := NIL; textTransform.specified := NIL;
  1376. whiteSpace.specified := NIL;
  1377. CSS2.IntToRGBA(Transparent, backgroundColor.computed.r, backgroundColor.computed.g,
  1378. backgroundColor.computed.b, backgroundColor.computed.a);
  1379. backgroundColor.specified := NIL;
  1380. backgroundImage.computed := NIL; backgroundImage.specified := NIL;
  1381. backgroundPosition.horizontal.computed := 0.0; backgroundPosition.horizontal.specified := NIL;
  1382. backgroundPosition.vertical.computed := 0.0; backgroundPosition.vertical.specified := NIL;
  1383. backgroundRepeat.horizontal.computed := TRUE; backgroundRepeat.horizontal.specified := NIL;
  1384. backgroundRepeat.vertical.computed := TRUE; backgroundRepeat.vertical.specified := NIL;
  1385. borderColor.top.computed := color.computed; borderColor.top.specified := NIL;
  1386. borderColor.right.computed := color.computed; borderColor.right.specified := NIL;
  1387. borderColor.bottom.computed := color.computed; borderColor.bottom.specified := NIL;
  1388. borderColor.left.computed := color.computed; borderColor.left.specified := NIL;
  1389. borderStyle.top.computed := None; borderStyle.top.specified := NIL;
  1390. borderStyle.right.computed := None; borderStyle.right.specified := NIL;
  1391. borderStyle.bottom.computed := None; borderStyle.bottom.specified := NIL;
  1392. borderStyle.left.computed := None; borderStyle.left.specified := NIL;
  1393. borderWidth.top.computed := mediumBorder; borderWidth.top.specified := NIL;
  1394. borderWidth.right.computed := mediumBorder; borderWidth.right.specified := NIL;
  1395. borderWidth.bottom.computed := mediumBorder; borderWidth.bottom.specified := NIL;
  1396. borderWidth.left.computed := mediumBorder; borderWidth.left.specified := NIL;
  1397. top.computed := DummyAuto; top.specified := NIL;
  1398. right.computed := DummyAuto; right.specified := NIL;
  1399. bottom.computed := DummyAuto; bottom.specified := NIL;
  1400. left.computed := DummyAuto; left.specified := NIL;
  1401. height.computed := DummyAuto; height.specified := NIL;
  1402. width.computed := DummyAuto; width.specified := NIL;
  1403. maxHeight.computed := DummyAuto; maxHeight.specified := NIL;
  1404. maxWidth.computed := DummyAuto; maxWidth.specified := NIL;
  1405. minHeight.computed := 0.0; minHeight.specified := NIL;
  1406. minWidth.computed := 0.0; minWidth.specified := NIL;
  1407. clear.left.computed := FALSE; clear.left.specified := NIL;
  1408. clear.right.computed := FALSE; clear.right.specified := NIL;
  1409. float.computed := None; float.specified := NIL;
  1410. markerOffset.computed := 0.0; markerOffset.specified := NIL;
  1411. outlineStyle.computed := None; outlineStyle.specified := NIL;
  1412. outlineWidth.computed := mediumBorder; outlineWidth.specified := NIL;
  1413. overflow.computed := Visible; overflow.specified := NIL;
  1414. position.computed := Static; position.specified := NIL;
  1415. tableLayout.computed := TRUE; tableLayout.specified := NIL;
  1416. textDecoration.computed := {}; textDecoration.specified := NIL;
  1417. (* textShadow.computed := ; textShadow.specified := NIL;*)
  1418. unicodeBidi.computed := Normal; unicodeBidi.specified := NIL;
  1419. verticalAlign.computed := Baseline; verticalAlign.specified := NIL;
  1420. visibility.computed := Visible; visibility.specified := NIL;
  1421. zIndex.computed := -1; zIndex.specified := NIL
  1422. END Initialize;
  1423. PROCEDURE ComputeValues*;
  1424. VAR terms: XMLObjects.Enumerator; term: ANY;
  1425. BEGIN
  1426. ComputeValues^();
  1427. WITH parent: VisualProperties DO
  1428. IF ~generated THEN
  1429. IF display.computed = None THEN
  1430. position.computed := None; float.computed := None
  1431. ELSE
  1432. ComputeIdent(position, parent.position);
  1433. IF position.computed IN {Absolute, Fixed} THEN
  1434. display.computed := Block; float.computed := None
  1435. ELSE
  1436. ComputeIdent(float, parent.float);
  1437. IF float.computed # None THEN
  1438. display.computed := Block
  1439. END
  1440. END
  1441. END
  1442. END;
  1443. ComputeBool(backgroundAttachment, parent.backgroundAttachment, Scroll);
  1444. ComputeColor(backgroundColor, parent.backgroundColor, IntToColor(Transparent));
  1445. ComputeImg(backgroundImage, parent.backgroundImage);
  1446. ComputeBool(backgroundRepeat.horizontal, parent.backgroundRepeat.horizontal, Repeat);
  1447. ComputeBool(backgroundRepeat.vertical, parent.backgroundRepeat.vertical, Repeat);
  1448. IF backgroundPosition.horizontal.specified # NIL THEN
  1449. backgroundPosition.horizontal.computed := backgroundPosition.horizontal.specified.GetRealVal()
  1450. END;
  1451. IF backgroundPosition.vertical.specified # NIL THEN
  1452. backgroundPosition.vertical.computed := backgroundPosition.vertical.specified.GetRealVal()
  1453. END;
  1454. ComputeIdent(borderStyle.top, parent.borderStyle.top);
  1455. ComputeIdent(borderStyle.right, parent.borderStyle.right);
  1456. ComputeIdent(borderStyle.bottom, parent.borderStyle.bottom);
  1457. ComputeIdent(borderStyle.left, parent.borderStyle.left);
  1458. ComputeDim(fontSize, parent.fontSize, ppi, parent.fontSize.computed, parent.font.computed);
  1459. IF display.computed IN {Table, InlineTable} THEN
  1460. ComputeBool(borderCollapse, parent.borderCollapse, Collapse);
  1461. IF borderCollapse.computed THEN borderSpacing.horizontal.computed := 0.0; borderSpacing.vertical.computed := 0.0
  1462. ELSE ComputeDim(borderSpacing.horizontal, parent.borderSpacing.horizontal, ppi, 0.0, font.computed)
  1463. END;
  1464. ComputeDim(borderSpacing.vertical, parent.borderSpacing.vertical, ppi, 0.0, font.computed);
  1465. ComputeBool(tableLayout, parent.tableLayout, Auto)
  1466. END;
  1467. ComputeColor(color, parent.color, IntToColor(defaultColor));
  1468. ComputeColor(borderColor.top, parent.borderColor.top, color);
  1469. ComputeColor(borderColor.right, parent.borderColor.right, color);
  1470. ComputeColor(borderColor.bottom, parent.borderColor.bottom, color);
  1471. ComputeColor(borderColor.left, parent.borderColor.left, color);
  1472. IF display.computed = TableCaption THEN
  1473. ComputeIdent(captionSide, parent.captionSide)
  1474. END;
  1475. IF IsBlockLevelElement() THEN
  1476. ComputeBool(clear.left, parent.clear.left, Clear); ComputeBool(clear.right, parent.clear.right, Clear);
  1477. ComputeIdent(textAlign, parent.textAlign);
  1478. ComputeIdent(whiteSpace, parent.whiteSpace)
  1479. END;
  1480. ComputeCursor(cursor, parent.cursor);
  1481. ComputeBool(direction, parent.direction, Ltr);
  1482. IF display.computed = TableCell THEN ComputeBool(emptyCells, parent.emptyCells, Show) END;
  1483. ComputeFont();
  1484. ComputeIdent(fontStretch, parent.fontStretch);
  1485. ComputeBool(fontVariant, parent.fontVariant, Normal);
  1486. ComputeDim(letterSpacing, parent.letterSpacing, ppi, 0.0, font.computed);
  1487. ComputeDim(wordSpacing, parent.wordSpacing, ppi, 0.0, font.computed);
  1488. IF lineHeight.specified # NIL THEN
  1489. IF lineHeight.specified.IsIdent(Normal) THEN
  1490. lineHeight.computed := 1.2 * (font.computed.ymax - font.computed.ymin)
  1491. ELSIF lineHeight.specified.GetType() = CSS2.Percent THEN
  1492. lineHeight.computed := lineHeight.specified.GetRealVal() * fontSize.computed
  1493. ELSIF lineHeight.specified.IsLength() THEN
  1494. ComputeDim(lineHeight, parent.lineHeight, ppi, 0.0, font.computed)
  1495. END
  1496. ELSE
  1497. lineHeight.computed := 1.2 * (font.computed.ymax - font.computed.ymin)
  1498. END;
  1499. IF display.computed = ListItem THEN
  1500. ComputeImg(listStyleImage, parent.listStyleImage);
  1501. ComputeBool(listStylePosition, parent.listStylePosition, Outside);
  1502. ComputeIdent(listStyleType, parent.listStyleType)
  1503. END;
  1504. IF display.computed = Marker THEN ComputeDim(markerOffset, parent.markerOffset, ppi, 0.0, font.computed) END;
  1505. ComputeColor(outlineColor, parent.outlineColor, IntToColor(Transparent));
  1506. ComputeIdent(outlineStyle, parent.outlineStyle);
  1507. ComputeDim(outlineWidth, parent.outlineWidth, ppi, 0.0, font.computed);
  1508. IF IsBlockLevelElement() OR replaced THEN
  1509. ComputeDim(clip.top, parent.clip.top, ppi, 0.0, font.computed);
  1510. ComputeDim(clip.right, parent.clip.right, ppi, 0.0, font.computed);
  1511. ComputeDim(clip.bottom, parent.clip.bottom, ppi, 0.0, font.computed);
  1512. ComputeDim(clip.left, parent.clip.left, ppi, 0.0, font.computed);
  1513. ComputeIdent(overflow, parent.overflow)
  1514. END;
  1515. IF textDecoration.specified # NIL THEN
  1516. IF textDecoration.specified.IsIdent(Inherit) THEN
  1517. textDecoration.computed := parent.textDecoration.computed
  1518. ELSE
  1519. textDecoration.computed := {};
  1520. (* NEW(terms, textDecoration.specified); *)
  1521. WHILE terms.HasMoreElements() DO
  1522. term := terms.GetNext();
  1523. IF term(CSS2.Term).IsIdent(Underline) THEN INCL(textDecoration.computed, Underline)
  1524. ELSIF term(CSS2.Term).IsIdent(Overline) THEN INCL(textDecoration.computed, Overline)
  1525. ELSIF term(CSS2.Term).IsIdent(LineThrough) THEN INCL(textDecoration.computed, LineThrough)
  1526. ELSIF term(CSS2.Term).IsIdent(Blink) THEN INCL(textDecoration.computed, Blink)
  1527. END
  1528. END
  1529. END
  1530. END;
  1531. ComputeIdent(textTransform, parent.textTransform);
  1532. ComputeIdent(unicodeBidi, parent.unicodeBidi);
  1533. IF visibility.specified = NIL THEN visibility.computed := parent.visibility.computed
  1534. ELSE ComputeIdent(visibility, parent.visibility)
  1535. END;
  1536. IF IsPositioned() THEN
  1537. IF zIndex.specified # NIL THEN
  1538. IF zIndex.specified.IsIdent(Inherit) THEN zIndex.computed := parent.zIndex.computed
  1539. ELSIF zIndex.specified.IsIdent(Auto) THEN zIndex.computed := -1
  1540. ELSIF zIndex.specified.GetType() = CSS2.IntNumber THEN zIndex.computed := zIndex.specified.GetIntVal()
  1541. END
  1542. END
  1543. END
  1544. END
  1545. END ComputeValues;
  1546. PROCEDURE ComputeDimensions*;
  1547. BEGIN
  1548. ComputeContainingBlock();
  1549. WITH parent: VisualProperties DO
  1550. IF position.computed = Static THEN
  1551. top.computed := 0.0; left.computed := 0.0; bottom.computed := 0.0; right.computed := 0.0
  1552. ELSE
  1553. ComputeDim(top, parent.top, ppi, containingBlock.height, font.computed);
  1554. ComputeDim(left, parent.left, ppi, containingBlock.width, font.computed);
  1555. ComputeDim(bottom, parent.bottom, ppi, containingBlock.height, font.computed);
  1556. ComputeDim(right, parent.right, ppi, containingBlock.width, font.computed)
  1557. END;
  1558. IF borderStyle.top.computed # None THEN
  1559. ComputeDim(borderWidth.top, parent.borderWidth.top, ppi, 0.0, font.computed)
  1560. ELSE
  1561. borderWidth.top.computed := 0
  1562. END;
  1563. IF borderStyle.right.computed # None THEN
  1564. ComputeDim(borderWidth.right, parent.borderWidth.right, ppi, 0.0, font.computed);
  1565. ELSE
  1566. borderWidth.right.computed := 0
  1567. END;
  1568. IF borderStyle.bottom.computed # None THEN
  1569. ComputeDim(borderWidth.bottom, parent.borderWidth.bottom, ppi, 0.0, font.computed);
  1570. ELSE
  1571. borderWidth.bottom.computed := 0
  1572. END;
  1573. IF borderStyle.left.computed # None THEN
  1574. ComputeDim(borderWidth.left, parent.borderWidth.left, ppi, 0.0, font.computed);
  1575. ELSE
  1576. borderWidth.left.computed := 0
  1577. END;
  1578. ComputeDim(padding.top, parent.padding.top, ppi, containingBlock.width, font.computed);
  1579. ComputeDim(padding.right, parent.padding.right, ppi, containingBlock.width, font.computed);
  1580. ComputeDim(padding.bottom, parent.padding.bottom, ppi, containingBlock.width, font.computed);
  1581. ComputeDim(padding.left, parent.padding.left, ppi, containingBlock.width, font.computed);
  1582. ComputeDim(margin.left, parent.margin.left, ppi, containingBlock.width, font.computed);
  1583. ComputeDim(margin.right, parent.margin.right, ppi, containingBlock.width, font.computed);
  1584. ComputeDim(width, parent.width, ppi, containingBlock.width, font.computed);
  1585. ComputeWidthsAndMargins();
  1586. IF (maxWidth.specified = NIL) OR maxWidth.specified.IsIdent(None) THEN
  1587. maxWidth.computed := MAX(LONGREAL)
  1588. ELSE
  1589. ComputeDim(maxWidth, parent.maxWidth, ppi, containingBlock.width, font.computed)
  1590. END;
  1591. IF (minWidth.specified = NIL) THEN minWidth.computed := 0.0
  1592. ELSE ComputeDim(minWidth, parent.minWidth, ppi, containingBlock.width, font.computed)
  1593. END;
  1594. IF minWidth.computed > maxWidth.computed THEN maxWidth.computed := minWidth.computed END; (* 10.4 2 *)
  1595. IF width.computed > maxWidth.computed THEN (* 10.4 3. *)
  1596. width.computed := maxWidth.computed;
  1597. ComputeWidthsAndMargins()
  1598. END;
  1599. IF width.computed < minWidth.computed THEN (* 10.4 4. *)
  1600. width.computed := minWidth.computed;
  1601. ComputeWidthsAndMargins();
  1602. END;
  1603. ComputeDim(margin.top, parent.margin.top, ppi, containingBlock.height, font.computed);
  1604. ComputeDim(height, parent.height, ppi, containingBlock.height, font.computed);
  1605. ComputeDim(margin.bottom, parent.margin.bottom, ppi, containingBlock.height, font.computed);
  1606. ComputeHeightsAndMargins();
  1607. (*ComputeDim(backgroundPosition.horizontal, parent.backgroundPosition.horizontal, ppi,
  1608. padding.right.computed + width.computed + padding.left.computed, font.computed);
  1609. ComputeDim(backgroundPosition.vertical, parent.backgroundPosition.vertical, ppi,
  1610. padding.top.computed + width.computed + padding.bottom.computed, font.computed);*)
  1611. ComputeDim(textIndent, parent.textIndent, ppi, containingBlock.width, font.computed);
  1612. IF verticalAlign.specified # NIL THEN
  1613. IF verticalAlign.specified.IsIdent(Inherit) THEN
  1614. verticalAlign.computed := parent.verticalAlign.computed;
  1615. verticalAlign.computedLength := parent.verticalAlign.computedLength
  1616. ELSIF verticalAlign.specified.GetType() = CSS2.Ident THEN
  1617. verticalAlign.computed := SHORT(SHORT(verticalAlign.specified.GetIntVal()))
  1618. ELSE
  1619. IF verticalAlign.specified.IsLength() THEN
  1620. verticalAlign.computed := 0;
  1621. verticalAlign.computedLength := GetPixels(verticalAlign.specified, ppi, font.computed)
  1622. ELSIF verticalAlign.specified.GetType() = CSS2.Percent THEN
  1623. verticalAlign.computedLength := verticalAlign.specified.GetRealVal() * lineHeight.computed
  1624. END
  1625. END
  1626. END
  1627. END;
  1628. dimensionChanged := FALSE
  1629. END ComputeDimensions;
  1630. PROCEDURE ComputeWidthsAndMargins; (* 10.3 *)
  1631. VAR floating: BOOLEAN (* floating = TRUE, normal flow = FALSE *);
  1632. remainingWidth: LONGREAL;
  1633. BEGIN
  1634. IF borderStyle.left.computed = None THEN borderWidth.left.computed := 0.0 END;
  1635. IF borderStyle.right.computed = None THEN borderWidth.right.computed := 0.0 END;
  1636. WITH parent: VisualProperties DO
  1637. IF position.computed # Absolute THEN
  1638. SetZeroIfAutoSize(left); SetZeroIfAutoSize(right);
  1639. IF IsInlineLevelElement() OR floating THEN
  1640. SetZeroIfAutoMargin(margin.left); SetZeroIfAutoMargin(margin.right);
  1641. IF replaced THEN
  1642. END
  1643. ELSIF IsBlockLevelElement() (*& (display.computed # TableCell)*) THEN (* 10.3.3 *)
  1644. IF IsAutoSize(width) THEN (* 10.3.3, 3rd "if" *)
  1645. SetZeroIfAutoMargin(margin.left); SetZeroIfAutoMargin(margin.right);
  1646. width.computed := containingBlock.width - margin.left.computed - borderWidth.left.computed
  1647. - padding.left.computed - padding.right.computed - borderWidth.right.computed
  1648. - margin.right.computed;
  1649. (*IF display.computed = Table THEN tableLayout.computed := TRUE END*)
  1650. ELSIF IsAutoMargin(margin.left) & IsAutoMargin(margin.right) THEN
  1651. remainingWidth := containingBlock.width - borderWidth.left.computed - padding.left.computed
  1652. - width.computed - padding.right.computed - borderWidth.right.computed;
  1653. margin.left.computed := remainingWidth / 2; margin.right.computed := remainingWidth / 2
  1654. ELSIF IsAutoMargin(margin.left) OR (direction.computed = FALSE) THEN
  1655. margin.left.computed := containingBlock.width - borderWidth.left.computed - padding.left.computed
  1656. - width.computed - padding.right.computed - borderWidth.right.computed - margin.right.computed
  1657. ELSIF IsAutoMargin(margin.right) OR (direction.computed = TRUE) THEN
  1658. (*margin.right.computed := containingBlock.width - margin.left.computed - borderWidth.left.computed
  1659. - padding.left.computed - width.computed - padding.right.computed - borderWidth.right.computed*)
  1660. END;
  1661. END
  1662. ELSIF ~replaced THEN
  1663. IF (borderStyle.right.specified # NIL) & borderStyle.right.specified.IsIdent(None) THEN
  1664. borderWidth.right.computed := 0.0
  1665. END;
  1666. IF (borderStyle.left.specified # NIL) & borderStyle.left.specified.IsIdent(None) THEN
  1667. borderWidth.left.computed := 0.0
  1668. END;
  1669. IF direction.computed = TRUE THEN SetZeroIfAutoSize(left) END; (* 10.3.7 1. *)
  1670. IF direction.computed = FALSE THEN SetZeroIfAutoSize(right) END; (* 10.3.7 2. *)
  1671. IF IsAutoSize(width) THEN (* 10.3.7 3. *)
  1672. SetZeroIfAutoSize(left); SetZeroIfAutoSize(right)
  1673. END;
  1674. IF IsAutoSize(left) OR IsAutoSize(width) OR IsAutoSize(right) THEN (* 10.3.7 4. *)
  1675. SetZeroIfAutoMargin(margin.left); SetZeroIfAutoMargin(margin.right)
  1676. END;
  1677. IF IsAutoMargin(margin.left) & IsAutoMargin(margin.right) THEN (* 10.3.7 5. *)
  1678. remainingWidth := containingBlock.width - left.computed - borderWidth.left.computed
  1679. - padding.left.computed - width.computed - padding.right.computed - borderWidth.right.computed
  1680. - right.computed;
  1681. margin.left.computed := remainingWidth / 2;
  1682. margin.right.computed := remainingWidth - margin.left.computed
  1683. ELSIF IsAutoSize(left) THEN (* 10.3.7 6. *)
  1684. left.computed := containingBlock.width - margin.left.computed - borderWidth.left.computed
  1685. - padding.left.computed - width.computed - padding.right.computed - borderWidth.right.computed
  1686. - margin.right.computed - right.computed
  1687. ELSIF IsAutoMargin(margin.left) THEN (* 10.3.7 6. *)
  1688. margin.left.computed := containingBlock.width - left.computed - borderWidth.left.computed
  1689. - padding.left.computed - width.computed - padding.right.computed - borderWidth.right.computed
  1690. - margin.right.computed - right.computed
  1691. ELSIF IsAutoSize(width) THEN (* 10.3.7 6. *)
  1692. width.computed := containingBlock.width - left.computed - margin.left.computed - borderWidth.left.computed
  1693. - padding.left.computed - padding.right.computed - borderWidth.right.computed
  1694. - margin.right.computed - right.computed
  1695. ELSIF IsAutoMargin(margin.right) THEN (* 10.3.7 6. *)
  1696. margin.right.computed := containingBlock.width - left.computed - margin.left.computed
  1697. - borderWidth.left.computed - padding.left.computed - width.computed - padding.right.computed
  1698. - borderWidth.right.computed - right.computed
  1699. ELSIF IsAutoSize(right) THEN (* 10.3.7 6.*)
  1700. right.computed := containingBlock.width - left.computed - margin.left.computed
  1701. - borderWidth.left.computed - padding.left.computed - width.computed - padding.right.computed
  1702. - borderWidth.right.computed - margin.right.computed
  1703. ELSIF direction.computed = TRUE THEN (* 10.3.7 7. *)
  1704. left.computed := containingBlock.width - margin.left.computed - borderWidth.left.computed
  1705. - padding.left.computed - width.computed - padding.right.computed - borderWidth.right.computed
  1706. - margin.right.computed - right.computed
  1707. ELSIF direction.computed = FALSE THEN (* 10.3.7 7. *)
  1708. right.computed := containingBlock.width - left.computed - margin.left.computed
  1709. - borderWidth.left.computed - padding.left.computed - width.computed - padding.right.computed
  1710. - borderWidth.right.computed - margin.right.computed
  1711. END
  1712. ELSE
  1713. END
  1714. END
  1715. END ComputeWidthsAndMargins;
  1716. PROCEDURE ComputeHeightsAndMargins; (* 10.6 *)
  1717. VAR remainingHeight: LONGREAL;
  1718. BEGIN
  1719. IF borderStyle.top.computed = None THEN borderWidth.top.computed := 0.0 END;
  1720. IF borderStyle.bottom.computed = None THEN borderWidth.bottom.computed := 0.0 END;
  1721. WITH parent: VisualProperties DO
  1722. IF position.computed # Absolute THEN
  1723. SetZeroIfAutoSize(top);
  1724. SetZeroIfAutoMargin(margin.top);
  1725. SetZeroIfAutoMargin(margin.bottom);
  1726. SetZeroIfAutoSize(bottom);
  1727. IF IsInlineLevelElement() THEN
  1728. height.computed := lineHeight.computed
  1729. ELSIF IsBlockLevelElement() THEN (* height depends on child boxes *)
  1730. SetZeroIfAutoSize(height)
  1731. END
  1732. ELSE (* 10.3.7 *)
  1733. SetZeroIfAutoSize(top); (* 10.6.4 1. *)
  1734. IF IsAutoSize(height) THEN SetZeroIfAutoSize(bottom) END; (* 10.6.4 2. *)
  1735. IF IsAutoSize(height) OR IsAutoSize(bottom) THEN (* 10.6.4 3. *)
  1736. SetZeroIfAutoMargin(margin.top); SetZeroIfAutoMargin(margin.bottom)
  1737. END;
  1738. IF IsAutoMargin(margin.top) & IsAutoMargin(margin.bottom) THEN (* 10.6.4 4. *)
  1739. remainingHeight := containingBlock.height - top.computed - borderWidth.top.computed
  1740. - padding.top.computed - height.computed - padding.bottom.computed
  1741. - borderWidth.bottom.computed - bottom.computed;
  1742. margin.top.computed := remainingHeight / 2;
  1743. margin.bottom.computed := remainingHeight - margin.top.computed
  1744. ELSIF IsAutoMargin(margin.top) THEN (* 10.6.4 5. *)
  1745. margin.top.computed := containingBlock.height - top.computed - borderWidth.top.computed
  1746. - padding.top.computed - height.computed - padding.bottom.computed
  1747. - borderWidth.bottom.computed - margin.bottom.computed - bottom.computed
  1748. ELSIF IsAutoSize(height) THEN (* 10.6.4 5. *)
  1749. height.computed := containingBlock.height - top.computed - margin.top.computed
  1750. - borderWidth.top.computed - padding.top.computed - padding.bottom.computed
  1751. - borderWidth.bottom.computed - margin.bottom.computed - bottom.computed
  1752. ELSIF IsAutoMargin(margin.bottom) THEN (* 10.6.4 5. *)
  1753. margin.bottom.computed := containingBlock.height - top.computed - margin.top.computed
  1754. - borderWidth.top.computed - padding.top.computed - height.computed - padding.bottom.computed
  1755. - borderWidth.bottom.computed - bottom.computed
  1756. ELSE (* 10.6.4 5./6. *)
  1757. bottom.computed := containingBlock.height - top.computed - margin.top.computed
  1758. - borderWidth.top.computed - padding.top.computed - height.computed - padding.bottom.computed
  1759. - borderWidth.bottom.computed - margin.bottom.computed
  1760. END
  1761. END
  1762. END
  1763. END ComputeHeightsAndMargins;
  1764. PROCEDURE ComputeFont;
  1765. VAR fontName: ARRAY GfxFonts.FontNameLen OF CHAR; fnt: GfxFonts.Font; s: String;
  1766. PROCEDURE ExtractPattern(VAR from: ARRAY OF CHAR; pat: ARRAY OF CHAR);
  1767. VAR i: LONGINT; patLen: LONGINT;
  1768. BEGIN
  1769. DynamicStrings.Search(pat, from, i);
  1770. IF i # -1 THEN
  1771. patLen := DynamicStrings.StringLength(pat);
  1772. FOR i := i + patLen TO DynamicStrings.StringLength(from) DO
  1773. from[i - patLen] := from[i]
  1774. END
  1775. END
  1776. END ExtractPattern;
  1777. BEGIN
  1778. WITH parent: VisualProperties DO
  1779. font.computed := parent.font.computed;
  1780. IF (font.specified # NIL) & (font.specified.IsIdent(Inherit)) THEN
  1781. font.computed := parent.font.computed
  1782. ELSE
  1783. IF font.specified # NIL THEN
  1784. CASE font.specified.GetIntVal() OF
  1785. | Caption: font.computed := captionFont;
  1786. | Icon: font.computed := iconFont;
  1787. | Menu: font.computed := menuFont;
  1788. | MessageBox: font.computed := messageBoxFont;
  1789. | SmallCaption: font.computed := smallCaptionFont;
  1790. | StatusBar: font.computed := statusBarFont;
  1791. ELSE
  1792. END
  1793. ELSIF fontFamily # NIL THEN
  1794. (* REPEAT
  1795. term := terms.GetNext(); (* <family-name> *)*)
  1796. s := fontFamily.GetStringVal();
  1797. IF s # NIL THEN COPY(s^, fontName);
  1798. IF fontWeight # NIL THEN
  1799. IF fontWeight.IsIdent(Bolder)
  1800. OR ((fontWeight.GetType() = CSS2.IntNumber) & (fontWeight.GetIntVal() >= 700)) THEN
  1801. DynamicStrings.StringAppend(fontName, "-Bold")
  1802. ELSIF fontWeight.IsIdent(Lighter) THEN (* not supported *)
  1803. END
  1804. END;
  1805. IF (fontStyle # NIL) THEN
  1806. IF fontStyle.IsIdent(Italic) THEN DynamicStrings.StringAppend(fontName, "-Italic")
  1807. ELSIF fontStyle.IsIdent(Oblique) THEN (* not supported *)
  1808. END
  1809. END;
  1810. fnt := GfxFonts.OpenSize(fontName, SHORT(ENTIER(fontSize.computed + 0.5)));
  1811. IF fnt # NIL THEN font.computed := fnt END
  1812. END;
  1813. (* term := terms.GetNext() (* <generic-family> *)
  1814. UNTIL ~terms.HasMoreElements() OR (font.computed # NIL)*)
  1815. ELSE
  1816. COPY(parent.font.computed.name, fontName);
  1817. IF (fontWeight # NIL) & (fontWeight.IsIdent(Lighter)
  1818. OR ((fontWeight.GetType() = CSS2.IntNumber) & (fontWeight.GetIntVal() < 700))) THEN
  1819. ExtractPattern(fontName, "-Bold")
  1820. END;
  1821. IF (fontStyle # NIL) & fontStyle.IsIdent(Normal) THEN ExtractPattern(fontName, "-Italic") END;
  1822. IF parent.font.computed.name # fontName THEN
  1823. fnt := GfxFonts.OpenSize(fontName, SHORT(ENTIER(fontSize.computed + 0.5)));
  1824. IF fnt # NIL THEN font.computed := fnt END
  1825. END
  1826. END
  1827. END
  1828. END
  1829. END ComputeFont;
  1830. PROCEDURE ComputeContainingBlock;
  1831. VAR vp: VisualProperties;
  1832. BEGIN
  1833. vp := parent(VisualProperties);
  1834. WHILE (vp # SELF) & ~vp.IsBlockLevelElement() DO
  1835. vp := vp.parent(VisualProperties)
  1836. END;
  1837. containingBlock.width := vp.width.computed;
  1838. containingBlock.height := vp.height.computed;
  1839. (* IF position = Fixed THEN
  1840. (* containing block := viewport *)
  1841. ELSIF position = Absolute THEN
  1842. ELSE
  1843. IF IsBlockLevel() THEN
  1844. width := left.computed.GetIntVal() + margin.left *)
  1845. END ComputeContainingBlock;
  1846. PROCEDURE IsPositioned(): BOOLEAN;
  1847. BEGIN
  1848. RETURN position.computed # Static
  1849. END IsPositioned;
  1850. END VisualProperties;
  1851. VAR m : WMWindowManager.WindowManager;
  1852. PROCEDURE IsAutoSize*(size: Dim): BOOLEAN;
  1853. BEGIN
  1854. RETURN (size.specified = NIL) OR size.specified.IsIdent(Auto) OR size.specified.IsStringIdent("auto")
  1855. END IsAutoSize;
  1856. PROCEDURE IsAutoMargin*(margin: Dim): BOOLEAN;
  1857. BEGIN
  1858. RETURN (margin.specified # NIL) & (margin.specified.IsIdent(Auto) OR margin.specified.IsStringIdent("auto"))
  1859. END IsAutoMargin;
  1860. PROCEDURE ChangeToIdent(identValue: SHORTINT): CSS2.Term;
  1861. VAR term: CSS2.Term;
  1862. BEGIN
  1863. NEW(term); term.SetType(CSS2.Ident); term.SetIntVal(identValue); RETURN term
  1864. END ChangeToIdent;
  1865. PROCEDURE ChangeToStringIdent(VAR term: CSS2.Term; identValue: ARRAY OF CHAR);
  1866. BEGIN
  1867. IF term = NIL THEN NEW(term) END;
  1868. term.SetType(CSS2.StringIdent);
  1869. term.SetStringVal(identValue)
  1870. END ChangeToStringIdent;
  1871. PROCEDURE SetNil(VAR property: CSS2.Term; term: CSS2.Term): BOOLEAN;
  1872. BEGIN
  1873. IF term = NIL THEN property := NIL; RETURN TRUE
  1874. ELSE RETURN FALSE
  1875. END
  1876. END SetNil;
  1877. PROCEDURE SetIdentOrInherit(VAR property: CSS2.Term; term: CSS2.Term): BOOLEAN;
  1878. BEGIN
  1879. IF term.GetType() = CSS2.Ident THEN
  1880. property := term; RETURN TRUE
  1881. ELSIF term.IsStringIdent("inherit") THEN
  1882. property := ChangeToIdent(Inherit);
  1883. RETURN TRUE
  1884. ELSE
  1885. RETURN FALSE
  1886. END
  1887. END SetIdentOrInherit;
  1888. PROCEDURE SetNone(VAR property: CSS2.Term; term: CSS2.Term): BOOLEAN;
  1889. BEGIN
  1890. IF term.IsStringIdent("none") THEN
  1891. property := ChangeToIdent(None);
  1892. RETURN TRUE
  1893. ELSE
  1894. RETURN FALSE
  1895. END
  1896. END SetNone;
  1897. PROCEDURE ChangeToIdentCollection(VAR collection: XMLObjects.Collection; identValue: SHORTINT);
  1898. VAR arrColl: XMLObjects.ArrayCollection; term: CSS2.Term;
  1899. BEGIN
  1900. IF collection = NIL THEN NEW(arrColl); collection := arrColl END;
  1901. NEW(term); term.SetType(CSS2.Ident); term.SetIntVal(identValue);
  1902. collection.Add(term)
  1903. END ChangeToIdentCollection;
  1904. PROCEDURE SetNilCollection(VAR collection: XMLObjects.Collection; term: CSS2.Term): BOOLEAN;
  1905. BEGIN
  1906. IF term = NIL THEN collection := NIL; RETURN TRUE
  1907. ELSE RETURN FALSE
  1908. END
  1909. END SetNilCollection;
  1910. PROCEDURE SetIdentOrInheritCollection(VAR collection: XMLObjects.Collection; term: CSS2.Term): BOOLEAN;
  1911. BEGIN
  1912. IF term.IsStringIdent("inherit") THEN
  1913. collection := NIL;
  1914. ChangeToIdentCollection(collection, Inherit);
  1915. RETURN TRUE
  1916. ELSE
  1917. RETURN FALSE
  1918. END
  1919. END SetIdentOrInheritCollection;
  1920. (* ppi: pixel per inch *)
  1921. PROCEDURE GetPixels(term: CSS2.Term; ppi: LONGREAL; font: GfxFonts.Font): LONGREAL;
  1922. VAR fact, pixels: LONGREAL; x, y, dx, dy: REAL; map: Raster.Image;
  1923. BEGIN
  1924. IF (term # NIL) & term.IsLength() THEN
  1925. CASE term.GetUnit() OF
  1926. | CSS2.em: fact := font.ptsize / ppi
  1927. | CSS2.ex: GfxFonts.GetMap(font, 'x', x, y, dx, dy, map); fact := -y / ppi
  1928. | CSS2.px: fact := 1.0 / ppi
  1929. | CSS2.in: fact := 1.0
  1930. | CSS2.cm: fact := 1.0 / 2.54
  1931. | CSS2.mm: fact := 1.0 / 25.4
  1932. | CSS2.pt: fact := 1.0 / 72.0
  1933. | CSS2.pc: fact := 1.0 / 6.0
  1934. END;
  1935. IF term.GetType() = CSS2.IntDimension THEN pixels := term.GetIntVal() * ppi * fact
  1936. ELSIF term.GetType() = CSS2.RealDimension THEN pixels := term.GetRealVal() * ppi * fact
  1937. END
  1938. ELSIF (term # NIL) & (((term.GetType() = CSS2.IntNumber) & (term.GetIntVal() = 0))
  1939. OR ((term.GetType() = CSS2.RealNumber) & (term.GetRealVal() = 0.0))) THEN
  1940. pixels := 0.0
  1941. ELSE
  1942. pixels := 0.0
  1943. END;
  1944. RETURN pixels
  1945. END GetPixels;
  1946. PROCEDURE ChangeToPixel(pixelVal: LONGREAL): CSS2.Term;
  1947. VAR term: CSS2.Term;
  1948. BEGIN
  1949. NEW(term); term.SetType(CSS2.RealDimension); term.SetRealVal(pixelVal); term.SetUnit(CSS2.px); RETURN term
  1950. END ChangeToPixel;
  1951. PROCEDURE SetColor(VAR property: CSS2.Term; term: CSS2.Term; invertAllowed: BOOLEAN);
  1952. VAR newTerm: CSS2.Term;
  1953. BEGIN
  1954. IF ~SetNil(property, term) & ~SetIdentOrInherit(property, term) THEN
  1955. IF term.GetType() = CSS2.Color THEN property := term
  1956. ELSE
  1957. NEW(newTerm); newTerm.SetType(CSS2.Color);
  1958. IF term.IsStringIdent("aqua") THEN newTerm.SetIntVal(Aqua); property := newTerm
  1959. ELSIF term.IsStringIdent("black") THEN newTerm.SetIntVal(Black); property := newTerm
  1960. ELSIF term.IsStringIdent("blue") THEN newTerm.SetIntVal(Blue); property := newTerm
  1961. ELSIF term.IsStringIdent("fuchsia") THEN newTerm.SetIntVal(Fuchsia); property := newTerm
  1962. ELSIF term.IsStringIdent("gray") THEN newTerm.SetIntVal(Gray); property := newTerm
  1963. ELSIF term.IsStringIdent("green") THEN newTerm.SetIntVal(Green); property := newTerm
  1964. ELSIF term.IsStringIdent("lime") THEN newTerm.SetIntVal(Lime); property := newTerm
  1965. ELSIF term.IsStringIdent("maroon") THEN newTerm.SetIntVal(Maroon); property := newTerm
  1966. ELSIF term.IsStringIdent("navy") THEN newTerm.SetIntVal(Navy); property := newTerm
  1967. ELSIF term.IsStringIdent("olive") THEN newTerm.SetIntVal(Olive); property := newTerm
  1968. ELSIF term.IsStringIdent("purple") THEN newTerm.SetIntVal(Purple); property := newTerm
  1969. ELSIF term.IsStringIdent("red") THEN newTerm.SetIntVal(Red); property := newTerm
  1970. ELSIF term.IsStringIdent("silver") THEN newTerm.SetIntVal(Silver); property := newTerm
  1971. ELSIF term.IsStringIdent("teal") THEN newTerm.SetIntVal(Teal); property := newTerm
  1972. ELSIF term.IsStringIdent("white") THEN newTerm.SetIntVal(White); property := newTerm
  1973. ELSIF term.IsStringIdent("yellow") THEN newTerm.SetIntVal(Yellow); property := newTerm
  1974. ELSIF term.IsStringIdent("transparent") OR (invertAllowed & term.IsStringIdent("invert")) THEN
  1975. newTerm.SetIntVal(Transparent); property := newTerm
  1976. END
  1977. END
  1978. END
  1979. END SetColor;
  1980. PROCEDURE IsBorderStyle(term: CSS2.Term): BOOLEAN;
  1981. BEGIN
  1982. RETURN (term # NIL) & (term.IsStringIdent("hidden") & term.IsStringIdent("dotted") OR term.IsStringIdent("dashed")
  1983. OR term.IsStringIdent("solid") OR term.IsStringIdent("double") OR term.IsStringIdent("groove")
  1984. OR term.IsStringIdent("ridge") OR term.IsStringIdent("inset") OR term.IsStringIdent("outset")
  1985. OR term.IsIdent(Hidden) OR term.IsIdent(Dotted) OR term.IsIdent(Dashed) OR term.IsIdent(Solid)
  1986. OR term.IsIdent(Double) OR term.IsIdent(Groove) OR term.IsIdent(Ridge)
  1987. OR term.IsIdent(Inset) OR term.IsIdent(Outset))
  1988. END IsBorderStyle;
  1989. PROCEDURE BorderStyle(VAR position: CSS2.Term; term: CSS2.Term);
  1990. BEGIN
  1991. IF ~SetNil(position, term) & ~SetIdentOrInherit(position, term) & ~SetNone(position, term) THEN
  1992. IF term.IsStringIdent("hidden") THEN position := ChangeToIdent(Hidden)
  1993. ELSIF term.IsStringIdent("dotted") THEN position := ChangeToIdent(Dotted)
  1994. ELSIF term.IsStringIdent("dashed") THEN position := ChangeToIdent(Dashed)
  1995. ELSIF term.IsStringIdent("solid") THEN position := ChangeToIdent(Solid)
  1996. ELSIF term.IsStringIdent("double") THEN position := ChangeToIdent(Double)
  1997. ELSIF term.IsStringIdent("groove") THEN position := ChangeToIdent(Groove)
  1998. ELSIF term.IsStringIdent("ridge") THEN position := ChangeToIdent(Ridge)
  1999. ELSIF term.IsStringIdent("inset") THEN position := ChangeToIdent(Inset)
  2000. ELSIF term.IsStringIdent("outset") THEN position := ChangeToIdent(Outset)
  2001. ELSIF term.GetType() = CSS2.Ident THEN position := term
  2002. END
  2003. END
  2004. END BorderStyle;
  2005. PROCEDURE IsBorderWidth(term: CSS2.Term): BOOLEAN;
  2006. BEGIN
  2007. RETURN (term # NIL) & (term.IsStringIdent("thin") OR term.IsStringIdent("medium") OR term.IsStringIdent("thick")
  2008. OR term.IsIdent(Thin) OR term.IsIdent(Thick) OR term.IsIdent(Medium) OR term.IsLength())
  2009. END IsBorderWidth;
  2010. PROCEDURE BorderWidth(VAR position: CSS2.Term; term: CSS2.Term);
  2011. BEGIN
  2012. IF ~SetNil(position, term) & ~SetIdentOrInherit(position, term) THEN
  2013. IF term.IsStringIdent("thin") THEN position := ChangeToPixel(thinBorder)
  2014. ELSIF term.IsStringIdent("medium") THEN position := ChangeToPixel(mediumBorder)
  2015. ELSIF term.IsStringIdent("thick") THEN position := ChangeToPixel(thickBorder)
  2016. ELSIF term.IsLength() THEN position := term
  2017. END
  2018. END
  2019. END BorderWidth;
  2020. PROCEDURE BoxOffset(VAR position: CSS2.Term; term: CSS2.Term);
  2021. BEGIN
  2022. IF ~SetNil(position, term) & ~SetIdentOrInherit(position, term) THEN
  2023. IF term.IsStringIdent("auto") THEN
  2024. position := ChangeToIdent(Auto)
  2025. ELSIF term.IsStringIdent("static-position") THEN
  2026. position := ChangeToIdent(StaticPosition)
  2027. ELSIF term.IsLength() OR (term.GetType() = CSS2.Percent) THEN
  2028. position := term
  2029. END
  2030. END
  2031. END BoxOffset;
  2032. (*
  2033. PROCEDURE GetSmallerFont(fontSize: LONGINT): LONGINT;
  2034. VAR i: SHORTINT;
  2035. BEGIN
  2036. i := XXSmall;
  2037. WHILE (i <= XXLarge) & (AbsoluteFontSizes[i] < fontSize) DO INC(i) END;
  2038. IF i = XXSmall THEN i := XXSmall + 1 END;
  2039. RETURN AbsoluteFontSizes[i - 1]
  2040. END GetSmallerFont;
  2041. PROCEDURE GetLargerFont(fontSize: LONGINT): LONGINT;
  2042. VAR i: SHORTINT;
  2043. BEGIN
  2044. i := XXLarge;
  2045. WHILE (XXSmall <= i) & (fontSize < AbsoluteFontSizes[i]) DO DEC(i) END;
  2046. IF i = XXLarge THEN i := XXLarge - 1 END;
  2047. RETURN AbsoluteFontSizes[i + 1]
  2048. END GetLargerFont;
  2049. *)
  2050. PROCEDURE ListStyleImage(VAR listStyleImage: CSS2.Term; term: CSS2.Term);
  2051. BEGIN
  2052. IF ~SetNil(listStyleImage, term) & ~SetIdentOrInherit(listStyleImage, term) & ~SetNone(listStyleImage, term) THEN
  2053. IF term.GetType() = CSS2.URI THEN listStyleImage := term
  2054. END
  2055. END
  2056. END ListStyleImage;
  2057. PROCEDURE ListStylePosition(VAR listStylePosition: CSS2.Term; term: CSS2.Term);
  2058. BEGIN
  2059. IF ~SetNil(listStylePosition, term) & ~SetIdentOrInherit(listStylePosition, term) THEN
  2060. IF term.IsStringIdent("inside") THEN listStylePosition := ChangeToIdent(Inside)
  2061. ELSIF term.IsStringIdent("outside") THEN listStylePosition := ChangeToIdent(Outside)
  2062. END
  2063. END
  2064. END ListStylePosition;
  2065. PROCEDURE ListStyleType(VAR listStyleType: CSS2.Term; term: CSS2.Term);
  2066. BEGIN
  2067. IF ~SetNil(listStyleType, term) & ~SetIdentOrInherit(listStyleType, term) OR ~SetNone(listStyleType, term) THEN
  2068. IF term.IsStringIdent("disc") THEN listStyleType := ChangeToIdent(Disc)
  2069. ELSIF term.IsStringIdent("circle") THEN listStyleType := ChangeToIdent(Circle)
  2070. ELSIF term.IsStringIdent("square") THEN listStyleType := ChangeToIdent(Square)
  2071. ELSIF term.IsStringIdent("decimal") THEN listStyleType := ChangeToIdent(Decimal)
  2072. ELSIF term.IsStringIdent("decimal-leading-zero") THEN listStyleType := ChangeToIdent(DecimalLeadingZero)
  2073. ELSIF term.IsStringIdent("lower-roman") THEN listStyleType := ChangeToIdent(LowerRoman)
  2074. ELSIF term.IsStringIdent("upper-roman") THEN listStyleType := ChangeToIdent(UpperRoman)
  2075. ELSIF term.IsStringIdent("lower-greek") THEN listStyleType := ChangeToIdent(LowerGreek)
  2076. ELSIF term.IsStringIdent("lower-alpha") THEN listStyleType := ChangeToIdent(LowerAlpha)
  2077. ELSIF term.IsStringIdent("lower-latin") THEN listStyleType := ChangeToIdent(LowerLatin)
  2078. ELSIF term.IsStringIdent("upper-alpha") THEN listStyleType := ChangeToIdent(UpperAlpha)
  2079. ELSIF term.IsStringIdent("upper-latin") THEN listStyleType := ChangeToIdent(UpperLatin)
  2080. ELSIF term.IsStringIdent("hebrew") THEN listStyleType := ChangeToIdent(Hebrew)
  2081. ELSIF term.IsStringIdent("armenian") THEN listStyleType := ChangeToIdent(Armenian)
  2082. ELSIF term.IsStringIdent("georgian") THEN listStyleType := ChangeToIdent(Georgian)
  2083. ELSIF term.IsStringIdent("cjk-ideographic") THEN listStyleType := ChangeToIdent(CjkIdeographic)
  2084. ELSIF term.IsStringIdent("hiragana") THEN listStyleType := ChangeToIdent(Hiragana)
  2085. ELSIF term.IsStringIdent("katakana") THEN listStyleType := ChangeToIdent(Katakana)
  2086. ELSIF term.IsStringIdent("hiragana-iroha") THEN listStyleType := ChangeToIdent(HiraganaIroha)
  2087. ELSIF term.IsStringIdent("katakana-iroha") THEN listStyleType := ChangeToIdent(KatakanaIroha)
  2088. END
  2089. END
  2090. END ListStyleType;
  2091. PROCEDURE MarginWidth(VAR position: CSS2.Term; term: CSS2.Term);
  2092. BEGIN
  2093. IF ~SetNil(position, term) & ~SetIdentOrInherit(position, term) THEN
  2094. IF term.IsStringIdent("auto") THEN position := ChangeToIdent(Auto)
  2095. ELSIF term.IsLength() OR (term.GetType() = CSS2.Percent) THEN position := term
  2096. END
  2097. END
  2098. END MarginWidth;
  2099. PROCEDURE MaxDimension(VAR dimension: CSS2.Term; term: CSS2.Term);
  2100. BEGIN
  2101. IF ~SetNil(dimension, term) & ~SetIdentOrInherit(dimension, term) OR ~SetNone(dimension, term) THEN
  2102. IF term.IsLength() OR (term.GetType() = CSS2.Percent) THEN
  2103. dimension := term
  2104. END
  2105. END
  2106. END MaxDimension;
  2107. PROCEDURE MinDimension(VAR dimension: CSS2.Term; term: CSS2.Term);
  2108. BEGIN
  2109. IF ~SetNil(dimension, term) & ~SetIdentOrInherit(dimension, term) THEN
  2110. IF term.IsLength() OR (term.GetType() = CSS2.Percent) THEN
  2111. dimension := term
  2112. END
  2113. END
  2114. END MinDimension;
  2115. PROCEDURE PaddingWidth(VAR position: CSS2.Term; term: CSS2.Term);
  2116. BEGIN
  2117. IF ~SetNil(position, term) & ~SetIdentOrInherit(position, term) THEN
  2118. IF term.IsLength() OR (term.GetType() = CSS2.Percent) THEN position := term
  2119. END
  2120. END
  2121. END PaddingWidth;
  2122. PROCEDURE ComputeBool(VAR property: Bool; parentProperty: Bool; trueIdent: LONGINT);
  2123. BEGIN
  2124. IF property.specified # NIL THEN
  2125. IF property.specified.IsIdent(Inherit) THEN property.computed := parentProperty.computed
  2126. ELSE property.computed := property.specified.GetIntVal() = trueIdent
  2127. END
  2128. END
  2129. END ComputeBool;
  2130. PROCEDURE ComputeColor(VAR property: Color; parentProperty, initial: Color);
  2131. BEGIN
  2132. IF property.specified # NIL THEN
  2133. IF property.specified.IsIdent(Inherit) THEN property.computed := parentProperty.computed
  2134. ELSE property.specified.GetColor(property.computed.r, property.computed.g,
  2135. property.computed.b, property.computed.a)
  2136. END
  2137. ELSE
  2138. property := initial; property.specified := NIL
  2139. END
  2140. END ComputeColor;
  2141. PROCEDURE ComputeImg(VAR property: Img; parentProperty: Img);
  2142. VAR name: String; imgTerm: ImgTerm;
  2143. BEGIN
  2144. IF (property.specified # NIL) THEN
  2145. IF property.specified IS ImgTerm THEN
  2146. property.computed := property.specified(ImgTerm).img
  2147. ELSIF property.specified.IsIdent(None) THEN
  2148. property.computed := NIL
  2149. ELSIF property.specified.IsIdent(Inherit) THEN
  2150. property.computed := parentProperty.computed
  2151. ELSE
  2152. name := property.specified.GetStringVal();
  2153. IF name # NIL THEN
  2154. property.computed := WMGraphics.LoadImage(name^, TRUE);
  2155. IF property.computed # NIL THEN
  2156. NEW(imgTerm); imgTerm.img := property.computed; property.specified := imgTerm;
  2157. ELSE property.computed := NIL
  2158. END
  2159. END
  2160. END
  2161. ELSE
  2162. property.computed := NIL
  2163. END
  2164. END ComputeImg;
  2165. PROCEDURE ComputeDim(VAR property: Dim; parentProperty: Dim; ppi, referenceDim: LONGREAL; font: GfxFonts.Font);
  2166. BEGIN
  2167. IF (property.specified # NIL) THEN
  2168. IF property.specified.IsIdent(Inherit) THEN
  2169. property.computed := parentProperty.computed
  2170. ELSIF property.specified.IsIdent(Auto) THEN
  2171. property.computed := DummyAuto
  2172. ELSIF property.specified.GetType() = CSS2.Percent THEN
  2173. property.computed := property.specified.GetRealVal() * referenceDim
  2174. ELSIF property.specified.IsLength() THEN
  2175. property.computed := GetPixels(property.specified, ppi, font)
  2176. END
  2177. END
  2178. END ComputeDim;
  2179. PROCEDURE ComputeIdent(VAR property: Ident; parentProperty: Ident);
  2180. BEGIN
  2181. IF (property.specified # NIL) THEN
  2182. IF property.specified.IsIdent(Inherit) THEN
  2183. property.computed := parentProperty.computed
  2184. ELSE
  2185. property.computed := SHORT(SHORT(property.specified.GetIntVal()))
  2186. END
  2187. END
  2188. END ComputeIdent;
  2189. PROCEDURE ComputeCursor(VAR property: Cursor; parentProperty: Cursor);
  2190. VAR terms: XMLObjects.Enumerator; term: ANY; s: String;
  2191. BEGIN
  2192. IF property.specified # NIL THEN
  2193. terms := property.specified.GetEnumerator();
  2194. term := terms.GetNext();
  2195. IF term(CSS2.Term).GetType() = CSS2.Ident THEN
  2196. CASE term(CSS2.Term).GetIntVal() OF
  2197. | Inherit: property.computed := parentProperty.computed
  2198. | Auto: property.computed := defaultCursor
  2199. | Default: property.computed := defaultCursor
  2200. | Crosshair: property.computed := crosshairCursor
  2201. | Pointer: property.computed := pointerCursor
  2202. | Move: property.computed := moveCursor
  2203. | EResize: property.computed := eResizeCursor
  2204. | NEResize: property.computed := neResizeCursor
  2205. | NWResize: property.computed := nwResizeCursor
  2206. | NResize: property.computed := nResizeCursor
  2207. | SEResize: property.computed := seResizeCursor
  2208. | SWResize: property.computed := swResizeCursor
  2209. | SResize: property.computed := sResizeCursor
  2210. | WResize: property.computed := wResizeCursor
  2211. | Text: property.computed := textCursor
  2212. | Wait: property.computed := waitCursor
  2213. | Help: property.computed := helpCursor
  2214. ELSE
  2215. END
  2216. ELSIF term(CSS2.Term).GetType() = CSS2.URI THEN
  2217. terms := property.specified.GetEnumerator();
  2218. REPEAT
  2219. term := terms.GetNext();
  2220. s := term(CSS2.Term).GetStringVal();
  2221. IF s # NIL THEN
  2222. NEW(property.computed);
  2223. property.computed.img := WMGraphics.LoadImage( s^, TRUE);
  2224. END
  2225. UNTIL ~terms.HasMoreElements() OR (property.computed # NIL)
  2226. END
  2227. END;
  2228. END ComputeCursor;
  2229. PROCEDURE SetZeroIfAutoSize(size: Dim);
  2230. BEGIN
  2231. IF IsAutoSize(size) THEN size.computed := 0.0 END
  2232. END SetZeroIfAutoSize;
  2233. PROCEDURE SetZeroIfAutoMargin(size: Dim);
  2234. BEGIN
  2235. IF IsAutoMargin(size) THEN size.computed := 0.0 END
  2236. END SetZeroIfAutoMargin;
  2237. PROCEDURE ToGfxColor*(color: Color): Gfx.Color;
  2238. VAR c: Gfx.Color;
  2239. BEGIN
  2240. c.r := ORD(color.computed.r); c.g := ORD(color.computed.g); c.b := ORD(color.computed.b); c.a := ORD(color.computed.a);
  2241. RETURN c
  2242. END ToGfxColor;
  2243. PROCEDURE IntToColor(color: LONGINT): Color;
  2244. VAR c1: CSS2.Term; c2: Color;
  2245. BEGIN
  2246. NEW(c1); c1.SetType(CSS2.Color); c1.SetIntVal(color);
  2247. c1.GetColor(c2.computed.r, c2.computed.g, c2.computed.b, c2.computed.a);
  2248. RETURN c2
  2249. END IntToColor;
  2250. BEGIN
  2251. AbsoluteFontSizes[XXSmall] := 6;
  2252. AbsoluteFontSizes[XSmall] := 8;
  2253. AbsoluteFontSizes[Small] := 10;
  2254. AbsoluteFontSizes[Medium] := 12;
  2255. AbsoluteFontSizes[Large] := 16;
  2256. AbsoluteFontSizes[XLarge] := 20;
  2257. AbsoluteFontSizes[XXLarge] := 24;
  2258. defaultColor := Black;
  2259. m := WMWindowManager.GetDefaultManager();
  2260. defaultCursor := m.pointerStandard;
  2261. crosshairCursor := m.pointerStandard;
  2262. pointerCursor := m.pointerStandard;
  2263. moveCursor := m.pointerMove;
  2264. eResizeCursor := m.pointerMove;
  2265. neResizeCursor := m.pointerMove;
  2266. nwResizeCursor := m.pointerMove;
  2267. nResizeCursor := m.pointerMove;
  2268. seResizeCursor := m.pointerMove;
  2269. swResizeCursor := m.pointerMove;
  2270. sResizeCursor := m.pointerMove;
  2271. wResizeCursor := m.pointerMove;
  2272. textCursor := m.pointerStandard;
  2273. waitCursor := m.pointerStandard;
  2274. helpCursor := m.pointerStandard;
  2275. defaultFont := GfxFonts.Default;
  2276. captionFont := GfxFonts.Default;
  2277. iconFont := GfxFonts.Default;
  2278. menuFont := GfxFonts.Default;
  2279. messageBoxFont := GfxFonts.Default;
  2280. smallCaptionFont := GfxFonts.Default;
  2281. statusBarFont := GfxFonts.Default;
  2282. thinBorder := 1.0;
  2283. mediumBorder := 3.0;
  2284. thickBorder := 5.0;
  2285. END CSS2Properties.