Open Bug 2089955 Opened 17 days ago

Remove the dead aChild null check in HTMLEditor::ContentWillBeRemoved

Categories

(Core :: DOM: Editor, task)

task

Tracking

()

People

(Reporter: Sylvestre, Unassigned, Mentored)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug, Whiteboard: [lang=c++])

Filing as a good first bug to learn workflows.

aChild is dereferenced earlier in this function (aChild->GetParentNode()), and a mutation observer is never called with a null child. Drop the aChild && part of the condition below.

Current code:

  if (!GetTopLevelEditSubAction() && aChild->GetParentNode()->IsEditable()) {
    if (aChild && EditorUtils::IsPaddingBRElementForEmptyEditor(*aChild)) {
      // Ignore removal of the padding <br> element for empty editor.

Link to the code:
https://searchfox.org/firefox-main/source/editor/libeditor/HTMLEditorMutationObserver.cpp

To verify the fix:

./mach build
./mach test editor/libeditor/tests --headless

This was reported by Coverity Scan (CID 1655218). The analyzer will stop reporting it once the change lands.

Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html

Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.

You need to log in before you can comment on or make changes to this bug.