Closed Bug 565611 Opened 15 years ago Closed 14 years ago

"ASSERTION: How did that happen?: 'form == aThisForm'" with <legend>

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- beta1+

People

(Reporter: jruderman, Assigned: mounir)

References

Details

(Keywords: assertion, regression, testcase)

Attachments

(2 files, 3 obsolete files)

Attached file testcase
###!!! ASSERTION: How did that happen?: 'form == aThisForm', file /home/jruderman/mozilla-central/content/html/content/src/nsHTMLFormElement.cpp, line 513 I think this is a very recent regression.
The assertion happens when you close the window containing the testcase, or something like that.
Presumably a regression from bug 555567.
Assignee: nobody → mounir.lamouri
Blocks: 555567
blocking2.0: --- → ?
I confirm that's a regression from bug 555567. mForm is set to the parent form but GetForm() return a the form of the parent fieldset element. If there is no fieldset element, mForm is set to the parent but GetForm() returns null. Actually, nsHTMLLegendElement shouldn't be a nsGenericHTMLFormElement. It's not submittable, not labelable, not listed, not resettable. It's more like an option element with a form attribute. Thank you for your report Jesse :)
Status: NEW → ASSIGNED
Attached patch Patch v1 (obsolete) — Splinter Review
With this patch, nsHTMLLegendElement is not a form element anymore. The behavior did not changed so I don't see any test. Boris, let me know if you have not enough time to review this patch.
Attachment #445223 - Flags: review?(bzbarsky)
Comment on attachment 445223 [details] [diff] [review] Patch v1 r=bzbarsky
Attachment #445223 - Flags: review?(bzbarsky) → review+
Actually, hold on. Did you check all the eHTML_FORM_CONTROL consumers? In particular, can <legend> ever be focusable? What happens if a <label> is labeling a legend?
(In reply to comment #6) > Actually, hold on. Did you check all the eHTML_FORM_CONTROL consumers? In > particular, can <legend> ever be focusable? What happens if a <label> is > labeling a legend? <legend> is not labelable nor focusable. The user should not be able to interact with <legend>. By the way, maybe be we could remove ::Focus and ::PerformAccessKey from nsHTMLLegend ?
> <legend> is not labelable nor focusable. Everything can be focusable. Just set a tabindex. And it seems like <legend> has a pretty consciously chosen ::Focus behavior when it's not focusable, no? Why would you want to break that?
(In reply to comment #8) > > <legend> is not labelable nor focusable. > > Everything can be focusable. Just set a tabindex. > > And it seems like <legend> has a pretty consciously chosen ::Focus behavior > when it's not focusable, no? Why would you want to break that? Indeed, everything is focusable with tabindex, I forget that. I was reading bug 81481 and realized ::Focus has a reason to exist. It's quite hard to find the corresponding HTML5 specification by the way. Anyway, that means the current patch is correct, right ?
OS: Linux → All
Hardware: x86_64 → All
Attachment #445223 - Flags: superreview?(Olli.Pettay)
(In reply to comment #6) > Actually, hold on. Did you check all the eHTML_FORM_CONTROL consumers? In > particular, can <legend> ever be focusable? What happens if a <label> is > labeling a legend? I'm assuming everything is okay regarding the focus (as far as I've checked/tested). For the labeling, as legend is not labelable, it's okay. Can you confirm that, Boris ?
So why is legend not labelable? Would it make sense for it to be? As in, should we ask for a spec change? What makes the most sense for web authors? Note that in our current code it's labelable but the label's action doesn't call focus() and the focus manager doesn't seem to have the label special-case.
(In reply to comment #11) > So why is legend not labelable? Would it make sense for it to be? As in, > should we ask for a spec change? What makes the most sense for web authors? > > Note that in our current code it's labelable but the label's action doesn't > call focus() and the focus manager doesn't seem to have the label special-case. I don't think it would make sense to have a labelable <legend> as <legend> is already a kind of "special label" for the <fieldset>. I don't see what information the label could add to the legend.
Hmm. OK, good point.
OK, so did you audit the other HTML_FORM_CONTROL consumers like I asked you to? At least for the nsDOMClassInfo one it looks like the patch you attached will give the wrong behavior, no?
(In reply to comment #14) > OK, so did you audit the other HTML_FORM_CONTROL consumers like I asked you to? > At least for the nsDOMClassInfo one it looks like the patch you attached will > give the wrong behavior, no? I checked or tested everything. For nsDOMClassInfo, I do not really get what could be wrong. |WrapNative| wouldn't be called anymore for <legend> and the parent would be the document instead of the form but is that an issue ?
> I checked or tested everything. Do we have existing tests for those codepaths? If not, how did you test? Is the new behavior definitely better in all cases? I'd appreciate a quick summary of why the change is ok or an improvement at all the callsites so I don't have to go through them all myself. > but is that an issue ? I'd think so. Consider this testcase: <form> <input name="x"> <fieldset> <legend onclick="try{ alert(x); } catch(e) { alert(e); }"> Click me and see what happens </legend> </fieldset> </form> At the moment, behavior on this testcase is interoperable at least in Chrome, Safari, Opera, and Firefox. Does your patch not break it?
http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsGenericHTMLElement.cpp#2271 http://mxr.mozilla.org/mozilla-central/source/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp#186 -> obviously doesn't change nothing http://mxr.mozilla.org/mozilla-central/source/embedding/components/find/src/nsFind.cpp#342 -> <legend> isn't a text control so it only make us leave the function sooner http://mxr.mozilla.org/mozilla-central/source/dom/base/nsFocusManager.cpp#1928 -> there is no caret in <legend> http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsHTMLLabelElement.cpp#399 -> <legend> isn't labelable http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsNodeUtils.cpp#244 -> <legend> isn't linked to the form http://mxr.mozilla.org/mozilla-central/source/content/html/document/src/nsHTMLDocument.cpp#2863 is used here http://mxr.mozilla.org/mozilla-central/source/content/html/document/src/nsHTMLDocument.cpp#2870 so we probably don't care for <legend> http://mxr.mozilla.org/mozilla-central/source/content/events/src/nsEventStateManager.cpp#2367 -> the <legend> frame is a text frame so it will not change anything http://mxr.mozilla.org/mozilla-central/source/layout/base/nsBidiPresUtils.cpp#418 -> for this one, I've put a breakpoint to see if we were going through line 418 with a <legend> and i didn't found a case where we were. In other words, |IsVisualMode()| was always returning false. I'm wondering if it could returns 'true' and break things sometimes... http://mxr.mozilla.org/mozilla-central/source/dom/base/nsFocusManager.cpp#2074 -> focus seems to work as expected for <legend> so I suppose it isn't breaking anything here but I wasn't able to test.
Attached patch nsDOMClassInfo patch (obsolete) — Splinter Review
Does this patch would be correct for you Boris ? (to fix the scope issue)
Attachment #445945 - Flags: feedback?(bzbarsky)
> there is no caret in <legend> There sure can be in caret browsing mode! That said, we don't want to treat legend as a leaf, so this part looks ok. > the <legend> frame is a text frame so it will not change anything I don't follow this (and note , the legend frame is a block frame, not a text frame). That said, excluding legend here doesn't necessarily make sense, so we're probably ok. > I'm wondering if it could returns 'true' and break things sometimes... It can certainly return true; it depends on the charset the page is in. That said, treating legend as visual-only doesn't make sense, so we're good here. The focus manager code seems to be making sure we don't step out of form controls when moving focus, but stepping out of legend is desirable. Good. Sounds like classinfo is the only problem child.
Attachment #445945 - Flags: feedback?(bzbarsky) → feedback+
Comment on attachment 445945 [details] [diff] [review] nsDOMClassInfo patch Yeah, that should work. Fix the indentation and s/it's/its/ and s/form form/form/, and looks fine. We should really deCOM nsIFormControl; file a bug on that if there isn't one already?
Attached patch Patch v2 (obsolete) — Splinter Review
Do you want/need to re-review the patch Boris ?
Attachment #445223 - Attachment is obsolete: true
Attachment #445945 - Attachment is obsolete: true
Attachment #446058 - Flags: superreview?(Olli.Pettay)
Attachment #445223 - Flags: superreview?(Olli.Pettay)
Depends on: 563668
Comment on attachment 446058 [details] [diff] [review] Patch v2 The indentation on the else if condition in nsDOMClassInfo.cpp is still off. Other than that looks good.
Attachment #446058 - Flags: review+
Attached patch Patch v2.1Splinter Review
r=bzbarsky
Attachment #446058 - Attachment is obsolete: true
Attachment #446383 - Flags: superreview?(Olli.Pettay)
Attachment #446058 - Flags: superreview?(Olli.Pettay)
blocking2.0: ? → beta1+
Comment on attachment 446383 [details] [diff] [review] Patch v2.1 I'm hoping this doesn't affect to createElement performance too badly.
Attachment #446383 - Flags: superreview?(Olli.Pettay) → superreview+
r=bz sr=smaug
Keywords: checkin-needed
I'm pushing this to try in just a bit; I fear it might cause some assertion-related orange though, and might need an update. I'll post here if so.
Pushed as http://hg.mozilla.org/mozilla-central/rev/0c87f407797d Had a small hunk to update, I just did it after getting Mounir's once-over as if it was a bustage fix.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Depends on: 570376
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: