Bug 72095 - [chromium] Font::drawComplexText can not draw a segment of text run
Summary: [chromium] Font::drawComplexText can not draw a segment of text run
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-11 00:27 PST by Robin Cao
Modified: 2011-11-17 21:25 PST (History)
5 users (show)

See Also:


Attachments
proposed patch with test case (12.39 KB, patch)
2011-11-11 01:04 PST, Robin Cao
no flags Details | Formatted Diff | Diff
patch-v2 (12.87 KB, patch)
2011-11-15 10:04 PST, Robin Cao
no flags Details | Formatted Diff | Diff
patch-v3 (12.41 KB, patch)
2011-11-17 18:15 PST, Robin Cao
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Cao 2011-11-11 00:27:35 PST
The implementation of Font::drawComplexText() in Chromium Linux does not respect the |from| and |to| arguments. It just draws the whole text run. This will result in text overlap.
Comment 1 Robin Cao 2011-11-11 01:04:21 PST
Created attachment 114642 [details]
proposed patch with test case
Comment 2 Robin Cao 2011-11-11 19:47:13 PST
CC folks familiar with this part of the code
Comment 3 Kenichi Ishibashi 2011-11-14 02:01:39 PST
Comment on attachment 114642 [details]
proposed patch with test case

View in context: https://bugs.webkit.org/attachment.cgi?id=114642&action=review

Thanks for the patch. It looks good to me. Some minor comments follows.

> Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h:109
> +    const unsigned charStartPos() const { return m_item.item.pos; }

nit: WebKit doesn't prefer abbreviation. characterStartPosition() would be fine.

> Source/WebCore/platform/graphics/chromium/FontLinux.cpp:211
> +            // No chars in this item to display.

I think this comment is saying almost the same of above comment. Braces can be removed when this comment is no longer needed.

> Source/WebCore/platform/graphics/chromium/FontLinux.cpp:227
> +            continue;

How about having a function which takes |from| and |to| as arguments and handles these logic in ComplexTextController? The function would return false if there is no glyph to be displayed in the run. Otherwise, the function would return true and update values of length() and positions(). This way, we don't need to expose logclusters and beginning offset.

> Source/WebCore/platform/graphics/chromium/FontLinux.cpp:238
> +            canvas->drawPosText(controller.glyphs() + fromGlyph, glyphCount << 1, controller.positions() + fromGlyph, strokePaint);

If you agree with having a function that handle clipping in ComplexTextController, these changes might not be needed.
Comment 4 Robin Cao 2011-11-15 09:50:05 PST
Thanks for your comments.

> 
> > Source/WebCore/platform/graphics/chromium/FontLinux.cpp:211
> > +            // No chars in this item to display.
> 
> I think this comment is saying almost the same of above comment. Braces can be removed when this comment is no longer needed.

Good point.

> 
> > Source/WebCore/platform/graphics/chromium/FontLinux.cpp:227
> > +            continue;
> 
> How about having a function which takes |from| and |to| as arguments and handles these logic in ComplexTextController? The function would return false if there is no glyph to be displayed in the run. Otherwise, the function would return true and update values of length() and positions(). This way, we don't need to expose logclusters and beginning offset.

I agree that we should add a function here, but personally, i don't like the idea of updating values of length() and positions() after calling nextScriptRun(). How about adding a function glyphsForRange() which will return the start index and length of glyphs that we need to draw?
Comment 5 Robin Cao 2011-11-15 10:04:58 PST
Created attachment 115186 [details]
patch-v2
Comment 6 Robin Cao 2011-11-16 23:45:53 PST
ping : i have updated the patch, could you take a look at it?
Comment 7 Kenichi Ishibashi 2011-11-17 00:03:35 PST
(In reply to comment #6)
> ping : i have updated the patch, could you take a look at it?

Sorry for late response. Looks good to me. Please wait for official reviewers review.
Comment 8 Robin Cao 2011-11-17 00:08:46 PST
(In reply to comment #7)
> 
> Sorry for late response. Looks good to me. Please wait for official reviewers review.

Thank you very much.
Comment 9 Adam Barth 2011-11-17 17:20:23 PST
Comment on attachment 115186 [details]
patch-v2

View in context: https://bugs.webkit.org/attachment.cgi?id=115186&action=review

> Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp:548
> +void ComplexTextController::glyphsForRange(int from , int to, int& fromGlyph, int& glyphLength)

nit: "from ," has an extra space.

> LayoutTests/platform/chromium-linux/fast/text/international/draw-complex-text-from-to.html:11
> +<p>The text and ellipsis should not overlap.</p>

Should this test be run on all ports?
Comment 10 Tony Chang 2011-11-17 17:21:19 PST
Comment on attachment 115186 [details]
patch-v2

View in context: https://bugs.webkit.org/attachment.cgi?id=115186&action=review

>> LayoutTests/platform/chromium-linux/fast/text/international/draw-complex-text-from-to.html:11
>> +<p>The text and ellipsis should not overlap.</p>
> 
> Should this test be run on all ports?

Can you add a call to layoutTestController.dumpAsText(true) to not have the render tree in the text output?
Comment 11 Robin Cao 2011-11-17 17:29:45 PST
(In reply to comment #9)

> > Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp:548
> > +void ComplexTextController::glyphsForRange(int from , int to, int& fromGlyph, int& glyphLength)
> 
> nit: "from ," has an extra space.
> 

good catch! Will remove it.
Comment 12 Robin Cao 2011-11-17 17:35:00 PST
(In reply to comment #10)
> (From update of attachment 115186 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=115186&action=review
> 
> >> LayoutTests/platform/chromium-linux/fast/text/international/draw-complex-text-from-to.html:11
> >> +<p>The text and ellipsis should not overlap.</p>
> > 
> > Should this test be run on all ports?
> 
> Can you add a call to layoutTestController.dumpAsText(true) to not have the render tree in the text output?

It makes sense to call layoutTestController.dumpAsText(true). If this test be run on all ports, should i generate all the expected PNGs on all platform in this patch?
Comment 13 Robin Cao 2011-11-17 18:15:36 PST
Created attachment 115720 [details]
patch-v3
Comment 14 WebKit Review Bot 2011-11-17 21:25:17 PST
Comment on attachment 115720 [details]
patch-v3

Clearing flags on attachment: 115720

Committed r100718: <http://trac.webkit.org/changeset/100718>
Comment 15 WebKit Review Bot 2011-11-17 21:25:22 PST
All reviewed patches have been landed.  Closing bug.