Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ee7894b212d0f8e3c7783db35042142fb472ce31
      
https://github.com/WebKit/WebKit/commit/ee7894b212d0f8e3c7783db35042142fb472ce31
  Author: Joanne Pan <[email protected]>
  Date:   2026-09-22 (Tue, 22 Sep 2026)

  Changed paths:
    M LayoutTests/editing/caret/caret-color-legibility-after-paste-expected.txt
    M LayoutTests/editing/caret/caret-color-legibility-after-paste.html
    M Source/WebCore/editing/FrameSelection.cpp

  Log Message:
  -----------
  mail.yahoo.com: v2 Copying Text change caret color to text color from copied 
article and make it difficult to find (when Dark Mode + Dark Text copied)
https://bugs.webkit.org/show_bug.cgi?id=323909
rdar://186543233

Reviewed by Wenson Hsieh.

The problem:
A caret at the end of a pasted run still uses the pasted text's color, 1.46:1 
against the
dark editor. 322506 only fixed this for content that fits on one line. It picks 
the inline
box by intersecting with the caret rect, and a caret is taller than its line 
box, so the
rect also hits the previous line of a wrapped run. That box spans the 
containing block's
width, so the midpoint test reports the caret as covered by the pasted 
background.

The fix:
inlineBackgroundCoversCaret now picks the inline's own inline box on the 
caret's line by the
caret's block-axis midpoint, and asks whether that box contains the caret. The 
background
paints into the inline box, so that is the box to test: measuring descendant 
text runs
instead misses inline padding and atomic inline children, and has to cross 
formatting
context boundaries to find them.

Also fixed here:
Subtract the caret painter's scrollPosition, which localCaretRect carries but 
box rects do not.
Collapse the surface back to one blended color, so a translucent inline 
background counts again.
Pick black or white by comparing contrast rather than thresholding luminance at 
0.5.
Match the test's sRGB threshold to ColorTransferFunctions.h.

rendererSkippingInlinesNotPaintingUnderCaret goes away with it. It returned the 
parent inline's
caret color outright, with no contrast check, so an editable with a light color 
and a light
background handed back an invisible caret. The surface walk now covers that 
case.

Test: editing/caret/caret-color-legibility-after-paste.html
Cases 7, 9 and 14 fail without this change. 14 fails if only the scrollPosition 
line is dropped.

Canonical link: https://commits.webkit.org/321615@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to