Closed Bug 704088 Opened 13 years ago Closed 13 years ago

Pass dom::Element to nsLayoutUtils::SurfaceFromElement

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla11

People

(Reporter: Ms2ger, Assigned: Ms2ger)

References

Details

Attachments

(1 file)

Most callers have an nsIContent, and it could reduce the number of QIs in nsLayoutUtils::SurfaceFromElement.
Seems reasonable to me. Or even Element?
Attached patch Patch v1Splinter Review
Attachment #575989 - Flags: review?(bzbarsky)
Assignee: nobody → Ms2ger
Comment on attachment 575989 [details] [diff] [review] Patch v1 > WebGLContext::DOMElementToImageSurface(nsIDOMElement *imageOrCanvas, >+ if (!content) { Followup bug to mark nsIDOMElement as builtinclass and remove the nullcheck, assuming imageOrCanvas is known to be non-null here? >+ if (nsHTMLCanvasElement* canvas = nsHTMLCanvasElement::FromContent(content)) { Extra pair of parens around assignment used as condition, please. >+++ b/layout/base/nsLayoutUtils.cpp >+ if (nsHTMLCanvasElement* canvas = nsHTMLCanvasElement::FromContent(aElement)) { Same here. >+ if (nsHTMLVideoElement* video = nsHTMLVideoElement::FromContent(aElement)) { And here. r=me with those nits.
Attachment #575989 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky (:bz) from comment #3) > Comment on attachment 575989 [details] [diff] [review] [diff] [details] [review] > Patch v1 > > > WebGLContext::DOMElementToImageSurface(nsIDOMElement *imageOrCanvas, > >+ if (!content) { > > Followup bug to mark nsIDOMElement as builtinclass and remove the nullcheck, > assuming imageOrCanvas is known to be non-null here? It can be null, afaict. The custom quickstub calls the _dom functions without checking if the argument it tried to convert to an nsIDOMElement* actually was one: <http://mxr.mozilla.org/mozilla-central/source/content/canvas/src/CustomQS_WebGL.h#314>. (But a followup to unwrap to dom::Element directly?) > > >+ if (nsHTMLCanvasElement* canvas = nsHTMLCanvasElement::FromContent(content)) { > > Extra pair of parens around assignment used as condition, please. This isn't usually done with this pattern, fwiw.
> But a followup to unwrap to dom::Element directly? Sounds lovely. > This isn't usually done with this pattern, fwiw. Why not? I'd expect a compiler warning on the pattern otherwise....
Blocks: 706052
(In reply to Boris Zbarsky (:bz) from comment #5) > > But a followup to unwrap to dom::Element directly? > > Sounds lovely. Bug 706052. > > This isn't usually done with this pattern, fwiw. > > Why not? I'd expect a compiler warning on the pattern otherwise.... nsHTMLCanvasElement* canvas; if (canvas = nsHTMLCanvasElement::FromContent(content)) would warn, but having the declaration in the condition as well makes it clear I didn't typo '==' (the second time you read it, at least :)).
Ah, good point. OK, fine.
Status: NEW → RESOLVED
Closed: 13 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Summary: Pass nsIContent to nsLayoutUtils::SurfaceFromElement? → Pass dom::Element to nsLayoutUtils::SurfaceFromElement
Target Milestone: --- → mozilla11
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: