Bug 64553 - [Mac] REGRESSION(r90089): search field focus ring painted multiple times
Summary: [Mac] REGRESSION(r90089): search field focus ring painted multiple times
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.6
: P1 Normal
Assignee: Kent Tamura
URL:
Keywords: InRadar, Regression
Depends on:
Blocks:
 
Reported: 2011-07-14 12:59 PDT by Daniel Bates
Modified: 2012-03-01 15:35 PST (History)
10 users (show)

See Also:


Attachments
Example (215 bytes, text/html)
2011-07-14 12:59 PDT, Daniel Bates
no flags Details
[Screenshot] Type one character into search field (28.16 KB, image/png)
2011-07-14 13:02 PDT, Daniel Bates
no flags Details
[Screenshot] Type two words into search field (29.18 KB, image/png)
2011-07-14 13:03 PDT, Daniel Bates
no flags Details
Patch (12.82 KB, patch)
2011-07-28 06:02 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Patch 2 (40.75 KB, patch)
2011-07-28 18:28 PDT, Kent Tamura
eric: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2011-07-14 12:59:53 PDT
Created attachment 100848 [details]
Example

When typing into an <input type="search"> the focus rings appears to be drawn multiple times. This is particularly noticeable at the top and bottom-right corner of the focus ring which an extra line and a smear mark, respectively. The extra line seems to grow longer as you type more.
Comment 1 Daniel Bates 2011-07-14 13:02:17 PDT
Created attachment 100849 [details]
[Screenshot] Type one character into search field
Comment 2 Daniel Bates 2011-07-14 13:03:11 PDT
Created attachment 100850 [details]
[Screenshot] Type two words into search field

Notice the rendering artifacts around the top and bottom-right corner of the focus ring.
Comment 3 Daniel Bates 2011-07-14 13:11:32 PDT
For completeness, this issue can be seen in Mac nightly r90991. This issue isn't seen in shipping Safari Version 5.0.5 (6533.21.1) on Mac.
Comment 4 Alexey Proskuryakov 2011-07-14 15:18:28 PDT
<rdar://problem/9778524>
Comment 5 Alexey Proskuryakov 2011-07-14 15:19:37 PDT
See also: bug 10049.
Comment 6 Kent Tamura 2011-07-15 01:22:52 PDT
input[type="search"]:focus {
  outline-width: 6px;
}

fixes the problem.  Is this a correct fix?

I'm not sure what is the root cause.
I investigated how RenderTextControlSIngleLine::layout() and paint() were called.
When a user types a key, the followings are called:

r90088:
layout(), layout(), PaintPhaseBlockBackgound, PaintPhaseChildBlockBackgrounds, PaintPhaseFloat, PaintPhaseForeground, then PaintPhaseOutline.

r90089:
layout(), PaintPhaseBlockBackgound, PaintPhaseChildBlockBackgrounds, PaintPhaseFloat, PaintPhaseForeground, then PaintPhaseOutline.

It seems that there are no differences of the number of outline paintings.
Comment 7 Kent Tamura 2011-07-20 22:41:27 PDT
(In reply to comment #6)
> input[type="search"]:focus {
>   outline-width: 6px;
> }
> fixes the problem.  Is this a correct fix?

I found this fix was incomplete.

> r90088:
> layout(), layout(), PaintPhaseBlockBackgound, PaintPhaseChildBlockBackgrounds, PaintPhaseFloat, PaintPhaseForeground, then PaintPhaseOutline.
> 
> r90089:
> layout(), PaintPhaseBlockBackgound, PaintPhaseChildBlockBackgrounds, PaintPhaseFloat, PaintPhaseForeground, then PaintPhaseOutline.

The repainting areas were different:
r90088:
PaintInfo: context=0x7fff5fbfadc0 (7,41) 131x25 phase=BlockBackground root=0x0
PaintInfo: context=0x7fff5fbfadc0 (7,41) 131x25 phase=ChildBlockBackgrounds root=0x0
PaintInfo: context=0x7fff5fbfadc0 (7,41) 131x25 phase=Float root=0x0
PaintInfo: context=0x7fff5fbfadc0 (7,41) 131x25 phase=Foreground root=0x0
PaintInfo: context=0x7fff5fbfadc0 (7,41) 131x25 phase=Outline root=0x0

r90089 or later:
PaintInfo: context=0x7fff5fbfadc0 (24,39) 114x27 phase=BlockBackground root=0x0
PaintInfo: context=0x7fff5fbfadc0 (24,39) 114x27 phase=ChildBlockBackgrounds root=0x0
PaintInfo: context=0x7fff5fbfadc0 (24,39) 114x27 phase=Float root=0x0
PaintInfo: context=0x7fff5fbfadc0 (24,39) 114x27 phase=Foreground root=0x0
PaintInfo: context=0x7fff5fbfadc0 (24,39) 114x27 phase=Outline root=0x0
Comment 8 Jon Lee 2011-07-25 11:04:50 PDT
Using ToT, I am only seeing this on Snow Leopard, and not Lion. Also, I can repro the first screenshot (with the white line), but not the second (with the extra smudges). Has anything changed for your side?
Comment 9 Kent Tamura 2011-07-26 05:46:58 PDT
Well, I understand what's happening.

1. A user types into a search field.
2. The inner editable element is updated.
3. A rectangle larger than the rectangle of the inner editable element is invalidated.
  See RenderBox::clippedOverflowRectForRepaint(). We inflate the rectangle by RenderStyle::maximulOutlineSize() even if the style has no outline.
4. Clear the inflated rectangle.
  The search field border is cleared, but the focus ring outside of the inflated rectangle is not cleared.
5. Clip the graphics context with the inflated rectangle
6. Draw NSSearchFieldCell with the focus ring.  Surprisingly the focus ring ignores the clipping. So the outer part of focus ring is drawn onto an existing focus ring.

I guess Lion respects clipping in focus ring drawing.

I'll investigate how to fix this issue.
Comment 10 Kent Tamura 2011-07-28 06:02:42 PDT
Created attachment 102249 [details]
Patch
Comment 11 Kent Tamura 2011-07-28 06:04:59 PDT
(In reply to comment #10)
> Created an attachment (id=102249) [details]
> Patch

I confirmed the test failed without the patch.
Comment 12 WebKit Review Bot 2011-07-28 07:06:38 PDT
Comment on attachment 102249 [details]
Patch

Attachment 102249 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9266200

New failing tests:
fast/repaint/search-field-cancel.html
Comment 13 Kent Tamura 2011-07-28 18:28:58 PDT
Created attachment 102321 [details]
Patch 2

search-field-cance.html should be updated.
Comment 14 WebKit Review Bot 2011-07-28 18:32:47 PDT
Attachment 102321 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast..." exit_code: 1

ERROR: FAILURES FOR <linux, x86, release, cpu>
ERROR: Line:19 Test lacks BUG modifier. editing/selection/empty-cell-right-click.html
ERROR: Line:20 Test lacks BUG modifier. editing/selection/dump-as-markup.html
ERROR: Line:21 Test lacks BUG modifier. fast/js/array-sort-modifying-tostring.html
ERROR: Line:22 Test lacks BUG modifier. fast/overflow/lots-of-sibling-inline-boxes.html
ERROR: Line:23 Test lacks BUG modifier. inspector/cookie-resource-match.html
LayoutTests/platform/qt/test_expectations.txt:19:  Test lacks BUG modifier. editing/selection/empty-cell-right-click.html  [test/expectations] [2]
LayoutTests/platform/qt/test_expectations.txt:20:  Test lacks BUG modifier. editing/selection/dump-as-markup.html  [test/expectations] [2]
LayoutTests/platform/qt/test_expectations.txt:21:  Test lacks BUG modifier. fast/js/array-sort-modifying-tostring.html  [test/expectations] [2]
LayoutTests/platform/qt/test_expectations.txt:22:  Test lacks BUG modifier. fast/overflow/lots-of-sibling-inline-boxes.html  [test/expectations] [2]
LayoutTests/platform/qt/test_expectations.txt:23:  Test lacks BUG modifier. inspector/cookie-resource-match.html  [test/expectations] [2]
Total errors found: 5 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 Eric Seidel (no email) 2012-02-13 13:14:32 PST
Comment on attachment 102321 [details]
Patch 2

Looking at the pixel results, it looks like we're now invalidating more on the left hand side of the box, no?
Comment 16 Eric Seidel (no email) 2012-03-01 15:35:06 PST
Comment on attachment 102321 [details]
Patch 2

Please explain the pixel result change (since it looks like we're painting more, not less).  Otherwise I'm happhy to review this once you do.