Last Comment Bug 339553 - drawString enhancement for <canvas>
: drawString enhancement for <canvas>
Status: RESOLVED FIXED
: dev-doc-complete
Product: Core
Classification: Components
Component: Canvas: 2D (show other bugs)
: Trunk
: All All
: -- enhancement (vote)
: mozilla1.9alpha7
Assigned To: Rob Arnold [:robarnold]
:
Mentors:
http://developer.mozilla.org/en/docs/...
Depends on: 390476
Blocks:
  Show dependency treegraph
 
Reported: 2006-05-29 01:17 PDT by Lars Schöning
Modified: 2008-04-02 14:18 PDT (History)
13 users (show)
asqueella: in‑testsuite?
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Implements textStyle, drawText, measureText (31.47 KB, patch)
2007-05-31 15:38 PDT, Rob Arnold [:robarnold]
no flags Details | Diff | Splinter Review
Now implements just drawText, measureText, textStyle and one assertion in gfxFont (13.69 KB, patch)
2007-05-31 16:31 PDT, Rob Arnold [:robarnold]
no flags Details | Diff | Splinter Review
TextStyle, DrawText, MeasureText, PathText, TextAlongPath (17.01 KB, patch)
2007-06-01 13:44 PDT, Rob Arnold [:robarnold]
no flags Details | Diff | Splinter Review
Fixes crash when SetTextStyle was not called before the other function calls (16.80 KB, patch)
2007-06-05 12:33 PDT, Rob Arnold [:robarnold]
vladimir: review+
Details | Diff | Splinter Review
Method/Attribute renaming and fixed a bug when the canvas was not attached to the dom (16.85 KB, patch)
2007-06-26 15:15 PDT, Rob Arnold [:robarnold]
vladimir: review+
Details | Diff | Splinter Review
Fixed builds errors on trunk (15.28 KB, patch)
2007-07-23 17:14 PDT, Rob Arnold [:robarnold]
vladimir: review+
Details | Diff | Splinter Review
Text path demo (1.67 KB, text/html)
2007-07-23 17:14 PDT, Rob Arnold [:robarnold]
no flags Details
Second path demo (1.78 KB, text/html)
2007-07-23 17:15 PDT, Rob Arnold [:robarnold]
no flags Details
Animated text demo (1.71 KB, text/html)
2007-07-23 17:15 PDT, Rob Arnold [:robarnold]
no flags Details
This fixes an issue in Windows optimized builds with some uninitialized data (1.06 KB, patch)
2007-08-02 14:58 PDT, Rob Arnold [:robarnold]
vladimir: review+
vladimir: approval1.9+
Details | Diff | Splinter Review

Description Lars Schöning 2006-05-29 01:17:03 PDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

As the canvas tag is not a standard anyway may I suggest the addition of a drawString method with parameters for font type, size and string. 

In order to achieve usability canvas really requires an equivalent prototype method, however the established prototype functions take immense amounts of clocktime and significantly (and unnessessarily) slow down the canvas. The current lack of standard in canvas makes it possible to include a drawString method before it is too late, thus adding new possibilities to the object.

Reproducible: Always
Comment 1 Christian :Biesinger (don't email me, ping me on IRC) 2006-05-29 01:42:09 PDT
> As the canvas tag is not a standard anyway

http://whatwg.org/specs/web-apps/current-work/#scs-dynamic
Comment 2 Anne (:annevk) 2006-05-29 01:47:55 PDT
Some ideas have been drafted http://wiki.mozilla.org/Canvas:Text but it would be best if this was discussed at whatwg@whatwg.org first.

(Note that even if it is a standard it's still possible to extend objects with possibilities following the undrafted rules for extensibility of objects or by proposing additions to such a atandard on the appropriate forums.)
Comment 3 Lars Schöning 2006-05-29 07:40:10 PDT
> > As the canvas tag is not a standard anyway
> 
> http://whatwg.org/specs/web-apps/current-work/#scs-dynamic

It is a working draft.
Comment 4 Anne (:annevk) 2006-05-29 10:47:14 PDT
Right, proposed extensions to such working drafts go to the document author and or the public mailing list attached to it: see comment 2.
Comment 5 Rob Arnold [:robarnold] 2007-05-31 15:38:24 PDT
Created attachment 266815 [details] [diff] [review]
Implements textStyle, drawText, measureText
Comment 6 Rob Arnold [:robarnold] 2007-05-31 16:31:33 PDT
Created attachment 266824 [details] [diff] [review]
Now implements just drawText, measureText, textStyle and one assertion in gfxFont

This patch is dependent on bug 382710
Comment 7 Rob Arnold [:robarnold] 2007-06-01 13:44:38 PDT
Created attachment 266941 [details] [diff] [review]
TextStyle, DrawText, MeasureText, PathText, TextAlongPath
Comment 8 Rob Arnold [:robarnold] 2007-06-01 13:48:58 PDT
Comment on attachment 266941 [details] [diff] [review]
TextStyle, DrawText, MeasureText, PathText, TextAlongPath

Still dependent on aforementioned bug 382710
Comment 9 Rob Arnold [:robarnold] 2007-06-05 12:33:34 PDT
Created attachment 267311 [details] [diff] [review]
Fixes crash when SetTextStyle was not called before the other function calls
Comment 10 Vladimir Vukicevic [:vlad] [:vladv] 2007-06-14 14:13:25 PDT
Comment on attachment 267311 [details] [diff] [review]
Fixes crash when SetTextStyle was not called before the other function calls

r+ me with name change to moz-prefixed names (mozTextStyle, etc.).  However, please request review from dbaron (or bz?) on the style additions.  Thanks!
Comment 11 Takeshi Kurosawa 2007-06-21 06:51:44 PDT
(In reply to comment #10)
> (From update of attachment 267311 [details] [diff] [review])
> r+ me with name change to moz-prefixed names (mozTextStyle, etc.).


According to HTML 5,
> drawing text is not supported in this version of the API
- http://www.whatwg.org/specs/web-apps/current-work/multipage/section-the-canvas.html#the-2d

> Vendors may also define experimental contexts using the syntax vendorname-context, for example, moz-3d. 
- http://www.whatwg.org/specs/web-apps/current-work/multipage/section-the-canvas.html#getcontext


So, we should create another context (e.g. moz-2dtext) as Opera did (opera-2dgame).
http://my.opera.com/WebApplications/blog/show.dml/200788
Comment 12 Rob Arnold [:robarnold] 2007-06-22 14:39:26 PDT
(In reply to comment #11)
> (In reply to comment #10)
> > (From update of attachment 267311 [details] [diff] [review] [details])
> > r+ me with name change to moz-prefixed names (mozTextStyle, etc.).
> 
> 
> According to HTML 5, drawing text is not supported in this version of the API

Which is why we are going to prefix our extension with moz so that when such an api is standardized, this implementation will not conflict.

> Vendors may also define experimental contexts using the syntax vendorname-context, for example, moz-3d. 
> -
> http://www.whatwg.org/specs/web-apps/current-work/multipage/section-the-canvas.html#getcontext

I interpret this as stating that it is not required to define another context. Also note that the same document states:
> UA must return a reference to an object implementing CanvasRenderingContext2D

The object we return does implement this interface.

> So, we should create another context (e.g. moz-2dtext) as Opera did
> (opera-2dgame).
> http://my.opera.com/WebApplications/blog/show.dml/200788

Perhaps, but given that we are prefixing our extension functions to avoid future naming collisions (unlike Opera), there is not as much of a reason to do this.
Comment 13 Rob Arnold [:robarnold] 2007-06-26 15:15:15 PDT
Created attachment 269917 [details] [diff] [review]
Method/Attribute renaming and fixed a bug when the canvas was not attached to the dom
Comment 14 Vladimir Vukicevic [:vlad] [:vladv] 2007-07-19 16:08:13 PDT
Comment on attachment 269917 [details] [diff] [review]
Method/Attribute renaming and fixed a bug when the canvas was not attached to the dom

Looks good
Comment 15 Rob Arnold [:robarnold] 2007-07-23 17:14:00 PDT
Created attachment 273496 [details] [diff] [review]
Fixed builds errors on trunk

gfxGlobalTextRunCache disappeared between when I posted and vlad review. New version uses gfxTextRunCache::AutoTextRun.
Comment 16 Rob Arnold [:robarnold] 2007-07-23 17:14:52 PDT
Created attachment 273497 [details]
Text path demo
Comment 17 Rob Arnold [:robarnold] 2007-07-23 17:15:30 PDT
Created attachment 273498 [details]
Second path demo
Comment 18 Rob Arnold [:robarnold] 2007-07-23 17:15:52 PDT
Created attachment 273499 [details]
Animated text demo
Comment 19 Vladimir Vukicevic [:vlad] [:vladv] 2007-07-23 17:21:28 PDT
Thanks.. this is still on my list to check in, my tree's just been full of new cairo, but I should have that wrapped up soon.  I'll get this in tonight or tomorrow.
Comment 20 Vladimir Vukicevic [:vlad] [:vladv] 2007-07-25 11:22:36 PDT
Checking in content/canvas/src/nsCanvasRenderingContext2D.cpp;
/cvsroot/mozilla/content/canvas/src/nsCanvasRenderingContext2D.cpp,v  <--  nsCanvasRenderingContext2D.cpp
new revision: 1.90; previous revision: 1.89
done
Checking in layout/style/nsStyleSet.cpp;
/cvsroot/mozilla/layout/style/nsStyleSet.cpp,v  <--  nsStyleSet.cpp
new revision: 3.185; previous revision: 3.184
done
Checking in layout/style/nsStyleSet.h;
/cvsroot/mozilla/layout/style/nsStyleSet.h,v  <--  nsStyleSet.h
new revision: 3.23; previous revision: 3.22
done
Checking in gfx/thebes/src/gfxFont.cpp;
/cvsroot/mozilla/gfx/thebes/src/gfxFont.cpp,v  <--  gfxFont.cpp
new revision: 1.58; previous revision: 1.57
done
Checking in dom/public/idl/canvas/nsIDOMCanvasRenderingContext2D.idl;
/cvsroot/mozilla/dom/public/idl/canvas/nsIDOMCanvasRenderingContext2D.idl,v  <--  nsIDOMCanvasRenderingContext2D.idl
new revision: 1.6; previous revision: 1.5
done
Comment 21 Vladimir Vukicevic [:vlad] [:vladv] 2007-07-30 16:55:06 PDT
Comment on attachment 273496 [details] [diff] [review]
Fixed builds errors on trunk

(was already reviewed and checked in)
Comment 22 Rob Arnold [:robarnold] 2007-08-02 14:58:55 PDT
Created attachment 275020 [details] [diff] [review]
This fixes an issue in Windows optimized builds with some uninitialized data
Comment 23 Vladimir Vukicevic [:vlad] [:vladv] 2007-08-03 15:47:58 PDT
Comment on attachment 275020 [details] [diff] [review]
This fixes an issue in Windows optimized builds with some uninitialized data

r+a=me, checked in, thanks!
Comment 24 Nickolay_Ponomarev 2007-09-08 20:36:20 PDT
http://developer.mozilla.org/en/docs/Canvas:Text has some docs (thanks Rob!), but it could use more detail (i.e. formal API documentation), so keeping on the dev-doc-needed radar.
Comment 25 Eric Shepherd [:sheppy] 2008-03-13 14:45:47 PDT
The docs have been overhauled substantially.  Basically the same content, just rearranged to match other reference documents more closely.

http://developer.mozilla.org/en/docs/Drawing_text_using_a_canvas

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