Closed Bug 1935923 Opened 2 months ago Closed 2 months ago

Make `<br>` elemnet inserters of `HTMLEditor` aware of preformatted line break too

Categories

(Core :: DOM: Editor, task)

task

Tracking

()

RESOLVED FIXED
135 Branch
Tracking Status
firefox135 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(5 files)

In bug 1935065, HTMLEditor will have LineBreakType. Therefore, if we make the <br> element inserters take a LineBreakType parameter, we can make each caller consider the line break type with GetPreferrredLineBreakType if and only if the caller may need to insert a preformatted linefeed.

For making most callers can insert either <br> or a preformatted linefeed,
the inserter should handle both of them.

This patch makes PrepareToInsertLineBreak which is renamed from
PrepareToInsertBRElement to check whether the container can have the new
line break. Then, one test starts failing, but it's okay because it's a
test in <xmp> which cannot have any elements, so, <xmp> is super legacy
element and must not be used in these days especially in editable content.

Depends on D231655

Although this fixes a logical bug of the cases when aPointToInsert is in an
inline element. I'm not sure how to reproduce the case because it's only caller
is the post processor, HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal.
So, this bug could be reproducible only when the delete handler forgets to
clean up ancestor empty inline elements. So, I guess that this patch does
not change the behavior in the most cases.

Note that as I commented in bug 1936193, padding line break should always be
<br> for avoiding them appear in .textContent value. Therefore, this
method should not take LineBreakType.

Depends on D231657

Its only caller is MaybeInsertPaddingBRElementForEmptyLastLineAtSelection
which just handles Selection. Now, we have enough simpler utilities to
access Selection. Therefore, we can get rid of the caller. Then, we can
reduce the number of selection update in
HTMLEditor::FormatBlockContainerAsSubAction and AlignAsSubAction.

Note that as I commented in bug 1936193, padding line break should always be
<br> for avoiding them appear in .textContent value. Therefore, this
method should not take LineBreakType.

Depends on D231658

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/552b6c2fdc22 part 1: Change `HTMLEditor::InsertBRElement` to `InsertLineBreak` r=m_kato https://hg.mozilla.org/integration/autoland/rev/b3b42030356f part 2: Change `WhiteSpaceVisibilityKeeper::InsertBRElement` to `InsertLineBreak` like `HTMLEditor` r=m_kato https://hg.mozilla.org/integration/autoland/rev/e23ec9a7919d part 3: Change `HTMLEditor::InsertBRElementIfHardLineIsEmptyAndEndsWithBlockBoundary` to `InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded` r=m_kato https://hg.mozilla.org/integration/autoland/rev/95c8aa202651 part 4: Change `HTMLEditor::InsertPaddingBRElementForEmptyLastLineIfNeeded` to `InsertPaddingBRElementIfInEmptyBlock` r=m_kato https://hg.mozilla.org/integration/autoland/rev/7c5e9c2afd3b part 5: Make `HTMLEditor::InsertPaddingBRElementIfNeeded` return `CreateLineBreakResult` r=m_kato

Backed out for causing build bustages @ EditorLineBreak.h

/builds/worker/checkouts/gecko/editor/libeditor/EditorLineBreak.h:300:38: error: call to non-'constexpr' function 'nsIContent& mozilla::EditorLineBreakBase<CT>::ContentRef() const [with ContentType = nsCOMPtr<nsIContent>]'
Flags: needinfo?(masayuki)
Flags: needinfo?(masayuki)
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/24527c9e2d79 part 1: Change `HTMLEditor::InsertBRElement` to `InsertLineBreak` r=m_kato https://hg.mozilla.org/integration/autoland/rev/5ada411cd298 part 2: Change `WhiteSpaceVisibilityKeeper::InsertBRElement` to `InsertLineBreak` like `HTMLEditor` r=m_kato https://hg.mozilla.org/integration/autoland/rev/11fa2fe306cb part 3: Change `HTMLEditor::InsertBRElementIfHardLineIsEmptyAndEndsWithBlockBoundary` to `InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded` r=m_kato https://hg.mozilla.org/integration/autoland/rev/d9aca93f476b part 4: Change `HTMLEditor::InsertPaddingBRElementForEmptyLastLineIfNeeded` to `InsertPaddingBRElementIfInEmptyBlock` r=m_kato https://hg.mozilla.org/integration/autoland/rev/5329436a678c part 5: Make `HTMLEditor::InsertPaddingBRElementIfNeeded` return `CreateLineBreakResult` r=m_kato
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: