001package Torello.Browser.BrowserAPI;
002
003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
004// Java-HTML Imports
005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
006
007import Torello.Browser.*;
008import Torello.Browser.helper.*;
009import Torello.Browser.JavaScriptAPI.*;
010import Torello.JSON.*;
011
012import Torello.Java.ReadOnly.ReadOnlyList;
013import Torello.Java.ReadOnly.ReadOnlyArrayList;
014
015import Torello.JavaDoc.Annotations.StaticFunctional;
016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg;
017
018import Torello.Browser.BrowserAPI.NestedHelpers.Commands.LayerTree$$Commands;
019
020
021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
022// JDK Imports
023// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
024
025import javax.json.JsonObject;
026import javax.json.JsonValue;
027
028/**
029 * <SPAN CLASS=COPIEDJDK><B><CODE>[No Description Provided by Google]</CODE></B></SPAN>
030 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE>
031 */
032@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE")
033public class LayerTree
034{
035    // No Pubic Constructors
036    private LayerTree() { }
037
038
039    // ********************************************************************************************
040    // ********************************************************************************************
041    // Eliminated Types
042    // ********************************************************************************************
043    // ********************************************************************************************
044
045
046    /**
047     * Unique Layer identifier.
048
049     * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType
050     *     DATA-NAME=LayerId>
051     */
052    public static final String LayerId =
053        "LayerId has been eliminated.\n" +
054        "It was replaced with the standard Java-Type: String";
055
056    /**
057     * Array of timings, one per paint step.
058
059     * <EMBED CLASS='external-html' DATA-CTAS='Number' DATA-FILE-ID=CDP.EliminatedType
060     *     DATA-NAME=PaintProfile>
061     */
062    public static final String PaintProfile =
063        "PaintProfile has been eliminated.\n" +
064        "It was replaced with the standard Java-Type: Number";
065
066    /**
067     * Unique snapshot identifier.
068
069     * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType
070     *     DATA-NAME=SnapshotId>
071     */
072    public static final String SnapshotId =
073        "SnapshotId has been eliminated.\n" +
074        "It was replaced with the standard Java-Type: String";
075
076
077
078    // ********************************************************************************************
079    // ********************************************************************************************
080    // Basic Types
081    // ********************************************************************************************
082    // ********************************************************************************************
083
084
085    /**
086     * Information about a compositing layer.
087     * 
088     * <EMBED CLASS=globalDefs DATA-DOMAIN=LayerTree DATA-API=BrowserAPI>
089     */
090    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
091    public static class Layer
092        extends BaseType<Layer>
093        implements java.io.Serializable
094    {
095        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
096        protected static final long serialVersionUID = 1;
097
098        private static final NestedHelper<LayerTree.Layer> singleton =
099            Torello.Browser.BrowserAPI.NestedHelpers.Types.
100                LayerTree$$Layer$$.singleton;
101
102        /** The unique id for this layer. */
103        public final String layerId;
104
105        /**
106         * The id of parent (not present for root).
107         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
108         */
109        public final String parentLayerId;
110
111        /**
112         * The backend id for the node associated with this layer.
113         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
114         */
115        public final Integer backendNodeId;
116
117        /** Offset from parent layer, X coordinate. */
118        public final Number offsetX;
119
120        /** Offset from parent layer, Y coordinate. */
121        public final Number offsetY;
122
123        /** Layer width. */
124        public final Number width;
125
126        /** Layer height. */
127        public final Number height;
128
129        /**
130         * Transformation matrix for layer, default is identity matrix
131         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
132         */
133        public final Number[] transform;
134
135        /**
136         * Transform anchor point X, absent if no transform specified
137         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
138         */
139        public final Number anchorX;
140
141        /**
142         * Transform anchor point Y, absent if no transform specified
143         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
144         */
145        public final Number anchorY;
146
147        /**
148         * Transform anchor point Z, absent if no transform specified
149         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
150         */
151        public final Number anchorZ;
152
153        /** Indicates how many time this layer has painted. */
154        public final int paintCount;
155
156        /**
157         * Indicates whether this layer hosts any content, rather than being used for
158         * transform/scrolling purposes only.
159         */
160        public final boolean drawsContent;
161
162        /**
163         * Set if layer is not visible.
164         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
165         */
166        public final Boolean invisible;
167
168        /**
169         * Rectangles scrolling on main thread only.
170         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
171         */
172        public final LayerTree.ScrollRect[] scrollRects;
173
174        /**
175         * Sticky position constraint information
176         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
177         */
178        public final LayerTree.StickyPositionConstraint stickyPositionConstraint;
179
180        /** Constructor.  Please review this class' fields for documentation. */
181        public Layer(
182                ReadOnlyList<Boolean> isPresent, String layerId, String parentLayerId,
183                Integer backendNodeId, Number offsetX, Number offsetY, Number width, Number height,
184                Number[] transform, Number anchorX, Number anchorY, Number anchorZ, int paintCount,
185                boolean drawsContent, Boolean invisible, ScrollRect[] scrollRects,
186                StickyPositionConstraint stickyPositionConstraint
187            )
188        {
189            super(singleton, Domains.LayerTree, "Layer", 16);
190
191            this.layerId                    = layerId;
192            this.parentLayerId              = parentLayerId;
193            this.backendNodeId              = backendNodeId;
194            this.offsetX                    = offsetX;
195            this.offsetY                    = offsetY;
196            this.width                      = width;
197            this.height                     = height;
198            this.transform                  = transform;
199            this.anchorX                    = anchorX;
200            this.anchorY                    = anchorY;
201            this.anchorZ                    = anchorZ;
202            this.paintCount                 = paintCount;
203            this.drawsContent               = drawsContent;
204            this.invisible                  = invisible;
205            this.scrollRects                = scrollRects;
206            this.stickyPositionConstraint   = stickyPositionConstraint;
207
208            this.isPresent = (isPresent == null)
209                ? singleton.generateIsPresentList(this)
210                : THROWS.check(isPresent, 16, "LayerTree.Layer");
211        }
212
213        /** Creates an instance of this class from a {@link JsonObject}.*/
214        public static Layer fromJSON(JsonObject jo)
215        { return singleton.fromJSON(jo); }
216
217        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
218        public static NestedDescriptor<Layer> descriptor()
219        { return singleton.descriptor(); }
220    }
221
222    /**
223     * Serialized fragment of layer picture along with its offset within the layer.
224     * 
225     * <EMBED CLASS=globalDefs DATA-DOMAIN=LayerTree DATA-API=BrowserAPI>
226     */
227    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
228    public static class PictureTile
229        extends BaseType<PictureTile>
230        implements java.io.Serializable
231    {
232        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
233        protected static final long serialVersionUID = 1;
234
235        private static final NestedHelper<LayerTree.PictureTile> singleton =
236            Torello.Browser.BrowserAPI.NestedHelpers.Types.
237                LayerTree$$PictureTile$$.singleton;
238
239        /** Offset from owning layer left boundary */
240        public final Number x;
241
242        /** Offset from owning layer top boundary */
243        public final Number y;
244
245        /** Base64-encoded snapshot data. (Encoded as a base64 string when passed over JSON) */
246        public final String picture;
247
248        /** Constructor.  Please review this class' fields for documentation. */
249        public PictureTile(ReadOnlyList<Boolean> isPresent, Number x, Number y, String picture)
250        {
251            super(singleton, Domains.LayerTree, "PictureTile", 3);
252
253            this.x          = x;
254            this.y          = y;
255            this.picture    = picture;
256
257            this.isPresent = (isPresent == null)
258                ? singleton.generateIsPresentList(this)
259                : THROWS.check(isPresent, 3, "LayerTree.PictureTile");
260        }
261
262        /** Creates an instance of this class from a {@link JsonObject}.*/
263        public static PictureTile fromJSON(JsonObject jo)
264        { return singleton.fromJSON(jo); }
265
266        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
267        public static NestedDescriptor<PictureTile> descriptor()
268        { return singleton.descriptor(); }
269    }
270
271    /**
272     * Rectangle where scrolling happens on the main thread.
273     * 
274     * <EMBED CLASS=globalDefs DATA-DOMAIN=LayerTree DATA-API=BrowserAPI>
275     */
276    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
277    public static class ScrollRect
278        extends BaseType<ScrollRect>
279        implements java.io.Serializable
280    {
281        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
282        protected static final long serialVersionUID = 1;
283
284        private static final NestedHelper<LayerTree.ScrollRect> singleton =
285            Torello.Browser.BrowserAPI.NestedHelpers.Types.
286                LayerTree$$ScrollRect$$.singleton;
287
288        /** Rectangle itself. */
289        public final DOM.Rect rect;
290
291        /**
292         * Reason for rectangle to force scrolling on the main thread
293         * <EMBED CLASS='external-html' DATA-D=LayerTree DATA-C=ScrollRect DATA-F=type DATA-FILE-ID=CDP.EL1>
294         * @see BaseType#enumStrList(String)
295         */
296        public final String type;
297
298        /** Constructor.  Please review this class' fields for documentation. */
299        public ScrollRect(ReadOnlyList<Boolean> isPresent, DOM.Rect rect, String type)
300        {
301            super(singleton, Domains.LayerTree, "ScrollRect", 2);
302
303            this.rect = rect;
304            this.type = type;
305
306            this.isPresent = (isPresent == null)
307                ? singleton.generateIsPresentList(this)
308                : THROWS.check(isPresent, 2, "LayerTree.ScrollRect");
309        }
310
311        /** Creates an instance of this class from a {@link JsonObject}.*/
312        public static ScrollRect fromJSON(JsonObject jo)
313        { return singleton.fromJSON(jo); }
314
315        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
316        public static NestedDescriptor<ScrollRect> descriptor()
317        { return singleton.descriptor(); }
318    }
319
320    /**
321     * Sticky position constraints.
322     * 
323     * <EMBED CLASS=globalDefs DATA-DOMAIN=LayerTree DATA-API=BrowserAPI>
324     */
325    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
326    public static class StickyPositionConstraint
327        extends BaseType<StickyPositionConstraint>
328        implements java.io.Serializable
329    {
330        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
331        protected static final long serialVersionUID = 1;
332
333        private static final NestedHelper<LayerTree.StickyPositionConstraint> singleton =
334            Torello.Browser.BrowserAPI.NestedHelpers.Types.
335                LayerTree$$StickyPositionConstraint$$.singleton;
336
337        /** Layout rectangle of the sticky element before being shifted */
338        public final DOM.Rect stickyBoxRect;
339
340        /** Layout rectangle of the containing block of the sticky element */
341        public final DOM.Rect containingBlockRect;
342
343        /**
344         * The nearest sticky layer that shifts the sticky box
345         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
346         */
347        public final String nearestLayerShiftingStickyBox;
348
349        /**
350         * The nearest sticky layer that shifts the containing block
351         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
352         */
353        public final String nearestLayerShiftingContainingBlock;
354
355        /** Constructor.  Please review this class' fields for documentation. */
356        public StickyPositionConstraint(
357                ReadOnlyList<Boolean> isPresent, DOM.Rect stickyBoxRect,
358                DOM.Rect containingBlockRect, String nearestLayerShiftingStickyBox,
359                String nearestLayerShiftingContainingBlock
360            )
361        {
362            super(singleton, Domains.LayerTree, "StickyPositionConstraint", 4);
363
364            this.stickyBoxRect                          = stickyBoxRect;
365            this.containingBlockRect                    = containingBlockRect;
366            this.nearestLayerShiftingStickyBox          = nearestLayerShiftingStickyBox;
367            this.nearestLayerShiftingContainingBlock    = nearestLayerShiftingContainingBlock;
368
369            this.isPresent = (isPresent == null)
370                ? singleton.generateIsPresentList(this)
371                : THROWS.check(isPresent, 4, "LayerTree.StickyPositionConstraint");
372        }
373
374        /** Creates an instance of this class from a {@link JsonObject}.*/
375        public static StickyPositionConstraint fromJSON(JsonObject jo)
376        { return singleton.fromJSON(jo); }
377
378        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
379        public static NestedDescriptor<StickyPositionConstraint> descriptor()
380        { return singleton.descriptor(); }
381    }
382
383
384    // ********************************************************************************************
385    // ********************************************************************************************
386    // Command-Return Types
387    // ********************************************************************************************
388    // ********************************************************************************************
389
390
391    /**
392     * Provides the reasons why the given layer was composited.
393     * 
394     * <EMBED CLASS=globalDefs DATA-DOMAIN=LayerTree DATA-API=BrowserAPI DATA-CMD=compositingReasons>
395     * @see LayerTree#compositingReasons
396     */
397    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_CMD_JDHBI")
398    public static class compositingReasons$$RET
399        extends BaseType<compositingReasons$$RET>
400        implements java.io.Serializable
401    {
402        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
403        protected static final long serialVersionUID = 1;
404
405        private static final NestedHelper<LayerTree.compositingReasons$$RET> singleton =
406            Torello.Browser.BrowserAPI.NestedHelpers.CmdReturns.
407                LayerTree$$compositingReasons$$RET.singleton;
408
409        /** A list of strings specifying reasons for the given layer to become composited. */
410        public final String[] compositingReasons;
411
412        /** A list of strings specifying reason IDs for the given layer to become composited. */
413        public final String[] compositingReasonIds;
414
415        /** Constructor.  Please review this class' fields for documentation. */
416        public compositingReasons$$RET(
417                ReadOnlyList<Boolean> isPresent, String[] compositingReasons,
418                String[] compositingReasonIds
419            )
420        {
421            super(singleton, Domains.LayerTree, "compositingReasons", 2);
422
423            this.compositingReasons     = compositingReasons;
424            this.compositingReasonIds   = compositingReasonIds;
425
426            this.isPresent = (isPresent == null)
427                ? singleton.generateIsPresentList(this)
428                : THROWS.check(isPresent, 2, "LayerTree.compositingReasons$$RET");
429        }
430
431        /** Creates an instance of this class from a {@link JsonObject}.*/
432        public static compositingReasons$$RET fromJSON(JsonObject jo)
433        { return singleton.fromJSON(jo); }
434
435        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
436        public static NestedDescriptor<compositingReasons$$RET> descriptor()
437        { return singleton.descriptor(); }
438    }
439
440
441    // ********************************************************************************************
442    // ********************************************************************************************
443    // Event Types
444    // ********************************************************************************************
445    // ********************************************************************************************
446
447
448    /**
449     * <CODE>[No Description Provided by Google]</CODE>
450     * 
451     * <EMBED CLASS=globalDefs DATA-DOMAIN=LayerTree DATA-API=BrowserAPI>
452     */
453    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
454    public static class layerPainted
455        extends BrowserEvent<layerPainted>
456        implements java.io.Serializable
457    {
458        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
459        protected static final long serialVersionUID = 1;
460
461        private static final NestedHelper<LayerTree.layerPainted> singleton =
462            Torello.Browser.BrowserAPI.NestedHelpers.Events.
463                LayerTree$$layerPainted$$.singleton;
464
465        /** The id of the painted layer. */
466        public final String layerId;
467
468        /** Clip rectangle. */
469        public final DOM.Rect clip;
470
471        /** Constructor.  Please review this class' fields for documentation. */
472        public layerPainted(ReadOnlyList<Boolean> isPresent, String layerId, DOM.Rect clip)
473        {
474            super(singleton, Domains.LayerTree, "layerPainted", 2);
475
476            this.layerId    = layerId;
477            this.clip       = clip;
478
479            this.isPresent = (isPresent == null)
480                ? singleton.generateIsPresentList(this)
481                : THROWS.check(isPresent, 2, "LayerTree.layerPainted");
482        }
483
484        /** Creates an instance of this class from a {@link JsonObject}.*/
485        public static layerPainted fromJSON(JsonObject jo)
486        { return singleton.fromJSON(jo); }
487
488        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
489        public static NestedDescriptor<layerPainted> descriptor()
490        { return singleton.descriptor(); }
491    }
492
493    /**
494     * <CODE>[No Description Provided by Google]</CODE>
495     * 
496     * <EMBED CLASS=globalDefs DATA-DOMAIN=LayerTree DATA-API=BrowserAPI>
497     */
498    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
499    public static class layerTreeDidChange
500        extends BrowserEvent<layerTreeDidChange>
501        implements java.io.Serializable
502    {
503        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
504        protected static final long serialVersionUID = 1;
505
506        private static final NestedHelper<LayerTree.layerTreeDidChange> singleton =
507            Torello.Browser.BrowserAPI.NestedHelpers.Events.
508                LayerTree$$layerTreeDidChange$$.singleton;
509
510        /**
511         * Layer tree, absent if not in the compositing mode.
512         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
513         */
514        public final LayerTree.Layer[] layers;
515
516        /** Constructor.  Please review this class' fields for documentation. */
517        public layerTreeDidChange(ReadOnlyList<Boolean> isPresent, Layer[] layers)
518        {
519            super(singleton, Domains.LayerTree, "layerTreeDidChange", 1);
520
521            this.layers = layers;
522
523            this.isPresent = (isPresent == null)
524                ? singleton.generateIsPresentList(this)
525                : THROWS.check(isPresent, 1, "LayerTree.layerTreeDidChange");
526        }
527
528        /** Creates an instance of this class from a {@link JsonObject}.*/
529        public static layerTreeDidChange fromJSON(JsonObject jo)
530        { return singleton.fromJSON(jo); }
531
532        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
533        public static NestedDescriptor<layerTreeDidChange> descriptor()
534        { return singleton.descriptor(); }
535    }
536
537
538
539
540    // ********************************************************************************************
541    // ********************************************************************************************
542    // Commands
543    // ********************************************************************************************
544    // ********************************************************************************************
545
546
547    /**
548     * Provides the reasons why the given layer was composited.
549     * 
550     * @param layerId The id of the layer for which we want to get the reasons it was composited.
551     * 
552     * @return An instance of <CODE>{@link Script}&lt;{@link compositingReasons$$RET}&gt;</CODE>
553     * 
554     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
555     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
556     * <CODE>&lt;{@link compositingReasons$$RET}&gt;</CODE> will be returned
557     *
558     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
559     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
560     * be retrieved.</I>
561     *
562     * <BR /><BR /><DIV CLASS=JDHint>
563     * This Browser Function's {@code Promise} returns:{@link compositingReasons$$RET}
564     * A dedicated return type implies that the browser may return more than 1 datum
565     * </DIV>
566     */
567    public static Script<compositingReasons$$RET> compositingReasons(String layerId)
568    {
569        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
570        final String requestJSON = WriteJSON.get
571            (CDPTypes.STRING, "layerId", false, "LayerTree.compositingReasons", layerId);
572
573        return new Script<>(
574            Domains.LayerTree, "compositingReasons", requestJSON,
575            compositingReasons$$RET::fromJSON,
576            compositingReasons$$RET.class
577        );
578    }
579
580    /**
581     * Disables compositing tree inspection.
582     * 
583     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
584     *
585     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
586     * browser receives the invocation-request.
587     *
588     * <BR /><BR /><DIV CLASS=JDHint>
589     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
590     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
591     * the Browser Function has run to completion.
592     * </DIV>
593     */
594    public static Script<Void> disable()
595    {
596        // Ultra-Simple Request JSON - Because this method has no parameters
597        final String requestJSON = "{\"method\":\"LayerTree.disable\"}";
598
599        return Script.NO_RET(Domains.LayerTree, "disable", requestJSON);
600    }
601
602    /**
603     * Enables compositing tree inspection.
604     * 
605     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
606     *
607     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
608     * browser receives the invocation-request.
609     *
610     * <BR /><BR /><DIV CLASS=JDHint>
611     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
612     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
613     * the Browser Function has run to completion.
614     * </DIV>
615     */
616    public static Script<Void> enable()
617    {
618        // Ultra-Simple Request JSON - Because this method has no parameters
619        final String requestJSON = "{\"method\":\"LayerTree.enable\"}";
620
621        return Script.NO_RET(Domains.LayerTree, "enable", requestJSON);
622    }
623
624    /**
625     * Returns the snapshot identifier.
626     * 
627     * @param tiles An array of tiles composing the snapshot.
628     * 
629     * @return An instance of <CODE>{@link Script}&lt;String&gt;</CODE>
630     * 
631     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
632     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
633     * <CODE>&lt;String&gt;</CODE> will be returned
634     *
635     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
636     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
637     * be retrieved.</I>
638     *
639     * <BR /><BR /><DIV CLASS=JDHint>
640     * This Browser Function's {@code Promise} returns:
641     * <CODE>String (<B>snapshotId</B>)</CODE>
642     * <BR />
643     * The id of the snapshot.
644     * </DIV>
645     */
646    public static Script<String> loadSnapshot(PictureTile[] tiles)
647    {
648        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
649        final String requestJSON = WriteJSON.get(
650            CDPTypes.CDP_TYPE_ARRAY_1D, "tiles", false, "LayerTree.loadSnapshot", (Object) tiles
651        );
652
653        return new Script<>(
654            Domains.LayerTree, "loadSnapshot", requestJSON,
655            jo -> ReadJSON.getString(jo, "snapshotId", true, false),
656            String.class
657        );
658    }
659
660    /**
661     * Returns the layer snapshot identifier.
662     * 
663     * @param layerId The id of the layer.
664     * 
665     * @return An instance of <CODE>{@link Script}&lt;String&gt;</CODE>
666     * 
667     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
668     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
669     * <CODE>&lt;String&gt;</CODE> will be returned
670     *
671     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
672     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
673     * be retrieved.</I>
674     *
675     * <BR /><BR /><DIV CLASS=JDHint>
676     * This Browser Function's {@code Promise} returns:
677     * <CODE>String (<B>snapshotId</B>)</CODE>
678     * <BR />
679     * The id of the layer snapshot.
680     * </DIV>
681     */
682    public static Script<String> makeSnapshot(String layerId)
683    {
684        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
685        final String requestJSON = WriteJSON.get
686            (CDPTypes.STRING, "layerId", false, "LayerTree.makeSnapshot", layerId);
687
688        return new Script<>(
689            Domains.LayerTree, "makeSnapshot", requestJSON,
690            jo -> ReadJSON.getString(jo, "snapshotId", true, false),
691            String.class
692        );
693    }
694
695    /**
696     * <CODE>[No Description Provided by Google]</CODE>
697     * 
698     * @param snapshotId The id of the layer snapshot.
699     * 
700     * @param minRepeatCount The maximum number of times to replay the snapshot (1, if not specified).
701     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
702     * 
703     * @param minDuration The minimum duration (in seconds) to replay the snapshot.
704     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
705     * 
706     * @param clipRect The clip rectangle to apply when replaying the snapshot.
707     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
708     * 
709     * @return An instance of <CODE>{@link Script}&lt;Number[]&gt;</CODE>
710     * 
711     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
712     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
713     * <CODE>&lt;Number[]&gt;</CODE> will be returned
714     *
715     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
716     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
717     * be retrieved.</I>
718     *
719     * <BR /><BR /><DIV CLASS=JDHint>
720     * This Browser Function's {@code Promise} returns:
721     * <CODE>Number[] (<B>timings</B>)</CODE>
722     * <BR />
723     * The array of paint profiles, one per run.
724     * </DIV>
725     */
726    public static Script<Number[]> profileSnapshot
727        (String snapshotId, Integer minRepeatCount, Number minDuration, DOM.Rect clipRect)
728    {
729        // Convert all Method Parameters into a JSON Request-Object (as a String)
730        final String requestJSON = WriteJSON.get(
731            LayerTree$$Commands.profileSnapshot$$, "LayerTree.profileSnapshot",
732            snapshotId, minRepeatCount, minDuration, clipRect
733        );
734
735        return new Script<>(
736            Domains.LayerTree, "profileSnapshot", requestJSON,
737            LayerTree$$Commands::profileSnapshot,
738            Number[].class
739        );
740    }
741
742    /**
743     * Releases layer snapshot captured by the back-end.
744     * 
745     * @param snapshotId The id of the layer snapshot.
746     * 
747     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
748     *
749     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
750     * browser receives the invocation-request.
751     *
752     * <BR /><BR /><DIV CLASS=JDHint>
753     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
754     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
755     * the Browser Function has run to completion.
756     * </DIV>
757     */
758    public static Script<Void> releaseSnapshot(String snapshotId)
759    {
760        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
761        final String requestJSON = WriteJSON.get
762            (CDPTypes.STRING, "snapshotId", false, "LayerTree.releaseSnapshot", snapshotId);
763
764        return Script.NO_RET(Domains.LayerTree, "releaseSnapshot", requestJSON);
765    }
766
767    /**
768     * Replays the layer snapshot and returns the resulting bitmap.
769     * 
770     * @param snapshotId The id of the layer snapshot.
771     * 
772     * @param fromStep The first step to replay from (replay from the very start if not specified).
773     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
774     * 
775     * @param toStep The last step to replay to (replay till the end if not specified).
776     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
777     * 
778     * @param scale The scale to apply while replaying (defaults to 1).
779     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
780     * 
781     * @return An instance of <CODE>{@link Script}&lt;String&gt;</CODE>
782     * 
783     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
784     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
785     * <CODE>&lt;String&gt;</CODE> will be returned
786     *
787     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
788     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
789     * be retrieved.</I>
790     *
791     * <BR /><BR /><DIV CLASS=JDHint>
792     * This Browser Function's {@code Promise} returns:
793     * <CODE>String (<B>dataURL</B>)</CODE>
794     * <BR />
795     * A data: URL for resulting image.
796     * </DIV>
797     */
798    public static Script<String> replaySnapshot
799        (String snapshotId, Integer fromStep, Integer toStep, Number scale)
800    {
801        // Convert all Method Parameters into a JSON Request-Object (as a String)
802        final String requestJSON = WriteJSON.get(
803            LayerTree$$Commands.replaySnapshot$$, "LayerTree.replaySnapshot",
804            snapshotId, fromStep, toStep, scale
805        );
806
807        return new Script<>(
808            Domains.LayerTree, "replaySnapshot", requestJSON,
809            jo -> ReadJSON.getString(jo, "dataURL", true, false),
810            String.class
811        );
812    }
813
814    /**
815     * Replays the layer snapshot and returns canvas log.
816     * 
817     * @param snapshotId The id of the layer snapshot.
818     * 
819     * @return An instance of <CODE>{@link Script}&lt;JsonValue&gt;</CODE>
820     * 
821     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
822     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
823     * <CODE>&lt;JsonValue&gt;</CODE> will be returned
824     *
825     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
826     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
827     * be retrieved.</I>
828     *
829     * <BR /><BR /><DIV CLASS=JDHint>
830     * This Browser Function's {@code Promise} returns:
831     * <CODE>JsonValue (<B>commandLog</B>)</CODE>
832     * <BR />
833     * The array of canvas function calls.
834     * </DIV>
835     */
836    public static Script<JsonValue> snapshotCommandLog(String snapshotId)
837    {
838        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
839        final String requestJSON = WriteJSON.get
840            (CDPTypes.STRING, "snapshotId", false, "LayerTree.snapshotCommandLog", snapshotId);
841
842        return new Script<>(
843            Domains.LayerTree, "snapshotCommandLog", requestJSON,
844            jo -> jo.get("commandLog"),
845            JsonValue.class
846        );
847    }
848
849
850}