Last Comment Bug 704088 - Pass dom::Element to nsLayoutUtils::SurfaceFromElement
: Pass dom::Element to nsLayoutUtils::SurfaceFromElement
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Layout (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla11
Assigned To: :Ms2ger (⌚ UTC+1/+2)
:
Mentors:
Depends on:
Blocks: 706052
  Show dependency treegraph
 
Reported: 2011-11-21 02:54 PST by :Ms2ger (⌚ UTC+1/+2)
Modified: 2011-12-04 14:09 PST (History)
2 users (show)
Ms2ger: in‑testsuite-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch v1 (22.98 KB, patch)
2011-11-21 15:13 PST, :Ms2ger (⌚ UTC+1/+2)
bzbarsky: review+
Details | Diff | Splinter Review

Description :Ms2ger (⌚ UTC+1/+2) 2011-11-21 02:54:38 PST
Most callers have an nsIContent, and it could reduce the number of QIs in nsLayoutUtils::SurfaceFromElement.
Comment 1 Boris Zbarsky [:bz] 2011-11-21 05:14:46 PST
Seems reasonable to me.  Or even Element?
Comment 2 :Ms2ger (⌚ UTC+1/+2) 2011-11-21 15:13:57 PST
Created attachment 575989 [details] [diff] [review]
Patch v1
Comment 3 Boris Zbarsky [:bz] 2011-11-28 18:40:38 PST
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.
Comment 4 :Ms2ger (⌚ UTC+1/+2) 2011-11-29 00:27:54 PST
(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.
Comment 5 Boris Zbarsky [:bz] 2011-11-29 01:05:43 PST
> 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....
Comment 6 :Ms2ger (⌚ UTC+1/+2) 2011-11-29 03:46:02 PST
(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 :)).
Comment 7 Boris Zbarsky [:bz] 2011-11-29 11:09:39 PST
Ah, good point.  OK, fine.
Comment 8 :Ms2ger (⌚ UTC+1/+2) 2011-12-04 14:09:14 PST
https://hg.mozilla.org/mozilla-central/rev/881155b89a68

Note You need to log in before you can comment on or make changes to this bug.