chromium/pdf/pdf_ink_module.cc

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

#include "pdf/pdf_ink_module.h"

#include <stddef.h>

#include <algorithm>
#include <limits>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/containers/fixed_flat_map.h"
#include "base/feature_list.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/time/time.h"
#include "base/values.h"
#include "pdf/draw_utils/page_boundary_intersect.h"
#include "pdf/ink/ink_affine_transform.h"
#include "pdf/ink/ink_brush.h"
#include "pdf/ink/ink_in_progress_stroke.h"
#include "pdf/ink/ink_intersects.h"
#include "pdf/ink/ink_modeled_shape_view.h"
#include "pdf/ink/ink_rect.h"
#include "pdf/ink/ink_skia_renderer.h"
#include "pdf/ink/ink_stroke.h"
#include "pdf/ink/ink_stroke_input_batch.h"
#include "pdf/ink/ink_stroke_input_batch_view.h"
#include "pdf/input_utils.h"
#include "pdf/pdf_features.h"
#include "pdf/pdf_ink_brush.h"
#include "pdf/pdf_ink_cursor.h"
#include "pdf/pdf_ink_transform.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/skia_conversions.h"

namespace chrome_pdf {

namespace {

PdfInkModule::StrokeInputPoints GetStrokePointsForTesting(  // IN-TEST
    const InkStrokeInputBatchView& input_batch) {}

// Default to a black pen brush.
std::unique_ptr<PdfInkBrush> CreateDefaultBrush() {}

// Check if `color` is a valid color value within range.
void CheckColorIsWithinRange(int color) {}

InkRect GetEraserRect(const gfx::PointF& center, int distance_to_center) {}

void UnionInkRects(std::optional<InkRect>& result_rect,
                   const InkRect& new_rect) {}

gfx::Rect InkRectToEnclosingGfxRect(const InkRect& rect) {}

SkRect GetDrawPageClipRect(const gfx::Rect& content_rect,
                           const gfx::Vector2dF& origin_offset) {}

}  // namespace

PdfInkModule::PdfInkModule(Client& client) :{}

PdfInkModule::~PdfInkModule() = default;

void PdfInkModule::Draw(SkCanvas& canvas) {}

bool PdfInkModule::HandleInputEvent(const blink::WebInputEvent& event) {}

bool PdfInkModule::OnMessage(const base::Value::Dict& message) {}

void PdfInkModule::OnGeometryChanged() {}

const PdfInkBrush* PdfInkModule::GetPdfInkBrushForTesting() const {}

std::optional<float> PdfInkModule::GetEraserSizeForTesting() const {}

PdfInkModule::DocumentStrokeInputPointsMap
PdfInkModule::GetStrokesInputPositionsForTesting() const {}

PdfInkModule::DocumentStrokeInputPointsMap
PdfInkModule::GetVisibleStrokesInputPositionsForTesting() const {}

void PdfInkModule::SetDrawRenderTransformCallbackForTesting(
    RenderTransformCallback callback) {}

bool PdfInkModule::OnMouseDown(const blink::WebMouseEvent& event) {}

bool PdfInkModule::OnMouseUp(const blink::WebMouseEvent& event) {}

bool PdfInkModule::OnMouseMove(const blink::WebMouseEvent& event) {}

bool PdfInkModule::StartStroke(const gfx::PointF& position) {}

bool PdfInkModule::ContinueStroke(const gfx::PointF& position) {}

bool PdfInkModule::FinishStroke(const gfx::PointF& position) {}

bool PdfInkModule::StartEraseStroke(const gfx::PointF& position) {}

bool PdfInkModule::ContinueEraseStroke(const gfx::PointF& position) {}

bool PdfInkModule::FinishEraseStroke(const gfx::PointF& position) {}

bool PdfInkModule::EraseHelper(const gfx::PointF& position, int page_index) {}

void PdfInkModule::HandleAnnotationRedoMessage(
    const base::Value::Dict& message) {}

void PdfInkModule::HandleAnnotationUndoMessage(
    const base::Value::Dict& message) {}

void PdfInkModule::HandleSetAnnotationBrushMessage(
    const base::Value::Dict& message) {}

void PdfInkModule::HandleSetAnnotationModeMessage(
    const base::Value::Dict& message) {}

std::vector<std::unique_ptr<InkInProgressStroke>>
PdfInkModule::CreateInProgressStrokeSegmentsFromInputs() const {}

gfx::PointF PdfInkModule::ConvertEventPositionToCanonicalPosition(
    const gfx::PointF& position,
    int page_index) {}

void PdfInkModule::RecordStrokePosition(const gfx::PointF& position) {}

void PdfInkModule::ApplyUndoRedoCommands(
    const PdfInkUndoRedoModel::Commands& commands) {}

void PdfInkModule::ApplyUndoRedoCommandsHelper(std::set<size_t> ids,
                                               bool should_draw) {}

void PdfInkModule::ApplyUndoRedoDiscards(
    const PdfInkUndoRedoModel::DiscardedDrawCommands& discards) {}

void PdfInkModule::MaybeSetCursor() {}

PdfInkModule::DrawingStrokeState::DrawingStrokeState() = default;

PdfInkModule::DrawingStrokeState::~DrawingStrokeState() = default;

PdfInkModule::FinishedStrokeState::FinishedStrokeState(
    std::unique_ptr<InkStroke> stroke,
    size_t id)
    :{}

PdfInkModule::FinishedStrokeState::FinishedStrokeState(
    PdfInkModule::FinishedStrokeState&&) noexcept = default;

PdfInkModule::FinishedStrokeState& PdfInkModule::FinishedStrokeState::operator=(
    PdfInkModule::FinishedStrokeState&&) noexcept = default;

PdfInkModule::FinishedStrokeState::~FinishedStrokeState() = default;

PdfInkModule::StrokeIdGenerator::StrokeIdGenerator() = default;

PdfInkModule::StrokeIdGenerator::~StrokeIdGenerator() = default;

size_t PdfInkModule::StrokeIdGenerator::GetIdAndAdvance() {}

void PdfInkModule::StrokeIdGenerator::ResetIdTo(size_t id) {}

}  // namespace chrome_pdf