chromium/third_party/blink/renderer/core/paint/highlight_painter.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/paint/highlight_painter.h"

#include "base/not_fatal_until.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/editing/editor.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/markers/custom_highlight_marker.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h"
#include "third_party/blink/renderer/core/editing/markers/styleable_marker.h"
#include "third_party/blink/renderer/core/editing/markers/text_match_marker.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/highlight/highlight.h"
#include "third_party/blink/renderer/core/highlight/highlight_registry.h"
#include "third_party/blink/renderer/core/highlight/highlight_style_utils.h"
#include "third_party/blink/renderer/core/layout/inline/inline_cursor.h"
#include "third_party/blink/renderer/core/layout/inline/text_offset_range.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_text_fragment.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h"
#include "third_party/blink/renderer/core/layout/text_decoration_offset.h"
#include "third_party/blink/renderer/core/paint/highlight_overlay.h"
#include "third_party/blink/renderer/core/paint/line_relative_rect.h"
#include "third_party/blink/renderer/core/paint/marker_range_mapping_context.h"
#include "third_party/blink/renderer/core/paint/paint_auto_dark_mode.h"
#include "third_party/blink/renderer/core/paint/paint_info.h"
#include "third_party/blink/renderer/core/paint/styleable_marker_painter.h"
#include "third_party/blink/renderer/core/paint/text_decoration_painter.h"
#include "third_party/blink/renderer/core/paint/text_painter.h"
#include "third_party/blink/renderer/platform/fonts/text_fragment_paint_info.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context_state_saver.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"

namespace blink {

namespace {

HighlightLayerType;
HighlightRange;
HighlightEdge;
HighlightDecoration;
HighlightBackground;
HighlightTextShadow;

LineRelativeRect LineRelativeLocalRect(const FragmentItem& text_fragment,
                                       StringView text,
                                       unsigned start_offset,
                                       unsigned end_offset) {}

void PaintRect(GraphicsContext& context,
               const PhysicalRect& rect,
               const Color color,
               const AutoDarkMode& auto_dark_mode) {}

const LayoutSelectionStatus* GetSelectionStatus(
    const HighlightPainter::SelectionPaintState* selection) {}

// Returns true if the styles for the given spelling or grammar pseudo require
// the full overlay painting algorithm.
bool HasNonTrivialSpellingGrammarStyles(const FragmentItem& fragment_item,
                                        Node* node,
                                        const ComputedStyle& originating_style,
                                        PseudoId pseudo) {}

TextPaintStyle TextPaintStyleForTextMatch(const TextMatchMarker& marker,
                                          const ComputedStyle& style,
                                          const Document& document,
                                          bool ignore_current_color) {}

// A contiguous run of parts that can have ‘background-color’ or ‘text-shadow’
// of some active overlay painted at once.
//
// These properties can often be painted a whole highlighted range at a time,
// and only need to be split into parts when affected by ‘currentColor’. By
// merging parts where possible, we avoid creating unnecessary “seams” in
// ‘background-color’, and avoid splitting ligatures in ‘text-shadow’.
//
// Inner’s operator== must return true iff the two operands come from the same
// layer and can be painted at once.
template <typename Inner>
struct MergedHighlightPart {};

}  // namespace

HighlightPainter::SelectionPaintState::SelectionPaintState(
    const InlineCursor& containing_block,
    const PhysicalOffset& box_offset,
    const std::optional<AffineTransform> writing_mode_rotation)
    :{}
HighlightPainter::SelectionPaintState::SelectionPaintState(
    const InlineCursor& containing_block,
    const PhysicalOffset& box_offset,
    const std::optional<AffineTransform> writing_mode_rotation,
    const FrameSelection& frame_selection)
    :{}

void HighlightPainter::SelectionPaintState::ComputeSelectionStyle(
    const Document& document,
    const ComputedStyle& style,
    Node* node,
    const PaintInfo& paint_info,
    const TextPaintStyle& text_style) {}

void HighlightPainter::SelectionPaintState::ComputeSelectionRectIfNeeded() {}

const PhysicalRect&
HighlightPainter::SelectionPaintState::PhysicalSelectionRect() {}

const LineRelativeRect&
HighlightPainter::SelectionPaintState::LineRelativeSelectionRect() {}

// |selection_start| and |selection_end| should be between
// [text_fragment.StartOffset(), text_fragment.EndOffset()].
void HighlightPainter::SelectionPaintState::PaintSelectionBackground(
    GraphicsContext& context,
    Node* node,
    const Document& document,
    const ComputedStyle& style,
    const std::optional<AffineTransform>& rotation) {}

// Paint the selected text only.
void HighlightPainter::SelectionPaintState::PaintSelectedText(
    TextPainter& text_painter,
    const TextFragmentPaintInfo& fragment_paint_info,
    const TextPaintStyle& text_style,
    DOMNodeId node_id,
    const AutoDarkMode& auto_dark_mode) {}

// Paint the given text range in the given style, suppressing the text proper
// (painting shadows only) where selected.
void HighlightPainter::SelectionPaintState::
    PaintSuppressingTextProperWhereSelected(
        TextPainter& text_painter,
        const TextFragmentPaintInfo& fragment_paint_info,
        const TextPaintStyle& text_style,
        DOMNodeId node_id,
        const AutoDarkMode& auto_dark_mode) {}

// GetNode() for first-letter fragment returns null because it is anonymous.
// Use AssociatedTextNode() of LayoutTextFragment to get the associated node.
static Node* AssociatedNode(const LayoutObject* layout_object) {}

HighlightPainter::HighlightPainter(
    const TextFragmentPaintInfo& fragment_paint_info,
    TextPainter& text_painter,
    TextDecorationPainter& decoration_painter,
    const PaintInfo& paint_info,
    const InlineCursor& cursor,
    const FragmentItem& fragment_item,
    const PhysicalOffset& box_origin,
    const ComputedStyle& style,
    const TextPaintStyle& text_style,
    SelectionPaintState* selection)
    :{}

void HighlightPainter::PaintNonCssMarkers(Phase phase) {}

HighlightPainter::Case HighlightPainter::PaintCase() const {}

HighlightPainter::Case HighlightPainter::ComputePaintCase() const {}

void HighlightPainter::FastPaintSpellingGrammarDecorations() {}

void HighlightPainter::FastPaintSpellingGrammarDecorations(
    const Text& text_node,
    const StringView& text,
    const DocumentMarkerVector& markers) {}

void HighlightPainter::PaintOneSpellingGrammarDecoration(
    DocumentMarker::MarkerType type,
    const StringView& text,
    unsigned paint_start_offset,
    unsigned paint_end_offset) {}

void HighlightPainter::PaintOneSpellingGrammarDecoration(
    DocumentMarker::MarkerType marker_type,
    const StringView& text,
    unsigned paint_start_offset,
    unsigned paint_end_offset,
    const ComputedStyle& style,
    const TextPaintStyle& text_style,
    const AppliedTextDecoration* decoration_override) {}

void HighlightPainter::PaintOriginatingShadow(const TextPaintStyle& text_style,
                                              DOMNodeId node_id) {}

Vector<LayoutSelectionStatus> HighlightPainter::GetHighlights(
    const HighlightLayer& layer) {}

TextOffsetRange HighlightPainter::GetFragmentDOMOffsets(const Text& text,
                                                        unsigned from,
                                                        unsigned to) {}

const PhysicalRect HighlightPainter::ComputeBackgroundRect(
    StringView text,
    unsigned start_offset,
    unsigned end_offset) {}

const PhysicalRect HighlightPainter::ComputeBackgroundRectForSelection(
    unsigned start_offset,
    unsigned end_offset) {}

void HighlightPainter::PaintHighlightOverlays(
    const TextPaintStyle& originating_text_style,
    DOMNodeId node_id,
    bool paint_marker_backgrounds,
    std::optional<AffineTransform> rotation) {}

void HighlightPainter::PaintHighlightBackground(
    GraphicsContext& context,
    const ComputedStyle& style,
    Color color,
    const PhysicalRect& rect,
    const std::optional<AffineTransform>& rotation) {}

PseudoId HighlightPainter::PseudoFor(DocumentMarker::MarkerType type) {}

TextDecorationLine HighlightPainter::LineFor(DocumentMarker::MarkerType type) {}

Color HighlightPainter::ColorFor(DocumentMarker::MarkerType type) {}

LineRelativeRect HighlightPainter::LineRelativeWorldRect(
    const HighlightOverlay::HighlightRange& range) {}

LineRelativeRect HighlightPainter::LocalRectInWritingModeSpace(
    unsigned from,
    unsigned to) const {}

void HighlightPainter::ClipToPartRect(const LineRelativeRect& part_rect) {}

void HighlightPainter::PaintDecorationsExceptLineThrough(
    const HighlightPart& part,
    const LineRelativeRect& part_rect) {}

void HighlightPainter::PaintDecorationsExceptLineThrough(
    const HighlightPart& part,
    const LineRelativeRect& part_rect,
    TextDecorationLine lines_to_paint) {}

void HighlightPainter::PaintDecorationsOnlyLineThrough(
    const HighlightPart& part,
    const LineRelativeRect& part_rect) {}

void HighlightPainter::PaintTextForCompositionMarker(
    const StringView& text,
    const Color& text_color,
    unsigned paint_start_offset,
    unsigned paint_end_offset) {}

}  // namespace blink