web.pas 105 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650
  1. {
  2. This file is part of the Pas2JS run time library.
  3. Copyright (c) 2017 by Mattias Gaertner
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {$mode objfpc}
  11. {$modeswitch externalclass}
  12. unit Web;
  13. interface
  14. uses Types, JS;
  15. Type
  16. // Forward definitions
  17. TJSWindow = class;
  18. TJSDOMTokenList = class;
  19. TJSXPathResult = CLass;
  20. TJSNodeList = class;
  21. TJSDocument = class;
  22. TJSElement = class;
  23. TJSCSSStyleSheet = Class;
  24. TJSNodeFilter = Class;
  25. TJSIDBObjectStore = Class;
  26. TIDBDatabase = class;
  27. TJSIDBRequest = class;
  28. TJSIDBRequest = class;
  29. TJSEventTarget = class;
  30. TJSMouseEvent = Class;
  31. TJSWheelEvent = Class;
  32. TJSKeyBoardEvent = class;
  33. TJSPointerEvent = Class;
  34. TJSUIEvent = class;
  35. TJSTouchEvent = Class;
  36. TJSAttr = class external name 'Attr'
  37. Private
  38. fLocalName : String; external name 'localName';
  39. fNameSpaceURI : String external name 'namespaceURI';
  40. fPrefix : string; external name 'prefix';
  41. fName : string; external name 'name';
  42. public
  43. value : JSValue;
  44. property localName : String Read fLocalName;
  45. property namespaceURI : string Read fNameSpaceURI;
  46. property prefix : string read fPrefix;
  47. property name : string Read fName;
  48. end;
  49. { TEventListenerEvent }
  50. TEventListenerEvent = class external name 'EventListener_Event'
  51. private
  52. FTarget: TJSEventTarget; external name 'target';
  53. public
  54. Property target: TJSEventTarget Read FTarget;
  55. end;
  56. TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean;
  57. TJSEventTarget = class external name 'EventTarget'
  58. public
  59. procedure addEventListener(aname : string; aListener : TJSEventHandler);
  60. procedure addEventListener(aname : string; aListener : JSValue);
  61. function dispatchEvent(event : JSValue) : Boolean;
  62. procedure removeEventListener(aname : string; aListener : TJSEventHandler);
  63. procedure removeEventListener(aname : string; aListener : JSValue);
  64. end;
  65. TJSNode = class external name 'Node' (TJSEventTarget)
  66. Private
  67. FBaseURI : String; external name 'baseURI';
  68. FChildNodes: TJSNodeList; external name 'childNodes';
  69. FFirstChild : TJSNode; external name 'firstChild';
  70. FNextSibling : TJSNode; external name 'nextSibling';
  71. FNodeName : String; external name 'nodeName';
  72. FNodeType : NativeInt; external name 'nodeType';
  73. FOwnerDocument : TJSDocument; external name 'ownerDocument';
  74. FParentElement : TJSElement; external name 'parentElement';
  75. FParentNode : TJSNode; external name 'parentNode';
  76. FPreviousSibling : TJSNode; external name 'previousSibling';
  77. Public
  78. Const
  79. ELEMENT_NODE =1;
  80. TEXT_NODE =3;
  81. PROCESSING_INSTRUCTION_NODE = 7;
  82. COMMENT_NODE =8;
  83. DOCUMENT_NODE =9;
  84. DOCUMENT_TYPE_NODE = 10;
  85. DOCUMENT_FRAGMENT_NODE = 11;
  86. DOCUMENT_POSITION_DISCONNECTED = 1;
  87. DOCUMENT_POSITION_PRECEDING = 2;
  88. DOCUMENT_POSITION_FOLLOWING = 4;
  89. DOCUMENT_POSITION_CONTAINS = 8;
  90. DOCUMENT_POSITION_CONTAINED_BY = 16;
  91. DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
  92. Public
  93. nodeValue: string;
  94. innerText : string;
  95. textContent : string;
  96. function appendChild(aChild : TJSNode) : TJSNode;
  97. function cloneNode(deep: boolean): TJSNode;
  98. function compareDocumentPosition(aNode : TJSNode) : NativeInt;
  99. function contains(aNode : TJSNode) : boolean;
  100. function hasChildNodes : boolean;
  101. function insertBefore(newNode, referenceNode : TJSNode) : TJSNode;
  102. function isDefaultNameSpace(aNameSpaceURI : String) : Boolean;
  103. function isEqualNode(aNode : TJSNode) : boolean;
  104. function isSameNode(aNode : TJSNode) : boolean;
  105. function lookupNamespaceURI(aPrefix : string) : string;
  106. function lookupPrefix(aPrefix : string) : string;
  107. procedure normalize;
  108. function removeChild(aChild: TJSNode) : TJSNode;
  109. function replaceChild(aNewChild, aOldChild : TJSNode) : TJSNode;
  110. property baseURI : string read FBaseURI;
  111. property childNodes : TJSNodeList read FChildNodes;
  112. property firstChild : TJSNode Read FFirstChild;
  113. property nextSibling : TJSNode Read FNextSibling;
  114. property nodeName : String Read FNodeName;
  115. property nodeType : NativeInt Read FNodeType;
  116. property ownerDocument : TJSDocument read FOwnerDocument;
  117. property parentElement : TJSElement read FParentElement;
  118. property parentNode : TJSNode read FParentNode;
  119. property previousSibling : TJSNode Read FPreviousSibling;
  120. end;
  121. TJSNodeListCallBack = procedure (currentValue : TJSNode; currentIndex: NativeInt; list : TJSNodeList);
  122. TJSNodeListEvent = procedure (currentValue : TJSNode; currentIndex: NativeInt; list : TJSNodeList) of object;
  123. TJSNodeList = class external name 'NodeList'
  124. Private
  125. FLength : NativeInt; external name 'length';
  126. Public
  127. procedure forEach(const aCallBack : TJSNodeListCallBack);
  128. procedure forEach(const aCallBack : TJSNodeListEvent);
  129. function item(aIndex : NativeInt) : TJSNode;
  130. Property length : NativeInt Read FLength;
  131. Property Nodes [aIndex : NativeInt] : TJSNode Read item; default;
  132. end;
  133. TJSNamedNodeMap = class external name 'NamedNodeMap'
  134. Public
  135. function getNamedItem(aName : string) : TJSAttr;
  136. Property Attrs[aIndex : String] : TJSattr Read getNamedItem; default;
  137. end;
  138. TJSHTMLCollection = class external name 'HTMLCollection'
  139. Private
  140. FLength : NativeInt; external name 'length';
  141. public
  142. Function item(aIndex : Integer) : TJSNode;
  143. Function namedItem(aName : string) : TJSNode;
  144. property Items[aIndex : Integer] : TJSNode Read item; default;
  145. property NamedItems[aName : String] : TJSNode Read namedItem;
  146. Property length : NativeInt Read FLength;
  147. end;
  148. TJSDOMString = String;
  149. TDOMTokenlistCallBack = Procedure (Current : JSValue; currentIndex : NativeInt; list : TJSDOMTokenList);
  150. // Interface
  151. TJSDOMTokenList = class external name 'DOMTokenList'
  152. Private
  153. FLength : NativeInt; external name 'length';
  154. public
  155. Procedure add(aToken : TJSDOMString); varargs;
  156. Procedure remove(aToken : TJSDOMString); varargs;
  157. function item(aIndex : NativeInt) : String;
  158. function contains(aToken : TJSDOMString) : Boolean;
  159. Procedure replace(aOldToken, ANewToken : TJSDOMString);
  160. function supports(aToken : TJSDOMString) : Boolean;
  161. function toggle(aToken : TJSDOMString) : Boolean;
  162. // entries,keys, values
  163. procedure forEach(const callback: TDOMTokenlistCallBack);
  164. property length : NativeInt read FLength;
  165. end;
  166. TJSDOMRect = class external name 'DOMRect'
  167. public
  168. left,top,right,bottom,x,y,width,height : double;
  169. {$IFDEF FIREFOX}
  170. constructor New;
  171. {$ENDIF}
  172. end;
  173. TJSClientRect = record
  174. left,top,right,bottom : double;
  175. {$IFDEF FIREFOX}
  176. width, height: double;
  177. {$ENDIF}
  178. end;
  179. TJSClientRectArray = array of TJSClientRect;
  180. TJSElement = class external name 'Element' (TJSNode)
  181. Private
  182. FAttributes : TJSNamedNodeMap; external name 'attributes';
  183. FChildElementCount : NativeInt; external name 'childElementCount';
  184. FChildren : TJSHTMLCollection; external name 'children';
  185. FClassList : TJSDOMTokenList; external name 'classList';
  186. FCLientHeight : NativeInt; external name 'clientHeight';
  187. FCLientLeft : NativeInt; external name 'clientLeft';
  188. FCLientTop : NativeInt; external name 'clientTop';
  189. FCLientWidth : NativeInt; external name 'clientWidth';
  190. FFirstElementChild : TJSElement; external name 'firstElementChild';
  191. FLastElementChild : TJSElement; external name 'lastElementChild';
  192. FLocalName : string; external name 'localName';
  193. FNameSpaceURI : String; external name 'namespaceURI';
  194. FNextElementSibling : TJSElement; external name 'nextElementSibling';
  195. FPreviousElementSibling : TJSElement; external name 'previousElementSibling';
  196. FPrefix : String; external name 'prefix';
  197. FScrollHeight : NativeInt; external name 'scrollHeight';
  198. {$IFDEF FIREFOX}
  199. FScrollLeftMax : NativeInt; external name 'scrollLeftMax';
  200. FScrollTopMax : NativeInt; external name 'scrollTopMax';
  201. {$endif}
  202. FScrollWidth : NativeInt; external name 'scrollWidth';
  203. FTagName : string; external name 'tagName';
  204. Public
  205. name : string;
  206. className : string;
  207. id : string;
  208. innerHTML : String;
  209. outerHTML : string;
  210. scrollLeft : NativeInt;
  211. scrollTop : NativeInt;
  212. procedure append(aText : String); overload;
  213. procedure append(aNode : TJSElement); overload;
  214. procedure append(aText : String; aNode : TJSElement); varargs; overload;
  215. procedure append(aNode1,aNode2: TJSElement); varargs; overload;
  216. function getAttribute(aName : string) : string;
  217. function getAttributeNode(aName : string) : TJSAttr;
  218. function getAttributeNodeNS(aNameSpace, aName : string) : TJSAttr;
  219. function getAttributeNS(aNameSpace, aName : string) : string;
  220. function getBoundingClientRect : TJSDOMRect;
  221. function getClientRects : TJSClientRectArray;
  222. function getElementsByClassName(aClassName: string) : TJSHTMLCollection;
  223. function getElementsByTagNameNS(aNameSpace, aTagName : String): TJSHTMLCollection;
  224. function getElementsByTagName(aTagName : String): TJSHTMLCollection;
  225. function hasAttribute(aName : String) : Boolean;
  226. function hasAttributeNS(aNameSpace,aName : String) : Boolean;
  227. function hasAttributes : Boolean;
  228. function insertAdjacentElement(aPosition : string; aElement : TJSElement) : TJSElement;
  229. procedure insertAdjacentHTML(aPosition,aHTML : string);
  230. procedure insertAdjacentText(aPosition,aText : string);
  231. function matches(aSelectorString : String) : Boolean;
  232. function querySelector(aSelectors : String) : TJSElement;
  233. function querySelectorAll(aSelectors : String) : TJSNodeList;
  234. procedure releasePointerCapture(evID : JSValue);
  235. procedure removeAttribute(aName: string);
  236. procedure removeAttributeNS(aNameSpace,aName: string);
  237. function removeAttributeNode(aAttr : TJSAttr) : TJSAttr;
  238. procedure setAttribute(aName : string; AValue : String);
  239. function setAttributeNode(aNode: TJSAttr) : TJSAttr;
  240. function setAttributeNodeNS(aNode: TJSAttr) : TJSAttr;
  241. procedure setAttributeNS(aNameSpace,aName : string; AValue : String);
  242. procedure setCapture(retargetToElement : Boolean);
  243. procedure setPointerCapture(pointerID : JSValue);
  244. procedure requestFullScreen;
  245. Property attributes : TJSNamedNodeMap read FAttributes;
  246. Property childElementCount : NativeInt Read FChildElementCount;
  247. Property children : TJSHTMLCollection Read FChildren;
  248. Property classList : TJSDOMTokenList read FClassList;
  249. property clientHeight : NativeInt read FClientHeight;
  250. property clientLeft : NativeInt read FClientLeft;
  251. property clientTop : NativeInt read FClientTop;
  252. property clientWidth : NativeInt read FClientWidth;
  253. property firstElementChild : TJSElement Read FFirstElementChild;
  254. property lastElementChild : TJSElement Read FLastElementChild;
  255. property localName : string Read FLocalName;
  256. property namespaceURI : String read FNameSpaceURI;
  257. property nextElementSibling : TJSElement Read FNextElementSibling;
  258. property previousElementSibling : TJSElement Read FPreviousElementSibling;
  259. property prefix : String read FPrefix;
  260. property scrollHeight : NativeInt Read FScrollHeight;
  261. {$IFDEF FIREFOX}
  262. property scrollLeftMax : NativeInt Read FScrollLeftMax;
  263. property scrollTopMax : NativeInt Read FScrollTopMax;
  264. {$ENDIF}
  265. property scrollWidth : NativeInt Read FScrollWidth;
  266. property tagName : String read FTagName;
  267. Property Attrs[aName : string] : String read getAttribute write setAttribute; default;
  268. end;
  269. TJSElementCreationOptions = record
  270. named : string;
  271. end;
  272. TJSDocumentType = class external name 'DocumentType' (TJSNode)
  273. private
  274. FName : String; external name 'name';
  275. FPublicID : String; external name 'publicId';
  276. FSystemID : String; external name 'systemId';
  277. public
  278. property name : String read FName;
  279. property publicId : String Read FPublicID;
  280. property systemId : String read FSystemID;
  281. end;
  282. TJSDOMImplementation = class external name 'DocumentImplementation'
  283. Public
  284. function createDocument(aNamespaceURI, aQualifiedNameStr : String; aDocumentType : TJSDocumentType) : TJSDocument;
  285. function createDocumentType(aQualifiedNameStr,aPublicId,aSystemId : String) : TJSDocumentType;
  286. function createHTMLDocument(aTitle : String) : TJSDocument;
  287. end;
  288. TJSLocation = class external name 'Location'
  289. Private
  290. FOrigin : string;
  291. Public
  292. hash : string;
  293. host : string;
  294. hostname : string;
  295. href : string;
  296. password : string;
  297. pathname : string;
  298. port : string;
  299. protocol : string;
  300. search : string;
  301. username : string;
  302. procedure assign(aURL : String);
  303. procedure reload(aForce : Boolean);
  304. procedure replace(aURL : String);
  305. function toString : String;
  306. property origin : string read FOrigin;
  307. end;
  308. TJSStyleSheet = class external name 'StyleSheet' (TJSEventTarget)
  309. Private
  310. FHRef : String; external name 'href';
  311. FOwnerNode : TJSNode; external name 'ownerNode';
  312. FParentStyleSheet : TJSStyleSheet; external name 'parentStyleSheet';
  313. FTitle : String; external name 'title';
  314. FType : String; external name 'type';
  315. Public
  316. disabled : String;
  317. Property href : String read FHRef;
  318. property ownerNode : TJSNode Read FOwnerNode;
  319. property parentStyleSheet : TJSStyleSheet read FParentStyleSheet;
  320. property title : string Read FTitle;
  321. property _type : String read FType;
  322. end;
  323. TJSCSSRule = class external name 'CSSRule'
  324. Private
  325. FCSSText : String; external name 'cssText';
  326. FParentStyleSheet : TJSCSSStyleSheet; external name 'parentStyleSheet';
  327. FparentRule : TJSCSSRule; external name 'parentRule';
  328. Public
  329. property cssText : String Read FCSSText;
  330. property parentRule : TJSCSSRule read FparentRule;
  331. property parentStyleSheet : TJSCSSStyleSheet Read FParentStyleSheet;
  332. end;
  333. TJSCSSRuleList = Class external name 'CSSRuleList'
  334. Private
  335. FLength : NativeInt; external name 'length';
  336. Public
  337. function item(index : NativeInt) : TJSCSSRule;
  338. property length : NativeInt Read FLength;
  339. Property items[aIndex : NativeInt] : TJSCSSRule read item; default;
  340. end;
  341. TJSCSSStyleSheet = class external name 'CSSStyleSheet' (TJSStyleSheet)
  342. Private
  343. FCSSRules : TJSCSSRuleList; external name 'cssRules';
  344. Public
  345. procedure deleteRule(aIndex : NativeInt);
  346. function insertRule(aRule : String; aIndex : NativeInt) : NativeInt;
  347. Property cssRules : TJSCSSRuleList read FCSSRules;
  348. end;
  349. TJSStyleSheetList = Class external name 'StyleSheetList'
  350. Private
  351. FLength : NativeInt; external name 'length';
  352. Public
  353. function item(index : NativeInt) : TJSStyleSheet;
  354. property length : NativeInt Read FLength;
  355. Property items[aIndex : NativeInt] : TJSStyleSheet read item; default;
  356. end;
  357. { TJSDocumentFragment }
  358. TJSDocumentFragment = Class external name 'DocumentFragment' (TJSNode)
  359. private
  360. FchildElementCount: Integer; external name 'childElementCount';
  361. Fchildren: TJSHTMLCollection; external name 'children';
  362. FfirstElementChild: TJSElement; external name 'firstElementChild';
  363. FlastElementChild: TJSElement; external name 'lastElementChild';
  364. public
  365. constructor new;
  366. function querySelector(aSelector : String) : TJSElement;
  367. function querySelectorAll(aSelector : String) : TJSNodeList;
  368. property childElementCount : Integer read FchildElementCount;
  369. property children : TJSHTMLCollection read Fchildren;
  370. property firstElementChild : TJSElement read FfirstElementChild;
  371. property lastElementChild : TJSElement read FlastElementChild;
  372. end;
  373. TJSEventInit = record
  374. bubbles : boolean;
  375. cancelable : boolean;
  376. scoped : boolean;
  377. composed : boolean;
  378. end;
  379. TJSEvent = class external name 'Event'
  380. Private
  381. FBubbles : Boolean; external name 'bubbles';
  382. FCancelable : Boolean; external name 'cancelable';
  383. FComposed : Boolean; external name 'composed';
  384. FCurrentTarget : TJSElement; external name 'currentTarget';
  385. FdefaultPrevented : Boolean; external name 'defaultPrevented';
  386. FEventPhase : NativeInt; external name 'eventPhase';
  387. FTarget : TJSElement; external name 'target';
  388. FTimeStamp : NativeInt; external name 'timestamp';
  389. FType : String; external name 'type';
  390. FIsTrusted : Boolean; external name 'isTrusted';
  391. Public
  392. Const
  393. NONE = 0;
  394. CAPTURING_PHASE = 1;
  395. AT_TARGET = 2;
  396. BUBBLING_PHASE = 3;
  397. public
  398. cancelBubble : Boolean;
  399. constructor new (aType : String; const aInit : TJSEventInit); overload;
  400. procedure preventDefault;
  401. procedure stopImmediatePropagation;
  402. procedure stopPropagation;
  403. Property bubbles : Boolean Read FBubbles;
  404. Property cancelable : Boolean Read FCancelable;
  405. Property composed : Boolean Read FComposed;
  406. property currentTarget : TJSElement Read FCurrentTarget;
  407. property defaultPrevented : Boolean Read FdefaultPrevented;
  408. property eventPhase : NativeInt Read FEventPhase;
  409. property target : TJSElement Read FTarget;
  410. Property timestamp : NativeInt Read FTimeStamp;
  411. property _type : string read FType;
  412. property isTrusted : Boolean Read FIsTrusted;
  413. end;
  414. TJSXPathExpression = class external name 'XPathExpression'
  415. Public
  416. function evaluate(contextNode : TJSNode; aType : NativeInt; aResult : TJSXPathResult) : TJSXPathResult;
  417. function evaluateWithContext(contextNode : TJSNode; aPosition, aSize, aType : NativeInt; aResult : TJSXPathResult) : TJSXPathResult;
  418. end;
  419. TJSXPathNSResolver = class external name 'XPathNSResolver'
  420. Public
  421. function lookupNamespaceURI(prefix : string) : string;
  422. end;
  423. { TJSCharacterData }
  424. TJSCharacterData = class external name 'CharacterData' (TJSNode)
  425. private
  426. FnextElementSibling: TJSElement; external name 'nextElementSibling';
  427. FpreviousElementSibling: TJSElement; external name 'previousElementSibling';
  428. public
  429. property nextElementSibling : TJSElement read FnextElementSibling;
  430. property previousElementSibling : TJSElement read FpreviousElementSibling;
  431. end;
  432. TJSProcessingInstruction = class external name 'ProcessingInstruction' (TJSCharacterData);
  433. { TJSRange }
  434. TJSRange = class external name 'Range'
  435. private
  436. FCollapsed: boolean; external name 'collapsed';
  437. FcommonAncestorContainer: TJSNode; external name 'commonAncestorContainer';
  438. FendContainer: TJSNode; external name 'endContainer';
  439. FEndOffset: NativeInt; external name 'endOffset';
  440. FstartContainer: TJSNode; external name 'startContainer';
  441. FstartOffset: NativeInt; external name 'startOffset';
  442. Public
  443. const
  444. END_TO_END = 0;
  445. END_TO_START = 1;
  446. START_TO_END = 2;
  447. START_TO_START = 3;
  448. Public
  449. constructor new;
  450. function cloneContents : TJSDocumentFragment;
  451. function cloneRange : TJSRange;
  452. procedure collapse;
  453. function compareBoundaryPoints(aHow : NativeInt) : NativeInt;
  454. function createContextualFragment(aTagstring : String) : TJSDocumentFragment;
  455. procedure deleteContents;
  456. procedure detach;
  457. function extractContents : TJSDocumentFragment;
  458. procedure insertNode(aNode : TJSNode);
  459. procedure selectNode(aNode : TJSNode);
  460. procedure selectNodeContents(aNode : TJSNode);
  461. procedure setEnd(aEndNode : TJSNode; aEndOffset : NativeInt);
  462. procedure setEndAfter(aEndNode : TJSNode);
  463. procedure setEndBefore(aEndNode : TJSNode);
  464. procedure setStart(aStartNode : TJSNode; aStartOffset : NativeInt);
  465. procedure setStartAfter(aStartNode : TJSNode);
  466. procedure setStartBefore(aStartNode : TJSNode);
  467. procedure surroundContents(aNode : TJSNode);
  468. function toString : string;
  469. property collapsed : boolean read FCollapsed;
  470. property commonAncestorContainer : TJSNode read FcommonAncestorContainer ;
  471. property endContainer : TJSNode read FendContainer;
  472. property endOffset : NativeInt Read FEndOffset;
  473. property startContainer : TJSNode read FstartContainer;
  474. property startOffset : NativeInt Read FstartOffset;
  475. end;
  476. { TJSTreeWalker }
  477. TJSTreeWalker = class external name 'TreeWalker'
  478. private
  479. FCurrentNode: TJSNode; external name 'currentNode';
  480. FexpandEntityReference: Boolean; external name 'expandEntityReference';
  481. FFilter: TJSNodeFilter; external name 'filter';
  482. FRoot: TJSNode; external name 'root';
  483. FWhatToShow: NativeInt; external name 'whatToShow';
  484. Public
  485. function firstChild : TJSNode;
  486. function lastChild : TJSNode;
  487. function nextNode : TJSNode;
  488. function nextSibling : TJSNode;
  489. function parentNode : TJSNode;
  490. function previousNode : TJSNode;
  491. function previousSibling : TJSNode;
  492. property root : TJSNode read FRoot;
  493. property whatToShow : NativeInt read FWhatToShow;
  494. property filter : TJSNodeFilter Read FFilter;
  495. property expandEntityReference : Boolean Read FexpandEntityReference;
  496. property currentNode : TJSNode Read FCurrentNode;
  497. end;
  498. TJSNodeFilter = class external name 'NodeFilter'
  499. const
  500. SHOW_ALL = -1;
  501. SHOW_ATTRIBUTE = 2;
  502. SHOW_CDATA_SECTION = 8;
  503. SHOW_COMMENT = 128;
  504. SHOW_DOCUMENT = 256;
  505. SHOW_DOCUMENT_FRAGMENT = 1024;
  506. SHOW_DOCUMENT_TYPE = 512;
  507. SHOW_ELEMENT = 1;
  508. SHOW_ENTITY = 32;
  509. SHOW_ENTITY_REFERENCE = 16;
  510. SHOW_NOTATION = 2048;
  511. SHOW_PROCESSING_INSTRUCTION = 64;
  512. SHOW_TEXT = 4;
  513. function acceptNode (aNode : TJSNode) : NativeInt;
  514. end;
  515. TJSXPathResult = class external name 'XPathResult'
  516. private
  517. FBooleanValue : Boolean; external name 'booleanValue';
  518. FNumberValue : Double; external name 'numberValue';
  519. FResultType : NativeInt; external name 'resultType';
  520. FSingleNodeValue : TJSNode; external name 'singleNodeValue';
  521. FSnaphotLength : NativeInt; external name 'snapshotLength';
  522. FStringValue : String; external name 'stringValue';
  523. public
  524. Function iterateNext : TJSNode;
  525. Function snapshotItem(Index: NativeInt) : TJSNode;
  526. Property booleanValue : Boolean Read FBooleanValue;
  527. Property numberValue : Double Read FNumberValue;
  528. property resultType : NativeInt Read FResultType;
  529. Property singleNodeValue : TJSNode Read FSingleNodeValue;
  530. property snapshotLength : NativeInt read FSnaphotLength;
  531. property stringValue : String Read FStringValue;
  532. end;
  533. TJSSelection = class external name 'Selection'
  534. Private
  535. FanchorNode : TJSNode ; external name 'anchorNode';
  536. FanchorOffset : NativeInt ; external name 'anchorOffset';
  537. FfocusNode : TJSNode ; external name 'focusNode';
  538. FfocusOffset : NativeInt ; external name 'focusOffset';
  539. FisCollapsed : Boolean ; external name 'isCollapsed';
  540. FrangeCount : NativeInt ; external name 'rangeCount';
  541. Ftype : String ; external name 'type';
  542. Public
  543. function getRangeAt(aIndex : NativeInt) : TJSRange;
  544. procedure collapse(aParentNode : TJSNode; Offset : NativeInt);
  545. procedure extend(aParentNode : TJSNode; Offset : NativeInt);
  546. procedure collapseToStart;
  547. procedure collapseToEnd;
  548. procedure selectAllChildren(aParentNode : TJSNode);
  549. procedure addRange(aRange : TJSRange);
  550. procedure removeRange(aRange : TJSRange);
  551. procedure removeAllRanges;
  552. procedure deleteFromDocument;
  553. function containsNode(aNode : TJSNode; aPartlyContained : Boolean) : Boolean;
  554. procedure setBaseAndExtent(aAnchorNode : TJSNode; aAnchorOffset : NativeInt; aFocusNode : TJSNode; aFocusOffset : NativeInt);
  555. function toString : String;
  556. property anchorNode : TJSNode read FAnchorNode;
  557. property anchorOffset : NativeInt read FAnchorOffset;
  558. property focusNode : TJSNode read FFocusNode;
  559. property focusOffset : NativeInt read FFocusOffset;
  560. property isCollapsed : Boolean read FIsCollapsed;
  561. property rangeCount : NativeInt read FRangeCount;
  562. property _type : String Read FType;
  563. end;
  564. TJSNameSpaceMapperCallback = function (aNameSpace : string ) : String;
  565. TJSHTMLFile = class;
  566. TJSHTMLFileList = Class;
  567. { TJSDataTransferItem }
  568. TJSDataTransferItemCallBack = reference to Procedure(aData : String);
  569. TJSDataTransferItem = class external name 'DataTransferItem'
  570. private
  571. FKind: String; external name 'kind';
  572. FType: string; external name 'type';
  573. Public
  574. function getAsFile : TJSHTMLFile;
  575. Procedure getAsString(aCallBack : TJSDataTransferItemCallBack);
  576. property Kind : String read FKind;
  577. property _Type : string read FType;
  578. end;
  579. TJSDataTransferItemList = class external name 'DataTransferItemList'
  580. private
  581. FLength: NativeInt; external name 'length';
  582. function getitem(aIndex : nativeInt) : TJSDataTransferItem ; external name '[]';
  583. Public
  584. Function add(aData : string; AType: string) : TJSDataTransferItem; overload;
  585. Function add(aFile : TJSHTMLFile) : TJSDataTransferItem; overload;
  586. Procedure clear;
  587. procedure remove(aIndex : integer);
  588. property length : NativeInt read FLength;
  589. property Items[aIndex : NativeInt] : TJSDataTransferItem Read getitem; default;
  590. end;
  591. { TDataTransfer }
  592. TJSDataTransfer = class external name 'DataTransfer'
  593. private
  594. FFiles: TJSHTMLFileList; external name 'files';
  595. FItems: TJSDataTransferItemList; external name 'items';
  596. FTypes: TJSStringDynArray; external name 'types';
  597. Public
  598. dropEffect : string;
  599. effectAllowed : string;
  600. Procedure clearData; overload;
  601. Procedure clearData(aFormat : string); overload;
  602. function getData(aFormat : string) : String;
  603. procedure setData(aFormat : String; aData : String);
  604. procedure setDragImage(aImage: TJSElement; xOffset,yOffset : integer);
  605. property files : TJSHTMLFileList Read FFiles;
  606. property items : TJSDataTransferItemList read FItems;
  607. property types : TJSStringDynArray read FTypes;
  608. end;
  609. { TJSDragEvent }
  610. TJSDragEvent = class external name 'DragEvent' (TJSEvent)
  611. Private
  612. FDataTransfer: TJSDataTransfer; external name 'dataTransfer';
  613. FrelatedTarget : TJSEventTarget external name 'relatedTarget';
  614. FscreenX : NativeInt external name 'screenX';
  615. FscreenY : NativeInt external name 'screenY';
  616. FclientX : NativeInt external name 'clientX';
  617. FclientY : NativeInt external name 'clientY';
  618. Fbutton : NativeInt external name 'button';
  619. Fbuttons : NativeInt external name 'buttons';
  620. FctrlKey : Boolean external name 'ctrlKey';
  621. FshiftKey : Boolean external name 'shiftKey';
  622. FaltKey : Boolean external name 'altKey';
  623. FmetaKey : Boolean external name 'metaKey';
  624. Public
  625. Property relatedTarget : TJSEventTarget Read FRelatedTarget;
  626. Property screenX : NativeInt Read FScreenX;
  627. Property screenY : NativeInt Read FScreenY;
  628. Property clientX : NativeInt Read FClientX;
  629. Property clientY : NativeInt Read FClientY;
  630. Property button : NativeInt Read FButton;
  631. Property buttons : NativeInt Read FButtons;
  632. Property ctrlKey : Boolean Read FctrlKey;
  633. Property shiftKey : Boolean Read FshiftKey;
  634. Property altKey : Boolean Read FaltKey;
  635. Property metaKey : Boolean Read FmetaKey;
  636. property dataTransfer : TJSDataTransfer Read FDataTransfer;
  637. end;
  638. TJSDragDropEventHandler = reference to function(aEvent: TJSDragEvent) : Boolean;
  639. THTMLClickEventHandler = reference to function(aEvent : TJSMouseEvent) : boolean;
  640. { Various events }
  641. {$IFNDEF FIREFOX}
  642. TJSFocusEvent = TJSEvent;
  643. {$ELSE}
  644. TJSFocusEvent = Class(TJSEvent)
  645. private
  646. FrelatedTarget : TJSElement external name 'relatedTarget';
  647. public
  648. property relatedTarget : TJSElement Read FrelatedTarget;
  649. end;
  650. {$ENDIF}
  651. TJSAnimationEvent = Class(TJSEvent);
  652. TJSLoadEvent = Class(TJSEvent);
  653. TJSErrorEvent = class external name 'ErrorEvent' (TJSEvent)
  654. Private
  655. Fmessage : String external name 'message';
  656. Ffilename : string external name 'filename';
  657. Flineno : integer external name 'lineno';
  658. Fcolno : integer external name 'colno';
  659. Ferror : TJSObject external name 'error';
  660. Public
  661. Property message : String read FMessage;
  662. property filename : string Read FFileName;
  663. property lineno : integer read FLineNo;
  664. Property colno : integer read FColNo;
  665. Property error : TJSObject read FError;
  666. end;
  667. TJsPageTransitionEvent = class(TJSEvent)
  668. end;
  669. TJSHashChangeEvent = class external name 'HashChangeEvent' (TJSEvent)
  670. Private
  671. FnewURL : String external name 'newURL';
  672. FoldURL : String external name 'oldURL';
  673. public
  674. property newURL : String Read FNewURL;
  675. property oldURL : String Read FOldURL;
  676. end;
  677. TJSPopStateEvent = class external name 'PopStateEvent' (TJSEvent)
  678. Private
  679. FState : JSValue; external name 'state';
  680. Public
  681. property state : JSValue read FState;
  682. end;
  683. TJSStorageEvent = class external name 'StorageEvent' (TJSEvent)
  684. private
  685. Fkey : String external name 'key';
  686. FoldValue : String external name 'oldValue';
  687. FnewValue : String external name 'newValue';
  688. Furl : String external name 'url';
  689. FstorageArea : String external name 'storageArea';
  690. public
  691. Property key : String Read FKey;
  692. Property oldValue : String Read FOldValue;
  693. Property newValue : String Read FNewValue;
  694. Property url : String Read FURL;
  695. Property storageArea : String Read FstorageArea;
  696. end;
  697. { TJSProgressEvent }
  698. TJSProgressEvent = class external name 'ProgressEvent' (TJSEvent)
  699. Private
  700. FlengthComputable : Boolean external name 'lengthComputable';
  701. Floaded : NativeUINT external name 'loaded';
  702. FTotal : NativeUINT external name 'Total';
  703. Public
  704. property lengthComputable : Boolean Read FlengthComputable;
  705. property loaded : NativeUINT Read FLoaded;
  706. property Total : NativeUINT Read FTotal;
  707. end;
  708. TJSPageTransitionEventHandler = reference to function(aEvent : TJsPageTransitionEvent) : boolean;
  709. TJSHashChangeEventhandler = reference to function(aEvent : TJSHashChangeEvent) : boolean;
  710. TJSMouseWheelEventHandler = reference to function(aEvent : TJSWheelEvent) : boolean;
  711. TJSMouseEventHandler = reference to function(aEvent : TJSMouseEvent) : boolean;
  712. THTMLAnimationEventHandler = reference to function(aEvent : TJSAnimationEvent) : boolean;
  713. TJSErrorEventHandler = reference to function(aEvent : TJSErrorEvent) : boolean;
  714. TJSFocusEventHandler = reference to function(aEvent : TJSFocusEvent) : boolean;
  715. TJSKeyEventhandler = reference to function (aEvent : TJSKeyBoardEvent) : boolean;
  716. TJSLoadEventhandler = reference to function (aEvent : TJSLoadEvent) : boolean;
  717. TJSPointerEventHandler = reference to function(aEvent : TJSPointerEvent) : boolean;
  718. TJSUIEventHandler = reference to function(aEvent : TJSUIEvent) : Boolean;
  719. TJSPopStateEventHandler = reference to function(aEvent : TJSPopStateEvent) : Boolean;
  720. TJSStorageEventHandler = reference to function(aEvent : TJSStorageEvent) : Boolean;
  721. TJSProgressEventhandler = reference to function(aEvent : TJSProgressEvent) : Boolean;
  722. TJSTouchEventHandler = reference to function(aEvent : TJSTouchEvent) : boolean;
  723. TJSDocument = class external name 'Document' (TJSNode)
  724. Private
  725. fActiveElement : TJSElement; external name 'activeElement';
  726. FCharacterSet: String; external name 'characterSet';
  727. FChildElementCount: NativeInt; external name 'childElementCount';
  728. FCompatMode: String; external name 'compatMode';
  729. FCurrentScript: TJSElement; external name 'currentScript';
  730. FDefaultView: TJSWindow; external name 'defaultView';
  731. FDocType: TJSDocumentType; external name 'docrype';
  732. FDocumentElement: TJSElement; external name 'documentElement';
  733. FDocumentURI: String; external name 'documentURI';
  734. FEmbeds: TJSHTMLCollection; external name 'embeds';
  735. FFirstElementChild : TJSElement; external name 'firstElementChild';
  736. FForms: TJSHTMLCollection; external name 'forms';
  737. FFullScreenElement: TJSElement; external name 'fullscreenElement';
  738. FFullscreenEnabled: Boolean; external name 'fullscreenEnabled';
  739. FHead: TJSElement; external name 'head';
  740. FHidden: Boolean; external name 'hidden';
  741. FImages: TJSHTMLCollection; external name 'images';
  742. FImplementation: TJSDOMImplementation; external name 'implementation';
  743. FLastElementChild : TJSElement; external name 'lastElementChild';
  744. FLastModified: String; external name 'lastModified';
  745. FLastStyleSheetSet: String; external name 'lastStyleSheetSet';
  746. FLinks: TJSHTMLCollection; external name 'links';
  747. FLocation: TJSLocation; external name 'location';
  748. FLocationString: String; external name 'location';
  749. FPlugins: TJSHTMLCollection; external name 'plugins';
  750. FPointerLockElement: TJSElement; external name 'pointerLockElement';
  751. FPreferredStyleSheetSet: String; external name 'preferredStyleSheetSet';
  752. FReadyState: String; external name 'readyState';
  753. FReferrer: String; external name 'referrer';
  754. FScripts: TJSHTMLCollection; external name 'scripts';
  755. FStyleSheets: TJSStyleSheetList; external name 'styleSheets';
  756. FStyleSheetSets: TJSValueDynArray; external name 'styleSheetSets';
  757. FURL: String; external name 'URL';
  758. FVisibilityState: string; external name 'visibilityState';
  759. Public
  760. function adoptNode(aExternalNode : TJSNode) : TJSNode;
  761. procedure close;
  762. function createAttribute(aName : string) : TJSAttr;
  763. function createCDATASection(S : String) : TJSNode;
  764. function createComment(S : String) : TJSNode;
  765. function createDocumentFragment : TJSDocumentFragment;
  766. function createElement(tagName : string) : TJSElement; overload;
  767. function createElement(tagName : string; const options : TJSElementCreationOptions) : TJSElement; overload;
  768. function createElementNS(aNameSpace,tagName : string) : TJSElement; overload;
  769. function createElementNS(aNameSpace,tagName : string; const options : TJSElementCreationOptions) : TJSElement; overload;
  770. function createEvent(aType : string) : TJSEvent;
  771. function createExpression(xPathText : String; aNameSpaceMapper: TJSNameSpaceMapperCallback) : TJSXPathExpression;
  772. function createNSResolver(aNode : TJSNode) : TJSXPathNSResolver;
  773. function createProcessingInstruction(target, data : String) : TJSProcessingInstruction;
  774. function createRange : TJSRange;
  775. function createTextNode(S : String) : TJSNode;
  776. function createTreeWalker(root : TJSNode; whatToShow : NativeInt; filter : TJSNodeFilter) : TJSTreeWalker;
  777. function elementFromPoint(x,y : integer) : TJSElement;
  778. procedure enableStyleSheetsForSet(aSet : String);
  779. function evaluate(xpathExpression : String; ContextNode : TJSNode; NameSpaceResolver : TJSNamespaceMapperCallBack; resultType : NativeInt; aResult : TJSXPathResult) : TJSXPathResult;
  780. function execCommand(aCommandName : String; aShowDefaultUI : Boolean; AValueArgument : String) : boolean; overload;
  781. function execCommand(aCommandName : String; aShowDefaultUI : Boolean) : boolean; overload;
  782. Procedure exitFullScreen;
  783. function getElementById(aID : String) : TJSElement;
  784. function getElementsyClassName(aNames : string) : TJSHTMLCollection;
  785. function getElementsByName(aName : String) : TJSNodeList;
  786. function getElementsByTagName(aName : String) : TJSHTMLCollection;
  787. function getElementsByTagNameNS(aNameSpace,aName : String) : TJSHTMLCollection;
  788. function getSelection : TJSSelection;
  789. function hasFocus : boolean;
  790. function importNode(aExternalNode : TJSNode; Deep: boolean) : TJSNode;
  791. function querySelector(aSelectors : String) : TJSElement;
  792. function querySelectorAll(aSelectors : String) : TJSNodeList;
  793. procedure open;
  794. procedure releaseCapture;
  795. procedure write(aLine : string);
  796. procedure writeln(aLine : String);
  797. Public
  798. body : TJSElement;
  799. designMode : string;
  800. dir : string;
  801. domain : string;
  802. selectedStyleSheetSet : string;
  803. title : string;
  804. onabort : TJSEventHandler;
  805. onblur : TJSEventHandler;
  806. oncancel : TJSEventHandler;
  807. oncanplay : TJSEventHandler;
  808. oncanplaythrough : TJSEventHandler;
  809. onchange : TJSEventHandler;
  810. onclick: THTMLClickEventHandler;
  811. onclose : TJSEventHandler;
  812. oncontextmenu : TJSEventHandler;
  813. oncuechange : TJSEventHandler;
  814. ondblclick : THTMLClickEventHandler;
  815. ondrag : TJSDragDropEventHandler;
  816. ondragend : TJSDragDropEventHandler;
  817. ondragenter : TJSDragDropEventHandler;
  818. ondragexit : TJSDragDropEventHandler;
  819. ondragover : TJSDragDropEventHandler;
  820. ondragleave : TJSDragDropEventHandler;
  821. ondragstart: TJSDragDropEventHandler;
  822. ondrop : TJSDragDropEventHandler;
  823. ondurationchange : TJSEventHandler;
  824. onemptied : TJSEventHandler;
  825. onended : TJSEventHandler;
  826. onerror : TJSErrorEventHandler;
  827. onfocus : TJSFocusEventhandler;
  828. ongotpointercapture : TJSPointerEventHandler;
  829. oninput : TJSEventhandler;
  830. oninvalid : TJSEventhandler;
  831. onkeydown : TJSKeyEventhandler;
  832. onkeypress : TJSKeyEventhandler;
  833. onkeyup : TJSKeyEventhandler;
  834. onload : TJSEventhandler;
  835. onloadeddata : TJSEventhandler;
  836. onloadedmetadata : TJSEventhandler;
  837. onloadend : TJSProgressEventhandler;
  838. onloadstart : TJSProgressEventhandler;
  839. onlostpointercapture : TJSPointerEventHandler;
  840. onmessage : TJSEventHandler;
  841. onmousedown : TJSMouseEventHandler;
  842. onmouseenter : TJSMouseEventHandler;
  843. onmouseleave : TJSMouseEventHandler;
  844. onmousemove : TJSMouseEventHandler;
  845. onmouseout : TJSMouseEventHandler;
  846. onmouseover : TJSMouseEventHandler;
  847. onmouseup : TJSMouseEventHandler;
  848. onmousewheel : TJSMouseEventHandler;
  849. onpause : TJSEventHandler;
  850. onplay : TJSEventHandler;
  851. onplaying : TJSEventHandler;
  852. onpointercancel : TJSPointerEventHandler;
  853. onpointerdown : TJSPointerEventHandler;
  854. onpointerenter : TJSPointerEventHandler;
  855. onpointerleave : TJSPointerEventHandler;
  856. onpointermove : TJSPointerEventHandler;
  857. onpointerout : TJSPointerEventHandler;
  858. onpointerover : TJSPointerEventHandler;
  859. onpointerup : TJSPointerEventHandler;
  860. onpointerlockchange : TJSPointerEventHandler;
  861. onprogress : TJSProgressEventhandler;
  862. onreset : TJSUIEventHandler;
  863. onratechange : TJSEventHandler;
  864. onscroll : TJSUIEventHandler;
  865. onseekend : TJSEventHandler;
  866. onseeking : TJSEventHandler;
  867. onselect : TJSEventHandler;
  868. onselectionchange : TJSEventHandler;
  869. onsshow : TJSEventHandler;
  870. onsubmit : TJSEventHandler;
  871. onunload : TJSUIEventHandler;
  872. onwaiting : TJSEventHandler;
  873. touchstart : TJSTouchEventHandler;
  874. touchend : TJSTouchEventHandler;
  875. touchmove : TJSTouchEventHandler;
  876. touchcancel : TJSTouchEventHandler;
  877. Property activeElement : TJSElement Read FActiveElement;
  878. Property characterSet : String Read FCharacterSet;
  879. property childElementCount : NativeInt Read FChildElementCount;
  880. property compatMode : String Read FCompatMode;
  881. property currentScript : TJSElement Read FCurrentScript;
  882. property defaultView : TJSWindow Read FDefaultView;
  883. property doctype : TJSDocumentType read FDocType;
  884. property documentElement : TJSElement read FDocumentElement;
  885. property documentURI : String Read FDocumentURI;
  886. property embeds : TJSHTMLCollection Read FEmbeds;
  887. property firstElementChild : TJSElement Read FFirstElementChild;
  888. property lastElementChild : TJSElement Read FLastElementChild;
  889. property Forms : TJSHTMLCollection Read FForms;
  890. property fullscreenElement : TJSElement Read FFullScreenElement;
  891. property fullscreenEnabled : Boolean Read FFullscreenEnabled;
  892. property head : TJSElement read FHead;
  893. Property hidden : Boolean read FHidden;
  894. property images : TJSHTMLCollection Read FImages;
  895. property _implementation : TJSDOMImplementation Read FImplementation;
  896. property lastModified : String Read FLastModified;
  897. property lastStyleSheetSet : String read FLastStyleSheetSet;
  898. property links : TJSHTMLCollection Read FLinks;
  899. property location : TJSLocation read FLocation;
  900. Property LocationString : String Read FURL Write FLocationString; // On purpose
  901. property plugins : TJSHTMLCollection Read FPlugins;
  902. property pointerLockElement : TJSElement Read FPointerLockElement;
  903. property preferredStyleSheetSet : String Read FPreferredStyleSheetSet;
  904. Property readyState : String Read FReadyState;
  905. Property referrer : String Read FReferrer;
  906. property scripts : TJSHTMLCollection Read FScripts;
  907. property styleSheets : TJSStyleSheetList Read FStyleSheets;
  908. property styleSheetSets : TJSValueDynArray Read FStyleSheetSets; // No type documented ?
  909. Property URL : String Read FURL;
  910. property visibilityState : string read FVisibilityState;
  911. end;
  912. TJSConsole = class external name 'Console'
  913. Public
  914. procedure assert(anAssertion : string; Obj1 : JSValue); varargs;
  915. Procedure clear;
  916. procedure count; overload;
  917. procedure count(aCounter : String);
  918. procedure error(Obj1 : JSValue); varargs;
  919. procedure group;
  920. procedure groupCollapsed;
  921. procedure groupEnd;
  922. procedure info(Obj1 : JSValue); varargs;
  923. procedure log(Obj1 : JSValue); varargs;
  924. procedure table(args: array of JSValue);
  925. procedure time(aName : string);
  926. procedure timeEnd(aName : string);
  927. procedure trace;
  928. procedure warn(Obj1 : JSValue); varargs;
  929. end;
  930. TPromiseResolverFunc = Procedure (aValue : JSValue);
  931. TPromiseResolverMethod = Procedure (aValue : JSValue);
  932. TJSPromiseExecutorFunc = procedure (resolve,reject : TPromiseResolverFunc);
  933. TJSPromiseExecutorMethod = procedure (resolve,reject : TPromiseResolverFunc) of object;
  934. TJSPromise = class external name 'Promise'
  935. constructor new(Executor : TJSPromiseExecutorFunc);
  936. constructor new(Executor : TJSPromiseExecutorMethod);
  937. class function reject(reason : JSValue) : TJSPromise;
  938. class function resolve(value : JSValue): TJSPromise;
  939. function catch (onRejected : TPromiseResolverFunc) : TJSPromise;
  940. function catch (onRejected : TPromiseResolverMethod) : TJSPromise;
  941. function _then (onRejected : TPromiseResolverFunc) : TJSPromise;
  942. function _then (onRejected : TPromiseResolverMethod) : TJSPromise;
  943. end;
  944. { TJSCryptoKey }
  945. TJSCryptoKey = class external name 'CryptoKey'
  946. private
  947. FAlgorithm: JSValue; external name 'algorithm';
  948. FExtractable: Boolean; external name 'extractable';
  949. FType: string; external name 'type';
  950. FUsages: TStringDynArray; external name 'usages';
  951. Public
  952. property _type : string read FType;
  953. property extractable: Boolean read FExtractable;
  954. property algorithm : JSValue read FAlgorithm;
  955. property usages : TStringDynArray Read FUsages;
  956. end;
  957. { TJSSubtleCrypto }
  958. TJSBufferSource = class external name 'BufferSource' end;
  959. TJSTypedArray = class external name 'TypedArray' end;
  960. TJSSubtleCrypto = class external name 'SubtleCrypto'
  961. Public
  962. function decrypt(algorithm : JSValue; aKey : TJSCryptoKey; aData : TJSBufferSource) : TJSPromise;
  963. function deriveKey(algorithm : JSValue; aMasterKey : TJSCryptoKey; aDerivedAlgo : JSValue; extractable : Boolean; Usages : TStringDynArray) : TJSPromise;
  964. function digest(algorithm : string; Buffer : TJSArrayBuffer) : TJSPromise; overload;
  965. function digest(algorithm : string; Buffer : TJSTypedArray) : TJSPromise; overload;
  966. function encrypt(algorithm : JSValue; aKey : TJSCryptoKey; aData : TJSBufferSource) : TJSPromise;
  967. function exportKey(algorithm : String; AKey : TJSCryptoKey) : TJSPromise;
  968. function generateKey(algorithm : JSValue; extractable : Boolean; Usages : TStringDynArray) : TJSPromise;
  969. function importKey(format : String; KeyData : TJSArrayBuffer; algorithm : String; extractable : Boolean; Usages : TStringDynArray) : TJSPromise;
  970. function sign(algorithm : string; Key : TJSCryptoKey; aText : TJSArrayBuffer) : TJSPromise; overload;
  971. function unwrapKey(algorithm : string; wrappedKey : TJSArrayBuffer; Key: TJSCryptoKey;
  972. unwrapAlgo : string; unwrappedKeyAlgo : string;
  973. extractable : Boolean; Usages : TStringDynArray) : TJSPromise;
  974. function verify(algorithm : String; key : TJSCryptoKey; Signature : TJSArrayBuffer;
  975. textToVerify : TJSArrayBuffer): TJSPromise;
  976. function wrapKey(aFormat : string; Key,WrappingKey : TJSCryptoKey; WrapAlgorithm : String) : TJSPromise;
  977. end;
  978. { TJSCrypto }
  979. TJSCrypto = class external name 'Crypto'
  980. private
  981. FsubtleCrypto: TJSSubtleCrypto;
  982. Public
  983. procedure getRandomValues (anArray : TJSTypedArray);
  984. property subtleCrypto : TJSSubtleCrypto Read FsubtleCrypto;
  985. end;
  986. { TJSHistory }
  987. TJSHistory = class external name 'History'
  988. private
  989. FLength: NativeInt; external name 'length';
  990. {$IFDEF FIREFOX}
  991. FState : JSValue; external name 'state';
  992. {$ENDIF}
  993. Public
  994. procedure back;
  995. procedure forward;
  996. procedure go(aIndex : NativeInt);
  997. procedure go;
  998. procedure pushState(aState : jsValue; aTitle : String; AURL : String);
  999. procedure pushState(aState : jsValue; aTitle : String);
  1000. procedure replaceState(aState : jsValue; aTitle : String; AURL : String);
  1001. procedure replaceState(aState : jsValue; aTitle : String);
  1002. procedure replaceState(aState : jsValue);
  1003. {$IFDEF FIREFOX}
  1004. property state : JSValue read FState;
  1005. {$ENDIF}
  1006. property length: NativeInt read FLength;
  1007. end;
  1008. TJSIDBTransactionMode = class
  1009. const
  1010. readonly = 'readonly';
  1011. readwrite = 'readwrite';
  1012. versionchange = 'versionchange';
  1013. end;
  1014. { TJSIDBTransaction }
  1015. TJSIDBTransaction = class external name 'IDBTransaction' (TJSEventTarget)
  1016. private
  1017. FDB : TIDBDatabase; external name 'db';
  1018. FError: JSValue; external name 'error';
  1019. FMode: String; external name 'mode';
  1020. FObjectStoreNames: TStringDynArray; external name 'objectStoreNames';
  1021. public
  1022. procedure abort;
  1023. function objectStore(aName : String) : TJSIDBObjectStore;
  1024. property db : TIDBDatabase read FDB;
  1025. property mode : String read FMode;
  1026. property objectStoreNames : TStringDynArray read FObjectStoreNames;
  1027. property error : JSValue read FError;
  1028. end;
  1029. { TJSIDBKeyRange }
  1030. TJSIDBKeyRange = class external name 'IDBKeyRange'
  1031. private
  1032. FLower: JSValue;
  1033. FLowerOpen: Boolean;
  1034. FUpper: JSValue;
  1035. FUpperOpen: Boolean;
  1036. Public
  1037. Class Function bound(aLower,aUpper : JSValue) : TJSIDBKeyRange; overload;
  1038. Class Function bound(aLower,aUpper : JSValue; aLowerOpen : Boolean) : TJSIDBKeyRange; overload;
  1039. Class Function bound(aLower,aUpper : JSValue; aLowerOpen,aUpperOpen : Boolean) : TJSIDBKeyRange; overload;
  1040. Class Function lowerBound(aLower : JSValue) : TJSIDBKeyRange; overload;
  1041. Class Function lowerBound(aLower : JSValue; aOpen: Boolean) : TJSIDBKeyRange; overload;
  1042. Class Function only(aValue : JSValue) : TJSIDBKeyRange;
  1043. Class Function upperBound(aUpper : JSValue) : TJSIDBKeyRange; overload;
  1044. Class Function upperBound(aUpper : JSValue; aOpen: Boolean) : TJSIDBKeyRange; overload;
  1045. function includes (aValue : JSValue) : Boolean;
  1046. property lower : JSValue read FLower;
  1047. property lowerOpen : Boolean read FLowerOpen;
  1048. property upper : JSValue read FUpper;
  1049. property upperOpen : Boolean read FUpperOpen;
  1050. end;
  1051. TJSIDBIndexParameters = record
  1052. unique : boolean;
  1053. multiEntry : boolean;
  1054. locale : string;
  1055. end;
  1056. { TJSIDBIndex }
  1057. TJSIDBIndex = class external name 'IDBIndex'
  1058. private
  1059. FKeyPath: JSValue; external name 'keyPath';
  1060. FMultiEntry: Boolean; external name 'multiEntry';
  1061. FObjectStore: TJSIDBObjectStore; external name 'objectStore';
  1062. FUnique: boolean; external name 'unique';
  1063. public
  1064. name : string;
  1065. function count : TJSIDBRequest;
  1066. function get(aKey : jsValue) : TJSIDBRequest; overload;
  1067. function get(aKey : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1068. function getAll(aKey : jsValue) : TJSIDBRequest; overload;
  1069. function getAll(aKey : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1070. function getAll(aKey : jsValue; ACount : NativeInt) : TJSIDBRequest; overload;
  1071. function getAll(aKey : TJSIDBKeyRange; ACount : NativeInt) : TJSIDBRequest; overload;
  1072. function getAllKeys(aKey : jsValue) : TJSIDBRequest; overload;
  1073. function getAllKeys(aKey : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1074. function getAllKeys(aKey : jsValue; ACount : NativeInt) : TJSIDBRequest; overload;
  1075. function getAllKeys(aKey : TJSIDBKeyRange; ACount : NativeInt) : TJSIDBRequest; overload;
  1076. function getKey(aKey : jsValue) : TJSIDBRequest;
  1077. function openCursor : TJSIDBRequest; overload;
  1078. function openCursor(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1079. function openCursor(aKeyRange : TJSIDBKeyRange; ADirection : String) : TJSIDBRequest;overload;
  1080. function openKeyCursor : TJSIDBRequest;overload;
  1081. function openKeyCursor(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest;overload;
  1082. function openKeyCursor(aKeyRange : TJSIDBKeyRange; ADirection : String) : TJSIDBRequest;overload;
  1083. Property keyPath : JSValue Read FKeyPath;
  1084. property multiEntry : Boolean read FMultiEntry;
  1085. property objectStore : TJSIDBObjectStore read FObjectStore;
  1086. property unique : boolean read FUnique;
  1087. end;
  1088. TJSIDBCursorDirection = class external name 'IDBCursorDirection'
  1089. Const
  1090. next = 'next';
  1091. nextUnique = 'nextUnique';
  1092. prev = 'prev';
  1093. prevUnique = 'prevUnique';
  1094. end;
  1095. { TJSIDBCursor }
  1096. TJSIDBCursor = class external name 'IDBCursor'
  1097. private
  1098. FDirection: string; external name 'direction';
  1099. FKey: JSValue; external name 'key';
  1100. FPrimaryKey: JSValue; external name 'primaryKey';
  1101. FSource: JSValue; external name 'source';
  1102. FSourceAsIndex: TJSIDBIndex; external name 'source';
  1103. FSourceAsStore: TJSIDBObjectStore; external name 'source';
  1104. Public
  1105. procedure advance(aCount : NativeInt); overload;
  1106. procedure advance(aKey : JSValue); overload;
  1107. procedure continue(aKey : JSValue); overload;
  1108. procedure continue; overload;
  1109. procedure continuePrimaryKey(aKey : JSValue); overload;
  1110. procedure continuePrimaryKey(aKey,aPrimaryKey : JSValue); overload;
  1111. procedure delete;
  1112. procedure update(aValue : JSValue);
  1113. property source : JSValue read FSource;
  1114. property sourceAsStore : TJSIDBObjectStore read FSourceAsStore;
  1115. property sourceAsIndex : TJSIDBIndex read FSourceAsIndex;
  1116. property key : JSValue read FKey;
  1117. property primaryKey : JSValue read FPrimaryKey;
  1118. property direction : string read FDirection;
  1119. end;
  1120. TJSIDBObjectStore = class external name 'IDBObjectStore' (TJSEventTarget)
  1121. public
  1122. function add(aValue : JSValue; aKey : String) : TJSIDBRequest;
  1123. function add(aValue : JSValue) : TJSIDBRequest;
  1124. function clear : TJSIDBRequest;
  1125. function delete(aKey : string) : TJSIDBRequest;
  1126. function delete(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest;
  1127. function get(aKey : string) : TJSIDBRequest; overload;
  1128. function get(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1129. function getKey(aKey : string) : TJSIDBRequest; overload;
  1130. function getKey(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1131. function getAll : TJSIDBRequest; overload;
  1132. function getAll(aKey : String) : TJSIDBRequest; overload;
  1133. function getAll(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1134. function getAll(aKey : String; aCount: NativeInt) : TJSIDBRequest; overload;
  1135. function getAll(aKeyRange : TJSIDBKeyRange; aCount: NativeInt) : TJSIDBRequest; overload;
  1136. function getAllKeys(aKey : String) : TJSIDBRequest; overload;
  1137. function getAllKeys(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1138. function getAllKeys(aKey : String; aCount: NativeInt) : TJSIDBRequest; overload;
  1139. function getAllKeys(aKeyRange : TJSIDBKeyRange; aCount: NativeInt) : TJSIDBRequest; overload;
  1140. function createIndex (aIndexName : String; KeyPath : String) : TJSIDBIndex; overload;
  1141. function createIndex (aIndexName : String; KeyPath : String; Options : TJSIDBIndexParameters) : TJSIDBIndex; overload;
  1142. function createIndex (aIndexName : String; KeyPath : Array of String) : TJSIDBIndex; overload;
  1143. function createIndex (aIndexName : String; KeyPath : Array of String; Options : TJSIDBIndexParameters) : TJSIDBIndex; overload;
  1144. Procedure deleteIndex (aIndexName : String);
  1145. function index (aIndexName : String) : TJSIDBIndex;
  1146. function put(aValue : JSValue; aKey : String) : TJSIDBRequest; overload;
  1147. function put(aValue : JSValue) : TJSIDBRequest; overload;
  1148. function openCursor : TJSIDBRequest; overload;
  1149. function openCursor(aKey : String) : TJSIDBRequest; overload;
  1150. function openCursor(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1151. function openCursor(aKey : String; aDirection : string) : TJSIDBRequest; overload;
  1152. function openCursor(aKeyRange : TJSIDBKeyRange; aDirection : string) : TJSIDBRequest; overload;
  1153. function openKeyCursor : TJSIDBRequest; overload;
  1154. function openKeyCursor(aKey : String) : TJSIDBRequest; overload;
  1155. function openKeyCursor(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1156. function openKeyCursor(aKey : String; aDirection : string) : TJSIDBRequest; overload;
  1157. function openKeyCursor(aKeyRange : TJSIDBKeyRange; aDirection : string) : TJSIDBRequest; overload;
  1158. function count : TJSIDBRequest; overload;
  1159. function count(aKey : String) : TJSIDBRequest; overload;
  1160. function count(aKeyRange : TJSIDBKeyRange) : TJSIDBRequest; overload;
  1161. property Indexes [aIndexName : String] : TJSIDBIndex read index;
  1162. end;
  1163. { TJSIDBRequest }
  1164. TJSIDBRequest = class external name 'IDBRequest' (TJSEventTarget)
  1165. private
  1166. Ferror : JSValue; external name 'error'; // standards are not quite clear on this one
  1167. FReadyState: string; external name 'readyState';
  1168. FResult: JSValue; external name 'result';
  1169. FResultDatabase: TIDBDatabase; external name 'result';
  1170. FResultIndex: TJSIDBIndex; external name 'result';
  1171. FResultObjectStore : TJSIDBObjectStore; external name 'result';
  1172. FResultCursor : TJSIDBCursor; external name 'result';
  1173. FSourceDatabase: TIDBDatabase; external name 'source';
  1174. FSourceIndex: TJSIDBIndex; external name 'source';
  1175. FSourceObjectStore : TJSIDBObjectStore; external name 'source';
  1176. FSourceCursor : TJSIDBCursor; external name 'source';
  1177. FSource: JSValue; external name 'source';
  1178. FTransaction: TJSIDBTransaction; external name 'transaction';
  1179. Public
  1180. onerror : TJSEventHandler;
  1181. onsuccess : TJSEventHandler;
  1182. Property error : JSValue read FError;
  1183. property readyState : string read FReadyState;
  1184. property result : JSValue read FResult;
  1185. property resultAsObjectStore : TJSIDBObjectStore read FResultObjectStore;
  1186. property resultAsCursor : TJSIDBCursor read FResultCursor;
  1187. property resultAsIndex : TJSIDBIndex read FResultIndex;
  1188. property resultAsDatabase : TIDBDatabase read FResultDatabase;
  1189. property source : JSValue read FSource;
  1190. property sourceAsObjectStore : TJSIDBObjectStore read FSourceObjectStore;
  1191. property sourceAsCursor : TJSIDBCursor read FSourceCursor;
  1192. property sourceAsIndex : TJSIDBIndex read FSourceIndex;
  1193. property sourceAsDatabase : TIDBDatabase read FSourceDatabase;
  1194. property transaction : TJSIDBTransaction read FTransaction;
  1195. end;
  1196. TJSIDBOpenDBRequest = class external name 'IDBOpenDBRequest' (TJSIDBRequest)
  1197. Public
  1198. onblocked : TJSEventHandler;
  1199. onupgradeneeded : TJSEventHandler;
  1200. end;
  1201. TJSCreateObjectStoreOptions = record
  1202. keyPath : jsValue;
  1203. autoIncrement : boolean;
  1204. end;
  1205. { TIDBDatabase }
  1206. TIDBDatabase = class external name 'IDBDatabase' (TJSEventTarget)
  1207. private
  1208. FName: string; external name 'name';
  1209. FobjectStoreNames: TStringDynArray; external name 'objectStoreNames';
  1210. FVersion: integer; external name 'version';
  1211. public
  1212. procedure close;
  1213. function createObjectStore(aName : string) : TJSIDBObjectStore; overload;
  1214. function createObjectStore(aName : string; Options: TJSCreateObjectStoreOptions) : TJSIDBObjectStore; overload;
  1215. procedure deleteObjectStore(aName : string);
  1216. function transaction(aStoreNames : array of string) : TJSIDBTransaction; overload;
  1217. function transaction(aStoreNames : array of string; aMode : string) : TJSIDBTransaction; overload;
  1218. property name : string read FName;
  1219. property version : integer read FVersion;
  1220. property objectStoreNames : TStringDynArray read FobjectStoreNames;
  1221. end;
  1222. TJSIDBFactory = class external name 'IDBFactory' (TJSEventTarget)
  1223. public
  1224. function open(aName : string) : TJSIDBOpenDBRequest;
  1225. function open(aName : string; aVersion : Integer) : TJSIDBOpenDBRequest;
  1226. function deleteDatabase(aName : string) : TJSIDBOpenDBRequest;
  1227. function cmp (a,b : jsValue) : NativeInt;
  1228. end;
  1229. { TJSStorage }
  1230. TJSStorage = class external name 'Storage' (TJSEventTarget)
  1231. private
  1232. FLength: NativeInt; external name 'length';
  1233. public
  1234. function key(aIndex : Integer) : String;
  1235. function getItem(aKeyName : string) : string;
  1236. procedure setItem(aKeyName : string; aValue : string);
  1237. procedure removeItem(aKeyName : string);
  1238. procedure clear;
  1239. property Keys[AIndex : Integer] : String read key;
  1240. property Items[aKeyName: String] : String read getItem write setItem; default;
  1241. property length : NativeInt Read FLength;
  1242. end;
  1243. // Fake object, used for objects whose visible can be checked
  1244. TJSVisibleItem = class external name 'IVisible'
  1245. Private
  1246. FVisible : boolean; external name 'visible';
  1247. Public
  1248. Property visible : boolean read FVisible;
  1249. end;
  1250. TJSLocationBar = class external name 'LocationBar' (TJSVisibleItem);
  1251. TJSMenuBar = class external name 'MenuBar' (TJSVisibleItem);
  1252. TJSToolBar = class external name 'ToolBar' (TJSVisibleItem);
  1253. TJSPersonalBar = class external name 'PersonalBar' (TJSVisibleItem);
  1254. TJSScrollBars = class external name 'ScrollBars' (TJSVisibleItem);
  1255. TJSPositionError = record
  1256. code : integer;
  1257. message : string;
  1258. end;
  1259. TJSPositionOptions = record
  1260. enableHighAccuracy : boolean;
  1261. timeout : integer;
  1262. maximumAge : integer;
  1263. end;
  1264. TJSCoordinates = record
  1265. latitude : double;
  1266. longitude : double;
  1267. altitude : double;
  1268. accuracy : double;
  1269. altitudeAccuracy : double;
  1270. heading : double;
  1271. speed : double;
  1272. end;
  1273. TJSPosition = record
  1274. coords : TJSCoordinates;
  1275. timestamp : String;
  1276. end;
  1277. TJSGeoLocationCallback = procedure (aPosition : TJSPosition);
  1278. TJSGeoLocationEvent = procedure (aPosition : TJSPosition) of object;
  1279. TJSGeoLocationErrorCallback = procedure (aValue : TJSPositionError);
  1280. TJSGeoLocationErrorEvent = procedure (aValue : TJSPositionError) of object;
  1281. TJSGeoLocation = class external name 'GeoLocation'
  1282. Public
  1283. Procedure getCurrentPosition(ASuccess : TJSGeoLocationCallback); overload;
  1284. Procedure getCurrentPosition(ASuccess : TJSGeoLocationCallback;aError : TJSGeoLocationErrorCallback); overload;
  1285. Procedure getCurrentPosition(ASuccess : TJSGeoLocationCallback;aError : TJSGeoLocationErrorCallback; AOptions : TJSPositionOptions); overload;
  1286. Function watchPosition(ASuccess : TJSGeoLocationCallback) : NativeInt; overload;
  1287. Function watchPosition(ASuccess : TJSGeoLocationCallback;aError : TJSGeoLocationErrorCallback) : NativeInt; overload;
  1288. Function watchPosition(ASuccess : TJSGeoLocationCallback;aError : TJSGeoLocationErrorCallback; AOptions : TJSPositionOptions) : NativeInt; overload;
  1289. procedure clearWatch(AID : NativeInt);
  1290. end;
  1291. TJSMediaDevices = class external name 'MediaDevices' (TJSEventTarget)
  1292. end;
  1293. TJSWorker = class external name 'Worker' (TJSEventTarget)
  1294. public
  1295. constructor new(aURL : string);
  1296. procedure postMessage(aValue : JSValue);
  1297. procedure postMessage(aValue : JSValue; aList : TJSValueDynArray);
  1298. procedure terminate;
  1299. end;
  1300. TJSMessagePort = class external name 'MessagePort' (TJSEventTarget)
  1301. Public
  1302. procedure close;
  1303. procedure postMessage(aValue : JSValue);
  1304. procedure postMessage(aValue : JSValue; aList : TJSValueDynArray);
  1305. procedure start;
  1306. end;
  1307. { TJSSharedWorker }
  1308. TJSSharedWorker = class external name 'SharedWorker' (TJSEventTarget)
  1309. private
  1310. FPort: TJSMessagePort; external name 'port';
  1311. Public
  1312. constructor new(aURL : String); overload;
  1313. constructor new(aURL : String; aName : string); overload;
  1314. property port : TJSMessagePort Read FPort;
  1315. end;
  1316. { TJSServiceWorker }
  1317. TJSServiceWorker = class external name 'ServiceWorker' (TJSWorker)
  1318. private
  1319. FscriptURL: String; external name 'scriptURL';
  1320. FState: string; external name 'state';
  1321. Public
  1322. property state : string read FState;
  1323. property scriptURL : String Read FscriptURL;
  1324. end;
  1325. { TJSServiceWorkerRegistration }
  1326. TJSServiceWorkerRegistration = class external name 'ServiceWorkerRegistration'
  1327. private
  1328. FActive: TJSServiceWorker; external name 'active';
  1329. FInstalling: TJSServiceWorker; external name 'installing';
  1330. FScope: string; external name 'scope';
  1331. FWaiting: TJSServiceWorker; external name 'waiting';
  1332. public
  1333. function unregister : TJSPromise;
  1334. procedure update;
  1335. property active : TJSServiceWorker read FActive;
  1336. property scope : string read FScope;
  1337. property waiting : TJSServiceWorker read FWaiting;
  1338. property installing : TJSServiceWorker read FInstalling;
  1339. end;
  1340. TJSServiceWorkerContainerOptions = record
  1341. scope : string;
  1342. end;
  1343. { TJSServiceWorkerContainer }
  1344. TJSServiceWorkerContainer = class external name 'ServiceWorkerContainer'
  1345. private
  1346. FController: TJSServiceWorker; external name 'controller';
  1347. FReady: TJSPromise; external name 'ready';
  1348. Public
  1349. function register(aURL : String) : TJSPromise; overload;
  1350. function register(aURL : String; aOptions : TJSServiceWorkerContainerOptions) : TJSPromise; overload;
  1351. function getRegistration(aURL : String) : TJSPromise; overload;
  1352. function getRegistration : TJSPromise; overload;
  1353. function getRegistrations : TJSPromise;
  1354. property controller : TJSServiceWorker read FController;
  1355. property ready : TJSPromise read FReady;
  1356. end;
  1357. { TJSNavigator }
  1358. TJSNavigator = class external name 'Navigator'
  1359. {$IFDEF FIREFOX}
  1360. FbuildID : String ; external name 'buildID';
  1361. FOSCPU : String ; external name 'oscpu';
  1362. FproductSub : string; external name 'productSub';
  1363. FVendor : string; external name 'vendor';
  1364. {$ENDIF}
  1365. private
  1366. FCookieEnabled: Boolean; external name 'cookieEnabled';
  1367. FGeoLocation: TJSGeoLocation; external name 'geolocation';
  1368. FLanguage: String; external name 'language';
  1369. FMaxTouchPoints: NativeInt; external name 'maxTouchPoints';
  1370. FMediaDevices: TJSMediaDevices; external name 'mediaDevices';
  1371. FOnline: boolean; external name 'onLine';
  1372. FPlatform: string; external name 'platform';
  1373. FServiceWorker: TJSServiceWorkerContainer; external name 'serviceWorker';
  1374. FUserAgent: string; external name 'userAgent';
  1375. public
  1376. function getBattery : TJSPromise;
  1377. function requestMediaKeySystemAccess(aKeySystem : String; supportedConfigurations : TJSValueDynArray) : TJSPromise;
  1378. Procedure registerContentHandler(aMimeType,aURI,aTitle : string);
  1379. Procedure registerProtocolHandler(aProtocol,aURI,aTitle : string);
  1380. Procedure vibrate(aPattern : NativeInt);
  1381. Procedure vibrate(aPattern : Array of NativeInt);
  1382. {$IFDEF FIREFOX}
  1383. property buildID : String read FBuildID;
  1384. property oscpu : string read FOSCPU;
  1385. property productSub: string read FproductSub;
  1386. property vendor : string read Fvendor;
  1387. {$ENDIF}
  1388. property cookieEnabled : Boolean read FCookieEnabled;
  1389. property geoLocation : TJSGeoLocation Read FGeoLocation;
  1390. property language : String read FLanguage;
  1391. property maxTouchPoints : NativeInt read FMaxTouchPoints;
  1392. property mediaDevices : TJSMediaDevices read FMediaDevices;
  1393. property onLine : boolean read FOnline;
  1394. property platform : string read FPlatform;
  1395. property userAgent : string read FUserAgent;
  1396. property serviceWorker : TJSServiceWorkerContainer read FServiceWorker;
  1397. end;
  1398. { TJSTouchEvent }
  1399. TTouchCoord = longint;
  1400. TJSTouch = class external name 'Touch'
  1401. private
  1402. FClientX: TTouchCoord; external name 'clientX';
  1403. FClientY: TTouchCoord; external name 'clientY';
  1404. FIDentifier: longint; external name 'identifier';
  1405. FPageX: TTouchCoord; external name 'pageX';
  1406. FPageY: TTouchCoord; external name 'pageY';
  1407. FScreenX: TTouchCoord; external name 'screenX';
  1408. FScreenY: TTouchCoord; external name 'screenY';
  1409. FTarget: TJSElement; external name 'target';
  1410. Public
  1411. Property identifier : longint read FIDentifier;
  1412. Property ScreenX : TTouchCoord Read FScreenX;
  1413. Property ScreenY : TTouchCoord Read FScreenY;
  1414. Property ClientX : TTouchCoord Read FClientX;
  1415. Property ClientY : TTouchCoord Read FClientY;
  1416. Property PageX : TTouchCoord Read FPageX;
  1417. Property PageY : TTouchCoord Read FPageY;
  1418. Property Target : TJSElement Read FTarget;
  1419. end;
  1420. { TJSTouchList }
  1421. TJSTouchList = class external name 'TouchList'
  1422. private
  1423. FLength: NativeInt; external name 'length';
  1424. Public
  1425. function item (aIndex : Integer) : TJSTouch;
  1426. property length : NativeInt Read FLength;
  1427. Property Touches[AIndex : Integer] : TJSTouch Read item; default;
  1428. end;
  1429. TJSPerformance = class external name 'Performance' (TJSObject);
  1430. TJSScreen = class external name 'Screen' (TJSObject);
  1431. TJSURL = class external name 'URL' (TJSObject);
  1432. TJSCSSStyleDeclaration = class; // forward
  1433. TJSTimerCallBack = reference to procedure;
  1434. { TJSMediaQueryList }
  1435. TJSMediaQueryList = class external name 'MediaQueryList' (TJSObject)
  1436. private
  1437. FMatches: Boolean; external name 'matches';
  1438. FMedia: String; external name 'media';
  1439. Public
  1440. Property matches : Boolean Read FMatches;
  1441. Property media : String Read FMedia;
  1442. end;
  1443. { TJSWindow }
  1444. TJSWindowArray = Array of TJSWindow;
  1445. TJSWindow = class external name 'Window' (TJSObject)
  1446. Private
  1447. FClosed: boolean; external name 'closed';
  1448. FConsole : TJSConsole; external name 'console';
  1449. FCrypto: TJSCrypto; external name 'crypto';
  1450. FDevicePixelRatio: Double; external name 'devicePixelRatio';
  1451. FDocument: TJSDocument; external name 'document';
  1452. FFrameElement: TJSElement; external name 'frameElement';
  1453. FFrames: TJSWindowArray; external name 'frames';
  1454. FHistory: TJSHistory; external name 'history';
  1455. FIndexedDB: TJSIDBFactory; external name 'indexedDB';
  1456. FInnerheight: NativeInt; external name 'innerHeight';
  1457. FInnerWidth: NativeInt; external name 'innerWidth';
  1458. FLength: NativeInt; external name 'length';
  1459. FLocalStorage: TJSStorage; external name 'localStorage';
  1460. FLocation: TJSLocation; external name 'location';
  1461. FLocationBar: TJSLocationBar; external name 'locationbar';
  1462. FLocationString: string; external name 'location';
  1463. FMenuBar: TJSMenuBar; external name 'menubar';
  1464. FNavigator: TJSNavigator; external name 'navigator';
  1465. FOpener: TJSWindow; external name 'opener';
  1466. FOuterheight: NativeInt; external name 'outerHeight';
  1467. FOuterWidth: NativeInt; external name 'outerWidth';
  1468. FParent: TJSWindow; external name 'parent';
  1469. FPerformance: TJSPerformance; external name 'Performance';
  1470. FPersonalBar: TJSPersonalBar; external name 'personalbar';
  1471. FScreen: TJSScreen; external name 'screen';
  1472. FScreenX: NativeInt; external name 'screenX';
  1473. FScreenY: NativeInt; external name 'screenY';
  1474. FScrollbar: TJSScrollBars; external name 'scrollbar';
  1475. FScrollX: NativeInt; external name 'scrollX';
  1476. FScrollY: NativeInt; external name 'scrollY';
  1477. FSelf: TJSWindow; external name 'self';
  1478. FSessionStorage: TJSStorage; external name 'sessionStorage';
  1479. FToolBar: TJSToolBar; external name 'toolbar';
  1480. FTop: TJSWindow; external name 'top';
  1481. FURL: TJSURL; external name 'URL';
  1482. Public
  1483. fullSreen : Boolean;
  1484. name : string;
  1485. status : string;
  1486. onabort : TJSEventHandler;
  1487. onafterprint : TJSEventHandler;
  1488. onbeforeprint : TJSEventHandler;
  1489. onbeforeinstallprompt : TJSEventHandler;
  1490. onbeforeunloadprompt : TJSEventHandler;
  1491. onblur : TJSEventHandler;
  1492. onchange : TJSEventHandler;
  1493. onclick: THTMLClickEventHandler;
  1494. onclose : TJSEventHandler;
  1495. oncontextmenu : TJSEventHandler;
  1496. ondblclick : THTMLClickEventHandler;
  1497. onerror : TJSErrorEventHandler;
  1498. onfocus : TJSFocusEventhandler;
  1499. onhashchange : TJSHashChangeEventhandler;
  1500. oninput : TJSEventhandler;
  1501. onkeydown : TJSKeyEventhandler;
  1502. onkeypress : TJSKeyEventhandler;
  1503. onkeyup : TJSKeyEventhandler;
  1504. onlanguagechange : TJSEventhandler;
  1505. onload : TJSEventhandler;
  1506. onloadend : TJSLoadEventhandler;
  1507. onloadstart : TJSLoadEventhandler;
  1508. onmessage : TJSEventHandler;
  1509. onmousedown : TJSMouseEventHandler;
  1510. onmouseenter : TJSMouseEventHandler;
  1511. onmouseleave : TJSMouseEventHandler;
  1512. onmousemove : TJSMouseEventHandler;
  1513. onmouseout : TJSMouseEventHandler;
  1514. onmouseover : TJSMouseEventHandler;
  1515. onmouseup : TJSMouseEventHandler;
  1516. onmousewheel : TJSMouseEventHandler;
  1517. onoffline : TJSEventHandler;
  1518. ononline : TJSEventHandler;
  1519. onpagehide : TJSPageTransitionEventHandler;
  1520. onpageshow : TJSPageTransitionEventHandler;
  1521. onpaint : TJSEventHandler;
  1522. onpointercancel : TJSPointerEventHandler;
  1523. onpointerdown : TJSPointerEventHandler;
  1524. onpointerenter : TJSPointerEventHandler;
  1525. onpointerleave : TJSPointerEventHandler;
  1526. onpointermove : TJSPointerEventHandler;
  1527. onpointerout : TJSPointerEventHandler;
  1528. onpointerover : TJSPointerEventHandler;
  1529. onpointerup : TJSPointerEventHandler;
  1530. onpointerlockchange : TJSPointerEventHandler;
  1531. onprogress : TJSProgressEventhandler;
  1532. onpopstate : TJSPopStateEventHandler;
  1533. onreset : TJSUIEventHandler;
  1534. onscroll : TJSUIEventHandler;
  1535. onselect : TJSEventHandler;
  1536. onselectionchange : TJSEventHandler;
  1537. onstorage : TJSStorageEventHandler;
  1538. onsubmit : TJSEventHandler;
  1539. onunload : TJSUIEventHandler;
  1540. touchstart : TJSTouchEventHandler;
  1541. touchend : TJSTouchEventHandler;
  1542. touchmove : TJSTouchEventHandler;
  1543. touchcancel : TJSTouchEventHandler;
  1544. Procedure alert(Const Msg : String);
  1545. Function atob(Const aValue : string) : string;
  1546. procedure blur;
  1547. Procedure clearInterval(aID: NativeInt);
  1548. Procedure clearTimeout(aID: NativeInt);
  1549. Function btoa(Const aValue : string) : string;
  1550. Procedure close;
  1551. Function confirm(Const aMsg : String) : boolean;
  1552. procedure focus;
  1553. Function getComputedStyle(aElement : TJSElement) : TJSCSSStyleDeclaration; overload;
  1554. Function getComputedStyle(aElement,aPseudoElement : TJSElement) : TJSCSSStyleDeclaration; overload;
  1555. function matchMedia(aQuery : String) : TJSMediaQueryList;
  1556. procedure moveBy(x,y : NativeInt);
  1557. procedure moveTo(x,y : NativeInt);
  1558. function open : TJSWindow;
  1559. function open(Const aURL : String) : TJSWindow; overload;
  1560. function open(Const aURL,aTarget : String) : TJSWindow; overload;
  1561. function open(Const aURL,aTarget : String; AOptions : TJSObject) : TJSWindow; overload;
  1562. procedure print;
  1563. function prompt(const aMessage : String) : String; overload;
  1564. function prompt(const aMessage,aDefault : String) : String; overload;
  1565. procedure resizeBy(aWidth,aHeight : NativeInt);
  1566. procedure resizeTo(aWidth,aHeight : NativeInt);
  1567. procedure scrollBy(x,y : NativeInt);
  1568. procedure scrollTo(x,y : NativeInt);
  1569. Function setInterval(ahandler : TJSTimerCallBack; aInterval : NativeUInt) : NativeInt; varargs;
  1570. Function setTimeout(ahandler : TJSTimerCallBack; aTimeout : NativeUInt) : NativeInt; varargs;
  1571. procedure stop;
  1572. property console : TJSConsole Read FConsole;
  1573. property closed : boolean read FClosed;
  1574. property crypto : TJSCrypto Read FCrypto;
  1575. property devicePixelRatio : Double read FDevicePixelRatio;
  1576. property document : TJSDocument read FDocument;
  1577. property frameElement : TJSElement Read FFrameElement;
  1578. Property frames : TJSWindowArray read FFrames;
  1579. Property history : TJSHistory read FHistory;
  1580. Property indexedDB : TJSIDBFactory read FIndexedDB;
  1581. Property innerHeight : NativeInt Read FInnerheight;
  1582. Property innerWidth : NativeInt Read FInnerWidth;
  1583. Property length : NativeInt Read FLength;
  1584. Property localStorage : TJSStorage Read FLocalStorage;
  1585. property location : TJSLocation Read FLocation;
  1586. Property locationString : String read FLocationString write FLocationString;
  1587. property locationbar : TJSLocationBar Read FLocationBar;
  1588. property menubar : TJSMenuBar Read FMenuBar;
  1589. property navigator : TJSNavigator Read FNavigator;
  1590. property opener : TJSWindow read FOpener;
  1591. Property outerHeight : NativeInt Read FOuterheight;
  1592. Property outerWidth : NativeInt Read FOuterWidth;
  1593. Property parent : TJSWindow Read FParent;
  1594. Property Performance : TJSPerformance Read FPerformance;
  1595. property personalbar : TJSPersonalBar Read FPersonalBar;
  1596. property screen : TJSScreen read FScreen;
  1597. property screenX : NativeInt read FScreenX;
  1598. Property screenY : NativeInt read FScreenY;
  1599. Property scrollbar : TJSScrollBars Read FScrollbar;
  1600. property scrollX : NativeInt read FScrollX;
  1601. Property scrollY : NativeInt read FScrollY;
  1602. Property _Self : TJSWindow read FSelf;
  1603. Property sessionStorage : TJSStorage Read FSessionStorage;
  1604. property toolbar : TJSToolBar Read FToolBar;
  1605. property top : TJSWindow Read FTop;
  1606. property URL : TJSURL Read FURL;
  1607. end;
  1608. { TJSCSSStyleDeclaration }
  1609. TJSCSSStyleDeclaration = class external name 'CSSStyleDeclaration'
  1610. private
  1611. FLength: NativeInt; external name 'length';
  1612. FParentRule: TJSCSSRule; external name 'parentRule';
  1613. public
  1614. cssText : string;
  1615. function item(aIndex : Integer) : string;
  1616. function removeProperty(const aProperty : String) : string;
  1617. function getPropertyPriority(const aProperty : String) : string;
  1618. function getPropertyValue(const aProperty : String) : string;
  1619. procedure setProperty(const aProperty,aValue : String);overload;
  1620. procedure setProperty(const aProperty,aValue,aPriority : string); overload;
  1621. property length : NativeInt read FLength;
  1622. property parentRule : TJSCSSRule read FParentRule;
  1623. end;
  1624. { TJSHTMLElement }
  1625. TJSHTMLElement = class external name 'HTMLELement' (TJSElement)
  1626. private
  1627. FDataset: TJSObject ; external name 'dataset';
  1628. FIsContentEditable: Boolean ; external name 'isContentEditable';
  1629. FOffsetHeight: Double; external name 'offsetHeight';
  1630. FOffsetLeft: Double; external name 'offsetLeft';
  1631. FOffsetParent: TJSElement; external name 'offsetParent';
  1632. FOffsetTop: Double; external name 'offsetTop';
  1633. FOffsetWidth: Double; external name 'offsetWidth';
  1634. Public
  1635. accessKey : string;
  1636. contentEditable : string;
  1637. dir : string;
  1638. draggable : boolean;
  1639. hidden : boolean;
  1640. lang : string;
  1641. spellcheck : boolean;
  1642. style : TJSCSSStyleDeclaration;
  1643. tabIndex : Integer;
  1644. title: string;
  1645. onabort : TJSEventHandler;
  1646. onanimationcancel: THTMLAnimationEventHandler;
  1647. onanimationend: THTMLAnimationEventHandler;
  1648. onblur : TJSEventHandler;
  1649. oncancel : TJSEventHandler;
  1650. oncanplay : TJSEventHandler;
  1651. oncanplaythrough : TJSEventHandler;
  1652. onchange : TJSEventHandler;
  1653. onclick: THTMLClickEventHandler;
  1654. onclose : TJSEventHandler;
  1655. oncontextmenu : TJSEventHandler;
  1656. ondblclick : THTMLClickEventHandler;
  1657. ondrag : TJSDragDropEventHandler;
  1658. ondragend : TJSDragDropEventHandler;
  1659. ondragenter : TJSDragDropEventHandler;
  1660. ondragexit : TJSDragDropEventHandler;
  1661. ondragover : TJSDragDropEventHandler;
  1662. ondragleave : TJSDragDropEventHandler;
  1663. ondragstart: TJSDragDropEventHandler;
  1664. ondrop : TJSDragDropEventHandler;
  1665. onerror : TJSErrorEventHandler;
  1666. onfocus : TJSFocusEventhandler;
  1667. ondurationchange : TJSEventHandler;
  1668. onemptied : TJSEventHandler;
  1669. onended : TJSEventHandler;
  1670. ongotpointercapture : TJSPointerEventHandler;
  1671. oninput : TJSEventhandler;
  1672. oninvalid : TJSEventhandler;
  1673. onkeydown : TJSKeyEventhandler;
  1674. onkeypress : TJSKeyEventhandler;
  1675. onkeyup : TJSKeyEventhandler;
  1676. onload : TJSEventhandler;
  1677. onloadeddata : TJSEventhandler;
  1678. onloadedmetadata : TJSEventhandler;
  1679. onloadend : TJSLoadEventhandler;
  1680. onloadstart : TJSLoadEventhandler;
  1681. onlostpointercapture : TJSPointerEventHandler;
  1682. onmousedown : TJSMouseEventHandler;
  1683. onmouseenter : TJSMouseEventHandler;
  1684. onmouseleave : TJSMouseEventHandler;
  1685. onmousemove : TJSMouseEventHandler;
  1686. onmouseout : TJSMouseEventHandler;
  1687. onmouseover : TJSMouseEventHandler;
  1688. onmouseup : TJSMouseEventHandler;
  1689. onmousewheel : TJSMouseEventHandler;
  1690. onpause : TJSPointerEventHandler;
  1691. onplay : TJSPointerEventHandler;
  1692. onplaying : TJSPointerEventHandler;
  1693. onpointercancel : TJSPointerEventHandler;
  1694. onpointerdown : TJSPointerEventHandler;
  1695. onpointerenter : TJSPointerEventHandler;
  1696. onpointerleave : TJSPointerEventHandler;
  1697. onpointermove : TJSPointerEventHandler;
  1698. onpointerout : TJSPointerEventHandler;
  1699. onpointerover : TJSPointerEventHandler;
  1700. onpointerup : TJSPointerEventHandler;
  1701. onpointerlockchange : TJSPointerEventHandler;
  1702. onprogress : TJSProgressEventhandler;
  1703. onseeked : TJSEventHandler;
  1704. onseeking : TJSEventHandler;
  1705. onreset : TJSUIEventHandler;
  1706. onscroll : TJSUIEventHandler;
  1707. onselect : TJSEventHandler;
  1708. onselectstart : TJSEventHandler;
  1709. onselectionchange : TJSEventHandler;
  1710. onshow : TJSEventHandler;
  1711. onstalled : TJSEventHandler;
  1712. ontimeupdate : TJSEventHandler;
  1713. ontransitioncancel : TJSEventHandler;
  1714. ontransitionend : TJSEventHandler;
  1715. onvolumechange : TJSEventHandler;
  1716. onsubmit : TJSEventHandler;
  1717. onwheel : TJSMouseWheelEventHandler;
  1718. onwaiting : TJSEventHandler;
  1719. touchstart : TJSTouchEventHandler;
  1720. touchend : TJSTouchEventHandler;
  1721. touchmove : TJSTouchEventHandler;
  1722. touchcancel : TJSTouchEventHandler;
  1723. Procedure blur;
  1724. Procedure focus;
  1725. Procedure click;
  1726. property dataset : TJSObject read FDataset;
  1727. property isContentEditable : Boolean read FIsContentEditable;
  1728. property offsetHeight : Double Read FOffsetHeight;
  1729. property offsetLeft : Double Read FOffsetLeft;
  1730. property offsetTop : Double Read FOffsetTop;
  1731. property offsetWidth : Double Read FOffsetWidth;
  1732. property offsetParent : TJSElement Read FOffsetParent;
  1733. end;
  1734. TJSHTMLFormControlsCollection = class external name 'HTMLFormControlsCollection' (TJSHTMLCollection)
  1735. Public
  1736. function namedItem(S : String) : TJSElement; reintroduce; external name 'namedItem';
  1737. property Items[S : String] : TJSElement read namedItem; default;
  1738. end;
  1739. { TJSHTMLFormElement }
  1740. TJSHTMLFormElement = class external name 'HTMLFormElement' (TJSHTMLElement)
  1741. private
  1742. FElements: TJSHTMLFormControlsCollection; external name 'elements';
  1743. FLength: NativeInt; external name 'length';
  1744. Public
  1745. method : string;
  1746. target : string;
  1747. action : string;
  1748. encoding : string;
  1749. enctype : string;
  1750. acceptCharset : string;
  1751. autocomplete : string;
  1752. noValidate : boolean;
  1753. property elements : TJSHTMLFormControlsCollection read FElements;
  1754. Property length : NativeInt Read FLength;
  1755. end;
  1756. { TJSValidityState }
  1757. TJSValidityState = class external name 'ValidityState'
  1758. private
  1759. FBadInput: Boolean; external name 'badInput';
  1760. FCustomError: Boolean; external name 'customError';
  1761. FPatternMismatch: Boolean; external name 'patternMisMatch';
  1762. FRangeOverflow: Boolean; external name 'rangeOverflow';
  1763. FRangeUnderflow: Boolean; external name 'rangeUnderflow';
  1764. FStepMismatch: Boolean; external name 'stepMismatch';
  1765. FTooLong: Boolean; external name 'tooLong';
  1766. FTooShort: Boolean; external name 'tooShort';
  1767. FTypeMismatch: Boolean; external name 'typeMisMatch';
  1768. FValid: Boolean; external name 'valid';
  1769. FValueMissing: Boolean; external name 'valueMissing';
  1770. public
  1771. property badInput : Boolean read FBadInput;
  1772. property customError : Boolean read FCustomError;
  1773. property patternMisMatch : Boolean read FPatternMismatch;
  1774. property rangeOverflow : Boolean read FRangeOverflow;
  1775. property rangeUnderflow : Boolean read FRangeUnderflow;
  1776. property stepMismatch : Boolean read FStepMismatch;
  1777. property tooLong : Boolean read FTooLong;
  1778. property tooShort : Boolean read FTooShort;
  1779. property typeMisMatch : Boolean read FTypeMismatch;
  1780. property valid : Boolean Read FValid;
  1781. property valueMissing : Boolean read FValueMissing;
  1782. end;
  1783. { TJSBlob }
  1784. TJSBlob = class external name 'Blob' (TJSEventTarget)
  1785. private
  1786. FSize: NativeInt; external name 'size';
  1787. FType: string; external name 'type';
  1788. Public
  1789. procedure close;
  1790. function slice : TJSBlob; overload;
  1791. function slice(aStart : NativeInt) : TJSBlob; overload;
  1792. function slice(aStart,aEnd : NativeInt) : TJSBlob; overload;
  1793. function slice(aStart,aEnd : NativeInt; AContentType : String) : TJSBlob; overload;
  1794. property size : NativeInt read FSize;
  1795. property _type : string read FType;
  1796. end;
  1797. { TJSHTMLFile }
  1798. TJSHTMLFile = class external name 'File' (TJSBlob)
  1799. private
  1800. FLastModified: NativeInt; external name 'lastModified';
  1801. FLastModifiedDate: TJSDate; external name 'lastModifiedDate';
  1802. FName: string; external name 'name';
  1803. Public
  1804. property name : string read FName;
  1805. property lastModified : NativeInt read FLastModified;
  1806. property lastModifiedDate : TJSDate read FLastModifiedDate;
  1807. end;
  1808. { TJSHTMLFileList }
  1809. TJSHTMLFileList = class external name 'FileList' (TJSEventTarget)
  1810. private
  1811. FLength: NativeInt; external name 'length';
  1812. Public
  1813. function item(aIndex : NativeInt) : TJSHTMLFile;
  1814. property length : NativeInt read FLength;
  1815. property Files[aIndex : NativeInt] : TJSHTMLFile Read item; default;
  1816. end;
  1817. { TJSHTMLInputElement }
  1818. // https://html.spec.whatwg.org/multipage/forms.html#the-input-element
  1819. TJSHTMLInputElement = class external name 'HTMLInputElement' (TJSHTMLElement)
  1820. private
  1821. FFiles: TJSHTMLFileList; external name 'files';
  1822. FForm: TJSHTMLFormElement; external name 'form';
  1823. FLabels: TJSNodeList; external name 'labels';
  1824. FList: TJSHTMLElement; external name 'list';
  1825. FValidationmMessage: string; external name 'validationMessage';
  1826. FValidity: TJSValidityState; external name 'validity';
  1827. FWillValidate: boolean; external name 'willValidate';
  1828. Public
  1829. procedure select;
  1830. procedure setCustomValidity(aText : string);
  1831. procedure stepUp; overload;
  1832. procedure stepUp(n : Integer); overload;
  1833. function checkValidity : Boolean;
  1834. function reportValidity : Boolean;
  1835. procedure setSelectionRange(selectionStart, selectionEnd: NativeInt) ; overload;
  1836. procedure setSelectionRange(selectionStart, selectionEnd: NativeInt; Direction : string) ; overload;
  1837. procedure setRangeText(aText : string; selectionStart, selectionEnd: NativeInt) ; overload;
  1838. procedure setRangeText(aText : string; selectionStart, selectionEnd: NativeInt; Direction : string) ; overload;
  1839. Public
  1840. accept : string;
  1841. allowDirs : boolean;
  1842. align : string;
  1843. alt : string;
  1844. autofocus : boolean;
  1845. autocapitalize : string;
  1846. autocomplete : string;
  1847. defaultValue : string;
  1848. defaultChecked : string;
  1849. checked : boolean;
  1850. dirName : string;
  1851. disabled : boolean;
  1852. formAction : string;
  1853. formEncType : string;
  1854. formMethod : string;
  1855. formNoValidate : Boolean;
  1856. formTarget : string;
  1857. height : Boolean;
  1858. indeterminate : boolean;
  1859. inputMode : string;
  1860. max : string;
  1861. maxLength : NativeInt;
  1862. min : string;
  1863. minLength : NativeInt;
  1864. multiple : boolean;
  1865. pattern : string;
  1866. placeholder : string;
  1867. readOnly : boolean;
  1868. required : boolean;
  1869. size : NativeInt;
  1870. src : string;
  1871. step : string;
  1872. _type : string; external name 'type';
  1873. selectionStart : NativeInt;
  1874. selectionEnd : NativeInt;
  1875. selectionDirection : string;
  1876. useMap : string;
  1877. value : string;
  1878. width : NativeInt;
  1879. property files : TJSHTMLFileList Read FFiles;
  1880. property form : TJSHTMLFormElement read FForm;
  1881. property labels : TJSNodeList read FLabels;
  1882. property list : TJSHTMLElement Read FList;
  1883. property validationMessage : string read FValidationmMessage;
  1884. property willValidate : boolean read FWillValidate;
  1885. property validity : TJSValidityState read FValidity;
  1886. end;
  1887. { TJSHTMLOptionElement }
  1888. TJSHTMLOptionElement = class external name 'Option' (TJSHTMLElement)
  1889. private
  1890. FForm: TJSHTMLFormElement; external name 'form';
  1891. FIndex: NativeInt; external name 'index';
  1892. Public
  1893. Constructor New; overload;
  1894. Constructor New(aText : String); overload;
  1895. Constructor New(aText,aValue : String); overload;
  1896. Constructor New(aText,aValue : String; aDefaultSelected : Boolean); overload;
  1897. Constructor New(aText,aValue : String; aDefaultSelected,Selected : Boolean); overload;
  1898. Public
  1899. defaultSelected : boolean;
  1900. disabled : boolean;
  1901. _label : string ; external name 'label';
  1902. selected : boolean;
  1903. text : string;
  1904. value : string;
  1905. property index : NativeInt Read FIndex;
  1906. property form : TJSHTMLFormElement Read FForm;
  1907. end;
  1908. TJSHTMLOptGroupElement = class external name 'HTMLOptGroupElement' (TJSHTMLElement)
  1909. end;
  1910. TJSHTMLOptionsCollection = class external name 'HTMLOptionsCollection' (TJSHTMLCollection)
  1911. end;
  1912. { TJSHTMLSelectElement }
  1913. TJSHTMLSelectElement = Class external name 'HTMLSelectElement' (TJSHTMLElement)
  1914. private
  1915. FForm: TJSHTMLFormElement; external name 'form';
  1916. FLabels: TJSNodeList; external name 'labels';
  1917. FLength: NativeInt; external name 'length';
  1918. FOptions: TJSHTMLOptionsCollection; external name 'options';
  1919. FSelectedOptions: TJSHTMLCollection; external name 'selectedOptions';
  1920. FType: String; external name 'type';
  1921. FValidationMessage: string; external name 'validationMessage';
  1922. FValidity: TJSValidityState; external name 'validity';
  1923. fwillValidate: Boolean; external name 'willValidate';
  1924. Public
  1925. Procedure add(anItem : TJSHTMLOptionElement); overload;
  1926. Procedure add(anItem, before : TJSHTMLOptionElement); overload;
  1927. function item(aIndex : NativeInt): TJSHTMLOptionElement;
  1928. function namedItem(aName : String): TJSHTMLOptionElement;
  1929. procedure remove(aIndex : NativeInt);
  1930. procedure checkValidity;
  1931. procedure setCustomValidity(aMessage : String);
  1932. Public
  1933. multiple : boolean;
  1934. required: boolean;
  1935. selectedIndex : NativeInt;
  1936. size : NativeInt;
  1937. value : string;
  1938. property length : NativeInt read FLength;
  1939. Property options : TJSHTMLOptionsCollection read FOptions;
  1940. Property selectedOptions : TJSHTMLCollection read FSelectedOptions;
  1941. Property form : TJSHTMLFormElement read FForm;
  1942. property labels : TJSNodeList Read FLabels;
  1943. property _type : String Read FType;
  1944. property validity : TJSValidityState Read FValidity;
  1945. property validationMessage : string Read FValidationMessage;
  1946. property willValidate : Boolean read fwillValidate;
  1947. end;
  1948. TJSCanvasRenderingContext2D = Class;
  1949. THTMLCanvasToBlobCallback = Reference to function (aBlob : TJSBlob) : boolean;
  1950. TJSHTMLCanvasElement = Class external name 'HTMLCanvasElement' (TJSHTMLElement)
  1951. Public
  1952. height : integer;
  1953. width : integer;
  1954. Function getContext(contextType : string) : TJSObject;
  1955. Function getContext(contextType : string; contextAttributes : TJSObject) : TJSObject;
  1956. Function getContextAs2DContext(contextType : string; contextAttributes : TJSObject) : TJSCanvasRenderingContext2D; external name 'getContext';
  1957. Function getContextAs2DContext(contextType : string) : TJSCanvasRenderingContext2D; external name 'getContext';
  1958. Procedure toBlob (aCallBack : THTMLCanvasToBlobCallback; aMimeType : String); overload;
  1959. Procedure toBlob (aCallBack : THTMLCanvasToBlobCallback; aMimeType : String; aQuality : Double); overload;
  1960. Function toDataURL : String; overload;
  1961. Function toDataURL(aMimeType : String) : String; overload;
  1962. Function toDataURL(aMimeType : String; aQuality : Double) : String; overload;
  1963. end;
  1964. // Opaque objects
  1965. TJSCanvasGradient = class external name 'CanvasGradient'
  1966. end;
  1967. TJSCanvasPattern = class external name 'CanvasPattern'
  1968. end;
  1969. TJSPath2D = class external name 'Path2D'
  1970. end;
  1971. { TJSImageData }
  1972. TJSImageData = class external name 'ImageData'
  1973. private
  1974. FData: TJSUint8ClampedArray; external name 'data';
  1975. FHeight: Integer; external name 'height';
  1976. FWidth: Integer; external name 'width';
  1977. Public
  1978. constructor new(awidth,aheight : integer); overload;
  1979. constructor new(anArray :TJSUint8ClampedArray; awidth,aheight : integer); overload;
  1980. property data : TJSUint8ClampedArray read FData;
  1981. property height : Integer Read FHeight;
  1982. property width : Integer Read FWidth;
  1983. end;
  1984. TCanvasCoordType = double; // Is in fact a number.
  1985. TJSTextMetrics = record
  1986. width : TCanvasCoordType;
  1987. actualBoundingBoxLeft : TCanvasCoordType;
  1988. actualBoundingBoxRight : TCanvasCoordType;
  1989. fontBoundingBoxAscent : TCanvasCoordType;
  1990. fontBoundingBoxDescent : TCanvasCoordType;
  1991. actualBoundingBoxAscent : TCanvasCoordType;
  1992. actualBoundingBoxDescent : TCanvasCoordType;
  1993. emHeightAscent : TCanvasCoordType;
  1994. emHeightDescent : TCanvasCoordType;
  1995. hangingBaseline : TCanvasCoordType;
  1996. alphabeticBaseline : TCanvasCoordType;
  1997. ideographicBaseline : TCanvasCoordType;
  1998. end;
  1999. { TJSCanvasRenderingContext2D }
  2000. TJSCanvasRenderingContext2D = class external name 'CanvasRenderingContext2D'
  2001. private
  2002. FCanvas: TJSHTMLCanvasElement; external name 'canvas';
  2003. FfillStyleColor: String; external name 'fillStyle';
  2004. FfillStyleGradient: TJSCanvasGradient; external name 'fillStyle';
  2005. FfillStylePattern: TJSCanvasPattern; external name 'fillStyle';
  2006. FstrokeStyleColor: String; external name 'strokeStyle';
  2007. FstrokeStyleGradient: TJSCanvasGradient; external name 'strokeStyle';
  2008. FstrokeStylePattern: TJSCanvasPattern; external name 'strokeStyle';
  2009. Public
  2010. fillStyle : JSValue;
  2011. font : string;
  2012. globalAlpha : double;
  2013. globalCompositeOperation : String;
  2014. lineCap : string;
  2015. lineDashOffset : Double;
  2016. lineJoin : String;
  2017. lineWidth : Double;
  2018. miterLimit : Double;
  2019. shadowBlur : Double;
  2020. shadowColor : String;
  2021. shadowOffsetX : Double;
  2022. shadowOffsetY : Double;
  2023. strokeStye : JSValue;
  2024. textAlign : String;
  2025. textBaseline : String;
  2026. procedure arc(x,y, radius,startAngle,endAngle : TCanvasCoordType); overload;
  2027. procedure arc(x,y, radius,startAngle,endAngle : TCanvasCoordType; antiClockWise : boolean); overload;
  2028. procedure arcTo(x1,y1,x2,y2,radius : TCanvasCoordType); overload;
  2029. procedure beginPath;
  2030. procedure bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y : TCanvasCoordType); overload;
  2031. procedure clearRect(x,y,width,height : TCanvasCoordType);
  2032. procedure clip; overload;
  2033. procedure clip(aFillRule : String); overload;
  2034. procedure clip(aPath : TJSPath2D); overload;
  2035. procedure closePath;
  2036. function createImageData(aWidth,aHeight : Integer) : TJSImageData; overload;
  2037. function createImageData(aImage : TJSImageData) : TJSImageData; overload;
  2038. function createLinearGradient(x0,y0,x1,y1 : TCanvasCoordType) : TJSCanvasGradient;
  2039. function createPattern(aImage : TJSObject; repetition : string) : TJSCanvasPattern;
  2040. function createRadialGradient(x0,y0,r0,x1,y1,r1 : TCanvasCoordType) : TJSCanvasGradient;
  2041. procedure drawFocusIfNeeded(aElement : TJSElement); overload;
  2042. procedure drawFocusIfNeeded(aPath : TJSPath2D; aElement : TJSElement); overload;
  2043. procedure drawImage(image : TJSObject; dx,dy : TCanvasCoordType); overload;
  2044. procedure drawImage(image : TJSObject; dx,dy,dwidth,dheight : TCanvasCoordType); overload;
  2045. procedure drawImage(image : TJSObject; sx,sy,sWidth,sHeight,dx,dy,dwidth,dheight : TCanvasCoordType); overload;
  2046. procedure fill; overload;
  2047. procedure fill(aRule : String); overload;
  2048. procedure fill(aPath : TJSPath2D); overload;
  2049. procedure fill(aPath : TJSPath2D;aRule : String); overload;
  2050. procedure fillRect(x,y,awidth,aheight: TCanvasCoordType); overload;
  2051. procedure fillText(aText : string; x,y : TCanvasCoordType); overload;
  2052. procedure fillText(aText : string; x,y, aMaxWidth : TCanvasCoordType); overload;
  2053. function getImageData(x,y,awidth,aheight: TCanvasCoordType) : TJSImageData; overload;
  2054. function getLineDash : TJSArray;
  2055. function isPointInPath(x,y : TCanvasCoordType) : Boolean; overload;
  2056. function isPointInPath(x,y : TCanvasCoordType; aFillRule : String) : Boolean; overload;
  2057. function isPointInPath(aPath : TJSPath2D; x,y : TCanvasCoordType) : Boolean; overload;
  2058. function isPointInPath(aPath : TJSPath2D; x,y : TCanvasCoordType; aFillRule : String) : Boolean; overload;
  2059. function isPointInStroke(x,y : TCanvasCoordType) : Boolean; overload;
  2060. function isPointInStroke(aPath : TJSPath2D; x,y : TCanvasCoordType) : Boolean; overload;
  2061. procedure lineTo(x,y : TCanvasCoordType);
  2062. function measureText(S : String) : TJSTextMetrics;
  2063. procedure moveTo(x,y : TCanvasCoordType);
  2064. procedure putImageData(aData : TJSImageData; x,y: TCanvasCoordType) ; overload;
  2065. procedure putImageData(aData : TJSImageData; x,y,dityX,dirtyY,dirtyWidth,dirtyHeight: TCanvasCoordType) ; overload;
  2066. procedure quadraticCurveTo(cpx,cpy,x,y : TCanvasCoordType);
  2067. procedure rect(x,y,awidth,aheight: TCanvasCoordType); overload;
  2068. procedure restore;
  2069. procedure rotate(anAngle : double);
  2070. procedure save;
  2071. procedure scale(x,y : double);
  2072. procedure setLineDash(segments : TJSArray); overload;
  2073. procedure setLineDash(segments : array of integer); overload;
  2074. procedure setTransform(a,b,c,d,e,f : double);
  2075. procedure stroke; overload;
  2076. procedure stroke(aPath : TJSPath2D); overload;
  2077. procedure strokeRect(x,y,awidth,aheight: TCanvasCoordType);
  2078. procedure strokeText(aText : string; x,y : TCanvasCoordType); overload;
  2079. procedure strokeText(aText : string; x,y, aMaxWidth : TCanvasCoordType); overload;
  2080. procedure transform(a,b,c,d,e,f : double);
  2081. procedure translate(x,y : TCanvasCoordType);
  2082. property canvas : TJSHTMLCanvasElement Read FCanvas;
  2083. property fillStyleAsColor : String Read FfillStyleColor Write FfillStyleColor;
  2084. property fillStyleAsGradient : TJSCanvasGradient Read FfillStyleGradient Write FfillStyleGradient;
  2085. property fillStyleAsPattern : TJSCanvasPattern Read FfillStylePattern Write FfillStylePattern;
  2086. property strokeStyleAsColor : String Read FstrokeStyleColor Write FstrokeStyleColor;
  2087. property strokeStyleAsGradient : TJSCanvasGradient Read FstrokeStyleGradient Write FstrokeStyleGradient;
  2088. property strokeStyleAsPattern : TJSCanvasPattern Read FstrokeStylePattern Write FstrokeStylePattern;
  2089. end;
  2090. { TJSHTMLIFrameElement }
  2091. TJSHTMLIFrameElement = Class external name 'HTMLIFrameElement' (TJSHTMLElement)
  2092. private
  2093. FAllowPaymentRequest: Boolean; external name 'allowPaymentRequest';
  2094. FContentDocument: TJSDocument; external name 'contentDocument';
  2095. FContentWindow: TJSWindow; external name 'contentWindow';
  2096. FSandbox: string; external name 'sandbox';
  2097. Public
  2098. height : string;
  2099. src : string;
  2100. srcdoc : string;
  2101. width : string;
  2102. Property allowPaymentRequest : Boolean Read FAllowPaymentRequest;
  2103. property contentWindow : TJSWindow Read FContentWindow;
  2104. property contentDocument : TJSDocument Read FContentDocument;
  2105. property sandbox : string read FSandbox;
  2106. end;
  2107. TJSXMLHttpRequestEventTarget = class external name 'XMLHttpRequestEventTarget' (TJSEventTarget)
  2108. end;
  2109. TJSXMLHttpRequestUpload = class external name 'XMLHttpRequestUpload' (TJSXMLHttpRequestEventTarget)
  2110. end;
  2111. { TJSXMLHttpRequest }
  2112. TJSOnReadyStateChangeHandler = reference to procedure;
  2113. TJSXMLHttpRequest = class external name 'XMLHttpRequest' (TJSXMLHttpRequestEventTarget)
  2114. private
  2115. FReadyState: NativeInt; external name 'readyState';
  2116. FResponse: JSValue; external name 'response';
  2117. FResponseText: string; external name 'responseText';
  2118. FResponseType: string; external name 'responseType';
  2119. FresponseURL: string; external name 'responseURL';
  2120. FresponseXML: TJSDocument; external name 'responseXML';
  2121. FUpload: TJSXMLHttpRequestUpload; external name 'upload';
  2122. FStatus : integer; external name 'status';
  2123. FStatusText : string; external name 'statusText';
  2124. public
  2125. const
  2126. UNSENT = 0;
  2127. OPENED = 1;
  2128. HEADERS_RECEIVED = 3;
  2129. LOADING = 3;
  2130. DONE = 4;
  2131. public
  2132. timeout : LongWord;
  2133. withCredentials : Boolean;
  2134. onreadystatechange : TJSOnReadyStateChangeHandler;
  2135. constructor new;
  2136. procedure abort;
  2137. function getResponseHeader(aName : string) : String;
  2138. function getAllResponseHeaders : String;
  2139. procedure open(aMethod,aURL : String); overload;
  2140. procedure open(aMethod,aURL : String; Async : Boolean); overload;
  2141. procedure open(aMethod,aURL : String; Async : Boolean; AUserame : String); overload;
  2142. procedure open(aMethod,aURL : String; Async : Boolean; AUserame,APassword : String); overload;
  2143. procedure overrideMimeType(aType : String);
  2144. procedure send(aBody : jsValue);overload;
  2145. procedure send;overload;
  2146. procedure setRequestHeader(aName, AValue : string);
  2147. property readyState : NativeInt read FReadyState;
  2148. property ResponseHeaders[aName : string] : string Read getResponseHeader;
  2149. property responseXML : TJSDocument read FresponseXML;
  2150. property responseURL : string read FresponseURL;
  2151. property responseType : string read FResponseType;
  2152. property response : JSValue Read FResponse;
  2153. property responseText : string read FResponseText;
  2154. property Status : integer read FStatus;
  2155. property StatusText : string read FStatusText;
  2156. property upload : TJSXMLHttpRequestUpload read FUpload;
  2157. end;
  2158. { TJSUIEvent }
  2159. TJSUIEvent = class external name 'UIEvent' (TJSEvent)
  2160. private
  2161. FDetail: NativeInt; external name 'detail';
  2162. FView: TJSWindow; external name 'view';
  2163. Public
  2164. property detail : NativeInt read FDetail;
  2165. property view : TJSWindow read FView;
  2166. end;
  2167. { TJSMouseEvent }
  2168. TJSMouseEvent = class external name 'MouseEvent' (TJSUIevent)
  2169. private
  2170. FAltKey: Boolean; external name 'altKey';
  2171. FBUtton: NativeInt; external name 'button';
  2172. FBUttons: NativeInt; external name 'buttons';
  2173. FClientX: Double; external name 'clientX';
  2174. FClientY: Double; external name 'clientY';
  2175. FCtrlKey: Boolean; external name 'ctrlKey';
  2176. FMetaKey: Boolean; external name 'metaKey';
  2177. FmovementX: Double; external name 'movementX';
  2178. FmovementY: Double; external name 'movementY';
  2179. FoffsetX: Double; external name 'offsetX';
  2180. FoffsetY: Double; external name 'offsetY';
  2181. FRegion: String; external name 'region';
  2182. FRelatedTarget: TJSEventTarget; external name 'relatedTarget';
  2183. FscreenX: Double; external name 'screenX';
  2184. FscreenY: Double; external name 'screenY';
  2185. FShiftKey: Boolean; external name 'shiftKey';
  2186. Public
  2187. Property altKey : Boolean read FAltKey;
  2188. Property button: NativeInt read FBUtton;
  2189. Property buttons: NativeInt read FBUttons;
  2190. property clientX : Double read FClientX;
  2191. property clientY : Double read FClientY;
  2192. property ctrlKey : Boolean read FCtrlKey;
  2193. property metaKey : Boolean read FMetaKey;
  2194. property movementX : Double read FmovementX;
  2195. property movementY : Double read FmovementY;
  2196. property offsetX : Double read FoffsetX;
  2197. property offsetY : Double read FoffsetY;
  2198. {$IFDEF FIREFOX}
  2199. property pageX : Double read FpageX;
  2200. property pageY : Double read FpageY;
  2201. {$ENDIF}
  2202. property region : String read FRegion;
  2203. property relatedTarget : TJSEventTarget read FRelatedTarget;
  2204. property screenX : Double read FscreenX;
  2205. property screenY : Double read FscreenY;
  2206. property shiftKey : Boolean read FShiftKey;
  2207. property x : Double read FClientX;
  2208. property y : Double read FClientY;
  2209. end;
  2210. { TJSWheelEvent }
  2211. TJSWheelEventInit = record
  2212. deltaX : Double;
  2213. deltaY : Double;
  2214. deltaZ : Double;
  2215. deltaMode : NativeInt;
  2216. end;
  2217. TJSWheelEvent = class external name 'WheelEvent' (TJSMouseEvent)
  2218. private
  2219. FDeltaMode: NativeInt; external name 'deltaMode';
  2220. FDeltaX: Double; external name 'deltaX';
  2221. FDeltaY: Double; external name 'deltaY';
  2222. FDeltaZ: Double; external name 'deltaZ';
  2223. Public
  2224. constructor new(atype : String); overload;
  2225. constructor new(atype : String; aInit : TJSWheelEventInit); overload;
  2226. Property deltaX : Double Read FDeltaX;
  2227. Property deltaY : Double Read FDeltaY;
  2228. Property deltaZ : Double Read FDeltaZ;
  2229. Property deltaMode : NativeInt Read FDeltaMode;
  2230. end;
  2231. TJSPointerEvent = Class external name 'PointerEvent' (TJSMouseEvent);
  2232. TJSTouchEvent = Class external name 'TouchEvent'(TJSUIEvent)
  2233. private
  2234. FAltKey: Boolean; external name 'altKey';
  2235. FChangedTouches: TJSTouchList; external name 'changedTouches';
  2236. FCtrlKey: Boolean; external name 'ctrlKey';
  2237. FMetaKey: Boolean; external name 'metaKey';
  2238. FShiftKey: Boolean; external name 'shiftKey';
  2239. FTargetTouches: TJSTouchList; external name 'targetTouches';
  2240. FTouches: TJSTouchList; external name 'touches';
  2241. Public
  2242. Property altKey : Boolean Read FAltKey;
  2243. Property ctrlKey : Boolean Read FCtrlKey;
  2244. Property metaKey : Boolean Read FMetaKey;
  2245. Property shiftKey : Boolean Read FShiftKey;
  2246. property changedTouches : TJSTouchList Read FChangedTouches;
  2247. property touches : TJSTouchList Read FTouches;
  2248. property targetTouches : TJSTouchList Read FTargetTouches;
  2249. end;
  2250. // Namespace for standard key names.
  2251. // See list at https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
  2252. TJSKeyNames = Class
  2253. Const
  2254. Alt = 'Alt';
  2255. AltGraph = 'AltGraph';
  2256. CapsLock = 'CapsLock';
  2257. Control = 'Control';
  2258. Fn = 'Fn';
  2259. FnLock = 'FnLock';
  2260. Hyper = 'Hyper';
  2261. Meta = 'Meta';
  2262. NumLock = 'NumLock';
  2263. ScrollLock = 'ScrollLock';
  2264. Shift = 'Shift';
  2265. Super = 'Super';
  2266. Symbol = 'Symbol';
  2267. SymbolLock = 'SymbolLock';
  2268. Enter = 'Enter';
  2269. Tab = 'Tab';
  2270. Space = ' ';
  2271. ArrowDown = 'ArrowDown';
  2272. ArrowLeft = 'ArrowLeft';
  2273. ArrowRight = 'ArrowRight';
  2274. ArrowUp = 'ArrowUp';
  2275. _End = 'End';
  2276. Home = 'Home';
  2277. PageDown = 'PageDown';
  2278. PageUp = 'PageUp';
  2279. BackSpace = 'Backspace';
  2280. Clear = 'Clear';
  2281. Copy = 'Copy';
  2282. CrSel = 'CrSel';
  2283. Cut = 'Cut';
  2284. Delete = 'Delete';
  2285. EraseEof = 'EraseEof';
  2286. ExSel = 'ExSel';
  2287. Insert = 'Insert';
  2288. Paste = 'Paste';
  2289. Redo = 'Redo';
  2290. Undo = 'Undo';
  2291. Accept = 'Accept';
  2292. Again = 'Again';
  2293. Attn = 'Attn';
  2294. Cancel = 'Cancel';
  2295. ContextMenu = 'Contextmenu';
  2296. Escape = 'Escape';
  2297. Execute = 'Execute';
  2298. Find = 'Find';
  2299. Finish = 'Finish';
  2300. Help = 'Help';
  2301. Pause = 'Pause';
  2302. Play = 'Play';
  2303. Props = 'Props';
  2304. Select = 'Select';
  2305. ZoomIn = 'ZoomIn';
  2306. ZoomOut = 'ZoomOut';
  2307. BrightnessDown = 'BrightnessDown';
  2308. BrightnessUp = 'BrightnessUp';
  2309. Eject = 'Eject';
  2310. LogOff = 'LogOff';
  2311. Power = 'Power';
  2312. PowerOff = 'PowerOff';
  2313. PrintScreen = 'PrintScreen';
  2314. Hibernate = 'Hibernate';
  2315. Standby = 'Standby';
  2316. WakeUp = 'WakeUp';
  2317. AllCandidates = 'AllCandidates';
  2318. Alphanumeric = 'Alphanumeric';
  2319. CodeInput = 'CodeInput';
  2320. Compose = 'Compose';
  2321. Convert = 'Convert';
  2322. Dead = 'Dead';
  2323. FinalMode = 'FinalMode';
  2324. GroupFirst = 'GroupFirst';
  2325. GroupLast = 'GroupLast';
  2326. GroupNext = 'GroupNext';
  2327. GroupPrevious = 'GroupPrevious';
  2328. ModelChange = 'ModelChange';
  2329. NextCandidate = 'NextCandidate';
  2330. NonConvert = 'NonConvert';
  2331. PreviousCandidate = 'PreviousCandidate';
  2332. Process = 'Process';
  2333. SingleCandidate = 'SingleCandidate';
  2334. HangulMode = 'HangulMode';
  2335. HanjaMode = 'HanjaMode';
  2336. JunjaMode = 'JunjaMode';
  2337. Eisu = 'Eisu';
  2338. Hankaku = 'Hankaku';
  2339. Hiranga = 'Hiranga';
  2340. HirangaKatakana = 'HirangaKatakana';
  2341. KanaMode = 'KanaMode';
  2342. Katakana = 'Katakana';
  2343. Romaji = 'Romaji';
  2344. Zenkaku = 'Zenkaku';
  2345. ZenkakuHanaku = 'ZenkakuHanaku';
  2346. F1 = 'F1';
  2347. F2 = 'F2';
  2348. F3 = 'F3';
  2349. F4 = 'F4';
  2350. F5 = 'F5';
  2351. F6 = 'F6';
  2352. F7 = 'F7';
  2353. F8 = 'F8';
  2354. F9 = 'F9';
  2355. F10 = 'F10';
  2356. F11 = 'F11';
  2357. F12 = 'F12';
  2358. F13 = 'F13';
  2359. F14 = 'F14';
  2360. F15 = 'F15';
  2361. F16 = 'F16';
  2362. F17 = 'F17';
  2363. F18 = 'F18';
  2364. F19 = 'F19';
  2365. F20 = 'F20';
  2366. Soft1 = 'Soft1';
  2367. Soft2 = 'Soft2';
  2368. Soft3 = 'Soft3';
  2369. Soft4 = 'Soft4';
  2370. Decimal = 'Decimal';
  2371. Key11 = 'Key11';
  2372. Key12 = 'Key12';
  2373. Multiply = 'Multiply';
  2374. Add = 'Add';
  2375. NumClear = 'Clear';
  2376. Divide = 'Divide';
  2377. Subtract = 'Subtract';
  2378. Separator = 'Separator';
  2379. AppSwitch = 'AppSwitch';
  2380. Call = 'Call';
  2381. Camera = 'Camera';
  2382. CameraFocus = 'CameraFocus';
  2383. EndCall = 'EndCall';
  2384. GoBack = 'GoBack';
  2385. GoHome = 'GoHome';
  2386. HeadsetHook = 'HeadsetHook';
  2387. LastNumberRedial = 'LastNumberRedial';
  2388. Notification = 'Notification';
  2389. MannerMode = 'MannerMode';
  2390. VoiceDial = 'VoiceDial';
  2391. // TODO : Multimedia keys
  2392. // TODO : Audio control keys
  2393. // TODO : TV control keys
  2394. // TODO : Media controller keys
  2395. // TODO : Speech recognition keys
  2396. // TODO : Document keys
  2397. // TODO : Application selector keys
  2398. // TODO : Browser Control keys
  2399. end;
  2400. { TJSKeyboardEvent }
  2401. TJSKeyboardEvent = class external name 'KeyboardEvent' (TJSUIEvent)
  2402. private
  2403. FAltKey: Boolean; external name 'altKey';
  2404. FCode: string; external name 'code';
  2405. FCtrlKey: Boolean; external name 'ctrlKey';
  2406. FIsComposing: Boolean; external name 'isComposing';
  2407. FKey: String; external name 'key';
  2408. FLocale: string; external name 'locale';
  2409. FLocation: NativeInt; external name 'location';
  2410. FMetaKey: Boolean; external name 'metaKey';
  2411. FRepeat: Boolean; external name 'repeat';
  2412. FShiftKey: Boolean; external name 'shiftKey';
  2413. Public
  2414. function getModifierState(aKey : string) : Boolean;
  2415. property code : string read FCode;
  2416. Property altKey : Boolean read FAltKey;
  2417. property ctrlKey : Boolean read FCtrlKey;
  2418. property isComposing : Boolean read FIsComposing;
  2419. property Key : String read FKey;
  2420. property locale : string read FLocale;
  2421. property location : NativeInt read FLocation;
  2422. property metaKey : Boolean read FMetaKey;
  2423. property _repeat : Boolean read FRepeat;
  2424. property shiftKey : Boolean read FShiftKey;
  2425. end;
  2426. var
  2427. document : TJSDocument; external name 'document';
  2428. window : TJSWindow; external name 'window';
  2429. console : TJSConsole; external name 'window.console';
  2430. implementation
  2431. end.