All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.kklisura.cdt.protocol.commands.Overlay Maven / Gradle / Ivy

The newest version!
package com.github.kklisura.cdt.protocol.commands;

/*-
 * #%L
 * cdt-java-client
 * %%
 * Copyright (C) 2018 - 2021 Kenan Klisura
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import com.github.kklisura.cdt.protocol.events.overlay.InspectModeCanceled;
import com.github.kklisura.cdt.protocol.events.overlay.InspectNodeRequested;
import com.github.kklisura.cdt.protocol.events.overlay.NodeHighlightRequested;
import com.github.kklisura.cdt.protocol.events.overlay.ScreenshotRequested;
import com.github.kklisura.cdt.protocol.support.annotations.EventName;
import com.github.kklisura.cdt.protocol.support.annotations.Experimental;
import com.github.kklisura.cdt.protocol.support.annotations.Optional;
import com.github.kklisura.cdt.protocol.support.annotations.ParamName;
import com.github.kklisura.cdt.protocol.support.annotations.Returns;
import com.github.kklisura.cdt.protocol.support.types.EventHandler;
import com.github.kklisura.cdt.protocol.support.types.EventListener;
import com.github.kklisura.cdt.protocol.types.dom.RGBA;
import com.github.kklisura.cdt.protocol.types.overlay.ColorFormat;
import com.github.kklisura.cdt.protocol.types.overlay.FlexNodeHighlightConfig;
import com.github.kklisura.cdt.protocol.types.overlay.GridNodeHighlightConfig;
import com.github.kklisura.cdt.protocol.types.overlay.HighlightConfig;
import com.github.kklisura.cdt.protocol.types.overlay.HingeConfig;
import com.github.kklisura.cdt.protocol.types.overlay.InspectMode;
import com.github.kklisura.cdt.protocol.types.overlay.ScrollSnapHighlightConfig;
import com.github.kklisura.cdt.protocol.types.overlay.SourceOrderConfig;
import java.util.List;
import java.util.Map;

/** This domain provides various functionality related to drawing atop the inspected page. */
@Experimental
public interface Overlay {

  /** Disables domain notifications. */
  void disable();

  /** Enables domain notifications. */
  void enable();

  /**
   * For testing.
   *
   * @param nodeId Id of the node to get highlight object for.
   */
  @Returns("highlight")
  Map getHighlightObjectForTest(@ParamName("nodeId") Integer nodeId);

  /**
   * For testing.
   *
   * @param nodeId Id of the node to get highlight object for.
   * @param includeDistance Whether to include distance info.
   * @param includeStyle Whether to include style info.
   * @param colorFormat The color format to get config with (default: hex).
   * @param showAccessibilityInfo Whether to show accessibility info (default: true).
   */
  @Returns("highlight")
  Map getHighlightObjectForTest(
      @ParamName("nodeId") Integer nodeId,
      @Optional @ParamName("includeDistance") Boolean includeDistance,
      @Optional @ParamName("includeStyle") Boolean includeStyle,
      @Optional @ParamName("colorFormat") ColorFormat colorFormat,
      @Optional @ParamName("showAccessibilityInfo") Boolean showAccessibilityInfo);

  /**
   * For Persistent Grid testing.
   *
   * @param nodeIds Ids of the node to get highlight object for.
   */
  @Returns("highlights")
  Map getGridHighlightObjectsForTest(@ParamName("nodeIds") List nodeIds);

  /**
   * For Source Order Viewer testing.
   *
   * @param nodeId Id of the node to highlight.
   */
  @Returns("highlight")
  Map getSourceOrderHighlightObjectForTest(@ParamName("nodeId") Integer nodeId);

  /** Hides any highlight. */
  void hideHighlight();

  /**
   * Highlights owner element of the frame with given id.
   *
   * @param frameId Identifier of the frame to highlight.
   */
  void highlightFrame(@ParamName("frameId") String frameId);

  /**
   * Highlights owner element of the frame with given id.
   *
   * @param frameId Identifier of the frame to highlight.
   * @param contentColor The content box highlight fill color (default: transparent).
   * @param contentOutlineColor The content box highlight outline color (default: transparent).
   */
  void highlightFrame(
      @ParamName("frameId") String frameId,
      @Optional @ParamName("contentColor") RGBA contentColor,
      @Optional @ParamName("contentOutlineColor") RGBA contentOutlineColor);

  /**
   * Highlights DOM node with given id or with the given JavaScript object wrapper. Either nodeId or
   * objectId must be specified.
   *
   * @param highlightConfig A descriptor for the highlight appearance.
   */
  void highlightNode(@ParamName("highlightConfig") HighlightConfig highlightConfig);

  /**
   * Highlights DOM node with given id or with the given JavaScript object wrapper. Either nodeId or
   * objectId must be specified.
   *
   * @param highlightConfig A descriptor for the highlight appearance.
   * @param nodeId Identifier of the node to highlight.
   * @param backendNodeId Identifier of the backend node to highlight.
   * @param objectId JavaScript object id of the node to be highlighted.
   * @param selector Selectors to highlight relevant nodes.
   */
  void highlightNode(
      @ParamName("highlightConfig") HighlightConfig highlightConfig,
      @Optional @ParamName("nodeId") Integer nodeId,
      @Optional @ParamName("backendNodeId") Integer backendNodeId,
      @Optional @ParamName("objectId") String objectId,
      @Optional @ParamName("selector") String selector);

  /**
   * Highlights given quad. Coordinates are absolute with respect to the main frame viewport.
   *
   * @param quad Quad to highlight
   */
  void highlightQuad(@ParamName("quad") List quad);

  /**
   * Highlights given quad. Coordinates are absolute with respect to the main frame viewport.
   *
   * @param quad Quad to highlight
   * @param color The highlight fill color (default: transparent).
   * @param outlineColor The highlight outline color (default: transparent).
   */
  void highlightQuad(
      @ParamName("quad") List quad,
      @Optional @ParamName("color") RGBA color,
      @Optional @ParamName("outlineColor") RGBA outlineColor);

  /**
   * Highlights given rectangle. Coordinates are absolute with respect to the main frame viewport.
   *
   * @param x X coordinate
   * @param y Y coordinate
   * @param width Rectangle width
   * @param height Rectangle height
   */
  void highlightRect(
      @ParamName("x") Integer x,
      @ParamName("y") Integer y,
      @ParamName("width") Integer width,
      @ParamName("height") Integer height);

  /**
   * Highlights given rectangle. Coordinates are absolute with respect to the main frame viewport.
   *
   * @param x X coordinate
   * @param y Y coordinate
   * @param width Rectangle width
   * @param height Rectangle height
   * @param color The highlight fill color (default: transparent).
   * @param outlineColor The highlight outline color (default: transparent).
   */
  void highlightRect(
      @ParamName("x") Integer x,
      @ParamName("y") Integer y,
      @ParamName("width") Integer width,
      @ParamName("height") Integer height,
      @Optional @ParamName("color") RGBA color,
      @Optional @ParamName("outlineColor") RGBA outlineColor);

  /**
   * Highlights the source order of the children of the DOM node with given id or with the given
   * JavaScript object wrapper. Either nodeId or objectId must be specified.
   *
   * @param sourceOrderConfig A descriptor for the appearance of the overlay drawing.
   */
  void highlightSourceOrder(@ParamName("sourceOrderConfig") SourceOrderConfig sourceOrderConfig);

  /**
   * Highlights the source order of the children of the DOM node with given id or with the given
   * JavaScript object wrapper. Either nodeId or objectId must be specified.
   *
   * @param sourceOrderConfig A descriptor for the appearance of the overlay drawing.
   * @param nodeId Identifier of the node to highlight.
   * @param backendNodeId Identifier of the backend node to highlight.
   * @param objectId JavaScript object id of the node to be highlighted.
   */
  void highlightSourceOrder(
      @ParamName("sourceOrderConfig") SourceOrderConfig sourceOrderConfig,
      @Optional @ParamName("nodeId") Integer nodeId,
      @Optional @ParamName("backendNodeId") Integer backendNodeId,
      @Optional @ParamName("objectId") String objectId);

  /**
   * Enters the 'inspect' mode. In this mode, elements that user is hovering over are highlighted.
   * Backend then generates 'inspectNodeRequested' event upon element selection.
   *
   * @param mode Set an inspection mode.
   */
  void setInspectMode(@ParamName("mode") InspectMode mode);

  /**
   * Enters the 'inspect' mode. In this mode, elements that user is hovering over are highlighted.
   * Backend then generates 'inspectNodeRequested' event upon element selection.
   *
   * @param mode Set an inspection mode.
   * @param highlightConfig A descriptor for the highlight appearance of hovered-over nodes. May be
   *     omitted if `enabled == false`.
   */
  void setInspectMode(
      @ParamName("mode") InspectMode mode,
      @Optional @ParamName("highlightConfig") HighlightConfig highlightConfig);

  /**
   * Highlights owner element of all frames detected to be ads.
   *
   * @param show True for showing ad highlights
   */
  void setShowAdHighlights(@ParamName("show") Boolean show);

  void setPausedInDebuggerMessage();

  /** @param message The message to display, also triggers resume and step over controls. */
  void setPausedInDebuggerMessage(@Optional @ParamName("message") String message);

  /**
   * Requests that backend shows debug borders on layers
   *
   * @param show True for showing debug borders
   */
  void setShowDebugBorders(@ParamName("show") Boolean show);

  /**
   * Requests that backend shows the FPS counter
   *
   * @param show True for showing the FPS counter
   */
  void setShowFPSCounter(@ParamName("show") Boolean show);

  /**
   * Highlight multiple elements with the CSS Grid overlay.
   *
   * @param gridNodeHighlightConfigs An array of node identifiers and descriptors for the highlight
   *     appearance.
   */
  void setShowGridOverlays(
      @ParamName("gridNodeHighlightConfigs")
          List gridNodeHighlightConfigs);

  /**
   * @param flexNodeHighlightConfigs An array of node identifiers and descriptors for the highlight
   *     appearance.
   */
  void setShowFlexOverlays(
      @ParamName("flexNodeHighlightConfigs")
          List flexNodeHighlightConfigs);

  /**
   * @param scrollSnapHighlightConfigs An array of node identifiers and descriptors for the
   *     highlight appearance.
   */
  void setShowScrollSnapOverlays(
      @ParamName("scrollSnapHighlightConfigs")
          List scrollSnapHighlightConfigs);

  /**
   * Requests that backend shows paint rectangles
   *
   * @param result True for showing paint rectangles
   */
  void setShowPaintRects(@ParamName("result") Boolean result);

  /**
   * Requests that backend shows layout shift regions
   *
   * @param result True for showing layout shift regions
   */
  void setShowLayoutShiftRegions(@ParamName("result") Boolean result);

  /**
   * Requests that backend shows scroll bottleneck rects
   *
   * @param show True for showing scroll bottleneck rects
   */
  void setShowScrollBottleneckRects(@ParamName("show") Boolean show);

  /**
   * Requests that backend shows hit-test borders on layers
   *
   * @param show True for showing hit-test borders
   */
  void setShowHitTestBorders(@ParamName("show") Boolean show);

  /**
   * Request that backend shows an overlay with web vital metrics.
   *
   * @param show
   */
  void setShowWebVitals(@ParamName("show") Boolean show);

  /**
   * Paints viewport size upon main frame resize.
   *
   * @param show Whether to paint size or not.
   */
  void setShowViewportSizeOnResize(@ParamName("show") Boolean show);

  /** Add a dual screen device hinge */
  void setShowHinge();

  /**
   * Add a dual screen device hinge
   *
   * @param hingeConfig hinge data, null means hideHinge
   */
  void setShowHinge(@Optional @ParamName("hingeConfig") HingeConfig hingeConfig);

  /**
   * Fired when the node should be inspected. This happens after call to `setInspectMode` or when
   * user manually inspects an element.
   */
  @EventName("inspectNodeRequested")
  EventListener onInspectNodeRequested(EventHandler eventListener);

  /** Fired when the node should be highlighted. This happens after call to `setInspectMode`. */
  @EventName("nodeHighlightRequested")
  EventListener onNodeHighlightRequested(EventHandler eventListener);

  /** Fired when user asks to capture screenshot of some area on the page. */
  @EventName("screenshotRequested")
  EventListener onScreenshotRequested(EventHandler eventListener);

  /** Fired when user cancels the inspect mode. */
  @EventName("inspectModeCanceled")
  EventListener onInspectModeCanceled(EventHandler eventListener);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy