-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Mac Catalyst] Adjust autocorrection underline color based on caret color #13588
Conversation
EWS run on previous version of this PR (hash 4acb3db) |
if (auto *insertionPointColor = [[self _textInputTraits] insertionPointColor]) | ||
return insertionPointColor; | ||
|
||
return UIColor.insertionPointColor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - possibly a bit more concise as return self._textInputTraits.insertionPointColor ?: UIColor.insertionPointColor;
.
@@ -1078,6 +1078,11 @@ static UIInterfaceOrientationMask toUIInterfaceOrientationMask(WebCore::ScreenOr | |||
return color; | |||
} | |||
|
|||
WebCore::Color PageClientImpl::insertionPointColor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - you can omit the WebCore:: here and below, since this file already uses namespace WebCore;
.
|
||
Color RenderThemeIOS::autocorrectionReplacementMarkerColor(const RenderText& renderer, OptionSet<StyleColorOptions>) const | ||
{ | ||
Color caretColor = CaretBase::computeCaretColor(renderer.style(), renderer.textNode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Color caretColor = CaretBase::computeCaretColor(renderer.style(), renderer.textNode()); | |
auto caretColor = CaretBase::computeCaretColor(renderer.style(), renderer.textNode()); |
return *cachedInsertionPointColor(); | ||
} | ||
|
||
Color RenderThemeIOS::autocorrectionReplacementMarkerColor(const RenderText& renderer, OptionSet<StyleColorOptions>) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - would it be cleaner to just pass in a renderer
here, and use renderer.styleColorOptions()
to grab the color options from it? (So that the function never takes a set of StyleColorOptions
that doesn't match the renderer
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was already using renderer.styleColorOptions()
in the method body β removed the parameter.
@@ -2041,7 +2041,7 @@ Color RenderTheme::platformDictationAlternativesMarkerColor(OptionSet<StyleColor | |||
return Color::green; | |||
} | |||
|
|||
Color RenderTheme::autocorrectionReplacementMarkerColor(OptionSet<StyleColorOptions> options) const | |||
Color RenderTheme::autocorrectionReplacementMarkerColor(const RenderText&, OptionSet<StyleColorOptions> options) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since options == RenderText::styleColorOptions()
, do we need the options
argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
Thanks for the reviews! |
EWS run on current version of this PR (hash c346ce9) |
β¦olor https://bugs.webkit.org/show_bug.cgi?id=256475 rdar://108355409 Reviewed by Wenson Hsieh. The autocorrection underline color should be a variant of the current caret color. In order to facilitate this, the insertion point color is plumbed from the UI Process into the Web Process. * Source/WebCore/rendering/RenderTheme.cpp: (WebCore::RenderTheme::autocorrectionReplacementMarkerColor const): (WebCore::RenderTheme::documentMarkerLineColor const): * Source/WebCore/rendering/RenderTheme.h: Add a `RenderText` parameter to `documentMarkerLineColor`, since it is necessary to determine the caret color. * Source/WebCore/rendering/RenderThemeCocoa.h: * Source/WebCore/rendering/RenderThemeCocoa.mm: (WebCore::RenderThemeCocoa::platformAutocorrectionReplacementMarkerColor const): Deleted. Remove override, as the color is too dynamic to be cached. `caret-color` can differ per-element, so the autocorrection underline color can no longer be cached. * Source/WebCore/rendering/RenderThemeIOS.h: Add a static method to set the insertion point color to avoid unnecessary initialization of the singleton. * Source/WebCore/rendering/RenderThemeIOS.mm: (WebCore::cachedInsertionPointColor): (WebCore::RenderThemeIOS::insertionPointColor): (WebCore::RenderThemeIOS::autocorrectionReplacementMarkerColor const): Adjust the autocorrection underline color based on the current caret color. If `caret-color` is `auto`, use the default color from the UI process. The adjustment is performed using the HSL colorspace, matching UIKit. (WebCore::RenderThemeIOS::setInsertionPointColor): * Source/WebCore/rendering/TextBoxPainter.cpp: (WebCore::TextBoxPainter<TextBoxPath>::paintPlatformDocumentMarker): * Source/WebKit/Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Source/WebKit/Shared/WebPageCreationParameters.h: * Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h: * Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm: (-[WKWebView _insertionPointColor]): Get the insertion point color from the text input traits if it exists. Otherwise, use the default color specified in UIKit. * Source/WebKit/UIProcess/PageClient.h: Add a `PageClient` hook to get the insertion point color. * Source/WebKit/UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::creationParameters): * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/UIProcess/ios/PageClientImplIOS.h: * Source/WebKit/UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::insertionPointColor): * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView tintColorDidChange]): Ensure the insertion point color is up-to-date, following changes to the view's tint color. * Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::insertionPointColorDidChange): * Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::platformInitialize): * Source/WebKit/WebProcess/WebPage/WebPage.h: * Source/WebKit/WebProcess/WebPage/WebPage.messages.in: * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::setInsertionPointColor): Canonical link: https://commits.webkit.org/263879@main
c346ce9
to
b199f7d
Compare
Committed 263879@main (b199f7d): https://commits.webkit.org/263879@main Reviewed commits have been landed. Closing PR #13588 and removing active labels. |
b199f7d
c346ce9