[whatwg] Callback driven initialization of canvas

Fabien Meghazi agr at amigrave.com
Tue Oct 21 08:53:30 PDT 2008


Hi all,

<disclaimer>
    Please forgive me if what I say is silly.
</disclaimer>

Undoubtedly, in the future, canvas will be used for good stuff but
also for nasty stuff.
Of course, how we consider nasty stuff is a personal feeling.
I don't like ads. Especially flash ads. This is why I use Firefox
extension flash block (amongs other reasons)
I'm sure in the future we will see canvas ads poping everywhere, and
here's my concern :

Will it be possible for the browsers to allow an extension such as
canvas block ?

My understanding is that it won't be possible (please correct me if
I'm wrong, I'm not an expert) as the initialization of a canvas
context is done as follow :

var canvas = document.getElementById('tutorial');
if (canvas.getContext){
  var ctx = canvas.getContext('2d');
  // drawing code here
} else {
  // canvas-unsupported code here
}

But if the initialization of the canvas tag was callback driven, then
I guess it would be possible to do a canvas block.

var canvas = document.getElementById('tutorial');
if (canvas.getContext){
  canvas.getContext('2d', function(ctx) {
       // drawing code here
  });
} else {
  // canvas-unsupported code here
}

With this scheme, I guess it would be possible to hook the getContext
function and do whathever with the callback function (eg: call it when
user click the canvas element like flash block)


-- 
Fabien Meghazi

Website: http://www.amigrave.com
Email: agr at amigrave.com
IM: amigrave at gmail.com



More information about the whatwg mailing list