Adding elements to contenteditable DOM in designMode will cause the -moz-read-write state not to update properly

VERIFIED FIXED in Firefox 7

Status

()

Core
DOM
VERIFIED FIXED
6 years ago
6 years ago

People

(Reporter: Ehsan, Assigned: Ehsan)

Tracking

({regression})

Trunk
mozilla8
regression
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox7+ fixed)

Details

Attachments

(2 attachments, 1 obsolete attachment)

Created attachment 546961 [details]
Testcase

See the attached testcase.

This is a regression from http://hg.mozilla.org/mozilla-central/rev/5ad2fcf8d9ed I believe.  This is the code responsible:  http://hg.mozilla.org/mozilla-central/annotate/aa2de73abc19/content/base/src/nsGenericElement.cpp#l1236

Boris, what was the reason for this optimization?  This has the potential of breaking editor operations _very_ badly (such as pressing backspace at the end of a paragraph deleting the whole paragraph because it's treated as a contenteditable=false section.)
The reason for the optimization is that calling UpdateState on a link is astronomically expensive.   I have a proposal to maybe fix that at http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/eb0a9472df8c0593/30fd10ec83f48a2a but it hasn't happened yet.

That said, what's breaking in this case?  Let me take a look.
In particular, I see us enter this function with aNotify == false, oldEditable != newEditable, and newEditable == true, so we remove the READONLY state and add the READWRITE state.

If I remove the "skip calling UpdateState if !aNotify" optimization, the bug remains.

If I remove the "skip messing with state if oldEditable != newEditable" optimization then the bug remains.....
And in fact, what's happening in that testcase is that the <body> is readonly, so gets styled with a red color and there are no other color styles around, so the red inherits into everything...
OS: Mac OS X → All
Hardware: x86 → All
Created attachment 547115 [details]
Testcase

Sorry, I uploaded the wrong version of the testcase (setting designMode to "true" doesn't work).

The bug happens because of the comparison of oldEditable and newEditable.  In this scenario, oldEditable is true because the document has the NODE_IS_EDITABLE flag, and newEditable is true because the node has the NODE_IS_EDITABLE flag.  But we think that we can skip updating the readonly/readwrite intrinsic states, so we end up with the p being readonly, which causes the editor to treat it as a contenteditable=false block, which leads to very bad results.
Assignee: nobody → ehsan
Status: NEW → ASSIGNED
Attachment #546961 - Attachment is obsolete: true
We need to fix this on Aurora too.
tracking-firefox7: --- → ?
Created attachment 547162 [details] [diff] [review]
Patch (v1)
Attachment #547162 - Flags: review?(bzbarsky)
Comment on attachment 547162 [details] [diff] [review]
Patch (v1)

r=me
Attachment #547162 - Flags: review?(bzbarsky) → review+
Comment on attachment 547162 [details] [diff] [review]
Patch (v1)

This patch is rather low-risk here.  We definitely want this on Aurora, otherwise the HTML editor might be broken in unexpected and major ways.
Attachment #547162 - Flags: approval-mozilla-aurora?
http://hg.mozilla.org/mozilla-central/rev/579944e7e8f7
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
status-firefox7: --- → affected
Flags: in-testsuite+
Comment on attachment 547162 [details] [diff] [review]
Patch (v1)

a=me for aurora, but this is a regression from what looks like a pretty large landing - if we see more regressions coming from that, we're going to want to look at backing out the original offender on aurora instead of chasing clean up fixes.
Attachment #547162 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
http://hg.mozilla.org/releases/mozilla-aurora/rev/8d1b66d7fb5b
status-firefox7: affected → fixed

Updated

6 years ago
tracking-firefox7: ? → +
Mozilla/5.0 (Windows NT 6.1; rv:7.0) Gecko/20100101 Firefox/7.0
Mozilla/5.0 (Windows NT 6.1; rv:9.0a1) Gecko/20110818 Firefox/9.0a1

I cannot reproduce the issue.
Was it Fixed?
Thanks!
Yes, this has been fixed in Firefox 7 and above.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.