Bug 266532 - [macOS] Form controls with visual overflow and `writing-mode: vertical-rl` do not fully repaint
Summary: [macOS] Form controls with visual overflow and `writing-mode: vertical-rl` do...
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: Aditya Keerthi
URL:
Keywords: BrowserCompat, InRadar, Regression
Depends on:
Blocks: 259380
  Show dependency treegraph
 
Reported: 2023-12-16 02:15 PST by Anne van Kesteren
Modified: 2024-01-08 21:40 PST (History)
7 users (show)

See Also:


Attachments
screenshot (7.19 KB, image/png)
2023-12-16 02:15 PST, Anne van Kesteren
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anne van Kesteren 2023-12-16 02:15:27 PST
Created attachment 469084 [details]
screenshot

While testing https://github.com/WebKit/WebKit/pull/21741 (bug 266347) I found an issue for this input:

data:text/html,<input%20type=checkbox%20switch%20style=width:10px;height:10px;writing-mode:vertical-rl>

I also tested it with writing-mode set on a parent:

data:text/html,<p%20style=writing-mode:vertical-rl><input%20type=checkbox%20switch%20style=width:10px;height:10px>

In both cases a repaint issue occurs.

This happens because of the flipForWritingModeCall() call in RenderBox::computeVisibleRectsInContainer():

    if (isWritingModeRoot()) {
        if (!isOutOfFlowPositioned() || !context.dirtyRectIsFlipped) {
            flipForWritingMode(adjustedRects);
            context.dirtyRectIsFlipped = true;
        }
    }

It incorrectly adjusts the x offset obtained from RenderThemeMac::adjustRepaintRect() at some earlier point. Removing the call to flipForWritingMode() here fixes the issue. In fact, making flipForWritingMode() a no-op fixes the issue, but I have not run all tests to see if that is the solution. I would appreciate some advice from a layout expert as I'm out of my depth.

I've attached a screenshot from the broken rendering. I'm not sure how to reproduce this without vertical switch support. Perhaps Aditya can think of another themed element with a similar issue.
Comment 1 Ahmad Saleem 2023-12-16 06:45:42 PST
I have seen Blink patch from 2014 / 2015 touching this function and removing 'OutOfFlow' condition. Although, we have added 'dirtyRect' context so I think we can remove it as well. I will try to find it, it might have failing test case as well.
Comment 2 Ahmad Saleem 2023-12-16 06:48:15 PST
Reference - https://src.chromium.org/viewvc/blink?view=revision&revision=177870
Comment 3 Anne van Kesteren 2023-12-16 08:08:29 PST
That's a nice find!

However, with that patch you'd still hit my issue. Because for my issue isWritingModeRoot() has to be true, and as it happens both isOutOfFlowPositioned() and context.dirtyRectIsFlipped are false.
Comment 4 Anne van Kesteren 2023-12-18 10:42:37 PST
This reproduces on macOS WebKit main

1. data:text/html,<input%20type=checkbox%20switch%20style=width:10px;height:10px;writing-mode:vertical-rl>
2. Click the switch in the top left corner.

The cause is vertical-rl, it does not reproduce with vertical-lr.
Comment 5 Anne van Kesteren 2023-12-18 23:40:18 PST
It seems this is a regression.

data:text/html,<input%20type=checkbox%20style=width:5px;height:5px;writing-mode:vertical-rl>

works fine in earlier releases.
Comment 6 Radar WebKit Bug Importer 2023-12-23 02:16:10 PST
<rdar://problem/120066970>
Comment 7 Aditya Keerthi 2024-01-08 11:46:43 PST
Pull request: https://github.com/WebKit/WebKit/pull/22516
Comment 8 EWS 2024-01-08 21:40:46 PST
Committed 272799@main (5cf446ee596f): <https://commits.webkit.org/272799@main>

Reviewed commits have been landed. Closing PR #22516 and removing active labels.