dom_html.pp 32 KB

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