#include "third_party/blink/renderer/core/inspector/inspector_highlight.h"
#include <memory>
#include "third_party/blink/renderer/core/css/css_color.h"
#include "third_party/blink/renderer/core/css/css_computed_style_declaration.h"
#include "third_party/blink/renderer/core/css/css_grid_auto_repeat_value.h"
#include "third_party/blink/renderer/core/css/css_grid_integer_repeat_value.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_property_name.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_value.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver.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/pseudo_element.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/inspector/dom_traversal_utils.h"
#include "third_party/blink/renderer/core/inspector/inspector_dom_agent.h"
#include "third_party/blink/renderer/core/inspector/node_content_visibility_state.h"
#include "third_party/blink/renderer/core/inspector/protocol/overlay.h"
#include "third_party/blink/renderer/core/layout/adjust_for_absolute_zoom.h"
#include "third_party/blink/renderer/core/layout/flex/devtools_flex_info.h"
#include "third_party/blink/renderer/core/layout/flex/layout_flexible_box.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_offset.h"
#include "third_party/blink/renderer/core/layout/grid/layout_grid.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/logical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/physical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/shapes/shape_outside_info.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/style/computed_style_constants.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
#include "third_party/blink/renderer/platform/graphics/path.h"
#include "third_party/blink/renderer/platform/text/writing_mode.h"
#include "third_party/blink/renderer/platform/web_test_support.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect_f.h"
namespace blink {
namespace {
class PathBuilder { … };
void PathBuilder::AppendPathCommandAndPoints(
const char* command,
base::span<const gfx::PointF> points) { … }
void PathBuilder::AppendPathElement(const PathElement& path_element) { … }
class ShapePathBuilder : public PathBuilder { … };
std::unique_ptr<protocol::Array<double>> BuildArrayForQuad(
const gfx::QuadF& quad) { … }
Path QuadToPath(const gfx::QuadF& quad) { … }
Path RowQuadToPath(const gfx::QuadF& quad, bool draw_end_line) { … }
Path ColumnQuadToPath(const gfx::QuadF& quad, bool draw_end_line) { … }
gfx::PointF FramePointToViewport(const LocalFrameView* view,
gfx::PointF point_in_frame) { … }
float PageScaleFromFrameView(const LocalFrameView* frame_view) { … }
float DeviceScaleFromFrameView(const LocalFrameView* frame_view) { … }
void FrameQuadToViewport(const LocalFrameView* view, gfx::QuadF& quad) { … }
const ShapeOutsideInfo* ShapeOutsideInfoForNode(Node* node,
Shape::DisplayPaths* paths,
gfx::QuadF* bounds) { … }
String ToHEXA(const Color& color) { … }
std::unique_ptr<protocol::ListValue> ToRGBAList(const Color& color) { … }
ContrastAlgorithmEnum;
String ContrastAlgorithmToString(const ContrastAlgorithm& contrast_algorithm) { … }
}
void AppendStyleInfo(Element* element,
protocol::DictionaryValue* element_info,
const InspectorHighlightContrastInfo& node_contrast,
const ContrastAlgorithm& contrast_algorithm) { … }
std::unique_ptr<protocol::DictionaryValue> BuildElementInfo(Element* element) { … }
namespace {
std::unique_ptr<protocol::DictionaryValue> BuildTextNodeInfo(Text* text_node) { … }
void AppendLineStyleConfig(
const std::optional<LineStyle>& line_style,
std::unique_ptr<protocol::DictionaryValue>& parent_config,
String line_name) { … }
void AppendBoxStyleConfig(
const std::optional<BoxStyle>& box_style,
std::unique_ptr<protocol::DictionaryValue>& parent_config,
String box_name) { … }
std::unique_ptr<protocol::DictionaryValue>
BuildFlexContainerHighlightConfigInfo(
const InspectorFlexContainerHighlightConfig& flex_config) { … }
std::unique_ptr<protocol::DictionaryValue> BuildFlexItemHighlightConfigInfo(
const InspectorFlexItemHighlightConfig& flex_config) { … }
std::unique_ptr<protocol::DictionaryValue> BuildGridHighlightConfigInfo(
const InspectorGridHighlightConfig& grid_config) { … }
std::unique_ptr<protocol::DictionaryValue>
BuildContainerQueryContainerHighlightConfigInfo(
const InspectorContainerQueryContainerHighlightConfig& container_config) { … }
std::unique_ptr<protocol::DictionaryValue>
BuildIsolationModeHighlightConfigInfo(
const InspectorIsolationModeHighlightConfig& config) { … }
PhysicalOffset Transpose(PhysicalOffset& offset) { … }
LayoutUnit TranslateRTLCoordinate(const LayoutObject* layout_object,
LayoutUnit position,
const Vector<LayoutUnit>& column_positions) { … }
LayoutUnit GetPositionForTrackAt(const LayoutObject* layout_object,
wtf_size_t index,
GridTrackSizingDirection direction,
const Vector<LayoutUnit>& positions) { … }
LayoutUnit GetPositionForFirstTrack(const LayoutObject* layout_object,
GridTrackSizingDirection direction,
const Vector<LayoutUnit>& positions) { … }
LayoutUnit GetPositionForLastTrack(const LayoutObject* layout_object,
GridTrackSizingDirection direction,
const Vector<LayoutUnit>& positions) { … }
PhysicalOffset LocalToAbsolutePoint(Node* node,
PhysicalOffset local,
float scale) { … }
String SnapAlignToString(const cc::SnapAlignment& value) { … }
std::unique_ptr<protocol::ListValue> BuildPathFromQuad(
const blink::LocalFrameView* containing_view,
gfx::QuadF quad) { … }
void BuildSnapAlignment(const cc::ScrollSnapType& snap_type,
const cc::SnapAlignment& alignment_block,
const cc::SnapAlignment& alignment_inline,
std::unique_ptr<protocol::DictionaryValue>& result) { … }
std::unique_ptr<protocol::DictionaryValue> BuildPosition(
PhysicalOffset position) { … }
std::unique_ptr<protocol::ListValue> BuildGridTrackSizes(
Node* node,
GridTrackSizingDirection direction,
float scale,
LayoutUnit gap,
LayoutUnit rtl_offset,
const Vector<LayoutUnit>& positions,
const Vector<LayoutUnit>& alt_axis_positions,
const Vector<String>* authored_values) { … }
std::unique_ptr<protocol::ListValue> BuildGridPositiveLineNumberPositions(
Node* node,
const LayoutUnit& grid_gap,
GridTrackSizingDirection direction,
float scale,
LayoutUnit rtl_offset,
const Vector<LayoutUnit>& positions,
const Vector<LayoutUnit>& alt_axis_positions) { … }
std::unique_ptr<protocol::ListValue> BuildGridNegativeLineNumberPositions(
Node* node,
const LayoutUnit& grid_gap,
GridTrackSizingDirection direction,
float scale,
LayoutUnit rtl_offset,
const Vector<LayoutUnit>& positions,
const Vector<LayoutUnit>& alt_axis_positions) { … }
bool IsLayoutNGFlexibleBox(const LayoutObject& layout_object) { … }
bool IsLayoutNGFlexItem(const LayoutObject& layout_object) { … }
std::unique_ptr<protocol::DictionaryValue> BuildAreaNamePaths(
Node* node,
float scale,
const Vector<LayoutUnit>& rows,
const Vector<LayoutUnit>& columns) { … }
std::unique_ptr<protocol::ListValue> BuildGridLineNames(
Node* node,
GridTrackSizingDirection direction,
float scale,
const Vector<LayoutUnit>& positions,
const Vector<LayoutUnit>& alt_axis_positions) { … }
int GetRotationAngle(LayoutObject* layout_object) { … }
String GetWritingMode(const ComputedStyle& computed_style) { … }
Vector<String> GetAuthoredGridTrackSizes(const CSSValue* value,
size_t auto_repeat_count) { … }
bool IsHorizontalFlex(LayoutObject* layout_flex) { … }
DevtoolsFlexInfo GetFlexLinesAndItems(LayoutBox* layout_box,
bool is_horizontal,
bool is_reverse) { … }
std::unique_ptr<protocol::DictionaryValue> BuildFlexContainerInfo(
Element* element,
const InspectorFlexContainerHighlightConfig&
flex_container_highlight_config,
float scale) { … }
std::unique_ptr<protocol::DictionaryValue> BuildFlexItemInfo(
Element* element,
const InspectorFlexItemHighlightConfig& flex_item_highlight_config,
float scale) { … }
std::unique_ptr<protocol::DictionaryValue> BuildGridInfo(
Element* element,
const InspectorGridHighlightConfig& grid_highlight_config,
float scale,
bool isPrimary) { … }
std::unique_ptr<protocol::DictionaryValue> BuildGridInfo(
Element* element,
const InspectorHighlightConfig& highlight_config,
float scale,
bool isPrimary) { … }
void CollectQuads(Node* node,
bool adjust_for_absolute_zoom,
Vector<gfx::QuadF>& out_quads) { … }
std::unique_ptr<protocol::Array<double>> RectForPhysicalRect(
const PhysicalRect& rect) { … }
PhysicalRect RectInRootFrame(const LayoutObject* layout_object) { … }
PhysicalRect TextFragmentRectInRootFrame(
const LayoutObject* layout_object,
const LayoutText::TextBoxInfo& text_box) { … }
}
InspectorHighlightConfig::InspectorHighlightConfig()
: … { … }
InspectorHighlight::InspectorHighlight(float scale)
: … { … }
InspectorSourceOrderConfig::InspectorSourceOrderConfig() = default;
LineStyle::LineStyle() = default;
BoxStyle::BoxStyle() = default;
InspectorGridHighlightConfig::InspectorGridHighlightConfig()
: … { … }
InspectorFlexContainerHighlightConfig::InspectorFlexContainerHighlightConfig() =
default;
InspectorFlexItemHighlightConfig::InspectorFlexItemHighlightConfig() = default;
InspectorHighlightBase::InspectorHighlightBase(float scale)
: … { … }
InspectorHighlightBase::InspectorHighlightBase(Node* node)
: … { … }
bool InspectorHighlightBase::BuildNodeQuads(Node* node,
gfx::QuadF* content,
gfx::QuadF* padding,
gfx::QuadF* border,
gfx::QuadF* margin) { … }
void InspectorHighlightBase::AppendQuad(const gfx::QuadF& quad,
const Color& fill_color,
const Color& outline_color,
const String& name) { … }
void InspectorHighlightBase::AppendPath(
std::unique_ptr<protocol::ListValue> path,
const Color& fill_color,
const Color& outline_color,
const String& name) { … }
InspectorSourceOrderHighlight::InspectorSourceOrderHighlight(
Node* node,
Color outline_color,
int source_order_position)
: … { … }
std::unique_ptr<protocol::DictionaryValue>
InspectorSourceOrderHighlight::AsProtocolValue() const { … }
InspectorSourceOrderConfig InspectorSourceOrderHighlight::DefaultConfig() { … }
InspectorHighlight::InspectorHighlight(
Node* node,
const InspectorHighlightConfig& highlight_config,
const InspectorHighlightContrastInfo& node_contrast,
bool append_element_info,
bool append_distance_info,
NodeContentVisibilityState content_visibility_state)
: … { … }
InspectorHighlight::~InspectorHighlight() = default;
void InspectorHighlight::AppendDistanceInfo(Node* node) { … }
void InspectorHighlight::VisitAndCollectDistanceInfo(Node* node) { … }
void InspectorHighlight::VisitAndCollectDistanceInfo(
PseudoId pseudo_id,
LayoutObject* layout_object) { … }
void InspectorHighlight::AddLayoutBoxToDistanceInfo(
LayoutObject* layout_object) { … }
void InspectorHighlight::AppendEventTargetQuads(
Node* event_target_node,
const InspectorHighlightConfig& highlight_config) { … }
void InspectorHighlight::AppendPathsForShapeOutside(
Node* node,
const InspectorHighlightConfig& config) { … }
void InspectorHighlight::AppendNodeHighlight(
Node* node,
const InspectorHighlightConfig& highlight_config) { … }
std::unique_ptr<protocol::DictionaryValue> InspectorHighlight::AsProtocolValue()
const { … }
bool InspectorHighlight::GetBoxModel(
Node* node,
std::unique_ptr<protocol::DOM::BoxModel>* model,
bool use_absolute_zoom) { … }
bool InspectorHighlight::BuildSVGQuads(Node* node, Vector<gfx::QuadF>& quads) { … }
bool InspectorHighlight::GetContentQuads(
Node* node,
std::unique_ptr<protocol::Array<protocol::Array<double>>>* result) { … }
std::unique_ptr<protocol::DictionaryValue> InspectorGridHighlight(
Node* node,
const InspectorGridHighlightConfig& config) { … }
std::unique_ptr<protocol::DictionaryValue> InspectorFlexContainerHighlight(
Node* node,
const InspectorFlexContainerHighlightConfig& config) { … }
std::unique_ptr<protocol::DictionaryValue> BuildSnapContainerInfo(Node* node) { … }
std::unique_ptr<protocol::DictionaryValue> InspectorScrollSnapHighlight(
Node* node,
const InspectorScrollSnapContainerHighlightConfig& config) { … }
Vector<gfx::QuadF> GetContainerQueryingDescendantQuads(Element* container) { … }
std::unique_ptr<protocol::DictionaryValue> BuildContainerQueryContainerInfo(
Node* node,
const InspectorContainerQueryContainerHighlightConfig&
container_query_container_highlight_config,
float scale) { … }
std::unique_ptr<protocol::DictionaryValue> BuildIsolatedElementInfo(
Element& element,
const InspectorIsolationModeHighlightConfig& config,
float scale) { … }
std::unique_ptr<protocol::DictionaryValue> InspectorContainerQueryHighlight(
Node* node,
const InspectorContainerQueryContainerHighlightConfig& config) { … }
std::unique_ptr<protocol::DictionaryValue> InspectorIsolatedElementHighlight(
Element* element,
const InspectorIsolationModeHighlightConfig& config) { … }
InspectorHighlightConfig InspectorHighlight::DefaultConfig() { … }
InspectorGridHighlightConfig InspectorHighlight::DefaultGridConfig() { … }
InspectorFlexContainerHighlightConfig
InspectorHighlight::DefaultFlexContainerConfig() { … }
InspectorFlexItemHighlightConfig InspectorHighlight::DefaultFlexItemConfig() { … }
LineStyle InspectorHighlight::DefaultLineStyle() { … }
BoxStyle InspectorHighlight::DefaultBoxStyle() { … }
}