chromium/third_party/blink/renderer/core/layout/inline/score_line_breaker.h

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

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_INLINE_SCORE_LINE_BREAKER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_INLINE_SCORE_LINE_BREAKER_H_

#include <optional>

#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/inline/inline_node.h"
#include "third_party/blink/renderer/core/layout/inline/line_break_candidate.h"
#include "third_party/blink/renderer/core/layout/inline/score_line_break_context.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"

namespace blink {

class ConstraintSpace;
class InlineBreakToken;
class InlineNode;
class LineInfoList;
class LineWidths;
struct LeadingFloats;

//
// This class computes line break points using penalties and scores, similar to
// the Knuth's TeX algorithm.
//
// In short, the algorithm works in following steps:
// 1. It runs `LineBreaker` to compute line break points greedy.
// 2. If the result doesn't meet the criteria to apply this score-based line
//    breaking, it returns the result without applying the algorithm.
// 3. It then computes all break candidates (a.k.a., break opportunities) with
//    penalties from the greedy results.
// 4. It then computes the scores for all break candidates.
// 5. The break candidates of the highest score is determined as the line break
//    points.
//
// This algorithm is based on Android's `LineBreak.Strategy.HighQuality`:
// https://cs.android.com/android/platform/superproject/+/master:frameworks/minikin/libs/minikin/OptimalLineBreaker.cpp
//
class CORE_EXPORT ScoreLineBreaker {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_INLINE_SCORE_LINE_BREAKER_H_