| Differences between
and this patch
- a/Source/WebCore/ChangeLog +59 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2021-09-22  Alan Bujtas  <zalan@apple.com>
2
3
        [LFC][IFC] Move LineGeometry and LineRun files under /inline/display
4
        https://bugs.webkit.org/show_bug.cgi?id=230632
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        This is in preparation for moving these classes out of the "layout namespace".
9
10
        * CMakeLists.txt:
11
        * WebCore.xcodeproj/project.pbxproj:
12
        * layout/formattingContexts/inline/display/InlineLineGeometry.h: Renamed from Source/WebCore/layout/formattingContexts/inline/InlineLineGeometry.h.
13
        (WebCore::Layout::LineGeometry::lineBoxLogicalRect const):
14
        (WebCore::Layout::LineGeometry::scrollableOverflow const):
15
        (WebCore::Layout::LineGeometry::enclosingTopAndBottom const):
16
        (WebCore::Layout::LineGeometry::baseline const):
17
        (WebCore::Layout::LineGeometry::contentLogicalLeft const):
18
        (WebCore::Layout::LineGeometry::contentLogicalWidth const):
19
        (WebCore::Layout::LineGeometry::moveVertically):
20
        (WebCore::Layout::LineGeometry::LineGeometry):
21
        * layout/formattingContexts/inline/display/InlineLineRun.h: Renamed from Source/WebCore/layout/formattingContexts/inline/InlineLineRun.h.
22
        (WebCore::Layout::Run::Text::start const):
23
        (WebCore::Layout::Run::Text::end const):
24
        (WebCore::Layout::Run::Text::length const):
25
        (WebCore::Layout::Run::Text::originalContent const):
26
        (WebCore::Layout::Run::Text::renderedContent const):
27
        (WebCore::Layout::Run::Text::hasHyphen const):
28
        (WebCore::Layout::Run::isText const):
29
        (WebCore::Layout::Run::isSoftLineBreak const):
30
        (WebCore::Layout::Run::isLineBreakBox const):
31
        (WebCore::Layout::Run::isLineBreak const):
32
        (WebCore::Layout::Run::isAtomicInlineLevelBox const):
33
        (WebCore::Layout::Run::isInlineBox const):
34
        (WebCore::Layout::Run::isNonRootInlineBox const):
35
        (WebCore::Layout::Run::isRootInlineBox const):
36
        (WebCore::Layout::Run::isGenericInlineLevelBox const):
37
        (WebCore::Layout::Run::isInlineLevelBox const):
38
        (WebCore::Layout::Run::isNonRootInlineLevelBox const):
39
        (WebCore::Layout::Run::type const):
40
        (WebCore::Layout::Run::hasContent const):
41
        (WebCore::Layout::Run::logicalRect const):
42
        (WebCore::Layout::Run::inkOverflow const):
43
        (WebCore::Layout::Run::logicalTop const):
44
        (WebCore::Layout::Run::logicalBottom const):
45
        (WebCore::Layout::Run::logicalLeft const):
46
        (WebCore::Layout::Run::logicalRight const):
47
        (WebCore::Layout::Run::logicalWidth const):
48
        (WebCore::Layout::Run::logicalHeight const):
49
        (WebCore::Layout::Run::moveVertically):
50
        (WebCore::Layout::Run::adjustInkOverflow):
51
        (WebCore::Layout::Run::text):
52
        (WebCore::Layout::Run::text const):
53
        (WebCore::Layout::Run::expansion const):
54
        (WebCore::Layout::Run::layoutBox const):
55
        (WebCore::Layout::Run::style const):
56
        (WebCore::Layout::Run::lineIndex const):
57
        (WebCore::Layout::Run::Run):
58
        (WebCore::Layout::Run::Text::Text):
59
1
2021-09-22  Gabriel Nava Marino  <gnavamarino@apple.com>
60
2021-09-22  Gabriel Nava Marino  <gnavamarino@apple.com>
2
61
3
        RenderBox is a RenderElement which can have image updates from style changes. We should call
62
        RenderBox is a RenderElement which can have image updates from style changes. We should call
- a/Source/WebCore/CMakeLists.txt +1 lines
Lines 113-118 set(WebCore_PRIVATE_INCLUDE_DIRECTORIES a/Source/WebCore/CMakeLists.txt_sec1
113
    "${WEBCORE_DIR}/layout/formattingContexts/flex"
113
    "${WEBCORE_DIR}/layout/formattingContexts/flex"
114
    "${WEBCORE_DIR}/layout/floats"
114
    "${WEBCORE_DIR}/layout/floats"
115
    "${WEBCORE_DIR}/layout/formattingContexts/inline"
115
    "${WEBCORE_DIR}/layout/formattingContexts/inline"
116
    "${WEBCORE_DIR}/layout/formattingContexts/inline/display"
116
    "${WEBCORE_DIR}/layout/formattingContexts/inline/invalidation"
117
    "${WEBCORE_DIR}/layout/formattingContexts/inline/invalidation"
117
    "${WEBCORE_DIR}/layout/formattingContexts/inline/text"
118
    "${WEBCORE_DIR}/layout/formattingContexts/inline/text"
118
    "${WEBCORE_DIR}/layout/integration"
119
    "${WEBCORE_DIR}/layout/integration"
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj -2 / +10 lines
Lines 18295-18300 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
18295
		115CFA9A208BC140001E6991 /* inline */ = {
18295
		115CFA9A208BC140001E6991 /* inline */ = {
18296
			isa = PBXGroup;
18296
			isa = PBXGroup;
18297
			children = (
18297
			children = (
18298
				11A1E6FB26FBB6CE00435D36 /* display */,
18298
				111FA1C326F0F2E6003B8F16 /* invalidation */,
18299
				111FA1C326F0F2E6003B8F16 /* invalidation */,
18299
				6FE7DDDD20EC6E8B008B5B4E /* text */,
18300
				6FE7DDDD20EC6E8B008B5B4E /* text */,
18300
				6FE198132178397B00446F08 /* InlineContentBreaker.cpp */,
18301
				6FE198132178397B00446F08 /* InlineContentBreaker.cpp */,
Lines 18322-18329 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
18322
				6F6EE74126D44EE200374CDA /* InlineLineBoxVerticalAligner.h */,
18323
				6F6EE74126D44EE200374CDA /* InlineLineBoxVerticalAligner.h */,
18323
				6F25B200220A85AB0000011B /* InlineLineBuilder.cpp */,
18324
				6F25B200220A85AB0000011B /* InlineLineBuilder.cpp */,
18324
				6F26EB46234004A5006906E2 /* InlineLineBuilder.h */,
18325
				6F26EB46234004A5006906E2 /* InlineLineBuilder.h */,
18325
				6F91420F25152137004E4FEA /* InlineLineGeometry.h */,
18326
				6FC3F9452516756600A49BEA /* InlineLineRun.h */,
18327
				6F40DA812513033A00EC04B7 /* InlineRect.h */,
18326
				6F40DA812513033A00EC04B7 /* InlineRect.h */,
18328
				6F360E4E23999420001512A7 /* InlineSoftLineBreakItem.h */,
18327
				6F360E4E23999420001512A7 /* InlineSoftLineBreakItem.h */,
18329
				6F1CC1DC225F8B4100720AD2 /* InlineTextItem.cpp */,
18328
				6F1CC1DC225F8B4100720AD2 /* InlineTextItem.cpp */,
Lines 18332-18337 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
18332
			path = inline;
18331
			path = inline;
18333
			sourceTree = "<group>";
18332
			sourceTree = "<group>";
18334
		};
18333
		};
18334
		11A1E6FB26FBB6CE00435D36 /* display */ = {
18335
			isa = PBXGroup;
18336
			children = (
18337
				6F91420F25152137004E4FEA /* InlineLineGeometry.h */,
18338
				6FC3F9452516756600A49BEA /* InlineLineRun.h */,
18339
			);
18340
			path = display;
18341
			sourceTree = "<group>";
18342
		};
18335
		1221E0581C02B409006A1A00 /* Animation */ = {
18343
		1221E0581C02B409006A1A00 /* Animation */ = {
18336
			isa = PBXGroup;
18344
			isa = PBXGroup;
18337
			children = (
18345
			children = (
- a/Source/WebCore/layout/formattingContexts/inline/InlineLineGeometry.h -83 lines
Lines 1-83 a/Source/WebCore/layout/formattingContexts/inline/InlineLineGeometry.h_sec1
1
/*
2
 * Copyright (C) 2020 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
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
29
30
#include "InlineRect.h"
31
32
namespace WebCore {
33
namespace Layout {
34
35
class LineGeometry {
36
    WTF_MAKE_FAST_ALLOCATED;
37
public:
38
    struct EnclosingTopAndBottom {
39
        // This values encloses the root inline box and any other inline level box's border box.
40
        InlineLayoutUnit top { 0 };
41
        InlineLayoutUnit bottom { 0 };
42
    };
43
    LineGeometry(const InlineRect& lineBoxLogicalRect, const InlineRect& scrollableOverflow, EnclosingTopAndBottom, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth);
44
45
    const InlineRect& lineBoxLogicalRect() const { return m_lineBoxLogicalRect; }
46
    const InlineRect& scrollableOverflow() const { return m_scrollableOverflow; }
47
48
    EnclosingTopAndBottom enclosingTopAndBottom() const { return m_enclosingTopAndBottom; }
49
50
    InlineLayoutUnit baseline() const { return m_aligmentBaseline; }
51
52
    InlineLayoutUnit contentLogicalLeft() const { return m_contentLogicalLeft; }
53
    InlineLayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; }
54
55
    void moveVertically(InlineLayoutUnit offset) { m_lineBoxLogicalRect.moveVertically(offset); }
56
57
private:
58
    // This is line box geometry (see https://www.w3.org/TR/css-inline-3/#line-box).
59
    InlineRect m_lineBoxLogicalRect;
60
    InlineRect m_scrollableOverflow;
61
    // Enclosing top and bottom includes all inline level boxes (border box) vertically.
62
    // While the line box usually enclose them as well, its vertical geometry is based on
63
    // the layout bounds of the inline level boxes which may be different when line-height is present.
64
    EnclosingTopAndBottom m_enclosingTopAndBottom;
65
    InlineLayoutUnit m_aligmentBaseline { 0 };
66
    InlineLayoutUnit m_contentLogicalLeft { 0 };
67
    InlineLayoutUnit m_contentLogicalWidth { 0 };
68
};
69
70
inline LineGeometry::LineGeometry(const InlineRect& lineBoxLogicalRect, const InlineRect& scrollableOverflow, EnclosingTopAndBottom enclosingTopAndBottom, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth)
71
    : m_lineBoxLogicalRect(lineBoxLogicalRect)
72
    , m_scrollableOverflow(scrollableOverflow)
73
    , m_enclosingTopAndBottom(enclosingTopAndBottom)
74
    , m_aligmentBaseline(aligmentBaseline)
75
    , m_contentLogicalLeft(contentLogicalLeft)
76
    , m_contentLogicalWidth(contentLogicalWidth)
77
{
78
}
79
80
}
81
}
82
83
#endif
- a/Source/WebCore/layout/formattingContexts/inline/InlineLineRun.h -149 lines
Lines 1-149 a/Source/WebCore/layout/formattingContexts/inline/InlineLineRun.h_sec1
1
/*
2
 * Copyright (C) 2020 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
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
29
30
#include "InlineRect.h"
31
#include "LayoutBox.h"
32
#include "TextFlags.h"
33
34
namespace WebCore {
35
namespace Layout {
36
37
struct Run {
38
    WTF_MAKE_STRUCT_FAST_ALLOCATED;
39
    struct Text {
40
        WTF_MAKE_STRUCT_FAST_ALLOCATED;
41
    public:
42
        Text(size_t position, size_t length, const String& originalContent, String adjustedContentToRender = String(), bool hasHyphen = false);
43
44
        size_t start() const { return m_start; }
45
        size_t end() const { return start() + length(); }
46
        size_t length() const { return m_length; }
47
        StringView originalContent() const { return StringView(m_originalContent).substring(m_start, m_length); }
48
        StringView renderedContent() const { return m_adjustedContentToRender.isNull() ? originalContent() : m_adjustedContentToRender; }
49
50
        bool hasHyphen() const { return m_hasHyphen; }
51
52
    private:
53
        size_t m_start { 0 };
54
        size_t m_length { 0 };
55
        bool m_hasHyphen { false };
56
        String m_originalContent;
57
        String m_adjustedContentToRender;
58
    };
59
60
    enum class Type {
61
        Text,
62
        SoftLineBreak,
63
        LineBreakBox,
64
        AtomicInlineLevelBox,
65
        NonRootInlineBox,
66
        RootInlineBox,
67
        GenericInlineLevelBox
68
    };
69
    struct Expansion;
70
    Run(size_t lineIndex, Type, const Box&, const InlineRect&, const InlineRect& inkOverflow, Expansion, std::optional<Text> = std::nullopt, bool hasContent = true);
71
72
    bool isText() const { return m_type == Type::Text; }
73
    bool isSoftLineBreak() const { return m_type == Type::SoftLineBreak; }
74
    bool isLineBreakBox() const { return m_type == Type::LineBreakBox; }
75
    bool isLineBreak() const { return isSoftLineBreak() || isLineBreakBox(); }
76
    bool isAtomicInlineLevelBox() const { return m_type == Type::AtomicInlineLevelBox; }
77
    bool isInlineBox() const { return isNonRootInlineBox() || isRootInlineBox(); }
78
    bool isNonRootInlineBox() const { return m_type == Type::NonRootInlineBox; }
79
    bool isRootInlineBox() const { return m_type == Type::RootInlineBox; }
80
    bool isGenericInlineLevelBox() const { return m_type == Type::GenericInlineLevelBox; }
81
    bool isInlineLevelBox() const { return isAtomicInlineLevelBox() || isLineBreakBox() || isInlineBox() || isGenericInlineLevelBox(); }
82
    bool isNonRootInlineLevelBox() const { return isInlineLevelBox() && !isRootInlineBox(); }
83
    Type type() const { return m_type; }
84
85
    bool hasContent() const { return m_hasContent; }
86
87
    const InlineRect& logicalRect() const { return m_logicalRect; }
88
    const InlineRect& inkOverflow() const { return m_inkOverflow; }
89
90
    InlineLayoutUnit logicalTop() const { return logicalRect().top(); }
91
    InlineLayoutUnit logicalBottom() const { return logicalRect().bottom(); }
92
    InlineLayoutUnit logicalLeft() const { return logicalRect().left(); }
93
    InlineLayoutUnit logicalRight() const { return logicalRect().right(); }
94
95
    InlineLayoutUnit logicalWidth() const { return logicalRect().width(); }
96
    InlineLayoutUnit logicalHeight() const { return logicalRect().height(); }
97
98
    void moveVertically(InlineLayoutUnit offset) { m_logicalRect.moveVertically(offset); }
99
    void adjustInkOverflow(const InlineRect& childBorderBox) { return m_inkOverflow.expandToContain(childBorderBox); }
100
101
    std::optional<Text>& text() { return m_text; }
102
    const std::optional<Text>& text() const { return m_text; }
103
104
    struct Expansion {
105
        ExpansionBehavior behavior { DefaultExpansion };
106
        InlineLayoutUnit horizontalExpansion { 0 };
107
    };
108
    Expansion expansion() const { return m_expansion; }
109
110
    const Box& layoutBox() const { return *m_layoutBox; }
111
    const RenderStyle& style() const { return layoutBox().style(); }
112
113
    size_t lineIndex() const { return m_lineIndex; }
114
115
private:
116
    const size_t m_lineIndex { 0 };
117
    const Type m_type { Type::GenericInlineLevelBox };
118
    WeakPtr<const Layout::Box> m_layoutBox;
119
    InlineRect m_logicalRect;
120
    InlineRect m_inkOverflow;
121
    bool m_hasContent { true };
122
    Expansion m_expansion;
123
    std::optional<Text> m_text;
124
};
125
126
inline Run::Run(size_t lineIndex, Type type, const Layout::Box& layoutBox, const InlineRect& logicalRect, const InlineRect& inkOverflow, Expansion expansion, std::optional<Text> text, bool hasContent)
127
    : m_lineIndex(lineIndex)
128
    , m_type(type)
129
    , m_layoutBox(makeWeakPtr(layoutBox))
130
    , m_logicalRect(logicalRect)
131
    , m_inkOverflow(inkOverflow)
132
    , m_hasContent(hasContent)
133
    , m_expansion(expansion)
134
    , m_text(text)
135
{
136
}
137
138
inline Run::Text::Text(size_t start, size_t length, const String& originalContent, String adjustedContentToRender, bool hasHyphen)
139
    : m_start(start)
140
    , m_length(length)
141
    , m_hasHyphen(hasHyphen)
142
    , m_originalContent(originalContent)
143
    , m_adjustedContentToRender(adjustedContentToRender)
144
{
145
}
146
147
}
148
}
149
#endif
- a/Source/WebCore/layout/formattingContexts/inline/display/InlineLineGeometry.h +83 lines
Line 0 a/Source/WebCore/layout/formattingContexts/inline/display/InlineLineGeometry.h_sec1
1
/*
2
 * Copyright (C) 2020 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
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
29
30
#include "InlineRect.h"
31
32
namespace WebCore {
33
namespace Layout {
34
35
class LineGeometry {
36
    WTF_MAKE_FAST_ALLOCATED;
37
public:
38
    struct EnclosingTopAndBottom {
39
        // This values encloses the root inline box and any other inline level box's border box.
40
        InlineLayoutUnit top { 0 };
41
        InlineLayoutUnit bottom { 0 };
42
    };
43
    LineGeometry(const InlineRect& lineBoxLogicalRect, const InlineRect& scrollableOverflow, EnclosingTopAndBottom, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth);
44
45
    const InlineRect& lineBoxLogicalRect() const { return m_lineBoxLogicalRect; }
46
    const InlineRect& scrollableOverflow() const { return m_scrollableOverflow; }
47
48
    EnclosingTopAndBottom enclosingTopAndBottom() const { return m_enclosingTopAndBottom; }
49
50
    InlineLayoutUnit baseline() const { return m_aligmentBaseline; }
51
52
    InlineLayoutUnit contentLogicalLeft() const { return m_contentLogicalLeft; }
53
    InlineLayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; }
54
55
    void moveVertically(InlineLayoutUnit offset) { m_lineBoxLogicalRect.moveVertically(offset); }
56
57
private:
58
    // This is line box geometry (see https://www.w3.org/TR/css-inline-3/#line-box).
59
    InlineRect m_lineBoxLogicalRect;
60
    InlineRect m_scrollableOverflow;
61
    // Enclosing top and bottom includes all inline level boxes (border box) vertically.
62
    // While the line box usually enclose them as well, its vertical geometry is based on
63
    // the layout bounds of the inline level boxes which may be different when line-height is present.
64
    EnclosingTopAndBottom m_enclosingTopAndBottom;
65
    InlineLayoutUnit m_aligmentBaseline { 0 };
66
    InlineLayoutUnit m_contentLogicalLeft { 0 };
67
    InlineLayoutUnit m_contentLogicalWidth { 0 };
68
};
69
70
inline LineGeometry::LineGeometry(const InlineRect& lineBoxLogicalRect, const InlineRect& scrollableOverflow, EnclosingTopAndBottom enclosingTopAndBottom, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth)
71
    : m_lineBoxLogicalRect(lineBoxLogicalRect)
72
    , m_scrollableOverflow(scrollableOverflow)
73
    , m_enclosingTopAndBottom(enclosingTopAndBottom)
74
    , m_aligmentBaseline(aligmentBaseline)
75
    , m_contentLogicalLeft(contentLogicalLeft)
76
    , m_contentLogicalWidth(contentLogicalWidth)
77
{
78
}
79
80
}
81
}
82
83
#endif
- a/Source/WebCore/layout/formattingContexts/inline/display/InlineLineRun.h +149 lines
Line 0 a/Source/WebCore/layout/formattingContexts/inline/display/InlineLineRun.h_sec1
1
/*
2
 * Copyright (C) 2020 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
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
29
30
#include "InlineRect.h"
31
#include "LayoutBox.h"
32
#include "TextFlags.h"
33
34
namespace WebCore {
35
namespace Layout {
36
37
struct Run {
38
    WTF_MAKE_STRUCT_FAST_ALLOCATED;
39
    struct Text {
40
        WTF_MAKE_STRUCT_FAST_ALLOCATED;
41
    public:
42
        Text(size_t position, size_t length, const String& originalContent, String adjustedContentToRender = String(), bool hasHyphen = false);
43
44
        size_t start() const { return m_start; }
45
        size_t end() const { return start() + length(); }
46
        size_t length() const { return m_length; }
47
        StringView originalContent() const { return StringView(m_originalContent).substring(m_start, m_length); }
48
        StringView renderedContent() const { return m_adjustedContentToRender.isNull() ? originalContent() : m_adjustedContentToRender; }
49
50
        bool hasHyphen() const { return m_hasHyphen; }
51
52
    private:
53
        size_t m_start { 0 };
54
        size_t m_length { 0 };
55
        bool m_hasHyphen { false };
56
        String m_originalContent;
57
        String m_adjustedContentToRender;
58
    };
59
60
    enum class Type {
61
        Text,
62
        SoftLineBreak,
63
        LineBreakBox,
64
        AtomicInlineLevelBox,
65
        NonRootInlineBox,
66
        RootInlineBox,
67
        GenericInlineLevelBox
68
    };
69
    struct Expansion;
70
    Run(size_t lineIndex, Type, const Box&, const InlineRect&, const InlineRect& inkOverflow, Expansion, std::optional<Text> = std::nullopt, bool hasContent = true);
71
72
    bool isText() const { return m_type == Type::Text; }
73
    bool isSoftLineBreak() const { return m_type == Type::SoftLineBreak; }
74
    bool isLineBreakBox() const { return m_type == Type::LineBreakBox; }
75
    bool isLineBreak() const { return isSoftLineBreak() || isLineBreakBox(); }
76
    bool isAtomicInlineLevelBox() const { return m_type == Type::AtomicInlineLevelBox; }
77
    bool isInlineBox() const { return isNonRootInlineBox() || isRootInlineBox(); }
78
    bool isNonRootInlineBox() const { return m_type == Type::NonRootInlineBox; }
79
    bool isRootInlineBox() const { return m_type == Type::RootInlineBox; }
80
    bool isGenericInlineLevelBox() const { return m_type == Type::GenericInlineLevelBox; }
81
    bool isInlineLevelBox() const { return isAtomicInlineLevelBox() || isLineBreakBox() || isInlineBox() || isGenericInlineLevelBox(); }
82
    bool isNonRootInlineLevelBox() const { return isInlineLevelBox() && !isRootInlineBox(); }
83
    Type type() const { return m_type; }
84
85
    bool hasContent() const { return m_hasContent; }
86
87
    const InlineRect& logicalRect() const { return m_logicalRect; }
88
    const InlineRect& inkOverflow() const { return m_inkOverflow; }
89
90
    InlineLayoutUnit logicalTop() const { return logicalRect().top(); }
91
    InlineLayoutUnit logicalBottom() const { return logicalRect().bottom(); }
92
    InlineLayoutUnit logicalLeft() const { return logicalRect().left(); }
93
    InlineLayoutUnit logicalRight() const { return logicalRect().right(); }
94
95
    InlineLayoutUnit logicalWidth() const { return logicalRect().width(); }
96
    InlineLayoutUnit logicalHeight() const { return logicalRect().height(); }
97
98
    void moveVertically(InlineLayoutUnit offset) { m_logicalRect.moveVertically(offset); }
99
    void adjustInkOverflow(const InlineRect& childBorderBox) { return m_inkOverflow.expandToContain(childBorderBox); }
100
101
    std::optional<Text>& text() { return m_text; }
102
    const std::optional<Text>& text() const { return m_text; }
103
104
    struct Expansion {
105
        ExpansionBehavior behavior { DefaultExpansion };
106
        InlineLayoutUnit horizontalExpansion { 0 };
107
    };
108
    Expansion expansion() const { return m_expansion; }
109
110
    const Box& layoutBox() const { return *m_layoutBox; }
111
    const RenderStyle& style() const { return layoutBox().style(); }
112
113
    size_t lineIndex() const { return m_lineIndex; }
114
115
private:
116
    const size_t m_lineIndex { 0 };
117
    const Type m_type { Type::GenericInlineLevelBox };
118
    WeakPtr<const Layout::Box> m_layoutBox;
119
    InlineRect m_logicalRect;
120
    InlineRect m_inkOverflow;
121
    bool m_hasContent { true };
122
    Expansion m_expansion;
123
    std::optional<Text> m_text;
124
};
125
126
inline Run::Run(size_t lineIndex, Type type, const Layout::Box& layoutBox, const InlineRect& logicalRect, const InlineRect& inkOverflow, Expansion expansion, std::optional<Text> text, bool hasContent)
127
    : m_lineIndex(lineIndex)
128
    , m_type(type)
129
    , m_layoutBox(makeWeakPtr(layoutBox))
130
    , m_logicalRect(logicalRect)
131
    , m_inkOverflow(inkOverflow)
132
    , m_hasContent(hasContent)
133
    , m_expansion(expansion)
134
    , m_text(text)
135
{
136
}
137
138
inline Run::Text::Text(size_t start, size_t length, const String& originalContent, String adjustedContentToRender, bool hasHyphen)
139
    : m_start(start)
140
    , m_length(length)
141
    , m_hasHyphen(hasHyphen)
142
    , m_originalContent(originalContent)
143
    , m_adjustedContentToRender(adjustedContentToRender)
144
{
145
}
146
147
}
148
}
149
#endif

Return to Bug 230632