Bug 236061 - The background of the main frame's transparent custom scrollbar should be filled with the view background color if !HAVE(RUBBER_BANDING)
Summary: The background of the main frame's transparent custom scrollbar should be fil...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Compositing (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on: 243306 243641
Blocks: 243648
  Show dependency treegraph
 
Reported: 2022-02-03 00:04 PST by Fujii Hironori
Modified: 2022-08-09 04:11 PDT (History)
13 users (show)

See Also:


Attachments
test case (915 bytes, text/html)
2022-02-03 00:04 PST, Fujii Hironori
no flags Details
test case (394 bytes, text/html)
2022-07-14 17:53 PDT, Fujii Hironori
no flags Details
test case (460 bytes, text/html)
2022-07-19 22:04 PDT, Fujii Hironori
no flags Details
Patch (4.18 KB, patch)
2022-07-19 22:43 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (6.27 KB, patch)
2022-07-20 20:54 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (6.31 KB, patch)
2022-07-20 20:57 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (6.42 KB, patch)
2022-07-20 23:53 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch for landing (6.42 KB, patch)
2022-07-25 14:03 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch for landing (6.50 KB, patch)
2022-07-29 00:10 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch for landing (6.50 KB, patch)
2022-07-29 00:12 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (6.50 KB, patch)
2022-08-04 18:40 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
[Screenshot] GTK regression (104.78 KB, image/png)
2022-08-07 12:41 PDT, Alice Mikhaylenko
no flags Details
Patch (6.58 KB, patch)
2022-08-07 17:55 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (7.26 KB, patch)
2022-08-07 22:23 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Corner issue screenshot (660.02 KB, image/png)
2022-08-08 15:03 PDT, Alice Mikhaylenko
no flags Details
Test case patch (8.55 KB, patch)
2022-08-08 15:07 PDT, Alice Mikhaylenko
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2022-02-03 00:04:48 PST
Created attachment 450738 [details]
test case

[WinCairo] transparent scrollbar layer doesn't repaint correctly

WinCairo can't render YouTube's custom scrollbar correctly.
Comment 1 Fujii Hironori 2022-07-14 17:53:13 PDT
Created attachment 460919 [details]
test case
Comment 2 Fujii Hironori 2022-07-19 00:33:08 PDT
Mac WK2 enables HAVE_RUBBER_BANDING and ENABLE_RUBBER_BANDING,
There is m_layerForOverhangAreas layer.

Mac WK1 and iOS don't seem to support custom scrollbar.
Comment 3 Fujii Hironori 2022-07-19 17:04:55 PDT
In GTK port, the background of the custom scrollbar is always black, because it clears color buffers with black.
It doesn't have the repainting issue because it clears the background for every frames.
If I disable it, it also has the same issue with WinCairo.

diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
index 57537cf53881..2f133b10e61f 100644
--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
@@ -234,7 +234,7 @@ void ThreadedCompositor::renderLayerTree()
         glViewport(0, 0, viewportSize.width(), viewportSize.height());
 
     glClearColor(0, 0, 0, 0);
-    glClear(GL_COLOR_BUFFER_BIT);
+    //glClear(GL_COLOR_BUFFER_BIT);
 
     m_scene->applyStateChanges(states);
     m_scene->paintToCurrentGLContext(viewportTransform, FloatRect { FloatPoint { }, viewportSize }, m_paintFlags);
Comment 4 Fujii Hironori 2022-07-19 22:04:23 PDT
Created attachment 461033 [details]
test case
Comment 5 Fujii Hironori 2022-07-19 22:07:53 PDT
Only scrollbar corner is filled with the background color.
https://github.com/WebKit/WebKit/blob/4c3c8c892f788fe62ab12e103a5b3d0f1132b108/Source/WebCore/page/FrameView.cpp#L4268
Comment 6 Fujii Hironori 2022-07-19 22:43:52 PDT
Created attachment 461039 [details]
Patch
Comment 7 Fujii Hironori 2022-07-20 20:54:04 PDT
Created attachment 461071 [details]
Patch
Comment 8 Fujii Hironori 2022-07-20 20:57:21 PDT
Created attachment 461072 [details]
Patch
Comment 9 Fujii Hironori 2022-07-20 23:53:06 PDT
Created attachment 461108 [details]
Patch
Comment 10 Darin Adler 2022-07-25 10:06:22 PDT
Comment on attachment 461108 [details]
Patch

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

> Source/WebCore/rendering/RenderLayerCompositor.cpp:3655
> +    if (backgroundColor.isValid())

In cases like this, I think it’s good to use isVisible() instead of isValid(). That’s guaranteed to return false for invalid color, but also returns false for fully transparent colors which don’t need painting.

On the other hand, maybe fillRect() already does an isVisible() check (I didn’t look). In that case, we don’t need the isValid() check either.
Comment 11 Fujii Hironori 2022-07-25 13:25:57 PDT
Comment on attachment 461108 [details]
Patch

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

>> Source/WebCore/rendering/RenderLayerCompositor.cpp:3655
>> +    if (backgroundColor.isValid())
> 
> In cases like this, I think it’s good to use isVisible() instead of isValid(). That’s guaranteed to return false for invalid color, but also returns false for fully transparent colors which don’t need painting.
> 
> On the other hand, maybe fillRect() already does an isVisible() check (I didn’t look). In that case, we don’t need the isValid() check either.

Color::isVisible doesn't explicitly check Valid flag, but assuming the invalid color has black transparent. So, isVisible returns false for the invalid color.

GraphicsContextCG::fillRect doesn't check the invalid color, it fills with black transparent in case of the invalid color.
Comment 12 Darin Adler 2022-07-25 13:32:12 PDT
Comment on attachment 461108 [details]
Patch

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

>>> Source/WebCore/rendering/RenderLayerCompositor.cpp:3655
>>> +    if (backgroundColor.isValid())
>> 
>> In cases like this, I think it’s good to use isVisible() instead of isValid(). That’s guaranteed to return false for invalid color, but also returns false for fully transparent colors which don’t need painting.
>> 
>> On the other hand, maybe fillRect() already does an isVisible() check (I didn’t look). In that case, we don’t need the isValid() check either.
> 
> Color::isVisible doesn't explicitly check Valid flag, but assuming the invalid color has black transparent. So, isVisible returns false for the invalid color.
> 
> GraphicsContextCG::fillRect doesn't check the invalid color, it fills with black transparent in case of the invalid color.

Yes, invalid is guaranteed to also be transparent black. I suggest changing this to isVisible.
Comment 13 Fujii Hironori 2022-07-25 14:03:17 PDT
Created attachment 461202 [details]
Patch for landing
Comment 14 EWS 2022-07-25 15:14:40 PDT
Committed 252803@main (386d6b252a24): <https://commits.webkit.org/252803@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 461202 [details].
Comment 15 Radar WebKit Bug Importer 2022-07-25 15:15:18 PDT
<rdar://problem/97572054>
Comment 16 Robert Jenner 2022-07-25 17:09:54 PDT
Re-opening for pull request https://github.com/WebKit/WebKit/pull/2352
Comment 17 WebKit Commit Bot 2022-07-28 11:22:17 PDT
Re-opened since this is blocked by bug 243306
Comment 18 Fujii Hironori 2022-07-29 00:10:14 PDT
Created attachment 461289 [details]
Patch for landing
Comment 19 Fujii Hironori 2022-07-29 00:12:52 PDT
Created attachment 461290 [details]
Patch for landing
Comment 20 Darin Adler 2022-07-29 10:01:27 PDT
Comment on attachment 461290 [details]
Patch for landing

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

> Source/WebCore/rendering/RenderLayerCompositor.cpp:3660
> +#if HAVE(RUBBER_BANDING)
> +    UNUSED_PARAM(backgroundColor);
> +#else

You can’t use an #if for WebKit1 vs. WebKit2, because both share the same underlying WebCore.
Comment 21 Fujii Hironori 2022-08-04 18:36:02 PDT
This patch has no effect for Cocoa ports.
EWS reported a test failure for the new test. This is another problem. I fixed it in bug#243422.
I'm going to submit the patch for EWS again.
Comment 22 Fujii Hironori 2022-08-04 18:40:27 PDT
Created attachment 461411 [details]
Patch
Comment 23 EWS 2022-08-05 00:49:27 PDT
Committed 253142@main (a905abaab2bd): <https://commits.webkit.org/253142@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 461411 [details].
Comment 24 Alice Mikhaylenko 2022-08-07 12:40:46 PDT
This regressed GTK overlay scrollbars, they now have a random background.
Comment 25 Alice Mikhaylenko 2022-08-07 12:41:23 PDT
Created attachment 461465 [details]
[Screenshot] GTK regression
Comment 26 Fujii Hironori 2022-08-07 12:55:41 PDT
Thank you for reporting. Will revert the change.
Comment 27 Fujii Hironori 2022-08-07 17:55:11 PDT
Created attachment 461469 [details]
Patch
Comment 28 Fujii Hironori 2022-08-07 22:23:12 PDT
Created attachment 461474 [details]
Patch
Comment 29 Alice Mikhaylenko 2022-08-08 14:07:59 PDT
FWIW I would like to have this at some point for GTK port for non-overlay scrollbars only.

And looking at the patch, this looks like it should already happen with the `scrollbar->isOverlayScrollbar()` check, but doesn't for some reason. No idea why, at least Adwaita scrollbars do properly set it.
Comment 30 Fujii Hironori 2022-08-08 14:11:43 PDT
What do you mean? Do you still have the same problem with the new patch? I tested the patch with GTK MiniBrowser.
Comment 31 Alice Mikhaylenko 2022-08-08 14:14:25 PDT
Oh wait. Sorry, I didn't realize there was a new patch, only saw a revert. 🤦️
Comment 32 Alice Mikhaylenko 2022-08-08 14:43:23 PDT
I can confirm it doesn't break overlay scrollbars. The non-overlay scrollbar variant obscures this background with its own background. If removed it works perfectly, I'll submit that patch in a separate bug once this one is in.
Comment 33 Fujii Hironori 2022-08-08 15:02:28 PDT
Comment on attachment 461474 [details]
Patch

Thank you very much for testing.
Comment 34 Alice Mikhaylenko 2022-08-08 15:03:44 PDT
Created attachment 461493 [details]
Corner issue screenshot

Unfortunately I have missed one thing though: it's missing the scrollbar corner, it needs the same color as well.

(Sorry for delays, webkit is just taking forever to build on my laptop)
Comment 35 Alice Mikhaylenko 2022-08-08 15:07:55 PDT
Created attachment 461494 [details]
Test case patch

Here's the patch I used to remove the GTK scrollbar bg to use these colors.
Comment 36 Fujii Hironori 2022-08-08 19:18:55 PDT
I think ScrollbarThemeAdwaita should paint the scrollbar background with the theme color.
Why do you want to change the behavior? Does any browsers do so?
Comment 37 Alice Mikhaylenko 2022-08-09 02:11:07 PDT
That scrollbar only has its own background because there was no way to get the page one. It's supposed to blend with the page the same way overlay scrollbars do.
Comment 38 Fujii Hironori 2022-08-09 03:24:06 PDT
Comment on attachment 461474 [details]
Patch

It seems to be a separate issue which should be filed separately.
Comment 39 EWS 2022-08-09 04:11:07 PDT
Committed 253258@main (dd1137d3994e): <https://commits.webkit.org/253258@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 461474 [details].