001package Torello.Browser; 002 003import java.util.*; 004import javax.json.*; 005import javax.json.stream.*; 006import java.io.*; 007 008import java.lang.reflect.Method; 009import java.lang.reflect.Parameter; 010import java.util.function.Function; 011 012import Torello.Java.Additional.*; 013import Torello.Java.JSON.*; 014 015import static Torello.Java.JSON.JFlag.*; 016 017import Torello.Java.StrCmpr; 018import Torello.JavaDoc.StaticFunctional; 019import Torello.JavaDoc.JDHeaderBackgroundImg; 020import Torello.JavaDoc.Excuse; 021 022/** 023 * <SPAN CLASS=COPIEDJDK><B><CODE>[No Description Provided by Google]</CODE></B></SPAN> 024 * 025 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 026 */ 027@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 028@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 029public class Input 030{ 031 // ******************************************************************************************** 032 // ******************************************************************************************** 033 // Class Header Stuff 034 // ******************************************************************************************** 035 // ******************************************************************************************** 036 037 038 // No Pubic Constructors 039 private Input () { } 040 041 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 042 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 043 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 044 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 045 046 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 047 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 048 // offically, two empty-vectors. One for String's, and the other for Classes. 049 050 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 051 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 052 053 static 054 { 055 for (Method m : Input.class.getMethods()) 056 { 057 // This doesn't work! The parameter names are all "arg0" ... "argN" 058 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 059 // 060 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 061 062 Vector<Class<?>> parameterTypesList = new Vector<>(); 063 064 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 065 066 parameterTypes.put( 067 m.getName(), 068 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 069 ); 070 } 071 } 072 073 static 074 { 075 Vector<String> v = null; 076 077 v = new Vector<String>(5); 078 parameterNames.put("dispatchDragEvent", v); 079 Collections.addAll(v, new String[] 080 { "type", "x", "y", "data", "modifiers", }); 081 082 v = new Vector<String>(15); 083 parameterNames.put("dispatchKeyEvent", v); 084 Collections.addAll(v, new String[] 085 { "type", "modifiers", "timestamp", "text", "unmodifiedText", "keyIdentifier", "code", "key", "windowsVirtualKeyCode", "nativeVirtualKeyCode", "autoRepeat", "isKeypad", "isSystemKey", "location", "commands", }); 086 087 v = new Vector<String>(1); 088 parameterNames.put("insertText", v); 089 Collections.addAll(v, new String[] 090 { "text", }); 091 092 v = new Vector<String>(5); 093 parameterNames.put("imeSetComposition", v); 094 Collections.addAll(v, new String[] 095 { "text", "selectionStart", "selectionEnd", "replacementStart", "replacementEnd", }); 096 097 v = new Vector<String>(16); 098 parameterNames.put("dispatchMouseEvent", v); 099 Collections.addAll(v, new String[] 100 { "type", "x", "y", "modifiers", "timestamp", "button", "buttons", "clickCount", "force", "tangentialPressure", "tiltX", "tiltY", "twist", "deltaX", "deltaY", "pointerType", }); 101 102 v = new Vector<String>(4); 103 parameterNames.put("dispatchTouchEvent", v); 104 Collections.addAll(v, new String[] 105 { "type", "touchPoints", "modifiers", "timestamp", }); 106 107 v = new Vector<String>(9); 108 parameterNames.put("emulateTouchFromMouseEvent", v); 109 Collections.addAll(v, new String[] 110 { "type", "x", "y", "button", "timestamp", "deltaX", "deltaY", "modifiers", "clickCount", }); 111 112 v = new Vector<String>(1); 113 parameterNames.put("setIgnoreInputEvents", v); 114 Collections.addAll(v, new String[] 115 { "ignore", }); 116 117 v = new Vector<String>(1); 118 parameterNames.put("setInterceptDrags", v); 119 Collections.addAll(v, new String[] 120 { "enabled", }); 121 122 v = new Vector<String>(5); 123 parameterNames.put("synthesizePinchGesture", v); 124 Collections.addAll(v, new String[] 125 { "x", "y", "scaleFactor", "relativeSpeed", "gestureSourceType", }); 126 127 v = new Vector<String>(12); 128 parameterNames.put("synthesizeScrollGesture", v); 129 Collections.addAll(v, new String[] 130 { "x", "y", "xDistance", "yDistance", "xOverscroll", "yOverscroll", "preventFling", "speed", "gestureSourceType", "repeatCount", "repeatDelayMs", "interactionMarkerName", }); 131 132 v = new Vector<String>(5); 133 parameterNames.put("synthesizeTapGesture", v); 134 Collections.addAll(v, new String[] 135 { "x", "y", "duration", "tapCount", "gestureSourceType", }); 136 } 137 138 139 // ******************************************************************************************** 140 // ******************************************************************************************** 141 // Types - Static Inner Classes 142 // ******************************************************************************************** 143 // ******************************************************************************************** 144 145 // public static class TimeSinceEpoch => Number 146 147 /** 148 * <CODE>[No Description Provided by Google]</CODE> 149 * <BR /> 150 * <BR /><B>EXPERIMENTAL</B> 151 */ 152 public static final String[] GestureSourceType = 153 { "default", "touch", "mouse", }; 154 155 /** <CODE>[No Description Provided by Google]</CODE> */ 156 public static final String[] MouseButton = 157 { "none", "left", "middle", "right", "back", "forward", }; 158 159 /** <CODE>[No Description Provided by Google]</CODE> */ 160 public static class TouchPoint 161 extends BaseType 162 implements java.io.Serializable 163 { 164 /** For Object Serialization. java.io.Serializable */ 165 protected static final long serialVersionUID = 1; 166 167 public boolean[] optionals() 168 { return new boolean[] { false, false, true, true, true, true, true, true, true, true, true, }; } 169 170 /** X coordinate of the event relative to the main frame's viewport in CSS pixels. */ 171 public final Number x; 172 173 /** 174 * Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to 175 * the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. 176 */ 177 public final Number y; 178 179 /** 180 * X radius of the touch area (default: 1.0). 181 * <BR /> 182 * <BR /><B>OPTIONAL</B> 183 */ 184 public final Number radiusX; 185 186 /** 187 * Y radius of the touch area (default: 1.0). 188 * <BR /> 189 * <BR /><B>OPTIONAL</B> 190 */ 191 public final Number radiusY; 192 193 /** 194 * Rotation angle (default: 0.0). 195 * <BR /> 196 * <BR /><B>OPTIONAL</B> 197 */ 198 public final Number rotationAngle; 199 200 /** 201 * Force (default: 1.0). 202 * <BR /> 203 * <BR /><B>OPTIONAL</B> 204 */ 205 public final Number force; 206 207 /** 208 * The normalized tangential pressure, which has a range of [-1,1] (default: 0). 209 * <BR /> 210 * <BR /><B>OPTIONAL</B> 211 * <BR /><B>EXPERIMENTAL</B> 212 */ 213 public final Number tangentialPressure; 214 215 /** 216 * The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0) 217 * <BR /> 218 * <BR /><B>OPTIONAL</B> 219 * <BR /><B>EXPERIMENTAL</B> 220 */ 221 public final Integer tiltX; 222 223 /** 224 * The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0). 225 * <BR /> 226 * <BR /><B>OPTIONAL</B> 227 * <BR /><B>EXPERIMENTAL</B> 228 */ 229 public final Integer tiltY; 230 231 /** 232 * The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0). 233 * <BR /> 234 * <BR /><B>OPTIONAL</B> 235 * <BR /><B>EXPERIMENTAL</B> 236 */ 237 public final Integer twist; 238 239 /** 240 * Identifier used to track touch sources between events, must be unique within an event. 241 * <BR /> 242 * <BR /><B>OPTIONAL</B> 243 */ 244 public final Number id; 245 246 /** 247 * Constructor 248 * 249 * @param x X coordinate of the event relative to the main frame's viewport in CSS pixels. 250 * 251 * @param y 252 * Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to 253 * the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. 254 * 255 * @param radiusX X radius of the touch area (default: 1.0). 256 * <BR /><B>OPTIONAL</B> 257 * 258 * @param radiusY Y radius of the touch area (default: 1.0). 259 * <BR /><B>OPTIONAL</B> 260 * 261 * @param rotationAngle Rotation angle (default: 0.0). 262 * <BR /><B>OPTIONAL</B> 263 * 264 * @param force Force (default: 1.0). 265 * <BR /><B>OPTIONAL</B> 266 * 267 * @param tangentialPressure The normalized tangential pressure, which has a range of [-1,1] (default: 0). 268 * <BR /><B>OPTIONAL</B> 269 * <BR /><B>EXPERIMENTAL</B> 270 * 271 * @param tiltX The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0) 272 * <BR /><B>OPTIONAL</B> 273 * <BR /><B>EXPERIMENTAL</B> 274 * 275 * @param tiltY The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0). 276 * <BR /><B>OPTIONAL</B> 277 * <BR /><B>EXPERIMENTAL</B> 278 * 279 * @param twist The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0). 280 * <BR /><B>OPTIONAL</B> 281 * <BR /><B>EXPERIMENTAL</B> 282 * 283 * @param id Identifier used to track touch sources between events, must be unique within an event. 284 * <BR /><B>OPTIONAL</B> 285 */ 286 public TouchPoint( 287 Number x, Number y, Number radiusX, Number radiusY, Number rotationAngle, 288 Number force, Number tangentialPressure, Integer tiltX, Integer tiltY, 289 Integer twist, Number id 290 ) 291 { 292 // Exception-Check(s) to ensure that if any parameters which are not declared as 293 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 294 295 if (x == null) THROWS.throwNPE("x"); 296 if (y == null) THROWS.throwNPE("y"); 297 298 this.x = x; 299 this.y = y; 300 this.radiusX = radiusX; 301 this.radiusY = radiusY; 302 this.rotationAngle = rotationAngle; 303 this.force = force; 304 this.tangentialPressure = tangentialPressure; 305 this.tiltX = tiltX; 306 this.tiltY = tiltY; 307 this.twist = twist; 308 this.id = id; 309 } 310 311 /** 312 * JSON Object Constructor 313 * @param jo A Json-Object having data about an instance of {@code 'TouchPoint'}. 314 */ 315 public TouchPoint (JsonObject jo) 316 { 317 this.x = ReadNumberJSON.get(jo, "x", false, true); 318 this.y = ReadNumberJSON.get(jo, "y", false, true); 319 this.radiusX = ReadNumberJSON.get(jo, "radiusX", true, false); 320 this.radiusY = ReadNumberJSON.get(jo, "radiusY", true, false); 321 this.rotationAngle = ReadNumberJSON.get(jo, "rotationAngle", true, false); 322 this.force = ReadNumberJSON.get(jo, "force", true, false); 323 this.tangentialPressure = ReadNumberJSON.get(jo, "tangentialPressure", true, false); 324 this.tiltX = ReadBoxedJSON.getInteger(jo, "tiltX", true); 325 this.tiltY = ReadBoxedJSON.getInteger(jo, "tiltY", true); 326 this.twist = ReadBoxedJSON.getInteger(jo, "twist", true); 327 this.id = ReadNumberJSON.get(jo, "id", true, false); 328 } 329 330 331 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 332 public boolean equals(Object other) 333 { 334 if (this == other) return true; 335 if (other == null) return false; 336 if (other.getClass() != this.getClass()) return false; 337 338 TouchPoint o = (TouchPoint) other; 339 340 return 341 Objects.equals(this.x, o.x) 342 && Objects.equals(this.y, o.y) 343 && Objects.equals(this.radiusX, o.radiusX) 344 && Objects.equals(this.radiusY, o.radiusY) 345 && Objects.equals(this.rotationAngle, o.rotationAngle) 346 && Objects.equals(this.force, o.force) 347 && Objects.equals(this.tangentialPressure, o.tangentialPressure) 348 && Objects.equals(this.tiltX, o.tiltX) 349 && Objects.equals(this.tiltY, o.tiltY) 350 && Objects.equals(this.twist, o.twist) 351 && Objects.equals(this.id, o.id); 352 } 353 354 /** Generates a Hash-Code for {@code 'this'} instance */ 355 public int hashCode() 356 { 357 return 358 Objects.hashCode(this.x) 359 + Objects.hashCode(this.y) 360 + Objects.hashCode(this.radiusX) 361 + Objects.hashCode(this.radiusY) 362 + Objects.hashCode(this.rotationAngle) 363 + Objects.hashCode(this.force) 364 + Objects.hashCode(this.tangentialPressure) 365 + Objects.hashCode(this.tiltX) 366 + Objects.hashCode(this.tiltY) 367 + Objects.hashCode(this.twist) 368 + Objects.hashCode(this.id); 369 } 370 } 371 372 /** 373 * <CODE>[No Description Provided by Google]</CODE> 374 * <BR /> 375 * <BR /><B>EXPERIMENTAL</B> 376 */ 377 public static class DragDataItem 378 extends BaseType 379 implements java.io.Serializable 380 { 381 /** For Object Serialization. java.io.Serializable */ 382 protected static final long serialVersionUID = 1; 383 384 public boolean[] optionals() 385 { return new boolean[] { false, false, true, true, }; } 386 387 /** Mime type of the dragged data. */ 388 public final String mimeType; 389 390 /** 391 * Depending of the value of <CODE>mimeType</CODE>, it contains the dragged link, 392 * text, HTML markup or any other data. 393 */ 394 public final String data; 395 396 /** 397 * Title associated with a link. Only valid when <CODE>mimeType</CODE> == "text/uri-list". 398 * <BR /> 399 * <BR /><B>OPTIONAL</B> 400 */ 401 public final String title; 402 403 /** 404 * Stores the base URL for the contained markup. Only valid when <CODE>mimeType</CODE> 405 * == "text/html". 406 * <BR /> 407 * <BR /><B>OPTIONAL</B> 408 */ 409 public final String baseURL; 410 411 /** 412 * Constructor 413 * 414 * @param mimeType Mime type of the dragged data. 415 * 416 * @param data 417 * Depending of the value of <CODE>mimeType</CODE>, it contains the dragged link, 418 * text, HTML markup or any other data. 419 * 420 * @param title Title associated with a link. Only valid when <CODE>mimeType</CODE> == "text/uri-list". 421 * <BR /><B>OPTIONAL</B> 422 * 423 * @param baseURL 424 * Stores the base URL for the contained markup. Only valid when <CODE>mimeType</CODE> 425 * == "text/html". 426 * <BR /><B>OPTIONAL</B> 427 */ 428 public DragDataItem(String mimeType, String data, String title, String baseURL) 429 { 430 // Exception-Check(s) to ensure that if any parameters which are not declared as 431 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 432 433 if (mimeType == null) THROWS.throwNPE("mimeType"); 434 if (data == null) THROWS.throwNPE("data"); 435 436 this.mimeType = mimeType; 437 this.data = data; 438 this.title = title; 439 this.baseURL = baseURL; 440 } 441 442 /** 443 * JSON Object Constructor 444 * @param jo A Json-Object having data about an instance of {@code 'DragDataItem'}. 445 */ 446 public DragDataItem (JsonObject jo) 447 { 448 this.mimeType = ReadJSON.getString(jo, "mimeType", false, true); 449 this.data = ReadJSON.getString(jo, "data", false, true); 450 this.title = ReadJSON.getString(jo, "title", true, false); 451 this.baseURL = ReadJSON.getString(jo, "baseURL", true, false); 452 } 453 454 455 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 456 public boolean equals(Object other) 457 { 458 if (this == other) return true; 459 if (other == null) return false; 460 if (other.getClass() != this.getClass()) return false; 461 462 DragDataItem o = (DragDataItem) other; 463 464 return 465 Objects.equals(this.mimeType, o.mimeType) 466 && Objects.equals(this.data, o.data) 467 && Objects.equals(this.title, o.title) 468 && Objects.equals(this.baseURL, o.baseURL); 469 } 470 471 /** Generates a Hash-Code for {@code 'this'} instance */ 472 public int hashCode() 473 { 474 return 475 Objects.hashCode(this.mimeType) 476 + Objects.hashCode(this.data) 477 + Objects.hashCode(this.title) 478 + Objects.hashCode(this.baseURL); 479 } 480 } 481 482 /** 483 * <CODE>[No Description Provided by Google]</CODE> 484 * <BR /> 485 * <BR /><B>EXPERIMENTAL</B> 486 */ 487 public static class DragData 488 extends BaseType 489 implements java.io.Serializable 490 { 491 /** For Object Serialization. java.io.Serializable */ 492 protected static final long serialVersionUID = 1; 493 494 public boolean[] optionals() 495 { return new boolean[] { false, true, false, }; } 496 497 /** <CODE>[No Description Provided by Google]</CODE> */ 498 public final Input.DragDataItem[] items; 499 500 /** 501 * List of filenames that should be included when dropping 502 * <BR /> 503 * <BR /><B>OPTIONAL</B> 504 */ 505 public final String[] files; 506 507 /** Bit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16 */ 508 public final int dragOperationsMask; 509 510 /** 511 * Constructor 512 * 513 * @param items - 514 * 515 * @param files List of filenames that should be included when dropping 516 * <BR /><B>OPTIONAL</B> 517 * 518 * @param dragOperationsMask Bit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16 519 */ 520 public DragData(Input.DragDataItem[] items, String[] files, int dragOperationsMask) 521 { 522 // Exception-Check(s) to ensure that if any parameters which are not declared as 523 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 524 525 if (items == null) THROWS.throwNPE("items"); 526 527 this.items = items; 528 this.files = files; 529 this.dragOperationsMask = dragOperationsMask; 530 } 531 532 /** 533 * JSON Object Constructor 534 * @param jo A Json-Object having data about an instance of {@code 'DragData'}. 535 */ 536 public DragData (JsonObject jo) 537 { 538 this.items = (jo.getJsonArray("items") == null) 539 ? null 540 : RJArrIntoStream.objArr(jo.getJsonArray("items"), null, 0, Input.DragDataItem.class).toArray(Input.DragDataItem[]::new); 541 542 this.files = (jo.getJsonArray("files") == null) 543 ? null 544 : RJArrIntoStream.strArr(jo.getJsonArray("files"), null, 0).toArray(String[]::new); 545 546 this.dragOperationsMask = ReadPrimJSON.getInt(jo, "dragOperationsMask"); 547 } 548 549 550 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 551 public boolean equals(Object other) 552 { 553 if (this == other) return true; 554 if (other == null) return false; 555 if (other.getClass() != this.getClass()) return false; 556 557 DragData o = (DragData) other; 558 559 return 560 Arrays.deepEquals(this.items, o.items) 561 && Arrays.deepEquals(this.files, o.files) 562 && (this.dragOperationsMask == o.dragOperationsMask); 563 } 564 565 /** Generates a Hash-Code for {@code 'this'} instance */ 566 public int hashCode() 567 { 568 return 569 Arrays.deepHashCode(this.items) 570 + Arrays.deepHashCode(this.files) 571 + this.dragOperationsMask; 572 } 573 } 574 575 /** 576 * Emitted only when <CODE>Input.setInterceptDrags</CODE> is enabled. Use this data with <CODE>Input.dispatchDragEvent</CODE> to 577 * restore normal drag and drop behavior. 578 * <BR /> 579 * <BR /><B>EXPERIMENTAL</B> 580 */ 581 public static class dragIntercepted 582 extends BrowserEvent 583 implements java.io.Serializable 584 { 585 /** For Object Serialization. java.io.Serializable */ 586 protected static final long serialVersionUID = 1; 587 588 public boolean[] optionals() 589 { return new boolean[] { false, }; } 590 591 /** <CODE>[No Description Provided by Google]</CODE> */ 592 public final Input.DragData data; 593 594 /** 595 * Constructor 596 * 597 * @param data - 598 */ 599 public dragIntercepted(Input.DragData data) 600 { 601 super("Input", "dragIntercepted", 1); 602 603 // Exception-Check(s) to ensure that if any parameters which are not declared as 604 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 605 606 if (data == null) THROWS.throwNPE("data"); 607 608 this.data = data; 609 } 610 611 /** 612 * JSON Object Constructor 613 * @param jo A Json-Object having data about an instance of {@code 'dragIntercepted'}. 614 */ 615 public dragIntercepted (JsonObject jo) 616 { 617 super("Input", "dragIntercepted", 1); 618 619 this.data = ReadJSON.getObject(jo, "data", Input.DragData.class, false, true); 620 } 621 622 623 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 624 public boolean equals(Object other) 625 { 626 if (this == other) return true; 627 if (other == null) return false; 628 if (other.getClass() != this.getClass()) return false; 629 630 dragIntercepted o = (dragIntercepted) other; 631 632 return 633 Objects.equals(this.data, o.data); 634 } 635 636 /** Generates a Hash-Code for {@code 'this'} instance */ 637 public int hashCode() 638 { 639 return 640 this.data.hashCode(); 641 } 642 } 643 644 645 // Counter for keeping the WebSocket Request ID's distinct. 646 private static int counter = 1; 647 648 /** 649 * Dispatches a drag event into the page. 650 * <BR /><B>EXPERIMENTAL</B> 651 * 652 * @param type Type of the drag event. 653 * <BR />Acceptable Values: ["dragEnter", "dragOver", "drop", "dragCancel"] 654 * 655 * @param x X coordinate of the event relative to the main frame's viewport in CSS pixels. 656 * 657 * @param y 658 * Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to 659 * the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. 660 * 661 * @param data - 662 * 663 * @param modifiers 664 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 665 * (default: 0). 666 * <BR /><B>OPTIONAL</B> 667 * 668 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 669 * {@link Ret0}></CODE> 670 * 671 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 672 * browser receives the invocation-request. 673 * 674 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 675 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 676 * {@code >} to ensure the Browser Function has run to completion. 677 */ 678 public static Script<String, JsonObject, Ret0> dispatchDragEvent 679 (String type, Number x, Number y, Input.DragData data, Integer modifiers) 680 { 681 // Exception-Check(s) to ensure that if any parameters which are not declared as 682 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 683 684 if (type == null) THROWS.throwNPE("type"); 685 if (x == null) THROWS.throwNPE("x"); 686 if (y == null) THROWS.throwNPE("y"); 687 if (data == null) THROWS.throwNPE("data"); 688 689 // Exception-Check(s) to ensure that if any parameters which must adhere to a 690 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 691 692 THROWS.checkIAE( 693 "type", type, 694 "dragEnter", "dragOver", "drop", "dragCancel" 695 ); 696 697 final int webSocketID = 25000000 + counter++; 698 final boolean[] optionals = { false, false, false, false, true, }; 699 700 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 701 String requestJSON = WriteJSON.get( 702 parameterTypes.get("dispatchDragEvent"), 703 parameterNames.get("dispatchDragEvent"), 704 optionals, webSocketID, 705 "Input.dispatchDragEvent", 706 type, x, y, data, modifiers 707 ); 708 709 // This Remote Command does not have a Return-Value. 710 return new Script<> 711 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 712 } 713 714 /** 715 * Dispatches a key event to the page. 716 * 717 * @param type Type of the key event. 718 * <BR />Acceptable Values: ["keyDown", "keyUp", "rawKeyDown", "char"] 719 * 720 * @param modifiers 721 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 722 * (default: 0). 723 * <BR /><B>OPTIONAL</B> 724 * 725 * @param timestamp Time at which the event occurred. 726 * <BR /><B>OPTIONAL</B> 727 * 728 * @param text 729 * Text as generated by processing a virtual key code with a keyboard layout. Not needed for 730 * for <CODE>keyUp</CODE> and <CODE>rawKeyDown</CODE> events (default: "") 731 * <BR /><B>OPTIONAL</B> 732 * 733 * @param unmodifiedText 734 * Text that would have been generated by the keyboard if no modifiers were pressed (except for 735 * shift). Useful for shortcut (accelerator) key handling (default: ""). 736 * <BR /><B>OPTIONAL</B> 737 * 738 * @param keyIdentifier Unique key identifier (e.g., 'U+0041') (default: ""). 739 * <BR /><B>OPTIONAL</B> 740 * 741 * @param code Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: ""). 742 * <BR /><B>OPTIONAL</B> 743 * 744 * @param key 745 * Unique DOM defined string value describing the meaning of the key in the context of active 746 * modifiers, keyboard layout, etc (e.g., 'AltGr') (default: ""). 747 * <BR /><B>OPTIONAL</B> 748 * 749 * @param windowsVirtualKeyCode Windows virtual key code (default: 0). 750 * <BR /><B>OPTIONAL</B> 751 * 752 * @param nativeVirtualKeyCode Native virtual key code (default: 0). 753 * <BR /><B>OPTIONAL</B> 754 * 755 * @param autoRepeat Whether the event was generated from auto repeat (default: false). 756 * <BR /><B>OPTIONAL</B> 757 * 758 * @param isKeypad Whether the event was generated from the keypad (default: false). 759 * <BR /><B>OPTIONAL</B> 760 * 761 * @param isSystemKey Whether the event was a system key event (default: false). 762 * <BR /><B>OPTIONAL</B> 763 * 764 * @param location 765 * Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 766 * 0). 767 * <BR /><B>OPTIONAL</B> 768 * 769 * @param commands 770 * Editing commands to send with the key event (e.g., 'selectAll') (default: []). 771 * These are related to but not equal the command names used in <CODE>document.execCommand</CODE> and NSStandardKeyBindingResponding. 772 * See https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names. 773 * <BR /><B>OPTIONAL</B> 774 * <BR /><B>EXPERIMENTAL</B> 775 * 776 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 777 * {@link Ret0}></CODE> 778 * 779 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 780 * browser receives the invocation-request. 781 * 782 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 783 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 784 * {@code >} to ensure the Browser Function has run to completion. 785 */ 786 public static Script<String, JsonObject, Ret0> dispatchKeyEvent( 787 String type, Integer modifiers, Number timestamp, String text, String unmodifiedText, 788 String keyIdentifier, String code, String key, Integer windowsVirtualKeyCode, 789 Integer nativeVirtualKeyCode, Boolean autoRepeat, Boolean isKeypad, Boolean isSystemKey, 790 Integer location, String[] commands 791 ) 792 { 793 // Exception-Check(s) to ensure that if any parameters which are not declared as 794 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 795 796 if (type == null) THROWS.throwNPE("type"); 797 798 // Exception-Check(s) to ensure that if any parameters which must adhere to a 799 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 800 801 THROWS.checkIAE( 802 "type", type, 803 "keyDown", "keyUp", "rawKeyDown", "char" 804 ); 805 806 final int webSocketID = 25001000 + counter++; 807 final boolean[] optionals = { false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, }; 808 809 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 810 String requestJSON = WriteJSON.get( 811 parameterTypes.get("dispatchKeyEvent"), 812 parameterNames.get("dispatchKeyEvent"), 813 optionals, webSocketID, 814 "Input.dispatchKeyEvent", 815 type, modifiers, timestamp, text, unmodifiedText, keyIdentifier, code, key, 816 windowsVirtualKeyCode, nativeVirtualKeyCode, autoRepeat, isKeypad, isSystemKey, 817 location, commands 818 ); 819 820 // This Remote Command does not have a Return-Value. 821 return new Script<> 822 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 823 } 824 825 /** 826 * This method emulates inserting text that doesn't come from a key press, 827 * for example an emoji keyboard or an IME. 828 * <BR /><B>EXPERIMENTAL</B> 829 * 830 * @param text The text to insert. 831 * 832 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 833 * {@link Ret0}></CODE> 834 * 835 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 836 * browser receives the invocation-request. 837 * 838 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 839 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 840 * {@code >} to ensure the Browser Function has run to completion. 841 */ 842 public static Script<String, JsonObject, Ret0> insertText(String text) 843 { 844 // Exception-Check(s) to ensure that if any parameters which are not declared as 845 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 846 847 if (text == null) THROWS.throwNPE("text"); 848 849 final int webSocketID = 25002000 + counter++; 850 final boolean[] optionals = { false, }; 851 852 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 853 String requestJSON = WriteJSON.get( 854 parameterTypes.get("insertText"), 855 parameterNames.get("insertText"), 856 optionals, webSocketID, 857 "Input.insertText", 858 text 859 ); 860 861 // This Remote Command does not have a Return-Value. 862 return new Script<> 863 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 864 } 865 866 /** 867 * This method sets the current candidate text for ime. 868 * Use imeCommitComposition to commit the final text. 869 * Use imeSetComposition with empty string as text to cancel composition. 870 * <BR /><B>EXPERIMENTAL</B> 871 * 872 * @param text The text to insert 873 * 874 * @param selectionStart selection start 875 * 876 * @param selectionEnd selection end 877 * 878 * @param replacementStart replacement start 879 * <BR /><B>OPTIONAL</B> 880 * 881 * @param replacementEnd replacement end 882 * <BR /><B>OPTIONAL</B> 883 * 884 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 885 * {@link Ret0}></CODE> 886 * 887 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 888 * browser receives the invocation-request. 889 * 890 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 891 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 892 * {@code >} to ensure the Browser Function has run to completion. 893 */ 894 public static Script<String, JsonObject, Ret0> imeSetComposition( 895 String text, int selectionStart, int selectionEnd, Integer replacementStart, 896 Integer replacementEnd 897 ) 898 { 899 // Exception-Check(s) to ensure that if any parameters which are not declared as 900 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 901 902 if (text == null) THROWS.throwNPE("text"); 903 904 final int webSocketID = 25003000 + counter++; 905 final boolean[] optionals = { false, false, false, true, true, }; 906 907 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 908 String requestJSON = WriteJSON.get( 909 parameterTypes.get("imeSetComposition"), 910 parameterNames.get("imeSetComposition"), 911 optionals, webSocketID, 912 "Input.imeSetComposition", 913 text, selectionStart, selectionEnd, replacementStart, replacementEnd 914 ); 915 916 // This Remote Command does not have a Return-Value. 917 return new Script<> 918 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 919 } 920 921 /** 922 * Dispatches a mouse event to the page. 923 * 924 * @param type Type of the mouse event. 925 * <BR />Acceptable Values: ["mousePressed", "mouseReleased", "mouseMoved", "mouseWheel"] 926 * 927 * @param x X coordinate of the event relative to the main frame's viewport in CSS pixels. 928 * 929 * @param y 930 * Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to 931 * the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. 932 * 933 * @param modifiers 934 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 935 * (default: 0). 936 * <BR /><B>OPTIONAL</B> 937 * 938 * @param timestamp Time at which the event occurred. 939 * <BR /><B>OPTIONAL</B> 940 * 941 * @param button Mouse button (default: "none"). 942 * <BR /><B>OPTIONAL</B> 943 * 944 * @param buttons 945 * A number indicating which buttons are pressed on the mouse when a mouse event is triggered. 946 * Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0. 947 * <BR /><B>OPTIONAL</B> 948 * 949 * @param clickCount Number of times the mouse button was clicked (default: 0). 950 * <BR /><B>OPTIONAL</B> 951 * 952 * @param force The normalized pressure, which has a range of [0,1] (default: 0). 953 * <BR /><B>OPTIONAL</B> 954 * <BR /><B>EXPERIMENTAL</B> 955 * 956 * @param tangentialPressure The normalized tangential pressure, which has a range of [-1,1] (default: 0). 957 * <BR /><B>OPTIONAL</B> 958 * <BR /><B>EXPERIMENTAL</B> 959 * 960 * @param tiltX The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0). 961 * <BR /><B>OPTIONAL</B> 962 * <BR /><B>EXPERIMENTAL</B> 963 * 964 * @param tiltY The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0). 965 * <BR /><B>OPTIONAL</B> 966 * <BR /><B>EXPERIMENTAL</B> 967 * 968 * @param twist The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0). 969 * <BR /><B>OPTIONAL</B> 970 * <BR /><B>EXPERIMENTAL</B> 971 * 972 * @param deltaX X delta in CSS pixels for mouse wheel event (default: 0). 973 * <BR /><B>OPTIONAL</B> 974 * 975 * @param deltaY Y delta in CSS pixels for mouse wheel event (default: 0). 976 * <BR /><B>OPTIONAL</B> 977 * 978 * @param pointerType Pointer type (default: "mouse"). 979 * <BR />Acceptable Values: ["mouse", "pen"] 980 * <BR /><B>OPTIONAL</B> 981 * 982 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 983 * {@link Ret0}></CODE> 984 * 985 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 986 * browser receives the invocation-request. 987 * 988 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 989 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 990 * {@code >} to ensure the Browser Function has run to completion. 991 */ 992 public static Script<String, JsonObject, Ret0> dispatchMouseEvent( 993 String type, Number x, Number y, Integer modifiers, Number timestamp, String button, 994 Integer buttons, Integer clickCount, Number force, Number tangentialPressure, 995 Integer tiltX, Integer tiltY, Integer twist, Number deltaX, Number deltaY, 996 String pointerType 997 ) 998 { 999 // Exception-Check(s) to ensure that if any parameters which are not declared as 1000 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1001 1002 if (type == null) THROWS.throwNPE("type"); 1003 if (x == null) THROWS.throwNPE("x"); 1004 if (y == null) THROWS.throwNPE("y"); 1005 1006 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1007 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1008 1009 THROWS.checkIAE( 1010 "type", type, 1011 "mousePressed", "mouseReleased", "mouseMoved", "mouseWheel" 1012 ); 1013 THROWS.checkIAE("button", button, "Input.MouseButton", Input.MouseButton); 1014 THROWS.checkIAE( 1015 "pointerType", pointerType, 1016 "mouse", "pen" 1017 ); 1018 1019 final int webSocketID = 25004000 + counter++; 1020 final boolean[] optionals = { false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, }; 1021 1022 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1023 String requestJSON = WriteJSON.get( 1024 parameterTypes.get("dispatchMouseEvent"), 1025 parameterNames.get("dispatchMouseEvent"), 1026 optionals, webSocketID, 1027 "Input.dispatchMouseEvent", 1028 type, x, y, modifiers, timestamp, button, buttons, clickCount, force, 1029 tangentialPressure, tiltX, tiltY, twist, deltaX, deltaY, pointerType 1030 ); 1031 1032 // This Remote Command does not have a Return-Value. 1033 return new Script<> 1034 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1035 } 1036 1037 /** 1038 * Dispatches a touch event to the page. 1039 * 1040 * @param type 1041 * Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while 1042 * TouchStart and TouchMove must contains at least one. 1043 * <BR />Acceptable Values: ["touchStart", "touchEnd", "touchMove", "touchCancel"] 1044 * 1045 * @param touchPoints 1046 * Active touch points on the touch device. One event per any changed point (compared to 1047 * previous touch event in a sequence) is generated, emulating pressing/moving/releasing points 1048 * one by one. 1049 * 1050 * @param modifiers 1051 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 1052 * (default: 0). 1053 * <BR /><B>OPTIONAL</B> 1054 * 1055 * @param timestamp Time at which the event occurred. 1056 * <BR /><B>OPTIONAL</B> 1057 * 1058 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1059 * {@link Ret0}></CODE> 1060 * 1061 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1062 * browser receives the invocation-request. 1063 * 1064 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1065 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1066 * {@code >} to ensure the Browser Function has run to completion. 1067 */ 1068 public static Script<String, JsonObject, Ret0> dispatchTouchEvent 1069 (String type, Input.TouchPoint[] touchPoints, Integer modifiers, Number timestamp) 1070 { 1071 // Exception-Check(s) to ensure that if any parameters which are not declared as 1072 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1073 1074 if (type == null) THROWS.throwNPE("type"); 1075 if (touchPoints == null) THROWS.throwNPE("touchPoints"); 1076 1077 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1078 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1079 1080 THROWS.checkIAE( 1081 "type", type, 1082 "touchStart", "touchEnd", "touchMove", "touchCancel" 1083 ); 1084 1085 final int webSocketID = 25005000 + counter++; 1086 final boolean[] optionals = { false, false, true, true, }; 1087 1088 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1089 String requestJSON = WriteJSON.get( 1090 parameterTypes.get("dispatchTouchEvent"), 1091 parameterNames.get("dispatchTouchEvent"), 1092 optionals, webSocketID, 1093 "Input.dispatchTouchEvent", 1094 type, touchPoints, modifiers, timestamp 1095 ); 1096 1097 // This Remote Command does not have a Return-Value. 1098 return new Script<> 1099 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1100 } 1101 1102 /** 1103 * Emulates touch event from the mouse event parameters. 1104 * <BR /><B>EXPERIMENTAL</B> 1105 * 1106 * @param type Type of the mouse event. 1107 * <BR />Acceptable Values: ["mousePressed", "mouseReleased", "mouseMoved", "mouseWheel"] 1108 * 1109 * @param x X coordinate of the mouse pointer in DIP. 1110 * 1111 * @param y Y coordinate of the mouse pointer in DIP. 1112 * 1113 * @param button Mouse button. Only "none", "left", "right" are supported. 1114 * 1115 * @param timestamp Time at which the event occurred (default: current time). 1116 * <BR /><B>OPTIONAL</B> 1117 * 1118 * @param deltaX X delta in DIP for mouse wheel event (default: 0). 1119 * <BR /><B>OPTIONAL</B> 1120 * 1121 * @param deltaY Y delta in DIP for mouse wheel event (default: 0). 1122 * <BR /><B>OPTIONAL</B> 1123 * 1124 * @param modifiers 1125 * Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 1126 * (default: 0). 1127 * <BR /><B>OPTIONAL</B> 1128 * 1129 * @param clickCount Number of times the mouse button was clicked (default: 0). 1130 * <BR /><B>OPTIONAL</B> 1131 * 1132 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1133 * {@link Ret0}></CODE> 1134 * 1135 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1136 * browser receives the invocation-request. 1137 * 1138 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1139 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1140 * {@code >} to ensure the Browser Function has run to completion. 1141 */ 1142 public static Script<String, JsonObject, Ret0> emulateTouchFromMouseEvent( 1143 String type, int x, int y, String button, Number timestamp, Number deltaX, 1144 Number deltaY, Integer modifiers, Integer clickCount 1145 ) 1146 { 1147 // Exception-Check(s) to ensure that if any parameters which are not declared as 1148 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1149 1150 if (type == null) THROWS.throwNPE("type"); 1151 if (button == null) THROWS.throwNPE("button"); 1152 1153 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1154 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1155 1156 THROWS.checkIAE( 1157 "type", type, 1158 "mousePressed", "mouseReleased", "mouseMoved", "mouseWheel" 1159 ); 1160 THROWS.checkIAE("button", button, "Input.MouseButton", Input.MouseButton); 1161 1162 final int webSocketID = 25006000 + counter++; 1163 final boolean[] optionals = { false, false, false, false, true, true, true, true, true, }; 1164 1165 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1166 String requestJSON = WriteJSON.get( 1167 parameterTypes.get("emulateTouchFromMouseEvent"), 1168 parameterNames.get("emulateTouchFromMouseEvent"), 1169 optionals, webSocketID, 1170 "Input.emulateTouchFromMouseEvent", 1171 type, x, y, button, timestamp, deltaX, deltaY, modifiers, clickCount 1172 ); 1173 1174 // This Remote Command does not have a Return-Value. 1175 return new Script<> 1176 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1177 } 1178 1179 /** 1180 * Ignores input events (useful while auditing page). 1181 * 1182 * @param ignore Ignores input events processing when set to true. 1183 * 1184 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1185 * {@link Ret0}></CODE> 1186 * 1187 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1188 * browser receives the invocation-request. 1189 * 1190 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1191 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1192 * {@code >} to ensure the Browser Function has run to completion. 1193 */ 1194 public static Script<String, JsonObject, Ret0> setIgnoreInputEvents(boolean ignore) 1195 { 1196 final int webSocketID = 25007000 + counter++; 1197 final boolean[] optionals = { false, }; 1198 1199 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1200 String requestJSON = WriteJSON.get( 1201 parameterTypes.get("setIgnoreInputEvents"), 1202 parameterNames.get("setIgnoreInputEvents"), 1203 optionals, webSocketID, 1204 "Input.setIgnoreInputEvents", 1205 ignore 1206 ); 1207 1208 // This Remote Command does not have a Return-Value. 1209 return new Script<> 1210 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1211 } 1212 1213 /** 1214 * Prevents default drag and drop behavior and instead emits <CODE>Input.dragIntercepted</CODE> events. 1215 * Drag and drop behavior can be directly controlled via <CODE>Input.dispatchDragEvent</CODE>. 1216 * <BR /><B>EXPERIMENTAL</B> 1217 * 1218 * @param enabled - 1219 * 1220 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1221 * {@link Ret0}></CODE> 1222 * 1223 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1224 * browser receives the invocation-request. 1225 * 1226 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1227 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1228 * {@code >} to ensure the Browser Function has run to completion. 1229 */ 1230 public static Script<String, JsonObject, Ret0> setInterceptDrags(boolean enabled) 1231 { 1232 final int webSocketID = 25008000 + counter++; 1233 final boolean[] optionals = { false, }; 1234 1235 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1236 String requestJSON = WriteJSON.get( 1237 parameterTypes.get("setInterceptDrags"), 1238 parameterNames.get("setInterceptDrags"), 1239 optionals, webSocketID, 1240 "Input.setInterceptDrags", 1241 enabled 1242 ); 1243 1244 // This Remote Command does not have a Return-Value. 1245 return new Script<> 1246 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1247 } 1248 1249 /** 1250 * Synthesizes a pinch gesture over a time period by issuing appropriate touch events. 1251 * <BR /><B>EXPERIMENTAL</B> 1252 * 1253 * @param x X coordinate of the start of the gesture in CSS pixels. 1254 * 1255 * @param y Y coordinate of the start of the gesture in CSS pixels. 1256 * 1257 * @param scaleFactor Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out). 1258 * 1259 * @param relativeSpeed Relative pointer speed in pixels per second (default: 800). 1260 * <BR /><B>OPTIONAL</B> 1261 * 1262 * @param gestureSourceType 1263 * Which type of input events to be generated (default: 'default', which queries the platform 1264 * for the preferred input type). 1265 * <BR /><B>OPTIONAL</B> 1266 * 1267 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1268 * {@link Ret0}></CODE> 1269 * 1270 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1271 * browser receives the invocation-request. 1272 * 1273 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1274 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1275 * {@code >} to ensure the Browser Function has run to completion. 1276 */ 1277 public static Script<String, JsonObject, Ret0> synthesizePinchGesture 1278 (Number x, Number y, Number scaleFactor, Integer relativeSpeed, String gestureSourceType) 1279 { 1280 // Exception-Check(s) to ensure that if any parameters which are not declared as 1281 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1282 1283 if (x == null) THROWS.throwNPE("x"); 1284 if (y == null) THROWS.throwNPE("y"); 1285 if (scaleFactor == null) THROWS.throwNPE("scaleFactor"); 1286 1287 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1288 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1289 1290 THROWS.checkIAE("gestureSourceType", gestureSourceType, "Input.GestureSourceType", Input.GestureSourceType); 1291 1292 final int webSocketID = 25009000 + counter++; 1293 final boolean[] optionals = { false, false, false, true, true, }; 1294 1295 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1296 String requestJSON = WriteJSON.get( 1297 parameterTypes.get("synthesizePinchGesture"), 1298 parameterNames.get("synthesizePinchGesture"), 1299 optionals, webSocketID, 1300 "Input.synthesizePinchGesture", 1301 x, y, scaleFactor, relativeSpeed, gestureSourceType 1302 ); 1303 1304 // This Remote Command does not have a Return-Value. 1305 return new Script<> 1306 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1307 } 1308 1309 /** 1310 * Synthesizes a scroll gesture over a time period by issuing appropriate touch events. 1311 * <BR /><B>EXPERIMENTAL</B> 1312 * 1313 * @param x X coordinate of the start of the gesture in CSS pixels. 1314 * 1315 * @param y Y coordinate of the start of the gesture in CSS pixels. 1316 * 1317 * @param xDistance The distance to scroll along the X axis (positive to scroll left). 1318 * <BR /><B>OPTIONAL</B> 1319 * 1320 * @param yDistance The distance to scroll along the Y axis (positive to scroll up). 1321 * <BR /><B>OPTIONAL</B> 1322 * 1323 * @param xOverscroll 1324 * The number of additional pixels to scroll back along the X axis, in addition to the given 1325 * distance. 1326 * <BR /><B>OPTIONAL</B> 1327 * 1328 * @param yOverscroll 1329 * The number of additional pixels to scroll back along the Y axis, in addition to the given 1330 * distance. 1331 * <BR /><B>OPTIONAL</B> 1332 * 1333 * @param preventFling Prevent fling (default: true). 1334 * <BR /><B>OPTIONAL</B> 1335 * 1336 * @param speed Swipe speed in pixels per second (default: 800). 1337 * <BR /><B>OPTIONAL</B> 1338 * 1339 * @param gestureSourceType 1340 * Which type of input events to be generated (default: 'default', which queries the platform 1341 * for the preferred input type). 1342 * <BR /><B>OPTIONAL</B> 1343 * 1344 * @param repeatCount The number of times to repeat the gesture (default: 0). 1345 * <BR /><B>OPTIONAL</B> 1346 * 1347 * @param repeatDelayMs The number of milliseconds delay between each repeat. (default: 250). 1348 * <BR /><B>OPTIONAL</B> 1349 * 1350 * @param interactionMarkerName The name of the interaction markers to generate, if not empty (default: ""). 1351 * <BR /><B>OPTIONAL</B> 1352 * 1353 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1354 * {@link Ret0}></CODE> 1355 * 1356 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1357 * browser receives the invocation-request. 1358 * 1359 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1360 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1361 * {@code >} to ensure the Browser Function has run to completion. 1362 */ 1363 public static Script<String, JsonObject, Ret0> synthesizeScrollGesture( 1364 Number x, Number y, Number xDistance, Number yDistance, Number xOverscroll, 1365 Number yOverscroll, Boolean preventFling, Integer speed, String gestureSourceType, 1366 Integer repeatCount, Integer repeatDelayMs, String interactionMarkerName 1367 ) 1368 { 1369 // Exception-Check(s) to ensure that if any parameters which are not declared as 1370 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1371 1372 if (x == null) THROWS.throwNPE("x"); 1373 if (y == null) THROWS.throwNPE("y"); 1374 1375 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1376 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1377 1378 THROWS.checkIAE("gestureSourceType", gestureSourceType, "Input.GestureSourceType", Input.GestureSourceType); 1379 1380 final int webSocketID = 25010000 + counter++; 1381 final boolean[] optionals = { false, false, true, true, true, true, true, true, true, true, true, true, }; 1382 1383 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1384 String requestJSON = WriteJSON.get( 1385 parameterTypes.get("synthesizeScrollGesture"), 1386 parameterNames.get("synthesizeScrollGesture"), 1387 optionals, webSocketID, 1388 "Input.synthesizeScrollGesture", 1389 x, y, xDistance, yDistance, xOverscroll, yOverscroll, preventFling, speed, 1390 gestureSourceType, repeatCount, repeatDelayMs, interactionMarkerName 1391 ); 1392 1393 // This Remote Command does not have a Return-Value. 1394 return new Script<> 1395 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1396 } 1397 1398 /** 1399 * Synthesizes a tap gesture over a time period by issuing appropriate touch events. 1400 * <BR /><B>EXPERIMENTAL</B> 1401 * 1402 * @param x X coordinate of the start of the gesture in CSS pixels. 1403 * 1404 * @param y Y coordinate of the start of the gesture in CSS pixels. 1405 * 1406 * @param duration Duration between touchdown and touchup events in ms (default: 50). 1407 * <BR /><B>OPTIONAL</B> 1408 * 1409 * @param tapCount Number of times to perform the tap (e.g. 2 for double tap, default: 1). 1410 * <BR /><B>OPTIONAL</B> 1411 * 1412 * @param gestureSourceType 1413 * Which type of input events to be generated (default: 'default', which queries the platform 1414 * for the preferred input type). 1415 * <BR /><B>OPTIONAL</B> 1416 * 1417 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 1418 * {@link Ret0}></CODE> 1419 * 1420 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 1421 * browser receives the invocation-request. 1422 * 1423 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 1424 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 1425 * {@code >} to ensure the Browser Function has run to completion. 1426 */ 1427 public static Script<String, JsonObject, Ret0> synthesizeTapGesture 1428 (Number x, Number y, Integer duration, Integer tapCount, String gestureSourceType) 1429 { 1430 // Exception-Check(s) to ensure that if any parameters which are not declared as 1431 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1432 1433 if (x == null) THROWS.throwNPE("x"); 1434 if (y == null) THROWS.throwNPE("y"); 1435 1436 // Exception-Check(s) to ensure that if any parameters which must adhere to a 1437 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 1438 1439 THROWS.checkIAE("gestureSourceType", gestureSourceType, "Input.GestureSourceType", Input.GestureSourceType); 1440 1441 final int webSocketID = 25011000 + counter++; 1442 final boolean[] optionals = { false, false, true, true, true, }; 1443 1444 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 1445 String requestJSON = WriteJSON.get( 1446 parameterTypes.get("synthesizeTapGesture"), 1447 parameterNames.get("synthesizeTapGesture"), 1448 optionals, webSocketID, 1449 "Input.synthesizeTapGesture", 1450 x, y, duration, tapCount, gestureSourceType 1451 ); 1452 1453 // This Remote Command does not have a Return-Value. 1454 return new Script<> 1455 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 1456 } 1457 1458}