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

// Copyright 2020 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/text_decoration_info.h"

#include <math.h>

#include "build/build_config.h"
#include "third_party/blink/renderer/core/layout/text_decoration_offset.h"
#include "third_party/blink/renderer/core/paint/decoration_line_painter.h"
#include "third_party/blink/renderer/core/paint/inline_paint_context.h"
#include "third_party/blink/renderer/core/paint/text_paint_style.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/geometry/length_functions.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/stroke_data.h"
#include "third_party/blink/renderer/platform/graphics/styled_stroke_data.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"

namespace blink {

namespace {

inline float GetAscent(const ComputedStyle& style, const Font* font_override) {}

static ResolvedUnderlinePosition ResolveUnderlinePosition(
    const ComputedStyle& style) {}

inline bool ShouldUseDecoratingBox(const ComputedStyle& style) {}

static float ComputeDecorationThickness(
    const TextDecorationThickness text_decoration_thickness,
    float computed_font_size,
    float minimum_thickness,
    const SimpleFontData* font_data) {}

static enum StrokeStyle TextDecorationStyleToStrokeStyle(
    ETextDecorationStyle decoration_style) {}

struct WavyParams {};

float WavyControlPointDistance(const WavyParams& params) {}

float WavyStep(const WavyParams& params) {}

// Computes the wavy pattern rect, which is where the desired wavy pattern would
// be found when painting the wavy stroke path at the origin, or in other words,
// how far PrepareWavyTileRecord needs to translate in the opposite direction
// when painting to ensure that nothing is painted at y<0.
gfx::RectF ComputeWavyPatternRect(const WavyParams& params,
                                  const Path& stroke_path) {}

// Prepares a path for a cubic Bezier curve repeated three times, yielding a
// wavy pattern that we can cut into a tiling shader (PrepareWavyTileRecord).
//
// The result ignores the local origin, line offset, and (wavy) double offset,
// so the midpoints are always at y=0.5, while the phase is shifted for either
// wavy or spelling/grammar decorations so the desired pattern starts at x=0.
//
// The start point, control points (cp1 and cp2), and end point of each curve
// form a diamond shape:
//
//            cp2                      cp2                      cp2
// ---         +                        +                        +
// |               x=0
// | control         |--- spelling/grammar ---|
// | point          . .                      . .                      . .
// | distance     .     .                  .     .                  .     .
// |            .         .              .         .              .         .
// +-- y=0.5   .            +           .            +           .            +
//  .         .              .         .              .         .
//    .     .                  .     .                  .     .
//      . .                      . .                      . .
//                          |-------- other ---------|
//                        x=0
//             +                        +                        +
//            cp1                      cp1                      cp1
// |-----------|------------|
//     step         step
Path PrepareWavyStrokePath(const WavyParams& params) {}

cc::PaintRecord PrepareWavyTileRecord(const WavyParams& params,
                                      const Path& stroke_path,
                                      const gfx::RectF& pattern_rect) {}

}  // anonymous namespace

TextDecorationInfo::TextDecorationInfo(
    LineRelativeOffset local_origin,
    LayoutUnit width,
    const ComputedStyle& target_style,
    const InlinePaintContext* inline_context,
    const TextDecorationLine selection_decoration_line,
    const Color selection_decoration_color,
    const AppliedTextDecoration* decoration_override,
    const Font* font_override,
    MinimumThickness1 minimum_thickness1,
    float scaling_factor)
    :{}

wtf_size_t TextDecorationInfo::AppliedDecorationCount() const {}

const AppliedTextDecoration& TextDecorationInfo::AppliedDecoration(
    wtf_size_t index) const {}

void TextDecorationInfo::SetDecorationIndex(int decoration_index) {}

// Update cached properties of |this| for the |decoration_index_|.
void TextDecorationInfo::UpdateForDecorationIndex() {}

void TextDecorationInfo::SetLineData(TextDecorationLine line,
                                     float line_offset) {}

// Returns the offset of the target text/box (|local_origin_|) from the
// decorating box.
LayoutUnit TextDecorationInfo::OffsetFromDecoratingBox() const {}

void TextDecorationInfo::SetUnderlineLineData(
    const TextDecorationOffset& decoration_offset) {}

void TextDecorationInfo::SetOverlineLineData(
    const TextDecorationOffset& decoration_offset) {}

void TextDecorationInfo::SetLineThroughLineData() {}

void TextDecorationInfo::SetSpellingOrGrammarErrorLineData(
    const TextDecorationOffset& decoration_offset) {}

bool TextDecorationInfo::ShouldAntialias() const {}

ETextDecorationStyle TextDecorationInfo::DecorationStyle() const {}

Color TextDecorationInfo::LineColor() const {}

gfx::PointF TextDecorationInfo::StartPoint() const {}
float TextDecorationInfo::DoubleOffset() const {}

enum StrokeStyle TextDecorationInfo::StrokeStyle() const {}

float TextDecorationInfo::ComputeThickness() const {}

float TextDecorationInfo::ComputeUnderlineThickness(
    const TextDecorationThickness& applied_decoration_thickness,
    const ComputedStyle* decorating_box_style) const {}

void TextDecorationInfo::ComputeWavyLineData(
    gfx::RectF& pattern_rect,
    cc::PaintRecord& tile_record) const {}

gfx::RectF TextDecorationInfo::Bounds() const {}

gfx::RectF TextDecorationInfo::BoundsForDottedOrDashed() const {}

// Returns the wavy bounds, which is the same size as the wavy paint rect but
// at the origin needed by the actual decoration, for the global transform.
//
// The origin is the sum of the local origin, line offset, (wavy) double offset,
// and the origin of the wavy pattern rect (around minus half the amplitude).
gfx::RectF TextDecorationInfo::BoundsForWavy() const {}

// Returns the wavy paint rect, which has the height of the wavy tile rect but
// the width needed by the actual decoration, for the DrawRect operation.
//
// The origin is still (0,0) so that the shader local matrix is independent of
// the origin of the decoration, allowing Skia to cache the tile. To determine
// the origin of the decoration, use Bounds().origin().
gfx::RectF TextDecorationInfo::WavyPaintRect() const {}

// Returns the wavy tile rect, which is the same size as the wavy pattern rect
// but at origin (0,0), for converting the PaintRecord to a PaintShader.
gfx::RectF TextDecorationInfo::WavyTileRect() const {}

cc::PaintRecord TextDecorationInfo::WavyTileRecord() const {}

void TextDecorationInfo::SetHighlightOverrideColor(
    const std::optional<Color>& color) {}

Path TextDecorationInfo::PrepareDottedOrDashedStrokePath() const {}

}  // namespace blink