Pass dom::Element to nsLayoutUtils::SurfaceFromElement

RESOLVED FIXED in mozilla11

Status

()

Core
Layout
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Ms2ger, Assigned: Ms2ger)

Tracking

Trunk
mozilla11
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
Most callers have an nsIContent, and it could reduce the number of QIs in nsLayoutUtils::SurfaceFromElement.
Seems reasonable to me.  Or even Element?
(Assignee)

Comment 2

6 years ago
Created attachment 575989 [details] [diff] [review]
Patch v1
Attachment #575989 - Flags: review?(bzbarsky)
(Assignee)

Updated

6 years ago
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+
(Assignee)

Comment 4

6 years ago
(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....
(Assignee)

Updated

6 years ago
Blocks: 706052
(Assignee)

Comment 6

6 years ago
(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.
(Assignee)

Comment 8

6 years ago
https://hg.mozilla.org/mozilla-central/rev/881155b89a68
Status: NEW → RESOLVED
Last Resolved: 6 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.