Bug 214333 - Caret leaves trails behind when the editable content is subpixel positioned
Summary: Caret leaves trails behind when the editable content is subpixel positioned
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
: 213300 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-07-14 16:58 PDT by zalan
Modified: 2020-07-15 11:20 PDT (History)
7 users (show)

See Also:


Attachments
Patch (7.47 KB, patch)
2020-07-14 17:06 PDT, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zalan 2020-07-14 16:58:46 PDT
<rdar://problem/61914738>
Comment 1 zalan 2020-07-14 17:06:01 PDT
Created attachment 404310 [details]
Patch
Comment 2 EWS 2020-07-14 19:46:36 PDT
Committed r264386: <https://trac.webkit.org/changeset/264386>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 404310 [details].
Comment 3 mitz 2020-07-14 20:11:42 PDT
I wonder if this fixes bug 213300 as well.
Comment 4 zalan 2020-07-14 20:17:07 PDT
*** Bug 213300 has been marked as a duplicate of this bug. ***
Comment 5 zalan 2020-07-14 20:18:11 PDT
(In reply to mitz from comment #3)
> I wonder if this fixes bug 213300 as well.
It indeed did. Thanks!
Comment 6 Darin Adler 2020-07-15 10:01:18 PDT
Comment on attachment 404310 [details]
Patch

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

I like all the const and upgrading to references, but landing all of those does seem to sort of hide the fix, which I assume was just adding the call to snapRectToDevicePixels?

Can we create a regression test?

> Source/WebCore/editing/FrameSelection.cpp:1787
> +    if (m_selection.isCaret() && m_caretPaint && m_selection.start().deprecatedNode())

What motivated the addition of this null check? The old code just assumed this is non-null.

> Source/WebCore/editing/FrameSelection.cpp:2291
> +    if (m_position.deepEquivalent().deprecatedNode() && m_position.deepEquivalent().deprecatedNode()->document().frame() == frame)

What motivated the addition of this null check?
Comment 7 zalan 2020-07-15 11:20:40 PDT
(In reply to Darin Adler from comment #6)
> Comment on attachment 404310 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=404310&action=review
> 
> I like all the const and upgrading to references, but landing all of those
> does seem to sort of hide the fix, which I assume was just adding the call
> to snapRectToDevicePixels?
Yes, the fix is simply going from roundedIntPoint to snapRectToDevicePixels. I tend to go with a pre-cleanup first and land the fix separately, so not sure what happened here. I think the initial const change looked small enough to land it together with the fix and I didn't really pay attention to how much additional changes it required at the end. In retrospect, I should have done my usual pre-cleanup setup here.


> 
> Can we create a regression test?
I tried but I couldn't think of a good way of (ref)testing a blinking caret. I can't even use the usual "collect the repaint rects" as the repaint rect are correct here. I am happy to create one if someone has some ideas.

> 
> > Source/WebCore/editing/FrameSelection.cpp:1787
> > +    if (m_selection.isCaret() && m_caretPaint && m_selection.start().deprecatedNode())
> 
> What motivated the addition of this null check? The old code just assumed
> this is non-null.
> 
> > Source/WebCore/editing/FrameSelection.cpp:2291
> > +    if (m_position.deepEquivalent().deprecatedNode() && m_position.deepEquivalent().deprecatedNode()->document().frame() == frame)
> 
> What motivated the addition of this null check?
>The old code just assumed this is non-null.
I noticed this pattern in the rendering code. The initial implementation, probably correctly, assumed a never-nullptr value (this was before we started using references extensively) but it may not be true today as the code evolved over time (hence all the drive-by reference changes). This code just looked unsafe to me.
(I personally very much dislike random null-checks in the code and prefer references when possible)