Diff
Modified: trunk/Source/WebCore/ChangeLog (234171 => 234172)
--- trunk/Source/WebCore/ChangeLog 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebCore/ChangeLog 2018-07-24 21:46:36 UTC (rev 234172)
@@ -1,3 +1,13 @@
+2018-07-24 Aditya Keerthi <[email protected]>
+
+ [Datalist][macOS] Display suggestions for input[type=color]
+ https://bugs.webkit.org/show_bug.cgi?id=187794
+
+ Reviewed by Tim Horton.
+
+ * html/ColorInputType.cpp:
+ (WebCore::ColorInputType::shouldRespectListAttribute):
+
2018-07-24 Ryan Haddad <[email protected]>
Unreviewed, rolling out r234121.
Modified: trunk/Source/WebCore/PAL/ChangeLog (234171 => 234172)
--- trunk/Source/WebCore/PAL/ChangeLog 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebCore/PAL/ChangeLog 2018-07-24 21:46:36 UTC (rev 234172)
@@ -1,3 +1,17 @@
+2018-07-24 Aditya Keerthi <[email protected]>
+
+ [Datalist][macOS] Display suggestions for input[type=color]
+ https://bugs.webkit.org/show_bug.cgi?id=187794
+
+ Reviewed by Tim Horton.
+
+ Added methods to enable customization of NSPopoverColorWell.
+
+ * PAL.xcodeproj/project.pbxproj:
+ * pal/spi/mac/NSColorWellSPI.h: Added.
+ * pal/spi/mac/NSPopoverColorWellSPI.h: Added.
+ * pal/spi/mac/NSPopoverSPI.h:
+
2018-07-23 Tim Horton <[email protected]>
Creating and loading content in a WKWebView triggers Main Thread Checker warnings under ServicesController
Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (234171 => 234172)
--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2018-07-24 21:46:36 UTC (rev 234172)
@@ -146,6 +146,8 @@
A3AB6E651F3D217F009C14B1 /* SystemSleepListenerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A3AB6E631F3D217F009C14B1 /* SystemSleepListenerMac.mm */; };
A3C66CDC1F462D6A009E6EE9 /* SessionID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3C66CDA1F462D6A009E6EE9 /* SessionID.cpp */; };
A3C66CDD1F462D6A009E6EE9 /* SessionID.h in Headers */ = {isa = PBXBuildFile; fileRef = A3C66CDB1F462D6A009E6EE9 /* SessionID.h */; };
+ E5D45D122106A07400D2B738 /* NSColorWellSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = E5D45D112106A07400D2B738 /* NSColorWellSPI.h */; };
+ E5D45D142106A18700D2B738 /* NSPopoverColorWellSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = E5D45D132106A18700D2B738 /* NSPopoverColorWellSPI.h */; };
F442915E1FA52473002CC93E /* NSFileSizeFormatterSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = F442915D1FA52473002CC93E /* NSFileSizeFormatterSPI.h */; };
F44291601FA5261E002CC93E /* FileSizeFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = F442915F1FA5261E002CC93E /* FileSizeFormatter.h */; };
F44291641FA52670002CC93E /* FileSizeFormatter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F44291621FA52670002CC93E /* FileSizeFormatter.cpp */; };
@@ -298,6 +300,8 @@
A3C66CDA1F462D6A009E6EE9 /* SessionID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SessionID.cpp; sourceTree = "<group>"; };
A3C66CDB1F462D6A009E6EE9 /* SessionID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SessionID.h; sourceTree = "<group>"; };
C2147A4A1EFD0AA600056FA5 /* CopyPALHeaders.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CopyPALHeaders.xcconfig; sourceTree = "<group>"; };
+ E5D45D112106A07400D2B738 /* NSColorWellSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSColorWellSPI.h; sourceTree = "<group>"; };
+ E5D45D132106A18700D2B738 /* NSPopoverColorWellSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSPopoverColorWellSPI.h; sourceTree = "<group>"; };
F442915D1FA52473002CC93E /* NSFileSizeFormatterSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFileSizeFormatterSPI.h; sourceTree = "<group>"; };
F442915F1FA5261E002CC93E /* FileSizeFormatter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FileSizeFormatter.h; sourceTree = "<group>"; };
F44291621FA52670002CC93E /* FileSizeFormatter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileSizeFormatter.cpp; sourceTree = "<group>"; };
@@ -432,6 +436,7 @@
1CCEE4F620D8743F0047B097 /* NSAppearanceSPI.h */,
0C7785751F45130F00F4EBB6 /* NSApplicationSPI.h */,
A1175B4A1F6B2D7E00C4B9F0 /* NSCellSPI.h */,
+ E5D45D112106A07400D2B738 /* NSColorWellSPI.h */,
0C7785761F45130F00F4EBB6 /* NSEventSPI.h */,
0C7785771F45130F00F4EBB6 /* NSFontSPI.h */,
A10826FD1F58A433004772AC /* NSGraphicsSPI.h */,
@@ -439,6 +444,7 @@
0C7785781F45130F00F4EBB6 /* NSImmediateActionGestureRecognizerSPI.h */,
0C7785791F45130F00F4EBB6 /* NSMenuSPI.h */,
0C77857A1F45130F00F4EBB6 /* NSPasteboardSPI.h */,
+ E5D45D132106A18700D2B738 /* NSPopoverColorWellSPI.h */,
0C77857B1F45130F00F4EBB6 /* NSPopoverSPI.h */,
A10826F01F573BCA004772AC /* NSResponderSPI.h */,
0C77857C1F45130F00F4EBB6 /* NSScrollerImpSPI.h */,
@@ -674,6 +680,7 @@
0C2DA14C1F3BEB4900DBC317 /* NSCalendarDateSPI.h in Headers */,
A1175B4B1F6B2D7E00C4B9F0 /* NSCellSPI.h in Headers */,
0C2DA14D1F3BEB4900DBC317 /* NSColorSPI.h in Headers */,
+ E5D45D122106A07400D2B738 /* NSColorWellSPI.h in Headers */,
0C77858F1F45130F00F4EBB6 /* NSEventSPI.h in Headers */,
0C2DA14E1F3BEB4900DBC317 /* NSExtensionSPI.h in Headers */,
0C2DA14F1F3BEB4900DBC317 /* NSFileManagerSPI.h in Headers */,
@@ -685,6 +692,7 @@
7A1656441F97B2B900BA3CE4 /* NSKeyedArchiverSPI.h in Headers */,
0C7785921F45130F00F4EBB6 /* NSMenuSPI.h in Headers */,
0C7785931F45130F00F4EBB6 /* NSPasteboardSPI.h in Headers */,
+ E5D45D142106A18700D2B738 /* NSPopoverColorWellSPI.h in Headers */,
0C7785941F45130F00F4EBB6 /* NSPopoverSPI.h in Headers */,
A10826F11F573BCA004772AC /* NSResponderSPI.h in Headers */,
0C7785951F45130F00F4EBB6 /* NSScrollerImpSPI.h in Headers */,
Added: trunk/Source/WebCore/PAL/pal/spi/mac/NSColorWellSPI.h (0 => 234172)
--- trunk/Source/WebCore/PAL/pal/spi/mac/NSColorWellSPI.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSColorWellSPI.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(APPKIT)
+
+@interface NSColorWell ()
++ (NSColorWell *)_exclusiveColorPanelOwner;
+@end
+
+#endif // USE(APPKIT)
Added: trunk/Source/WebCore/PAL/pal/spi/mac/NSPopoverColorWellSPI.h (0 => 234172)
--- trunk/Source/WebCore/PAL/pal/spi/mac/NSPopoverColorWellSPI.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSPopoverColorWellSPI.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(APPKIT)
+
+@interface NSPopoverColorWell : NSColorWell<NSPopoverDelegate>
+- (void)_showPopover;
+@end
+
+@interface NSColorPickerMatrixView : NSView
+@end
+
+@interface NSColorPickerMatrixView ()
+- (void)setColorList:(NSColorList *)list;
+- (void)setSwatchSize:(NSSize)size;
+- (void)setNumberOfColumns:(NSUInteger)columns;
+@end
+
+@interface NSColorPopoverController : NSViewController
+@end
+
+@interface NSColorPopoverController ()
+@property (assign) id delegate;
+@property (assign) NSPopover *popover;
+@property (assign) NSColorPickerMatrixView *topBarMatrixView;
+@end
+
+#endif // USE(APPKIT)
Modified: trunk/Source/WebCore/PAL/pal/spi/mac/NSPopoverSPI.h (234171 => 234172)
--- trunk/Source/WebCore/PAL/pal/spi/mac/NSPopoverSPI.h 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSPopoverSPI.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -42,5 +42,6 @@
};
@interface NSPopover (WKDetails)
+- (void)_setRequiresCorrectContentAppearance:(BOOL)requiresCorrectAppearance;
@property NSPopoverPositioningOptions positioningOptions;
@end
Modified: trunk/Source/WebCore/html/ColorInputType.cpp (234171 => 234172)
--- trunk/Source/WebCore/html/ColorInputType.cpp 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebCore/html/ColorInputType.cpp 2018-07-24 21:46:36 UTC (rev 234172)
@@ -187,7 +187,7 @@
bool ColorInputType::shouldRespectListAttribute()
{
- return InputType::themeSupportsDataListUI(this);
+ return true;
}
bool ColorInputType::typeMismatchFor(const String& value) const
Modified: trunk/Source/WebKit/ChangeLog (234171 => 234172)
--- trunk/Source/WebKit/ChangeLog 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/ChangeLog 2018-07-24 21:46:36 UTC (rev 234172)
@@ -1,3 +1,53 @@
+2018-07-24 Aditya Keerthi <[email protected]>
+
+ [Datalist][macOS] Display suggestions for input[type=color]
+ https://bugs.webkit.org/show_bug.cgi?id=187794
+
+ Reviewed by Tim Horton.
+
+ An input[type=color] element that has an associated datalist element should
+ display the color values provided. We now support 1-12 suggested colors, that
+ will be displayed at the top of the color selection popover. If no suggestions
+ are specified we keep the existing default colors.
+
+ Created an NSPopoverColorWell subclass that allows custom colors to be specified
+ in the form of an NSColorList.
+
+ Also fixed a bug where an additional color well was displayed when clicking on
+ the input element.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<Color>::decode):
+ * Shared/WebCoreArgumentCoders.h:
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::createColorPicker):
+ * UIProcess/API/gtk/PageClientImpl.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::showColorPicker):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::createColorPicker):
+ * UIProcess/mac/PageClientImplMac.h:
+ * UIProcess/mac/PageClientImplMac.mm:
+ (WebKit::PageClientImpl::createColorPicker):
+ * UIProcess/mac/WebColorPickerMac.h:
+ * UIProcess/mac/WebColorPickerMac.mm:
+ (WebKit::WebColorPickerMac::create):
+ (WebKit::WebColorPickerMac::WebColorPickerMac):
+ (WebKit::WebColorPickerMac::showColorPicker):
+ (+[WKPopoverColorWell _colorPopoverCreateIfNecessary:]):
+ (-[WKPopoverColorWell _showPopover]):
+ (-[WKPopoverColorWell setSuggestedColors:]):
+ (-[WKColorPopoverMac initWithFrame:inView:]):
+ (-[WKColorPopoverMac setAndShowPicker:withColor:suggestions:]):
+ (-[WKColorPanelMac setAndShowPicker:withColor:suggestions:]):
+ * WebProcess/WebCoreSupport/WebColorChooser.cpp:
+ (WebKit::WebColorChooser::WebColorChooser):
+ (WebKit::WebColorChooser::reattachColorChooser):
+
2018-07-24 Alex Christensen <[email protected]>
Modernize NavigationState
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (234171 => 234172)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2018-07-24 21:46:36 UTC (rev 234172)
@@ -1515,6 +1515,15 @@
return true;
}
+std::optional<Color> ArgumentCoder<Color>::decode(Decoder& decoder)
+{
+ Color color;
+ if (!decode(decoder, color))
+ return std::nullopt;
+
+ return color;
+}
+
#if ENABLE(DRAG_SUPPORT)
void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
{
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (234171 => 234172)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -379,6 +379,7 @@
template<> struct ArgumentCoder<WebCore::Color> {
static void encode(Encoder&, const WebCore::Color&);
static bool decode(Decoder&, WebCore::Color&);
+ static std::optional<WebCore::Color> decode(Decoder&);
};
#if ENABLE(DRAG_SUPPORT)
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2018-07-24 21:46:36 UTC (rev 234172)
@@ -217,7 +217,7 @@
return WebContextMenuProxyGtk::create(m_viewWidget, page, WTFMove(context), userData);
}
-RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& color, const WebCore::IntRect& rect)
+RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& color, const WebCore::IntRect& rect, Vector<WebCore::Color>&&)
{
if (WEBKIT_IS_WEB_VIEW(m_viewWidget))
return WebKitColorChooser::create(*page, color, rect);
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -84,7 +84,7 @@
RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
Ref<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, ContextMenuContextData&&, const UserData&) override;
#if ENABLE(INPUT_TYPE_COLOR)
- RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&) override;
+ RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&) override;
#endif
void selectionDidChange() override;
#if ENABLE(DRAG_SUPPORT)
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -224,7 +224,7 @@
#endif
#if ENABLE(INPUT_TYPE_COLOR)
- virtual RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) = 0;
+ virtual RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&) = 0;
#endif
#if ENABLE(DATALIST_ELEMENT)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-07-24 21:46:36 UTC (rev 234172)
@@ -4697,7 +4697,7 @@
}
#if ENABLE(INPUT_TYPE_COLOR)
-void WebPageProxy::showColorPicker(const WebCore::Color& initialColor, const IntRect& elementRect)
+void WebPageProxy::showColorPicker(const WebCore::Color& initialColor, const IntRect& elementRect, Vector<WebCore::Color>&& suggestions)
{
#if ENABLE(INPUT_TYPE_COLOR_POPOVER)
// A new popover color well needs to be created (and the previous one destroyed) for
@@ -4705,7 +4705,7 @@
m_colorPicker = nullptr;
#endif
if (!m_colorPicker)
- m_colorPicker = m_pageClient.createColorPicker(this, initialColor, elementRect);
+ m_colorPicker = m_pageClient.createColorPicker(this, initialColor, elementRect, WTFMove(suggestions));
m_colorPicker->showColorPicker(initialColor);
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -1517,7 +1517,7 @@
void didChangeContentSize(const WebCore::IntSize&);
#if ENABLE(INPUT_TYPE_COLOR)
- void showColorPicker(const WebCore::Color& initialColor, const WebCore::IntRect&);
+ void showColorPicker(const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&);
void didChooseColor(const WebCore::Color&) override;
void didEndColorPicker() override;
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-07-24 21:46:36 UTC (rev 234172)
@@ -93,7 +93,7 @@
DidChangeContentSize(WebCore::IntSize newSize)
#if ENABLE(INPUT_TYPE_COLOR)
- ShowColorPicker(WebCore::Color initialColor, WebCore::IntRect elementRect);
+ ShowColorPicker(WebCore::Color initialColor, WebCore::IntRect elementRect, Vector<WebCore::Color> suggestions);
SetColorPickerColor(WebCore::Color color);
EndColorPicker();
#endif
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -101,7 +101,7 @@
Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final;
#if ENABLE(INPUT_TYPE_COLOR)
- RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) final;
+ RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&) final;
#endif
#if ENABLE(DATALIST_ELEMENT)
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2018-07-24 21:46:36 UTC (rev 234172)
@@ -765,7 +765,7 @@
}
#if ENABLE(INPUT_TYPE_COLOR)
-RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&)
+RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&)
{
return nullptr;
}
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -129,7 +129,7 @@
#endif
#if ENABLE(INPUT_TYPE_COLOR)
- RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) override;
+ RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&) override;
#endif
#if ENABLE(DATALIST_ELEMENT)
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2018-07-24 21:46:36 UTC (rev 234172)
@@ -453,9 +453,9 @@
#endif
#if ENABLE(INPUT_TYPE_COLOR)
-RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& initialColor, const WebCore::IntRect& rect)
+RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& initialColor, const WebCore::IntRect& rect, Vector<WebCore::Color>&& suggestions)
{
- return WebColorPickerMac::create(page, initialColor, rect, m_view);
+ return WebColorPickerMac::create(page, initialColor, rect, WTFMove(suggestions), m_view);
}
#endif
Modified: trunk/Source/WebKit/UIProcess/mac/WebColorPickerMac.h (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/mac/WebColorPickerMac.h 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/mac/WebColorPickerMac.h 2018-07-24 21:46:36 UTC (rev 234172)
@@ -29,8 +29,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebColorPickerMac_h
-#define WebColorPickerMac_h
+#pragma once
#if ENABLE(INPUT_TYPE_COLOR)
@@ -49,7 +48,7 @@
}
@protocol WKColorPickerUIMac <NSObject>
-- (void)setAndShowPicker:(WebKit::WebColorPickerMac*)picker withColor:(NSColor *)color;
+- (void)setAndShowPicker:(WebKit::WebColorPickerMac*)picker withColor:(NSColor *)color suggestions:(Vector<WebCore::Color>&&)suggestions;
- (void)invalidate;
- (void)setColor:(NSColor *)color;
- (void)didChooseColor:(id)sender;
@@ -59,7 +58,7 @@
class WebColorPickerMac : public WebColorPicker {
public:
- static Ref<WebColorPickerMac> create(WebColorPicker::Client*, const WebCore::Color&, const WebCore::IntRect&, NSView*);
+ static Ref<WebColorPickerMac> create(WebColorPicker::Client*, const WebCore::Color&, const WebCore::IntRect&, Vector<WebCore::Color>&&, NSView *);
~WebColorPickerMac();
void endPicker() override;
@@ -69,8 +68,9 @@
void didChooseColor(const WebCore::Color&);
private:
- WebColorPickerMac(WebColorPicker::Client*, const WebCore::Color&, const WebCore::IntRect&, NSView*);
+ WebColorPickerMac(WebColorPicker::Client*, const WebCore::Color&, const WebCore::IntRect&, Vector<WebCore::Color>&&, NSView *);
RetainPtr<NSObject<WKColorPickerUIMac> > m_colorPickerUI;
+ Vector<WebCore::Color> m_suggestions;
};
} // namespace WebKit
@@ -78,5 +78,3 @@
#endif // ENABLE(INPUT_TYPE_COLOR)
#endif // USE(APPKIT)
-
-#endif // WebContextMenuProxyMac_h
Modified: trunk/Source/WebKit/UIProcess/mac/WebColorPickerMac.mm (234171 => 234172)
--- trunk/Source/WebKit/UIProcess/mac/WebColorPickerMac.mm 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/UIProcess/mac/WebColorPickerMac.mm 2018-07-24 21:46:36 UTC (rev 234172)
@@ -36,6 +36,7 @@
#if USE(APPKIT)
+#import <WebCore/Color.h>
#import <WebCore/ColorMac.h>
using namespace WebKit;
@@ -42,14 +43,20 @@
#if ENABLE(INPUT_TYPE_COLOR_POPOVER)
-// The methods we use from NSPopoverColorWell aren't declared in its header
-// so there's no benefit to trying to include them. Instead we just declare
-// the class and methods here.
-@interface NSPopoverColorWell : NSColorWell
-@end
+#import <pal/spi/mac/NSColorWellSPI.h>
+#import <pal/spi/mac/NSPopoverColorWellSPI.h>
+#import <pal/spi/mac/NSPopoverSPI.h>
-@interface NSPopoverColorWell (AppKitSecretsIKnow)
-- (void)_showPopover;
+static const size_t maxColorSuggestions = 12;
+static const CGFloat colorPickerMatrixNumColumns = 12.0;
+static const CGFloat colorPickerMatrixSwatchWidth = 12.0;
+static const CGFloat colorPickerMatrixBorderWidth = 1.0;
+
+@interface WKPopoverColorWell : NSPopoverColorWell {
+ RetainPtr<NSColorList> _suggestedColors;
+}
+
+- (void)setSuggestedColors:(NSColorList *)suggestedColors;
@end
@interface WKColorPopoverMac : NSObject<WKColorPickerUIMac, NSWindowDelegate> {
@@ -56,7 +63,7 @@
@private
BOOL _lastChangedByUser;
WebColorPickerMac *_picker;
- RetainPtr<NSPopoverColorWell> _popoverWell;
+ RetainPtr<WKPopoverColorWell> _popoverWell;
}
- (id)initWithFrame:(const WebCore::IntRect &)rect inView:(NSView *)view;
@end
@@ -75,9 +82,9 @@
namespace WebKit {
-Ref<WebColorPickerMac> WebColorPickerMac::create(WebColorPicker::Client* client, const WebCore::Color& initialColor, const WebCore::IntRect& rect, NSView* view)
+Ref<WebColorPickerMac> WebColorPickerMac::create(WebColorPicker::Client* client, const WebCore::Color& initialColor, const WebCore::IntRect& rect, Vector<WebCore::Color>&& suggestions, NSView *view)
{
- return adoptRef(*new WebColorPickerMac(client, initialColor, rect, view));
+ return adoptRef(*new WebColorPickerMac(client, initialColor, rect, WTFMove(suggestions), view));
}
WebColorPickerMac::~WebColorPickerMac()
@@ -86,8 +93,9 @@
endPicker();
}
-WebColorPickerMac::WebColorPickerMac(WebColorPicker::Client* client, const WebCore::Color& initialColor, const WebCore::IntRect& rect, NSView* view)
+WebColorPickerMac::WebColorPickerMac(WebColorPicker::Client* client, const WebCore::Color& initialColor, const WebCore::IntRect& rect, Vector<WebCore::Color>&& suggestions, NSView *view)
: WebColorPicker(client)
+ , m_suggestions(WTFMove(suggestions))
{
#if ENABLE(INPUT_TYPE_COLOR_POPOVER)
m_colorPickerUI = adoptNS([[WKColorPopoverMac alloc] initWithFrame:rect inView:view]);
@@ -128,7 +136,7 @@
m_colorPickerUI = adoptNS([[WKColorPanelMac alloc] init]);
#endif
- [m_colorPickerUI setAndShowPicker:this withColor:nsColor(color)];
+ [m_colorPickerUI setAndShowPicker:this withColor:nsColor(color) suggestions:WTFMove(m_suggestions)];
}
} // namespace WebKit
@@ -135,6 +143,68 @@
#if ENABLE(INPUT_TYPE_COLOR_POPOVER)
+@implementation WKPopoverColorWell
+
++ (NSPopover *)_colorPopoverCreateIfNecessary:(BOOL)forceCreation
+{
+ static NSPopover *colorPopover = nil;
+ if (forceCreation) {
+ NSPopover *popover = [[NSPopover alloc] init];
+ [popover _setRequiresCorrectContentAppearance:YES];
+ popover.behavior = NSPopoverBehaviorTransient;
+
+ NSColorPopoverController *controller = [[NSClassFromString(@"NSColorPopoverController") alloc] init];
+ popover.contentViewController = controller;
+ controller.popover = popover;
+ [controller release];
+
+ colorPopover = popover;
+ }
+
+ return colorPopover;
+}
+
+- (void)_showPopover
+{
+ NSPopover *popover = [[self class] _colorPopoverCreateIfNecessary:YES];
+ popover.delegate = self;
+
+ [self deactivate];
+
+ // Deactivate previous NSPopoverColorWell
+ NSColorWell *owner = [NSColorWell _exclusiveColorPanelOwner];
+ if ([owner isKindOfClass:[NSPopoverColorWell class]])
+ [owner deactivate];
+
+ NSColorPopoverController *controller = (NSColorPopoverController *)[popover contentViewController];
+ controller.delegate = self;
+
+ if (_suggestedColors) {
+ NSUInteger numColors = [[_suggestedColors allKeys] count];
+ CGFloat swatchWidth = (colorPickerMatrixNumColumns * colorPickerMatrixSwatchWidth + (colorPickerMatrixNumColumns * colorPickerMatrixBorderWidth - numColors)) / numColors;
+ CGFloat swatchHeight = colorPickerMatrixSwatchWidth;
+
+ // topBarMatrixView cannot be accessed until view has been loaded
+ if (!controller.isViewLoaded)
+ [controller loadView];
+
+ NSColorPickerMatrixView *topMatrix = controller.topBarMatrixView;
+ [topMatrix setNumberOfColumns:numColors];
+ [topMatrix setSwatchSize:NSMakeSize(swatchWidth, swatchHeight)];
+ [topMatrix setColorList:_suggestedColors.get()];
+ }
+
+ [self activate:YES];
+ [popover showRelativeToRect:self.bounds ofView:self preferredEdge:NSMinYEdge];
+}
+
+- (void)setSuggestedColors:(NSColorList *)suggestedColors
+{
+ _suggestedColors = suggestedColors;
+}
+
+@end
+
@implementation WKColorPopoverMac
- (id)initWithFrame:(const WebCore::IntRect &)rect inView:(NSView *)view
{
@@ -141,16 +211,17 @@
if(!(self = [super init]))
return self;
- _popoverWell = adoptNS([[NSPopoverColorWell alloc] initWithFrame:[view convertRect:NSRectFromCGRect(rect) toView:nil]]);
+ _popoverWell = adoptNS([[WKPopoverColorWell alloc] initWithFrame:[view convertRect:NSRectFromCGRect(rect) toView:nil]]);
if (!_popoverWell)
return self;
+ [_popoverWell setAlphaValue:0.0];
[[view window].contentView addSubview:_popoverWell.get()];
return self;
}
-- (void)setAndShowPicker:(WebKit::WebColorPickerMac*)picker withColor:(NSColor *)color
+- (void)setAndShowPicker:(WebKit::WebColorPickerMac*)picker withColor:(NSColor *)color suggestions:(Vector<WebCore::Color>&&)suggestions
{
_picker = picker;
@@ -157,6 +228,15 @@
[_popoverWell setTarget:self];
[_popoverWell setAction:@selector(didChooseColor:)];
[_popoverWell setColor:color];
+
+ NSColorList *suggestedColors = nil;
+ if (suggestions.size()) {
+ suggestedColors = [[[NSColorList alloc] init] autorelease];
+ for (size_t i = 0; i < std::min(suggestions.size(), maxColorSuggestions); i++)
+ [suggestedColors insertColor:nsColor(suggestions.at(i)) key:@(i).stringValue atIndex:i];
+ }
+
+ [_popoverWell setSuggestedColors:suggestedColors];
[_popoverWell _showPopover];
_lastChangedByUser = YES;
@@ -216,7 +296,7 @@
return self;
}
-- (void)setAndShowPicker:(WebColorPickerMac*)picker withColor:(NSColor *)color
+- (void)setAndShowPicker:(WebColorPickerMac*)picker withColor:(NSColor *)color suggestions:(Vector<WebCore::Color>&&)suggestions
{
_picker = picker;
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp (234171 => 234172)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp 2018-07-24 21:42:20 UTC (rev 234171)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp 2018-07-24 21:46:36 UTC (rev 234172)
@@ -43,7 +43,7 @@
, m_page(page)
{
m_page->setActiveColorChooser(this);
- WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowColorPicker(initialColor, client->elementRectRelativeToRootView()), m_page->pageID());
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowColorPicker(initialColor, client->elementRectRelativeToRootView(), client->suggestions()), m_page->pageID());
}
WebColorChooser::~WebColorChooser()
@@ -75,7 +75,7 @@
m_page->setActiveColorChooser(this);
ASSERT(m_colorChooserClient);
- WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowColorPicker(color, m_colorChooserClient->elementRectRelativeToRootView()), m_page->pageID());
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowColorPicker(color, m_colorChooserClient->elementRectRelativeToRootView(), m_colorChooserClient->suggestions()), m_page->pageID());
}
void WebColorChooser::setSelectedColor(const Color& color)