Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8d7b28e8a7123325243f1521cfcf0abce5fd50c5
      
https://github.com/WebKit/WebKit/commit/8d7b28e8a7123325243f1521cfcf0abce5fd50c5
  Author: Mike Wyrzykowski <[email protected]>
  Date:   2025-11-04 (Tue, 04 Nov 2025)

  Changed paths:
    M Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
    M Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
    M Tools/TestWebKitAPI/Tests/WebCore/DisplayListRecorderTests.cpp

  Log Message:
  -----------
  initialClip is not transformed by the CTM, leading to cursor clipping during 
dictation
rdar://161084596
https://bugs.webkit.org/show_bug.cgi?id=301729

Reviewed by Simon Fraser.

There was a missing transform on the display list side with regards to initial 
clip
and a duplicate transform occurring on the GraphicsContextCG side.

* Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::Recorder):
As seen in Recorder's constructor, the state stack expects the clipping
matrix to be transformed:

    m_stateStack.append({ state, initialCTM, initialCTM.mapRect(initialClip) });

but we had left m_initialClip assigned to the untranformed clip rect and then
later directly assigned it to currentState().clipBounds which incorrectly mapped
the untransformed clip rect to the clip bounds.

(WebCore::DisplayList::Recorder::updateStateForResetClip):

The GraphicsContextCG side is invoked via 
RemoteGraphicsContextProxy::resetClip()
which calls Recorder::updateStateForClip() which we see:
   currentState().clipBounds.intersect(currentState().ctm.mapRect(rect));

but when we pass initialClip(), we want the result of:

m_initialClip = CTM * (some matrix K) * m_initialClip

solving for K, K = CTM^(-1) which is what initialClip() returns now.

(WebCore::DisplayList::Recorder::initialClip const):
The CTM should always be invertible but handle the case, e.g., a zero
scale, where it is not invertible.

I hesitate to add a debug assertion as I'm not sure if there are valid
use cases for a zero transform which would cause the assertion to trigger.

* Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::initialClip const): Deleted.
Moved to the .cpp file

* Tools/TestWebKitAPI/Tests/WebCore/DisplayListRecorderTests.cpp:
Update test to add a transform which would have detected this bug.

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



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

Reply via email to