Closed
Bug 902799
Opened 11 years ago
Closed 10 years ago
support vertical text in canvas text drawing methods
Categories
(Core :: Graphics: Canvas2D, defect)
Core
Graphics: Canvas2D
Tracking
()
RESOLVED
FIXED
mozilla35
People
(Reporter: jtd, Assigned: jfkthame)
References
(Blocks 2 open bugs)
Details
Attachments
(1 file, 6 obsolete files)
(deleted),
patch
|
bas.schouten
:
review+
|
Details | Diff | Splinter Review |
Canvas methods such as FillText, etc. need to support some form of vertical text rendering. Initially I think this could be added simply by respecting the writing-mode value for the canvas element but eventually I think there probably needs to be a separate method or context parameter for this.
This is actually interesting because this can be used to experiment with vertical text run construction (bug 789104, bug 902762) without the need to wait for the more complex issues associated with handling vertical text runs within text frames.
Comment 1•11 years ago
|
||
Is there any proposal about this?
Assignee | ||
Comment 2•10 years ago
|
||
Attachment #8486621 -
Flags: review?(jdaggett)
Assignee | ||
Updated•10 years ago
|
Assignee: jdaggett → jfkthame
Status: NEW → ASSIGNED
Assignee | ||
Comment 3•10 years ago
|
||
Updated to fix a crash when the Canvas element is not in a document.
Attachment #8487084 -
Flags: review?(jdaggett)
Assignee | ||
Updated•10 years ago
|
Attachment #8486621 -
Attachment is obsolete: true
Attachment #8486621 -
Flags: review?(jdaggett)
Assignee | ||
Comment 4•10 years ago
|
||
Updated to include support for drawing right-to-left textruns to canvas2d.
Attachment #8489618 -
Flags: review?(jdaggett)
Assignee | ||
Updated•10 years ago
|
Attachment #8487084 -
Attachment is obsolete: true
Attachment #8487084 -
Flags: review?(jdaggett)
Assignee | ||
Comment 5•10 years ago
|
||
Attachment #8490352 -
Flags: review?(smontagu)
Assignee | ||
Updated•10 years ago
|
Attachment #8489618 -
Attachment is obsolete: true
Attachment #8489618 -
Flags: review?(jdaggett)
Assignee | ||
Comment 6•10 years ago
|
||
Rebased this patch following bug 927892. (Also depends on review-pending patches in bug 902762.)
Attachment #8495164 -
Flags: review?(bas)
Assignee | ||
Updated•10 years ago
|
Attachment #8490352 -
Attachment is obsolete: true
Attachment #8490352 -
Flags: review?(smontagu)
Comment 7•10 years ago
|
||
Comment on attachment 8495164 [details] [diff] [review]
support textruns with vertical writing modes when drawing Canvas2D text.
Review of attachment 8495164 [details] [diff] [review]:
-----------------------------------------------------------------
I wonder if there's a way in which we could make this code a little cleaner, perhaps taking the conditions out of some of the loops somehow.
Assignee | ||
Comment 8•10 years ago
|
||
OK, here's a version that's a bit cleaner and easier to read, I think; it sets up 'inline' and 'block'-named aliases (references) for the x and y coordinates, allowing us to avoid a bunch of the nested if-else blocks. The overall effect is the same, but the code looks less cluttered. What I'd really like to do (as suggested by the comment in the code here) is to replace the guts of CanvasBidiProcessor::DrawText with code from gfxTextRun and gfxFont, which has to do all the same work, but last time I looked that was a bit awkward because the two areas of the codebase were at different stages of Moz2d-ification. So I think it's easiest to defer that refactoring to some future bug, and just handle the drawing of different direction runs in canvas manually for now.
Attachment #8496825 -
Flags: review?(bas)
Assignee | ||
Updated•10 years ago
|
Attachment #8495164 -
Attachment is obsolete: true
Attachment #8495164 -
Flags: review?(bas)
Comment 10•10 years ago
|
||
Comment on attachment 8496825 [details] [diff] [review]
support textruns with vertical writing modes when drawing Canvas2D text.
Review of attachment 8496825 [details] [diff] [review]:
-----------------------------------------------------------------
Sorry about missing this r?. This is a lot better indeed and a lot easier to read. I've got one comment which is a little bit of a nit, but I'm going to r- over it just to make sure we get this all right.
::: dom/canvas/CanvasRenderingContext2D.cpp
@@ +3213,5 @@
> + gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT) {
> + sideways = true;
> + mCtx->Save();
> + ErrorResult error;
> + mCtx->Translate(baselineOrigin.x, baselineOrigin.y, error);
This will result in a lot of wasteful sets and gets. Which are reasonably expensive. We should replace it with something like mCtx->SetMatrix(mCtx->GetMatrix().Copy().Translate().Rotate().Translate()) etc. I'd suggest we manipulate the Moz2D target directly and use AutoRestoreTransform (i.e. have an empty AutoRestoreTransform outside of the scope of this block, and Init it inside this block, see gfx/2d/Helpers.h). That'll prevent the wasteful full context save/restore pair in this situation as well.
Assignee | ||
Comment 11•10 years ago
|
||
Something like this? Note that I had to add the no-arg constructor to AutoRestoreTransform in Helpers.h, otherwise the compiler won't let me declare an empty instance.
Attachment #8500402 -
Flags: review?(bas)
Assignee | ||
Updated•10 years ago
|
Attachment #8496825 -
Attachment is obsolete: true
Attachment #8496825 -
Flags: review?(bas)
Comment 12•10 years ago
|
||
Comment on attachment 8500402 [details] [diff] [review]
Support textruns with vertical writing modes when drawing Canvas2D text.
Review of attachment 8500402 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good to me!
Attachment #8500402 -
Flags: review?(bas) → review+
Assignee | ||
Comment 13•10 years ago
|
||
Flags: needinfo?(bas)
Target Milestone: --- → mozilla35
Comment 14•10 years ago
|
||
Assignee | ||
Comment 15•10 years ago
|
||
Argh, warnings-as-errors strikes again. Relanded with fix:
https://hg.mozilla.org/integration/mozilla-inbound/rev/88bb2a142e10
Comment 16•10 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Comment 17•10 years ago
|
||
We should either back this out or fix the crashers asap.
(I asked Tomcat to back out, but perhaps there is a crash fix already coming.)
Comment 18•10 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #17)
> We should either back this out or fix the crashers asap.
> (I asked Tomcat to back out, but perhaps there is a crash fix already
> coming.)
backed out per irc request (as smaug mentioned) in remote: https://hg.mozilla.org/mozilla-central/rev/dd7637cc42d5 and will retrigger nightly builds
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Updated•10 years ago
|
Target Milestone: mozilla35 → ---
Assignee | ||
Comment 19•10 years ago
|
||
Comment on attachment 8500402 [details] [diff] [review]
Support textruns with vertical writing modes when drawing Canvas2D text.
Review of attachment 8500402 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/canvas/CanvasRenderingContext2D.cpp
@@ +3507,5 @@
> // offset pt.y based on text baseline
> processor.mFontgrp->UpdateUserFonts(); // ensure user font generation is current
> const gfxFont::Metrics& fontMetrics =
> + processor.mFontgrp->GetFirstValidFont()->GetMetrics(
> + processor.mTextRun->IsVertical() ? gfxFont::eVertical :
It turns out this isn't safe, as processor.mTextRun may not have been created yet; hence the crashes people have reported.
Instead, we can check the TEXT_ORIENTATION_MASK field of processor.mTextRunFlags to decide what to pass here.
Assignee | ||
Comment 20•10 years ago
|
||
Re-landed with fix:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1d454aaf1dec
Target Milestone: --- → mozilla35
Status: REOPENED → RESOLVED
Closed: 10 years ago → 10 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•