Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: dcb25ff14a12a2975d67b3de8d90bd9d42162407
      
https://github.com/WebKit/WebKit/commit/dcb25ff14a12a2975d67b3de8d90bd9d42162407
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-09-02 (Wed, 02 Sep 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-001-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-001-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-001.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-002-expected.html
    A
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-002-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-002.html
    M Source/WebCore/Modules/highlight/Highlight.cpp
    M Source/WebCore/Modules/highlight/Highlight.h
    M Source/WebCore/Modules/highlight/HighlightRegistry.cpp
    M Source/WebCore/dom/Document.cpp

  Log Message:
  -----------
  Second CSS Highlight sharing a Range with an already-registered Highlight 
never paints
https://bugs.webkit.org/show_bug.cgi?id=321994
rdar://185173794

Reviewed by Megan Gardner.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

HighlightRange caches the resolved Positions that painting uses, but the dirty
bit driving their recomputation lives on Range, so it is shared by every
Highlight wrapping that Range while
collectHighlightRangesFromRegister() only
visits Highlights already in the registry before resetting it.

With two Highlights over one Range and only the first registered, the next
rendering update resolves positions for the registered one and clears the shared
flag, leaving the other HighlightRange with null positions. Registering it later
only repaints, so the collect loop skips it permanently,
RenderHighlight::setRenderRange() bails on the null positions, and the highlight
never paints.

Track the dirtiness per HighlightRange so a newly created one always resolves 
its
positions on the next rendering update, and mark a Highlight's ranges as needing
a position update when it is registered so one that went stale while 
unregistered
is repositioned instead of painting at its old offsets.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-001-expected.html:
 Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-001-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-001.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-002-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-002-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-two-highlights-same-range-002.html:
 Added.
* Source/WebCore/Modules/highlight/Highlight.cpp:
(WebCore::Highlight::setAllRangesNeedPositionUpdate):
* Source/WebCore/Modules/highlight/Highlight.h:
(WebCore::HighlightRange::needsPositionUpdate
const):
(WebCore::HighlightRange::setNeedsPositionUpdate):
(WebCore::HighlightRange::didUpdatePositions):
* Source/WebCore/Modules/highlight/HighlightRegistry.cpp:
(WebCore::HighlightRegistry::setFromMapLike):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::collectHighlightRangesFromRegister):
(WebCore::Document::updateHighlightPositions):

Canonical link: 
https://flagged.apple.com:443/proxy?t2=Ds1w5e9Ix1&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzIwMzU1QG1haW4=&emid=86667073-5e2a-4070-a0fa-f32eb93f41a6&c=11



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

Reply via email to