Closed
Bug 1257849
Opened 9 years ago
Closed 9 years ago
Implement DOMTokenList.supports() and supported tokens
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: crimsteam, Assigned: bzbarsky)
Details
(Keywords: dev-doc-complete, Whiteboard: [tw-dom] btpp-fixlater)
Attachments
(5 files, 6 obsolete files)
4.68 KB,
patch
|
bkelly
:
review+
|
Details | Diff | Splinter Review |
8.25 KB,
patch
|
bkelly
:
review+
|
Details | Diff | Splinter Review |
3.63 KB,
patch
|
bkelly
:
review+
|
Details | Diff | Splinter Review |
2.79 KB,
patch
|
bkelly
:
review+
|
Details | Diff | Splinter Review |
7.00 KB,
patch
|
bkelly
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0 Build ID: 20160303134406 Steps to reproduce: https://dom.spec.whatwg.org/#dom-domtokenlist-supports https://github.com/whatwg/dom/pull/123 Actually it was added in Chrome 50 (https://developers.google.com/web/updates/2016/03/domtokenlist-validation-added-in-chrome-50).
Updated•9 years ago
|
Whiteboard: [tw-dom] btpp-fixlater
Assignee | ||
Comment 1•9 years ago
|
||
Intent to ship: https://groups.google.com/forum/#!topic/mozilla.dev.platform/YFRTGKaY5-g
Assignee | ||
Comment 2•9 years ago
|
||
Attachment #8748354 -
Flags: review?(bkelly)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → bzbarsky
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee | ||
Comment 3•9 years ago
|
||
Attachment #8748355 -
Flags: review?(bkelly)
Assignee | ||
Comment 4•9 years ago
|
||
Attachment #8748356 -
Flags: review?(bkelly)
Assignee | ||
Comment 5•9 years ago
|
||
Attachment #8748357 -
Flags: review?(bkelly)
Assignee | ||
Comment 6•9 years ago
|
||
Attachment #8748358 -
Flags: review?(bkelly)
Updated•9 years ago
|
Keywords: dev-doc-needed
Assignee | ||
Comment 7•9 years ago
|
||
Attachment #8748472 -
Flags: review?(bkelly)
Assignee | ||
Updated•9 years ago
|
Attachment #8748357 -
Attachment is obsolete: true
Attachment #8748357 -
Flags: review?(bkelly)
Comment 8•9 years ago
|
||
Comment on attachment 8748354 [details] [diff] [review] part 1. Add a concept of supported tokens to nsDOMTokenList Review of attachment 8748354 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/base/nsDOMTokenList.h @@ +39,5 @@ > > + // aSupportedTokens is either null or a null-terminated list of > + // ASCII-lowercase values, typically pointing at some sort of static table. > + // The caller retains ownership of aSupportedTokens and must ensure they > + // outlive the nsDOMTokenList. I feel like this could be slightly improved by creating a header somewhere with: typedef const char* const DOMSupportedToken; typedef DOMSupportedToken* DOMSupportedTokenList; And then macros for defining and searching the static lists. This would tie the various places we use this together in a single header that can contain documenting comments. What do you think?
Comment 9•9 years ago
|
||
Comment on attachment 8748472 [details] [diff] [review] part 4. Pass in the right set of supported tokens to the <link> relList implementation Review of attachment 8748472 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/html/HTMLLinkElement.cpp @@ +480,5 @@ > if (!mRelList) { > + const char* const * const relValues = > + nsStyleLinkElement::IsImportEnabled() ? > + sSupportedRelValues : &sSupportedRelValues[1]; > + nit: trailing whitespace
Comment 10•9 years ago
|
||
Comment on attachment 8748358 [details] [diff] [review] part 5. Implement DOMTokenList.prototype.supports() Review of attachment 8748358 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/base/nsDOMTokenList.cpp @@ +348,5 @@ > } > > +bool > +nsDOMTokenList::Supports(const nsAString& aToken, > + ErrorResult& aError) nit: indentation
Assignee | ||
Comment 11•9 years ago
|
||
> I feel like this could be slightly improved by creating a header somewhere with:
Hmm. A macro for searching doesn't make much sense to me and a macro for defining would only be usable in two places, not the third one. But having the typedefs in one spot, with comments, makes sense. Let me do that.
Assignee | ||
Comment 12•9 years ago
|
||
Attachment #8748786 -
Flags: review?(bkelly)
Assignee | ||
Updated•9 years ago
|
Attachment #8748354 -
Attachment is obsolete: true
Attachment #8748354 -
Flags: review?(bkelly)
Assignee | ||
Comment 13•9 years ago
|
||
Attachment #8748787 -
Flags: review?(bkelly)
Assignee | ||
Updated•9 years ago
|
Attachment #8748355 -
Attachment is obsolete: true
Attachment #8748355 -
Flags: review?(bkelly)
Assignee | ||
Comment 14•9 years ago
|
||
Attachment #8748788 -
Flags: review?(bkelly)
Assignee | ||
Updated•9 years ago
|
Attachment #8748356 -
Attachment is obsolete: true
Attachment #8748356 -
Flags: review?(bkelly)
Assignee | ||
Comment 15•9 years ago
|
||
Attachment #8748789 -
Flags: review?(bkelly)
Assignee | ||
Updated•9 years ago
|
Attachment #8748472 -
Attachment is obsolete: true
Attachment #8748472 -
Flags: review?(bkelly)
Assignee | ||
Comment 16•9 years ago
|
||
Attachment #8748790 -
Flags: review?(bkelly)
Assignee | ||
Updated•9 years ago
|
Attachment #8748358 -
Attachment is obsolete: true
Attachment #8748358 -
Flags: review?(bkelly)
Comment 17•9 years ago
|
||
Comment on attachment 8748786 [details] [diff] [review] part 1. Add a concept of supported tokens to nsDOMTokenList Review of attachment 8748786 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/base/nsDOMTokenList.h @@ +38,5 @@ > NS_DECL_CYCLE_COLLECTING_ISUPPORTS > NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTokenList) > > + nsDOMTokenList(Element* aElement, nsIAtom* aAttrAtom, > + const mozilla::dom::DOMTokenListSupportedTokenArray = nullptr); Is this const necessary? Seems all the consts are in the typedef. @@ +88,5 @@ > inline const nsAttrValue* GetParsedAttr(); > > nsCOMPtr<Element> mElement; > nsCOMPtr<nsIAtom> mAttrAtom; > + const mozilla::dom::DOMTokenListSupportedTokenArray mSupportedTokens; I think this const means you can't change the mSupportedTokens pointer once set, which seems correct.
Attachment #8748786 -
Flags: review?(bkelly) → review+
Comment 18•9 years ago
|
||
Comment on attachment 8748787 [details] [diff] [review] part 2. Pass in the right set of supported tokens to the sandbox tokenlist implementation Review of attachment 8748787 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/base/Element.h @@ +1334,5 @@ > */ > virtual void GetLinkTarget(nsAString& aTarget); > > + nsDOMTokenList* GetTokenList(nsIAtom* aAtom, > + const DOMTokenListSupportedTokenArray aSupportedTokens = nullptr); Same question about the const here. Seems its not necessary with the typedef?
Attachment #8748787 -
Flags: review?(bkelly) → review+
Updated•9 years ago
|
Attachment #8748788 -
Flags: review?(bkelly) → review+
Updated•9 years ago
|
Attachment #8748789 -
Flags: review?(bkelly) → review+
Updated•9 years ago
|
Attachment #8748790 -
Flags: review?(bkelly) → review+
Assignee | ||
Comment 19•9 years ago
|
||
> Is this const necessary? Seems all the consts are in the typedef. It's not _necessary_, but it _is_ semantically meaningful. The typedef for DOMTokenListSupportedTokenArray defines it as a pointer to immutable pointers to immutable chars. This const is saying that you have an immutable such pointer, that can't be repointed to some other set of pointers... I could bake this const into the typedef like so: typedef DOMTokenListSupportedToken * const DOMTokenListSupportedTokenArray; but then I couldn't use DOMTokenListSupportedTokenArray during the search through the list, because there I actually want to advance the pointer to pointers thing. > Same question about the const here. Seems its not necessary with the typedef? Same answer.
Assignee | ||
Comment 20•9 years ago
|
||
Oh, and the reason it's not _necessary_ is that we're passing that pointer by value anyway. So this is the moral equivalent of writing: void foo(const int arg); if I have a const int at the callsite and only plan to use it without changing in the callee. The const there could be dropped, but it does enforce that the callee won't mess with it. Except of course the callee can copy it like so: int copy = arg; or DOMTokenListSupportedTokenArray copy = aSupportedTokens; and then modify the copy as desired...
Comment 21•9 years ago
|
||
Ok, but I don't think your original patch had that level constness. We were living dangerously in the previous version!
Assignee | ||
Comment 22•9 years ago
|
||
You're right, I had that in the member but not the argument. ;)
Comment 23•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/5bc5900c5f3d https://hg.mozilla.org/integration/mozilla-inbound/rev/9f9654253256 https://hg.mozilla.org/integration/mozilla-inbound/rev/48b96216d74a https://hg.mozilla.org/integration/mozilla-inbound/rev/7df7d2acee67 https://hg.mozilla.org/integration/mozilla-inbound/rev/5d87bd22c1c9
Comment 24•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/5bc5900c5f3d https://hg.mozilla.org/mozilla-central/rev/9f9654253256 https://hg.mozilla.org/mozilla-central/rev/48b96216d74a https://hg.mozilla.org/mozilla-central/rev/7df7d2acee67 https://hg.mozilla.org/mozilla-central/rev/5d87bd22c1c9
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Comment 25•9 years ago
|
||
Documented: https://developer.mozilla.org/en-US/Firefox/Releases/49#DOM_HTML_DOM and https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/supports
Keywords: dev-doc-needed → dev-doc-complete
Comment 27•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/0ca978ff9e6d
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•