Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for painting document markers using system colors #10601

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

pxlcoder
Copy link
Member

@pxlcoder pxlcoder commented Feb 23, 2023

68ae85e

Add support for painting document markers using system colors
https://bugs.webkit.org/show_bug.cgi?id=252791
rdar://105796291

Reviewed by Wenson Hsieh and Megan Gardner.

Use system colors for painting document markers when possible. To support this
functionality, new `RenderTheme` methods are added to control platform-specific
marker colors and the color cache is expanded for the new colors. This approach
matches the implementation of existing system colors.

* Source/WebCore/PAL/pal/spi/mac/NSSpellCheckerSPI.h:
* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::spellingMarkerColor const):
(WebCore::RenderTheme::platformSpellingMarkerColor const):
(WebCore::RenderTheme::dictationAlternativesMarkerColor const):
(WebCore::RenderTheme::platformDictationAlternativesMarkerColor const):
(WebCore::RenderTheme::autocorrectionReplacementMarkerColor const):
(WebCore::RenderTheme::platformAutocorrectionReplacementMarkerColor const):
(WebCore::RenderTheme::grammarMarkerColor const):
(WebCore::RenderTheme::platformGrammarMarkerColor const):
(WebCore::RenderTheme::documentMarkerLineColor const):
* Source/WebCore/rendering/RenderTheme.h:
* Source/WebCore/rendering/RenderThemeCocoa.h:
* Source/WebCore/rendering/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::platformSpellingMarkerColor const):
(WebCore::RenderThemeCocoa::platformDictationAlternativesMarkerColor const):
(WebCore::RenderThemeCocoa::platformAutocorrectionReplacementMarkerColor const):
(WebCore::RenderThemeCocoa::platformGrammarMarkerColor const):
(WebCore::grammarColor): Deleted.
(WebCore::RenderThemeCocoa::documentMarkerLineColor const): Deleted.
* Source/WebCore/rendering/RenderThemeMac.h:
* Source/WebCore/rendering/RenderThemeMac.mm:
(WebCore::usePlatformColorForAutocorrectionReplacementMarker):
(WebCore::RenderThemeMac::platformAutocorrectionReplacementMarkerColor const):

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

1173f0e

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios   πŸ›  mac   πŸ›  wpe   πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim   πŸ›  mac-AS-debug βœ… πŸ›  gtk
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac   πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios   πŸ§ͺ mac-wk1   πŸ§ͺ api-gtk
βœ… πŸ›  tv   πŸ§ͺ mac-wk2
  πŸ›  tv-sim   πŸ§ͺ mac-AS-debug-wk2
  πŸ›  watch   πŸ§ͺ mac-wk2-stress
βœ… πŸ›  watch-sim
βœ… πŸ›  πŸ§ͺ unsafe-merge

@pxlcoder pxlcoder self-assigned this Feb 23, 2023
@pxlcoder pxlcoder added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Feb 23, 2023
@pxlcoder
Copy link
Member Author

Thanks for the review!

#endif // USE(APPLE_INTERNAL_SDK)

#if HAVE(NSSPELLCHECKER_CORRECTION_INDICATOR_UNDERLINE_COLOR)
@interface NSSpellChecker (Staging_105286196)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you haven't, can you file a bug for removing this staging code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed a bug and added a comment.

Color RenderThemeCocoa::platformDictationAlternativesMarkerColor(OptionSet<StyleColorOptions> options) const
{
auto useDarkMode = options.contains(StyleColorOptions::UseDarkAppearance);
return useDarkMode ? SRGBA<uint8_t> { 40, 145, 255, 217 } : SRGBA<uint8_t> { 0, 122, 255, 191 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can factor out all the same special numbers so that it's more clear that they're all the same thing? I'm also assuming there's no way to get these from the system or elsewhere and they need to be manually defined.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was doing some digging and it appears that there are system colors that we can use for these!

Though I will need to audit them individually to compare behavior. Since this hardcoding is not new I have filed https://bugs.webkit.org/show_bug.cgi?id=252868 to address this separately.

For now, I have updated the PR to unify the dictation alternative paths, and share the same color method, reducing the amount of duplication.

@pxlcoder pxlcoder added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 24, 2023
https://bugs.webkit.org/show_bug.cgi?id=252791
rdar://105796291

Reviewed by Wenson Hsieh and Megan Gardner.

Use system colors for painting document markers when possible. To support this
functionality, new `RenderTheme` methods are added to control platform-specific
marker colors and the color cache is expanded for the new colors. This approach
matches the implementation of existing system colors.

* Source/WebCore/PAL/pal/spi/mac/NSSpellCheckerSPI.h:
* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::spellingMarkerColor const):
(WebCore::RenderTheme::platformSpellingMarkerColor const):
(WebCore::RenderTheme::dictationAlternativesMarkerColor const):
(WebCore::RenderTheme::platformDictationAlternativesMarkerColor const):
(WebCore::RenderTheme::autocorrectionReplacementMarkerColor const):
(WebCore::RenderTheme::platformAutocorrectionReplacementMarkerColor const):
(WebCore::RenderTheme::grammarMarkerColor const):
(WebCore::RenderTheme::platformGrammarMarkerColor const):
(WebCore::RenderTheme::documentMarkerLineColor const):
* Source/WebCore/rendering/RenderTheme.h:
* Source/WebCore/rendering/RenderThemeCocoa.h:
* Source/WebCore/rendering/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::platformSpellingMarkerColor const):
(WebCore::RenderThemeCocoa::platformDictationAlternativesMarkerColor const):
(WebCore::RenderThemeCocoa::platformAutocorrectionReplacementMarkerColor const):
(WebCore::RenderThemeCocoa::platformGrammarMarkerColor const):
(WebCore::grammarColor): Deleted.
(WebCore::RenderThemeCocoa::documentMarkerLineColor const): Deleted.
* Source/WebCore/rendering/RenderThemeMac.h:
* Source/WebCore/rendering/RenderThemeMac.mm:
(WebCore::usePlatformColorForAutocorrectionReplacementMarker):
(WebCore::RenderThemeMac::platformAutocorrectionReplacementMarkerColor const):

Canonical link: https://commits.webkit.org/260779@main
@webkit-commit-queue
Copy link
Collaborator

Committed 260779@main (68ae85e): https://commits.webkit.org/260779@main

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

@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Bugs Unclassified bugs are placed in this component until the correct component can be determined.
Projects
None yet
5 participants