Closed Bug 772869 Opened 12 years ago Closed 12 years ago

getOwnPropertyNames for proxy-based DOM list bindings should add names for named items

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: peterv, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

No description provided.
Blocks: 803129
Ms2ger, can you please look over the imptests change?
Attachment #673073 - Flags: review?(peterv)
Attachment #673073 - Flags: review?(Ms2ger)
Assignee: nobody → bzbarsky
Whiteboard: [need review]
Attachment #673223 - Flags: review?(peterv)
Attachment #673223 - Flags: review?(Ms2ger)
Attachment #673073 - Attachment is obsolete: true
Attachment #673073 - Flags: review?(peterv)
Attachment #673073 - Flags: review?(Ms2ger)
Comment on attachment 673223 [details] [diff] [review] With the lone mochitest unexpected pass fixed Review of attachment 673223 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/html/content/src/HTMLPropertiesCollection.cpp @@ +370,5 @@ > } else { > aContent = element->GetNextNode(aElement); > } > } > } I wouldn't mind if you removed all this trailing whitespace :) ::: content/html/content/src/nsHTMLFormElement.cpp @@ +2569,5 @@ > +nsFormControlList::GetSupportedNames(nsTArray<nsString>& aNames) > +{ > + FlushPendingNotifications(); > + // Just enumerate mNameLookupTable. This won't guarantee order, but > + // that's OK. Hm. WebIDL does define an order... ::: dom/imptests/html/tests/submission/Opera/microdata/test_001.html @@ +1530,5 @@ > }, 'properties.item must give each property in tree order'); > test(function () { > var testEl = makeEl('div',{itemscope:'itemscope'},'<div itemprop="foo"></div><div itemprop="bar"><div itemprop="foo"></div></div><div itemprop="baz qux"></div>'); > + testEl.properties.something = "another"; > + names = Object.getOwnPropertyNames(testEl.properties); `var` or inline it in the assert_array_equals call. @@ +1532,5 @@ > var testEl = makeEl('div',{itemscope:'itemscope'},'<div itemprop="foo"></div><div itemprop="bar"><div itemprop="foo"></div></div><div itemprop="baz qux"></div>'); > + testEl.properties.something = "another"; > + names = Object.getOwnPropertyNames(testEl.properties); > + assert_array_equals(names, ["0", "1", "2", "3", "foo", "bar", "baz", > + "qux", "something"]); Code style here appears to have spaces after ( and before ), as hideous as that may be.
Attachment #673223 - Flags: review?(Ms2ger) → review+
> Hm. WebIDL does define an order... WebIDL says this: If the object supports named properties, then the object’s supported property names are enumerated next, in the order given in the definition of the set of supported property names. And the HTML5 spec says: The supported property names consist of the values of all the id and name attributes of all the elements represented by the collection. That's it. So there is no order defined in this case.
> I wouldn't mind if you removed all this trailing whitespace :) I would, so no. ;) I made the test changes you asked for.
Comment on attachment 673223 [details] [diff] [review] With the lone mochitest unexpected pass fixed Review of attachment 673223 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/base/src/nsContentList.cpp @@ +647,5 @@ > + nsGenericHTMLElement* el = nsGenericHTMLElement::FromContent(content); > + if (el) { > + // XXXbz should we be checking for particular tags here? How > + // stable is this part of the spec? > + // Note: HasName means the names is exposed on the document, nsINode::HasName()? Also, 'the names is exposed' sounds wrong to me. ::: content/html/content/src/nsHTMLFormElement.cpp @@ +2569,5 @@ > +nsFormControlList::GetSupportedNames(nsTArray<nsString>& aNames) > +{ > + FlushPendingNotifications(); > + // Just enumerate mNameLookupTable. This won't guarantee order, but > + // that's OK. WebIDL does talk about an order, but I don't see where this one would be defined. ::: content/html/content/src/nsHTMLTableElement.cpp @@ +307,5 @@ > + if (coll) { > + coll->GetSupportedNames(names); > + for (uint32_t i = 0; i < names.Length(); ++i) { > + if (!aNames.Contains(names[i])) { > + aNames.AppendElement(names[i]); Given this code it might make sense to have the virtual GetSupportedNames take a |nsTArray<nsIAtom>&| and have the one taking |nsTArray<nsString>& aNames| call that and then copy? You'd still call the virtual one here but wouldn't need to check with Contains and copy here. I wish we could use the nsTArray<nsIAtom> directly to convert to the jsid array, but it seems it'll make things a bit complicated.
Attachment #673223 - Flags: review?(peterv) → review+
> nsINode::HasName()? Also, 'the names is exposed' sounds wrong to me. Fixed, on both counts. > WebIDL does talk about an order, but I don't see where this one would be defined. WebIDL doesn't leaves the definition of the order to the spec defining the interface. In this case that spec does not define an order. See comment 4. I fixed the comment to make that clearer. > You'd still call the virtual one here but wouldn't need to check with Contains and copy > here. I still would... The problem is what happens when I have elements with the same id in different row groups. I want to only end up with that name in the output array once, no? Hence the Contains() checks. Using nsIAtom would make the Contains() call faster, though. I guess I can do that if you'd prefer. Note that there are no string copies going on here, by the way. Just refcounting of stringbuffers. I agree that refcounting atoms would be faster, though.
Oh, but we wouldn't need to refcount the atoms, since we'd just turn them into strings. OK, going to do what you suggested.
Hrm. Except form.elements doesn't have the names in atomized form. Nor does the HTMLPropertiesCollection. So I'll leave it as-is for now. :(
Blocks: 808606
Flags: in-testsuite+
Whiteboard: [need review]
Target Milestone: --- → mozilla19
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Depends on: 843840
Depends on: 845588
Depends on: 849551
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: