WebKit Bugzilla
Attachment 356842 Details for
Bug 192518
: WKWebView should support custom tintColor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192518-20181207150311.patch (text/plain), 7.35 KB, created by
Tim Horton
on 2018-12-07 15:03:11 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2018-12-07 15:03:11 PST
Size:
7.35 KB
patch
obsolete
>Subversion Revision: 238961 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 0d0e15c1c2e571d34c4d39d83e15c6a01107042a..5463cbd38aafbab86b6c488bb5936377097015fa 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,30 @@ >+2018-12-07 Tim Horton <timothy_horton@apple.com> >+ >+ WKWebView should support custom tintColor >+ https://bugs.webkit.org/show_bug.cgi?id=192518 >+ <rdar://problem/37243261> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Platform/spi/ios/UIKitSPI.h: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView insertionPointColor]): >+ (-[WKContentView selectionBarColor]): >+ (-[WKContentView selectionHighlightColor]): >+ Grab insertion point and selection colors from UITextInputTraits. >+ >+ (-[WKContentView _updateInteractionTintColor]): >+ Determine our effective tint color: >+ - transparent if interaction is disabled >+ - a CSS-derived color if caret-color style is applied >+ - the _inheritedInteractionTintColor, which climbs up to the tintColor API >+ Apply it to our UITextInputTraits. >+ >+ (-[WKContentView tintColorDidChange]): >+ (-[WKContentView textInputTraits]): >+ Call _updateInteractionTintColor whenever we create a new UITextInputTraits >+ or when the tint color changes. >+ > 2018-12-07 Truitt Savell <tsavell@apple.com> > > Unreviewed, rolling out r238947. >diff --git a/Source/WebKit/Platform/spi/ios/UIKitSPI.h b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >index 56988c68e24658cc2059402ec1f821e1c8684212..3cdf8499aaa59f079862b63f04945e21b0c0b2c8 100644 >--- a/Source/WebKit/Platform/spi/ios/UIKitSPI.h >+++ b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >@@ -374,6 +374,9 @@ typedef enum { > - (void)takeTraitsFrom:(id <UITextInputTraits>)traits; > @optional > @property (nonatomic) UITextShortcutConversionType shortcutConversionType; >+@property (nonatomic, retain) UIColor *insertionPointColor; >+@property (nonatomic, retain) UIColor *selectionBarColor; >+@property (nonatomic, retain) UIColor *selectionHighlightColor; > @end > > @class UITextInputArrowKeyHistory; >@@ -397,6 +400,7 @@ typedef enum { > @end > > @interface UITextInputTraits : NSObject <UITextInputTraits, UITextInputTraits_Private, NSCopying> >+- (void)_setColorsToMatchTintColor:(UIColor *)tintColor; > @end > > @interface UITextInteractionAssistant : NSObject >@@ -502,6 +506,7 @@ typedef NS_ENUM (NSInteger, _UIBackdropMaskViewFlags) { > - (void)viewWillMoveToSuperview:(UIView *)newSuperview; > - (CGSize)convertSize:(CGSize)size toView:(UIView *)view; > - (void)_removeAllAnimations:(BOOL)includeSubviews; >+- (UIColor *)_inheritedInteractionTintColor; > @end > > @interface UIWebSelectionView : UIView >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 2941dbd250093afccdd72959beccd8c628e37665..c38321725c518b2a39d683179d2f0ad5dd18a4f4 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -2489,15 +2489,41 @@ - (NSDictionary *)textStylingAtPosition:(UITextPosition *)position inDirection:( > > - (UIColor *)insertionPointColor > { >- if (!_webView.configuration._textInteractionGesturesEnabled) >- return [UIColor clearColor]; >+ return [self.textInputTraits insertionPointColor]; >+} > >- if (!_page->editorState().isMissingPostLayoutData) { >- WebCore::Color caretColor = _page->editorState().postLayoutData().caretColor; >- if (caretColor.isValid()) >- return [UIColor colorWithCGColor:cachedCGColor(caretColor)]; >- } >- return [UIColor insertionPointColor]; >+- (UIColor *)selectionBarColor >+{ >+ return [self.textInputTraits selectionBarColor]; >+} >+ >+- (UIColor *)selectionHighlightColor >+{ >+ return [self.textInputTraits selectionHighlightColor]; >+} >+ >+- (void)_updateInteractionTintColor >+{ >+ UIColor *tintColor = ^{ >+ if (!_webView.configuration._textInteractionGesturesEnabled) >+ return [UIColor clearColor]; >+ >+ if (!_page->editorState().isMissingPostLayoutData) { >+ WebCore::Color caretColor = _page->editorState().postLayoutData().caretColor; >+ if (caretColor.isValid()) >+ return [UIColor colorWithCGColor:cachedCGColor(caretColor)]; >+ } >+ >+ return [self _inheritedInteractionTintColor]; >+ }(); >+ >+ [_traits.get() _setColorsToMatchTintColor:tintColor]; >+} >+ >+- (void)tintColorDidChange >+{ >+ [super tintColorDidChange]; >+ [self _updateInteractionTintColor]; > } > > - (BOOL)canPerformAction:(SEL)action withSender:(id)sender >@@ -3846,6 +3872,8 @@ - (UITextInputTraits *)textInputTraits > > [_traits setTextContentType:contentTypeFromFieldName(_assistedNodeInformation.autofillFieldName)]; > >+ [self _updateInteractionTintColor]; >+ > return _traits.get(); > } > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index ad0e369963bef4f8a5f3b1d6da33649ec34d226f..cb92f57d8ca426d694e4c47ae631c282468697df 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,15 @@ >+2018-12-07 Tim Horton <timothy_horton@apple.com> >+ >+ WKWebView should support custom tintColor >+ https://bugs.webkit.org/show_bug.cgi?id=192518 >+ <rdar://problem/37243261> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm: >+ (TestWebKitAPI::TEST): >+ Add a test that tintColor affects UITextInputTraits' interaction colors. >+ > 2018-12-07 Aakash Jain <aakash_jain@apple.com> > > [ews-app] Send bug id as a build property >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm >index fe49e30d8412f8a1b5e8fe43fd520649d0434845..b4084befc335800a026ddd0e492685f4c3ff497f 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm >@@ -36,6 +36,11 @@ > #import <pal/spi/cocoa/NSColorSPI.h> > #endif > >+#if PLATFORM(IOS_FAMILY) >+#import "UIKitSPI.h" >+#import <UIKit/UIKit.h> >+#endif >+ > namespace TestWebKitAPI { > > TEST(WebKit, LinkColor) >@@ -69,6 +74,19 @@ TEST(WebKit, LinkColorWithSystemAppearance) > } > #endif > >+#if PLATFORM(IOS_FAMILY) >+TEST(WebKit, TintColorAffectsInteractionColor) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ [webView setTintColor:[UIColor greenColor]]; >+ [webView synchronouslyLoadHTMLString:@"<body contenteditable></body>"]; >+ [webView stringByEvaluatingJavaScript:@"document.body.focus()"]; >+ UIView<UITextInputTraits_Private> *textInput = (UIView<UITextInputTraits_Private> *) [webView textInputContentView]; >+ EXPECT_TRUE([textInput.insertionPointColor isEqual:[UIColor greenColor]]); >+ EXPECT_TRUE([textInput.selectionBarColor isEqual:[UIColor greenColor]]); >+} >+#endif >+ > } // namespace TestWebKitAPI > > #endif >diff --git a/Tools/TestWebKitAPI/ios/UIKitSPI.h b/Tools/TestWebKitAPI/ios/UIKitSPI.h >index f7bd9398df39d5b1a9358048c88391c03df02f0a..a189bb87971b0803eccac1373a69807a5743befc 100644 >--- a/Tools/TestWebKitAPI/ios/UIKitSPI.h >+++ b/Tools/TestWebKitAPI/ios/UIKitSPI.h >@@ -68,6 +68,7 @@ WTF_EXTERN_C_END > > @protocol UITextInputTraits_Private <NSObject, UITextInputTraits> > @property (nonatomic, readonly) UIColor *insertionPointColor; >+@property (nonatomic, readonly) UIColor *selectionBarColor; > @end > > @class WebEvent;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192518
:
356842
|
356843