WebKit Bugzilla
Attachment 348685 Details for
Bug 189214
: [macOS] Add Touch Bar support for <input type=color>
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189214-20180831171019.patch (text/plain), 21.09 KB, created by
Aditya Keerthi
on 2018-08-31 17:10:20 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Aditya Keerthi
Created:
2018-08-31 17:10:20 PDT
Size:
21.09 KB
patch
obsolete
>Subversion Revision: 235577 >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index e695f7a594990c43e0bfb56dc806670f2f6eb4bd..caaf95e0c21c14d2bf158f25a593e5628dec7c98 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,12 @@ >+2018-08-31 Aditya Keerthi <akeerthi@apple.com> >+ >+ [macOS] Add Touch Bar support for <input type=color> >+ https://bugs.webkit.org/show_bug.cgi?id=189214 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * pal/spi/cocoa/NSTouchBarSPI.h: Add SPI for NSTouchBarColorPicker. >+ > 2018-08-30 Don Olmstead <don.olmstead@sony.com> > > [CMake] Replace AVFoundationSupport.py using CMake >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index fc03a5651c260cacf00093a99c5a2ac8f0c75343..cc5a1792ee71750bc8f867280f8a3d59a6b815f2 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,56 @@ >+2018-08-31 Aditya Keerthi <akeerthi@apple.com> >+ >+ [macOS] Add Touch Bar support for <input type=color> >+ https://bugs.webkit.org/show_bug.cgi?id=189214 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In order to have a complete <input type=color> experience on macOS, we should >+ support displaying a color picker in the Touch Bar. >+ >+ The color touch bar is created and owned by WebViewImpl, managed through >+ WKColorTouchBarManager. The manager provides methods to update the touch bar >+ if the form control is changed and to update the form control if the touch >+ bar value is changed. >+ >+ Furthermore, we must synchronize the value of the color touch bar with the value >+ of WebColorPicker. This is done through communication between WebViewImpl, >+ PageClientImpl and WebPageProxy. >+ >+ * UIProcess/Cocoa/WebViewImpl.h: >+ * UIProcess/Cocoa/WebViewImpl.mm: >+ (-[WKColorTouchBarManager initWithWebViewImpl:]): >+ (-[WKColorTouchBarManager touchBar]): >+ (-[WKColorTouchBarManager updateColor:]): >+ (-[WKColorTouchBarManager colorPickerViewController:didSelectColor:]): >+ (WebKit::WebViewImpl::updateTouchBar): >+ (WebKit::WebViewImpl::updateColorTouchBar): >+ (WebKit::WebViewImpl::updateColorTouchBarColor): >+ (WebKit::WebViewImpl::colorTouchBar const): >+ * UIProcess/PageClient.h: >+ * UIProcess/WebColorPicker.cpp: >+ (WebKit::WebColorPicker::setColorFromTouchBar): >+ (WebKit::WebColorPicker::currentColor): >+ * UIProcess/WebColorPicker.h: >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::activeColorPicker const): >+ (WebKit::WebPageProxy::showColorPicker): >+ (WebKit::WebPageProxy::didChooseColor): >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/mac/PageClientImplMac.h: >+ * UIProcess/mac/PageClientImplMac.mm: >+ (WebKit::PageClientImpl::updateTouchBar): >+ (WebKit::PageClientImpl::updateColorTouchBarColor): >+ * UIProcess/mac/WebColorPickerMac.h: >+ * UIProcess/mac/WebColorPickerMac.mm: >+ (WebKit::WebColorPickerMac::setColorFromTouchBar): >+ (WebKit::WebColorPickerMac::currentColor): >+ (-[WKPopoverColorWell setColorWithoutClose:]): >+ (-[WKColorPopoverMac currentColor]): >+ (-[WKColorPopoverMac setColorFromTouchBar:]): >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::elementDidFocus): >+ > 2018-08-31 John Wilander <wilander@apple.com> > > Storage Access API: Maintain access through same-site navigations >diff --git a/Source/WebCore/PAL/pal/spi/cocoa/NSTouchBarSPI.h b/Source/WebCore/PAL/pal/spi/cocoa/NSTouchBarSPI.h >index 2acaeaa7ea78615bc338c0a93f21046bcbb5e9dc..a97abc47cae166f51e58b7a5fa0d1ef2667329d0 100644 >--- a/Source/WebCore/PAL/pal/spi/cocoa/NSTouchBarSPI.h >+++ b/Source/WebCore/PAL/pal/spi/cocoa/NSTouchBarSPI.h >@@ -29,6 +29,7 @@ > > #import <AppKit/NSCandidateListTouchBarItem_Private.h> > #import <AppKit/NSTextTouchBarItemController_WebKitSPI.h> >+#import <AppKit/NSTouchBarColorPicker.h> > #import <AppKit/NSTouchBar_Private.h> > > #if __MAC_OS_X_VERSION_MAX_ALLOWED < 101300 >@@ -62,6 +63,21 @@ NS_ASSUME_NONNULL_BEGIN > - (void)setCandidates:(NSArray *)candidates forSelectedRange:(NSRange)selectedRange inString:(nullable NSString *)string rect:(NSRect)rect view:(nullable NSView *)view completionHandler:(nullable void (^)(id acceptedCandidate))completionBlock; > @end > >+@protocol NSTouchBarColorPickerViewControllerDelegate; >+ >+@interface NSTouchBarColorPickerViewController : NSViewController >+ >+@property (weak) id<NSTouchBarColorPickerViewControllerDelegate> delegate; >+@property (copy) NSColor *currentColor; >+@property BOOL allowsAlpha; >+ >+- (instancetype)initWithInitialColor:(NSColor *)initialColor; >+@end >+ >+@protocol NSTouchBarColorPickerViewControllerDelegate <NSObject> >+- (void)colorPickerViewController:(NSTouchBarColorPickerViewController *)controller didSelectColor:(NSColor *)color; >+@end >+ > #endif // !USE(APPLE_INTERNAL_SDK) > > APPKIT_EXTERN NSNotificationName const NSTouchBarWillEnterCustomization API_AVAILABLE(macosx(10.12.2)); >diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >index e54dd00140584fc1e19148a22e78fc2fe0b09742..4b1ec2c26206d0fae44732427c162441b48947fb 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >+++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >@@ -67,6 +67,7 @@ OBJC_CLASS NSTouchBarItem; > OBJC_CLASS NSPopoverTouchBarItem; > OBJC_CLASS WKTextTouchBarItemController; > OBJC_CLASS WebPlaybackControlsManager; >+OBJC_CLASS WKColorTouchBarManager; > #endif // HAVE(TOUCH_BAR) > > namespace API { >@@ -550,6 +551,11 @@ public: > AVFunctionBarScrubber *mediaPlaybackControlsView() const; > #endif > #endif >+#if ENABLE(INPUT_TYPE_COLOR) >+ NSTouchBar *colorTouchBar() const; >+ void updateColorTouchBarColor(const WebCore::Color&); >+#endif >+ > NSTouchBar *textTouchBar() const; > void dismissTextTouchBarPopoverItemWithIdentifier(NSString *); > >@@ -574,6 +580,9 @@ private: > void setUpTextTouchBar(NSTouchBar *); > void updateTextTouchBar(); > void updateMediaTouchBar(); >+#if ENABLE(INPUT_TYPE_COLOR) >+ void updateColorTouchBar(); >+#endif > > bool useMediaPlaybackControlsView() const; > bool isRichlyEditable() const; >@@ -594,6 +603,9 @@ private: > RetainPtr<NSCandidateListTouchBarItem> m_passwordTextCandidateListTouchBarItem; > RetainPtr<WebPlaybackControlsManager> m_playbackControlsManager; > RetainPtr<NSCustomTouchBarItem> m_exitFullScreenButton; >+#if ENABLE(INPUT_TYPE_COLOR) >+ RetainPtr<WKColorTouchBarManager> m_colorTouchBarManager; >+#endif > > #if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER) > #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 >diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >index de48e0f8a895eb82c17b4f8753c63e1521688e5a..e17c2782d3f3540e8aacbb0e8e82ccf0f68bf7c3 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >+++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >@@ -63,6 +63,7 @@ > #import "WKViewLayoutStrategy.h" > #import "WKWebViewPrivate.h" > #import "WebBackForwardList.h" >+#import "WebColorPicker.h" > #import "WebEditCommandProxy.h" > #import "WebEventFactory.h" > #import "WebInspectorProxy.h" >@@ -877,6 +878,70 @@ static const NSUInteger orderedListSegment = 2; > > @end > >+#if ENABLE(INPUT_TYPE_COLOR) >+ >+static NSString * const WKColorPickerTouchBarItem = @"WKColorPickerTouchBarItem"; >+ >+@interface WKColorTouchBarManager : NSObject <NSTouchBarColorPickerViewControllerDelegate> { >+@private >+ WebViewImpl* _webViewImpl; >+ >+ RetainPtr<NSTouchBarColorPickerViewController> _controller; >+ RetainPtr<NSCustomTouchBarItem> _item; >+ RetainPtr<NSTouchBar> _touchBar; >+} >+ >+- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl; >+- (NSTouchBar *)touchBar; >+- (void)updateColor:(NSColor *)color; >+@end >+ >+@implementation WKColorTouchBarManager >+ >+- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl >+{ >+ if (!(self = [super init])) >+ return nil; >+ >+ _webViewImpl = webViewImpl; >+ >+ _controller = adoptNS([[NSTouchBarColorPickerViewController alloc] initWithInitialColor:nsColor(_webViewImpl->page().activeColorPicker()->currentColor())]); >+ [_controller setAllowsAlpha:NO]; >+ [_controller setDelegate:self]; >+ >+ _item = adoptNS([[NSCustomTouchBarItem alloc] initWithIdentifier:WKColorPickerTouchBarItem]); >+ [_item setViewController:_controller.get()]; >+ >+ _touchBar = adoptNS([[NSTouchBar alloc] init]); >+ [_touchBar setDefaultItemIdentifiers:@[ WKColorPickerTouchBarItem ]]; >+ [_touchBar setTemplateItems:[NSSet setWithArray:@[ _item.get() ]]]; >+ >+ return self; >+} >+ >+- (NSTouchBar *)touchBar >+{ >+ return _touchBar.get(); >+} >+ >+- (void)updateColor:(NSColor *)color >+{ >+ [_controller setCurrentColor:color]; >+} >+ >+- (void)colorPickerViewController:(NSTouchBarColorPickerViewController *)controller didSelectColor:(NSColor *)color >+{ >+ WebColorPicker* colorPicker = _webViewImpl->page().activeColorPicker(); >+ if (!colorPicker) >+ return; >+ >+ colorPicker->setColorFromTouchBar(colorFromNSColor(color)); >+} >+ >+@end >+ >+#endif // ENABLE(INPUT_TYPE_COLOR) >+ > @interface WKPromisedAttachmentContext : NSObject { > @private > RetainPtr<NSURL> _blobURL; >@@ -962,6 +1027,12 @@ void WebViewImpl::updateTouchBar() > [m_mediaPlaybackControlsView setPlaybackControlsController:nil]; > } > #endif >+#if ENABLE(INPUT_TYPE_COLOR) >+ if (m_page->activeColorPicker()) { >+ updateColorTouchBar(); >+ touchBar = colorTouchBar(); >+ } >+#endif > > if (touchBar == m_currentTouchBar) > return; >@@ -1006,6 +1077,30 @@ bool WebViewImpl::useMediaPlaybackControlsView() const > return m_clientWantsMediaPlaybackControlsView; > } > >+#if ENABLE(INPUT_TYPE_COLOR) >+ >+void WebViewImpl::updateColorTouchBar() >+{ >+ if (m_colorTouchBarManager) { >+ [m_colorTouchBarManager updateColor:nsColor(m_page->activeColorPicker()->currentColor())]; >+ return; >+ } >+ >+ m_colorTouchBarManager = adoptNS([[WKColorTouchBarManager alloc] initWithWebViewImpl:this]); >+} >+ >+void WebViewImpl::updateColorTouchBarColor(const WebCore::Color& color) >+{ >+ [m_colorTouchBarManager updateColor:nsColor(color)]; >+} >+ >+NSTouchBar *WebViewImpl::colorTouchBar() const >+{ >+ return [m_colorTouchBarManager touchBar]; >+} >+ >+#endif // ENABLE(INPUT_TYPE_COLOR) >+ > void WebViewImpl::dismissTextTouchBarPopoverItemWithIdentifier(NSString *identifier) > { > NSTouchBarItem *foundItem = nil; >diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h >index bb09d1d6e52aaf76813aaeca09c7c417bfeba2c8..990bed58d2a8372af23f83a7fec11674bc9eb36a 100644 >--- a/Source/WebKit/UIProcess/PageClient.h >+++ b/Source/WebKit/UIProcess/PageClient.h >@@ -267,6 +267,10 @@ public: > virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) = 0; > #endif > >+#if HAVE(TOUCH_BAR) >+ virtual void updateTouchBar() = 0; >+#endif >+ > virtual RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) = 0; > #if ENABLE(CONTEXT_MENUS) > virtual Ref<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, ContextMenuContextData&&, const UserData&) = 0; >@@ -274,6 +278,9 @@ public: > > #if ENABLE(INPUT_TYPE_COLOR) > virtual RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&) = 0; >+#if HAVE(TOUCH_BAR) >+ virtual void updateColorTouchBarColor(const WebCore::Color&) = 0; >+#endif > #endif > > #if ENABLE(DATALIST_ELEMENT) >diff --git a/Source/WebKit/UIProcess/WebColorPicker.cpp b/Source/WebKit/UIProcess/WebColorPicker.cpp >index 60263d74a7c3a66f47d4d372f950b2e446b43e65..d9dfca72fa126bccfbafd8b2b8fac48bbb2cf1b8 100644 >--- a/Source/WebKit/UIProcess/WebColorPicker.cpp >+++ b/Source/WebKit/UIProcess/WebColorPicker.cpp >@@ -62,6 +62,17 @@ void WebColorPicker::showColorPicker(const WebCore::Color&) > return; > } > >+void WebColorPicker::setColorFromTouchBar(const WebCore::Color&) >+{ >+ ASSERT_NOT_REACHED(); >+ return; >+} >+ >+WebCore::Color WebColorPicker::currentColor() >+{ >+ return Color(); >+} >+ > } // namespace WebKit > > #endif // ENABLE(INPUT_TYPE_COLOR) >diff --git a/Source/WebKit/UIProcess/WebColorPicker.h b/Source/WebKit/UIProcess/WebColorPicker.h >index df0be5cdbd6a333345eafdc19907e8f66e701741..eea750531701da762bae8eb0687234b037072618 100644 >--- a/Source/WebKit/UIProcess/WebColorPicker.h >+++ b/Source/WebKit/UIProcess/WebColorPicker.h >@@ -59,6 +59,8 @@ public: > virtual void endPicker(); > virtual void setSelectedColor(const WebCore::Color&); > virtual void showColorPicker(const WebCore::Color&); >+ virtual void setColorFromTouchBar(const WebCore::Color&); >+ virtual WebCore::Color currentColor(); > > protected: > explicit WebColorPicker(Client*); >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index e28310ba60a928337a08f7693d8edc9156eba436..c33803726d9b4e972a12d957b50de8ca6037ad5b 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -4714,10 +4714,19 @@ void WebPageProxy::didChangeContentSize(const IntSize& size) > } > > #if ENABLE(INPUT_TYPE_COLOR) >+ >+WebColorPicker* WebPageProxy::activeColorPicker() const >+{ >+ return m_colorPicker.get(); >+} >+ > void WebPageProxy::showColorPicker(const WebCore::Color& initialColor, const IntRect& elementRect, Vector<WebCore::Color>&& suggestions) > { > m_colorPicker = m_pageClient.createColorPicker(this, initialColor, elementRect, WTFMove(suggestions)); > m_colorPicker->showColorPicker(initialColor); >+#if HAVE(TOUCH_BAR) >+ m_pageClient.updateTouchBar(); >+#endif > } > > void WebPageProxy::setColorPickerColor(const WebCore::Color& color) >@@ -4740,6 +4749,9 @@ void WebPageProxy::didChooseColor(const WebCore::Color& color) > if (!isValid()) > return; > >+#if HAVE(TOUCH_BAR) >+ m_pageClient.updateColorTouchBarColor(color); >+#endif > m_process->send(Messages::WebPage::DidChooseColor(color), m_pageID); > } > >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 452814bc25fd2dd009b0dcdb1ebd2ffe5451d18e..419a7e7700c71d91f9a87b165104242a65f50db1 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1101,6 +1101,7 @@ public: > void postMessageToInjectedBundle(const String& messageName, API::Object* messageBody); > > #if ENABLE(INPUT_TYPE_COLOR) >+ WebColorPicker* activeColorPicker() const; > void setColorPickerColor(const WebCore::Color&); > void endColorPicker(); > #endif >diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.h b/Source/WebKit/UIProcess/mac/PageClientImplMac.h >index c538b5bcf613fd2cc85c9d70634e4497b3a1bcbf..566bf053a18faa525ac8ece21695976781e1d347 100644 >--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.h >+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.h >@@ -123,6 +123,10 @@ private: > > void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override; > >+#if HAVE(TOUCH_BAR) >+ void updateTouchBar() override; >+#endif >+ > RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override; > #if ENABLE(CONTEXT_MENUS) > Ref<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, ContextMenuContextData&&, const UserData&) override; >@@ -130,6 +134,9 @@ private: > > #if ENABLE(INPUT_TYPE_COLOR) > RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&) override; >+#if HAVE(TOUCH_BAR) >+ void updateColorTouchBarColor(const WebCore::Color&) override; >+#endif > #endif > > #if ENABLE(DATALIST_ELEMENT) >diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >index 8c23b28b820b5be1e741b317e3d209ffa8161d0c..9e8500c18dde5b4d7a32e7c72e23ea8488f9b316 100644 >--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >@@ -449,6 +449,13 @@ void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool > m_impl->doneWithKeyEvent(event.nativeEvent(), eventWasHandled); > } > >+#if HAVE(TOUCH_BAR) >+void PageClientImpl::updateTouchBar() >+{ >+ m_impl->updateTouchBar(); >+} >+#endif >+ > RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page) > { > return WebPopupMenuProxyMac::create(m_view, page); >@@ -466,7 +473,14 @@ RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, con > { > return WebColorPickerMac::create(page, initialColor, rect, WTFMove(suggestions), m_view); > } >-#endif >+ >+#if HAVE(TOUCH_BAR) >+void PageClientImpl::updateColorTouchBarColor(const WebCore::Color& color) >+{ >+ m_impl->updateColorTouchBarColor(color); >+} >+#endif // HAVE(TOUCH_BAR) >+#endif // ENABLE(INPUT_TYPE_COLOR) > > #if ENABLE(DATALIST_ELEMENT) > RefPtr<WebDataListSuggestionsDropdown> PageClientImpl::createDataListSuggestionsDropdown(WebPageProxy& page) >diff --git a/Source/WebKit/UIProcess/mac/WebColorPickerMac.h b/Source/WebKit/UIProcess/mac/WebColorPickerMac.h >index 54af0637e60fcffed6ef3f11ee41c8982996f71e..79f324d61555ee06aabce94c04d382f75b843db6 100644 >--- a/Source/WebKit/UIProcess/mac/WebColorPickerMac.h >+++ b/Source/WebKit/UIProcess/mac/WebColorPickerMac.h >@@ -53,6 +53,8 @@ class WebColorPickerMac; > - (void)invalidate; > - (void)setColor:(NSColor *)color; > - (void)didChooseColor:(id)sender; >+- (void)setColorFromTouchBar:(const WebCore::Color&)color; >+- (NSColor *)currentColor; > @end > > namespace WebKit { >@@ -65,6 +67,8 @@ public: > void endPicker() override; > void setSelectedColor(const WebCore::Color&) override; > void showColorPicker(const WebCore::Color&) override; >+ void setColorFromTouchBar(const WebCore::Color&) override; >+ WebCore::Color currentColor() override; > > void didChooseColor(const WebCore::Color&); > >diff --git a/Source/WebKit/UIProcess/mac/WebColorPickerMac.mm b/Source/WebKit/UIProcess/mac/WebColorPickerMac.mm >index 34a360b91ef93d3eb37cb231193396a340760b20..6eb6f4230741c7435c9ec5852442dda11a147c13 100644 >--- a/Source/WebKit/UIProcess/mac/WebColorPickerMac.mm >+++ b/Source/WebKit/UIProcess/mac/WebColorPickerMac.mm >@@ -38,6 +38,7 @@ > > #import <WebCore/Color.h> > #import <WebCore/ColorMac.h> >+#import <objc/runtime.h> > #import <pal/spi/mac/NSColorWellSPI.h> > #import <pal/spi/mac/NSPopoverColorWellSPI.h> > #import <pal/spi/mac/NSPopoverSPI.h> >@@ -63,6 +64,7 @@ static const CGFloat colorPickerMatrixSwatchWidth = 12.0; > > @property (nonatomic, weak) id<WKPopoverColorWellDelegate> webDelegate; > >+- (void)setColorWithoutClose:(NSColor *)color; > - (void)setSuggestedColors:(NSColorList *)suggestedColors; > @end > >@@ -128,6 +130,19 @@ void WebColorPickerMac::showColorPicker(const WebCore::Color& color) > [m_colorPickerUI setAndShowPicker:this withColor:nsColor(color) suggestions:WTFMove(m_suggestions)]; > } > >+void WebColorPickerMac::setColorFromTouchBar(const WebCore::Color& color) >+{ >+ [m_colorPickerUI setColorFromTouchBar:color]; >+} >+ >+WebCore::Color WebColorPickerMac::currentColor() >+{ >+ if (!m_colorPickerUI) >+ return Color(); >+ >+ return WebCore::colorFromNSColor([m_colorPickerUI currentColor]); >+} >+ > } // namespace WebKit > > @implementation WKPopoverColorWell >@@ -194,6 +209,15 @@ void WebColorPickerMac::showColorPicker(const WebCore::Color& color) > return nil; > } > >+- (void)setColorWithoutClose:(NSColor *)color >+{ >+ // The default behavior of NSPopoverColorWell is to close the popover when the color is changed. >+ // The default behavior does not make sense when we change the color using the touch bar. >+ Class original = self.superclass.superclass; >+ void (* imp)(id, SEL, NSColor *) = (void (*)(id, SEL, NSColor *))class_getMethodImplementation(original, @selector(setColor:)); >+ imp(self, @selector(setColor:), color); >+} >+ > - (void)setSuggestedColors:(NSColorList *)suggestedColors > { > _suggestedColors = suggestedColors; >@@ -241,6 +265,18 @@ void WebColorPickerMac::showColorPicker(const WebCore::Color& color) > _lastChangedByUser = YES; > } > >+- (NSColor *)currentColor >+{ >+ return [_popoverWell color]; >+} >+ >+- (void)setColorFromTouchBar:(const WebCore::Color&)color >+{ >+ _lastChangedByUser = YES; >+ _picker->didChooseColor(color); >+ [_popoverWell setColorWithoutClose:nsColor(color)]; >+} >+ > - (void)invalidate > { > [_popoverWell removeFromSuperviewWithoutNeedingDisplay]; >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index 3cca8210b874ca16d413ea10016b6edf6848c6fd..9023aff7cf7c760ea68c2d08cba3170f70fac770 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -5038,7 +5038,8 @@ void WebPage::elementDidFocus(WebCore::Node* node) > > send(Messages::WebPageProxy::StartAssistingNode(information, m_userIsInteracting, m_hasPendingBlurNotification, m_changingActivityState, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); > #elif PLATFORM(MAC) >- if (node->hasTagName(WebCore::HTMLNames::selectTag)) >+ if (node->hasTagName(WebCore::HTMLNames::selectTag) >+ || (is<HTMLInputElement>(node) && downcast<HTMLInputElement>(*node).isColorControl())) > send(Messages::WebPageProxy::SetEditableElementIsFocused(false)); > else > send(Messages::WebPageProxy::SetEditableElementIsFocused(true));
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 189214
:
348681
|
348685
|
348688