W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2008

[whatwg] Callback driven initialization of canvas

From: Fabien Meghazi <agr@amigrave.com>
Date: Tue, 21 Oct 2008 17:53:30 +0200
Message-ID: <7772a2590810210853t70032989r67580a9e146c89f6@mail.gmail.com>
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
Received on Tuesday, 21 October 2008 08:53:30 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:06 UTC