001package Torello.Browser.BrowserAPI; 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.Browser.BrowserEvent; 013import Torello.Browser.JavaScriptAPI.*; 014import Torello.Browser.helper.*; 015 016import Torello.Java.Additional.*; 017import Torello.Java.JSON.*; 018 019import static Torello.Java.JSON.JFlag.*; 020 021import Torello.Java.StrCmpr; 022import Torello.JavaDoc.StaticFunctional; 023import Torello.JavaDoc.JDHeaderBackgroundImg; 024import Torello.JavaDoc.Excuse; 025 026/** 027 * <SPAN CLASS=COPIEDJDK><B>This domain exposes DOM read/write operations. Each DOM Node is represented with its mirror object 028 * that has an {@code id}. This {@code id} can be used to get additional information on the Node, resolve it into 029 * the JavaScript object wrapper, etc. It is important that client receives DOM events only for the 030 * nodes that are known to the client. Backend keeps track of the nodes that were sent to the client 031 * and never sends the same node twice. It is client's responsibility to collect information about 032 * the nodes that were sent to the client. Note that {@code iframe} owner elements will return 033 * corresponding document elements as their child nodes.</B></SPAN> 034 * 035 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 036 */ 037@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 038@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 039public class DOM 040{ 041 // ******************************************************************************************** 042 // ******************************************************************************************** 043 // Class Header Stuff 044 // ******************************************************************************************** 045 // ******************************************************************************************** 046 047 048 // No Pubic Constructors 049 private DOM () { } 050 051 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 052 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 053 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 054 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 055 056 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 057 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 058 // offically, two empty-vectors. One for String's, and the other for Classes. 059 060 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 061 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 062 063 static 064 { 065 for (Method m : DOM.class.getMethods()) 066 { 067 // This doesn't work! The parameter names are all "arg0" ... "argN" 068 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 069 // 070 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 071 072 Vector<Class<?>> parameterTypesList = new Vector<>(); 073 074 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 075 076 parameterTypes.put( 077 m.getName(), 078 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 079 ); 080 } 081 } 082 083 static 084 { 085 Vector<String> v = null; 086 087 v = new Vector<String>(1); 088 parameterNames.put("collectClassNamesFromSubtree", v); 089 Collections.addAll(v, new String[] 090 { "nodeId", }); 091 092 v = new Vector<String>(3); 093 parameterNames.put("copyTo", v); 094 Collections.addAll(v, new String[] 095 { "nodeId", "targetNodeId", "insertBeforeNodeId", }); 096 097 v = new Vector<String>(5); 098 parameterNames.put("describeNode", v); 099 Collections.addAll(v, new String[] 100 { "nodeId", "backendNodeId", "objectId", "depth", "pierce", }); 101 102 v = new Vector<String>(4); 103 parameterNames.put("scrollIntoViewIfNeeded", v); 104 Collections.addAll(v, new String[] 105 { "nodeId", "backendNodeId", "objectId", "rect", }); 106 107 parameterNames.put("disable", EMPTY_VEC_STR); 108 109 v = new Vector<String>(1); 110 parameterNames.put("discardSearchResults", v); 111 Collections.addAll(v, new String[] 112 { "searchId", }); 113 114 v = new Vector<String>(1); 115 parameterNames.put("enable", v); 116 Collections.addAll(v, new String[] 117 { "includeWhitespace", }); 118 119 v = new Vector<String>(3); 120 parameterNames.put("focus", v); 121 Collections.addAll(v, new String[] 122 { "nodeId", "backendNodeId", "objectId", }); 123 124 v = new Vector<String>(1); 125 parameterNames.put("getAttributes", v); 126 Collections.addAll(v, new String[] 127 { "nodeId", }); 128 129 v = new Vector<String>(3); 130 parameterNames.put("getBoxModel", v); 131 Collections.addAll(v, new String[] 132 { "nodeId", "backendNodeId", "objectId", }); 133 134 v = new Vector<String>(3); 135 parameterNames.put("getContentQuads", v); 136 Collections.addAll(v, new String[] 137 { "nodeId", "backendNodeId", "objectId", }); 138 139 v = new Vector<String>(2); 140 parameterNames.put("getDocument", v); 141 Collections.addAll(v, new String[] 142 { "depth", "pierce", }); 143 144 v = new Vector<String>(2); 145 parameterNames.put("getFlattenedDocument", v); 146 Collections.addAll(v, new String[] 147 { "depth", "pierce", }); 148 149 v = new Vector<String>(3); 150 parameterNames.put("getNodesForSubtreeByStyle", v); 151 Collections.addAll(v, new String[] 152 { "nodeId", "computedStyles", "pierce", }); 153 154 v = new Vector<String>(4); 155 parameterNames.put("getNodeForLocation", v); 156 Collections.addAll(v, new String[] 157 { "x", "y", "includeUserAgentShadowDOM", "ignorePointerEventsNone", }); 158 159 v = new Vector<String>(4); 160 parameterNames.put("getOuterHTML", v); 161 Collections.addAll(v, new String[] 162 { "nodeId", "backendNodeId", "objectId", "includeShadowDOM", }); 163 164 v = new Vector<String>(1); 165 parameterNames.put("getRelayoutBoundary", v); 166 Collections.addAll(v, new String[] 167 { "nodeId", }); 168 169 v = new Vector<String>(3); 170 parameterNames.put("getSearchResults", v); 171 Collections.addAll(v, new String[] 172 { "searchId", "fromIndex", "toIndex", }); 173 174 parameterNames.put("hideHighlight", EMPTY_VEC_STR); 175 176 parameterNames.put("highlightNode", EMPTY_VEC_STR); 177 178 parameterNames.put("highlightRect", EMPTY_VEC_STR); 179 180 parameterNames.put("markUndoableState", EMPTY_VEC_STR); 181 182 v = new Vector<String>(3); 183 parameterNames.put("moveTo", v); 184 Collections.addAll(v, new String[] 185 { "nodeId", "targetNodeId", "insertBeforeNodeId", }); 186 187 v = new Vector<String>(2); 188 parameterNames.put("performSearch", v); 189 Collections.addAll(v, new String[] 190 { "query", "includeUserAgentShadowDOM", }); 191 192 v = new Vector<String>(1); 193 parameterNames.put("pushNodeByPathToFrontend", v); 194 Collections.addAll(v, new String[] 195 { "path", }); 196 197 v = new Vector<String>(1); 198 parameterNames.put("pushNodesByBackendIdsToFrontend", v); 199 Collections.addAll(v, new String[] 200 { "backendNodeIds", }); 201 202 v = new Vector<String>(2); 203 parameterNames.put("querySelector", v); 204 Collections.addAll(v, new String[] 205 { "nodeId", "selector", }); 206 207 v = new Vector<String>(2); 208 parameterNames.put("querySelectorAll", v); 209 Collections.addAll(v, new String[] 210 { "nodeId", "selector", }); 211 212 parameterNames.put("getTopLayerElements", EMPTY_VEC_STR); 213 214 v = new Vector<String>(2); 215 parameterNames.put("getElementByRelation", v); 216 Collections.addAll(v, new String[] 217 { "nodeId", "relation", }); 218 219 parameterNames.put("redo", EMPTY_VEC_STR); 220 221 v = new Vector<String>(2); 222 parameterNames.put("removeAttribute", v); 223 Collections.addAll(v, new String[] 224 { "nodeId", "name", }); 225 226 v = new Vector<String>(1); 227 parameterNames.put("removeNode", v); 228 Collections.addAll(v, new String[] 229 { "nodeId", }); 230 231 v = new Vector<String>(3); 232 parameterNames.put("requestChildNodes", v); 233 Collections.addAll(v, new String[] 234 { "nodeId", "depth", "pierce", }); 235 236 v = new Vector<String>(1); 237 parameterNames.put("requestNode", v); 238 Collections.addAll(v, new String[] 239 { "objectId", }); 240 241 v = new Vector<String>(4); 242 parameterNames.put("resolveNode", v); 243 Collections.addAll(v, new String[] 244 { "nodeId", "backendNodeId", "objectGroup", "executionContextId", }); 245 246 v = new Vector<String>(3); 247 parameterNames.put("setAttributeValue", v); 248 Collections.addAll(v, new String[] 249 { "nodeId", "name", "value", }); 250 251 v = new Vector<String>(3); 252 parameterNames.put("setAttributesAsText", v); 253 Collections.addAll(v, new String[] 254 { "nodeId", "text", "name", }); 255 256 v = new Vector<String>(4); 257 parameterNames.put("setFileInputFiles", v); 258 Collections.addAll(v, new String[] 259 { "files", "nodeId", "backendNodeId", "objectId", }); 260 261 v = new Vector<String>(1); 262 parameterNames.put("setNodeStackTracesEnabled", v); 263 Collections.addAll(v, new String[] 264 { "enable", }); 265 266 v = new Vector<String>(1); 267 parameterNames.put("getNodeStackTraces", v); 268 Collections.addAll(v, new String[] 269 { "nodeId", }); 270 271 v = new Vector<String>(1); 272 parameterNames.put("getFileInfo", v); 273 Collections.addAll(v, new String[] 274 { "objectId", }); 275 276 parameterNames.put("getDetachedDomNodes", EMPTY_VEC_STR); 277 278 v = new Vector<String>(1); 279 parameterNames.put("setInspectedNode", v); 280 Collections.addAll(v, new String[] 281 { "nodeId", }); 282 283 v = new Vector<String>(2); 284 parameterNames.put("setNodeName", v); 285 Collections.addAll(v, new String[] 286 { "nodeId", "name", }); 287 288 v = new Vector<String>(2); 289 parameterNames.put("setNodeValue", v); 290 Collections.addAll(v, new String[] 291 { "nodeId", "value", }); 292 293 v = new Vector<String>(2); 294 parameterNames.put("setOuterHTML", v); 295 Collections.addAll(v, new String[] 296 { "nodeId", "outerHTML", }); 297 298 parameterNames.put("undo", EMPTY_VEC_STR); 299 300 v = new Vector<String>(1); 301 parameterNames.put("getFrameOwner", v); 302 Collections.addAll(v, new String[] 303 { "frameId", }); 304 305 v = new Vector<String>(6); 306 parameterNames.put("getContainerForNode", v); 307 Collections.addAll(v, new String[] 308 { "nodeId", "containerName", "physicalAxes", "logicalAxes", "queriesScrollState", "queriesAnchored", }); 309 310 v = new Vector<String>(1); 311 parameterNames.put("getQueryingDescendantsForContainer", v); 312 Collections.addAll(v, new String[] 313 { "nodeId", }); 314 315 v = new Vector<String>(2); 316 parameterNames.put("getAnchorElement", v); 317 Collections.addAll(v, new String[] 318 { "nodeId", "anchorSpecifier", }); 319 320 v = new Vector<String>(2); 321 parameterNames.put("forceShowPopover", v); 322 Collections.addAll(v, new String[] 323 { "nodeId", "enable", }); 324 } 325 326 327 // ******************************************************************************************** 328 // ******************************************************************************************** 329 // Types - Static Inner Classes 330 // ******************************************************************************************** 331 // ******************************************************************************************** 332 333 // public static class NodeId => Integer 334 335 // public static class BackendNodeId => Integer 336 337 // public static class Quad => Number[] 338 339 /** Pseudo element type. */ 340 public static final String[] PseudoType = 341 { 342 "first-line", "first-letter", "checkmark", "before", "after", "picker-icon", 343 "interest-hint", "marker", "backdrop", "column", "selection", "search-text", "target-text", 344 "spelling-error", "grammar-error", "highlight", "first-line-inherited", "scroll-marker", 345 "scroll-marker-group", "scroll-button", "scrollbar", "scrollbar-thumb", "scrollbar-button", 346 "scrollbar-track", "scrollbar-track-piece", "scrollbar-corner", "resizer", 347 "input-list-button", "view-transition", "view-transition-group", 348 "view-transition-image-pair", "view-transition-group-children", "view-transition-old", 349 "view-transition-new", "placeholder", "file-selector-button", "details-content", "picker", 350 "permission-icon", 351 }; 352 353 /** Shadow root type. */ 354 public static final String[] ShadowRootType = 355 { "user-agent", "open", "closed", }; 356 357 /** Document compatibility mode. */ 358 public static final String[] CompatibilityMode = 359 { "QuirksMode", "LimitedQuirksMode", "NoQuirksMode", }; 360 361 /** ContainerSelector physical axes */ 362 public static final String[] PhysicalAxes = 363 { "Horizontal", "Vertical", "Both", }; 364 365 /** ContainerSelector logical axes */ 366 public static final String[] LogicalAxes = 367 { "Inline", "Block", "Both", }; 368 369 /** Physical scroll orientation */ 370 public static final String[] ScrollOrientation = 371 { "horizontal", "vertical", }; 372 373 /** Backend node with a friendly name. */ 374 public static class BackendNode 375 extends BaseType 376 implements java.io.Serializable 377 { 378 /** For Object Serialization. java.io.Serializable */ 379 protected static final long serialVersionUID = 1; 380 381 public boolean[] optionals() 382 { return new boolean[] { false, false, false, }; } 383 384 /** {@code Node}'s nodeType. */ 385 public final int nodeType; 386 387 /** {@code Node}'s nodeName. */ 388 public final String nodeName; 389 390 /** <CODE>[No Description Provided by Google]</CODE> */ 391 public final int backendNodeId; 392 393 /** 394 * Constructor 395 * 396 * @param nodeType {@code Node}'s nodeType. 397 * 398 * @param nodeName {@code Node}'s nodeName. 399 * 400 * @param backendNodeId - 401 */ 402 public BackendNode(int nodeType, String nodeName, int backendNodeId) 403 { 404 // Exception-Check(s) to ensure that if any parameters which are not declared as 405 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 406 407 if (nodeName == null) THROWS.throwNPE("nodeName"); 408 409 this.nodeType = nodeType; 410 this.nodeName = nodeName; 411 this.backendNodeId = backendNodeId; 412 } 413 414 /** 415 * JSON Object Constructor 416 * @param jo A Json-Object having data about an instance of {@code 'BackendNode'}. 417 */ 418 public BackendNode (JsonObject jo) 419 { 420 this.nodeType = ReadPrimJSON.getInt(jo, "nodeType"); 421 this.nodeName = ReadJSON.getString(jo, "nodeName", false, true); 422 this.backendNodeId = ReadPrimJSON.getInt(jo, "backendNodeId"); 423 } 424 425 426 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 427 public boolean equals(Object other) 428 { 429 if (this == other) return true; 430 if (other == null) return false; 431 if (other.getClass() != this.getClass()) return false; 432 433 BackendNode o = (BackendNode) other; 434 435 return 436 (this.nodeType == o.nodeType) 437 && Objects.equals(this.nodeName, o.nodeName) 438 && Objects.equals(this.backendNodeId, o.backendNodeId); 439 } 440 441 /** Generates a Hash-Code for {@code 'this'} instance */ 442 public int hashCode() 443 { 444 return 445 this.nodeType 446 + Objects.hashCode(this.nodeName) 447 + this.backendNodeId; 448 } 449 } 450 451 /** 452 * DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. 453 * DOMNode is a base node mirror type. 454 */ 455 public static class Node 456 extends BaseType 457 implements java.io.Serializable 458 { 459 /** For Object Serialization. java.io.Serializable */ 460 protected static final long serialVersionUID = 1; 461 462 public boolean[] optionals() 463 { return new boolean[] { false, true, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, }; } 464 465 /** 466 * Node identifier that is passed into the rest of the DOM messages as the {@code nodeId}. Backend 467 * will only push node with given {@code id} once. It is aware of all requested nodes and will only 468 * fire DOM events for nodes known to the client. 469 */ 470 public final int nodeId; 471 472 /** 473 * The id of the parent node if any. 474 * <BR /><B CLASS=Opt>OPTIONAL</B> 475 */ 476 public final Integer parentId; 477 478 /** The BackendNodeId for this node. */ 479 public final int backendNodeId; 480 481 /** {@code Node}'s nodeType. */ 482 public final int nodeType; 483 484 /** {@code Node}'s nodeName. */ 485 public final String nodeName; 486 487 /** {@code Node}'s localName. */ 488 public final String localName; 489 490 /** {@code Node}'s nodeValue. */ 491 public final String nodeValue; 492 493 /** 494 * Child count for {@code Container} nodes. 495 * <BR /><B CLASS=Opt>OPTIONAL</B> 496 */ 497 public final Integer childNodeCount; 498 499 /** 500 * Child nodes of this node when requested with children. 501 * <BR /><B CLASS=Opt>OPTIONAL</B> 502 */ 503 public final DOM.Node[] children; 504 505 /** 506 * Attributes of the {@code Element} node in the form of flat array {@code [name1, value1, name2, value2]}. 507 * <BR /><B CLASS=Opt>OPTIONAL</B> 508 */ 509 public final String[] attributes; 510 511 /** 512 * Document URL that {@code Document} or {@code FrameOwner} node points to. 513 * <BR /><B CLASS=Opt>OPTIONAL</B> 514 */ 515 public final String documentURL; 516 517 /** 518 * Base URL that {@code Document} or {@code FrameOwner} node uses for URL completion. 519 * <BR /><B CLASS=Opt>OPTIONAL</B> 520 */ 521 public final String baseURL; 522 523 /** 524 * {@code DocumentType}'s publicId. 525 * <BR /><B CLASS=Opt>OPTIONAL</B> 526 */ 527 public final String publicId; 528 529 /** 530 * {@code DocumentType}'s systemId. 531 * <BR /><B CLASS=Opt>OPTIONAL</B> 532 */ 533 public final String systemId; 534 535 /** 536 * {@code DocumentType}'s internalSubset. 537 * <BR /><B CLASS=Opt>OPTIONAL</B> 538 */ 539 public final String internalSubset; 540 541 /** 542 * {@code Document}'s XML version in case of XML documents. 543 * <BR /><B CLASS=Opt>OPTIONAL</B> 544 */ 545 public final String xmlVersion; 546 547 /** 548 * {@code Attr}'s name. 549 * <BR /><B CLASS=Opt>OPTIONAL</B> 550 */ 551 public final String name; 552 553 /** 554 * {@code Attr}'s value. 555 * <BR /><B CLASS=Opt>OPTIONAL</B> 556 */ 557 public final String value; 558 559 /** 560 * Pseudo element type for this node. 561 * <BR /><B CLASS=Opt>OPTIONAL</B> 562 */ 563 public final String pseudoType; 564 565 /** 566 * Pseudo element identifier for this node. Only present if there is a 567 * valid pseudoType. 568 * <BR /><B CLASS=Opt>OPTIONAL</B> 569 */ 570 public final String pseudoIdentifier; 571 572 /** 573 * Shadow root type. 574 * <BR /><B CLASS=Opt>OPTIONAL</B> 575 */ 576 public final String shadowRootType; 577 578 /** 579 * Frame ID for frame owner elements. 580 * <BR /><B CLASS=Opt>OPTIONAL</B> 581 */ 582 public final String frameId; 583 584 /** 585 * Content document for frame owner elements. 586 * <BR /><B CLASS=Opt>OPTIONAL</B> 587 */ 588 public final DOM.Node contentDocument; 589 590 /** 591 * Shadow root list for given element host. 592 * <BR /><B CLASS=Opt>OPTIONAL</B> 593 */ 594 public final DOM.Node[] shadowRoots; 595 596 /** 597 * Content document fragment for template elements. 598 * <BR /><B CLASS=Opt>OPTIONAL</B> 599 */ 600 public final DOM.Node templateContent; 601 602 /** 603 * Pseudo elements associated with this node. 604 * <BR /><B CLASS=Opt>OPTIONAL</B> 605 */ 606 public final DOM.Node[] pseudoElements; 607 608 /** 609 * Deprecated, as the HTML Imports API has been removed (crbug.com/937746). 610 * This property used to return the imported document for the HTMLImport links. 611 * The property is always undefined now. 612 * <BR /><B CLASS=Opt>OPTIONAL</B> 613 <B CLASS=Dep>DEPRECATED</B> 614 */ 615 public final DOM.Node importedDocument; 616 617 /** 618 * Distributed nodes for given insertion point. 619 * <BR /><B CLASS=Opt>OPTIONAL</B> 620 */ 621 public final DOM.BackendNode[] distributedNodes; 622 623 /** 624 * Whether the node is SVG. 625 * <BR /><B CLASS=Opt>OPTIONAL</B> 626 */ 627 public final Boolean isSVG; 628 629 /** 630 * <CODE>[No Description Provided by Google]</CODE> 631 * <BR /><B CLASS=Opt>OPTIONAL</B> 632 */ 633 public final String compatibilityMode; 634 635 /** 636 * <CODE>[No Description Provided by Google]</CODE> 637 * <BR /><B CLASS=Opt>OPTIONAL</B> 638 */ 639 public final DOM.BackendNode assignedSlot; 640 641 /** 642 * <CODE>[No Description Provided by Google]</CODE> 643 * <BR /><B CLASS=Opt>OPTIONAL</B> 644 <B CLASS=Exp>EXPERIMENTAL</B> 645 */ 646 public final Boolean isScrollable; 647 648 /** 649 * Constructor 650 * 651 * @param nodeId 652 * Node identifier that is passed into the rest of the DOM messages as the {@code nodeId}. Backend 653 * will only push node with given {@code id} once. It is aware of all requested nodes and will only 654 * fire DOM events for nodes known to the client. 655 * 656 * @param parentId The id of the parent node if any. 657 * <BR /><B CLASS=Opt>OPTIONAL</B> 658 * 659 * @param backendNodeId The BackendNodeId for this node. 660 * 661 * @param nodeType {@code Node}'s nodeType. 662 * 663 * @param nodeName {@code Node}'s nodeName. 664 * 665 * @param localName {@code Node}'s localName. 666 * 667 * @param nodeValue {@code Node}'s nodeValue. 668 * 669 * @param childNodeCount Child count for {@code Container} nodes. 670 * <BR /><B CLASS=Opt>OPTIONAL</B> 671 * 672 * @param children Child nodes of this node when requested with children. 673 * <BR /><B CLASS=Opt>OPTIONAL</B> 674 * 675 * @param attributes Attributes of the {@code Element} node in the form of flat array {@code [name1, value1, name2, value2]}. 676 * <BR /><B CLASS=Opt>OPTIONAL</B> 677 * 678 * @param documentURL Document URL that {@code Document} or {@code FrameOwner} node points to. 679 * <BR /><B CLASS=Opt>OPTIONAL</B> 680 * 681 * @param baseURL Base URL that {@code Document} or {@code FrameOwner} node uses for URL completion. 682 * <BR /><B CLASS=Opt>OPTIONAL</B> 683 * 684 * @param publicId {@code DocumentType}'s publicId. 685 * <BR /><B CLASS=Opt>OPTIONAL</B> 686 * 687 * @param systemId {@code DocumentType}'s systemId. 688 * <BR /><B CLASS=Opt>OPTIONAL</B> 689 * 690 * @param internalSubset {@code DocumentType}'s internalSubset. 691 * <BR /><B CLASS=Opt>OPTIONAL</B> 692 * 693 * @param xmlVersion {@code Document}'s XML version in case of XML documents. 694 * <BR /><B CLASS=Opt>OPTIONAL</B> 695 * 696 * @param name {@code Attr}'s name. 697 * <BR /><B CLASS=Opt>OPTIONAL</B> 698 * 699 * @param value {@code Attr}'s value. 700 * <BR /><B CLASS=Opt>OPTIONAL</B> 701 * 702 * @param pseudoType Pseudo element type for this node. 703 * <BR /><B CLASS=Opt>OPTIONAL</B> 704 * 705 * @param pseudoIdentifier 706 * Pseudo element identifier for this node. Only present if there is a 707 * valid pseudoType. 708 * <BR /><B CLASS=Opt>OPTIONAL</B> 709 * 710 * @param shadowRootType Shadow root type. 711 * <BR /><B CLASS=Opt>OPTIONAL</B> 712 * 713 * @param frameId Frame ID for frame owner elements. 714 * <BR /><B CLASS=Opt>OPTIONAL</B> 715 * 716 * @param contentDocument Content document for frame owner elements. 717 * <BR /><B CLASS=Opt>OPTIONAL</B> 718 * 719 * @param shadowRoots Shadow root list for given element host. 720 * <BR /><B CLASS=Opt>OPTIONAL</B> 721 * 722 * @param templateContent Content document fragment for template elements. 723 * <BR /><B CLASS=Opt>OPTIONAL</B> 724 * 725 * @param pseudoElements Pseudo elements associated with this node. 726 * <BR /><B CLASS=Opt>OPTIONAL</B> 727 * 728 * @param importedDocument 729 * Deprecated, as the HTML Imports API has been removed (crbug.com/937746). 730 * This property used to return the imported document for the HTMLImport links. 731 * The property is always undefined now. 732 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Dep>DEPRECATED</B> 733 * 734 * @param distributedNodes Distributed nodes for given insertion point. 735 * <BR /><B CLASS=Opt>OPTIONAL</B> 736 * 737 * @param isSVG Whether the node is SVG. 738 * <BR /><B CLASS=Opt>OPTIONAL</B> 739 * 740 * @param compatibilityMode - 741 * <BR /><B CLASS=Opt>OPTIONAL</B> 742 * 743 * @param assignedSlot - 744 * <BR /><B CLASS=Opt>OPTIONAL</B> 745 * 746 * @param isScrollable - 747 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 748 */ 749 public Node( 750 int nodeId, Integer parentId, int backendNodeId, int nodeType, String nodeName, 751 String localName, String nodeValue, Integer childNodeCount, DOM.Node[] children, 752 String[] attributes, String documentURL, String baseURL, String publicId, 753 String systemId, String internalSubset, String xmlVersion, String name, 754 String value, String pseudoType, String pseudoIdentifier, String shadowRootType, 755 String frameId, DOM.Node contentDocument, DOM.Node[] shadowRoots, 756 DOM.Node templateContent, DOM.Node[] pseudoElements, DOM.Node importedDocument, 757 DOM.BackendNode[] distributedNodes, Boolean isSVG, String compatibilityMode, 758 DOM.BackendNode assignedSlot, Boolean isScrollable 759 ) 760 { 761 // Exception-Check(s) to ensure that if any parameters which are not declared as 762 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 763 764 if (nodeName == null) THROWS.throwNPE("nodeName"); 765 if (localName == null) THROWS.throwNPE("localName"); 766 if (nodeValue == null) THROWS.throwNPE("nodeValue"); 767 768 // Exception-Check(s) to ensure that if any parameters which must adhere to a 769 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 770 771 THROWS.checkIAE("pseudoType", pseudoType, "DOM.PseudoType", DOM.PseudoType); 772 THROWS.checkIAE("shadowRootType", shadowRootType, "DOM.ShadowRootType", DOM.ShadowRootType); 773 THROWS.checkIAE("compatibilityMode", compatibilityMode, "DOM.CompatibilityMode", DOM.CompatibilityMode); 774 775 this.nodeId = nodeId; 776 this.parentId = parentId; 777 this.backendNodeId = backendNodeId; 778 this.nodeType = nodeType; 779 this.nodeName = nodeName; 780 this.localName = localName; 781 this.nodeValue = nodeValue; 782 this.childNodeCount = childNodeCount; 783 this.children = children; 784 this.attributes = attributes; 785 this.documentURL = documentURL; 786 this.baseURL = baseURL; 787 this.publicId = publicId; 788 this.systemId = systemId; 789 this.internalSubset = internalSubset; 790 this.xmlVersion = xmlVersion; 791 this.name = name; 792 this.value = value; 793 this.pseudoType = pseudoType; 794 this.pseudoIdentifier = pseudoIdentifier; 795 this.shadowRootType = shadowRootType; 796 this.frameId = frameId; 797 this.contentDocument = contentDocument; 798 this.shadowRoots = shadowRoots; 799 this.templateContent = templateContent; 800 this.pseudoElements = pseudoElements; 801 this.importedDocument = importedDocument; 802 this.distributedNodes = distributedNodes; 803 this.isSVG = isSVG; 804 this.compatibilityMode = compatibilityMode; 805 this.assignedSlot = assignedSlot; 806 this.isScrollable = isScrollable; 807 } 808 809 /** 810 * JSON Object Constructor 811 * @param jo A Json-Object having data about an instance of {@code 'Node'}. 812 */ 813 public Node (JsonObject jo) 814 { 815 this.nodeId = ReadPrimJSON.getInt(jo, "nodeId"); 816 this.parentId = ReadBoxedJSON.getInteger(jo, "parentId", true); 817 this.backendNodeId = ReadPrimJSON.getInt(jo, "backendNodeId"); 818 this.nodeType = ReadPrimJSON.getInt(jo, "nodeType"); 819 this.nodeName = ReadJSON.getString(jo, "nodeName", false, true); 820 this.localName = ReadJSON.getString(jo, "localName", false, true); 821 this.nodeValue = ReadJSON.getString(jo, "nodeValue", false, true); 822 this.childNodeCount = ReadBoxedJSON.getInteger(jo, "childNodeCount", true); 823 this.children = (jo.getJsonArray("children") == null) 824 ? null 825 : RJArrIntoStream.objArr(jo.getJsonArray("children"), null, 0, DOM.Node.class).toArray(DOM.Node[]::new); 826 827 this.attributes = (jo.getJsonArray("attributes") == null) 828 ? null 829 : RJArrIntoStream.strArr(jo.getJsonArray("attributes"), null, 0).toArray(String[]::new); 830 831 this.documentURL = ReadJSON.getString(jo, "documentURL", true, false); 832 this.baseURL = ReadJSON.getString(jo, "baseURL", true, false); 833 this.publicId = ReadJSON.getString(jo, "publicId", true, false); 834 this.systemId = ReadJSON.getString(jo, "systemId", true, false); 835 this.internalSubset = ReadJSON.getString(jo, "internalSubset", true, false); 836 this.xmlVersion = ReadJSON.getString(jo, "xmlVersion", true, false); 837 this.name = ReadJSON.getString(jo, "name", true, false); 838 this.value = ReadJSON.getString(jo, "value", true, false); 839 this.pseudoType = ReadJSON.getString(jo, "pseudoType", true, false); 840 this.pseudoIdentifier = ReadJSON.getString(jo, "pseudoIdentifier", true, false); 841 this.shadowRootType = ReadJSON.getString(jo, "shadowRootType", true, false); 842 this.frameId = ReadJSON.getString(jo, "frameId", true, false); 843 this.contentDocument = ReadJSON.getObject(jo, "contentDocument", DOM.Node.class, true, false); 844 this.shadowRoots = (jo.getJsonArray("shadowRoots") == null) 845 ? null 846 : RJArrIntoStream.objArr(jo.getJsonArray("shadowRoots"), null, 0, DOM.Node.class).toArray(DOM.Node[]::new); 847 848 this.templateContent = ReadJSON.getObject(jo, "templateContent", DOM.Node.class, true, false); 849 this.pseudoElements = (jo.getJsonArray("pseudoElements") == null) 850 ? null 851 : RJArrIntoStream.objArr(jo.getJsonArray("pseudoElements"), null, 0, DOM.Node.class).toArray(DOM.Node[]::new); 852 853 this.importedDocument = ReadJSON.getObject(jo, "importedDocument", DOM.Node.class, true, false); 854 this.distributedNodes = (jo.getJsonArray("distributedNodes") == null) 855 ? null 856 : RJArrIntoStream.objArr(jo.getJsonArray("distributedNodes"), null, 0, DOM.BackendNode.class).toArray(DOM.BackendNode[]::new); 857 858 this.isSVG = ReadBoxedJSON.getBoolean(jo, "isSVG", true); 859 this.compatibilityMode = ReadJSON.getString(jo, "compatibilityMode", true, false); 860 this.assignedSlot = ReadJSON.getObject(jo, "assignedSlot", DOM.BackendNode.class, true, false); 861 this.isScrollable = ReadBoxedJSON.getBoolean(jo, "isScrollable", true); 862 } 863 864 865 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 866 public boolean equals(Object other) 867 { 868 if (this == other) return true; 869 if (other == null) return false; 870 if (other.getClass() != this.getClass()) return false; 871 872 Node o = (Node) other; 873 874 return 875 Objects.equals(this.nodeId, o.nodeId) 876 && Objects.equals(this.parentId, o.parentId) 877 && Objects.equals(this.backendNodeId, o.backendNodeId) 878 && (this.nodeType == o.nodeType) 879 && Objects.equals(this.nodeName, o.nodeName) 880 && Objects.equals(this.localName, o.localName) 881 && Objects.equals(this.nodeValue, o.nodeValue) 882 && Objects.equals(this.childNodeCount, o.childNodeCount) 883 && Arrays.deepEquals(this.children, o.children) 884 && Arrays.deepEquals(this.attributes, o.attributes) 885 && Objects.equals(this.documentURL, o.documentURL) 886 && Objects.equals(this.baseURL, o.baseURL) 887 && Objects.equals(this.publicId, o.publicId) 888 && Objects.equals(this.systemId, o.systemId) 889 && Objects.equals(this.internalSubset, o.internalSubset) 890 && Objects.equals(this.xmlVersion, o.xmlVersion) 891 && Objects.equals(this.name, o.name) 892 && Objects.equals(this.value, o.value) 893 && Objects.equals(this.pseudoType, o.pseudoType) 894 && Objects.equals(this.pseudoIdentifier, o.pseudoIdentifier) 895 && Objects.equals(this.shadowRootType, o.shadowRootType) 896 && Objects.equals(this.frameId, o.frameId) 897 && Objects.equals(this.contentDocument, o.contentDocument) 898 && Arrays.deepEquals(this.shadowRoots, o.shadowRoots) 899 && Objects.equals(this.templateContent, o.templateContent) 900 && Arrays.deepEquals(this.pseudoElements, o.pseudoElements) 901 && Objects.equals(this.importedDocument, o.importedDocument) 902 && Arrays.deepEquals(this.distributedNodes, o.distributedNodes) 903 && Objects.equals(this.isSVG, o.isSVG) 904 && Objects.equals(this.compatibilityMode, o.compatibilityMode) 905 && Objects.equals(this.assignedSlot, o.assignedSlot) 906 && Objects.equals(this.isScrollable, o.isScrollable); 907 } 908 909 /** Generates a Hash-Code for {@code 'this'} instance */ 910 public int hashCode() 911 { 912 return 913 this.nodeId 914 + Objects.hashCode(this.parentId) 915 + this.backendNodeId 916 + this.nodeType 917 + Objects.hashCode(this.nodeName) 918 + Objects.hashCode(this.localName) 919 + Objects.hashCode(this.nodeValue) 920 + Objects.hashCode(this.childNodeCount) 921 + Arrays.deepHashCode(this.children) 922 + Arrays.deepHashCode(this.attributes) 923 + Objects.hashCode(this.documentURL) 924 + Objects.hashCode(this.baseURL) 925 + Objects.hashCode(this.publicId) 926 + Objects.hashCode(this.systemId) 927 + Objects.hashCode(this.internalSubset) 928 + Objects.hashCode(this.xmlVersion) 929 + Objects.hashCode(this.name) 930 + Objects.hashCode(this.value) 931 + Objects.hashCode(this.pseudoType) 932 + Objects.hashCode(this.pseudoIdentifier) 933 + Objects.hashCode(this.shadowRootType) 934 + Objects.hashCode(this.frameId) 935 + this.contentDocument.hashCode() 936 + Arrays.deepHashCode(this.shadowRoots) 937 + this.templateContent.hashCode() 938 + Arrays.deepHashCode(this.pseudoElements) 939 + this.importedDocument.hashCode() 940 + Arrays.deepHashCode(this.distributedNodes) 941 + Objects.hashCode(this.isSVG) 942 + Objects.hashCode(this.compatibilityMode) 943 + this.assignedSlot.hashCode() 944 + Objects.hashCode(this.isScrollable); 945 } 946 } 947 948 /** A structure to hold the top-level node of a detached tree and an array of its retained descendants. */ 949 public static class DetachedElementInfo 950 extends BaseType 951 implements java.io.Serializable 952 { 953 /** For Object Serialization. java.io.Serializable */ 954 protected static final long serialVersionUID = 1; 955 956 public boolean[] optionals() 957 { return new boolean[] { false, false, }; } 958 959 /** <CODE>[No Description Provided by Google]</CODE> */ 960 public final DOM.Node treeNode; 961 962 /** <CODE>[No Description Provided by Google]</CODE> */ 963 public final int[] retainedNodeIds; 964 965 /** 966 * Constructor 967 * 968 * @param treeNode - 969 * 970 * @param retainedNodeIds - 971 */ 972 public DetachedElementInfo(DOM.Node treeNode, int[] retainedNodeIds) 973 { 974 // Exception-Check(s) to ensure that if any parameters which are not declared as 975 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 976 977 if (treeNode == null) THROWS.throwNPE("treeNode"); 978 if (retainedNodeIds == null) THROWS.throwNPE("retainedNodeIds"); 979 980 this.treeNode = treeNode; 981 this.retainedNodeIds = retainedNodeIds; 982 } 983 984 /** 985 * JSON Object Constructor 986 * @param jo A Json-Object having data about an instance of {@code 'DetachedElementInfo'}. 987 */ 988 public DetachedElementInfo (JsonObject jo) 989 { 990 this.treeNode = ReadJSON.getObject(jo, "treeNode", DOM.Node.class, false, true); 991 this.retainedNodeIds = (jo.getJsonArray("retainedNodeIds") == null) 992 ? null 993 : RJArrIntoPrimArray.intArr(jo.getJsonArray("retainedNodeIds"), -1, 0, null); 994 995 } 996 997 998 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 999 public boolean equals(Object other) 1000 { 1001 if (this == other) return true; 1002 if (other == null) return false; 1003 if (other.getClass() != this.getClass()) return false; 1004 1005 DetachedElementInfo o = (DetachedElementInfo) other; 1006 1007 return 1008 Objects.equals(this.treeNode, o.treeNode) 1009 && Arrays.equals(this.retainedNodeIds, o.retainedNodeIds); 1010 } 1011 1012 /** Generates a Hash-Code for {@code 'this'} instance */ 1013 public int hashCode() 1014 { 1015 return 1016 this.treeNode.hashCode() 1017 + Arrays.hashCode(this.retainedNodeIds); 1018 } 1019 } 1020 1021 /** A structure holding an RGBA color. */ 1022 public static class RGBA 1023 extends BaseType 1024 implements java.io.Serializable 1025 { 1026 /** For Object Serialization. java.io.Serializable */ 1027 protected static final long serialVersionUID = 1; 1028 1029 public boolean[] optionals() 1030 { return new boolean[] { false, false, false, true, }; } 1031 1032 /** The red component, in the [0-255] range. */ 1033 public final int r; 1034 1035 /** The green component, in the [0-255] range. */ 1036 public final int g; 1037 1038 /** The blue component, in the [0-255] range. */ 1039 public final int b; 1040 1041 /** 1042 * The alpha component, in the [0-1] range (default: 1). 1043 * <BR /><B CLASS=Opt>OPTIONAL</B> 1044 */ 1045 public final Number a; 1046 1047 /** 1048 * Constructor 1049 * 1050 * @param r The red component, in the [0-255] range. 1051 * 1052 * @param g The green component, in the [0-255] range. 1053 * 1054 * @param b The blue component, in the [0-255] range. 1055 * 1056 * @param a The alpha component, in the [0-1] range (default: 1). 1057 * <BR /><B CLASS=Opt>OPTIONAL</B> 1058 */ 1059 public RGBA(int r, int g, int b, Number a) 1060 { 1061 this.r = r; 1062 this.g = g; 1063 this.b = b; 1064 this.a = a; 1065 } 1066 1067 /** 1068 * JSON Object Constructor 1069 * @param jo A Json-Object having data about an instance of {@code 'RGBA'}. 1070 */ 1071 public RGBA (JsonObject jo) 1072 { 1073 this.r = ReadPrimJSON.getInt(jo, "r"); 1074 this.g = ReadPrimJSON.getInt(jo, "g"); 1075 this.b = ReadPrimJSON.getInt(jo, "b"); 1076 this.a = ReadNumberJSON.get(jo, "a", true, false); 1077 } 1078 1079 1080 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1081 public boolean equals(Object other) 1082 { 1083 if (this == other) return true; 1084 if (other == null) return false; 1085 if (other.getClass() != this.getClass()) return false; 1086 1087 RGBA o = (RGBA) other; 1088 1089 return 1090 (this.r == o.r) 1091 && (this.g == o.g) 1092 && (this.b == o.b) 1093 && Objects.equals(this.a, o.a); 1094 } 1095 1096 /** Generates a Hash-Code for {@code 'this'} instance */ 1097 public int hashCode() 1098 { 1099 return 1100 this.r 1101 + this.g 1102 + this.b 1103 + Objects.hashCode(this.a); 1104 } 1105 } 1106 1107 /** Box model. */ 1108 public static class BoxModel 1109 extends BaseType 1110 implements java.io.Serializable 1111 { 1112 /** For Object Serialization. java.io.Serializable */ 1113 protected static final long serialVersionUID = 1; 1114 1115 public boolean[] optionals() 1116 { return new boolean[] { false, false, false, false, false, false, true, }; } 1117 1118 /** Content box */ 1119 public final Number[] content; 1120 1121 /** Padding box */ 1122 public final Number[] padding; 1123 1124 /** Border box */ 1125 public final Number[] border; 1126 1127 /** Margin box */ 1128 public final Number[] margin; 1129 1130 /** Node width */ 1131 public final int width; 1132 1133 /** Node height */ 1134 public final int height; 1135 1136 /** 1137 * Shape outside coordinates 1138 * <BR /><B CLASS=Opt>OPTIONAL</B> 1139 */ 1140 public final DOM.ShapeOutsideInfo shapeOutside; 1141 1142 /** 1143 * Constructor 1144 * 1145 * @param content Content box 1146 * 1147 * @param padding Padding box 1148 * 1149 * @param border Border box 1150 * 1151 * @param margin Margin box 1152 * 1153 * @param width Node width 1154 * 1155 * @param height Node height 1156 * 1157 * @param shapeOutside Shape outside coordinates 1158 * <BR /><B CLASS=Opt>OPTIONAL</B> 1159 */ 1160 public BoxModel( 1161 Number[] content, Number[] padding, Number[] border, Number[] margin, int width, 1162 int height, DOM.ShapeOutsideInfo shapeOutside 1163 ) 1164 { 1165 // Exception-Check(s) to ensure that if any parameters which are not declared as 1166 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1167 1168 if (content == null) THROWS.throwNPE("content"); 1169 if (padding == null) THROWS.throwNPE("padding"); 1170 if (border == null) THROWS.throwNPE("border"); 1171 if (margin == null) THROWS.throwNPE("margin"); 1172 1173 this.content = content; 1174 this.padding = padding; 1175 this.border = border; 1176 this.margin = margin; 1177 this.width = width; 1178 this.height = height; 1179 this.shapeOutside = shapeOutside; 1180 } 1181 1182 /** 1183 * JSON Object Constructor 1184 * @param jo A Json-Object having data about an instance of {@code 'BoxModel'}. 1185 */ 1186 public BoxModel (JsonObject jo) 1187 { 1188 this.content = (jo.getJsonArray("content") == null) 1189 ? null 1190 : RJArrIntoBoxedStream.numberArr(jo.getJsonArray("content"), -1, 0, null).toArray(Number[]::new); 1191 1192 this.padding = (jo.getJsonArray("padding") == null) 1193 ? null 1194 : RJArrIntoBoxedStream.numberArr(jo.getJsonArray("padding"), -1, 0, null).toArray(Number[]::new); 1195 1196 this.border = (jo.getJsonArray("border") == null) 1197 ? null 1198 : RJArrIntoBoxedStream.numberArr(jo.getJsonArray("border"), -1, 0, null).toArray(Number[]::new); 1199 1200 this.margin = (jo.getJsonArray("margin") == null) 1201 ? null 1202 : RJArrIntoBoxedStream.numberArr(jo.getJsonArray("margin"), -1, 0, null).toArray(Number[]::new); 1203 1204 this.width = ReadPrimJSON.getInt(jo, "width"); 1205 this.height = ReadPrimJSON.getInt(jo, "height"); 1206 this.shapeOutside = ReadJSON.getObject(jo, "shapeOutside", DOM.ShapeOutsideInfo.class, true, false); 1207 } 1208 1209 1210 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1211 public boolean equals(Object other) 1212 { 1213 if (this == other) return true; 1214 if (other == null) return false; 1215 if (other.getClass() != this.getClass()) return false; 1216 1217 BoxModel o = (BoxModel) other; 1218 1219 return 1220 Objects.equals(this.content, o.content) 1221 && Objects.equals(this.padding, o.padding) 1222 && Objects.equals(this.border, o.border) 1223 && Objects.equals(this.margin, o.margin) 1224 && (this.width == o.width) 1225 && (this.height == o.height) 1226 && Objects.equals(this.shapeOutside, o.shapeOutside); 1227 } 1228 1229 /** Generates a Hash-Code for {@code 'this'} instance */ 1230 public int hashCode() 1231 { 1232 return 1233 Arrays.deepHashCode(this.content) 1234 + Arrays.deepHashCode(this.padding) 1235 + Arrays.deepHashCode(this.border) 1236 + Arrays.deepHashCode(this.margin) 1237 + this.width 1238 + this.height 1239 + this.shapeOutside.hashCode(); 1240 } 1241 } 1242 1243 /** CSS Shape Outside details. */ 1244 public static class ShapeOutsideInfo 1245 extends BaseType 1246 implements java.io.Serializable 1247 { 1248 /** For Object Serialization. java.io.Serializable */ 1249 protected static final long serialVersionUID = 1; 1250 1251 public boolean[] optionals() 1252 { return new boolean[] { false, false, false, }; } 1253 1254 /** Shape bounds */ 1255 public final Number[] bounds; 1256 1257 /** Shape coordinate details */ 1258 public final JsonArray shape; 1259 1260 /** Margin shape bounds */ 1261 public final JsonArray marginShape; 1262 1263 /** 1264 * Constructor 1265 * 1266 * @param bounds Shape bounds 1267 * 1268 * @param shape Shape coordinate details 1269 * 1270 * @param marginShape Margin shape bounds 1271 */ 1272 public ShapeOutsideInfo(Number[] bounds, JsonArray shape, JsonArray marginShape) 1273 { 1274 // Exception-Check(s) to ensure that if any parameters which are not declared as 1275 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1276 1277 if (bounds == null) THROWS.throwNPE("bounds"); 1278 if (shape == null) THROWS.throwNPE("shape"); 1279 if (marginShape == null) THROWS.throwNPE("marginShape"); 1280 1281 this.bounds = bounds; 1282 this.shape = shape; 1283 this.marginShape = marginShape; 1284 } 1285 1286 /** 1287 * JSON Object Constructor 1288 * @param jo A Json-Object having data about an instance of {@code 'ShapeOutsideInfo'}. 1289 */ 1290 public ShapeOutsideInfo (JsonObject jo) 1291 { 1292 this.bounds = (jo.getJsonArray("bounds") == null) 1293 ? null 1294 : RJArrIntoBoxedStream.numberArr(jo.getJsonArray("bounds"), -1, 0, null).toArray(Number[]::new); 1295 1296 this.shape = jo.getJsonArray("shape"); 1297 this.marginShape = jo.getJsonArray("marginShape"); 1298 } 1299 1300 1301 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1302 public boolean equals(Object other) 1303 { 1304 if (this == other) return true; 1305 if (other == null) return false; 1306 if (other.getClass() != this.getClass()) return false; 1307 1308 ShapeOutsideInfo o = (ShapeOutsideInfo) other; 1309 1310 return 1311 Objects.equals(this.bounds, o.bounds) 1312 && Objects.equals(this.shape, o.shape) 1313 && Objects.equals(this.marginShape, o.marginShape); 1314 } 1315 1316 /** Generates a Hash-Code for {@code 'this'} instance */ 1317 public int hashCode() 1318 { 1319 return 1320 Arrays.deepHashCode(this.bounds) 1321 + Objects.hashCode(this.shape) 1322 + Objects.hashCode(this.marginShape); 1323 } 1324 } 1325 1326 /** Rectangle. */ 1327 public static class Rect 1328 extends BaseType 1329 implements java.io.Serializable 1330 { 1331 /** For Object Serialization. java.io.Serializable */ 1332 protected static final long serialVersionUID = 1; 1333 1334 public boolean[] optionals() 1335 { return new boolean[] { false, false, false, false, }; } 1336 1337 /** X coordinate */ 1338 public final Number x; 1339 1340 /** Y coordinate */ 1341 public final Number y; 1342 1343 /** Rectangle width */ 1344 public final Number width; 1345 1346 /** Rectangle height */ 1347 public final Number height; 1348 1349 /** 1350 * Constructor 1351 * 1352 * @param x X coordinate 1353 * 1354 * @param y Y coordinate 1355 * 1356 * @param width Rectangle width 1357 * 1358 * @param height Rectangle height 1359 */ 1360 public Rect(Number x, Number y, Number width, Number height) 1361 { 1362 // Exception-Check(s) to ensure that if any parameters which are not declared as 1363 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1364 1365 if (x == null) THROWS.throwNPE("x"); 1366 if (y == null) THROWS.throwNPE("y"); 1367 if (width == null) THROWS.throwNPE("width"); 1368 if (height == null) THROWS.throwNPE("height"); 1369 1370 this.x = x; 1371 this.y = y; 1372 this.width = width; 1373 this.height = height; 1374 } 1375 1376 /** 1377 * JSON Object Constructor 1378 * @param jo A Json-Object having data about an instance of {@code 'Rect'}. 1379 */ 1380 public Rect (JsonObject jo) 1381 { 1382 this.x = ReadNumberJSON.get(jo, "x", false, true); 1383 this.y = ReadNumberJSON.get(jo, "y", false, true); 1384 this.width = ReadNumberJSON.get(jo, "width", false, true); 1385 this.height = ReadNumberJSON.get(jo, "height", false, true); 1386 } 1387 1388 1389 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1390 public boolean equals(Object other) 1391 { 1392 if (this == other) return true; 1393 if (other == null) return false; 1394 if (other.getClass() != this.getClass()) return false; 1395 1396 Rect o = (Rect) other; 1397 1398 return 1399 Objects.equals(this.x, o.x) 1400 && Objects.equals(this.y, o.y) 1401 && Objects.equals(this.width, o.width) 1402 && Objects.equals(this.height, o.height); 1403 } 1404 1405 /** Generates a Hash-Code for {@code 'this'} instance */ 1406 public int hashCode() 1407 { 1408 return 1409 Objects.hashCode(this.x) 1410 + Objects.hashCode(this.y) 1411 + Objects.hashCode(this.width) 1412 + Objects.hashCode(this.height); 1413 } 1414 } 1415 1416 /** <CODE>[No Description Provided by Google]</CODE> */ 1417 public static class CSSComputedStyleProperty 1418 extends BaseType 1419 implements java.io.Serializable 1420 { 1421 /** For Object Serialization. java.io.Serializable */ 1422 protected static final long serialVersionUID = 1; 1423 1424 public boolean[] optionals() 1425 { return new boolean[] { false, false, }; } 1426 1427 /** Computed style property name. */ 1428 public final String name; 1429 1430 /** Computed style property value. */ 1431 public final String value; 1432 1433 /** 1434 * Constructor 1435 * 1436 * @param name Computed style property name. 1437 * 1438 * @param value Computed style property value. 1439 */ 1440 public CSSComputedStyleProperty(String name, String value) 1441 { 1442 // Exception-Check(s) to ensure that if any parameters which are not declared as 1443 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1444 1445 if (name == null) THROWS.throwNPE("name"); 1446 if (value == null) THROWS.throwNPE("value"); 1447 1448 this.name = name; 1449 this.value = value; 1450 } 1451 1452 /** 1453 * JSON Object Constructor 1454 * @param jo A Json-Object having data about an instance of {@code 'CSSComputedStyleProperty'}. 1455 */ 1456 public CSSComputedStyleProperty (JsonObject jo) 1457 { 1458 this.name = ReadJSON.getString(jo, "name", false, true); 1459 this.value = ReadJSON.getString(jo, "value", false, true); 1460 } 1461 1462 1463 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1464 public boolean equals(Object other) 1465 { 1466 if (this == other) return true; 1467 if (other == null) return false; 1468 if (other.getClass() != this.getClass()) return false; 1469 1470 CSSComputedStyleProperty o = (CSSComputedStyleProperty) other; 1471 1472 return 1473 Objects.equals(this.name, o.name) 1474 && Objects.equals(this.value, o.value); 1475 } 1476 1477 /** Generates a Hash-Code for {@code 'this'} instance */ 1478 public int hashCode() 1479 { 1480 return 1481 Objects.hashCode(this.name) 1482 + Objects.hashCode(this.value); 1483 } 1484 } 1485 1486 /** 1487 * Fired when {@code Document} has been totally updated. Node ids are no longer valid. 1488 * 1489 * <BR /><BR />This is Marker-Event. Marker-Event's are Events that do not posses 1490 * any data, fields or state. When they are fired, only the event name is supplied. 1491 */ 1492 public static class documentUpdated 1493 extends BrowserEvent 1494 implements java.io.Serializable 1495 { 1496 /** For Object Serialization. java.io.Serializable */ 1497 protected static final long serialVersionUID = 1; 1498 1499 public boolean[] optionals() { return new boolean[0]; } 1500 1501 /** JSON Object Constructor */ 1502 public documentUpdated(JsonObject jo) 1503 { super("DOM", "documentUpdated", 0); } 1504 1505 @Override 1506 public String toString() { return "DOM.documentUpdated Marker Event\n"; } 1507 } 1508 1509 /** 1510 * Called when top layer elements are changed. 1511 * <BR /> 1512 * <BR /><B>EXPERIMENTAL</B> 1513 * 1514 * <BR /><BR />This is Marker-Event. Marker-Event's are Events that do not posses 1515 * any data, fields or state. When they are fired, only the event name is supplied. 1516 */ 1517 public static class topLayerElementsUpdated 1518 extends BrowserEvent 1519 implements java.io.Serializable 1520 { 1521 /** For Object Serialization. java.io.Serializable */ 1522 protected static final long serialVersionUID = 1; 1523 1524 public boolean[] optionals() { return new boolean[0]; } 1525 1526 /** JSON Object Constructor */ 1527 public topLayerElementsUpdated(JsonObject jo) 1528 { super("DOM", "topLayerElementsUpdated", 0); } 1529 1530 @Override 1531 public String toString() { return "DOM.topLayerElementsUpdated Marker Event\n"; } 1532 } 1533 1534 /** Fired when {@code Element}'s attribute is modified. */ 1535 public static class attributeModified 1536 extends BrowserEvent 1537 implements java.io.Serializable 1538 { 1539 /** For Object Serialization. java.io.Serializable */ 1540 protected static final long serialVersionUID = 1; 1541 1542 public boolean[] optionals() 1543 { return new boolean[] { false, false, false, }; } 1544 1545 /** Id of the node that has changed. */ 1546 public final int nodeId; 1547 1548 /** Attribute name. */ 1549 public final String name; 1550 1551 /** Attribute value. */ 1552 public final String value; 1553 1554 /** 1555 * Constructor 1556 * 1557 * @param nodeId Id of the node that has changed. 1558 * 1559 * @param name Attribute name. 1560 * 1561 * @param value Attribute value. 1562 */ 1563 public attributeModified(int nodeId, String name, String value) 1564 { 1565 super("DOM", "attributeModified", 3); 1566 1567 // Exception-Check(s) to ensure that if any parameters which are not declared as 1568 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1569 1570 if (name == null) THROWS.throwNPE("name"); 1571 if (value == null) THROWS.throwNPE("value"); 1572 1573 this.nodeId = nodeId; 1574 this.name = name; 1575 this.value = value; 1576 } 1577 1578 /** 1579 * JSON Object Constructor 1580 * @param jo A Json-Object having data about an instance of {@code 'attributeModified'}. 1581 */ 1582 public attributeModified (JsonObject jo) 1583 { 1584 super("DOM", "attributeModified", 3); 1585 1586 this.nodeId = ReadPrimJSON.getInt(jo, "nodeId"); 1587 this.name = ReadJSON.getString(jo, "name", false, true); 1588 this.value = ReadJSON.getString(jo, "value", false, true); 1589 } 1590 1591 1592 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1593 public boolean equals(Object other) 1594 { 1595 if (this == other) return true; 1596 if (other == null) return false; 1597 if (other.getClass() != this.getClass()) return false; 1598 1599 attributeModified o = (attributeModified) other; 1600 1601 return 1602 Objects.equals(this.nodeId, o.nodeId) 1603 && Objects.equals(this.name, o.name) 1604 && Objects.equals(this.value, o.value); 1605 } 1606 1607 /** Generates a Hash-Code for {@code 'this'} instance */ 1608 public int hashCode() 1609 { 1610 return 1611 this.nodeId 1612 + Objects.hashCode(this.name) 1613 + Objects.hashCode(this.value); 1614 } 1615 } 1616 1617 /** Fired when {@code Element}'s attribute is removed. */ 1618 public static class attributeRemoved 1619 extends BrowserEvent 1620 implements java.io.Serializable 1621 { 1622 /** For Object Serialization. java.io.Serializable */ 1623 protected static final long serialVersionUID = 1; 1624 1625 public boolean[] optionals() 1626 { return new boolean[] { false, false, }; } 1627 1628 /** Id of the node that has changed. */ 1629 public final int nodeId; 1630 1631 /** A ttribute name. */ 1632 public final String name; 1633 1634 /** 1635 * Constructor 1636 * 1637 * @param nodeId Id of the node that has changed. 1638 * 1639 * @param name A ttribute name. 1640 */ 1641 public attributeRemoved(int nodeId, String name) 1642 { 1643 super("DOM", "attributeRemoved", 2); 1644 1645 // Exception-Check(s) to ensure that if any parameters which are not declared as 1646 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1647 1648 if (name == null) THROWS.throwNPE("name"); 1649 1650 this.nodeId = nodeId; 1651 this.name = name; 1652 } 1653 1654 /** 1655 * JSON Object Constructor 1656 * @param jo A Json-Object having data about an instance of {@code 'attributeRemoved'}. 1657 */ 1658 public attributeRemoved (JsonObject jo) 1659 { 1660 super("DOM", "attributeRemoved", 2); 1661 1662 this.nodeId = ReadPrimJSON.getInt(jo, "nodeId"); 1663 this.name = ReadJSON.getString(jo, "name", false, true); 1664 } 1665 1666 1667 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1668 public boolean equals(Object other) 1669 { 1670 if (this == other) return true; 1671 if (other == null) return false; 1672 if (other.getClass() != this.getClass()) return false; 1673 1674 attributeRemoved o = (attributeRemoved) other; 1675 1676 return 1677 Objects.equals(this.nodeId, o.nodeId) 1678 && Objects.equals(this.name, o.name); 1679 } 1680 1681 /** Generates a Hash-Code for {@code 'this'} instance */ 1682 public int hashCode() 1683 { 1684 return 1685 this.nodeId 1686 + Objects.hashCode(this.name); 1687 } 1688 } 1689 1690 /** Mirrors {@code DOMCharacterDataModified} event. */ 1691 public static class characterDataModified 1692 extends BrowserEvent 1693 implements java.io.Serializable 1694 { 1695 /** For Object Serialization. java.io.Serializable */ 1696 protected static final long serialVersionUID = 1; 1697 1698 public boolean[] optionals() 1699 { return new boolean[] { false, false, }; } 1700 1701 /** Id of the node that has changed. */ 1702 public final int nodeId; 1703 1704 /** New text value. */ 1705 public final String characterData; 1706 1707 /** 1708 * Constructor 1709 * 1710 * @param nodeId Id of the node that has changed. 1711 * 1712 * @param characterData New text value. 1713 */ 1714 public characterDataModified(int nodeId, String characterData) 1715 { 1716 super("DOM", "characterDataModified", 2); 1717 1718 // Exception-Check(s) to ensure that if any parameters which are not declared as 1719 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1720 1721 if (characterData == null) THROWS.throwNPE("characterData"); 1722 1723 this.nodeId = nodeId; 1724 this.characterData = characterData; 1725 } 1726 1727 /** 1728 * JSON Object Constructor 1729 * @param jo A Json-Object having data about an instance of {@code 'characterDataModified'}. 1730 */ 1731 public characterDataModified (JsonObject jo) 1732 { 1733 super("DOM", "characterDataModified", 2); 1734 1735 this.nodeId = ReadPrimJSON.getInt(jo, "nodeId"); 1736 this.characterData = ReadJSON.getString(jo, "characterData", false, true); 1737 } 1738 1739 1740 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1741 public boolean equals(Object other) 1742 { 1743 if (this == other) return true; 1744 if (other == null) return false; 1745 if (other.getClass() != this.getClass()) return false; 1746 1747 characterDataModified o = (characterDataModified) other; 1748 1749 return 1750 Objects.equals(this.nodeId, o.nodeId) 1751 && Objects.equals(this.characterData, o.characterData); 1752 } 1753 1754 /** Generates a Hash-Code for {@code 'this'} instance */ 1755 public int hashCode() 1756 { 1757 return 1758 this.nodeId 1759 + Objects.hashCode(this.characterData); 1760 } 1761 } 1762 1763 /** Fired when {@code Container}'s child node count has changed. */ 1764 public static class childNodeCountUpdated 1765 extends BrowserEvent 1766 implements java.io.Serializable 1767 { 1768 /** For Object Serialization. java.io.Serializable */ 1769 protected static final long serialVersionUID = 1; 1770 1771 public boolean[] optionals() 1772 { return new boolean[] { false, false, }; } 1773 1774 /** Id of the node that has changed. */ 1775 public final int nodeId; 1776 1777 /** New node count. */ 1778 public final int childNodeCount; 1779 1780 /** 1781 * Constructor 1782 * 1783 * @param nodeId Id of the node that has changed. 1784 * 1785 * @param childNodeCount New node count. 1786 */ 1787 public childNodeCountUpdated(int nodeId, int childNodeCount) 1788 { 1789 super("DOM", "childNodeCountUpdated", 2); 1790 1791 this.nodeId = nodeId; 1792 this.childNodeCount = childNodeCount; 1793 } 1794 1795 /** 1796 * JSON Object Constructor 1797 * @param jo A Json-Object having data about an instance of {@code 'childNodeCountUpdated'}. 1798 */ 1799 public childNodeCountUpdated (JsonObject jo) 1800 { 1801 super("DOM", "childNodeCountUpdated", 2); 1802 1803 this.nodeId = ReadPrimJSON.getInt(jo, "nodeId"); 1804 this.childNodeCount = ReadPrimJSON.getInt(jo, "childNodeCount"); 1805 } 1806 1807 1808 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1809 public boolean equals(Object other) 1810 { 1811 if (this == other) return true; 1812 if (other == null) return false; 1813 if (other.getClass() != this.getClass()) return false; 1814 1815 childNodeCountUpdated o = (childNodeCountUpdated) other; 1816 1817 return 1818 Objects.equals(this.nodeId, o.nodeId) 1819 && (this.childNodeCount == o.childNodeCount); 1820 } 1821 1822 /** Generates a Hash-Code for {@code 'this'} instance */ 1823 public int hashCode() 1824 { 1825 return 1826 this.nodeId 1827 + this.childNodeCount; 1828 } 1829 } 1830 1831 /** Mirrors {@code DOMNodeInserted} event. */ 1832 public static class childNodeInserted 1833 extends BrowserEvent 1834 implements java.io.Serializable 1835 { 1836 /** For Object Serialization. java.io.Serializable */ 1837 protected static final long serialVersionUID = 1; 1838 1839 public boolean[] optionals() 1840 { return new boolean[] { false, false, false, }; } 1841 1842 /** Id of the node that has changed. */ 1843 public final int parentNodeId; 1844 1845 /** Id of the previous sibling. */ 1846 public final int previousNodeId; 1847 1848 /** Inserted node data. */ 1849 public final DOM.Node node; 1850 1851 /** 1852 * Constructor 1853 * 1854 * @param parentNodeId Id of the node that has changed. 1855 * 1856 * @param previousNodeId Id of the previous sibling. 1857 * 1858 * @param node Inserted node data. 1859 */ 1860 public childNodeInserted(int parentNodeId, int previousNodeId, DOM.Node node) 1861 { 1862 super("DOM", "childNodeInserted", 3); 1863 1864 // Exception-Check(s) to ensure that if any parameters which are not declared as 1865 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 1866 1867 if (node == null) THROWS.throwNPE("node"); 1868 1869 this.parentNodeId = parentNodeId; 1870 this.previousNodeId = previousNodeId; 1871 this.node = node; 1872 } 1873 1874 /** 1875 * JSON Object Constructor 1876 * @param jo A Json-Object having data about an instance of {@code 'childNodeInserted'}. 1877 */ 1878 public childNodeInserted (JsonObject jo) 1879 { 1880 super("DOM", "childNodeInserted", 3); 1881 1882 this.parentNodeId = ReadPrimJSON.getInt(jo, "parentNodeId"); 1883 this.previousNodeId = ReadPrimJSON.getInt(jo, "previousNodeId"); 1884 this.node = ReadJSON.getObject(jo, "node", DOM.Node.class, false, true); 1885 } 1886 1887 1888 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1889 public boolean equals(Object other) 1890 { 1891 if (this == other) return true; 1892 if (other == null) return false; 1893 if (other.getClass() != this.getClass()) return false; 1894 1895 childNodeInserted o = (childNodeInserted) other; 1896 1897 return 1898 Objects.equals(this.parentNodeId, o.parentNodeId) 1899 && Objects.equals(this.previousNodeId, o.previousNodeId) 1900 && Objects.equals(this.node, o.node); 1901 } 1902 1903 /** Generates a Hash-Code for {@code 'this'} instance */ 1904 public int hashCode() 1905 { 1906 return 1907 this.parentNodeId 1908 + this.previousNodeId 1909 + this.node.hashCode(); 1910 } 1911 } 1912 1913 /** Mirrors {@code DOMNodeRemoved} event. */ 1914 public static class childNodeRemoved 1915 extends BrowserEvent 1916 implements java.io.Serializable 1917 { 1918 /** For Object Serialization. java.io.Serializable */ 1919 protected static final long serialVersionUID = 1; 1920 1921 public boolean[] optionals() 1922 { return new boolean[] { false, false, }; } 1923 1924 /** Parent id. */ 1925 public final int parentNodeId; 1926 1927 /** Id of the node that has been removed. */ 1928 public final int nodeId; 1929 1930 /** 1931 * Constructor 1932 * 1933 * @param parentNodeId Parent id. 1934 * 1935 * @param nodeId Id of the node that has been removed. 1936 */ 1937 public childNodeRemoved(int parentNodeId, int nodeId) 1938 { 1939 super("DOM", "childNodeRemoved", 2); 1940 1941 this.parentNodeId = parentNodeId; 1942 this.nodeId = nodeId; 1943 } 1944 1945 /** 1946 * JSON Object Constructor 1947 * @param jo A Json-Object having data about an instance of {@code 'childNodeRemoved'}. 1948 */ 1949 public childNodeRemoved (JsonObject jo) 1950 { 1951 super("DOM", "childNodeRemoved", 2); 1952 1953 this.parentNodeId = ReadPrimJSON.getInt(jo, "parentNodeId"); 1954 this.nodeId = ReadPrimJSON.getInt(jo, "nodeId"); 1955 } 1956 1957 1958 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 1959 public boolean equals(Object other) 1960 { 1961 if (this == other) return true; 1962 if (other == null) return false; 1963 if (other.getClass() != this.getClass()) return false; 1964 1965 childNodeRemoved o = (childNodeRemoved) other; 1966 1967 return 1968 Objects.equals(this.parentNodeId, o.parentNodeId) 1969 && Objects.equals(this.nodeId, o.nodeId); 1970 } 1971 1972 /** Generates a Hash-Code for {@code 'this'} instance */ 1973 public int hashCode() 1974 { 1975 return 1976 this.parentNodeId 1977 + this.nodeId; 1978 } 1979 } 1980 1981 /** 1982 * Called when distribution is changed. 1983 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 1984 */ 1985 public static class distributedNodesUpdated 1986 extends BrowserEvent 1987 implements java.io.Serializable 1988 { 1989 /** For Object Serialization. java.io.Serializable */ 1990 protected static final long serialVersionUID = 1; 1991 1992 public boolean[] optionals() 1993 { return new boolean[] { false, false, }; } 1994 1995 /** Insertion point where distributed nodes were updated. */ 1996 public final int insertionPointId; 1997 1998 /** Distributed nodes for given insertion point. */ 1999 public final DOM.BackendNode[] distributedNodes; 2000 2001 /** 2002 * Constructor 2003 * 2004 * @param insertionPointId Insertion point where distributed nodes were updated. 2005 * 2006 * @param distributedNodes Distributed nodes for given insertion point. 2007 */ 2008 public distributedNodesUpdated(int insertionPointId, DOM.BackendNode[] distributedNodes) 2009 { 2010 super("DOM", "distributedNodesUpdated", 2); 2011 2012 // Exception-Check(s) to ensure that if any parameters which are not declared as 2013 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2014 2015 if (distributedNodes == null) THROWS.throwNPE("distributedNodes"); 2016 2017 this.insertionPointId = insertionPointId; 2018 this.distributedNodes = distributedNodes; 2019 } 2020 2021 /** 2022 * JSON Object Constructor 2023 * @param jo A Json-Object having data about an instance of {@code 'distributedNodesUpdated'}. 2024 */ 2025 public distributedNodesUpdated (JsonObject jo) 2026 { 2027 super("DOM", "distributedNodesUpdated", 2); 2028 2029 this.insertionPointId = ReadPrimJSON.getInt(jo, "insertionPointId"); 2030 this.distributedNodes = (jo.getJsonArray("distributedNodes") == null) 2031 ? null 2032 : RJArrIntoStream.objArr(jo.getJsonArray("distributedNodes"), null, 0, DOM.BackendNode.class).toArray(DOM.BackendNode[]::new); 2033 2034 } 2035 2036 2037 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2038 public boolean equals(Object other) 2039 { 2040 if (this == other) return true; 2041 if (other == null) return false; 2042 if (other.getClass() != this.getClass()) return false; 2043 2044 distributedNodesUpdated o = (distributedNodesUpdated) other; 2045 2046 return 2047 Objects.equals(this.insertionPointId, o.insertionPointId) 2048 && Arrays.deepEquals(this.distributedNodes, o.distributedNodes); 2049 } 2050 2051 /** Generates a Hash-Code for {@code 'this'} instance */ 2052 public int hashCode() 2053 { 2054 return 2055 this.insertionPointId 2056 + Arrays.deepHashCode(this.distributedNodes); 2057 } 2058 } 2059 2060 /** 2061 * Fired when {@code Element}'s inline style is modified via a CSS property modification. 2062 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2063 */ 2064 public static class inlineStyleInvalidated 2065 extends BrowserEvent 2066 implements java.io.Serializable 2067 { 2068 /** For Object Serialization. java.io.Serializable */ 2069 protected static final long serialVersionUID = 1; 2070 2071 public boolean[] optionals() 2072 { return new boolean[] { false, }; } 2073 2074 /** Ids of the nodes for which the inline styles have been invalidated. */ 2075 public final int[] nodeIds; 2076 2077 /** 2078 * Constructor 2079 * 2080 * @param nodeIds Ids of the nodes for which the inline styles have been invalidated. 2081 */ 2082 public inlineStyleInvalidated(int[] nodeIds) 2083 { 2084 super("DOM", "inlineStyleInvalidated", 1); 2085 2086 // Exception-Check(s) to ensure that if any parameters which are not declared as 2087 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2088 2089 if (nodeIds == null) THROWS.throwNPE("nodeIds"); 2090 2091 this.nodeIds = nodeIds; 2092 } 2093 2094 /** 2095 * JSON Object Constructor 2096 * @param jo A Json-Object having data about an instance of {@code 'inlineStyleInvalidated'}. 2097 */ 2098 public inlineStyleInvalidated (JsonObject jo) 2099 { 2100 super("DOM", "inlineStyleInvalidated", 1); 2101 2102 this.nodeIds = (jo.getJsonArray("nodeIds") == null) 2103 ? null 2104 : RJArrIntoPrimArray.intArr(jo.getJsonArray("nodeIds"), -1, 0, null); 2105 2106 } 2107 2108 2109 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2110 public boolean equals(Object other) 2111 { 2112 if (this == other) return true; 2113 if (other == null) return false; 2114 if (other.getClass() != this.getClass()) return false; 2115 2116 inlineStyleInvalidated o = (inlineStyleInvalidated) other; 2117 2118 return 2119 Arrays.equals(this.nodeIds, o.nodeIds); 2120 } 2121 2122 /** Generates a Hash-Code for {@code 'this'} instance */ 2123 public int hashCode() 2124 { 2125 return 2126 Arrays.hashCode(this.nodeIds); 2127 } 2128 } 2129 2130 /** 2131 * Called when a pseudo element is added to an element. 2132 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2133 */ 2134 public static class pseudoElementAdded 2135 extends BrowserEvent 2136 implements java.io.Serializable 2137 { 2138 /** For Object Serialization. java.io.Serializable */ 2139 protected static final long serialVersionUID = 1; 2140 2141 public boolean[] optionals() 2142 { return new boolean[] { false, false, }; } 2143 2144 /** Pseudo element's parent element id. */ 2145 public final int parentId; 2146 2147 /** The added pseudo element. */ 2148 public final DOM.Node pseudoElement; 2149 2150 /** 2151 * Constructor 2152 * 2153 * @param parentId Pseudo element's parent element id. 2154 * 2155 * @param pseudoElement The added pseudo element. 2156 */ 2157 public pseudoElementAdded(int parentId, DOM.Node pseudoElement) 2158 { 2159 super("DOM", "pseudoElementAdded", 2); 2160 2161 // Exception-Check(s) to ensure that if any parameters which are not declared as 2162 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2163 2164 if (pseudoElement == null) THROWS.throwNPE("pseudoElement"); 2165 2166 this.parentId = parentId; 2167 this.pseudoElement = pseudoElement; 2168 } 2169 2170 /** 2171 * JSON Object Constructor 2172 * @param jo A Json-Object having data about an instance of {@code 'pseudoElementAdded'}. 2173 */ 2174 public pseudoElementAdded (JsonObject jo) 2175 { 2176 super("DOM", "pseudoElementAdded", 2); 2177 2178 this.parentId = ReadPrimJSON.getInt(jo, "parentId"); 2179 this.pseudoElement = ReadJSON.getObject(jo, "pseudoElement", DOM.Node.class, false, true); 2180 } 2181 2182 2183 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2184 public boolean equals(Object other) 2185 { 2186 if (this == other) return true; 2187 if (other == null) return false; 2188 if (other.getClass() != this.getClass()) return false; 2189 2190 pseudoElementAdded o = (pseudoElementAdded) other; 2191 2192 return 2193 Objects.equals(this.parentId, o.parentId) 2194 && Objects.equals(this.pseudoElement, o.pseudoElement); 2195 } 2196 2197 /** Generates a Hash-Code for {@code 'this'} instance */ 2198 public int hashCode() 2199 { 2200 return 2201 this.parentId 2202 + this.pseudoElement.hashCode(); 2203 } 2204 } 2205 2206 /** 2207 * Fired when a node's scrollability state changes. 2208 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2209 */ 2210 public static class scrollableFlagUpdated 2211 extends BrowserEvent 2212 implements java.io.Serializable 2213 { 2214 /** For Object Serialization. java.io.Serializable */ 2215 protected static final long serialVersionUID = 1; 2216 2217 public boolean[] optionals() 2218 { return new boolean[] { false, false, }; } 2219 2220 /** The id of the node. */ 2221 public final int nodeId; 2222 2223 /** If the node is scrollable. */ 2224 public final boolean isScrollable; 2225 2226 /** 2227 * Constructor 2228 * 2229 * @param nodeId The id of the node. 2230 * 2231 * @param isScrollable If the node is scrollable. 2232 */ 2233 public scrollableFlagUpdated(int nodeId, boolean isScrollable) 2234 { 2235 super("DOM", "scrollableFlagUpdated", 2); 2236 2237 this.nodeId = nodeId; 2238 this.isScrollable = isScrollable; 2239 } 2240 2241 /** 2242 * JSON Object Constructor 2243 * @param jo A Json-Object having data about an instance of {@code 'scrollableFlagUpdated'}. 2244 */ 2245 public scrollableFlagUpdated (JsonObject jo) 2246 { 2247 super("DOM", "scrollableFlagUpdated", 2); 2248 2249 this.nodeId = ReadPrimJSON.getInt(jo, "nodeId"); 2250 this.isScrollable = ReadPrimJSON.getBoolean(jo, "isScrollable"); 2251 } 2252 2253 2254 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2255 public boolean equals(Object other) 2256 { 2257 if (this == other) return true; 2258 if (other == null) return false; 2259 if (other.getClass() != this.getClass()) return false; 2260 2261 scrollableFlagUpdated o = (scrollableFlagUpdated) other; 2262 2263 return 2264 Objects.equals(this.nodeId, o.nodeId) 2265 && (this.isScrollable == o.isScrollable); 2266 } 2267 2268 /** Generates a Hash-Code for {@code 'this'} instance */ 2269 public int hashCode() 2270 { 2271 return 2272 this.nodeId 2273 + (this.isScrollable ? 1 : 0); 2274 } 2275 } 2276 2277 /** 2278 * Called when a pseudo element is removed from an element. 2279 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2280 */ 2281 public static class pseudoElementRemoved 2282 extends BrowserEvent 2283 implements java.io.Serializable 2284 { 2285 /** For Object Serialization. java.io.Serializable */ 2286 protected static final long serialVersionUID = 1; 2287 2288 public boolean[] optionals() 2289 { return new boolean[] { false, false, }; } 2290 2291 /** Pseudo element's parent element id. */ 2292 public final int parentId; 2293 2294 /** The removed pseudo element id. */ 2295 public final int pseudoElementId; 2296 2297 /** 2298 * Constructor 2299 * 2300 * @param parentId Pseudo element's parent element id. 2301 * 2302 * @param pseudoElementId The removed pseudo element id. 2303 */ 2304 public pseudoElementRemoved(int parentId, int pseudoElementId) 2305 { 2306 super("DOM", "pseudoElementRemoved", 2); 2307 2308 this.parentId = parentId; 2309 this.pseudoElementId = pseudoElementId; 2310 } 2311 2312 /** 2313 * JSON Object Constructor 2314 * @param jo A Json-Object having data about an instance of {@code 'pseudoElementRemoved'}. 2315 */ 2316 public pseudoElementRemoved (JsonObject jo) 2317 { 2318 super("DOM", "pseudoElementRemoved", 2); 2319 2320 this.parentId = ReadPrimJSON.getInt(jo, "parentId"); 2321 this.pseudoElementId = ReadPrimJSON.getInt(jo, "pseudoElementId"); 2322 } 2323 2324 2325 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2326 public boolean equals(Object other) 2327 { 2328 if (this == other) return true; 2329 if (other == null) return false; 2330 if (other.getClass() != this.getClass()) return false; 2331 2332 pseudoElementRemoved o = (pseudoElementRemoved) other; 2333 2334 return 2335 Objects.equals(this.parentId, o.parentId) 2336 && Objects.equals(this.pseudoElementId, o.pseudoElementId); 2337 } 2338 2339 /** Generates a Hash-Code for {@code 'this'} instance */ 2340 public int hashCode() 2341 { 2342 return 2343 this.parentId 2344 + this.pseudoElementId; 2345 } 2346 } 2347 2348 /** 2349 * Fired when backend wants to provide client with the missing DOM structure. This happens upon 2350 * most of the calls requesting node ids. 2351 */ 2352 public static class setChildNodes 2353 extends BrowserEvent 2354 implements java.io.Serializable 2355 { 2356 /** For Object Serialization. java.io.Serializable */ 2357 protected static final long serialVersionUID = 1; 2358 2359 public boolean[] optionals() 2360 { return new boolean[] { false, false, }; } 2361 2362 /** Parent node id to populate with children. */ 2363 public final int parentId; 2364 2365 /** Child nodes array. */ 2366 public final DOM.Node[] nodes; 2367 2368 /** 2369 * Constructor 2370 * 2371 * @param parentId Parent node id to populate with children. 2372 * 2373 * @param nodes Child nodes array. 2374 */ 2375 public setChildNodes(int parentId, DOM.Node[] nodes) 2376 { 2377 super("DOM", "setChildNodes", 2); 2378 2379 // Exception-Check(s) to ensure that if any parameters which are not declared as 2380 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2381 2382 if (nodes == null) THROWS.throwNPE("nodes"); 2383 2384 this.parentId = parentId; 2385 this.nodes = nodes; 2386 } 2387 2388 /** 2389 * JSON Object Constructor 2390 * @param jo A Json-Object having data about an instance of {@code 'setChildNodes'}. 2391 */ 2392 public setChildNodes (JsonObject jo) 2393 { 2394 super("DOM", "setChildNodes", 2); 2395 2396 this.parentId = ReadPrimJSON.getInt(jo, "parentId"); 2397 this.nodes = (jo.getJsonArray("nodes") == null) 2398 ? null 2399 : RJArrIntoStream.objArr(jo.getJsonArray("nodes"), null, 0, DOM.Node.class).toArray(DOM.Node[]::new); 2400 2401 } 2402 2403 2404 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2405 public boolean equals(Object other) 2406 { 2407 if (this == other) return true; 2408 if (other == null) return false; 2409 if (other.getClass() != this.getClass()) return false; 2410 2411 setChildNodes o = (setChildNodes) other; 2412 2413 return 2414 Objects.equals(this.parentId, o.parentId) 2415 && Arrays.deepEquals(this.nodes, o.nodes); 2416 } 2417 2418 /** Generates a Hash-Code for {@code 'this'} instance */ 2419 public int hashCode() 2420 { 2421 return 2422 this.parentId 2423 + Arrays.deepHashCode(this.nodes); 2424 } 2425 } 2426 2427 /** 2428 * Called when shadow root is popped from the element. 2429 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2430 */ 2431 public static class shadowRootPopped 2432 extends BrowserEvent 2433 implements java.io.Serializable 2434 { 2435 /** For Object Serialization. java.io.Serializable */ 2436 protected static final long serialVersionUID = 1; 2437 2438 public boolean[] optionals() 2439 { return new boolean[] { false, false, }; } 2440 2441 /** Host element id. */ 2442 public final int hostId; 2443 2444 /** Shadow root id. */ 2445 public final int rootId; 2446 2447 /** 2448 * Constructor 2449 * 2450 * @param hostId Host element id. 2451 * 2452 * @param rootId Shadow root id. 2453 */ 2454 public shadowRootPopped(int hostId, int rootId) 2455 { 2456 super("DOM", "shadowRootPopped", 2); 2457 2458 this.hostId = hostId; 2459 this.rootId = rootId; 2460 } 2461 2462 /** 2463 * JSON Object Constructor 2464 * @param jo A Json-Object having data about an instance of {@code 'shadowRootPopped'}. 2465 */ 2466 public shadowRootPopped (JsonObject jo) 2467 { 2468 super("DOM", "shadowRootPopped", 2); 2469 2470 this.hostId = ReadPrimJSON.getInt(jo, "hostId"); 2471 this.rootId = ReadPrimJSON.getInt(jo, "rootId"); 2472 } 2473 2474 2475 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2476 public boolean equals(Object other) 2477 { 2478 if (this == other) return true; 2479 if (other == null) return false; 2480 if (other.getClass() != this.getClass()) return false; 2481 2482 shadowRootPopped o = (shadowRootPopped) other; 2483 2484 return 2485 Objects.equals(this.hostId, o.hostId) 2486 && Objects.equals(this.rootId, o.rootId); 2487 } 2488 2489 /** Generates a Hash-Code for {@code 'this'} instance */ 2490 public int hashCode() 2491 { 2492 return 2493 this.hostId 2494 + this.rootId; 2495 } 2496 } 2497 2498 /** 2499 * Called when shadow root is pushed into the element. 2500 * <BR /><B CLASS=Exp>EXPERIMENTAL</B> 2501 */ 2502 public static class shadowRootPushed 2503 extends BrowserEvent 2504 implements java.io.Serializable 2505 { 2506 /** For Object Serialization. java.io.Serializable */ 2507 protected static final long serialVersionUID = 1; 2508 2509 public boolean[] optionals() 2510 { return new boolean[] { false, false, }; } 2511 2512 /** Host element id. */ 2513 public final int hostId; 2514 2515 /** Shadow root. */ 2516 public final DOM.Node root; 2517 2518 /** 2519 * Constructor 2520 * 2521 * @param hostId Host element id. 2522 * 2523 * @param root Shadow root. 2524 */ 2525 public shadowRootPushed(int hostId, DOM.Node root) 2526 { 2527 super("DOM", "shadowRootPushed", 2); 2528 2529 // Exception-Check(s) to ensure that if any parameters which are not declared as 2530 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2531 2532 if (root == null) THROWS.throwNPE("root"); 2533 2534 this.hostId = hostId; 2535 this.root = root; 2536 } 2537 2538 /** 2539 * JSON Object Constructor 2540 * @param jo A Json-Object having data about an instance of {@code 'shadowRootPushed'}. 2541 */ 2542 public shadowRootPushed (JsonObject jo) 2543 { 2544 super("DOM", "shadowRootPushed", 2); 2545 2546 this.hostId = ReadPrimJSON.getInt(jo, "hostId"); 2547 this.root = ReadJSON.getObject(jo, "root", DOM.Node.class, false, true); 2548 } 2549 2550 2551 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 2552 public boolean equals(Object other) 2553 { 2554 if (this == other) return true; 2555 if (other == null) return false; 2556 if (other.getClass() != this.getClass()) return false; 2557 2558 shadowRootPushed o = (shadowRootPushed) other; 2559 2560 return 2561 Objects.equals(this.hostId, o.hostId) 2562 && Objects.equals(this.root, o.root); 2563 } 2564 2565 /** Generates a Hash-Code for {@code 'this'} instance */ 2566 public int hashCode() 2567 { 2568 return 2569 this.hostId 2570 + this.root.hashCode(); 2571 } 2572 } 2573 2574 2575 // Counter for keeping the WebSocket Request ID's distinct. 2576 private static int counter = 1; 2577 2578 /** 2579 * Collects class names for the node with given id and all of it's child nodes. 2580 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2581 * 2582 * @param nodeId Id of the node to collect class names. 2583 * 2584 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2585 * String[]></CODE> 2586 * 2587 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2588 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2589 * String[]></CODE> will be returned. 2590 * 2591 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2592 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2593 * may be retrieved.</I> 2594 * 2595 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2596 * <BR /><BR /><UL CLASS=JDUL> 2597 * <LI><CODE>String[] (<B>classNames</B></CODE>) 2598 * <BR />Class name list. 2599 * </LI> 2600 * </UL> */ 2601 public static Script<String, JsonObject, String[]> collectClassNamesFromSubtree(int nodeId) 2602 { 2603 final int webSocketID = 17000000 + counter++; 2604 final boolean[] optionals = { false, }; 2605 2606 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2607 String requestJSON = WriteJSON.get( 2608 parameterTypes.get("collectClassNamesFromSubtree"), 2609 parameterNames.get("collectClassNamesFromSubtree"), 2610 optionals, webSocketID, 2611 "DOM.collectClassNamesFromSubtree", 2612 nodeId 2613 ); 2614 2615 // 'JSON Binding' ... Converts Browser Response-JSON to 'String[]' 2616 Function<JsonObject, String[]> responseProcessor = (JsonObject jo) -> 2617 (jo.getJsonArray("classNames") == null) 2618 ? null 2619 : RJArrIntoStream.strArr(jo.getJsonArray("classNames"), null, 0).toArray(String[]::new); 2620 2621 return new Script<>(webSocketID, requestJSON, responseProcessor); 2622 } 2623 2624 /** 2625 * Creates a deep copy of the specified node and places it into the target container before the 2626 * given anchor. 2627 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2628 * 2629 * @param nodeId Id of the node to copy. 2630 * 2631 * @param targetNodeId Id of the element to drop the copy into. 2632 * 2633 * @param insertBeforeNodeId 2634 * Drop the copy before this node (if absent, the copy becomes the last child of 2635 * {@code targetNodeId}). 2636 * <BR /><B CLASS=Opt>OPTIONAL</B> 2637 * 2638 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2639 * Integer></CODE> 2640 * 2641 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2642 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2643 * Integer></CODE> will be returned. 2644 * 2645 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2646 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2647 * may be retrieved.</I> 2648 * 2649 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2650 * <BR /><BR /><UL CLASS=JDUL> 2651 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 2652 * <BR />Id of the node clone. 2653 * </LI> 2654 * </UL> */ 2655 public static Script<String, JsonObject, Integer> copyTo 2656 (int nodeId, int targetNodeId, Integer insertBeforeNodeId) 2657 { 2658 final int webSocketID = 17001000 + counter++; 2659 final boolean[] optionals = { false, false, true, }; 2660 2661 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2662 String requestJSON = WriteJSON.get( 2663 parameterTypes.get("copyTo"), 2664 parameterNames.get("copyTo"), 2665 optionals, webSocketID, 2666 "DOM.copyTo", 2667 nodeId, targetNodeId, insertBeforeNodeId 2668 ); 2669 2670 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 2671 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 2672 ReadBoxedJSON.getInteger(jo, "nodeId", true); 2673 2674 return new Script<>(webSocketID, requestJSON, responseProcessor); 2675 } 2676 2677 /** 2678 * Describes node given its id, does not require domain to be enabled. Does not start tracking any 2679 * objects, can be used for automation. 2680 * 2681 * @param nodeId Identifier of the node. 2682 * <BR /><B CLASS=Opt>OPTIONAL</B> 2683 * 2684 * @param backendNodeId Identifier of the backend node. 2685 * <BR /><B CLASS=Opt>OPTIONAL</B> 2686 * 2687 * @param objectId JavaScript object id of the node wrapper. 2688 * <BR /><B CLASS=Opt>OPTIONAL</B> 2689 * 2690 * @param depth 2691 * The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the 2692 * entire subtree or provide an integer larger than 0. 2693 * <BR /><B CLASS=Opt>OPTIONAL</B> 2694 * 2695 * @param pierce 2696 * Whether or not iframes and shadow roots should be traversed when returning the subtree 2697 * (default is false). 2698 * <BR /><B CLASS=Opt>OPTIONAL</B> 2699 * 2700 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2701 * {@link DOM.Node}></CODE> 2702 * 2703 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2704 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2705 * {@link DOM.Node}></CODE> will be returned. 2706 * 2707 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2708 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2709 * may be retrieved.</I> 2710 * 2711 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2712 * <BR /><BR /><UL CLASS=JDUL> 2713 * <LI><CODE>{@link DOM.Node} (<B>node</B></CODE>) 2714 * <BR />Node description. 2715 * </LI> 2716 * </UL> */ 2717 public static Script<String, JsonObject, DOM.Node> describeNode 2718 (Integer nodeId, Integer backendNodeId, String objectId, Integer depth, Boolean pierce) 2719 { 2720 final int webSocketID = 17002000 + counter++; 2721 final boolean[] optionals = { true, true, true, true, true, }; 2722 2723 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2724 String requestJSON = WriteJSON.get( 2725 parameterTypes.get("describeNode"), 2726 parameterNames.get("describeNode"), 2727 optionals, webSocketID, 2728 "DOM.describeNode", 2729 nodeId, backendNodeId, objectId, depth, pierce 2730 ); 2731 2732 // 'JSON Binding' ... Converts Browser Response-JSON to 'DOM.Node' 2733 Function<JsonObject, DOM.Node> responseProcessor = (JsonObject jo) -> 2734 ReadJSON.getObject(jo, "node", DOM.Node.class, false, true); 2735 2736 return new Script<>(webSocketID, requestJSON, responseProcessor); 2737 } 2738 2739 /** 2740 * Scrolls the specified rect of the given node into view if not already visible. 2741 * Note: exactly one between nodeId, backendNodeId and objectId should be passed 2742 * to identify the node. 2743 * 2744 * @param nodeId Identifier of the node. 2745 * <BR /><B CLASS=Opt>OPTIONAL</B> 2746 * 2747 * @param backendNodeId Identifier of the backend node. 2748 * <BR /><B CLASS=Opt>OPTIONAL</B> 2749 * 2750 * @param objectId JavaScript object id of the node wrapper. 2751 * <BR /><B CLASS=Opt>OPTIONAL</B> 2752 * 2753 * @param rect 2754 * The rect to be scrolled into view, relative to the node's border box, in CSS pixels. 2755 * When omitted, center of the node will be used, similar to Element.scrollIntoView. 2756 * <BR /><B CLASS=Opt>OPTIONAL</B> 2757 * 2758 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2759 * {@link Ret0}></CODE> 2760 * 2761 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2762 * browser receives the invocation-request. 2763 * 2764 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2765 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2766 * {@code >} to ensure the Browser Function has run to completion. 2767 */ 2768 public static Script<String, JsonObject, Ret0> scrollIntoViewIfNeeded 2769 (Integer nodeId, Integer backendNodeId, String objectId, DOM.Rect rect) 2770 { 2771 final int webSocketID = 17003000 + counter++; 2772 final boolean[] optionals = { true, true, true, true, }; 2773 2774 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2775 String requestJSON = WriteJSON.get( 2776 parameterTypes.get("scrollIntoViewIfNeeded"), 2777 parameterNames.get("scrollIntoViewIfNeeded"), 2778 optionals, webSocketID, 2779 "DOM.scrollIntoViewIfNeeded", 2780 nodeId, backendNodeId, objectId, rect 2781 ); 2782 2783 // This Remote Command does not have a Return-Value. 2784 return new Script<> 2785 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2786 } 2787 2788 /** 2789 * Disables DOM agent for the given page. 2790 * 2791 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2792 * {@link Ret0}></CODE> 2793 * 2794 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2795 * browser receives the invocation-request. 2796 * 2797 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2798 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2799 * {@code >} to ensure the Browser Function has run to completion. 2800 */ 2801 public static Script<String, JsonObject, Ret0> disable() 2802 { 2803 final int webSocketID = 17004000 + counter++; 2804 final boolean[] optionals = new boolean[0]; 2805 2806 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2807 String requestJSON = WriteJSON.get( 2808 parameterTypes.get("disable"), 2809 parameterNames.get("disable"), 2810 optionals, webSocketID, 2811 "DOM.disable" 2812 ); 2813 2814 // This Remote Command does not have a Return-Value. 2815 return new Script<> 2816 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2817 } 2818 2819 /** 2820 * Discards search results from the session with the given id. {@code getSearchResults} should no longer 2821 * be called for that search. 2822 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 2823 * 2824 * @param searchId Unique search session identifier. 2825 * 2826 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2827 * {@link Ret0}></CODE> 2828 * 2829 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2830 * browser receives the invocation-request. 2831 * 2832 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2833 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2834 * {@code >} to ensure the Browser Function has run to completion. 2835 */ 2836 public static Script<String, JsonObject, Ret0> discardSearchResults(String searchId) 2837 { 2838 // Exception-Check(s) to ensure that if any parameters which are not declared as 2839 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 2840 2841 if (searchId == null) THROWS.throwNPE("searchId"); 2842 2843 final int webSocketID = 17005000 + counter++; 2844 final boolean[] optionals = { false, }; 2845 2846 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2847 String requestJSON = WriteJSON.get( 2848 parameterTypes.get("discardSearchResults"), 2849 parameterNames.get("discardSearchResults"), 2850 optionals, webSocketID, 2851 "DOM.discardSearchResults", 2852 searchId 2853 ); 2854 2855 // This Remote Command does not have a Return-Value. 2856 return new Script<> 2857 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2858 } 2859 2860 /** 2861 * Enables DOM agent for the given page. 2862 * 2863 * @param includeWhitespace Whether to include whitespaces in the children array of returned Nodes. 2864 * <BR />Acceptable Values: ["none", "all"] 2865 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 2866 * 2867 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2868 * {@link Ret0}></CODE> 2869 * 2870 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2871 * browser receives the invocation-request. 2872 * 2873 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2874 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2875 * {@code >} to ensure the Browser Function has run to completion. 2876 */ 2877 public static Script<String, JsonObject, Ret0> enable(String includeWhitespace) 2878 { 2879 // Exception-Check(s) to ensure that if any parameters which must adhere to a 2880 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 2881 2882 THROWS.checkIAE( 2883 "includeWhitespace", includeWhitespace, 2884 "none", "all" 2885 ); 2886 2887 final int webSocketID = 17006000 + counter++; 2888 final boolean[] optionals = { true, }; 2889 2890 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2891 String requestJSON = WriteJSON.get( 2892 parameterTypes.get("enable"), 2893 parameterNames.get("enable"), 2894 optionals, webSocketID, 2895 "DOM.enable", 2896 includeWhitespace 2897 ); 2898 2899 // This Remote Command does not have a Return-Value. 2900 return new Script<> 2901 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2902 } 2903 2904 /** 2905 * Focuses the given element. 2906 * 2907 * @param nodeId Identifier of the node. 2908 * <BR /><B CLASS=Opt>OPTIONAL</B> 2909 * 2910 * @param backendNodeId Identifier of the backend node. 2911 * <BR /><B CLASS=Opt>OPTIONAL</B> 2912 * 2913 * @param objectId JavaScript object id of the node wrapper. 2914 * <BR /><B CLASS=Opt>OPTIONAL</B> 2915 * 2916 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2917 * {@link Ret0}></CODE> 2918 * 2919 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 2920 * browser receives the invocation-request. 2921 * 2922 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 2923 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 2924 * {@code >} to ensure the Browser Function has run to completion. 2925 */ 2926 public static Script<String, JsonObject, Ret0> focus 2927 (Integer nodeId, Integer backendNodeId, String objectId) 2928 { 2929 final int webSocketID = 17007000 + counter++; 2930 final boolean[] optionals = { true, true, true, }; 2931 2932 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2933 String requestJSON = WriteJSON.get( 2934 parameterTypes.get("focus"), 2935 parameterNames.get("focus"), 2936 optionals, webSocketID, 2937 "DOM.focus", 2938 nodeId, backendNodeId, objectId 2939 ); 2940 2941 // This Remote Command does not have a Return-Value. 2942 return new Script<> 2943 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 2944 } 2945 2946 /** 2947 * Returns attributes for the specified node. 2948 * 2949 * @param nodeId Id of the node to retrieve attributes for. 2950 * 2951 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 2952 * String[]></CODE> 2953 * 2954 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 2955 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 2956 * String[]></CODE> will be returned. 2957 * 2958 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 2959 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 2960 * may be retrieved.</I> 2961 * 2962 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 2963 * <BR /><BR /><UL CLASS=JDUL> 2964 * <LI><CODE>String[] (<B>attributes</B></CODE>) 2965 * <BR />An interleaved array of node attribute names and values. 2966 * </LI> 2967 * </UL> */ 2968 public static Script<String, JsonObject, String[]> getAttributes(int nodeId) 2969 { 2970 final int webSocketID = 17008000 + counter++; 2971 final boolean[] optionals = { false, }; 2972 2973 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 2974 String requestJSON = WriteJSON.get( 2975 parameterTypes.get("getAttributes"), 2976 parameterNames.get("getAttributes"), 2977 optionals, webSocketID, 2978 "DOM.getAttributes", 2979 nodeId 2980 ); 2981 2982 // 'JSON Binding' ... Converts Browser Response-JSON to 'String[]' 2983 Function<JsonObject, String[]> responseProcessor = (JsonObject jo) -> 2984 (jo.getJsonArray("attributes") == null) 2985 ? null 2986 : RJArrIntoStream.strArr(jo.getJsonArray("attributes"), null, 0).toArray(String[]::new); 2987 2988 return new Script<>(webSocketID, requestJSON, responseProcessor); 2989 } 2990 2991 /** 2992 * Returns boxes for the given node. 2993 * 2994 * @param nodeId Identifier of the node. 2995 * <BR /><B CLASS=Opt>OPTIONAL</B> 2996 * 2997 * @param backendNodeId Identifier of the backend node. 2998 * <BR /><B CLASS=Opt>OPTIONAL</B> 2999 * 3000 * @param objectId JavaScript object id of the node wrapper. 3001 * <BR /><B CLASS=Opt>OPTIONAL</B> 3002 * 3003 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3004 * {@link DOM.BoxModel}></CODE> 3005 * 3006 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3007 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3008 * {@link DOM.BoxModel}></CODE> will be returned. 3009 * 3010 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3011 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3012 * may be retrieved.</I> 3013 * 3014 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3015 * <BR /><BR /><UL CLASS=JDUL> 3016 * <LI><CODE>{@link DOM.BoxModel} (<B>model</B></CODE>) 3017 * <BR />Box model for the node. 3018 * </LI> 3019 * </UL> */ 3020 public static Script<String, JsonObject, DOM.BoxModel> getBoxModel 3021 (Integer nodeId, Integer backendNodeId, String objectId) 3022 { 3023 final int webSocketID = 17009000 + counter++; 3024 final boolean[] optionals = { true, true, true, }; 3025 3026 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3027 String requestJSON = WriteJSON.get( 3028 parameterTypes.get("getBoxModel"), 3029 parameterNames.get("getBoxModel"), 3030 optionals, webSocketID, 3031 "DOM.getBoxModel", 3032 nodeId, backendNodeId, objectId 3033 ); 3034 3035 // 'JSON Binding' ... Converts Browser Response-JSON to 'DOM.BoxModel' 3036 Function<JsonObject, DOM.BoxModel> responseProcessor = (JsonObject jo) -> 3037 ReadJSON.getObject(jo, "model", DOM.BoxModel.class, false, true); 3038 3039 return new Script<>(webSocketID, requestJSON, responseProcessor); 3040 } 3041 3042 /** 3043 * Returns quads that describe node position on the page. This method 3044 * might return multiple quads for inline nodes. 3045 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3046 * 3047 * @param nodeId Identifier of the node. 3048 * <BR /><B CLASS=Opt>OPTIONAL</B> 3049 * 3050 * @param backendNodeId Identifier of the backend node. 3051 * <BR /><B CLASS=Opt>OPTIONAL</B> 3052 * 3053 * @param objectId JavaScript object id of the node wrapper. 3054 * <BR /><B CLASS=Opt>OPTIONAL</B> 3055 * 3056 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3057 * Number[][]></CODE> 3058 * 3059 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3060 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3061 * Number[][]></CODE> will be returned. 3062 * 3063 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3064 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3065 * may be retrieved.</I> 3066 * 3067 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3068 * <BR /><BR /><UL CLASS=JDUL> 3069 * <LI><CODE>Number[][] (<B>quads</B></CODE>) 3070 * <BR />Quads that describe node layout relative to viewport. 3071 * </LI> 3072 * </UL> */ 3073 public static Script<String, JsonObject, Number[][]> getContentQuads 3074 (Integer nodeId, Integer backendNodeId, String objectId) 3075 { 3076 final int webSocketID = 17010000 + counter++; 3077 final boolean[] optionals = { true, true, true, }; 3078 3079 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3080 String requestJSON = WriteJSON.get( 3081 parameterTypes.get("getContentQuads"), 3082 parameterNames.get("getContentQuads"), 3083 optionals, webSocketID, 3084 "DOM.getContentQuads", 3085 nodeId, backendNodeId, objectId 3086 ); 3087 3088 // 'JSON Binding' ... Converts Browser Response-JSON to 'Number[][]' 3089 Function<JsonObject, Number[][]> responseProcessor = (JsonObject jo) -> 3090 (jo.getJsonArray("quads") == null) 3091 ? null 3092 : RJArrDimN.arrNumber(jo.getJsonArray("quads"), -1, 0, null, Number[][].class); 3093 3094 return new Script<>(webSocketID, requestJSON, responseProcessor); 3095 } 3096 3097 /** 3098 * Returns the root DOM node (and optionally the subtree) to the caller. 3099 * Implicitly enables the DOM domain events for the current target. 3100 * 3101 * @param depth 3102 * The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the 3103 * entire subtree or provide an integer larger than 0. 3104 * <BR /><B CLASS=Opt>OPTIONAL</B> 3105 * 3106 * @param pierce 3107 * Whether or not iframes and shadow roots should be traversed when returning the subtree 3108 * (default is false). 3109 * <BR /><B CLASS=Opt>OPTIONAL</B> 3110 * 3111 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3112 * {@link DOM.Node}></CODE> 3113 * 3114 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3115 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3116 * {@link DOM.Node}></CODE> will be returned. 3117 * 3118 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3119 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3120 * may be retrieved.</I> 3121 * 3122 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3123 * <BR /><BR /><UL CLASS=JDUL> 3124 * <LI><CODE>{@link DOM.Node} (<B>root</B></CODE>) 3125 * <BR />Resulting node. 3126 * </LI> 3127 * </UL> */ 3128 public static Script<String, JsonObject, DOM.Node> getDocument 3129 (Integer depth, Boolean pierce) 3130 { 3131 final int webSocketID = 17011000 + counter++; 3132 final boolean[] optionals = { true, true, }; 3133 3134 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3135 String requestJSON = WriteJSON.get( 3136 parameterTypes.get("getDocument"), 3137 parameterNames.get("getDocument"), 3138 optionals, webSocketID, 3139 "DOM.getDocument", 3140 depth, pierce 3141 ); 3142 3143 // 'JSON Binding' ... Converts Browser Response-JSON to 'DOM.Node' 3144 Function<JsonObject, DOM.Node> responseProcessor = (JsonObject jo) -> 3145 ReadJSON.getObject(jo, "root", DOM.Node.class, false, true); 3146 3147 return new Script<>(webSocketID, requestJSON, responseProcessor); 3148 } 3149 3150 /** 3151 * Returns the root DOM node (and optionally the subtree) to the caller. 3152 * Deprecated, as it is not designed to work well with the rest of the DOM agent. 3153 * Use DOMSnapshot.captureSnapshot instead. 3154 * <BR /><B CLASS=Dep-Top>DEPRECATED</B> 3155 * 3156 * @param depth 3157 * The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the 3158 * entire subtree or provide an integer larger than 0. 3159 * <BR /><B CLASS=Opt>OPTIONAL</B> 3160 * 3161 * @param pierce 3162 * Whether or not iframes and shadow roots should be traversed when returning the subtree 3163 * (default is false). 3164 * <BR /><B CLASS=Opt>OPTIONAL</B> 3165 * 3166 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3167 * {@link DOM.Node}[]></CODE> 3168 * 3169 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3170 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3171 * {@link DOM.Node}[]></CODE> will be returned. 3172 * 3173 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3174 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3175 * may be retrieved.</I> 3176 * 3177 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3178 * <BR /><BR /><UL CLASS=JDUL> 3179 * <LI><CODE>{@link DOM.Node}[] (<B>nodes</B></CODE>) 3180 * <BR />Resulting node. 3181 * </LI> 3182 * </UL> */ 3183 public static Script<String, JsonObject, DOM.Node[]> getFlattenedDocument 3184 (Integer depth, Boolean pierce) 3185 { 3186 final int webSocketID = 17012000 + counter++; 3187 final boolean[] optionals = { true, true, }; 3188 3189 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3190 String requestJSON = WriteJSON.get( 3191 parameterTypes.get("getFlattenedDocument"), 3192 parameterNames.get("getFlattenedDocument"), 3193 optionals, webSocketID, 3194 "DOM.getFlattenedDocument", 3195 depth, pierce 3196 ); 3197 3198 // 'JSON Binding' ... Converts Browser Response-JSON to 'DOM.Node[]' 3199 Function<JsonObject, DOM.Node[]> responseProcessor = (JsonObject jo) -> 3200 (jo.getJsonArray("nodes") == null) 3201 ? null 3202 : RJArrIntoStream.objArr(jo.getJsonArray("nodes"), null, 0, DOM.Node.class).toArray(DOM.Node[]::new); 3203 3204 return new Script<>(webSocketID, requestJSON, responseProcessor); 3205 } 3206 3207 /** 3208 * Finds nodes with a given computed style in a subtree. 3209 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3210 * 3211 * @param nodeId Node ID pointing to the root of a subtree. 3212 * 3213 * @param computedStyles The style to filter nodes by (includes nodes if any of properties matches). 3214 * 3215 * @param pierce 3216 * Whether or not iframes and shadow roots in the same target should be traversed when returning the 3217 * results (default is false). 3218 * <BR /><B CLASS=Opt>OPTIONAL</B> 3219 * 3220 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3221 * int[]></CODE> 3222 * 3223 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3224 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3225 * int[]></CODE> will be returned. 3226 * 3227 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3228 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3229 * may be retrieved.</I> 3230 * 3231 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3232 * <BR /><BR /><UL CLASS=JDUL> 3233 * <LI><CODE>int[] (<B>nodeIds</B></CODE>) 3234 * <BR />Resulting nodes. 3235 * </LI> 3236 * </UL> */ 3237 public static Script<String, JsonObject, int[]> getNodesForSubtreeByStyle 3238 (int nodeId, DOM.CSSComputedStyleProperty[] computedStyles, Boolean pierce) 3239 { 3240 // Exception-Check(s) to ensure that if any parameters which are not declared as 3241 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3242 3243 if (computedStyles == null) THROWS.throwNPE("computedStyles"); 3244 3245 final int webSocketID = 17013000 + counter++; 3246 final boolean[] optionals = { false, false, true, }; 3247 3248 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3249 String requestJSON = WriteJSON.get( 3250 parameterTypes.get("getNodesForSubtreeByStyle"), 3251 parameterNames.get("getNodesForSubtreeByStyle"), 3252 optionals, webSocketID, 3253 "DOM.getNodesForSubtreeByStyle", 3254 nodeId, computedStyles, pierce 3255 ); 3256 3257 // 'JSON Binding' ... Converts Browser Response-JSON to 'int[]' 3258 Function<JsonObject, int[]> responseProcessor = (JsonObject jo) -> 3259 (jo.getJsonArray("nodeIds") == null) 3260 ? null 3261 : RJArrIntoPrimArray.intArr(jo.getJsonArray("nodeIds"), -1, 0, null); 3262 3263 return new Script<>(webSocketID, requestJSON, responseProcessor); 3264 } 3265 3266 /** 3267 * Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is 3268 * either returned or not. 3269 * 3270 * @param x X coordinate. 3271 * 3272 * @param y Y coordinate. 3273 * 3274 * @param includeUserAgentShadowDOM False to skip to the nearest non-UA shadow root ancestor (default: false). 3275 * <BR /><B CLASS=Opt>OPTIONAL</B> 3276 * 3277 * @param ignorePointerEventsNone Whether to ignore pointer-events: none on elements and hit test them. 3278 * <BR /><B CLASS=Opt>OPTIONAL</B> 3279 * 3280 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3281 * {@link Ret3}></CODE> 3282 * 3283 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 3284 * {@link Script#exec()}), and a {@link Promise} returned. 3285 * 3286 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 3287 * (using {@link Promise#await()}), the {@code Ret3} will subsequently 3288 * be returned from that call. 3289 * 3290 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 3291 * in an instance of <B>{@link Ret3}</B> 3292 * 3293 * <BR /><BR /><UL CLASS=JDUL> 3294 * <LI><CODE><B>Ret3.a:</B> Integer (<B>backendNodeId</B>)</CODE> 3295 * <BR />Resulting node. 3296 * <BR /><BR /></LI> 3297 * <LI><CODE><B>Ret3.b:</B> String (<B>frameId</B>)</CODE> 3298 * <BR />Frame this node belongs to. 3299 * <BR /><BR /></LI> 3300 * <LI><CODE><B>Ret3.c:</B> Integer (<B>nodeId</B>)</CODE> 3301 * <BR />Id of the node at given coordinates, only when enabled and requested document. 3302 * </LI> 3303 * </UL> 3304 */ 3305 public static Script<String, JsonObject, Ret3<Integer, String, Integer>> getNodeForLocation 3306 (int x, int y, Boolean includeUserAgentShadowDOM, Boolean ignorePointerEventsNone) 3307 { 3308 final int webSocketID = 17014000 + counter++; 3309 final boolean[] optionals = { false, false, true, true, }; 3310 3311 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3312 String requestJSON = WriteJSON.get( 3313 parameterTypes.get("getNodeForLocation"), 3314 parameterNames.get("getNodeForLocation"), 3315 optionals, webSocketID, 3316 "DOM.getNodeForLocation", 3317 x, y, includeUserAgentShadowDOM, ignorePointerEventsNone 3318 ); 3319 3320 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret3' 3321 Function<JsonObject, Ret3<Integer, String, Integer>> 3322 responseProcessor = (JsonObject jo) -> new Ret3<>( 3323 ReadBoxedJSON.getInteger(jo, "backendNodeId", true), 3324 ReadJSON.getString(jo, "frameId", false, true), 3325 ReadBoxedJSON.getInteger(jo, "nodeId", true) 3326 ); 3327 3328 return new Script<>(webSocketID, requestJSON, responseProcessor); 3329 } 3330 3331 /** 3332 * Returns node's HTML markup. 3333 * 3334 * @param nodeId Identifier of the node. 3335 * <BR /><B CLASS=Opt>OPTIONAL</B> 3336 * 3337 * @param backendNodeId Identifier of the backend node. 3338 * <BR /><B CLASS=Opt>OPTIONAL</B> 3339 * 3340 * @param objectId JavaScript object id of the node wrapper. 3341 * <BR /><B CLASS=Opt>OPTIONAL</B> 3342 * 3343 * @param includeShadowDOM Include all shadow roots. Equals to false if not specified. 3344 * <BR /><B CLASS=Opt>OPTIONAL</B><B CLASS=Exp>EXPERIMENTAL</B> 3345 * 3346 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3347 * String></CODE> 3348 * 3349 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3350 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3351 * String></CODE> will be returned. 3352 * 3353 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3354 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3355 * may be retrieved.</I> 3356 * 3357 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3358 * <BR /><BR /><UL CLASS=JDUL> 3359 * <LI><CODE>String (<B>outerHTML</B></CODE>) 3360 * <BR />Outer HTML markup. 3361 * </LI> 3362 * </UL> */ 3363 public static Script<String, JsonObject, String> getOuterHTML 3364 (Integer nodeId, Integer backendNodeId, String objectId, Boolean includeShadowDOM) 3365 { 3366 final int webSocketID = 17015000 + counter++; 3367 final boolean[] optionals = { true, true, true, true, }; 3368 3369 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3370 String requestJSON = WriteJSON.get( 3371 parameterTypes.get("getOuterHTML"), 3372 parameterNames.get("getOuterHTML"), 3373 optionals, webSocketID, 3374 "DOM.getOuterHTML", 3375 nodeId, backendNodeId, objectId, includeShadowDOM 3376 ); 3377 3378 // 'JSON Binding' ... Converts Browser Response-JSON to 'String' 3379 Function<JsonObject, String> responseProcessor = (JsonObject jo) -> 3380 ReadJSON.getString(jo, "outerHTML", false, true); 3381 3382 return new Script<>(webSocketID, requestJSON, responseProcessor); 3383 } 3384 3385 /** 3386 * Returns the id of the nearest ancestor that is a relayout boundary. 3387 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3388 * 3389 * @param nodeId Id of the node. 3390 * 3391 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3392 * Integer></CODE> 3393 * 3394 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3395 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3396 * Integer></CODE> will be returned. 3397 * 3398 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3399 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3400 * may be retrieved.</I> 3401 * 3402 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3403 * <BR /><BR /><UL CLASS=JDUL> 3404 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 3405 * <BR />Relayout boundary node id for the given node. 3406 * </LI> 3407 * </UL> */ 3408 public static Script<String, JsonObject, Integer> getRelayoutBoundary(int nodeId) 3409 { 3410 final int webSocketID = 17016000 + counter++; 3411 final boolean[] optionals = { false, }; 3412 3413 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3414 String requestJSON = WriteJSON.get( 3415 parameterTypes.get("getRelayoutBoundary"), 3416 parameterNames.get("getRelayoutBoundary"), 3417 optionals, webSocketID, 3418 "DOM.getRelayoutBoundary", 3419 nodeId 3420 ); 3421 3422 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 3423 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 3424 ReadBoxedJSON.getInteger(jo, "nodeId", true); 3425 3426 return new Script<>(webSocketID, requestJSON, responseProcessor); 3427 } 3428 3429 /** 3430 * Returns search results from given {@code fromIndex} to given {@code toIndex} from the search with the given 3431 * identifier. 3432 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3433 * 3434 * @param searchId Unique search session identifier. 3435 * 3436 * @param fromIndex Start index of the search result to be returned. 3437 * 3438 * @param toIndex End index of the search result to be returned. 3439 * 3440 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3441 * int[]></CODE> 3442 * 3443 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3444 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3445 * int[]></CODE> will be returned. 3446 * 3447 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3448 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3449 * may be retrieved.</I> 3450 * 3451 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3452 * <BR /><BR /><UL CLASS=JDUL> 3453 * <LI><CODE>int[] (<B>nodeIds</B></CODE>) 3454 * <BR />Ids of the search result nodes. 3455 * </LI> 3456 * </UL> */ 3457 public static Script<String, JsonObject, int[]> getSearchResults 3458 (String searchId, int fromIndex, int toIndex) 3459 { 3460 // Exception-Check(s) to ensure that if any parameters which are not declared as 3461 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3462 3463 if (searchId == null) THROWS.throwNPE("searchId"); 3464 3465 final int webSocketID = 17017000 + counter++; 3466 final boolean[] optionals = { false, false, false, }; 3467 3468 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3469 String requestJSON = WriteJSON.get( 3470 parameterTypes.get("getSearchResults"), 3471 parameterNames.get("getSearchResults"), 3472 optionals, webSocketID, 3473 "DOM.getSearchResults", 3474 searchId, fromIndex, toIndex 3475 ); 3476 3477 // 'JSON Binding' ... Converts Browser Response-JSON to 'int[]' 3478 Function<JsonObject, int[]> responseProcessor = (JsonObject jo) -> 3479 (jo.getJsonArray("nodeIds") == null) 3480 ? null 3481 : RJArrIntoPrimArray.intArr(jo.getJsonArray("nodeIds"), -1, 0, null); 3482 3483 return new Script<>(webSocketID, requestJSON, responseProcessor); 3484 } 3485 3486 /** 3487 * Hides any highlight. 3488 * 3489 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3490 * {@link Ret0}></CODE> 3491 * 3492 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3493 * browser receives the invocation-request. 3494 * 3495 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3496 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3497 * {@code >} to ensure the Browser Function has run to completion. 3498 */ 3499 public static Script<String, JsonObject, Ret0> hideHighlight() 3500 { 3501 final int webSocketID = 17018000 + counter++; 3502 final boolean[] optionals = new boolean[0]; 3503 3504 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3505 String requestJSON = WriteJSON.get( 3506 parameterTypes.get("hideHighlight"), 3507 parameterNames.get("hideHighlight"), 3508 optionals, webSocketID, 3509 "DOM.hideHighlight" 3510 ); 3511 3512 // This Remote Command does not have a Return-Value. 3513 return new Script<> 3514 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3515 } 3516 3517 /** 3518 * Highlights DOM node. 3519 * 3520 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3521 * {@link Ret0}></CODE> 3522 * 3523 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3524 * browser receives the invocation-request. 3525 * 3526 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3527 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3528 * {@code >} to ensure the Browser Function has run to completion. 3529 */ 3530 public static Script<String, JsonObject, Ret0> highlightNode() 3531 { 3532 final int webSocketID = 17019000 + counter++; 3533 final boolean[] optionals = new boolean[0]; 3534 3535 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3536 String requestJSON = WriteJSON.get( 3537 parameterTypes.get("highlightNode"), 3538 parameterNames.get("highlightNode"), 3539 optionals, webSocketID, 3540 "DOM.highlightNode" 3541 ); 3542 3543 // This Remote Command does not have a Return-Value. 3544 return new Script<> 3545 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3546 } 3547 3548 /** 3549 * Highlights given rectangle. 3550 * 3551 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3552 * {@link Ret0}></CODE> 3553 * 3554 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3555 * browser receives the invocation-request. 3556 * 3557 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3558 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3559 * {@code >} to ensure the Browser Function has run to completion. 3560 */ 3561 public static Script<String, JsonObject, Ret0> highlightRect() 3562 { 3563 final int webSocketID = 17020000 + counter++; 3564 final boolean[] optionals = new boolean[0]; 3565 3566 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3567 String requestJSON = WriteJSON.get( 3568 parameterTypes.get("highlightRect"), 3569 parameterNames.get("highlightRect"), 3570 optionals, webSocketID, 3571 "DOM.highlightRect" 3572 ); 3573 3574 // This Remote Command does not have a Return-Value. 3575 return new Script<> 3576 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3577 } 3578 3579 /** 3580 * Marks last undoable state. 3581 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3582 * 3583 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3584 * {@link Ret0}></CODE> 3585 * 3586 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 3587 * browser receives the invocation-request. 3588 * 3589 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 3590 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 3591 * {@code >} to ensure the Browser Function has run to completion. 3592 */ 3593 public static Script<String, JsonObject, Ret0> markUndoableState() 3594 { 3595 final int webSocketID = 17021000 + counter++; 3596 final boolean[] optionals = new boolean[0]; 3597 3598 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3599 String requestJSON = WriteJSON.get( 3600 parameterTypes.get("markUndoableState"), 3601 parameterNames.get("markUndoableState"), 3602 optionals, webSocketID, 3603 "DOM.markUndoableState" 3604 ); 3605 3606 // This Remote Command does not have a Return-Value. 3607 return new Script<> 3608 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 3609 } 3610 3611 /** 3612 * Moves node into the new container, places it before the given anchor. 3613 * 3614 * @param nodeId Id of the node to move. 3615 * 3616 * @param targetNodeId Id of the element to drop the moved node into. 3617 * 3618 * @param insertBeforeNodeId 3619 * Drop node before this one (if absent, the moved node becomes the last child of 3620 * {@code targetNodeId}). 3621 * <BR /><B CLASS=Opt>OPTIONAL</B> 3622 * 3623 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3624 * Integer></CODE> 3625 * 3626 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3627 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3628 * Integer></CODE> will be returned. 3629 * 3630 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3631 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3632 * may be retrieved.</I> 3633 * 3634 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3635 * <BR /><BR /><UL CLASS=JDUL> 3636 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 3637 * <BR />New id of the moved node. 3638 * </LI> 3639 * </UL> */ 3640 public static Script<String, JsonObject, Integer> moveTo 3641 (int nodeId, int targetNodeId, Integer insertBeforeNodeId) 3642 { 3643 final int webSocketID = 17022000 + counter++; 3644 final boolean[] optionals = { false, false, true, }; 3645 3646 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3647 String requestJSON = WriteJSON.get( 3648 parameterTypes.get("moveTo"), 3649 parameterNames.get("moveTo"), 3650 optionals, webSocketID, 3651 "DOM.moveTo", 3652 nodeId, targetNodeId, insertBeforeNodeId 3653 ); 3654 3655 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 3656 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 3657 ReadBoxedJSON.getInteger(jo, "nodeId", true); 3658 3659 return new Script<>(webSocketID, requestJSON, responseProcessor); 3660 } 3661 3662 /** 3663 * Searches for a given string in the DOM tree. Use {@code getSearchResults} to access search results or 3664 * {@code cancelSearch} to end this search session. 3665 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3666 * 3667 * @param query Plain text or query selector or XPath search query. 3668 * 3669 * @param includeUserAgentShadowDOM True to search in user agent shadow DOM. 3670 * <BR /><B CLASS=Opt>OPTIONAL</B> 3671 * 3672 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3673 * {@link Ret2}></CODE> 3674 * 3675 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 3676 * {@link Script#exec()}), and a {@link Promise} returned. 3677 * 3678 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 3679 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 3680 * be returned from that call. 3681 * 3682 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 3683 * in an instance of <B>{@link Ret2}</B> 3684 * 3685 * <BR /><BR /><UL CLASS=JDUL> 3686 * <LI><CODE><B>Ret2.a:</B> String (<B>searchId</B>)</CODE> 3687 * <BR />Unique search session identifier. 3688 * <BR /><BR /></LI> 3689 * <LI><CODE><B>Ret2.b:</B> Integer (<B>resultCount</B>)</CODE> 3690 * <BR />Number of search results. 3691 * </LI> 3692 * </UL> 3693 */ 3694 public static Script<String, JsonObject, Ret2<String, Integer>> performSearch 3695 (String query, Boolean includeUserAgentShadowDOM) 3696 { 3697 // Exception-Check(s) to ensure that if any parameters which are not declared as 3698 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3699 3700 if (query == null) THROWS.throwNPE("query"); 3701 3702 final int webSocketID = 17023000 + counter++; 3703 final boolean[] optionals = { false, true, }; 3704 3705 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3706 String requestJSON = WriteJSON.get( 3707 parameterTypes.get("performSearch"), 3708 parameterNames.get("performSearch"), 3709 optionals, webSocketID, 3710 "DOM.performSearch", 3711 query, includeUserAgentShadowDOM 3712 ); 3713 3714 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 3715 Function<JsonObject, Ret2<String, Integer>> 3716 responseProcessor = (JsonObject jo) -> new Ret2<>( 3717 ReadJSON.getString(jo, "searchId", false, true), 3718 ReadBoxedJSON.getInteger(jo, "resultCount", true) 3719 ); 3720 3721 return new Script<>(webSocketID, requestJSON, responseProcessor); 3722 } 3723 3724 /** 3725 * Requests that the node is sent to the caller given its path. // FIXME, use XPath 3726 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3727 * 3728 * @param path Path to node in the proprietary format. 3729 * 3730 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3731 * Integer></CODE> 3732 * 3733 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3734 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3735 * Integer></CODE> will be returned. 3736 * 3737 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3738 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3739 * may be retrieved.</I> 3740 * 3741 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3742 * <BR /><BR /><UL CLASS=JDUL> 3743 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 3744 * <BR />Id of the node for given path. 3745 * </LI> 3746 * </UL> */ 3747 public static Script<String, JsonObject, Integer> pushNodeByPathToFrontend(String path) 3748 { 3749 // Exception-Check(s) to ensure that if any parameters which are not declared as 3750 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3751 3752 if (path == null) THROWS.throwNPE("path"); 3753 3754 final int webSocketID = 17024000 + counter++; 3755 final boolean[] optionals = { false, }; 3756 3757 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3758 String requestJSON = WriteJSON.get( 3759 parameterTypes.get("pushNodeByPathToFrontend"), 3760 parameterNames.get("pushNodeByPathToFrontend"), 3761 optionals, webSocketID, 3762 "DOM.pushNodeByPathToFrontend", 3763 path 3764 ); 3765 3766 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 3767 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 3768 ReadBoxedJSON.getInteger(jo, "nodeId", true); 3769 3770 return new Script<>(webSocketID, requestJSON, responseProcessor); 3771 } 3772 3773 /** 3774 * Requests that a batch of nodes is sent to the caller given their backend node ids. 3775 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3776 * 3777 * @param backendNodeIds The array of backend node ids. 3778 * 3779 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3780 * int[]></CODE> 3781 * 3782 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3783 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3784 * int[]></CODE> will be returned. 3785 * 3786 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3787 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3788 * may be retrieved.</I> 3789 * 3790 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3791 * <BR /><BR /><UL CLASS=JDUL> 3792 * <LI><CODE>int[] (<B>nodeIds</B></CODE>) 3793 * <BR />The array of ids of pushed nodes that correspond to the backend ids specified in 3794 * backendNodeIds. 3795 * </LI> 3796 * </UL> */ 3797 public static Script<String, JsonObject, int[]> pushNodesByBackendIdsToFrontend 3798 (int[] backendNodeIds) 3799 { 3800 // Exception-Check(s) to ensure that if any parameters which are not declared as 3801 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3802 3803 if (backendNodeIds == null) THROWS.throwNPE("backendNodeIds"); 3804 3805 final int webSocketID = 17025000 + counter++; 3806 final boolean[] optionals = { false, }; 3807 3808 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3809 String requestJSON = WriteJSON.get( 3810 parameterTypes.get("pushNodesByBackendIdsToFrontend"), 3811 parameterNames.get("pushNodesByBackendIdsToFrontend"), 3812 optionals, webSocketID, 3813 "DOM.pushNodesByBackendIdsToFrontend", 3814 (Object) backendNodeIds 3815 ); 3816 3817 // 'JSON Binding' ... Converts Browser Response-JSON to 'int[]' 3818 Function<JsonObject, int[]> responseProcessor = (JsonObject jo) -> 3819 (jo.getJsonArray("nodeIds") == null) 3820 ? null 3821 : RJArrIntoPrimArray.intArr(jo.getJsonArray("nodeIds"), -1, 0, null); 3822 3823 return new Script<>(webSocketID, requestJSON, responseProcessor); 3824 } 3825 3826 /** 3827 * Executes {@code querySelector} on a given node. 3828 * 3829 * @param nodeId Id of the node to query upon. 3830 * 3831 * @param selector Selector string. 3832 * 3833 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3834 * Integer></CODE> 3835 * 3836 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3837 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3838 * Integer></CODE> will be returned. 3839 * 3840 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3841 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3842 * may be retrieved.</I> 3843 * 3844 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3845 * <BR /><BR /><UL CLASS=JDUL> 3846 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 3847 * <BR />Query selector result. 3848 * </LI> 3849 * </UL> */ 3850 public static Script<String, JsonObject, Integer> querySelector(int nodeId, String selector) 3851 { 3852 // Exception-Check(s) to ensure that if any parameters which are not declared as 3853 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3854 3855 if (selector == null) THROWS.throwNPE("selector"); 3856 3857 final int webSocketID = 17026000 + counter++; 3858 final boolean[] optionals = { false, false, }; 3859 3860 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3861 String requestJSON = WriteJSON.get( 3862 parameterTypes.get("querySelector"), 3863 parameterNames.get("querySelector"), 3864 optionals, webSocketID, 3865 "DOM.querySelector", 3866 nodeId, selector 3867 ); 3868 3869 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 3870 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 3871 ReadBoxedJSON.getInteger(jo, "nodeId", true); 3872 3873 return new Script<>(webSocketID, requestJSON, responseProcessor); 3874 } 3875 3876 /** 3877 * Executes {@code querySelectorAll} on a given node. 3878 * 3879 * @param nodeId Id of the node to query upon. 3880 * 3881 * @param selector Selector string. 3882 * 3883 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3884 * int[]></CODE> 3885 * 3886 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3887 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3888 * int[]></CODE> will be returned. 3889 * 3890 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3891 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3892 * may be retrieved.</I> 3893 * 3894 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3895 * <BR /><BR /><UL CLASS=JDUL> 3896 * <LI><CODE>int[] (<B>nodeIds</B></CODE>) 3897 * <BR />Query selector result. 3898 * </LI> 3899 * </UL> */ 3900 public static Script<String, JsonObject, int[]> querySelectorAll 3901 (int nodeId, String selector) 3902 { 3903 // Exception-Check(s) to ensure that if any parameters which are not declared as 3904 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 3905 3906 if (selector == null) THROWS.throwNPE("selector"); 3907 3908 final int webSocketID = 17027000 + counter++; 3909 final boolean[] optionals = { false, false, }; 3910 3911 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3912 String requestJSON = WriteJSON.get( 3913 parameterTypes.get("querySelectorAll"), 3914 parameterNames.get("querySelectorAll"), 3915 optionals, webSocketID, 3916 "DOM.querySelectorAll", 3917 nodeId, selector 3918 ); 3919 3920 // 'JSON Binding' ... Converts Browser Response-JSON to 'int[]' 3921 Function<JsonObject, int[]> responseProcessor = (JsonObject jo) -> 3922 (jo.getJsonArray("nodeIds") == null) 3923 ? null 3924 : RJArrIntoPrimArray.intArr(jo.getJsonArray("nodeIds"), -1, 0, null); 3925 3926 return new Script<>(webSocketID, requestJSON, responseProcessor); 3927 } 3928 3929 /** 3930 * Returns NodeIds of current top layer elements. 3931 * Top layer is rendered closest to the user within a viewport, therefore its elements always 3932 * appear on top of all other content. 3933 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3934 * 3935 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3936 * int[]></CODE> 3937 * 3938 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3939 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3940 * int[]></CODE> will be returned. 3941 * 3942 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3943 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3944 * may be retrieved.</I> 3945 * 3946 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3947 * <BR /><BR /><UL CLASS=JDUL> 3948 * <LI><CODE>int[] (<B>nodeIds</B></CODE>) 3949 * <BR />NodeIds of top layer elements 3950 * </LI> 3951 * </UL> */ 3952 public static Script<String, JsonObject, int[]> getTopLayerElements() 3953 { 3954 final int webSocketID = 17028000 + counter++; 3955 final boolean[] optionals = new boolean[0]; 3956 3957 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 3958 String requestJSON = WriteJSON.get( 3959 parameterTypes.get("getTopLayerElements"), 3960 parameterNames.get("getTopLayerElements"), 3961 optionals, webSocketID, 3962 "DOM.getTopLayerElements" 3963 ); 3964 3965 // 'JSON Binding' ... Converts Browser Response-JSON to 'int[]' 3966 Function<JsonObject, int[]> responseProcessor = (JsonObject jo) -> 3967 (jo.getJsonArray("nodeIds") == null) 3968 ? null 3969 : RJArrIntoPrimArray.intArr(jo.getJsonArray("nodeIds"), -1, 0, null); 3970 3971 return new Script<>(webSocketID, requestJSON, responseProcessor); 3972 } 3973 3974 /** 3975 * Returns the NodeId of the matched element according to certain relations. 3976 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 3977 * 3978 * @param nodeId Id of the node from which to query the relation. 3979 * 3980 * @param relation Type of relation to get. 3981 * <BR />Acceptable Values: ["PopoverTarget", "InterestTarget", "CommandFor"] 3982 * 3983 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 3984 * Integer></CODE> 3985 * 3986 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 3987 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 3988 * Integer></CODE> will be returned. 3989 * 3990 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 3991 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 3992 * may be retrieved.</I> 3993 * 3994 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 3995 * <BR /><BR /><UL CLASS=JDUL> 3996 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 3997 * <BR />NodeId of the element matching the queried relation. 3998 * </LI> 3999 * </UL> */ 4000 public static Script<String, JsonObject, Integer> getElementByRelation 4001 (int nodeId, String relation) 4002 { 4003 // Exception-Check(s) to ensure that if any parameters which are not declared as 4004 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4005 4006 if (relation == null) THROWS.throwNPE("relation"); 4007 4008 // Exception-Check(s) to ensure that if any parameters which must adhere to a 4009 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 4010 4011 THROWS.checkIAE( 4012 "relation", relation, 4013 "PopoverTarget", "InterestTarget", "CommandFor" 4014 ); 4015 4016 final int webSocketID = 17029000 + counter++; 4017 final boolean[] optionals = { false, false, }; 4018 4019 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4020 String requestJSON = WriteJSON.get( 4021 parameterTypes.get("getElementByRelation"), 4022 parameterNames.get("getElementByRelation"), 4023 optionals, webSocketID, 4024 "DOM.getElementByRelation", 4025 nodeId, relation 4026 ); 4027 4028 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 4029 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 4030 ReadBoxedJSON.getInteger(jo, "nodeId", true); 4031 4032 return new Script<>(webSocketID, requestJSON, responseProcessor); 4033 } 4034 4035 /** 4036 * Re-does the last undone action. 4037 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4038 * 4039 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4040 * {@link Ret0}></CODE> 4041 * 4042 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4043 * browser receives the invocation-request. 4044 * 4045 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4046 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4047 * {@code >} to ensure the Browser Function has run to completion. 4048 */ 4049 public static Script<String, JsonObject, Ret0> redo() 4050 { 4051 final int webSocketID = 17030000 + counter++; 4052 final boolean[] optionals = new boolean[0]; 4053 4054 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4055 String requestJSON = WriteJSON.get( 4056 parameterTypes.get("redo"), 4057 parameterNames.get("redo"), 4058 optionals, webSocketID, 4059 "DOM.redo" 4060 ); 4061 4062 // This Remote Command does not have a Return-Value. 4063 return new Script<> 4064 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4065 } 4066 4067 /** 4068 * Removes attribute with given name from an element with given id. 4069 * 4070 * @param nodeId Id of the element to remove attribute from. 4071 * 4072 * @param name Name of the attribute to remove. 4073 * 4074 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4075 * {@link Ret0}></CODE> 4076 * 4077 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4078 * browser receives the invocation-request. 4079 * 4080 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4081 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4082 * {@code >} to ensure the Browser Function has run to completion. 4083 */ 4084 public static Script<String, JsonObject, Ret0> removeAttribute(int nodeId, String name) 4085 { 4086 // Exception-Check(s) to ensure that if any parameters which are not declared as 4087 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4088 4089 if (name == null) THROWS.throwNPE("name"); 4090 4091 final int webSocketID = 17031000 + counter++; 4092 final boolean[] optionals = { false, false, }; 4093 4094 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4095 String requestJSON = WriteJSON.get( 4096 parameterTypes.get("removeAttribute"), 4097 parameterNames.get("removeAttribute"), 4098 optionals, webSocketID, 4099 "DOM.removeAttribute", 4100 nodeId, name 4101 ); 4102 4103 // This Remote Command does not have a Return-Value. 4104 return new Script<> 4105 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4106 } 4107 4108 /** 4109 * Removes node with given id. 4110 * 4111 * @param nodeId Id of the node to remove. 4112 * 4113 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4114 * {@link Ret0}></CODE> 4115 * 4116 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4117 * browser receives the invocation-request. 4118 * 4119 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4120 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4121 * {@code >} to ensure the Browser Function has run to completion. 4122 */ 4123 public static Script<String, JsonObject, Ret0> removeNode(int nodeId) 4124 { 4125 final int webSocketID = 17032000 + counter++; 4126 final boolean[] optionals = { false, }; 4127 4128 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4129 String requestJSON = WriteJSON.get( 4130 parameterTypes.get("removeNode"), 4131 parameterNames.get("removeNode"), 4132 optionals, webSocketID, 4133 "DOM.removeNode", 4134 nodeId 4135 ); 4136 4137 // This Remote Command does not have a Return-Value. 4138 return new Script<> 4139 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4140 } 4141 4142 /** 4143 * Requests that children of the node with given id are returned to the caller in form of 4144 * {@code setChildNodes} events where not only immediate children are retrieved, but all children down to 4145 * the specified depth. 4146 * 4147 * @param nodeId Id of the node to get children for. 4148 * 4149 * @param depth 4150 * The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the 4151 * entire subtree or provide an integer larger than 0. 4152 * <BR /><B CLASS=Opt>OPTIONAL</B> 4153 * 4154 * @param pierce 4155 * Whether or not iframes and shadow roots should be traversed when returning the sub-tree 4156 * (default is false). 4157 * <BR /><B CLASS=Opt>OPTIONAL</B> 4158 * 4159 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4160 * {@link Ret0}></CODE> 4161 * 4162 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4163 * browser receives the invocation-request. 4164 * 4165 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4166 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4167 * {@code >} to ensure the Browser Function has run to completion. 4168 */ 4169 public static Script<String, JsonObject, Ret0> requestChildNodes 4170 (int nodeId, Integer depth, Boolean pierce) 4171 { 4172 final int webSocketID = 17033000 + counter++; 4173 final boolean[] optionals = { false, true, true, }; 4174 4175 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4176 String requestJSON = WriteJSON.get( 4177 parameterTypes.get("requestChildNodes"), 4178 parameterNames.get("requestChildNodes"), 4179 optionals, webSocketID, 4180 "DOM.requestChildNodes", 4181 nodeId, depth, pierce 4182 ); 4183 4184 // This Remote Command does not have a Return-Value. 4185 return new Script<> 4186 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4187 } 4188 4189 /** 4190 * Requests that the node is sent to the caller given the JavaScript node object reference. All 4191 * nodes that form the path from the node to the root are also sent to the client as a series of 4192 * {@code setChildNodes} notifications. 4193 * 4194 * @param objectId JavaScript object id to convert into node. 4195 * 4196 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4197 * Integer></CODE> 4198 * 4199 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 4200 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 4201 * Integer></CODE> will be returned. 4202 * 4203 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 4204 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 4205 * may be retrieved.</I> 4206 * 4207 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 4208 * <BR /><BR /><UL CLASS=JDUL> 4209 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 4210 * <BR />Node id for given object. 4211 * </LI> 4212 * </UL> */ 4213 public static Script<String, JsonObject, Integer> requestNode(String objectId) 4214 { 4215 // Exception-Check(s) to ensure that if any parameters which are not declared as 4216 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4217 4218 if (objectId == null) THROWS.throwNPE("objectId"); 4219 4220 final int webSocketID = 17034000 + counter++; 4221 final boolean[] optionals = { false, }; 4222 4223 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4224 String requestJSON = WriteJSON.get( 4225 parameterTypes.get("requestNode"), 4226 parameterNames.get("requestNode"), 4227 optionals, webSocketID, 4228 "DOM.requestNode", 4229 objectId 4230 ); 4231 4232 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 4233 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 4234 ReadBoxedJSON.getInteger(jo, "nodeId", true); 4235 4236 return new Script<>(webSocketID, requestJSON, responseProcessor); 4237 } 4238 4239 /** 4240 * Resolves the JavaScript node object for a given NodeId or BackendNodeId. 4241 * 4242 * @param nodeId Id of the node to resolve. 4243 * <BR /><B CLASS=Opt>OPTIONAL</B> 4244 * 4245 * @param backendNodeId Backend identifier of the node to resolve. 4246 * <BR /><B CLASS=Opt>OPTIONAL</B> 4247 * 4248 * @param objectGroup Symbolic group name that can be used to release multiple objects. 4249 * <BR /><B CLASS=Opt>OPTIONAL</B> 4250 * 4251 * @param executionContextId Execution context in which to resolve the node. 4252 * <BR /><B CLASS=Opt>OPTIONAL</B> 4253 * 4254 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4255 * {@link RunTime.RemoteObject}></CODE> 4256 * 4257 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 4258 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 4259 * {@link RunTime.RemoteObject}></CODE> will be returned. 4260 * 4261 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 4262 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 4263 * may be retrieved.</I> 4264 * 4265 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 4266 * <BR /><BR /><UL CLASS=JDUL> 4267 * <LI><CODE>{@link RunTime.RemoteObject} (<B>object</B></CODE>) 4268 * <BR />JavaScript object wrapper for given node. 4269 * </LI> 4270 * </UL> */ 4271 public static Script<String, JsonObject, RunTime.RemoteObject> resolveNode 4272 (Integer nodeId, Integer backendNodeId, String objectGroup, Integer executionContextId) 4273 { 4274 final int webSocketID = 17035000 + counter++; 4275 final boolean[] optionals = { true, true, true, true, }; 4276 4277 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4278 String requestJSON = WriteJSON.get( 4279 parameterTypes.get("resolveNode"), 4280 parameterNames.get("resolveNode"), 4281 optionals, webSocketID, 4282 "DOM.resolveNode", 4283 nodeId, backendNodeId, objectGroup, executionContextId 4284 ); 4285 4286 // 'JSON Binding' ... Converts Browser Response-JSON to 'RunTime.RemoteObject' 4287 Function<JsonObject, RunTime.RemoteObject> responseProcessor = (JsonObject jo) -> 4288 ReadJSON.getObject(jo, "object", RunTime.RemoteObject.class, false, true); 4289 4290 return new Script<>(webSocketID, requestJSON, responseProcessor); 4291 } 4292 4293 /** 4294 * Sets attribute for an element with given id. 4295 * 4296 * @param nodeId Id of the element to set attribute for. 4297 * 4298 * @param name Attribute name. 4299 * 4300 * @param value Attribute value. 4301 * 4302 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4303 * {@link Ret0}></CODE> 4304 * 4305 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4306 * browser receives the invocation-request. 4307 * 4308 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4309 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4310 * {@code >} to ensure the Browser Function has run to completion. 4311 */ 4312 public static Script<String, JsonObject, Ret0> setAttributeValue 4313 (int nodeId, String name, String value) 4314 { 4315 // Exception-Check(s) to ensure that if any parameters which are not declared as 4316 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4317 4318 if (name == null) THROWS.throwNPE("name"); 4319 if (value == null) THROWS.throwNPE("value"); 4320 4321 final int webSocketID = 17036000 + counter++; 4322 final boolean[] optionals = { false, false, false, }; 4323 4324 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4325 String requestJSON = WriteJSON.get( 4326 parameterTypes.get("setAttributeValue"), 4327 parameterNames.get("setAttributeValue"), 4328 optionals, webSocketID, 4329 "DOM.setAttributeValue", 4330 nodeId, name, value 4331 ); 4332 4333 // This Remote Command does not have a Return-Value. 4334 return new Script<> 4335 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4336 } 4337 4338 /** 4339 * Sets attributes on element with given id. This method is useful when user edits some existing 4340 * attribute value and types in several attribute name/value pairs. 4341 * 4342 * @param nodeId Id of the element to set attributes for. 4343 * 4344 * @param text Text with a number of attributes. Will parse this text using HTML parser. 4345 * 4346 * @param name 4347 * Attribute name to replace with new attributes derived from text in case text parsed 4348 * successfully. 4349 * <BR /><B CLASS=Opt>OPTIONAL</B> 4350 * 4351 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4352 * {@link Ret0}></CODE> 4353 * 4354 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4355 * browser receives the invocation-request. 4356 * 4357 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4358 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4359 * {@code >} to ensure the Browser Function has run to completion. 4360 */ 4361 public static Script<String, JsonObject, Ret0> setAttributesAsText 4362 (int nodeId, String text, String name) 4363 { 4364 // Exception-Check(s) to ensure that if any parameters which are not declared as 4365 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4366 4367 if (text == null) THROWS.throwNPE("text"); 4368 4369 final int webSocketID = 17037000 + counter++; 4370 final boolean[] optionals = { false, false, true, }; 4371 4372 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4373 String requestJSON = WriteJSON.get( 4374 parameterTypes.get("setAttributesAsText"), 4375 parameterNames.get("setAttributesAsText"), 4376 optionals, webSocketID, 4377 "DOM.setAttributesAsText", 4378 nodeId, text, name 4379 ); 4380 4381 // This Remote Command does not have a Return-Value. 4382 return new Script<> 4383 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4384 } 4385 4386 /** 4387 * Sets files for the given file input element. 4388 * 4389 * @param files Array of file paths to set. 4390 * 4391 * @param nodeId Identifier of the node. 4392 * <BR /><B CLASS=Opt>OPTIONAL</B> 4393 * 4394 * @param backendNodeId Identifier of the backend node. 4395 * <BR /><B CLASS=Opt>OPTIONAL</B> 4396 * 4397 * @param objectId JavaScript object id of the node wrapper. 4398 * <BR /><B CLASS=Opt>OPTIONAL</B> 4399 * 4400 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4401 * {@link Ret0}></CODE> 4402 * 4403 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4404 * browser receives the invocation-request. 4405 * 4406 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4407 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4408 * {@code >} to ensure the Browser Function has run to completion. 4409 */ 4410 public static Script<String, JsonObject, Ret0> setFileInputFiles 4411 (String[] files, Integer nodeId, Integer backendNodeId, String objectId) 4412 { 4413 // Exception-Check(s) to ensure that if any parameters which are not declared as 4414 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4415 4416 if (files == null) THROWS.throwNPE("files"); 4417 4418 final int webSocketID = 17038000 + counter++; 4419 final boolean[] optionals = { false, true, true, true, }; 4420 4421 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4422 String requestJSON = WriteJSON.get( 4423 parameterTypes.get("setFileInputFiles"), 4424 parameterNames.get("setFileInputFiles"), 4425 optionals, webSocketID, 4426 "DOM.setFileInputFiles", 4427 files, nodeId, backendNodeId, objectId 4428 ); 4429 4430 // This Remote Command does not have a Return-Value. 4431 return new Script<> 4432 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4433 } 4434 4435 /** 4436 * Sets if stack traces should be captured for Nodes. See {@code Node.getNodeStackTraces}. Default is disabled. 4437 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4438 * 4439 * @param enable Enable or disable. 4440 * 4441 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4442 * {@link Ret0}></CODE> 4443 * 4444 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4445 * browser receives the invocation-request. 4446 * 4447 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4448 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4449 * {@code >} to ensure the Browser Function has run to completion. 4450 */ 4451 public static Script<String, JsonObject, Ret0> setNodeStackTracesEnabled(boolean enable) 4452 { 4453 final int webSocketID = 17039000 + counter++; 4454 final boolean[] optionals = { false, }; 4455 4456 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4457 String requestJSON = WriteJSON.get( 4458 parameterTypes.get("setNodeStackTracesEnabled"), 4459 parameterNames.get("setNodeStackTracesEnabled"), 4460 optionals, webSocketID, 4461 "DOM.setNodeStackTracesEnabled", 4462 enable 4463 ); 4464 4465 // This Remote Command does not have a Return-Value. 4466 return new Script<> 4467 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4468 } 4469 4470 /** 4471 * Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation. 4472 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4473 * 4474 * @param nodeId Id of the node to get stack traces for. 4475 * 4476 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4477 * {@link RunTime.StackTrace}></CODE> 4478 * 4479 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 4480 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 4481 * {@link RunTime.StackTrace}></CODE> will be returned. 4482 * 4483 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 4484 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 4485 * may be retrieved.</I> 4486 * 4487 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 4488 * <BR /><BR /><UL CLASS=JDUL> 4489 * <LI><CODE>{@link RunTime.StackTrace} (<B>creation</B></CODE>) 4490 * <BR />Creation stack trace, if available. 4491 * </LI> 4492 * </UL> */ 4493 public static Script<String, JsonObject, RunTime.StackTrace> getNodeStackTraces(int nodeId) 4494 { 4495 final int webSocketID = 17040000 + counter++; 4496 final boolean[] optionals = { false, }; 4497 4498 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4499 String requestJSON = WriteJSON.get( 4500 parameterTypes.get("getNodeStackTraces"), 4501 parameterNames.get("getNodeStackTraces"), 4502 optionals, webSocketID, 4503 "DOM.getNodeStackTraces", 4504 nodeId 4505 ); 4506 4507 // 'JSON Binding' ... Converts Browser Response-JSON to 'RunTime.StackTrace' 4508 Function<JsonObject, RunTime.StackTrace> responseProcessor = (JsonObject jo) -> 4509 ReadJSON.getObject(jo, "creation", RunTime.StackTrace.class, true, false); 4510 4511 return new Script<>(webSocketID, requestJSON, responseProcessor); 4512 } 4513 4514 /** 4515 * Returns file information for the given 4516 * File wrapper. 4517 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4518 * 4519 * @param objectId JavaScript object id of the node wrapper. 4520 * 4521 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4522 * String></CODE> 4523 * 4524 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 4525 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 4526 * String></CODE> will be returned. 4527 * 4528 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 4529 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 4530 * may be retrieved.</I> 4531 * 4532 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 4533 * <BR /><BR /><UL CLASS=JDUL> 4534 * <LI><CODE>String (<B>path</B></CODE>) 4535 * <BR />- 4536 * </LI> 4537 * </UL> */ 4538 public static Script<String, JsonObject, String> getFileInfo(String objectId) 4539 { 4540 // Exception-Check(s) to ensure that if any parameters which are not declared as 4541 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4542 4543 if (objectId == null) THROWS.throwNPE("objectId"); 4544 4545 final int webSocketID = 17041000 + counter++; 4546 final boolean[] optionals = { false, }; 4547 4548 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4549 String requestJSON = WriteJSON.get( 4550 parameterTypes.get("getFileInfo"), 4551 parameterNames.get("getFileInfo"), 4552 optionals, webSocketID, 4553 "DOM.getFileInfo", 4554 objectId 4555 ); 4556 4557 // 'JSON Binding' ... Converts Browser Response-JSON to 'String' 4558 Function<JsonObject, String> responseProcessor = (JsonObject jo) -> 4559 ReadJSON.getString(jo, "path", false, true); 4560 4561 return new Script<>(webSocketID, requestJSON, responseProcessor); 4562 } 4563 4564 /** 4565 * Returns list of detached nodes 4566 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4567 * 4568 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4569 * {@link DOM.DetachedElementInfo}[]></CODE> 4570 * 4571 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 4572 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 4573 * {@link DOM.DetachedElementInfo}[]></CODE> will be returned. 4574 * 4575 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 4576 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 4577 * may be retrieved.</I> 4578 * 4579 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 4580 * <BR /><BR /><UL CLASS=JDUL> 4581 * <LI><CODE>{@link DOM.DetachedElementInfo}[] (<B>detachedNodes</B></CODE>) 4582 * <BR />The list of detached nodes 4583 * </LI> 4584 * </UL> */ 4585 public static Script<String, JsonObject, DOM.DetachedElementInfo[]> getDetachedDomNodes() 4586 { 4587 final int webSocketID = 17042000 + counter++; 4588 final boolean[] optionals = new boolean[0]; 4589 4590 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4591 String requestJSON = WriteJSON.get( 4592 parameterTypes.get("getDetachedDomNodes"), 4593 parameterNames.get("getDetachedDomNodes"), 4594 optionals, webSocketID, 4595 "DOM.getDetachedDomNodes" 4596 ); 4597 4598 // 'JSON Binding' ... Converts Browser Response-JSON to 'DOM.DetachedElementInfo[]' 4599 Function<JsonObject, DOM.DetachedElementInfo[]> responseProcessor = (JsonObject jo) -> 4600 (jo.getJsonArray("detachedNodes") == null) 4601 ? null 4602 : RJArrIntoStream.objArr(jo.getJsonArray("detachedNodes"), null, 0, DOM.DetachedElementInfo.class).toArray(DOM.DetachedElementInfo[]::new); 4603 4604 return new Script<>(webSocketID, requestJSON, responseProcessor); 4605 } 4606 4607 /** 4608 * Enables console to refer to the node with given id via $x (see Command Line API for more details 4609 * $x functions). 4610 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4611 * 4612 * @param nodeId DOM node id to be accessible by means of $x command line API. 4613 * 4614 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4615 * {@link Ret0}></CODE> 4616 * 4617 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4618 * browser receives the invocation-request. 4619 * 4620 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4621 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4622 * {@code >} to ensure the Browser Function has run to completion. 4623 */ 4624 public static Script<String, JsonObject, Ret0> setInspectedNode(int nodeId) 4625 { 4626 final int webSocketID = 17043000 + counter++; 4627 final boolean[] optionals = { false, }; 4628 4629 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4630 String requestJSON = WriteJSON.get( 4631 parameterTypes.get("setInspectedNode"), 4632 parameterNames.get("setInspectedNode"), 4633 optionals, webSocketID, 4634 "DOM.setInspectedNode", 4635 nodeId 4636 ); 4637 4638 // This Remote Command does not have a Return-Value. 4639 return new Script<> 4640 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4641 } 4642 4643 /** 4644 * Sets node name for a node with given id. 4645 * 4646 * @param nodeId Id of the node to set name for. 4647 * 4648 * @param name New node's name. 4649 * 4650 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4651 * Integer></CODE> 4652 * 4653 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 4654 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 4655 * Integer></CODE> will be returned. 4656 * 4657 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 4658 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 4659 * may be retrieved.</I> 4660 * 4661 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 4662 * <BR /><BR /><UL CLASS=JDUL> 4663 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 4664 * <BR />New node's id. 4665 * </LI> 4666 * </UL> */ 4667 public static Script<String, JsonObject, Integer> setNodeName(int nodeId, String name) 4668 { 4669 // Exception-Check(s) to ensure that if any parameters which are not declared as 4670 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4671 4672 if (name == null) THROWS.throwNPE("name"); 4673 4674 final int webSocketID = 17044000 + counter++; 4675 final boolean[] optionals = { false, false, }; 4676 4677 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4678 String requestJSON = WriteJSON.get( 4679 parameterTypes.get("setNodeName"), 4680 parameterNames.get("setNodeName"), 4681 optionals, webSocketID, 4682 "DOM.setNodeName", 4683 nodeId, name 4684 ); 4685 4686 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 4687 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 4688 ReadBoxedJSON.getInteger(jo, "nodeId", true); 4689 4690 return new Script<>(webSocketID, requestJSON, responseProcessor); 4691 } 4692 4693 /** 4694 * Sets node value for a node with given id. 4695 * 4696 * @param nodeId Id of the node to set value for. 4697 * 4698 * @param value New node's value. 4699 * 4700 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4701 * {@link Ret0}></CODE> 4702 * 4703 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4704 * browser receives the invocation-request. 4705 * 4706 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4707 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4708 * {@code >} to ensure the Browser Function has run to completion. 4709 */ 4710 public static Script<String, JsonObject, Ret0> setNodeValue(int nodeId, String value) 4711 { 4712 // Exception-Check(s) to ensure that if any parameters which are not declared as 4713 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4714 4715 if (value == null) THROWS.throwNPE("value"); 4716 4717 final int webSocketID = 17045000 + counter++; 4718 final boolean[] optionals = { false, false, }; 4719 4720 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4721 String requestJSON = WriteJSON.get( 4722 parameterTypes.get("setNodeValue"), 4723 parameterNames.get("setNodeValue"), 4724 optionals, webSocketID, 4725 "DOM.setNodeValue", 4726 nodeId, value 4727 ); 4728 4729 // This Remote Command does not have a Return-Value. 4730 return new Script<> 4731 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4732 } 4733 4734 /** 4735 * Sets node HTML markup, returns new node id. 4736 * 4737 * @param nodeId Id of the node to set markup for. 4738 * 4739 * @param outerHTML Outer HTML markup to set. 4740 * 4741 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4742 * {@link Ret0}></CODE> 4743 * 4744 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4745 * browser receives the invocation-request. 4746 * 4747 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4748 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4749 * {@code >} to ensure the Browser Function has run to completion. 4750 */ 4751 public static Script<String, JsonObject, Ret0> setOuterHTML(int nodeId, String outerHTML) 4752 { 4753 // Exception-Check(s) to ensure that if any parameters which are not declared as 4754 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4755 4756 if (outerHTML == null) THROWS.throwNPE("outerHTML"); 4757 4758 final int webSocketID = 17046000 + counter++; 4759 final boolean[] optionals = { false, false, }; 4760 4761 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4762 String requestJSON = WriteJSON.get( 4763 parameterTypes.get("setOuterHTML"), 4764 parameterNames.get("setOuterHTML"), 4765 optionals, webSocketID, 4766 "DOM.setOuterHTML", 4767 nodeId, outerHTML 4768 ); 4769 4770 // This Remote Command does not have a Return-Value. 4771 return new Script<> 4772 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4773 } 4774 4775 /** 4776 * Undoes the last performed action. 4777 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4778 * 4779 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4780 * {@link Ret0}></CODE> 4781 * 4782 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 4783 * browser receives the invocation-request. 4784 * 4785 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 4786 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 4787 * {@code >} to ensure the Browser Function has run to completion. 4788 */ 4789 public static Script<String, JsonObject, Ret0> undo() 4790 { 4791 final int webSocketID = 17047000 + counter++; 4792 final boolean[] optionals = new boolean[0]; 4793 4794 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4795 String requestJSON = WriteJSON.get( 4796 parameterTypes.get("undo"), 4797 parameterNames.get("undo"), 4798 optionals, webSocketID, 4799 "DOM.undo" 4800 ); 4801 4802 // This Remote Command does not have a Return-Value. 4803 return new Script<> 4804 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 4805 } 4806 4807 /** 4808 * Returns iframe node that owns iframe with the given domain. 4809 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4810 * 4811 * @param frameId - 4812 * 4813 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4814 * {@link Ret2}></CODE> 4815 * 4816 * <BR /><BR />This {@link Script} may be <B STYLE='color:red'>executed</B> (using 4817 * {@link Script#exec()}), and a {@link Promise} returned. 4818 * 4819 * <BR /><BR />When the {@code Promise} is <B STYLE='color: red'>awaited</B> 4820 * (using {@link Promise#await()}), the {@code Ret2} will subsequently 4821 * be returned from that call. 4822 * 4823 * <BR /><BR />The <B STYLE='color: red'>returned</B> values are encapsulated 4824 * in an instance of <B>{@link Ret2}</B> 4825 * 4826 * <BR /><BR /><UL CLASS=JDUL> 4827 * <LI><CODE><B>Ret2.a:</B> Integer (<B>backendNodeId</B>)</CODE> 4828 * <BR />Resulting node. 4829 * <BR /><BR /></LI> 4830 * <LI><CODE><B>Ret2.b:</B> Integer (<B>nodeId</B>)</CODE> 4831 * <BR />Id of the node at given coordinates, only when enabled and requested document. 4832 * </LI> 4833 * </UL> 4834 */ 4835 public static Script<String, JsonObject, Ret2<Integer, Integer>> getFrameOwner 4836 (String frameId) 4837 { 4838 // Exception-Check(s) to ensure that if any parameters which are not declared as 4839 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 4840 4841 if (frameId == null) THROWS.throwNPE("frameId"); 4842 4843 final int webSocketID = 17048000 + counter++; 4844 final boolean[] optionals = { false, }; 4845 4846 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4847 String requestJSON = WriteJSON.get( 4848 parameterTypes.get("getFrameOwner"), 4849 parameterNames.get("getFrameOwner"), 4850 optionals, webSocketID, 4851 "DOM.getFrameOwner", 4852 frameId 4853 ); 4854 4855 // 'JSON Binding' ... Converts Browser Response-JSON into Java-Type 'Ret2' 4856 Function<JsonObject, Ret2<Integer, Integer>> 4857 responseProcessor = (JsonObject jo) -> new Ret2<>( 4858 ReadBoxedJSON.getInteger(jo, "backendNodeId", true), 4859 ReadBoxedJSON.getInteger(jo, "nodeId", true) 4860 ); 4861 4862 return new Script<>(webSocketID, requestJSON, responseProcessor); 4863 } 4864 4865 /** 4866 * Returns the query container of the given node based on container query 4867 * conditions: containerName, physical and logical axes, and whether it queries 4868 * scroll-state or anchored elements. If no axes are provided and 4869 * queriesScrollState is false, the style container is returned, which is the 4870 * direct parent or the closest element with a matching container-name. 4871 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4872 * 4873 * @param nodeId - 4874 * 4875 * @param containerName - 4876 * <BR /><B CLASS=Opt>OPTIONAL</B> 4877 * 4878 * @param physicalAxes - 4879 * <BR /><B CLASS=Opt>OPTIONAL</B> 4880 * 4881 * @param logicalAxes - 4882 * <BR /><B CLASS=Opt>OPTIONAL</B> 4883 * 4884 * @param queriesScrollState - 4885 * <BR /><B CLASS=Opt>OPTIONAL</B> 4886 * 4887 * @param queriesAnchored - 4888 * <BR /><B CLASS=Opt>OPTIONAL</B> 4889 * 4890 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4891 * Integer></CODE> 4892 * 4893 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 4894 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 4895 * Integer></CODE> will be returned. 4896 * 4897 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 4898 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 4899 * may be retrieved.</I> 4900 * 4901 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 4902 * <BR /><BR /><UL CLASS=JDUL> 4903 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 4904 * <BR />The container node for the given node, or null if not found. 4905 * </LI> 4906 * </UL> */ 4907 public static Script<String, JsonObject, Integer> getContainerForNode( 4908 int nodeId, String containerName, String physicalAxes, String logicalAxes, 4909 Boolean queriesScrollState, Boolean queriesAnchored 4910 ) 4911 { 4912 // Exception-Check(s) to ensure that if any parameters which must adhere to a 4913 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 4914 4915 THROWS.checkIAE("physicalAxes", physicalAxes, "DOM.PhysicalAxes", DOM.PhysicalAxes); 4916 THROWS.checkIAE("logicalAxes", logicalAxes, "DOM.LogicalAxes", DOM.LogicalAxes); 4917 4918 final int webSocketID = 17049000 + counter++; 4919 final boolean[] optionals = { false, true, true, true, true, true, }; 4920 4921 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4922 String requestJSON = WriteJSON.get( 4923 parameterTypes.get("getContainerForNode"), 4924 parameterNames.get("getContainerForNode"), 4925 optionals, webSocketID, 4926 "DOM.getContainerForNode", 4927 nodeId, containerName, physicalAxes, logicalAxes, queriesScrollState, queriesAnchored 4928 ); 4929 4930 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 4931 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 4932 ReadBoxedJSON.getInteger(jo, "nodeId", true); 4933 4934 return new Script<>(webSocketID, requestJSON, responseProcessor); 4935 } 4936 4937 /** 4938 * Returns the descendants of a container query container that have 4939 * container queries against this container. 4940 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4941 * 4942 * @param nodeId Id of the container node to find querying descendants from. 4943 * 4944 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 4945 * int[]></CODE> 4946 * 4947 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 4948 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 4949 * int[]></CODE> will be returned. 4950 * 4951 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 4952 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 4953 * may be retrieved.</I> 4954 * 4955 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 4956 * <BR /><BR /><UL CLASS=JDUL> 4957 * <LI><CODE>int[] (<B>nodeIds</B></CODE>) 4958 * <BR />Descendant nodes with container queries against the given container. 4959 * </LI> 4960 * </UL> */ 4961 public static Script<String, JsonObject, int[]> getQueryingDescendantsForContainer 4962 (int nodeId) 4963 { 4964 final int webSocketID = 17050000 + counter++; 4965 final boolean[] optionals = { false, }; 4966 4967 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 4968 String requestJSON = WriteJSON.get( 4969 parameterTypes.get("getQueryingDescendantsForContainer"), 4970 parameterNames.get("getQueryingDescendantsForContainer"), 4971 optionals, webSocketID, 4972 "DOM.getQueryingDescendantsForContainer", 4973 nodeId 4974 ); 4975 4976 // 'JSON Binding' ... Converts Browser Response-JSON to 'int[]' 4977 Function<JsonObject, int[]> responseProcessor = (JsonObject jo) -> 4978 (jo.getJsonArray("nodeIds") == null) 4979 ? null 4980 : RJArrIntoPrimArray.intArr(jo.getJsonArray("nodeIds"), -1, 0, null); 4981 4982 return new Script<>(webSocketID, requestJSON, responseProcessor); 4983 } 4984 4985 /** 4986 * Returns the target anchor element of the given anchor query according to 4987 * https://www.w3.org/TR/css-anchor-position-1/#target. 4988 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 4989 * 4990 * @param nodeId Id of the positioned element from which to find the anchor. 4991 * 4992 * @param anchorSpecifier 4993 * An optional anchor specifier, as defined in 4994 * https://www.w3.org/TR/css-anchor-position-1/#anchor-specifier. 4995 * If not provided, it will return the implicit anchor element for 4996 * the given positioned element. 4997 * <BR /><B CLASS=Opt>OPTIONAL</B> 4998 * 4999 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 5000 * Integer></CODE> 5001 * 5002 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 5003 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 5004 * Integer></CODE> will be returned. 5005 * 5006 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 5007 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 5008 * may be retrieved.</I> 5009 * 5010 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 5011 * <BR /><BR /><UL CLASS=JDUL> 5012 * <LI><CODE>Integer (<B>nodeId</B></CODE>) 5013 * <BR />The anchor element of the given anchor query. 5014 * </LI> 5015 * </UL> */ 5016 public static Script<String, JsonObject, Integer> getAnchorElement 5017 (int nodeId, String anchorSpecifier) 5018 { 5019 final int webSocketID = 17051000 + counter++; 5020 final boolean[] optionals = { false, true, }; 5021 5022 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 5023 String requestJSON = WriteJSON.get( 5024 parameterTypes.get("getAnchorElement"), 5025 parameterNames.get("getAnchorElement"), 5026 optionals, webSocketID, 5027 "DOM.getAnchorElement", 5028 nodeId, anchorSpecifier 5029 ); 5030 5031 // 'JSON Binding' ... Converts Browser Response-JSON to 'Integer' 5032 Function<JsonObject, Integer> responseProcessor = (JsonObject jo) -> 5033 ReadBoxedJSON.getInteger(jo, "nodeId", true); 5034 5035 return new Script<>(webSocketID, requestJSON, responseProcessor); 5036 } 5037 5038 /** 5039 * When enabling, this API force-opens the popover identified by nodeId 5040 * and keeps it open until disabled. 5041 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B> 5042 * 5043 * @param nodeId Id of the popover HTMLElement 5044 * 5045 * @param enable 5046 * If true, opens the popover and keeps it open. If false, closes the 5047 * popover if it was previously force-opened. 5048 * 5049 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 5050 * int[]></CODE> 5051 * 5052 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 5053 * {@link Script#exec()}, and afterwards, a {@link Promise}<CODE><JsonObject, 5054 * int[]></CODE> will be returned. 5055 * 5056 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 5057 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 5058 * may be retrieved.</I> 5059 * 5060 * <BR /><BR />This Browser Function <B STYLE='color: red'>returns</B> 5061 * <BR /><BR /><UL CLASS=JDUL> 5062 * <LI><CODE>int[] (<B>nodeIds</B></CODE>) 5063 * <BR />List of popovers that were closed in order to respect popover stacking order. 5064 * </LI> 5065 * </UL> */ 5066 public static Script<String, JsonObject, int[]> forceShowPopover(int nodeId, boolean enable) 5067 { 5068 final int webSocketID = 17052000 + counter++; 5069 final boolean[] optionals = { false, false, }; 5070 5071 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 5072 String requestJSON = WriteJSON.get( 5073 parameterTypes.get("forceShowPopover"), 5074 parameterNames.get("forceShowPopover"), 5075 optionals, webSocketID, 5076 "DOM.forceShowPopover", 5077 nodeId, enable 5078 ); 5079 5080 // 'JSON Binding' ... Converts Browser Response-JSON to 'int[]' 5081 Function<JsonObject, int[]> responseProcessor = (JsonObject jo) -> 5082 (jo.getJsonArray("nodeIds") == null) 5083 ? null 5084 : RJArrIntoPrimArray.intArr(jo.getJsonArray("nodeIds"), -1, 0, null); 5085 5086 return new Script<>(webSocketID, requestJSON, responseProcessor); 5087 } 5088 5089}