Open Bug 598468 Opened 10 years ago Updated 16 days ago

Remove ugly code preventing assert in DoCompareTreePosition when called from nsHTMLFormElement.cpp

Categories

(Core :: DOM: Forms, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: mounir, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: [CID 1286161])

Somewhat like: nsLayoutUtils::CompareTreePosition.
This should be used in nsHTMLFormElement.cpp, CompareFormControlPosition. Most form controls have the form element has a common ancestor so it would be nice to take this in consideration.
Whiteboard: [mounir-pg2]
Jonas wants to use a global var to prevent the assert so we are going to keep calling the same method with a fix to prevent the asserts...
Summary: Add a PositionIsBefore-like method in nsContentUtils which takes a third parameter which is a possible common ancestor → Remove ugly code preventing assert in DoCompareTreePosition when called from nsHTMLFormElement.cpp
Whiteboard: [mounir-pg2]
Keywords: coverity
Whiteboard: [CID 1286161]
Priority: -- → P5

hsinyi, should we just remove the dead code in https://searchfox.org/mozilla-central/source/dom/html/HTMLFormElement.cpp#1108 ?
(grep for 598468)
seems that nothing will ever happen here.

Flags: needinfo?(htsai)

This bug was introduced by bug 595606 comment 6. Per spec, it should make sure elements in tree order in HTMLFormControlsCollection[1] and Constructing the entry list[2]. I think it's still valid and we should fix this bug. It's safe to remove the code in https://searchfox.org/mozilla-central/source/dom/html/HTMLFormElement.cpp#1108 because we can make sure elements in tree order by tests. However, I'll leave it for DOM Peer to do the final call.

[1] https://html.spec.whatwg.org/#the-htmlformcontrolscollection-interface
[2] https://html.spec.whatwg.org/#constructing-form-data-set

Type: defect → enhancement
Component: DOM: Core & HTML → DOM: Forms

This looks valid bug to me. And there is no dead code (in debug builds).

Flags: needinfo?(htsai)
You need to log in before you can comment on or make changes to this bug.