Bug 122716 - Broken text rendering when input field has selection.
Summary: Broken text rendering when input field has selection.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: http://www.spanishdict.com/translate/...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-12 23:46 PDT by peavo
Modified: 2013-10-15 04:07 PDT (History)
5 users (show)

See Also:


Attachments
Patch (4.18 KB, patch)
2013-10-12 23:52 PDT, peavo
no flags Details | Formatted Diff | Diff
Image showing broken text rendering on WinCairo (31.06 KB, image/png)
2013-10-13 07:18 PDT, peavo
no flags Details
Testcase for broken text rendering (794 bytes, text/html)
2013-10-13 09:39 PDT, peavo
no flags Details
Patch (2.65 KB, patch)
2013-10-14 01:40 PDT, peavo
no flags Details | Formatted Diff | Diff
Patch (3.69 KB, patch)
2013-10-14 02:31 PDT, peavo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description peavo 2013-10-12 23:46:09 PDT
In the last builds, I see broken text rendering in some places. It seems the text color is wrong.
Comment 1 peavo 2013-10-12 23:52:32 PDT
Created attachment 214086 [details]
Patch
Comment 2 Antti Koivisto 2013-10-13 02:04:25 PDT
Comment on attachment 214086 [details]
Patch

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

This needs a test case. It should be easy to make one as a ref test. See tests with -expected.html under LayoutTests/fast/text/ for example.

r- because lack of test case or even information how to reproduce the bug.

> Source/WebCore/ChangeLog:3
> +        Broken text rendering in some cases.

What cases? The bug description doesn't say either.

> Source/WebCore/rendering/InlineTextBox.cpp:551
> -    TextPaintStyle selectionPaintStyle = computeTextSelectionPaintStyle(textPaintStyle, renderer(), lineStyle, paintInfo, paintSelectedTextOnly, paintSelectedTextSeparately, selectionShadow);
> -
> +    TextPaintStyle selectionPaintStyle = computeTextSelectionPaintStyle(textPaintStyle, renderer(), lineStyle, paintInfo, haveSelection, paintSelectedTextOnly, paintSelectedTextSeparately, selectionShadow);

Instead of adding an extra boolean parameter it would be better to just not call computeTextSelectionPaintStyle if haveSelection is false.
Comment 3 peavo 2013-10-13 06:04:33 PDT
(In reply to comment #2)
> (From update of attachment 214086 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=214086&action=review
> 
> This needs a test case. It should be easy to make one as a ref test. See tests with -expected.html under LayoutTests/fast/text/ for example.
> 
> r- because lack of test case or even information how to reproduce the bug.
> 
> > Source/WebCore/ChangeLog:3
> > +        Broken text rendering in some cases.
> 
> What cases? The bug description doesn't say either.
> 

Sorry for the short description :) I added an url where it can be reproduced, at least when running WinCairo. 

> > Source/WebCore/rendering/InlineTextBox.cpp:551
> > -    TextPaintStyle selectionPaintStyle = computeTextSelectionPaintStyle(textPaintStyle, renderer(), lineStyle, paintInfo, paintSelectedTextOnly, paintSelectedTextSeparately, selectionShadow);
> > -
> > +    TextPaintStyle selectionPaintStyle = computeTextSelectionPaintStyle(textPaintStyle, renderer(), lineStyle, paintInfo, haveSelection, paintSelectedTextOnly, paintSelectedTextSeparately, selectionShadow);
> 
> Instead of adding an extra boolean parameter it would be better to just not call computeTextSelectionPaintStyle if haveSelection is false.

OK, but isn't there some initialization at the beginning of computeTextSelectionPaintStyle that needs to be done even if haveSelection is false?
Comment 4 Antti Koivisto 2013-10-13 06:54:20 PDT
(In reply to comment #3)
> OK, but isn't there some initialization at the beginning of computeTextSelectionPaintStyle that needs to be done even if haveSelection is false?

Maybe though it seems wrong that we actually use any of this stuff when haveSelection is false.
Comment 5 Antti Koivisto 2013-10-13 06:59:28 PDT
I don't see anything obviously wrong with the page on mac. Can you include a screenshot?

It is possible that this is just exposing a WinCairo bug.
Comment 6 peavo 2013-10-13 07:13:35 PDT
(In reply to comment #5)
> I don't see anything obviously wrong with the page on mac. Can you include a screenshot?
> 

Yes, will do. I also see it when searching for changesets: e.g: http://trac.webkit.org/search?q=157000

> It is possible that this is just exposing a WinCairo bug.

That could very well be. I also noticed that there used to be a check for haveSelection.
Comment 7 peavo 2013-10-13 07:18:03 PDT
Created attachment 214100 [details]
Image showing broken text rendering on WinCairo
Comment 8 Antti Koivisto 2013-10-13 07:21:58 PDT
Mac rendering of that page looks fine.
Comment 9 peavo 2013-10-13 07:39:31 PDT
(In reply to comment #8)
> Mac rendering of that page looks fine.

Ok, will have a look at platform code :)
Comment 10 Antti Koivisto 2013-10-13 08:38:42 PDT
Does this fix it?

--- Source/WebCore/rendering/InlineTextBox.cpp	(revision 157368)
+++ Source/WebCore/rendering/InlineTextBox.cpp	(working copy)
@@ -610,7 +610,7 @@
 
     int sPos = 0;
     int ePos = 0;
-    if (paintSelectedTextOnly || paintSelectedTextSeparately)
+    if (haveSelection && (paintSelectedTextOnly || paintSelectedTextSeparately))
         selectionStartEnd(sPos, ePos);
 
     if (m_truncation != cNoTruncation) {
Comment 11 peavo 2013-10-13 09:01:01 PDT
(In reply to comment #10)
> Does this fix it?
> 
> --- Source/WebCore/rendering/InlineTextBox.cpp    (revision 157368)
> +++ Source/WebCore/rendering/InlineTextBox.cpp    (working copy)
> @@ -610,7 +610,7 @@
> 
>      int sPos = 0;
>      int ePos = 0;
> -    if (paintSelectedTextOnly || paintSelectedTextSeparately)
> +    if (haveSelection && (paintSelectedTextOnly || paintSelectedTextSeparately))
>          selectionStartEnd(sPos, ePos);
> 
>      if (m_truncation != cNoTruncation) {

Yes, that does the trick :) Commit?
Comment 12 Antti Koivisto 2013-10-13 09:06:34 PDT
If you could make a reduced test case that would be neat. Maybe I can figure out how to make the bug visible on mac too.
Comment 13 peavo 2013-10-13 09:39:37 PDT
Created attachment 214105 [details]
Testcase for broken text rendering
Comment 14 peavo 2013-10-13 09:42:01 PDT
(In reply to comment #12)
> If you could make a reduced test case that would be neat. Maybe I can figure out how to make the bug visible on mac too.

I attached a somewhat reduced test case. Pretty weird though, seems there needs to be an input field with some content, which receives focus, for the bug to appear ...
Comment 15 peavo 2013-10-14 01:40:39 PDT
Created attachment 214133 [details]
Patch
Comment 16 peavo 2013-10-14 01:41:39 PDT
(In reply to comment #10)
> Does this fix it?
> 
> --- Source/WebCore/rendering/InlineTextBox.cpp    (revision 157368)
> +++ Source/WebCore/rendering/InlineTextBox.cpp    (working copy)
> @@ -610,7 +610,7 @@
> 
>      int sPos = 0;
>      int ePos = 0;
> -    if (paintSelectedTextOnly || paintSelectedTextSeparately)
> +    if (haveSelection && (paintSelectedTextOnly || paintSelectedTextSeparately))
>          selectionStartEnd(sPos, ePos);
> 
>      if (m_truncation != cNoTruncation) {

Updated the patch with your fix, and a testcase.
Comment 17 Antti Koivisto 2013-10-14 02:00:38 PDT
Comment on attachment 214133 [details]
Patch

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

The test case is missing a file. It also doesn't work on mac (it might by setting some selection colours) but that's ok. At least it can be tested exercises the code paths (and can be tested manually on wincairo).

> LayoutTests/ChangeLog:8
> +        * fast/text/text-rendering-with-input-selection-expected.html: Added.

Ref test should have two files: text-rendering-with-input-selection.html and  text-rendering-with-input-selection-expected.html

The test works by generating bitmap from both and comparing them. -expected should contain something that renders the same exact way as the test case but does so without hitting the bug.
Comment 18 peavo 2013-10-14 02:31:34 PDT
Created attachment 214137 [details]
Patch
Comment 19 peavo 2013-10-14 02:33:07 PDT
(In reply to comment #17)
> (From update of attachment 214133 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=214133&action=review
> 
> The test case is missing a file. It also doesn't work on mac (it might by setting some selection colours) but that's ok. At least it can be tested exercises the code paths (and can be tested manually on wincairo).
> 
> > LayoutTests/ChangeLog:8
> > +        * fast/text/text-rendering-with-input-selection-expected.html: Added.
> 
> Ref test should have two files: text-rendering-with-input-selection.html and  text-rendering-with-input-selection-expected.html
> 
> The test works by generating bitmap from both and comparing them. -expected should contain something that renders the same exact way as the test case but does so without hitting the bug.

Thanks for clearifying, updated patch :)
Comment 20 Antti Koivisto 2013-10-14 03:08:24 PDT
Comment on attachment 214137 [details]
Patch

r=me
Comment 21 WebKit Commit Bot 2013-10-14 03:31:58 PDT
Comment on attachment 214137 [details]
Patch

Clearing flags on attachment: 214137

Committed r157392: <http://trac.webkit.org/changeset/157392>
Comment 22 WebKit Commit Bot 2013-10-14 03:32:01 PDT
All reviewed patches have been landed.  Closing bug.
Comment 23 peavo 2013-10-15 03:44:25 PDT
(In reply to comment #20)
> (From update of attachment 214137 [details])
> r=me

Thanks :)

On another note, I was just wondering if the function updateGraphicsContext when called with UseEmphasisMarkColor should set the fill color from the emphasisMarkColor, instead of the stroke color? I'm not sure though ...
Comment 24 Antti Koivisto 2013-10-15 03:57:02 PDT
> On another note, I was just wondering if the function updateGraphicsContext when called with UseEmphasisMarkColor should set the fill color from the emphasisMarkColor, instead of the stroke color? I'm not sure though ...

You are right, looks like that has been switched around. Can you file a bug? Test case would be nice too :)
Comment 25 peavo 2013-10-15 04:07:21 PDT
(In reply to comment #24)
> > On another note, I was just wondering if the function updateGraphicsContext when called with UseEmphasisMarkColor should set the fill color from the emphasisMarkColor, instead of the stroke color? I'm not sure though ...
> 
> You are right, looks like that has been switched around. Can you file a bug? Test case would be nice too :)

Yes, will file a bug, and see if I am able to come up with a testcase aswell ;)