#include "third_party/blink/renderer/core/inspector/inspector_overlay_agent.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "build/build_config.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/picture_layer.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_data.h"
#include "third_party/blink/public/resources/grit/inspector_overlay_resources_map.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_evaluation_result.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_inspector_overlay_host.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_utilities.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/static_node_list.h"
#include "third_party/blink/renderer/core/events/web_input_event_conversion.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/frame/frame_overlay.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/root_frame_viewport.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_frame_widget_impl.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/inspector/identifiers_factory.h"
#include "third_party/blink/renderer/core/inspector/inspect_tools.h"
#include "third_party/blink/renderer/core/inspector/inspected_frames.h"
#include "third_party/blink/renderer/core/inspector/inspector_css_agent.h"
#include "third_party/blink/renderer/core/inspector/inspector_dom_agent.h"
#include "third_party/blink/renderer/core/inspector/inspector_overlay_host.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/loader/frame_load_request.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
#include "third_party/blink/renderer/platform/data_resource_helper.h"
#include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/cull_rect.h"
#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h"
#include "third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/keyboard_codes.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/inspector_protocol/crdtp/json.h"
#include "ui/accessibility/ax_mode.h"
#include "v8/include/v8.h"
SpanFrom;
ConvertCBORToJSON;
namespace blink {
Maybe;
namespace {
bool ParseQuad(std::unique_ptr<protocol::Array<double>> quad_array,
gfx::QuadF* quad) { … }
v8::MaybeLocal<v8::Value> GetV8Property(v8::Local<v8::Context> context,
v8::Local<v8::Value> object,
const String& name) { … }
Color ParseColor(protocol::DOM::RGBA* rgba) { … }
}
const char* OverlayNames::OVERLAY_HIGHLIGHT = …;
const char* OverlayNames::OVERLAY_PERSISTENT = …;
const char* OverlayNames::OVERLAY_SOURCE_ORDER = …;
const char* OverlayNames::OVERLAY_DISTANCES = …;
const char* OverlayNames::OVERLAY_VIEWPORT_SIZE = …;
const char* OverlayNames::OVERLAY_SCREENSHOT = …;
const char* OverlayNames::OVERLAY_PAUSED = …;
const char* OverlayNames::OVERLAY_WINDOW_CONTROLS_OVERLAY = …;
bool InspectTool::HandleInputEvent(LocalFrameView* frame_view,
const WebInputEvent& input_event,
bool* swallow_next_mouse_up) { … }
bool InspectTool::HandleMouseEvent(const WebMouseEvent& mouse_event,
bool* swallow_next_mouse_up) { … }
bool InspectTool::HandleMouseDown(const WebMouseEvent&,
bool* swallow_next_mouse_up) { … }
bool InspectTool::HandleMouseUp(const WebMouseEvent&) { … }
bool InspectTool::HandleMouseMove(const WebMouseEvent&) { … }
bool InspectTool::HandleGestureTapEvent(const WebGestureEvent&) { … }
bool InspectTool::HandlePointerEvent(const WebPointerEvent&) { … }
bool InspectTool::HandleKeyboardEvent(const WebKeyboardEvent&) { … }
bool InspectTool::ForwardEventsToOverlay() { … }
bool InspectTool::SupportsPersistentOverlays() { … }
bool InspectTool::HideOnMouseMove() { … }
bool InspectTool::HideOnHideHighlight() { … }
void InspectTool::Trace(Visitor* visitor) const { … }
Hinge::Hinge(gfx::QuadF quad,
Color content_color,
Color outline_color,
InspectorOverlayAgent* overlay)
: … { … }
String Hinge::GetOverlayName() { … }
void Hinge::Trace(Visitor* visitor) const { … }
void Hinge::Draw(float scale) { … }
class InspectorOverlayAgent::InspectorPageOverlayDelegate final
: public FrameOverlay::Delegate,
public cc::ContentLayerClient { … };
class InspectorOverlayAgent::InspectorOverlayChromeClient final
: public EmptyChromeClient { … };
InspectorOverlayAgent::InspectorOverlayAgent(
WebLocalFrameImpl* frame_impl,
InspectedFrames* inspected_frames,
v8_inspector::V8InspectorSession* v8_session,
InspectorDOMAgent* dom_agent)
: … { … }
InspectorOverlayAgent::~InspectorOverlayAgent() { … }
void InspectorOverlayAgent::Trace(Visitor* visitor) const { … }
void InspectorOverlayAgent::Restore() { … }
void InspectorOverlayAgent::Dispose() { … }
protocol::Response InspectorOverlayAgent::enable() { … }
bool InspectorOverlayAgent::HasAXContext(Node* node) { … }
void InspectorOverlayAgent::EnsureAXContext(Node* node) { … }
void InspectorOverlayAgent::EnsureAXContext(Document& document) { … }
protocol::Response InspectorOverlayAgent::disable() { … }
protocol::Response InspectorOverlayAgent::setShowAdHighlights(bool show) { … }
protocol::Response InspectorOverlayAgent::setShowDebugBorders(bool show) { … }
protocol::Response InspectorOverlayAgent::setShowFPSCounter(bool show) { … }
protocol::Response InspectorOverlayAgent::setShowPaintRects(bool show) { … }
protocol::Response InspectorOverlayAgent::setShowLayoutShiftRegions(bool show) { … }
protocol::Response InspectorOverlayAgent::setShowScrollBottleneckRects(
bool show) { … }
protocol::Response InspectorOverlayAgent::setShowHitTestBorders(bool show) { … }
protocol::Response InspectorOverlayAgent::setShowViewportSizeOnResize(
bool show) { … }
protocol::Response InspectorOverlayAgent::setShowWebVitals(bool show) { … }
protocol::Response InspectorOverlayAgent::setShowWindowControlsOverlay(
protocol::Maybe<protocol::Overlay::WindowControlsOverlayConfig>
wco_config) { … }
protocol::Response InspectorOverlayAgent::setPausedInDebuggerMessage(
Maybe<String> message) { … }
protocol::Response InspectorOverlayAgent::highlightRect(
int x,
int y,
int width,
int height,
Maybe<protocol::DOM::RGBA> color,
Maybe<protocol::DOM::RGBA> outline_color) { … }
protocol::Response InspectorOverlayAgent::highlightQuad(
std::unique_ptr<protocol::Array<double>> quad_array,
Maybe<protocol::DOM::RGBA> color,
Maybe<protocol::DOM::RGBA> outline_color) { … }
protocol::Response InspectorOverlayAgent::setShowHinge(
protocol::Maybe<protocol::Overlay::HingeConfig> tool_config) { … }
protocol::Response InspectorOverlayAgent::highlightNode(
std::unique_ptr<protocol::Overlay::HighlightConfig>
highlight_inspector_object,
Maybe<int> node_id,
Maybe<int> backend_node_id,
Maybe<String> object_id,
Maybe<String> selector_list) { … }
protocol::Response InspectorOverlayAgent::setShowGridOverlays(
std::unique_ptr<protocol::Array<protocol::Overlay::GridNodeHighlightConfig>>
grid_node_highlight_configs) { … }
protocol::Response InspectorOverlayAgent::setShowFlexOverlays(
std::unique_ptr<protocol::Array<protocol::Overlay::FlexNodeHighlightConfig>>
flex_node_highlight_configs) { … }
protocol::Response InspectorOverlayAgent::setShowScrollSnapOverlays(
std::unique_ptr<
protocol::Array<protocol::Overlay::ScrollSnapHighlightConfig>>
scroll_snap_highlight_configs) { … }
protocol::Response InspectorOverlayAgent::setShowContainerQueryOverlays(
std::unique_ptr<
protocol::Array<protocol::Overlay::ContainerQueryHighlightConfig>>
container_query_highlight_configs) { … }
protocol::Response InspectorOverlayAgent::setShowIsolatedElements(
std::unique_ptr<
protocol::Array<protocol::Overlay::IsolatedElementHighlightConfig>>
isolated_element_highlight_configs) { … }
protocol::Response InspectorOverlayAgent::highlightSourceOrder(
std::unique_ptr<protocol::Overlay::SourceOrderConfig>
source_order_inspector_object,
Maybe<int> node_id,
Maybe<int> backend_node_id,
Maybe<String> object_id) { … }
protocol::Response InspectorOverlayAgent::highlightFrame(
const String& frame_id,
Maybe<protocol::DOM::RGBA> color,
Maybe<protocol::DOM::RGBA> outline_color) { … }
protocol::Response InspectorOverlayAgent::hideHighlight() { … }
protocol::Response InspectorOverlayAgent::getHighlightObjectForTest(
int node_id,
Maybe<bool> include_distance,
Maybe<bool> include_style,
Maybe<String> colorFormat,
Maybe<bool> show_accessibility_info,
std::unique_ptr<protocol::DictionaryValue>* result) { … }
protocol::Response InspectorOverlayAgent::getGridHighlightObjectsForTest(
std::unique_ptr<protocol::Array<int>> node_ids,
std::unique_ptr<protocol::DictionaryValue>* highlights) { … }
protocol::Response InspectorOverlayAgent::getSourceOrderHighlightObjectForTest(
int node_id,
std::unique_ptr<protocol::DictionaryValue>* result) { … }
void InspectorOverlayAgent::UpdatePrePaint() { … }
void InspectorOverlayAgent::PaintOverlay(GraphicsContext& context) { … }
bool InspectorOverlayAgent::IsInspectorLayer(const cc::Layer* layer) const { … }
LocalFrame* InspectorOverlayAgent::GetFrame() const { … }
void InspectorOverlayAgent::DispatchBufferedTouchEvents() { … }
void InspectorOverlayAgent::SetPageIsScrolling(bool is_scrolling) { … }
WebInputEventResult InspectorOverlayAgent::HandleInputEvent(
const WebInputEvent& input_event) { … }
WebInputEventResult InspectorOverlayAgent::HandleInputEventInOverlay(
const WebInputEvent& input_event) { … }
void InspectorOverlayAgent::ScheduleUpdate() { … }
void InspectorOverlayAgent::PaintOverlayPage() { … }
float InspectorOverlayAgent::EmulationScaleFactor() const { … }
void InspectorOverlayAgent::DidInitializeFrameWidget() { … }
bool InspectorOverlayAgent::FrameWidgetInitialized() const { … }
static std::unique_ptr<protocol::DictionaryValue> BuildObjectForSize(
const gfx::Size& size) { … }
static std::unique_ptr<protocol::DictionaryValue> BuildObjectForSize(
const gfx::SizeF& size) { … }
float InspectorOverlayAgent::WindowToViewportScale() const { … }
void InspectorOverlayAgent::LoadOverlayPageResource() { … }
LocalFrame* InspectorOverlayAgent::OverlayMainFrame() { … }
void InspectorOverlayAgent::Reset(
const gfx::Size& viewport_size,
const gfx::SizeF& viewport_size_for_media_queries) { … }
void InspectorOverlayAgent::EvaluateInOverlay(const String& method,
const String& argument) { … }
void InspectorOverlayAgent::EvaluateInOverlay(
const String& method,
std::unique_ptr<protocol::Value> argument) { … }
String InspectorOverlayAgent::EvaluateInOverlayForTest(const String& script) { … }
void InspectorOverlayAgent::OnResizeTimer(TimerBase*) { … }
void InspectorOverlayAgent::Dispatch(const ScriptValue& message,
ExceptionState& exception_state) { … }
void InspectorOverlayAgent::PageLayoutInvalidated(bool resized) { … }
protocol::Response InspectorOverlayAgent::CompositingEnabled() { … }
bool InspectorOverlayAgent::InSomeInspectMode() { … }
void InspectorOverlayAgent::Inspect(Node* inspected_node) { … }
protocol::Response InspectorOverlayAgent::setInspectMode(
const String& mode,
Maybe<protocol::Overlay::HighlightConfig> highlight_inspector_object) { … }
void InspectorOverlayAgent::PickTheRightTool() { … }
void InspectorOverlayAgent::DisableFrameOverlay() { … }
void InspectorOverlayAgent::EnsureEnableFrameOverlay() { … }
void InspectorOverlayAgent::ClearInspectTool() { … }
protocol::Response InspectorOverlayAgent::SetInspectTool(
InspectTool* inspect_tool) { … }
InspectorSourceOrderConfig
InspectorOverlayAgent::SourceOrderConfigFromInspectorObject(
std::unique_ptr<protocol::Overlay::SourceOrderConfig>
source_order_inspector_object) { … }
protocol::Response InspectorOverlayAgent::HighlightConfigFromInspectorObject(
Maybe<protocol::Overlay::HighlightConfig> highlight_inspector_object,
std::unique_ptr<InspectorHighlightConfig>* out_config) { … }
std::unique_ptr<InspectorGridHighlightConfig>
InspectorOverlayAgent::ToGridHighlightConfig(
protocol::Overlay::GridHighlightConfig* config) { … }
std::unique_ptr<InspectorFlexContainerHighlightConfig>
InspectorOverlayAgent::ToFlexContainerHighlightConfig(
protocol::Overlay::FlexContainerHighlightConfig* config) { … }
std::unique_ptr<InspectorScrollSnapContainerHighlightConfig>
InspectorOverlayAgent::ToScrollSnapContainerHighlightConfig(
protocol::Overlay::ScrollSnapContainerHighlightConfig* config) { … }
std::unique_ptr<InspectorContainerQueryContainerHighlightConfig>
InspectorOverlayAgent::ToContainerQueryContainerHighlightConfig(
protocol::Overlay::ContainerQueryContainerHighlightConfig* config) { … }
std::unique_ptr<InspectorFlexItemHighlightConfig>
InspectorOverlayAgent::ToFlexItemHighlightConfig(
protocol::Overlay::FlexItemHighlightConfig* config) { … }
std::unique_ptr<InspectorIsolationModeHighlightConfig>
InspectorOverlayAgent::ToIsolationModeHighlightConfig(
protocol::Overlay::IsolationModeHighlightConfig* config,
int idx) { … }
std::optional<LineStyle> InspectorOverlayAgent::ToLineStyle(
protocol::Overlay::LineStyle* config) { … }
std::optional<BoxStyle> InspectorOverlayAgent::ToBoxStyle(
protocol::Overlay::BoxStyle* config) { … }
ContrastAlgorithm GetContrastAlgorithm(const String& contrast_algorithm) { … }
std::unique_ptr<InspectorHighlightConfig>
InspectorOverlayAgent::ToHighlightConfig(
protocol::Overlay::HighlightConfig* config) { … }
void InspectorOverlayAgent::SetNeedsUnbufferedInput(bool unbuffered) { … }
}