interpreter.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. class ListenerMap {
  2. constructor(root) {
  3. // bubbling events can listen at the root element
  4. this.global = {};
  5. // non bubbling events listen at the element the listener was created at
  6. this.local = {};
  7. this.root = root;
  8. }
  9. create(event_name, element, handler, bubbles) {
  10. if (bubbles) {
  11. if (this.global[event_name] === undefined) {
  12. this.global[event_name] = {};
  13. this.global[event_name].active = 1;
  14. this.global[event_name].callback = handler;
  15. this.root.addEventListener(event_name, handler);
  16. } else {
  17. this.global[event_name].active++;
  18. }
  19. } else {
  20. const id = element.getAttribute("data-dioxus-id");
  21. if (!this.local[id]) {
  22. this.local[id] = {};
  23. }
  24. this.local[id][event_name] = handler;
  25. element.addEventListener(event_name, handler);
  26. }
  27. }
  28. remove(element, event_name, bubbles) {
  29. if (bubbles) {
  30. this.global[event_name].active--;
  31. if (this.global[event_name].active === 0) {
  32. this.root.removeEventListener(
  33. event_name,
  34. this.global[event_name].callback
  35. );
  36. delete this.global[event_name];
  37. }
  38. } else {
  39. const id = element.getAttribute("data-dioxus-id");
  40. delete this.local[id][event_name];
  41. if (this.local[id].length === 0) {
  42. delete this.local[id];
  43. }
  44. element.removeEventListener(event_name, handler);
  45. }
  46. }
  47. removeAllNonBubbling(element) {
  48. const id = element.getAttribute("data-dioxus-id");
  49. delete this.local[id];
  50. }
  51. }
  52. class Interpreter {
  53. constructor(root) {
  54. this.root = root;
  55. this.listeners = new ListenerMap(root);
  56. this.nodes = [root];
  57. this.stack = [root];
  58. this.handlers = {};
  59. this.templates = {};
  60. this.lastNodeWasText = false;
  61. }
  62. top() {
  63. return this.stack[this.stack.length - 1];
  64. }
  65. pop() {
  66. return this.stack.pop();
  67. }
  68. MountToRoot() {
  69. this.AppendChildren(this.stack.length - 1);
  70. }
  71. SetNode(id, node) {
  72. this.nodes[id] = node;
  73. }
  74. PushRoot(root) {
  75. const node = this.nodes[root];
  76. this.stack.push(node);
  77. }
  78. PopRoot() {
  79. this.stack.pop();
  80. }
  81. AppendChildren(many) {
  82. // let root = this.nodes[id];
  83. let root = this.stack[this.stack.length - 1 - many];
  84. let to_add = this.stack.splice(this.stack.length - many);
  85. for (let i = 0; i < many; i++) {
  86. root.appendChild(to_add[i]);
  87. }
  88. }
  89. ReplaceWith(root_id, m) {
  90. let root = this.nodes[root_id];
  91. let els = this.stack.splice(this.stack.length - m);
  92. if (is_element_node(root.nodeType)) {
  93. this.listeners.removeAllNonBubbling(root);
  94. }
  95. root.replaceWith(...els);
  96. }
  97. InsertAfter(root, n) {
  98. let old = this.nodes[root];
  99. let new_nodes = this.stack.splice(this.stack.length - n);
  100. old.after(...new_nodes);
  101. }
  102. InsertBefore(root, n) {
  103. let old = this.nodes[root];
  104. let new_nodes = this.stack.splice(this.stack.length - n);
  105. old.before(...new_nodes);
  106. }
  107. Remove(root) {
  108. let node = this.nodes[root];
  109. if (node !== undefined) {
  110. if (is_element_node(node)) {
  111. this.listeners.removeAllNonBubbling(node);
  112. }
  113. node.remove();
  114. }
  115. }
  116. CreateTextNode(text, root) {
  117. const node = document.createTextNode(text);
  118. this.nodes[root] = node;
  119. this.stack.push(node);
  120. }
  121. CreatePlaceholder(root) {
  122. let el = document.createElement("pre");
  123. el.hidden = true;
  124. this.stack.push(el);
  125. this.nodes[root] = el;
  126. }
  127. NewEventListener(event_name, root, bubbles, handler) {
  128. const element = this.nodes[root];
  129. element.setAttribute("data-dioxus-id", `${root}`);
  130. this.listeners.create(event_name, element, handler, bubbles);
  131. }
  132. RemoveEventListener(root, event_name, bubbles) {
  133. const element = this.nodes[root];
  134. element.removeAttribute(`data-dioxus-id`);
  135. this.listeners.remove(element, event_name, bubbles);
  136. }
  137. SetText(root, text) {
  138. this.nodes[root].textContent = text;
  139. }
  140. SetAttribute(id, field, value, ns) {
  141. if (value === null) {
  142. this.RemoveAttribute(id, field, ns);
  143. } else {
  144. const node = this.nodes[id];
  145. this.SetAttributeInner(node, field, value, ns);
  146. }
  147. }
  148. SetAttributeInner(node, field, value, ns) {
  149. const name = field;
  150. if (ns === "style") {
  151. // ????? why do we need to do this
  152. if (node.style === undefined) {
  153. node.style = {};
  154. }
  155. node.style[name] = value;
  156. } else if (ns != null && ns != undefined) {
  157. node.setAttributeNS(ns, name, value);
  158. } else {
  159. switch (name) {
  160. case "value":
  161. if (value !== node.value) {
  162. node.value = value;
  163. }
  164. break;
  165. case "checked":
  166. node.checked = value === "true" || value === true;
  167. break;
  168. case "selected":
  169. node.selected = value === "true" || value === true;
  170. break;
  171. case "dangerous_inner_html":
  172. node.innerHTML = value;
  173. break;
  174. default:
  175. // https://github.com/facebook/react/blob/8b88ac2592c5f555f315f9440cbb665dd1e7457a/packages/react-dom/src/shared/DOMProperty.js#L352-L364
  176. if (value === "false" && bool_attrs.hasOwnProperty(name)) {
  177. node.removeAttribute(name);
  178. } else {
  179. node.setAttribute(name, value);
  180. }
  181. }
  182. }
  183. }
  184. RemoveAttribute(root, field, ns) {
  185. const name = field;
  186. const node = this.nodes[root];
  187. if (ns == "style") {
  188. node.style.removeProperty(name);
  189. } else if (ns !== null || ns !== undefined) {
  190. node.removeAttributeNS(ns, name);
  191. } else if (name === "value") {
  192. node.value = "";
  193. } else if (name === "checked") {
  194. node.checked = false;
  195. } else if (name === "selected") {
  196. node.selected = false;
  197. } else if (name === "dangerous_inner_html") {
  198. node.innerHTML = "";
  199. } else {
  200. node.removeAttribute(name);
  201. }
  202. }
  203. handleEdits(edits) {
  204. for (let template of edits.templates) {
  205. this.SaveTemplate(template);
  206. }
  207. for (let edit of edits.edits) {
  208. this.handleEdit(edit);
  209. }
  210. /*POST_HANDLE_EDITS*/
  211. }
  212. SaveTemplate(template) {
  213. let roots = [];
  214. for (let root of template.roots) {
  215. roots.push(this.MakeTemplateNode(root));
  216. }
  217. this.templates[template.name] = roots;
  218. }
  219. MakeTemplateNode(node) {
  220. switch (node.type) {
  221. case "Text":
  222. return document.createTextNode(node.text);
  223. case "Dynamic":
  224. let dyn = document.createElement("pre");
  225. dyn.hidden = true;
  226. return dyn;
  227. case "DynamicText":
  228. return document.createTextNode("placeholder");
  229. case "Element":
  230. let el;
  231. if (node.namespace != null) {
  232. el = document.createElementNS(node.namespace, node.tag);
  233. } else {
  234. el = document.createElement(node.tag);
  235. }
  236. for (let attr of node.attrs) {
  237. if (attr.type == "Static") {
  238. this.SetAttributeInner(el, attr.name, attr.value, attr.namespace);
  239. }
  240. }
  241. for (let child of node.children) {
  242. el.appendChild(this.MakeTemplateNode(child));
  243. }
  244. return el;
  245. }
  246. }
  247. AssignId(path, id) {
  248. this.nodes[id] = this.LoadChild(path);
  249. }
  250. LoadChild(path) {
  251. // iterate through each number and get that child
  252. let node = this.stack[this.stack.length - 1];
  253. for (let i = 0; i < path.length; i++) {
  254. node = node.childNodes[path[i]];
  255. }
  256. return node;
  257. }
  258. HydrateText(path, value, id) {
  259. let node = this.LoadChild(path);
  260. if (node.nodeType == Node.TEXT_NODE) {
  261. node.textContent = value;
  262. } else {
  263. // replace with a textnode
  264. let text = document.createTextNode(value);
  265. node.replaceWith(text);
  266. node = text;
  267. }
  268. this.nodes[id] = node;
  269. }
  270. ReplacePlaceholder(path, m) {
  271. let els = this.stack.splice(this.stack.length - m);
  272. let node = this.LoadChild(path);
  273. node.replaceWith(...els);
  274. }
  275. LoadTemplate(name, index, id) {
  276. let node = this.templates[name][index].cloneNode(true);
  277. this.nodes[id] = node;
  278. this.stack.push(node);
  279. }
  280. handleEdit(edit) {
  281. switch (edit.type) {
  282. case "AppendChildren":
  283. this.AppendChildren(edit.m);
  284. break;
  285. case "AssignId":
  286. this.AssignId(edit.path, edit.id);
  287. break;
  288. case "CreatePlaceholder":
  289. this.CreatePlaceholder(edit.id);
  290. break;
  291. case "CreateTextNode":
  292. this.CreateTextNode(edit.value, edit.id);
  293. break;
  294. case "HydrateText":
  295. this.HydrateText(edit.path, edit.value, edit.id);
  296. break;
  297. case "LoadTemplate":
  298. this.LoadTemplate(edit.name, edit.index, edit.id);
  299. break;
  300. case "PushRoot":
  301. this.PushRoot(edit.id);
  302. break;
  303. case "ReplaceWith":
  304. this.ReplaceWith(edit.id, edit.m);
  305. break;
  306. case "ReplacePlaceholder":
  307. this.ReplacePlaceholder(edit.path, edit.m);
  308. break;
  309. case "InsertAfter":
  310. this.InsertAfter(edit.id, edit.m);
  311. break;
  312. case "InsertBefore":
  313. this.InsertBefore(edit.id, edit.m);
  314. break;
  315. case "Remove":
  316. this.Remove(edit.id);
  317. break;
  318. case "SetText":
  319. this.SetText(edit.id, edit.value);
  320. break;
  321. case "SetAttribute":
  322. this.SetAttribute(edit.id, edit.name, edit.value, edit.ns);
  323. break;
  324. case "RemoveAttribute":
  325. this.RemoveAttribute(edit.id, edit.name, edit.ns);
  326. break;
  327. case "RemoveEventListener":
  328. this.RemoveEventListener(edit.id, edit.name);
  329. break;
  330. case "NewEventListener":
  331. let bubbles = event_bubbles(edit.name);
  332. this.NewEventListener(edit.name, edit.id, bubbles, (event) => {
  333. handler(event, edit.name, bubbles);
  334. });
  335. break;
  336. }
  337. }
  338. }
  339. // this handler is only provided on the desktop and liveview implementations since this
  340. // method is not used by the web implementation
  341. function handler(event, name, bubbles) {
  342. let target = event.target;
  343. if (target != null) {
  344. let preventDefaultRequests = target.getAttribute(`dioxus-prevent-default`);
  345. if (event.type === "click") {
  346. // todo call prevent default if it's the right type of event
  347. let a_element = target.closest("a");
  348. if (a_element != null) {
  349. event.preventDefault();
  350. let elementShouldPreventDefault =
  351. preventDefaultRequests && preventDefaultRequests.includes(`onclick`);
  352. let aElementShouldPreventDefault = a_element.getAttribute(
  353. `dioxus-prevent-default`
  354. );
  355. let linkShouldPreventDefault =
  356. aElementShouldPreventDefault &&
  357. aElementShouldPreventDefault.includes(`onclick`);
  358. if (!elementShouldPreventDefault && !linkShouldPreventDefault) {
  359. const href = a_element.getAttribute("href");
  360. if (href !== "" && href !== null && href !== undefined) {
  361. window.ipc.postMessage(
  362. serializeIpcMessage("browser_open", { href })
  363. );
  364. }
  365. }
  366. }
  367. // also prevent buttons from submitting
  368. if (target.tagName === "BUTTON" && event.type == "submit") {
  369. event.preventDefault();
  370. }
  371. }
  372. const realId = find_real_id(target);
  373. if (
  374. preventDefaultRequests &&
  375. preventDefaultRequests.includes(`on${event.type}`)
  376. ) {
  377. event.preventDefault();
  378. }
  379. if (event.type === "submit") {
  380. event.preventDefault();
  381. }
  382. let contents = serialize_event(event);
  383. /*POST_EVENT_SERIALIZATION*/
  384. if (
  385. target.tagName === "FORM" &&
  386. (event.type === "submit" || event.type === "input")
  387. ) {
  388. if (
  389. target.tagName === "FORM" &&
  390. (event.type === "submit" || event.type === "input")
  391. ) {
  392. const formData = new FormData(target);
  393. for (let name of formData.keys()) {
  394. let value = formData.getAll(name);
  395. contents.values[name] = value;
  396. }
  397. }
  398. }
  399. if (realId === null) {
  400. return;
  401. }
  402. window.ipc.postMessage(
  403. serializeIpcMessage("user_event", {
  404. name: name,
  405. element: parseInt(realId),
  406. data: contents,
  407. bubbles,
  408. })
  409. );
  410. }
  411. }
  412. function find_real_id(target) {
  413. let realId = target.getAttribute(`data-dioxus-id`);
  414. // walk the tree to find the real element
  415. while (realId == null) {
  416. // we've reached the root we don't want to send an event
  417. if (target.parentElement === null) {
  418. return;
  419. }
  420. target = target.parentElement;
  421. realId = target.getAttribute(`data-dioxus-id`);
  422. }
  423. return realId;
  424. }
  425. function get_mouse_data(event) {
  426. const {
  427. altKey,
  428. button,
  429. buttons,
  430. clientX,
  431. clientY,
  432. ctrlKey,
  433. metaKey,
  434. offsetX,
  435. offsetY,
  436. pageX,
  437. pageY,
  438. screenX,
  439. screenY,
  440. shiftKey,
  441. } = event;
  442. return {
  443. alt_key: altKey,
  444. button: button,
  445. buttons: buttons,
  446. client_x: clientX,
  447. client_y: clientY,
  448. ctrl_key: ctrlKey,
  449. meta_key: metaKey,
  450. offset_x: offsetX,
  451. offset_y: offsetY,
  452. page_x: pageX,
  453. page_y: pageY,
  454. screen_x: screenX,
  455. screen_y: screenY,
  456. shift_key: shiftKey,
  457. };
  458. }
  459. function serialize_event(event) {
  460. switch (event.type) {
  461. case "copy":
  462. case "cut":
  463. case "past": {
  464. return {};
  465. }
  466. case "compositionend":
  467. case "compositionstart":
  468. case "compositionupdate": {
  469. let { data } = event;
  470. return {
  471. data,
  472. };
  473. }
  474. case "keydown":
  475. case "keypress":
  476. case "keyup": {
  477. let {
  478. charCode,
  479. key,
  480. altKey,
  481. ctrlKey,
  482. metaKey,
  483. keyCode,
  484. shiftKey,
  485. location,
  486. repeat,
  487. which,
  488. code,
  489. } = event;
  490. return {
  491. char_code: charCode,
  492. key: key,
  493. alt_key: altKey,
  494. ctrl_key: ctrlKey,
  495. meta_key: metaKey,
  496. key_code: keyCode,
  497. shift_key: shiftKey,
  498. location: location,
  499. repeat: repeat,
  500. which: which,
  501. code,
  502. };
  503. }
  504. case "focus":
  505. case "blur": {
  506. return {};
  507. }
  508. case "change": {
  509. let target = event.target;
  510. let value;
  511. if (target.type === "checkbox" || target.type === "radio") {
  512. value = target.checked ? "true" : "false";
  513. } else {
  514. value = target.value ?? target.textContent;
  515. }
  516. return {
  517. value: value,
  518. values: {},
  519. };
  520. }
  521. case "input":
  522. case "invalid":
  523. case "reset":
  524. case "submit": {
  525. let target = event.target;
  526. let value = target.value ?? target.textContent;
  527. if (target.type === "checkbox") {
  528. value = target.checked ? "true" : "false";
  529. }
  530. return {
  531. value: value,
  532. values: {},
  533. };
  534. }
  535. case "drag":
  536. case "dragend":
  537. case "dragenter":
  538. case "dragexit":
  539. case "dragleave":
  540. case "dragover":
  541. case "dragstart":
  542. case "drop": {
  543. return { mouse: get_mouse_data(event) };
  544. }
  545. case "click":
  546. case "contextmenu":
  547. case "doubleclick":
  548. case "dblclick":
  549. case "mousedown":
  550. case "mouseenter":
  551. case "mouseleave":
  552. case "mousemove":
  553. case "mouseout":
  554. case "mouseover":
  555. case "mouseup": {
  556. return get_mouse_data(event);
  557. }
  558. case "pointerdown":
  559. case "pointermove":
  560. case "pointerup":
  561. case "pointercancel":
  562. case "gotpointercapture":
  563. case "lostpointercapture":
  564. case "pointerenter":
  565. case "pointerleave":
  566. case "pointerover":
  567. case "pointerout": {
  568. const {
  569. altKey,
  570. button,
  571. buttons,
  572. clientX,
  573. clientY,
  574. ctrlKey,
  575. metaKey,
  576. pageX,
  577. pageY,
  578. screenX,
  579. screenY,
  580. shiftKey,
  581. pointerId,
  582. width,
  583. height,
  584. pressure,
  585. tangentialPressure,
  586. tiltX,
  587. tiltY,
  588. twist,
  589. pointerType,
  590. isPrimary,
  591. } = event;
  592. return {
  593. alt_key: altKey,
  594. button: button,
  595. buttons: buttons,
  596. client_x: clientX,
  597. client_y: clientY,
  598. ctrl_key: ctrlKey,
  599. meta_key: metaKey,
  600. page_x: pageX,
  601. page_y: pageY,
  602. screen_x: screenX,
  603. screen_y: screenY,
  604. shift_key: shiftKey,
  605. pointer_id: pointerId,
  606. width: width,
  607. height: height,
  608. pressure: pressure,
  609. tangential_pressure: tangentialPressure,
  610. tilt_x: tiltX,
  611. tilt_y: tiltY,
  612. twist: twist,
  613. pointer_type: pointerType,
  614. is_primary: isPrimary,
  615. };
  616. }
  617. case "select": {
  618. return {};
  619. }
  620. case "touchcancel":
  621. case "touchend":
  622. case "touchmove":
  623. case "touchstart": {
  624. const { altKey, ctrlKey, metaKey, shiftKey } = event;
  625. return {
  626. // changed_touches: event.changedTouches,
  627. // target_touches: event.targetTouches,
  628. // touches: event.touches,
  629. alt_key: altKey,
  630. ctrl_key: ctrlKey,
  631. meta_key: metaKey,
  632. shift_key: shiftKey,
  633. };
  634. }
  635. case "scroll": {
  636. return {};
  637. }
  638. case "wheel": {
  639. const { deltaX, deltaY, deltaZ, deltaMode } = event;
  640. return {
  641. delta_x: deltaX,
  642. delta_y: deltaY,
  643. delta_z: deltaZ,
  644. delta_mode: deltaMode,
  645. };
  646. }
  647. case "animationstart":
  648. case "animationend":
  649. case "animationiteration": {
  650. const { animationName, elapsedTime, pseudoElement } = event;
  651. return {
  652. animation_name: animationName,
  653. elapsed_time: elapsedTime,
  654. pseudo_element: pseudoElement,
  655. };
  656. }
  657. case "transitionend": {
  658. const { propertyName, elapsedTime, pseudoElement } = event;
  659. return {
  660. property_name: propertyName,
  661. elapsed_time: elapsedTime,
  662. pseudo_element: pseudoElement,
  663. };
  664. }
  665. case "abort":
  666. case "canplay":
  667. case "canplaythrough":
  668. case "durationchange":
  669. case "emptied":
  670. case "encrypted":
  671. case "ended":
  672. case "error":
  673. case "loadeddata":
  674. case "loadedmetadata":
  675. case "loadstart":
  676. case "pause":
  677. case "play":
  678. case "playing":
  679. case "progress":
  680. case "ratechange":
  681. case "seeked":
  682. case "seeking":
  683. case "stalled":
  684. case "suspend":
  685. case "timeupdate":
  686. case "volumechange":
  687. case "waiting": {
  688. return {};
  689. }
  690. case "toggle": {
  691. return {};
  692. }
  693. default: {
  694. return {};
  695. }
  696. }
  697. }
  698. function serializeIpcMessage(method, params = {}) {
  699. return JSON.stringify({ method, params });
  700. }
  701. const bool_attrs = {
  702. allowfullscreen: true,
  703. allowpaymentrequest: true,
  704. async: true,
  705. autofocus: true,
  706. autoplay: true,
  707. checked: true,
  708. controls: true,
  709. default: true,
  710. defer: true,
  711. disabled: true,
  712. formnovalidate: true,
  713. hidden: true,
  714. ismap: true,
  715. itemscope: true,
  716. loop: true,
  717. multiple: true,
  718. muted: true,
  719. nomodule: true,
  720. novalidate: true,
  721. open: true,
  722. playsinline: true,
  723. readonly: true,
  724. required: true,
  725. reversed: true,
  726. selected: true,
  727. truespeed: true,
  728. };
  729. function is_element_node(node) {
  730. return node.nodeType == 1;
  731. }
  732. function event_bubbles(event) {
  733. switch (event) {
  734. case "copy":
  735. return true;
  736. case "cut":
  737. return true;
  738. case "paste":
  739. return true;
  740. case "compositionend":
  741. return true;
  742. case "compositionstart":
  743. return true;
  744. case "compositionupdate":
  745. return true;
  746. case "keydown":
  747. return true;
  748. case "keypress":
  749. return true;
  750. case "keyup":
  751. return true;
  752. case "focus":
  753. return false;
  754. case "focusout":
  755. return true;
  756. case "focusin":
  757. return true;
  758. case "blur":
  759. return false;
  760. case "change":
  761. return true;
  762. case "input":
  763. return true;
  764. case "invalid":
  765. return true;
  766. case "reset":
  767. return true;
  768. case "submit":
  769. return true;
  770. case "click":
  771. return true;
  772. case "contextmenu":
  773. return true;
  774. case "doubleclick":
  775. return true;
  776. case "dblclick":
  777. return true;
  778. case "drag":
  779. return true;
  780. case "dragend":
  781. return true;
  782. case "dragenter":
  783. return false;
  784. case "dragexit":
  785. return false;
  786. case "dragleave":
  787. return true;
  788. case "dragover":
  789. return true;
  790. case "dragstart":
  791. return true;
  792. case "drop":
  793. return true;
  794. case "mousedown":
  795. return true;
  796. case "mouseenter":
  797. return false;
  798. case "mouseleave":
  799. return false;
  800. case "mousemove":
  801. return true;
  802. case "mouseout":
  803. return true;
  804. case "scroll":
  805. return false;
  806. case "mouseover":
  807. return true;
  808. case "mouseup":
  809. return true;
  810. case "pointerdown":
  811. return true;
  812. case "pointermove":
  813. return true;
  814. case "pointerup":
  815. return true;
  816. case "pointercancel":
  817. return true;
  818. case "gotpointercapture":
  819. return true;
  820. case "lostpointercapture":
  821. return true;
  822. case "pointerenter":
  823. return false;
  824. case "pointerleave":
  825. return false;
  826. case "pointerover":
  827. return true;
  828. case "pointerout":
  829. return true;
  830. case "select":
  831. return true;
  832. case "touchcancel":
  833. return true;
  834. case "touchend":
  835. return true;
  836. case "touchmove":
  837. return true;
  838. case "touchstart":
  839. return true;
  840. case "wheel":
  841. return true;
  842. case "abort":
  843. return false;
  844. case "canplay":
  845. return false;
  846. case "canplaythrough":
  847. return false;
  848. case "durationchange":
  849. return false;
  850. case "emptied":
  851. return false;
  852. case "encrypted":
  853. return true;
  854. case "ended":
  855. return false;
  856. case "error":
  857. return false;
  858. case "loadeddata":
  859. case "loadedmetadata":
  860. case "loadstart":
  861. case "load":
  862. return false;
  863. case "pause":
  864. return false;
  865. case "play":
  866. return false;
  867. case "playing":
  868. return false;
  869. case "progress":
  870. return false;
  871. case "ratechange":
  872. return false;
  873. case "seeked":
  874. return false;
  875. case "seeking":
  876. return false;
  877. case "stalled":
  878. return false;
  879. case "suspend":
  880. return false;
  881. case "timeupdate":
  882. return false;
  883. case "volumechange":
  884. return false;
  885. case "waiting":
  886. return false;
  887. case "animationstart":
  888. return true;
  889. case "animationend":
  890. return true;
  891. case "animationiteration":
  892. return true;
  893. case "transitionend":
  894. return true;
  895. case "toggle":
  896. return true;
  897. }
  898. return true;
  899. }