|Summary:||Drawing to a dynamically created canvas element before it is appended to document doesnt work|
|Product:||WebKit||Reporter:||Andrew Wooldridge <triptych>|
|Component:||Layout and Rendering||Assignee:||Nobody <webkit-unassigned>|
Description Andrew Wooldridge 2005-12-29 17:03:42 PST
When a canvas element is created via document.createElement('canvas') and then drawn to via methods such as fillRect, the canvas does not reflect those method calls. However once the canvas has been appended to the document, subsequent calls to drawing methods "work".
Comment 1 Andrew Wooldridge 2005-12-29 17:07:06 PST
Created attachment 5360 [details] simple html document illustrating the problem
Comment 2 Joost de Valk (AlthA) 2006-02-07 14:32:46 PST
If you click the second link in the testcase first, nothing happens, the other way around, it does. Needs a better reduction but i think i can confirm this one.
Comment 3 Andrew Wooldridge 2006-02-07 17:17:31 PST
To further explain the sample document. The first click tries to create a canvas element, draw to it then append it to the document. In safari you wont see a black square in the canvas after you click the first link, however in opera and Firefox you do.
Comment 4 David Carson 2006-03-08 16:47:35 PST
The problem seems to be that the Canvas render object (RenderCanvasImage) has not been created yet, although there is a valid DOM element. By memory, render objects are not created until they are attached to the DOM tree. I believe this is because the engine does not know how to provide the style information needed to create a render object until it knows it's location within the tree. So, although the getContext function will return with a valid canvas context, no methods on that object will succeed until it is attached to the DOM. I am not sure what can be done about this.
Comment 5 David Carson 2006-03-08 16:58:10 PST
The same root cause as http://bugzilla.opendarwin.org/show_bug.cgi?id=4884