chromium/third_party/blink/renderer/core/layout/inline/inline_caret_position.cc

// Copyright 2018 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/layout/inline/inline_caret_position.h"

#include "third_party/blink/renderer/core/editing/bidi_adjustment.h"
#include "third_party/blink/renderer/core/editing/position_with_affinity.h"
#include "third_party/blink/renderer/core/editing/text_affinity.h"
#include "third_party/blink/renderer/core/layout/inline/fragment_item.h"
#include "third_party/blink/renderer/core/layout/inline/inline_cursor.h"
#include "third_party/blink/renderer/core/layout/inline/inline_node.h"
#include "third_party/blink/renderer/core/layout/inline/offset_mapping.h"
#include "third_party/blink/renderer/core/layout/inline/physical_line_box_fragment.h"
#include "third_party/blink/renderer/core/layout/layout_block_flow.h"

namespace blink {

namespace {

// The calculation takes the following input:
// - An inline formatting context as a |LayoutBlockFlow|
// - An offset in the |text_content_| string of the above context
// - A TextAffinity
//
// The calculation iterates all inline fragments in the context, and tries to
// compute an InlineCaretPosition using the "caret resolution process" below:
//
// The (offset, affinity) pair is compared against each inline fragment to see
// if the corresponding caret should be placed in the fragment, using the
// |TryResolveInlineCaretPositionInXXX()| functions. These functions may return:
// - Failed, indicating that the caret must not be placed in the fragment;
// - Resolved, indicating that the care should be placed in the fragment, and
//   no further search is required. The result InlineCaretPosition is returned
//   together.
// - FoundCandidate, indicating that the caret may be placed in the fragment;
//   however, further search may find a better position. The candidate
//   InlineCaretPosition is also returned together.

enum class ResolutionType {};
struct InlineCaretPositionResolution {};

bool CanResolveInlineCaretPositionBeforeFragment(const InlineCursor& cursor,
                                                 TextAffinity affinity) {}

bool CanResolveInlineCaretPositionAfterFragment(const InlineCursor& cursor,
                                                TextAffinity affinity) {}

// Returns a |kFailed| resolution if |offset| doesn't belong to the text
// fragment. Otherwise, return either |kFoundCandidate| or |kResolved| depending
// on |affinity|.
InlineCaretPositionResolution TryResolveInlineCaretPositionInTextFragment(
    const InlineCursor& cursor,
    unsigned offset,
    TextAffinity affinity) {}

unsigned GetTextOffsetBefore(const Node& node) {}

// Returns a |kFailed| resolution if |offset| doesn't belong to the atomic
// inline box fragment. Otherwise, return either |kFoundCandidate| or
// |kResolved| depending on |affinity|.
InlineCaretPositionResolution TryResolveInlineCaretPositionByBoxFragmentSide(
    const InlineCursor& cursor,
    unsigned offset,
    TextAffinity affinity) {}

InlineCaretPositionResolution TryResolveInlineCaretPositionWithFragment(
    const InlineCursor& cursor,
    unsigned offset,
    TextAffinity affinity) {}

bool NeedsBidiAdjustment(const InlineCaretPosition& caret_position) {}

InlineCaretPosition AdjustInlineCaretPositionForBidiText(
    const InlineCaretPosition& caret_position) {}

bool IsUpstreamAfterLineBreak(const InlineCaretPosition& caret_position) {}

InlineCaretPosition BetterCandidateBetween(const InlineCaretPosition& current,
                                           const InlineCaretPosition& other,
                                           unsigned offset) {}

InlineCaretPosition ComputeInlineCaretPositionAfterInline(
    const PositionWithAffinity& position_with_affinity) {}
InlineCaretPosition ComputeInlineCaretPositionBeforeInline(
    const PositionWithAffinity& position_with_affinity) {}

}  // namespace

// The main function for compute an InlineCaretPosition. See the comments at the
// top of this file for details.
InlineCaretPosition ComputeInlineCaretPosition(const LayoutBlockFlow& context,
                                               unsigned offset,
                                               TextAffinity affinity,
                                               const LayoutText* layout_text) {}

InlineCaretPosition ComputeInlineCaretPosition(
    const PositionWithAffinity& position_with_affinity) {}

Position InlineCaretPosition::ToPositionInDOMTree() const {}

PositionWithAffinity InlineCaretPosition::ToPositionInDOMTreeWithAffinity()
    const {}

}  // namespace blink