Closed Bug 1788840 Opened 3 years ago Closed 3 years ago

HTMLEditor::HandleCSSIndentAroundRanges should not use moved variable

Categories

(Core :: DOM: Editor, defect)

Unspecified
All
defect

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: m_kato, Assigned: masayuki)

Details

Attachments

(1 file)

I guess I overlook Bug 1774704's review.

https://searchfox.org/mozilla-central/rev/2c8fa11af2d6e795c99ebe395d39390fde47df85/editor/libeditor/HTMLEditSubActionHandler.cpp#4398-4404

    const EditorDOMPoint pointToInsertDivElement =
        pointToPutCaret.IsSet()
            ? std::move(pointToPutCaret)
            : aRanges.GetFirstRangeStartPoint<EditorDOMPoint>();

So pointToPutCaret is moved, so it may become nothing value. But we re-use pointToPutCaret at next.

    if (NS_WARN_IF(!pointToPutCaret.IsSet())) {
      return NS_ERROR_FAILURE;
    }
Severity: -- → S3

Oh, indeed, it should check pointToInsertDivElement.IsSet() instead.

Unfortunately, the result is really different from the other browsers.
E.g., when execCommand("indent") at <div>abc<br>{}<br></div>, Gecko inserts
a <div> and set its margin-left. However, Chrome splits parent <div>
element and wrap the <div> which contains the caret in new <blockquote>.
Therefore, this does not contain new WPT.

Depends on D157404

Assignee: nobody → masayuki
Status: NEW → ASSIGNED
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/343bf04a54ba Make `HTMLEditor::HandleCSSIndentAroundRanges` stop referring moved `EditorDOMPoint` r=m_kato
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: