Skip to content

Commit 7594f89

Browse files
committed
text-indent not working on contenteditable elements in Safari 26.2
https://bugs.webkit.org/show_bug.cgi?id=307125 <rdar://problem/170280101> Reviewed by Antti Koivisto. 1. text-indent relies on 'isFirstFormattedLineCandidate' 2. isFirstFormattedLineCandidate checks if there's a valid previousLine (std::optional<PreviousLine> When partial layout starts from the first line (damage is either on the first or the second line), we should just have std::null_opt as PreviousLine. Test: fast/text/partial-layout-with-text-indent.html * LayoutTests/fast/text/partial-layout-with-text-indent-expected.html: Added. * LayoutTests/fast/text/partial-layout-with-text-indent.html: Added. * Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp: (WebCore::Layout::InlineFormattingContext::layout): Canonical link: https://commits.webkit.org/307646@main
1 parent a770c44 commit 7594f89

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<style>
2+
div {
3+
text-indent: 20px;
4+
border: 1px solid green;
5+
width: 200px;
6+
height: 400px;
7+
font-family: Ahem;
8+
}
9+
</style>
10+
<div id=change_this class="editable" contenteditable="true"> some text</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<style>
2+
div {
3+
text-indent: 20px;
4+
border: 1px solid green;
5+
width: 200px;
6+
height: 400px;
7+
font-family: Ahem;
8+
}
9+
</style>
10+
<div id=change_this class="editable" contenteditable="true"> some </div>
11+
<script>
12+
document.body.offsetHeight;
13+
change_this.appendChild(document.createTextNode("text"));
14+
</script>

Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ std::unique_ptr<InlineLayoutResult> InlineFormattingContext::layout(const Constr
158158
ASSERT_NOT_REACHED();
159159
return { };
160160
}
161+
if (!lineDamage->layoutStartPosition()->lineIndex)
162+
return { };
161163
auto lastLineIndex = lineDamage->layoutStartPosition()->lineIndex - 1;
162164
// FIXME: We should be able to extract the last line information and provide it to layout as "previous line" (ends in line break and inline direction).
163165
return PreviousLine { lastLineIndex, { }, { }, { }, { } };

0 commit comments

Comments
 (0)