Closed Bug 1658302 Opened 4 years ago Closed 4 years ago

Changing the `placeholder` property of the input cause loss of editing history.

Categories

(Core :: DOM: Editor, defect, P3)

Firefox 81
defect

Tracking

()

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: nayinain, Assigned: emilio)

References

Details

Attachments

(2 files, 1 obsolete file)

Attached file testcase.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0

Steps to reproduce:

  1. Open the testcase.html
  2. Delete the text in input 1 or textarea 1.
  3. Undo (<kbd>Ctrl + Z</kbd>) the changes.

Actual results:

Cannot undo changes.

Expected results:

Can undo the changes.

Has STR: --- → yes

The issue already exists in Firefox 4.

:nayinain, if you think that's a regression, then could you try to find a regression range in using for example mozregression?

It seems that editor instance is recreated when placeholder attribute is changed.
https://searchfox.org/mozilla-central/rev/ab81b8552f4aa9696a2524f97fdfeb59d4dc31c1/dom/html/HTMLInputElement.cpp#5181-5182
If so, editor is recreated without previous transaction.

emilio: Any ideas?

Flags: needinfo?(emilio)

Changing the placeholder attribute reconstruct the layout frame.

Same seems happens if instead of changing placeholder I toggle .style.display, fwiw.

We don't seem to preserve the editing history across reframes, which seems a bit unexpected? Masayuki, do you know what is the background for this if any?

For this specific case, we probably can avoid reframing by incrementally updating the textnode in nsTextControlFrame::CreatePlaceholderIfNeeded (and only reframe if it's an addition / removal). But the root cause is ^ I think.

Flags: needinfo?(emilio) → needinfo?(masayuki)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #4)

We don't seem to preserve the editing history across reframes, which seems a bit unexpected? Masayuki, do you know what is the background for this if any?

As this bug reported, I feel it's unexpected behavior setting placeholder value resets editor transactions (if I were a web app developer).

For this specific case, we probably can avoid reframing by incrementally updating the textnode in nsTextControlFrame::CreatePlaceholderIfNeeded (and only reframe if it's an addition / removal). But the root cause is ^ I think.

Yeah, I also guessed that the root cause is difficult to fix. I think that we don't need to fix only specific cases. So, perhaps, we should do it if actual web-compat issue is reported.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(masayuki)
Priority: -- → P3
Assignee: nobody → emilio
Flags: needinfo?(emilio)

We still reframe for additions / removals of the attribute because that
makes us create the placeholder <div>. We could avoid it if we created
it independently of the presence of the attribute but that seems like it
could regress perf for the case where there's no placeholder attribute,
which is probably common enough.

Flags: needinfo?(emilio)

There's nothing in nsFileControlFrame that would change the frame tree
depending on these attributes.

Attachment #9172878 - Attachment is obsolete: true
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0e94014166b3 Don't reframe for changes to the placeholder attribute value. r=masayuki
Blocks: 1659126
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
Backout by apavel@mozilla.com: https://hg.mozilla.org/mozilla-central/rev/4a18696ce81f Backed out changeset 0e94014166b3 for causing bug 1662483
Status: RESOLVED → REOPENED
Flags: needinfo?(emilio)
Resolution: FIXED → ---
Target Milestone: 82 Branch → ---
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/aa4266b83461 Don't reframe for changes to the placeholder attribute value. r=masayuki
Flags: needinfo?(emilio)
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/25348 for changes under testing/web-platform/tests
Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: