lib/selenium/devtools/v136/overlay.rb



# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The SFC licenses this file
# to you 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.

# This file is automatically generated. Any changes will be lost!
module Selenium
  module DevTools
    module V136
      class Overlay
        EVENTS = {
          inspect_node_requested: 'inspectNodeRequested',
          node_highlight_requested: 'nodeHighlightRequested',
          screenshot_requested: 'screenshotRequested',
          inspect_mode_canceled: 'inspectModeCanceled',
        }.freeze

        def initialize(devtools)
          @devtools = devtools
        end

        def on(event, &block)
          event = EVENTS[event] if event.is_a?(Symbol)
          @devtools.callbacks["Overlay.#{event}"] << block
        end

        def disable
          @devtools.send_cmd('Overlay.disable')
        end

        def enable
          @devtools.send_cmd('Overlay.enable')
        end

        def get_highlight_object_for_test(node_id:, include_distance: nil, include_style: nil, color_format: nil, show_accessibility_info: nil)
          @devtools.send_cmd('Overlay.getHighlightObjectForTest',
                             nodeId: node_id,
                             includeDistance: include_distance,
                             includeStyle: include_style,
                             colorFormat: color_format,
                             showAccessibilityInfo: show_accessibility_info)
        end

        def get_grid_highlight_objects_for_test(node_ids:)
          @devtools.send_cmd('Overlay.getGridHighlightObjectsForTest',
                             nodeIds: node_ids)
        end

        def get_source_order_highlight_object_for_test(node_id:)
          @devtools.send_cmd('Overlay.getSourceOrderHighlightObjectForTest',
                             nodeId: node_id)
        end

        def hide_highlight
          @devtools.send_cmd('Overlay.hideHighlight')
        end

        def highlight_frame(frame_id:, content_color: nil, content_outline_color: nil)
          @devtools.send_cmd('Overlay.highlightFrame',
                             frameId: frame_id,
                             contentColor: content_color,
                             contentOutlineColor: content_outline_color)
        end

        def highlight_node(highlight_config:, node_id: nil, backend_node_id: nil, object_id: nil, selector: nil)
          @devtools.send_cmd('Overlay.highlightNode',
                             highlightConfig: highlight_config,
                             nodeId: node_id,
                             backendNodeId: backend_node_id,
                             objectId: object_id,
                             selector: selector)
        end

        def highlight_quad(quad:, color: nil, outline_color: nil)
          @devtools.send_cmd('Overlay.highlightQuad',
                             quad: quad,
                             color: color,
                             outlineColor: outline_color)
        end

        def highlight_rect(x:, y:, width:, height:, color: nil, outline_color: nil)
          @devtools.send_cmd('Overlay.highlightRect',
                             x: x,
                             y: y,
                             width: width,
                             height: height,
                             color: color,
                             outlineColor: outline_color)
        end

        def highlight_source_order(source_order_config:, node_id: nil, backend_node_id: nil, object_id: nil)
          @devtools.send_cmd('Overlay.highlightSourceOrder',
                             sourceOrderConfig: source_order_config,
                             nodeId: node_id,
                             backendNodeId: backend_node_id,
                             objectId: object_id)
        end

        def set_inspect_mode(mode:, highlight_config: nil)
          @devtools.send_cmd('Overlay.setInspectMode',
                             mode: mode,
                             highlightConfig: highlight_config)
        end

        def set_show_ad_highlights(show:)
          @devtools.send_cmd('Overlay.setShowAdHighlights',
                             show: show)
        end

        def set_paused_in_debugger_message(message: nil)
          @devtools.send_cmd('Overlay.setPausedInDebuggerMessage',
                             message: message)
        end

        def set_show_debug_borders(show:)
          @devtools.send_cmd('Overlay.setShowDebugBorders',
                             show: show)
        end

        def set_show_fps_counter(show:)
          @devtools.send_cmd('Overlay.setShowFPSCounter',
                             show: show)
        end

        def set_show_grid_overlays(grid_node_highlight_configs:)
          @devtools.send_cmd('Overlay.setShowGridOverlays',
                             gridNodeHighlightConfigs: grid_node_highlight_configs)
        end

        def set_show_flex_overlays(flex_node_highlight_configs:)
          @devtools.send_cmd('Overlay.setShowFlexOverlays',
                             flexNodeHighlightConfigs: flex_node_highlight_configs)
        end

        def set_show_scroll_snap_overlays(scroll_snap_highlight_configs:)
          @devtools.send_cmd('Overlay.setShowScrollSnapOverlays',
                             scrollSnapHighlightConfigs: scroll_snap_highlight_configs)
        end

        def set_show_container_query_overlays(container_query_highlight_configs:)
          @devtools.send_cmd('Overlay.setShowContainerQueryOverlays',
                             containerQueryHighlightConfigs: container_query_highlight_configs)
        end

        def set_show_paint_rects(result:)
          @devtools.send_cmd('Overlay.setShowPaintRects',
                             result: result)
        end

        def set_show_layout_shift_regions(result:)
          @devtools.send_cmd('Overlay.setShowLayoutShiftRegions',
                             result: result)
        end

        def set_show_scroll_bottleneck_rects(show:)
          @devtools.send_cmd('Overlay.setShowScrollBottleneckRects',
                             show: show)
        end

        def set_show_hit_test_borders(show:)
          @devtools.send_cmd('Overlay.setShowHitTestBorders',
                             show: show)
        end

        def set_show_web_vitals(show:)
          @devtools.send_cmd('Overlay.setShowWebVitals',
                             show: show)
        end

        def set_show_viewport_size_on_resize(show:)
          @devtools.send_cmd('Overlay.setShowViewportSizeOnResize',
                             show: show)
        end

        def set_show_hinge(hinge_config: nil)
          @devtools.send_cmd('Overlay.setShowHinge',
                             hingeConfig: hinge_config)
        end

        def set_show_isolated_elements(isolated_element_highlight_configs:)
          @devtools.send_cmd('Overlay.setShowIsolatedElements',
                             isolatedElementHighlightConfigs: isolated_element_highlight_configs)
        end

        def set_show_window_controls_overlay(window_controls_overlay_config: nil)
          @devtools.send_cmd('Overlay.setShowWindowControlsOverlay',
                             windowControlsOverlayConfig: window_controls_overlay_config)
        end

      end # Overlay
    end # V136
  end # DevTools
end # Selenium