Closed Bug 1951039 Opened 1 year ago Closed 1 year ago

Remove unnecessary `InsertPaddingBRElementIfNeeded` callers if it's inserted only for making the trailing white-space visible

Categories

(Core :: DOM: Editor, task)

task

Tracking

()

RESOLVED FIXED
142 Branch
Tracking Status
firefox142 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(2 files)

It's also used for making empty block has one-line-height. Therefore, we may not be able to delete the callers a lot, but at least the inserting content handlers don't need it, I guess.

It seems that the method callers keep calling it for putting a <br> for making an empty block visible. However, we can make the helper methods of it stop handling collapsible white-spaces.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED

The new white-space normalizer always makes the last white-space as
an NBSP if it should be visible but white-spaces are collapsible.
Therefore, the method won't be used for putting a padding <br> to
make the preceding collapsible white-space visible. So, it does not
need to check the case anymore.

HTMLEditUtils::GetElementOfImmediateBlockBoundary() refers
CharacterData::TextIsOnlyWhitespace(), but it may return false if
the text node is marked as "may have non-ASCII character" [1].

Therefore, it should scan the text data correctly. This patch adds
nsTextFragment methods for faster scan. The behavior is based on
FindChar() and RFindChar() of the XPCOM string classes especially
about the start offset.

We should make HTMLEditor code use the new methods more in a follow
up bug.

  1. https://searchfox.org/mozilla-central/rev/db42cf091b40365ba4de898da3ae54aac66544f9/dom/base/CharacterData.cpp#534-541
Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/08c1346ef836 https://hg.mozilla.org/integration/autoland/rev/9b04407fbce0 part 1: Make `HTMLEditUtils::LineRequiresPaddingLineBreakToBeVisible` stop handling trailing collapsible white-spaces r=m_kato https://github.com/mozilla-firefox/firefox/commit/e843c3f2f1f2 https://hg.mozilla.org/integration/autoland/rev/9bd068fe45e0 part 2: Make `HTMLEditUtils::GetElementOfImmediateBlockBoundary` scan text data strictly r=m_kato,jjaschke,dom-core
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 142 Branch
QA Whiteboard: [qa-triage-done-c143/b142]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: