~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Source/WebCore/rendering/line/LineLayoutTraversalSimplePath.h

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2019 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
23
 * THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#pragma once
 
27
 
 
28
#include "LineLayoutTraversal.h"
 
29
#include "SimpleLineLayoutResolver.h"
 
30
 
 
31
namespace WebCore {
 
32
namespace LineLayoutTraversal {
 
33
 
 
34
class SimplePath {
 
35
public:
 
36
    SimplePath(SimpleLineLayout::RunResolver::Iterator iterator, SimpleLineLayout::RunResolver::Iterator end)
 
37
        : m_iterator(iterator)
 
38
        , m_end(end)
 
39
    { }
 
40
 
 
41
    FloatRect rect() const { return (*m_iterator).rect(); }
 
42
 
 
43
    float baselineOffset() const { return (*m_iterator).baselineOffset(); }
 
44
 
 
45
    bool isLeftToRightDirection() const { return true; }
 
46
    bool isHorizontal() const { return true; }
 
47
    bool dirOverride() const { return false; }
 
48
    bool isLineBreak() const { return (*m_iterator).isLineBreak(); }
 
49
 
 
50
    bool useLineBreakBoxRenderTreeDumpQuirk() const
 
51
    {
 
52
        if (m_iterator.atBegin())
 
53
            return false;
 
54
        auto previous = m_iterator;
 
55
        --previous;
 
56
        return !(*previous).isEndOfLine();
 
57
    }
 
58
 
 
59
    bool hasHyphen() const { return (*m_iterator).hasHyphen(); }
 
60
    StringView text() const { return (*m_iterator).text(); }
 
61
    unsigned localStartOffset() const { return (*m_iterator).localStart(); }
 
62
    unsigned localEndOffset() const { return (*m_iterator).localEnd(); }
 
63
    unsigned length() const { return (*m_iterator).end() - (*m_iterator).start(); }
 
64
 
 
65
    bool isLastOnLine() const
 
66
    {
 
67
        auto next = m_iterator;
 
68
        ++next;
 
69
        return next == m_end || (*m_iterator).lineIndex() != (*next).lineIndex();
 
70
    }
 
71
    bool isLast() const
 
72
    {
 
73
        auto next = m_iterator;
 
74
        ++next;
 
75
        return next == m_end;
 
76
    };
 
77
 
 
78
    void traverseNextTextBoxInVisualOrder()
 
79
    {
 
80
        // This function is currently only used for consecutive text runs.
 
81
        ++m_iterator;
 
82
    }
 
83
    void traverseNextTextBoxInTextOrder() {  traverseNextTextBoxInVisualOrder(); }
 
84
 
 
85
    bool operator==(const SimplePath& other) const { return m_iterator == other.m_iterator; }
 
86
    bool atEnd() const { return m_iterator == m_end; }
 
87
 
 
88
private:
 
89
    SimpleLineLayout::RunResolver::Iterator m_iterator;
 
90
    SimpleLineLayout::RunResolver::Iterator m_end;
 
91
};
 
92
 
 
93
}
 
94
}