Closed
Bug 1393419
Opened 7 years ago
Closed 7 years ago
Implement nsIContent::As<T> to replace QI(nsIDOMHTML*Element)
Categories
(Core :: DOM: Core & HTML, enhancement, P3)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
INVALID
People
(Reporter: emk, Assigned: emk)
References
Details
Attachments
(1 file, 1 obsolete file)
7.20 KB,
patch
|
Details | Diff | Splinter Review |
This is inspired by JSObject::as<T>. This is safer than a bare static_cast and has no overhead such as virtual calls. qdot, WDYT?
Attachment #8900698 -
Flags: feedback?(kyle)
Updated•7 years ago
|
Assignee: nobody → VYV03354
Comment 1•7 years ago
|
||
Comment on attachment 8900698 [details] [diff] [review] Proof of concept Review of attachment 8900698 [details] [diff] [review]: ----------------------------------------------------------------- This looks ok to me. The LocalName() lookup is a little awkward but I can't find anywhere else that we have easily accessible nsGkAtoms -> binding type lookups. I may ask bz about this once he's synced back up from vacation. ::: docshell/base/nsContextMenuInfo.cpp @@ +85,5 @@ > content = do_QueryInterface(curr); > if (!content) { > break; > } > + if (content->IsHTMLElement(nsGkAtoms::a)) { I think we could just move the As<>() call here instead of having to check for HTML element type first?
Attachment #8900698 -
Flags: feedback?(kyle) → feedback+
Assignee | ||
Comment 2•7 years ago
|
||
> I think we could just move the As<>() call here instead of having to check for HTML element type first?
Good point, fixed.
Attachment #8900698 -
Attachment is obsolete: true
Updated•7 years ago
|
Priority: -- → P3
Assignee | ||
Comment 3•7 years ago
|
||
Boris, do you have better idea to get binding types from nsGkAtoms?
Flags: needinfo?(bzbarsky)
Comment 4•7 years ago
|
||
Well, the first problem is that you can't do it, in general. For example, both <q> and <blockquote> are HTMLQuoteElement, so if you wanted to do As<HTMLQuoteElement> you wouldn't be able to do it using the setup with T::LocalName() or any other setup that depends on a one-to-one mapping of localnames to types. Similar for <col> and <colgroup>, and the fact that we have an HTMLSharedElement complicates things even further. For the cases where tags map 1-1 to element types, we already have FromContent machinery, no?
Flags: needinfo?(bzbarsky)
Assignee | ||
Comment 5•7 years ago
|
||
Oh, I didn't notice FromContent. Thank you.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•