Closed Bug 2006520 Opened 3 months ago Closed 3 months ago

`TextInputListener::OnEditActionHandled` should notify ` the text control element even if no frame

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED FIXED
148 Branch
Tracking Status
firefox148 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(1 file)

Currently,

nsresult TextInputListener::OnEditActionHandled(TextEditor& aTextEditor) {
  if (mFrame) {
    // XXX Do we still need this or can we just remove the mFrame and
    // frame.IsAlive() conditions below?
    AutoWeakFrame weakFrame = mFrame;

    // Update the undo / redo menus
    //
    size_t numUndoItems = aTextEditor.NumberOfUndoItems();
    size_t numRedoItems = aTextEditor.NumberOfRedoItems();
    if ((numUndoItems && !mHadUndoItems) || (!numUndoItems && mHadUndoItems) ||
        (numRedoItems && !mHadRedoItems) || (!numRedoItems && mHadRedoItems)) {
      // Modify the menu if undo or redo items are different
      UpdateTextInputCommands(u"undo"_ns);

      mHadUndoItems = numUndoItems != 0;
      mHadRedoItems = numRedoItems != 0;
    }

    if (weakFrame.IsAlive()) {
      HandleValueChanged(aTextEditor);
    }
  }

  return mTextControlState ? mTextControlState->OnEditActionHandled() : NS_OK;
}

TextInputListener::HandleValueChanged calls TextControlElement::OnValueChanged which updates the element state. Therefore, it does not directly require the frame. Additionally, if the frame is destroyed during TextEditor does something, the text control element may not receive the value change within this path. So, it might cause mismatch between the element state and the latest value.

It's called by TextEditor after (maybe) modifying the value before
dispatching input event.

First, it updates the enabled state of the undo/redo commands. However,
it's managed by the window. Therefore, it does not make sense to depend
on the frame.

Then, it updates the various state of the related objects. For making
them work with destroyed TextEditor, this patch makes TextEditor
keep storing the latest value with caching the Text while it's
handling something.

Duplicate of this bug: 1992044
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
QA Whiteboard: [qa-triage-done-c149/b148]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: