Closed Bug 734319 Opened 13 years ago Closed 13 years ago

nsTextFrame::DrawTextRunAndDecorations should limit decoration to the offset/length given

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: heycam, Assigned: heycam)

References

Details

Attachments

(1 file)

nsTextFrame::DrawTextRunAndDecorations currently restricts any line decorations that it draws to aClipEdges but not to aOffset/aLength. I am calling into the nsTextFrame::PaintText with specific offset/lengths to paint substrings of a text frame and this is currently painting the decoration for the entire width of the frame.
Measure the substring of the text run to determine how much decoration to paint.
Attachment #604302 - Flags: review?(dbaron)
Assignee: nobody → cam
Status: NEW → ASSIGNED
Whiteboard: [autoland]
Blocks: svgtext
Whiteboard: [autoland] → [autoland-try]
Whiteboard: [autoland-try] → [autoland-in-queue]
Autoland Patchset: Patches: 604302 Branch: mozilla-central => try Destination: http://hg.mozilla.org/try/pushloghtml?changeset=5d90a5a2a32d Try run started, revision 5d90a5a2a32d. To cancel or monitor the job, see: https://tbpl.mozilla.org/?tree=Try&rev=5d90a5a2a32d
Forgot to #include <limits>...
Comment on attachment 604302 [details] [diff] [review] Limit line decorations to the given offset/length when painting a text frame. >+ nscoord width; >+ if (aOffset == 0 && aLength == std::numeric_limits<PRUint32>::max()) { >+ width = GetRect().width; Is that really the normal-case value of aLength? (And if it is, can you just write it as PR_UINT32_MAX ?)
Comment on attachment 604302 [details] [diff] [review] Limit line decorations to the given offset/length when painting a text frame. (In reply to David Baron [:dbaron] from comment #4) > Is that really the normal-case value of aLength? Hmm, I got confused with other local changes I've got in my tree. Will check and revise.
Attachment #604302 - Flags: review?(dbaron)
Try run for 5d90a5a2a32d is complete. Detailed breakdown of the results available here: https://tbpl.mozilla.org/?tree=Try&rev=5d90a5a2a32d Results (out of 14 total builds): success: 2 failure: 12 Builds (or logs if builds failed) available at: http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/autolanduser@mozilla.com-5d90a5a2a32d
Whiteboard: [autoland-in-queue]
Sorry for the drive-by review, but I don't think this is the right place to do this. If aOffset/aLength is a sub-range of the frame's text then aClipEdges is expected to clip to that range. It is the *caller's* responsibility calculate this (if clipping text-decorations is desired).
Mats, I guess I could compute the points for aClipEdges so that it clips to the characters that I want, but I already have a content offset/length. Is it worth it to turn these into nscoords just so that they can be converted back to the offset/length pair to restrict the decoration rendering to?
Or are there currently situations where we do need to render a substring of the frame's glyphs but say all of the decoration?
> Is it worth it to turn these into nscoords just so that they can be converted > back to the offset/length pair to restrict the decoration rendering to? What do you mean? there's no "converting back" going on in this method. Drawing the text use aOffset/aLength, drawing the decorations use nscoord that comes from GetRect().width, clipped to aClipEdges. On the contrary, the suggested patch would slow down existing callers that already provides a correct aOffset/aLength/aClipEdges by doing a redundant mTextRun->GetAdvanceWidth(). Currently we calculate aClipEdges *once* and then pass that around to a bunch of helper methods that does the drawing. Calculating the clip in each of the leaf methods would be much more expensive. Consider for example: PaintTextWithSelectionColors for (PRUint32 i = textStyle->mTextShadow->Length(); i > 0; --i) { PaintOneShadow DrawText DrawTextRunAndDecorations > Or are there currently situations where we do need to render a substring of > the frame's glyphs but say all of the decoration? No, I don't think so.
OK, fair enough, thanks.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: