dom_html.pp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. {
  2. $Id$
  3. This file is part of the Free Component Library
  4. Implementation of DOM HTML interfaces
  5. Copyright (c) 2002 by
  6. Areca Systems GmbH / Sebastian Guenther, [email protected]
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. { Please note that this is a very early version, most properties and methods
  14. are not implemented yet. }
  15. unit DOM_HTML;
  16. interface
  17. uses DOM;
  18. type
  19. THTMLDocument = class;
  20. THTMLFormElement = class;
  21. THTMLTableCaptionElement = class;
  22. THTMLTableSectionElement = class;
  23. THTMLCollection = class
  24. public
  25. property Length: Cardinal; // !!!: ro
  26. function Item(Index: Cardinal): TDOMNode;
  27. function NamedItem(const Index: DOMString): TDOMNode;
  28. end;
  29. THTMLOptionsCollection = class
  30. public
  31. property Length: Cardinal; // !!!: ro
  32. function Item(Index: Cardinal): TDOMNode;
  33. function NamedItem(const Index: DOMString): TDOMNode;
  34. end;
  35. THTMLElement = class(TDOMElement)
  36. private
  37. function GetID: DOMString;
  38. procedure SetID(const Value: DOMString);
  39. function GetTitle: DOMString;
  40. procedure SetTitle(const Value: DOMString);
  41. function GetLang: DOMString;
  42. procedure SetLang(const Value: DOMString);
  43. function GetDir: DOMString;
  44. procedure SetDir(const Value: DOMString);
  45. function GetClassName: DOMString;
  46. procedure SetClassName(const Value: DOMString);
  47. protected
  48. constructor Create(AOwner: THTMLDocument; const ATagName: DOMString);
  49. public
  50. property ID: DOMString read GetID write SetID;
  51. property Title: DOMString read GetTitle write SetTitle;
  52. property Lang: DOMString read GetLang write SetLang;
  53. property Dir: DOMString read GetDir write SetDir;
  54. property ClassName: DOMString read GetClassName write SetClassName;
  55. end;
  56. THTMLHtmlElement = class(THTMLElement)
  57. private
  58. function GetVersion: DOMString;
  59. procedure SetVersion(const Value: DOMString);
  60. public
  61. property Version: DOMString read GetVersion write SetVersion;
  62. end;
  63. THTMLHeadElement = class(THTMLElement)
  64. private
  65. function GetProfile: DOMString;
  66. procedure SetProfile(const Value: DOMString);
  67. public
  68. property Profile: DOMString read GetProfile write SetProfile;
  69. end;
  70. THTMLLinkElement = class(THTMLElement)
  71. public
  72. property Disabled: Boolean; // !!!: rw
  73. property Charset: DOMString; // !!!: rw
  74. property HRef: DOMString; // !!!: rw
  75. property HRefLang: DOMString; // !!!: rw
  76. property Media: DOMString; // !!!: rw
  77. property Rel: DOMString; // !!!: rw
  78. property Rev: DOMString; // !!!: rw
  79. property Target: DOMString; // !!!: rw
  80. property HTMLType: DOMString; // !!!: rw
  81. end;
  82. THTMLTitleElement = class(THTMLElement)
  83. public
  84. property Text: DOMString; // !!!: rw
  85. end;
  86. THTMLMetaElement = class(THTMLElement)
  87. public
  88. property Content: DOMString; // !!!: rw
  89. property HTTPEqiv: DOMString; // !!!: rw
  90. property Name: DOMString; // !!!: rw
  91. property Scheme: DOMString; // !!!: rw
  92. end;
  93. THTMLBaseElement = class(THTMLElement)
  94. public
  95. property HRef: DOMString; // !!!: rw
  96. property Target: DOMString; // !!!: rw
  97. end;
  98. THTMLIsIndexElement = class(THTMLElement)
  99. public
  100. property Form: THTMLFormElement; // !!!: ro
  101. property Prompt: DOMString; // !!!: rw
  102. end;
  103. THTMLStyleElement = class(THTMLElement)
  104. public
  105. property Disabled: Boolean; // !!!: rw
  106. property Media: DOMString; // !!!: rw
  107. property HTMLType: DOMString; // !!!: rw
  108. end;
  109. THTMLBodyElement = class(THTMLElement)
  110. public
  111. property ALink: DOMString; // !!!: rw
  112. property Background: DOMString; // !!!: rw
  113. property BgColor: DOMString; // !!!: rw
  114. property Link: DOMString; // !!!: rw
  115. property Text: DOMString; // !!!: rw
  116. property VLink: DOMString; // !!!: rw
  117. end;
  118. THTMLFormElement = class(THTMLElement)
  119. public
  120. property Elements: THTMLCollection; // !!!: ro
  121. property Length: Integer; // !!!: ro
  122. property Name: DOMString; // !!!: rw
  123. property AcceptCharset: DOMString; // !!!: rw
  124. property Action: DOMString; // !!!: rw
  125. property EncType: DOMString; // !!!: rw
  126. property Method: DOMString; // !!!: rw
  127. property Target: DOMString; // !!!: rw
  128. procedure Submit; virtual; abstract;
  129. procedure Reset; virtual; abstract;
  130. end;
  131. THTMLSelectElement = class(THTMLElement)
  132. public
  133. property HTMLType: DOMString; // !!!: ro
  134. property SelectedIndex: Integer; // !!!: rw
  135. property Value: DOMString; // !!!: rw
  136. property Length: Cardinal; // !!!: rw
  137. property Form: THTMLFormElement; // !!!: ro
  138. property Options: THTMLOptionsCollection; // !!!: ro
  139. property Disabled: Boolean; // !!!: rw
  140. property Multiple: Boolean; // !!!: rw
  141. property Name: DOMString; // !!!: rw
  142. property Size: Integer; // !!!: rw
  143. property TabIndex: Integer; // !!!: rw
  144. procedure Add(Element, Before: THTMLElement);
  145. procedure Remove(Index: Integer);
  146. procedure Blur; virtual; abstract;
  147. procedure Focus; virtual; abstract;
  148. end;
  149. THTMLOptGroupElement = class(THTMLElement)
  150. public
  151. property Disabled: Boolean; // !!!: rw
  152. property GroupLabel: DOMString; // !!!: rw
  153. end;
  154. THTMLOptionElement = class(THTMLElement)
  155. public
  156. property Form: THTMLFormElement; // !!!: ro
  157. property DefaultSelected: Boolean; // !!!: rw
  158. property Text: DOMString; // !!!: ro
  159. property Index: Integer; // !!!: ro
  160. property Disabled: Boolean; // !!!: rw
  161. property OptionLabel: DOMString; // !!!: rw
  162. property Selected: Boolean; // !!!: rw
  163. property Value: DOMString; // !!!: rw
  164. end;
  165. THTMLInputElement = class(THTMLElement)
  166. public
  167. property DefaultValue: DOMString; // !!!: rw
  168. property DefaultChecked: Boolean; // !!!: rw
  169. property Form: THTMLFormElement; // !!!: ro
  170. property Accept: DOMString; // !!!: rw
  171. property AccessKey: DOMString; // !!!: rw
  172. property Align: DOMString; // !!!: rw
  173. property Alt: DOMString; // !!!: rw
  174. property Checked: Boolean; // !!!: rw
  175. property Disabled: Boolean; // !!!: rw
  176. property MaxLength: Integer; // !!!: rw
  177. property Name: DOMString; // !!!: rw
  178. property ReadOnly: Boolean; // !!!: rw
  179. property Size: Cardinal; // !!!: rw
  180. property Src: DOMString; // !!!: rw
  181. property TabIndex: Integer; // !!!: rw
  182. property HTMLType: DOMString; // !!!: rw
  183. property UseMap: DOMString; // !!!: rw
  184. property Value: DOMString; // !!!: rw
  185. procedure Blur; virtual; abstract;
  186. procedure Focus; virtual; abstract;
  187. procedure Select; virtual; abstract;
  188. procedure Click; virtual; abstract;
  189. end;
  190. THTMLTextAreaElement = class(THTMLElement)
  191. public
  192. property DefaultValue: DOMString; // !!!: rw
  193. property Form: THTMLFormElement; // !!!: ro
  194. property AccessKey: DOMString; // !!!: rw
  195. property Cols: Integer; // !!!: rw
  196. property Disabled: Boolean; // !!!: rw
  197. property Name: DOMString; // !!!: rw
  198. property ReadOnly: Boolean; // !!!: rw
  199. property Rows: Integer; // !!!: rw
  200. property TabIndex: Integer; // !!!: rw
  201. property HTMLType: DOMString; // !!!: rw
  202. property Value: DOMString; // !!!: rw
  203. procedure Blur; virtual; abstract;
  204. procedure Focus; virtual; abstract;
  205. procedure Select; virtual; abstract;
  206. end;
  207. THTMLButtonElement = class(THTMLElement)
  208. public
  209. property Form: THTMLFormElement; // !!!: ro
  210. property AccessKey: DOMString; // !!!: rw
  211. property Disabled: Boolean; // !!!: rw
  212. property Name: DOMString; // !!!: rw
  213. property TabIndex: Integer; // !!!: rw
  214. property HTMLType: DOMString; // !!!: rw
  215. property Value: DOMString; // !!!: rw
  216. end;
  217. THTMLLabelElement = class(THTMLElement)
  218. public
  219. property Form: THTMLFormElement; // !!!: ro
  220. property AccessKey: DOMString; // !!!: rw
  221. property HtmlFor: DOMString; // !!!: rw
  222. end;
  223. THTMLFieldSetElement = class(THTMLElement)
  224. public
  225. property Form: THTMLFormElement; // !!!: ro
  226. end;
  227. THTMLLegendElement = class(THTMLElement)
  228. public
  229. property Form: THTMLFormElement; // !!!: ro
  230. property AccessKey: DOMString; // !!!: rw
  231. property Align: DOMString; // !!!: rw
  232. end;
  233. THTMLUListElement = class(THTMLElement)
  234. public
  235. property Compact: Boolean; // !!!: rw
  236. property HTMLType: DOMString; // !!!: rw
  237. end;
  238. THTMLOListElement = class(THTMLElement)
  239. public
  240. property Compact: Boolean; // !!!: rw
  241. property Start: Integer; // !!!: rw
  242. property HTMLType: DOMString; // !!!: rw
  243. end;
  244. THTMLDListElement = class(THTMLElement)
  245. public
  246. property Compact: Boolean; // !!!: rw
  247. end;
  248. THTMLDirectoryElement = class(THTMLElement)
  249. public
  250. property Compact: Boolean; // !!!: rw
  251. end;
  252. THTMLMenuElement = class(THTMLElement)
  253. public
  254. property Compact: Boolean; // !!!: rw
  255. end;
  256. THTMLLIElement = class(THTMLElement)
  257. public
  258. property HTMLType: DOMString; // !!!: rw
  259. property Value: Integer; // !!!: rw
  260. end;
  261. THTMLDivElement = class(THTMLElement)
  262. public
  263. property Align: DOMString; // !!!: rw
  264. end;
  265. THTMLParagraphElement = class(THTMLElement)
  266. public
  267. property Align: DOMString; // !!!: rw
  268. end;
  269. THTMLHeadingElement = class(THTMLElement)
  270. public
  271. property Align: DOMString; // !!!: rw
  272. end;
  273. THTMLQuoteElement = class(THTMLElement)
  274. public
  275. property Cite: DOMString; // !!!: rw
  276. end;
  277. THTMLPreElement = class(THTMLElement)
  278. public
  279. property Width: Integer; // !!!: rw
  280. end;
  281. THTMLBREElement = class(THTMLElement)
  282. public
  283. property Clear: DOMString; // !!!: rw
  284. end;
  285. THTMLBaseFontElement = class(THTMLElement)
  286. public
  287. property Color: DOMString; // !!!: rw
  288. property Face: DOMString; // !!!: rw
  289. property Size: Integer; // !!!: rw
  290. end;
  291. THTMLFontElement = class(THTMLElement)
  292. public
  293. property Color: DOMString; // !!!: rw
  294. property Face: DOMString; // !!!: rw
  295. property Size: Integer; // !!!: rw
  296. end;
  297. THTMLHRElement = class(THTMLElement)
  298. public
  299. property Align: DOMString; // !!!: rw
  300. property NoShade: Boolean; // !!!: rw
  301. property Size: DOMString; // !!!: rw
  302. property Width: DOMString; // !!!: rw
  303. end;
  304. THTMLModElement = class(THTMLElement)
  305. public
  306. property Cite: DOMString; // !!!: rw
  307. property DateTime: DOMString; // !!!: rw
  308. end;
  309. THTMLAnchorElement = class(THTMLElement)
  310. public
  311. property AccessKey: DOMString; // !!!: rw
  312. property Charset: DOMString; // !!!: rw
  313. property Coords: DOMString; // !!!: rw
  314. property HRef: DOMString; // !!!: rw
  315. property HRefLang: DOMString; // !!!: rw
  316. property Name: DOMString; // !!!: rw
  317. property Rel: DOMString; // !!!: rw
  318. property Rev: DOMString; // !!!: rw
  319. property Shape: DOMString; // !!!: rw
  320. property TabIndex: Integer; // !!!: rw
  321. property Target: DOMString; // !!!: rw
  322. property HTMLType: DOMString; // !!!: rw
  323. procedure Blur; virtual; abstract;
  324. procedure Focus; virtual; abstract;
  325. end;
  326. THTMLImageElement = class(THTMLElement)
  327. public
  328. property Name: DOMString; // !!!: rw
  329. property Align: DOMString; // !!!: rw
  330. property Alt: DOMString; // !!!: rw
  331. property Border: DOMString; // !!!: rw
  332. property Height: Integer; // !!!: rw
  333. property HSpace: Integer; // !!!: rw
  334. property IsMap: Boolean; // !!!: rw
  335. property LongDesc: DOMString; // !!!: rw
  336. property Src: Integer; // !!!: rw
  337. property UseMap: DOMString; // !!!: rw
  338. property VSpace: Integer; // !!!: rw
  339. property Width: Integer; // !!!: rw
  340. end;
  341. THTMLObjectElement = class(THTMLElement)
  342. public
  343. property Form: THTMLFormElement; // !!!: ro
  344. property Code: DOMString; // !!!: rw
  345. property Align: DOMString; // !!!: rw
  346. property Archive: DOMString; // !!!: rw
  347. property Border: DOMString; // !!!: rw
  348. property CodeBase: DOMString; // !!!: rw
  349. property CodeType: DOMString; // !!!: rw
  350. property Data: DOMString; // !!!: rw
  351. property Declare: Boolean; // !!!: rw
  352. property Height: DOMString; // !!!: rw
  353. property HSpace: Integer; // !!!: rw
  354. property Name: DOMString; // !!!: rw
  355. property StandBy: DOMString; // !!!: rw
  356. property TabIndex: Integer; // !!!: rw
  357. property HTMLType: DOMString; // !!!: rw
  358. property UseMap: DOMString; // !!!: rw
  359. property VSpace: Integer; // !!!: rw
  360. property Width: Integer; // !!!: rw
  361. property ContentDocument: TDOMDocument; // !!!: ro
  362. end;
  363. THTMLParamElement = class(THTMLElement)
  364. public
  365. property Name: DOMString; // !!!: rw
  366. property HTMLType: DOMString; // !!!: rw
  367. property Value: DOMString; // !!!: rw
  368. property ValueType: DOMString; // !!!: rw
  369. end;
  370. THTMLAppletElement = class(THTMLElement)
  371. public
  372. property Align: DOMString; // !!!: rw
  373. property Alt: DOMString; // !!!: rw
  374. property Archive: DOMString; // !!!: rw
  375. property Code: DOMString; // !!!: rw
  376. property CodeBase: DOMString; // !!!: rw
  377. property Height: DOMString; // !!!: rw
  378. property HSpace: Integer; // !!!: rw
  379. property Name: DOMString; // !!!: rw
  380. property AppletObject: DOMString; // !!!: rw
  381. property VSpace: Integer; // !!!: rw
  382. property Width: Integer; // !!!: rw
  383. end;
  384. THTMLMapElement = class(THTMLElement)
  385. public
  386. property Areas: THTMLCollection; // !!!: ro
  387. property Name: DOMString; // !!!: rw
  388. end;
  389. THTMLAreaElement = class(THTMLElement)
  390. public
  391. property AccessKey: DOMString; // !!!: rw
  392. property Alt: DOMString; // !!!: rw
  393. property Coords: DOMString; // !!!: rw
  394. property HRef: DOMString; // !!!: rw
  395. property NoHRef: Boolean; // !!!: rw
  396. property Shape: DOMString; // !!!: rw
  397. property TabIndex: Integer; // !!!: rw
  398. property Target: DOMString; // !!!: rw
  399. end;
  400. THTMLScriptElement = class(THTMLElement)
  401. public
  402. property Text: DOMString; // !!!: rw
  403. property HtmlFor: DOMString; // !!!: rw
  404. property Event: DOMString; // !!!: rw
  405. property Charset: DOMString; // !!!: rw
  406. property Defer: Boolean; // !!!: rw
  407. property Src: DOMString; // !!!: rw
  408. property HTMLType: DOMString; // !!!: rw
  409. end;
  410. THTMLTableElement = class(THTMLElement)
  411. public
  412. property Caption: THTMLTableCaptionElement; // !!!: rw
  413. property THead: THTMLTableSectionElement; // !!!: rw
  414. property TFoot: THTMLTableSectionElement; // !!!: rw
  415. property Rows: THTMLCollection; // !!!: ro
  416. property TBodies: THTMLCollection; // !!!: ro
  417. property Align: DOMString; // !!!: rw
  418. property BgColor: DOMString; // !!!: rw
  419. property Border: DOMString; // !!!: rw
  420. property CellPadding: DOMString; // !!!: rw
  421. property CellSpacing: DOMString; // !!!: rw
  422. property Frame: DOMString; // !!!: rw
  423. property Rules: DOMString; // !!!: rw
  424. property Summary: DOMString; // !!!: rw
  425. property Width: DOMString; // !!!: rw
  426. function CreateTHead: THTMLElement;
  427. procedure DeleteTHead;
  428. function CreateTFoot: THTMLElement;
  429. procedure DeleteTFoot;
  430. function CreateCaption: THTMLElement;
  431. procedure DeleteCaption;
  432. function InsertRow(Index: Integer): THTMLElement;
  433. procedure DeleteRow(Index: Integer);
  434. end;
  435. THTMLTableCaptionElement = class(THTMLElement)
  436. public
  437. property Align: DOMString; // !!!: rw
  438. end;
  439. THTMLTableColElement = class(THTMLElement)
  440. public
  441. property Align: DOMString; // !!!: rw
  442. property Ch: DOMString; // !!!: rw
  443. property ChOff: DOMString; // !!!: rw
  444. property Span: Integer; // !!!: rw
  445. property VAlign: DOMString; // !!!: rw
  446. property Width: DOMString; // !!!: rw
  447. end;
  448. THTMLTableSectionElement = class(THTMLElement)
  449. public
  450. property Align: DOMString; // !!!: rw
  451. property Ch: DOMString; // !!!: rw
  452. property ChOff: DOMString; // !!!: rw
  453. property VAlign: DOMString; // !!!: rw
  454. property Rows: THTMLCollection; // !!!: ro
  455. function InsertRow(Index: Integer): THTMLElement;
  456. procedure DeleteRow(Index: Integer);
  457. end;
  458. THTMLTableRowElement = class(THTMLElement)
  459. public
  460. property RowIndex: Integer; // !!!: ro
  461. property SectionRowIndex: Integer; // !!!: ro
  462. property Cells: THTMLCollection; // !!!: ro
  463. property Align: DOMString; // !!!: rw
  464. property BgColor: DOMString; // !!!: rw
  465. property Ch: DOMString; // !!!: rw
  466. property ChOff: DOMString; // !!!: rw
  467. property VAlign: DOMString; // !!!: rw
  468. function InsertCell(Index: Integer): THTMLElement;
  469. procedure DeleteCell(Index: Integer);
  470. end;
  471. THTMLTableCellElement = class(THTMLElement)
  472. public
  473. property CellIndex: Integer; // !!!: ro
  474. property Abbr: DOMString; // !!!: rw
  475. property Align: DOMString; // !!!: rw
  476. property Axis: DOMString; // !!!: rw
  477. property BgColor: DOMString; // !!!: rw
  478. property Ch: DOMString; // !!!: rw
  479. property ChOff: DOMString; // !!!: rw
  480. property ColSpan: Integer; // !!!: rw
  481. property Headers: DOMString; // !!!: rw
  482. property Height: DOMString; // !!!: rw
  483. property NoWrap: Boolean; // !!!: rw
  484. property RowSpan: Integer; // !!!: rw
  485. property Scope: DOMString; // !!!: rw
  486. property VAlign: DOMString; // !!!: rw
  487. property Width: DOMString; // !!!: rw
  488. end;
  489. THTMLFrameSetElement = class(THTMLElement)
  490. public
  491. property Cols: DOMString; // !!!: rw
  492. property Rows: DOMString; // !!!: rw
  493. end;
  494. THTMLFrameElement = class(THTMLElement)
  495. public
  496. property FrameBorder: DOMString; // !!!: rw
  497. property LongDesc: DOMString; // !!!: rw
  498. property MarginHeight: DOMString; // !!!: rw
  499. property MarginWidth: DOMString; // !!!: rw
  500. property Name: DOMString; // !!!: rw
  501. property NoResize: Boolean; // !!!: rw
  502. property Scrolling: DOMString; // !!!: rw
  503. property Src: DOMString; // !!!: rw
  504. property ContentDocument: TDOMDocument; // !!!: ro
  505. end;
  506. THTMLIFrameElement = class(THTMLElement)
  507. public
  508. property Align: DOMString; // !!!: rw
  509. property FrameBorder: DOMString; // !!!: rw
  510. property Height: DOMString; // !!!: rw
  511. property LongDesc: DOMString; // !!!: rw
  512. property MarginHeight: DOMString; // !!!: rw
  513. property MarginWidth: DOMString; // !!!: rw
  514. property Name: DOMString; // !!!: rw
  515. property Scrolling: DOMString; // !!!: rw
  516. property Src: DOMString; // !!!: rw
  517. property Width: DOMString; // !!!: rw
  518. property ContentDocument: TDOMDocument; // !!!: ro
  519. end;
  520. THTMLDocument = class(TXMLDocument)
  521. private
  522. function GetTitle: DOMString;
  523. procedure SetTitle(const Value: DOMString);
  524. public
  525. property Title: DOMString read GetTitle write SetTitle;
  526. property Referrer: DOMString; // !!!: ro
  527. property Domain: DOMString; // !!!: ro
  528. property URL: DOMString; // !!!: ro
  529. property Body: THTMLElement; // !!!: rw
  530. property Images: THTMLCollection; // !!!: ro
  531. property Applets: THTMLCollection; // !!!: ro
  532. property Links: THTMLCollection; // !!!: ro
  533. property Forms: THTMLCollection; // !!!: ro
  534. property Anchors: THTMLCollection; // !!!: ro
  535. property Cookie: DOMString; // !!!: rw
  536. procedure Open; virtual; abstract;
  537. procedure Close; virtual; abstract;
  538. procedure Write(const AText: DOMString);
  539. procedure WriteLn(const AText: DOMString);
  540. function GetElementsByName(const ElementName: DOMString): TDOMNodeList;
  541. // Helper functions (not in DOM standard):
  542. function CreateElement(const tagName: DOMString): THTMLElement;
  543. function CreateSubElement: THTMLElement;
  544. function CreateSupElement: THTMLElement;
  545. function CreateSpanElement: THTMLElement;
  546. function CreateBDOElement: THTMLElement;
  547. function CreateTTElement: THTMLElement;
  548. function CreateIElement: THTMLElement;
  549. function CreateBElement: THTMLElement;
  550. function CreateUElement: THTMLElement;
  551. function CreateSElement: THTMLElement;
  552. function CreateStrikeElement: THTMLElement;
  553. function CreateBigElement: THTMLElement;
  554. function CreateSmallElement: THTMLElement;
  555. function CreateEmElement: THTMLElement;
  556. function CreateStrongElement: THTMLElement;
  557. function CreateDfnElement: THTMLElement;
  558. function CreateCodeElement: THTMLElement;
  559. function CreateSampElement: THTMLElement;
  560. function CreateKbdElement: THTMLElement;
  561. function CreateVarElement: THTMLElement;
  562. function CreateCiteElement: THTMLElement;
  563. function CreateAcronymElement: THTMLElement;
  564. function CreateAbbrElement: THTMLElement;
  565. function CreateDDElement: THTMLElement;
  566. function CreateDTElement: THTMLElement;
  567. function CreateNoFramesElement: THTMLElement;
  568. function CreateNoScriptElement: THTMLElement;
  569. function CreateAddressElement: THTMLElement;
  570. function CreateCenterElement: THTMLElement;
  571. function CreateHtmlElement: THTMLHtmlElement;
  572. function CreateHeadElement: THTMLHeadElement;
  573. function CreateLinkElement: THTMLLinkElement;
  574. { function CreateTitleElement: THTMLTitleElement;
  575. function CreateMetaElement: THTMLMetaElement;
  576. function CreateBaseElement: THTMLBaseElement;
  577. function CreateIsIndexElement: THTMLIsIndexElement;
  578. function CreateStyleElement: THTMLStyleElement;}
  579. function CreateBodyElement: THTMLBodyElement;
  580. { function CreateFormElement: THTMLFormElement;
  581. function CreateSelectElement: THTMLSelectElement;
  582. function CreateOptGroupElement: THTMLOptGroupElement;
  583. function CreateOptionElement: THTMLOptionElement;
  584. function CreateInputElement: THTMLInputElement;
  585. function CreateTextAreaElement: THTMLTextAreaElement;
  586. function CreateButtonElement: THTMLButtonElement;
  587. function CreateLabelElement: THTMLLabelElement;
  588. function CreateFieldSetElement: THTMLFieldSetElement;
  589. function CreateLegendElement: THTMLLegendElement;}
  590. function CreateUListElement: THTMLUListElement;
  591. function CreateOListElement: THTMLOListElement;
  592. function CreateDListElement: THTMLDListElement;
  593. { function CreateDirectoryElement: THTMLDirectoryElement;
  594. function CreateMenuElement: THTMLMenuElement;}
  595. function CreateLIElement: THTMLLIElement;
  596. { function CreateDivElement: THTMLDivElement;}
  597. function CreateParagraphElement: THTMLParagraphElement;
  598. { function CreateHeadingElement: THTMLHeadingElement;
  599. function CreateQuoteElement: THTMLQuoteElement;
  600. function CreatePreElement: THTMLPreElement;
  601. function CreateBRElement: THTMLBreElement;
  602. function CreateBaseFontElement: THTMLBaseFontElement;
  603. function CreateFontElement: THTMFontLElement;
  604. function CreateHRElement: THTMLHREElement;
  605. function CreateModElement: THTMLModElement;
  606. function CreateAnchorElement: THTMLAnchorElement;
  607. function CreateImageElement: THTMLImageElement;
  608. function CreateObjectElement: THTMLObjectElement;
  609. function CreateParamElement: THTMLParamElement;
  610. function CreateAppletElement: THTMLAppletElement;
  611. function CreateMapElement: THTMLMapElement;
  612. function CreateAreaElement: THTMLAreaElement;
  613. function CreateScriptElement: THTMLScriptElement;
  614. function CreateTableElement: THTMLTableElement;
  615. function CreateTableCaptionElement: THTMLTableCaptionElement;
  616. function CreateTableColElement: THTMLTableColElement;
  617. function CreateTableSectionElement: THTMLTableSectionElement;
  618. function CreateTableRowElement: THTMLTableRowElement;
  619. function CreateTableCellElement: THTMLTableCellElement;
  620. function CreateFrameSetElement: THTMLFrameSetElement;
  621. function CreateFrameElement: THTMLFrameElement;
  622. function CreateIFrameElement: THTMLIFrameElement;}
  623. end;
  624. implementation
  625. function THTMLCollection.Item(Index: Cardinal): TDOMNode;
  626. begin
  627. Result := nil;
  628. end;
  629. function THTMLCollection.NamedItem(const Index: DOMString): TDOMNode;
  630. begin
  631. Result := nil;
  632. end;
  633. function THTMLOptionsCollection.Item(Index: Cardinal): TDOMNode;
  634. begin
  635. Result := nil;
  636. end;
  637. function THTMLOptionsCollection.NamedItem(const Index: DOMString): TDOMNode;
  638. begin
  639. Result := nil;
  640. end;
  641. constructor THTMLElement.Create(AOwner: THTMLDocument; const ATagName: DOMString);
  642. begin
  643. inherited Create(AOwner);
  644. FNodeName := ATagName;
  645. end;
  646. function THTMLElement.GetID: DOMString; begin Result := GetAttribute('id') end;
  647. procedure THTMLElement.SetID(const Value: DOMString); begin SetAttribute('id', Value) end;
  648. function THTMLElement.GetTitle: DOMString; begin Result := GetAttribute('title') end;
  649. procedure THTMLElement.SetTitle(const Value: DOMString); begin SetAttribute('title', Value) end;
  650. function THTMLElement.GetLang: DOMString; begin Result := GetAttribute('lang') end;
  651. procedure THTMLElement.SetLang(const Value: DOMString); begin SetAttribute('lang', Value) end;
  652. function THTMLElement.GetDir: DOMString; begin Result := GetAttribute('dir') end;
  653. procedure THTMLElement.SetDir(const Value: DOMString); begin SetAttribute('dir', Value) end;
  654. function THTMLElement.GetClassName: DOMString; begin Result := GetAttribute('class') end;
  655. procedure THTMLElement.SetClassName(const Value: DOMString); begin SetAttribute('class', Value) end;
  656. function THTMLHtmlElement.GetVersion: DOMString; begin Result := GetAttribute('version') end;
  657. procedure THTMLHtmlElement.SetVersion(const Value: DOMString); begin SetAttribute('version', Value) end;
  658. function THTMLHeadElement.GetProfile: DOMString; begin Result := GetAttribute('profile') end;
  659. procedure THTMLHeadElement.SetProfile(const Value: DOMString); begin SetAttribute('profile', Value) end;
  660. procedure THTMLSelectElement.Add(Element, Before: THTMLElement);
  661. begin
  662. end;
  663. procedure THTMLSelectElement.Remove(Index: Integer);
  664. begin
  665. end;
  666. function THTMLTableElement.CreateTHead: THTMLElement;
  667. begin
  668. Result := nil;
  669. end;
  670. procedure THTMLTableElement.DeleteTHead;
  671. begin
  672. end;
  673. function THTMLTableElement.CreateTFoot: THTMLElement;
  674. begin
  675. Result := nil;
  676. end;
  677. procedure THTMLTableElement.DeleteTFoot;
  678. begin
  679. end;
  680. function THTMLTableElement.CreateCaption: THTMLElement;
  681. begin
  682. Result := nil;
  683. end;
  684. procedure THTMLTableElement.DeleteCaption;
  685. begin
  686. end;
  687. function THTMLTableElement.InsertRow(Index: Integer): THTMLElement;
  688. begin
  689. Result := nil;
  690. end;
  691. procedure THTMLTableElement.DeleteRow(Index: Integer);
  692. begin
  693. end;
  694. function THTMLTableSectionElement.InsertRow(Index: Integer): THTMLElement;
  695. begin
  696. Result := nil;
  697. end;
  698. procedure THTMLTableSectionElement.DeleteRow(Index: Integer);
  699. begin
  700. end;
  701. function THTMLTableRowElement.InsertCell(Index: Integer): THTMLElement;
  702. begin
  703. Result := nil;
  704. end;
  705. procedure THTMLTableRowElement.DeleteCell(Index: Integer);
  706. begin
  707. end;
  708. function THTMLDocument.GetTitle: DOMString;
  709. var
  710. Node: TDOMNode;
  711. begin
  712. Result := '';
  713. if not Assigned(DocumentElement) then
  714. exit;
  715. Node := DocumentElement.FirstChild;
  716. while Assigned(Node) and (Node.NodeName <> 'head') do
  717. Node := Node.NextSibling;
  718. if not Assigned(Node) then
  719. exit;
  720. Node := Node.FirstChild;
  721. while Assigned(Node) and (Node.NodeName <> 'title') do
  722. Node := Node.NextSibling;
  723. if not Assigned(Node) then
  724. exit;
  725. Node := Node.FirstChild;
  726. if Assigned(Node) and (Node.NodeType = TEXT_NODE) then
  727. Result := Node.NodeValue;
  728. end;
  729. procedure THTMLDocument.SetTitle(const Value: DOMString);
  730. var
  731. Node: TDOMNode;
  732. TitleEl: TDOMElement;
  733. begin
  734. if not Assigned(DocumentElement) then
  735. AppendChild(CreateHtmlElement);
  736. Node := DocumentElement.FirstChild;
  737. while Assigned(Node) and (Node.NodeName <> 'head') do
  738. Node := Node.NextSibling;
  739. if not Assigned(Node) then
  740. begin
  741. Node := CreateHeadElement;
  742. DocumentElement.InsertBefore(Node, DocumentElement.FirstChild);
  743. end;
  744. TitleEl := TDOMElement(Node.FirstChild);
  745. while Assigned(TitleEl) and (TitleEl.NodeName <> 'title') do
  746. TitleEl := TDOMElement(TitleEl.NextSibling);
  747. if not Assigned(TitleEl) then
  748. begin
  749. TitleEl := CreateElement('title');
  750. Node.AppendChild(TitleEl);
  751. end;
  752. while Assigned(TitleEl.FirstChild) do
  753. TitleEl.RemoveChild(TitleEl.FirstChild);
  754. TitleEl.AppendChild(CreateTextNode(Value));
  755. end;
  756. procedure THTMLDocument.Write(const AText: DOMString);
  757. begin
  758. end;
  759. procedure THTMLDocument.WriteLn(const AText: DOMString);
  760. begin
  761. end;
  762. function THTMLDocument.GetElementsByName(const ElementName: DOMString): TDOMNodeList;
  763. begin
  764. Result := nil;
  765. end;
  766. function THTMLDocument.CreateElement(const tagName: DOMString): THTMLElement;
  767. begin
  768. Result := THTMLElement.Create(Self, tagName);
  769. end;
  770. function THTMLDocument.CreateSubElement: THTMLElement; begin Result := CreateElement('sub') end;
  771. function THTMLDocument.CreateSupElement: THTMLElement; begin Result := CreateElement('sup') end;
  772. function THTMLDocument.CreateSpanElement: THTMLElement; begin Result := CreateElement('span') end;
  773. function THTMLDocument.CreateBDOElement: THTMLElement; begin Result := CreateElement('bdo') end;
  774. function THTMLDocument.CreateTTElement: THTMLElement; begin Result := CreateElement('tt') end;
  775. function THTMLDocument.CreateIElement: THTMLElement; begin Result := CreateElement('i') end;
  776. function THTMLDocument.CreateBElement: THTMLElement; begin Result := CreateElement('b') end;
  777. function THTMLDocument.CreateUElement: THTMLElement; begin Result := CreateElement('u') end;
  778. function THTMLDocument.CreateSElement: THTMLElement; begin Result := CreateElement('s') end;
  779. function THTMLDocument.CreateStrikeElement: THTMLElement; begin Result := CreateElement('strike') end;
  780. function THTMLDocument.CreateBigElement: THTMLElement; begin Result := CreateElement('big') end;
  781. function THTMLDocument.CreateSmallElement: THTMLElement; begin Result := CreateElement('small') end;
  782. function THTMLDocument.CreateEmElement: THTMLElement; begin Result := CreateElement('em') end;
  783. function THTMLDocument.CreateStrongElement: THTMLElement; begin Result := CreateElement('strong') end;
  784. function THTMLDocument.CreateDfnElement: THTMLElement; begin Result := CreateElement('dfn') end;
  785. function THTMLDocument.CreateCodeElement: THTMLElement; begin Result := CreateElement('code') end;
  786. function THTMLDocument.CreateSampElement: THTMLElement; begin Result := CreateElement('samp') end;
  787. function THTMLDocument.CreateKbdElement: THTMLElement; begin Result := CreateElement('kbd') end;
  788. function THTMLDocument.CreateVarElement: THTMLElement; begin Result := CreateElement('var') end;
  789. function THTMLDocument.CreateCiteElement: THTMLElement; begin Result := CreateElement('cite') end;
  790. function THTMLDocument.CreateAcronymElement: THTMLElement; begin Result := CreateElement('acronym') end;
  791. function THTMLDocument.CreateAbbrElement: THTMLElement; begin Result := CreateElement('abbr') end;
  792. function THTMLDocument.CreateDDElement: THTMLElement; begin Result := CreateElement('dd') end;
  793. function THTMLDocument.CreateDTElement: THTMLElement; begin Result := CreateElement('dt') end;
  794. function THTMLDocument.CreateNoFramesElement: THTMLElement; begin Result := CreateElement('noframes') end;
  795. function THTMLDocument.CreateNoScriptElement: THTMLElement; begin Result := CreateElement('noscript') end;
  796. function THTMLDocument.CreateAddressElement: THTMLElement; begin Result := CreateElement('address') end;
  797. function THTMLDocument.CreateCenterElement: THTMLElement; begin Result := CreateElement('center') end;
  798. function THTMLDocument.CreateHtmlElement: THTMLHtmlElement; begin Result := THTMLHtmlElement.Create(Self, 'html') end;
  799. function THTMLDocument.CreateHeadElement: THTMLHeadElement; begin Result := THTMLHeadElement.Create(Self, 'head') end;
  800. function THTMLDocument.CreateLinkElement: THTMLLinkElement; begin Result := THTMLLinkElement.Create(Self, 'a') end;
  801. //...
  802. function THTMLDocument.CreateBodyElement: THTMLBodyElement; begin Result := THTMLBodyElement.Create(Self, 'body') end;
  803. //...
  804. function THTMLDocument.CreateUListElement: THTMLUListElement; begin Result := THTMLUListElement.Create(Self, 'ul') end;
  805. function THTMLDocument.CreateOListElement: THTMLOListElement; begin Result := THTMLOListElement.Create(Self, 'ol') end;
  806. function THTMLDocument.CreateDListElement: THTMLDListElement; begin Result := THTMLDListElement.Create(Self, 'dl') end;
  807. // ...
  808. function THTMLDocument.CreateLIElement: THTMLLIElement; begin Result := THTMLLIElement.Create(Self, 'li') end;
  809. //...
  810. function THTMLDocument.CreateParagraphElement: THTMLParagraphElement; begin Result := THTMLParagraphElement.Create(Self, 'p') end;
  811. end.
  812. {
  813. $Log$
  814. Revision 1.1 2002-12-11 21:06:07 sg
  815. * Small cleanups
  816. * Replaced htmldoc unit with dom_html unit
  817. * Added SAX parser framework and SAX HTML parser
  818. }