Bug 245055 - Add platform-specific expectations of http/tests/scroll-to-text-fragment ref-tests for WinCairo, GTK and WPE port
Summary: Add platform-specific expectations of http/tests/scroll-to-text-fragment ref-...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-09-11 14:50 PDT by Fujii Hironori
Modified: 2022-09-20 00:25 PDT (History)
14 users (show)

See Also:


Attachments
WIP patch (582 bytes, patch)
2022-09-11 15:10 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (5.61 KB, patch)
2022-09-11 18:16 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (5.76 KB, patch)
2022-09-11 21:01 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (8.61 KB, patch)
2022-09-12 13:32 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (12.25 KB, patch)
2022-09-12 23:11 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (11.57 KB, patch)
2022-09-15 17:50 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (13.87 KB, patch)
2022-09-19 14:33 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
[fast-cq] Patch for landing (13.88 KB, patch)
2022-09-19 21:39 PDT, Fujii Hironori
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-09-11 14:50:51 PDT
RenderTheme::platformAnnotationHighlightColor is yellow which isn't matching to RenderThemeMac and RenderThemeIOS

Non-Cocoa ports are failing the following tests because the annotation highlight color is yellow.

  http/tests/scroll-to-text-fragment/start-text-emoji.html [ ImageOnlyFailure ]
  http/tests/scroll-to-text-fragment/start-text-quote.html [ ImageOnlyFailure ]
  http/tests/scroll-to-text-fragment/start-text-sentence.html [ ImageOnlyFailure ]
  http/tests/scroll-to-text-fragment/start-text-word.html [ ImageOnlyFailure ]

See also: Bug 236693 – Draw highlights for Scroll To Text Fragment
Comment 1 Fujii Hironori 2022-09-11 15:10:18 PDT
Created attachment 462271 [details]
WIP patch

This patch doesn't make the tests pass. I don't know why. They are almost same color for my eyes.
Comment 2 Fujii Hironori 2022-09-11 18:00:53 PDT
RenderTheme::transformSelectionBackgroundColor is using blendWithWhite to convert the value of platformAnnotationHighlightColor.
blendWithWhite tries to find the corresponding color if the givin color is blended with white.
I think it's OK to add fuzzy meta tag in these test cases.
Comment 3 Fujii Hironori 2022-09-11 18:16:46 PDT
Created attachment 462274 [details]
Patch
Comment 4 Fujii Hironori 2022-09-11 21:01:54 PDT
Created attachment 462277 [details]
Patch
Comment 5 Fujii Hironori 2022-09-12 13:25:31 PDT
Comment on attachment 462277 [details]
Patch

gtk-wk2 EWS reported test failures:

  http/tests/scroll-to-text-fragment/start-text-emoji.html [ ImageOnlyFailure ]
  http/tests/scroll-to-text-fragment/start-text-sentence.html [ ImageOnlyFailure ]
  http/tests/scroll-to-text-fragment/start-text-word.html [ ImageOnlyFailure ]

I didn't know that GTK has yellow -expected.html files. I'm going to remove them.
Comment 6 Fujii Hironori 2022-09-12 13:32:53 PDT
Created attachment 462296 [details]
Patch
Comment 7 Tim Nguyen (:ntim) 2022-09-12 22:41:03 PDT
Comment on attachment 462296 [details]
Patch

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

> Source/WebCore/rendering/RenderTheme.cpp:1430
>  Color RenderTheme::platformAnnotationHighlightColor(OptionSet<StyleColorOptions>) const
>  {
> -    return Color::yellow;
> +    return { { 255, 238, 190 } };
>  }

I'll leave it to Aditya, but I wonder if it's really useful at this point to keep the RenderThemeIOS/Mac methods given they also just return this hardcoded color.
Comment 8 Fujii Hironori 2022-09-12 23:01:14 PDT
Comment on attachment 462296 [details]
Patch

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

>> Source/WebCore/rendering/RenderTheme.cpp:1430
>>  }
> 
> I'll leave it to Aditya, but I wonder if it's really useful at this point to keep the RenderThemeIOS/Mac methods given they also just return this hardcoded color.

I agree. Will fix.
Comment 9 Fujii Hironori 2022-09-12 23:11:56 PDT
Created attachment 462304 [details]
Patch
Comment 10 Fujii Hironori 2022-09-14 13:24:55 PDT
I had a discussion in https://webkit.slack.com/archives/CU81QR94P/p1663044973078139

Darin Adler
> Here’s why I didn’t review yet:
> I am puzzled that we are changing the actual color displayed on the screen to match Apple’s colors. The reason this is in RenderTheme is the concept that this is not necessarily the same on all platforms. That‘s what "theme" is about. Is this really the best behavior for all ports? If so, then why do we indirect this through the theme?
> Obviously not theming a color is the simplest way to use a single set of graphical results in our regression tests, but outside of that, maybe there are reasons to match platform standards rather than just matching Apple’s style. If we don’t happen to want the same color everywhere, for some of our testing we could even set a mode where all platforms use the same color and ignore the theme

fujihiro
> all browsers use blue color for hyperlinks by default by using UA stylesheet. It increases the web compatibility and reduces the user confusing. I think it isn't a bad idea to use the same annotation color for all WebKit engines. But, your opinion makes sense. How about an idea changing the ref test to a non-match ref test?
Comment 11 Fujii Hironori 2022-09-15 17:50:45 PDT
Created attachment 462380 [details]
Patch
Comment 12 Darin Adler 2022-09-16 11:57:08 PDT
Comment on attachment 462380 [details]
Patch

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

> COMMIT_MESSAGE:9
> +The annotation highlight color is platform-dependent that is customize
> +by RenderTheme::platformAnnotationHighlightColor virtual function. The
> +expectations of the ref-tests hard-coded the annotation highlight
> +color of Cocoa ports. Changed the ref-tests to mismatch ref-tests.

I don’t like this strategy for making the tests work well cross-platform. Mismatch tests are fragile. Any mismatch is a "pass".

Instead I suggest we expose the correct color somehow to the testing machinery so the expected files can use the correct color. Maybe just make an internals function that will return the color. Or if we want to be super-fancy we could find a way add a CSS named color that is there while testing.

We should use very few mismatch tests. They aren’t very good.
Comment 13 Radar WebKit Bug Importer 2022-09-18 14:51:17 PDT
<rdar://problem/100096699>
Comment 14 Fujii Hironori 2022-09-19 13:07:02 PDT
It sounds like a bit complicated.
I prefer an idea to use platform-specific expectations because it's much simpler.
Comment 15 Fujii Hironori 2022-09-19 13:35:31 PDT
I found out another problem.
GTK port has yellow test expectations for some tests, but they are failing.
https://build.webkit.org/results/GTK-Linux-64-bit-Release-Tests/254602@main%20(9198)/results.html
maxDifference is 51.
Does blendWithWhite have a problem?
Comment 16 Fujii Hironori 2022-09-19 14:10:11 PDT
Because yellow has 0 blue, no semi-transparent color can't result in yellow by blending with white.
So, blendWithWhite falls back to return a color with 80% alpha.
https://github.com/WebKit/WebKit/blob/cfb088fd56631a371a89d06697cfba363583d33d/Source/WebCore/platform/graphics/ColorBlending.cpp#L57
Comment 17 Fujii Hironori 2022-09-19 14:33:23 PDT
Created attachment 462452 [details]
Patch
Comment 18 Fujii Hironori 2022-09-19 21:39:42 PDT
Created attachment 462463 [details]
[fast-cq] Patch for landing
Comment 19 EWS 2022-09-20 00:25:36 PDT
Committed 254664@main (c2c84973bcac): <https://commits.webkit.org/254664@main>

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