[iOS] Add support for input[type=color]
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2018 19:13:08 +0000 (19:13 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2018 19:13:08 +0000 (19:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187871

Patch by Aditya Keerthi <akeerthi@apple.com> on 2018-07-23
Reviewed by Tim Horton.

Source/WebCore:

* css/html.css: Remove unwanted styling for color inputs with a list attribute.
* html/ColorInputType.cpp: Make the element focusable.
(WebCore::ColorInputType::isMouseFocusable const):
(WebCore::ColorInputType::isKeyboardFocusable const):
* html/ColorInputType.h:
* html/HTMLInputElement.h: Expose isColorControl() to WebKit.
* page/Chrome.cpp:
(WebCore::Chrome::createColorChooser):

Source/WebKit:

Created WKFormColorControl to display a color picker once a color input gains
focus. The control is presented as an inputView on iPhone and as a popover on
iPad. The picker itself consists of two color matrices. The first is a set of 12
default colors, displayed on the top row of the picker. In a subsequent patch,
this top row will be made customizable through the use of the datalist element.
The second matrix is a grid of 120 colors, provided by the system. Colors can be
selected from either matrix by tapping or with a pan gesture.

WKColorMatrixView represents a single color matrix and is comprised of
WKColorButtons that represent each color in the matrix.

* Shared/AssistedNodeInformation.h:
* UIProcess/API/Cocoa/_WKFocusedElementInfo.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::createColorPicker):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKFocusedElementInfo initWithAssistedNodeInformation:isUserInitiated:userObject:]):
(-[WKContentView _requiresKeyboardWhenFirstResponder]):
(-[WKContentView inputView]):
(-[WKContentView requiresAccessoryView]):
(isAssistableInputType):
(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
(-[WKContentView actionNameForFocusedFormControlView:]):
* UIProcess/ios/forms/WKFormColorControl.h: Added.
* UIProcess/ios/forms/WKFormColorControl.mm: Added.
(-[WKColorPopover initWithView:]):
(-[WKColorPopover controlView]):
(-[WKColorPopover controlBeginEditing]):
(-[WKColorPopover controlEndEditing]):
(-[WKFormColorControl initWithView:]):
(-[WKFormColorControl assistantView]):
(-[WKFormColorControl beginEditing]):
(-[WKFormColorControl endEditing]):
* UIProcess/ios/forms/WKFormColorPicker.h: Added.
* UIProcess/ios/forms/WKFormColorPicker.mm: Added.
(+[WKColorButton colorButtonWithColor:]):
(-[WKColorMatrixView initWithFrame:]):
(-[WKColorMatrixView initWithFrame:colorMatrix:]):
(-[WKColorMatrixView layoutSubviews]):
(-[WKColorMatrixView colorButtonTapped:]):
(+[WKColorPicker defaultTopColorMatrix]):
(-[WKColorPicker initWithView:]):
(-[WKColorPicker setControlValueFromUIColor:]):
(-[WKColorPicker controlView]):
(-[WKColorPicker controlBeginEditing]):
(-[WKColorPicker controlEndEditing]):
(-[WKColorPicker colorMatrixView:didTapColorButton:]):
(-[WKColorPicker didPanColors:]):
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::isAssistableElement):
(WebKit::WebPage::getAssistedNodeInformation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234105 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/html.css
Source/WebCore/html/ColorInputType.cpp
Source/WebCore/html/ColorInputType.h
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/page/Chrome.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/AssistedNodeInformation.h
Source/WebKit/UIProcess/API/Cocoa/_WKFocusedElementInfo.h
Source/WebKit/UIProcess/ios/PageClientImplIOS.h
Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/forms/WKFormColorControl.h [new file with mode: 0644]
Source/WebKit/UIProcess/ios/forms/WKFormColorControl.mm [new file with mode: 0644]
Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.h [new file with mode: 0644]
Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

index 354dd08..959b8b5 100644 (file)
@@ -1,3 +1,19 @@
+2018-07-23  Aditya Keerthi  <akeerthi@apple.com>
+
+        [iOS] Add support for input[type=color]
+        https://bugs.webkit.org/show_bug.cgi?id=187871
+
+        Reviewed by Tim Horton.
+
+        * css/html.css: Remove unwanted styling for color inputs with a list attribute.
+        * html/ColorInputType.cpp: Make the element focusable.
+        (WebCore::ColorInputType::isMouseFocusable const):
+        (WebCore::ColorInputType::isKeyboardFocusable const):
+        * html/ColorInputType.h:
+        * html/HTMLInputElement.h: Expose isColorControl() to WebKit.
+        * page/Chrome.cpp:
+        (WebCore::Chrome::createColorChooser):
+
 2018-07-22  Dean Jackson  <dino@apple.com>
 
         fullscreen env() variables should have initial values
index 6a7e49e..6412569 100644 (file)
@@ -863,7 +863,9 @@ select:focus {
 #if defined(ENABLE_INPUT_TYPE_COLOR) && ENABLE_INPUT_TYPE_COLOR
 
 input[type="color"] {
+#if !(defined(WTF_PLATFORM_IOS) && WTF_PLATFORM_IOS)
     -webkit-appearance: square-button;
+#endif
     width: 44px;
     height: 23px;
 }
@@ -882,23 +884,6 @@ input[type="color"]::-webkit-color-swatch {
     flex: 1;
 }
 
-#if defined(ENABLE_DATALIST_ELEMENT) && ENABLE_DATALIST_ELEMENT
-
-input[type="color"][list] {
-    -webkit-appearance: menulist;
-    width: 88px;
-    height: 23px;
-}
-
-input[type="color"][list]::-webkit-color-swatch-wrapper {
-    padding-left: 8px;
-    padding-right: 24px;
-}
-
-input[type="color"][list]::-webkit-color-swatch {
-    border-color: #000000;
-}
-
 #endif // defined(ENABLE_DATALIST_ELEMENT) && ENABLE_DATALIST_ELEMENT
 
 #endif // defined(ENABLE_INPUT_TYPE_COLOR) && ENABLE_INPUT_TYPE_COLOR
index 8ce2465..543e37a 100644 (file)
@@ -81,6 +81,24 @@ ColorInputType::~ColorInputType()
     endColorChooser();
 }
 
+bool ColorInputType::isMouseFocusable() const
+{
+    ASSERT(element());
+    return element()->isTextFormControlFocusable();
+}
+
+bool ColorInputType::isKeyboardFocusable(KeyboardEvent*) const
+{
+    ASSERT(element());
+#if PLATFORM(IOS)
+    if (element()->isReadOnly())
+        return false;
+
+    return element()->isTextFormControlFocusable();
+#endif
+    return false;
+}
+
 bool ColorInputType::isColorControl() const
 {
     return true;
index 646d452..bb2962b 100644 (file)
@@ -51,6 +51,8 @@ private:
     Color currentColor() final;
     bool shouldShowSuggestions() const final;
     Vector<Color> suggestions() const final;
+    bool isMouseFocusable() const final;
+    bool isKeyboardFocusable(KeyboardEvent*) const final;
     bool isColorControl() const final;
     const AtomicString& formControlType() const final;
     bool supportsRequired() const final;
index c894aa6..3729b89 100644 (file)
@@ -107,7 +107,7 @@ public:
     bool isRangeControl() const;
 
 #if ENABLE(INPUT_TYPE_COLOR)
-    bool isColorControl() const;
+    WEBCORE_EXPORT bool isColorControl() const;
 #endif
 
     // FIXME: It's highly likely that any call site calling this function should instead
index c984563..e058fa8 100644 (file)
@@ -424,6 +424,9 @@ void Chrome::disableSuddenTermination()
 
 std::unique_ptr<ColorChooser> Chrome::createColorChooser(ColorChooserClient& client, const Color& initialColor)
 {
+#if PLATFORM(IOS)
+    return nullptr;
+#endif
     notifyPopupOpeningObservers();
     return m_client.createColorChooser(client, initialColor);
 }
index 9d22f4a..f7798d0 100644 (file)
@@ -1,3 +1,64 @@
+2018-07-23  Aditya Keerthi  <akeerthi@apple.com>
+
+        [iOS] Add support for input[type=color]
+        https://bugs.webkit.org/show_bug.cgi?id=187871
+
+        Reviewed by Tim Horton.
+
+        Created WKFormColorControl to display a color picker once a color input gains
+        focus. The control is presented as an inputView on iPhone and as a popover on
+        iPad. The picker itself consists of two color matrices. The first is a set of 12
+        default colors, displayed on the top row of the picker. In a subsequent patch,
+        this top row will be made customizable through the use of the datalist element.
+        The second matrix is a grid of 120 colors, provided by the system. Colors can be
+        selected from either matrix by tapping or with a pan gesture.
+
+        WKColorMatrixView represents a single color matrix and is comprised of
+        WKColorButtons that represent each color in the matrix.
+
+        * Shared/AssistedNodeInformation.h:
+        * UIProcess/API/Cocoa/_WKFocusedElementInfo.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::createColorPicker):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKFocusedElementInfo initWithAssistedNodeInformation:isUserInitiated:userObject:]):
+        (-[WKContentView _requiresKeyboardWhenFirstResponder]):
+        (-[WKContentView inputView]):
+        (-[WKContentView requiresAccessoryView]):
+        (isAssistableInputType):
+        (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+        (-[WKContentView actionNameForFocusedFormControlView:]):
+        * UIProcess/ios/forms/WKFormColorControl.h: Added.
+        * UIProcess/ios/forms/WKFormColorControl.mm: Added.
+        (-[WKColorPopover initWithView:]):
+        (-[WKColorPopover controlView]):
+        (-[WKColorPopover controlBeginEditing]):
+        (-[WKColorPopover controlEndEditing]):
+        (-[WKFormColorControl initWithView:]):
+        (-[WKFormColorControl assistantView]):
+        (-[WKFormColorControl beginEditing]):
+        (-[WKFormColorControl endEditing]):
+        * UIProcess/ios/forms/WKFormColorPicker.h: Added.
+        * UIProcess/ios/forms/WKFormColorPicker.mm: Added.
+        (+[WKColorButton colorButtonWithColor:]):
+        (-[WKColorMatrixView initWithFrame:]):
+        (-[WKColorMatrixView initWithFrame:colorMatrix:]):
+        (-[WKColorMatrixView layoutSubviews]):
+        (-[WKColorMatrixView colorButtonTapped:]):
+        (+[WKColorPicker defaultTopColorMatrix]):
+        (-[WKColorPicker initWithView:]):
+        (-[WKColorPicker setControlValueFromUIColor:]):
+        (-[WKColorPicker controlView]):
+        (-[WKColorPicker controlBeginEditing]):
+        (-[WKColorPicker controlEndEditing]):
+        (-[WKColorPicker colorMatrixView:didTapColorButton:]):
+        (-[WKColorPicker didPanColors:]):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::isAssistableElement):
+        (WebKit::WebPage::getAssistedNodeInformation):
+
 2018-07-23  Stephan Szabo  <stephan.szabo@sony.com>
 
         [WinCairo] Fix detection of held modifier keys for key events
index 03fb6af..6b0ce17 100644 (file)
@@ -52,7 +52,10 @@ enum class InputType {
     Month,
     Week,
     Time,
-    Select
+    Select,
+#if ENABLE(INPUT_TYPE_COLOR)
+    Color
+#endif
 };
 
 #if PLATFORM(IOS)
index 9ca1687..8704f82 100644 (file)
@@ -52,7 +52,8 @@ typedef NS_ENUM(NSInteger, WKInputType) {
     WKInputTypeMonth,
     WKInputTypeWeek,
     WKInputTypeTime,
-    WKInputTypeSelect
+    WKInputTypeSelect,
+    WKInputTypeColor
 };
 
 /**
index 77e05ce..5bdd9bc 100644 (file)
@@ -100,6 +100,10 @@ private:
     RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
     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;
+#endif
+
 #if ENABLE(DATALIST_ELEMENT)
     RefPtr<WebDataListSuggestionsDropdown> createDataListSuggestionsDropdown(WebPageProxy&) final;
 #endif
index e17d00f..3104772 100644 (file)
@@ -764,6 +764,13 @@ Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& messa
     return ValidationBubble::create(m_contentView, message, settings);
 }
 
+#if ENABLE(INPUT_TYPE_COLOR)
+RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&)
+{
+    return nullptr;
+}
+#endif
+
 #if ENABLE(DATALIST_ELEMENT)
 RefPtr<WebDataListSuggestionsDropdown> PageClientImpl::createDataListSuggestionsDropdown(WebPageProxy& page)
 {
index c89397c..a1a4dc8 100644 (file)
 #import <pal/spi/ios/GraphicsServicesSPI.h>
 #endif
 
+#if ENABLE(INPUT_TYPE_COLOR)
+#import "WKFormColorControl.h"
+#endif
+
 @interface UIEvent(UIEventInternal)
 @property (nonatomic, assign) UIKeyboardInputFlags _inputFlags;
 @end
@@ -477,6 +481,11 @@ const CGFloat minimumTapHighlightRadius = 2.0;
     case WebKit::InputType::Select:
         _type = WKInputTypeSelect;
         break;
+#if ENABLE(INPUT_TYPE_COLOR)
+    case WebKit::InputType::Color:
+        _type = WKInputTypeColor;
+        break;
+#endif
     case WebKit::InputType::None:
         _type = WKInputTypeNone;
         break;
@@ -1256,6 +1265,9 @@ static NSValue *nsSizeForTapHighlightBorderRadius(WebCore::IntSize borderRadius,
     case InputType::None:
         return NO;
     case InputType::Select:
+#if ENABLE(INPUT_TYPE_COLOR)
+    case InputType::Color:
+#endif
         return !currentUserInterfaceIdiomIsPad();
     case InputType::Date:
     case InputType::Month:
@@ -1296,9 +1308,21 @@ static NSValue *nsSizeForTapHighlightBorderRadius(WebCore::IntSize borderRadius,
     if (!hasAssistedNode(_assistedNodeInformation))
         return nil;
 
-    if (!_inputPeripheral)
-        _inputPeripheral = adoptNS(_assistedNodeInformation.elementType == InputType::Select ? [[WKFormSelectControl alloc] initWithView:self] : [[WKFormInputControl alloc] initWithView:self]);
-    else
+    if (!_inputPeripheral) {
+        switch (_assistedNodeInformation.elementType) {
+        case InputType::Select:
+            _inputPeripheral = adoptNS([[WKFormSelectControl alloc] initWithView:self]);
+            break;
+#if ENABLE(INPUT_TYPE_COLOR)
+        case InputType::Color:
+            _inputPeripheral = adoptNS([[WKFormColorControl alloc] initWithView:self]);
+            break;
+#endif
+        default:
+            _inputPeripheral = adoptNS([[WKFormInputControl alloc] initWithView:self]);
+            break;
+        }
+    } else
         [self _displayFormNodeInputView];
 
     return [_formInputSession customInputView] ?: [_inputPeripheral assistantView];
@@ -2034,6 +2058,9 @@ static void cancelPotentialTapIfNecessary(WKContentView* contentView)
     case InputType::Month:
     case InputType::Week:
     case InputType::Time:
+#if ENABLE(INPUT_TYPE_COLOR)
+    case InputType::Color:
+#endif
         return !currentUserInterfaceIdiomIsPad();
     }
 }
@@ -4035,6 +4062,9 @@ static bool isAssistableInputType(InputType type)
     case InputType::Week:
     case InputType::Time:
     case InputType::Select:
+#if ENABLE(INPUT_TYPE_COLOR)
+    case InputType::Color:
+#endif
         return true;
 
     case InputType::None:
@@ -4140,6 +4170,9 @@ static bool isAssistableInputType(InputType type)
     case InputType::Time:
     case InputType::Month:
     case InputType::Date:
+#if ENABLE(INPUT_TYPE_COLOR)
+    case InputType::Color:
+#endif
         break;
     default:
         [self _startAssistingKeyboard];
@@ -4396,6 +4429,9 @@ static bool isAssistableInputType(InputType type)
     case InputType::Select:
     case InputType::Time:
     case InputType::Date:
+#if ENABLE(INPUT_TYPE_COLOR)
+    case InputType::Color:
+#endif
         return nil;
     case InputType::Search:
         return formControlSearchButtonTitle();
diff --git a/Source/WebKit/UIProcess/ios/forms/WKFormColorControl.h b/Source/WebKit/UIProcess/ios/forms/WKFormColorControl.h
new file mode 100644 (file)
index 0000000..f6d4889
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#if ENABLE(INPUT_TYPE_COLOR) && PLATFORM(IOS)
+
+#import "WKFormPeripheral.h"
+
+@class WKContentView;
+
+@interface WKFormColorControl : NSObject<WKFormPeripheral>
+- (instancetype)initWithView:(WKContentView *)view;
+@end
+
+#endif // ENABLE(INPUT_TYPE_COLOR) && PLATFORM(IOS)
diff --git a/Source/WebKit/UIProcess/ios/forms/WKFormColorControl.mm b/Source/WebKit/UIProcess/ios/forms/WKFormColorControl.mm
new file mode 100644 (file)
index 0000000..ec4f357
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+#import "WKFormColorControl.h"
+
+#if ENABLE(INPUT_TYPE_COLOR) && PLATFORM(IOS)
+
+#import "UIKitSPI.h"
+#import "WKContentView.h"
+#import "WKFormColorPicker.h"
+#import "WKFormPopover.h"
+
+#pragma mark - WKColorPopover
+
+@interface WKColorPopover : WKFormRotatingAccessoryPopover<WKFormControl> {
+    RetainPtr<NSObject<WKFormControl>> _innerControl;
+}
+
+- (instancetype)initWithView:(WKContentView *)view;
+@end
+
+@implementation WKColorPopover
+
+- (instancetype)initWithView:(WKContentView *)view
+{
+    if (!(self = [super initWithView:view]))
+        return nil;
+
+    _innerControl = adoptNS([[WKColorPicker alloc] initWithView:view]);
+
+    RetainPtr<UIViewController> popoverViewController = adoptNS([[UIViewController alloc] init]);
+    UIView *controlView = [_innerControl controlView];
+    [popoverViewController setView:controlView];
+    [popoverViewController setPreferredContentSize:controlView.frame.size];
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+    RetainPtr<UIPopoverController> controller = adoptNS([[UIPopoverController alloc] initWithContentViewController:popoverViewController.get()]);
+#pragma clang diagnostic pop
+    [self setPopoverController:controller.get()];
+
+    return self;
+}
+
+- (UIView *)controlView
+{
+    return nil;
+}
+
+- (void)controlBeginEditing
+{
+    [self presentPopoverAnimated:NO];
+}
+
+- (void)controlEndEditing
+{
+}
+
+@end
+
+#pragma mark - WKFormColorControl
+
+@implementation WKFormColorControl {
+    RetainPtr<id<WKFormControl>> _control;
+}
+
+- (instancetype)initWithView:(WKContentView *)view
+{
+    if (!(self = [super init]))
+        return nil;
+
+    if (currentUserInterfaceIdiomIsPad())
+        _control = adoptNS([[WKColorPopover alloc] initWithView:view]);
+    else
+        _control = adoptNS([[WKColorPicker alloc] initWithView:view]);
+
+    return self;
+}
+
+- (UIView *)assistantView
+{
+    return [_control controlView];
+}
+
+- (void)beginEditing
+{
+    [_control controlBeginEditing];
+}
+
+- (void)endEditing
+{
+    [_control controlEndEditing];
+}
+
+@end
+
+#endif // ENABLE(INPUT_TYPE_COLOR) && PLATFORM(IOS)
diff --git a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.h b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.h
new file mode 100644 (file)
index 0000000..8dca9a4
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+#if ENABLE(INPUT_TYPE_COLOR) && PLATFORM(IOS)
+
+#import "WKFormPeripheral.h"
+
+OBJC_CLASS UIColor;
+OBJC_CLASS WKColorButton;
+OBJC_CLASS WKColorMatrixView;
+OBJC_CLASS WKContentView;
+
+@protocol WKColorMatrixViewDelegate
+- (void)colorMatrixView:(WKColorMatrixView *)matrixView didTapColorButton:(WKColorButton *)colorButton;
+@end
+
+@interface WKColorPicker : NSObject<WKFormControl, WKColorMatrixViewDelegate>
+- (instancetype)initWithView:(WKContentView *)view;
+@end
+
+#endif // ENABLE(INPUT_TYPE_COLOR) && PLATFORM(IOS)
diff --git a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm
new file mode 100644 (file)
index 0000000..b65b14f
--- /dev/null
@@ -0,0 +1,246 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WKFormColorPicker.h"
+
+#if ENABLE(INPUT_TYPE_COLOR) && PLATFORM(IOS)
+
+#import "AssistedNodeInformation.h"
+#import "UIKitSPI.h"
+#import "WKContentViewInteraction.h"
+#import "WKFormPopover.h"
+#import "WebPageProxy.h"
+
+#import <WebCore/Color.h>
+#import <wtf/SoftLinking.h>
+
+SOFT_LINK_PRIVATE_FRAMEWORK(PencilKit)
+SOFT_LINK_CLASS(PencilKit, PKColorMatrixView)
+
+static const CGFloat additionalKeyboardAffordance = 80;
+static const CGFloat colorSelectionIndicatorBorderWidth = 2;
+static const CGFloat pickerWidthForPopover = 280;
+static const CGFloat topColorMatrixPadding = 8;
+
+using namespace WebKit;
+
+#pragma mark - PKColorMatrixView
+
+@interface PKColorMatrixView
++ (NSArray<NSArray<UIColor *> *> *)defaultColorMatrix;
+@end
+
+#pragma mark - WKColorButton
+
+@interface WKColorButton : UIButton
+@property (nonatomic, strong) UIColor *color;
+
++ (instancetype)colorButtonWithColor:(UIColor *)color;
+@end
+
+@implementation WKColorButton
+
++ (instancetype)colorButtonWithColor:(UIColor *)color
+{
+    WKColorButton *colorButton = [WKColorButton buttonWithType:UIButtonTypeCustom];
+    colorButton.color = color;
+    colorButton.backgroundColor = color;
+    return colorButton;
+}
+
+@end
+
+#pragma mark - WKColorMatrixView
+
+@interface WKColorMatrixView : UIView {
+    RetainPtr<NSArray<NSArray<UIColor *> *>> _colorMatrix;
+    RetainPtr<NSArray<NSArray<WKColorButton *> *>> _colorButtons;
+}
+
+@property (nonatomic, weak) id<WKColorMatrixViewDelegate> delegate;
+
+- (instancetype)initWithFrame:(CGRect)frame colorMatrix:(NSArray<NSArray<UIColor *> *> *)matrix;
+@end
+
+@implementation WKColorMatrixView
+
+- (instancetype)initWithFrame:(CGRect)frame
+{
+    return [self initWithFrame:frame colorMatrix:[getPKColorMatrixViewClass() defaultColorMatrix]];
+}
+
+- (instancetype)initWithFrame:(CGRect)frame colorMatrix:(NSArray<NSArray<UIColor *> *> *)matrix
+{
+    if (!(self = [super initWithFrame:frame]))
+        return nil;
+
+    _colorMatrix = matrix;
+
+    NSMutableArray *colorButtons = [NSMutableArray array];
+    for (NSUInteger row = 0; row < [_colorMatrix count]; row++) {
+        NSMutableArray *buttons = [NSMutableArray array];
+        for (NSUInteger col = 0; col < [_colorMatrix.get()[0] count]; col++) {
+            WKColorButton *button = [WKColorButton colorButtonWithColor:_colorMatrix.get()[row][col]];
+            [button addTarget:self action:@selector(colorButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
+            [buttons addObject:button];
+            [self addSubview:button];
+        }
+        RetainPtr<NSArray> colorButtonsRow = buttons;
+        [colorButtons addObject:colorButtonsRow.get()];
+    }
+    _colorButtons = colorButtons;
+
+    return self;
+}
+
+- (void)layoutSubviews
+{
+    [super layoutSubviews];
+
+    CGSize matrixSize = self.bounds.size;
+    CGFloat numRows = [_colorMatrix count];
+    CGFloat numCols = [_colorMatrix.get()[0] count];
+    CGFloat buttonHeight = matrixSize.height / numRows;
+    CGFloat buttonWidth = matrixSize.width / numCols;
+
+    for (NSUInteger row = 0; row < numRows; row++) {
+        for (NSUInteger col = 0; col < numCols; col++) {
+            WKColorButton *button = _colorButtons.get()[row][col];
+            button.frame = CGRectMake(col * buttonWidth, row * buttonHeight, buttonWidth, buttonHeight);
+        }
+    }
+}
+
+- (void)colorButtonTapped:(WKColorButton *)colorButton
+{
+    [self.delegate colorMatrixView:self didTapColorButton:colorButton];
+}
+
+@end
+
+#pragma mark - WKFormColorPicker
+
+@implementation WKColorPicker {
+    WKContentView *_view;
+    RetainPtr<UIView> _colorPicker;
+
+    RetainPtr<UIView> _colorSelectionIndicator;
+    RetainPtr<WKColorMatrixView> _topColorMatrix;
+    RetainPtr<WKColorMatrixView> _mainColorMatrix;
+
+    RetainPtr<UIPanGestureRecognizer> _colorPanGR;
+}
+
++ (NSArray<NSArray<UIColor *> *> *)defaultTopColorMatrix
+{
+    return @[@[[UIColor redColor], [UIColor orangeColor], [UIColor yellowColor], [UIColor greenColor], [UIColor cyanColor], [UIColor blueColor], [UIColor magentaColor], [UIColor purpleColor], [UIColor brownColor], [UIColor whiteColor], [UIColor grayColor], [UIColor blackColor]]];
+}
+
+- (instancetype)initWithView:(WKContentView *)view
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _view = view;
+
+    CGSize colorPickerSize;
+    if (currentUserInterfaceIdiomIsPad())
+        colorPickerSize = CGSizeMake(pickerWidthForPopover, pickerWidthForPopover);
+    else {
+        CGSize keyboardSize = [UIKeyboard defaultSizeForInterfaceOrientation:[UIApp interfaceOrientation]];
+        colorPickerSize = CGSizeMake(keyboardSize.width, keyboardSize.height + additionalKeyboardAffordance);
+    }
+
+    _colorPicker = adoptNS([[UIView alloc] initWithSize:colorPickerSize]);
+
+    CGFloat totalRows = [[getPKColorMatrixViewClass() defaultColorMatrix] count] + 1;
+    CGFloat swatchHeight = (colorPickerSize.height - topColorMatrixPadding) / totalRows;
+
+    _mainColorMatrix = adoptNS([[WKColorMatrixView alloc] initWithFrame:CGRectMake(0, swatchHeight + topColorMatrixPadding, colorPickerSize.width, swatchHeight * (totalRows - 1))]);
+    [_mainColorMatrix setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
+    [_mainColorMatrix setDelegate:self];
+    [_colorPicker addSubview:_mainColorMatrix.get()];
+
+    _topColorMatrix = adoptNS([[WKColorMatrixView alloc] initWithFrame:CGRectMake(0, 0, colorPickerSize.width, swatchHeight) colorMatrix:[[self class] defaultTopColorMatrix]]);
+    [_topColorMatrix setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
+    [_topColorMatrix setDelegate:self];
+    [_colorPicker addSubview:_topColorMatrix.get()];
+
+    _colorSelectionIndicator = adoptNS([[UIView alloc] initWithFrame:CGRectZero]);
+    [[_colorSelectionIndicator layer] setBorderColor:[[UIColor whiteColor] CGColor]];
+    [[_colorSelectionIndicator layer] setBorderWidth:colorSelectionIndicatorBorderWidth];
+    [_colorPicker addSubview:_colorSelectionIndicator.get()];
+
+    _colorPanGR = adoptNS([[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPanColors:)]);
+    [_colorPicker addGestureRecognizer:_colorPanGR.get()];
+
+    return self;
+}
+
+- (void)setControlValueFromUIColor:(UIColor *)uiColor
+{
+    WebCore::Color color(uiColor.CGColor);
+    [_view page]->setAssistedNodeValue(color.serialized());
+}
+
+#pragma mark WKFormControl
+
+- (UIView *)controlView
+{
+    return _colorPicker.get();
+}
+
+- (void)controlBeginEditing
+{
+}
+
+- (void)controlEndEditing
+{
+}
+
+#pragma mark WKColorMatrixViewDelegate
+
+- (void)colorMatrixView:(WKColorMatrixView *)matrixView didTapColorButton:(WKColorButton *)colorButton
+{
+    [_colorSelectionIndicator setFrame:[_colorPicker convertRect:colorButton.bounds fromView:colorButton]];
+    [self setControlValueFromUIColor:colorButton.color];
+}
+
+#pragma mark UIPanGestureRecognizer
+
+- (void)didPanColors:(UIGestureRecognizer *)gestureRecognizer
+{
+    CGPoint location = [gestureRecognizer locationInView:gestureRecognizer.view];
+    UIView *view = [gestureRecognizer.view hitTest:location withEvent:nil];
+    if ([view isKindOfClass:[WKColorButton class]]) {
+        [_colorSelectionIndicator setFrame:[_colorPicker convertRect:[view bounds] fromView:view]];
+        [self setControlValueFromUIColor:[(WKColorButton *)view color]];
+    }
+}
+
+@end
+
+#endif // ENABLE(INPUT_TYPE_COLOR) && PLATFORM(IOS)
index 6d90df6..acd05ff 100644 (file)
                E4E864931B16750700C82F40 /* VersionChecks.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E8648E1B1673FB00C82F40 /* VersionChecks.h */; };
                E52CF55220A35C3A00DADA27 /* WebDataListSuggestionPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF55020A35C3A00DADA27 /* WebDataListSuggestionPicker.h */; };
                E52CF55320A35C3A00DADA27 /* WebDataListSuggestionPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E52CF55120A35C3A00DADA27 /* WebDataListSuggestionPicker.cpp */; };
+               E548EBD121015F0E00BE3C32 /* WKFormColorPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = E548EBCF21015F0E00BE3C32 /* WKFormColorPicker.h */; };
+               E548EBD221015F0E00BE3C32 /* WKFormColorPicker.mm in Sources */ = {isa = PBXBuildFile; fileRef = E548EBD021015F0E00BE3C32 /* WKFormColorPicker.mm */; };
                E54A14CF20FCFB7B007E13D8 /* WebDataListSuggestionsDropdown.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E54A14CE20FCFB7B007E13D8 /* WebDataListSuggestionsDropdown.cpp */; };
                E568B91F20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h in Headers */ = {isa = PBXBuildFile; fileRef = E568B91E20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h */; };
                E568B92220A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h in Headers */ = {isa = PBXBuildFile; fileRef = E568B92020A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h */; };
                E568B92320A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E568B92120A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.mm */; };
+               E5CB07DC20E1678F0022C183 /* WKFormColorControl.h in Headers */ = {isa = PBXBuildFile; fileRef = E5CB07DA20E1678F0022C183 /* WKFormColorControl.h */; };
+               E5CB07DD20E1678F0022C183 /* WKFormColorControl.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5CB07DB20E1678F0022C183 /* WKFormColorControl.mm */; };
                ECA680D81E690E2500731D20 /* WebProcessCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = ECA680D71E690DF800731D20 /* WebProcessCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
                ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A22F0FF1289FCD90085E74F /* WKBundlePageOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; };
                EDCA71B7128DDA8C00201B26 /* WKBundlePageOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A22F1001289FCD90085E74F /* WKBundlePageOverlay.cpp */; };
                E4E8648F1B1673FB00C82F40 /* VersionChecks.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VersionChecks.mm; sourceTree = "<group>"; };
                E52CF55020A35C3A00DADA27 /* WebDataListSuggestionPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebDataListSuggestionPicker.h; sourceTree = "<group>"; };
                E52CF55120A35C3A00DADA27 /* WebDataListSuggestionPicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebDataListSuggestionPicker.cpp; sourceTree = "<group>"; };
+               E548EBCF21015F0E00BE3C32 /* WKFormColorPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKFormColorPicker.h; path = ios/forms/WKFormColorPicker.h; sourceTree = "<group>"; };
+               E548EBD021015F0E00BE3C32 /* WKFormColorPicker.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFormColorPicker.mm; path = ios/forms/WKFormColorPicker.mm; sourceTree = "<group>"; };
                E54A14CE20FCFB7B007E13D8 /* WebDataListSuggestionsDropdown.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebDataListSuggestionsDropdown.cpp; sourceTree = "<group>"; };
                E568B91E20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebDataListSuggestionsDropdown.h; sourceTree = "<group>"; };
                E568B92020A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebDataListSuggestionsDropdownMac.h; sourceTree = "<group>"; };
                E568B92120A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = WebDataListSuggestionsDropdownMac.mm; sourceTree = "<group>"; };
+               E5CB07DA20E1678F0022C183 /* WKFormColorControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKFormColorControl.h; path = ios/forms/WKFormColorControl.h; sourceTree = "<group>"; };
+               E5CB07DB20E1678F0022C183 /* WKFormColorControl.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFormColorControl.mm; path = ios/forms/WKFormColorControl.mm; sourceTree = "<group>"; };
                ECA680D31E6904B500731D20 /* ExtraPrivateSymbolsForTAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtraPrivateSymbolsForTAPI.h; sourceTree = "<group>"; };
                ECA680D71E690DF800731D20 /* WebProcessCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebProcessCocoa.h; sourceTree = "<group>"; };
                ECBFC1DB1E6A4D66000300C7 /* ExtraPublicSymbolsForTAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtraPublicSymbolsForTAPI.h; sourceTree = "<group>"; };
                                A58B6F0718FCA733008CBA53 /* WKFileUploadPanel.mm */,
                                2E16B6CD2017B7AC008996D6 /* WKFocusedFormControlView.h */,
                                2E16B6CC2017B7AB008996D6 /* WKFocusedFormControlView.mm */,
+                               E5CB07DA20E1678F0022C183 /* WKFormColorControl.h */,
+                               E5CB07DB20E1678F0022C183 /* WKFormColorControl.mm */,
+                               E548EBCF21015F0E00BE3C32 /* WKFormColorPicker.h */,
+                               E548EBD021015F0E00BE3C32 /* WKFormColorPicker.mm */,
                                C54256AF18BEC18B00DE4179 /* WKFormInputControl.h */,
                                C54256B018BEC18B00DE4179 /* WKFormInputControl.mm */,
                                C54256B118BEC18B00DE4179 /* WKFormPeripheral.h */,
                                A58B6F0818FCA733008CBA53 /* WKFileUploadPanel.h in Headers */,
                                37F623B812A57B6200E3FDF6 /* WKFindOptions.h in Headers */,
                                2E16B6CF2017B7AD008996D6 /* WKFocusedFormControlView.h in Headers */,
+                               E5CB07DC20E1678F0022C183 /* WKFormColorControl.h in Headers */,
+                               E548EBD121015F0E00BE3C32 /* WKFormColorPicker.h in Headers */,
                                C54256B518BEC18C00DE4179 /* WKFormInputControl.h in Headers */,
                                C54256B718BEC18C00DE4179 /* WKFormPeripheral.h in Headers */,
                                C54256B818BEC18C00DE4179 /* WKFormPopover.h in Headers */,
                                BC4075FB124FF0270068F20A /* WKErrorRef.cpp in Sources */,
                                A58B6F0918FCA733008CBA53 /* WKFileUploadPanel.mm in Sources */,
                                2E16B6CE2017B7AD008996D6 /* WKFocusedFormControlView.mm in Sources */,
+                               E5CB07DD20E1678F0022C183 /* WKFormColorControl.mm in Sources */,
+                               E548EBD221015F0E00BE3C32 /* WKFormColorPicker.mm in Sources */,
                                C54256B618BEC18C00DE4179 /* WKFormInputControl.mm in Sources */,
                                C54256B918BEC18C00DE4179 /* WKFormPopover.mm in Sources */,
                                C57193BE18C14A44002D0F12 /* WKFormSelectControl.mm in Sources */,
index 8daa9cc..c794493 100644 (file)
@@ -2018,6 +2018,10 @@ static inline bool isAssistableElement(Element& node)
     if (is<HTMLInputElement>(node)) {
         HTMLInputElement& inputElement = downcast<HTMLInputElement>(node);
         // FIXME: This laundry list of types is not a good way to factor this. Need a suitable function on HTMLInputElement itself.
+#if ENABLE(INPUT_TYPE_COLOR)
+        if (inputElement.isColorControl())
+            return true;
+#endif
         return inputElement.isTextField() || inputElement.isDateField() || inputElement.isDateTimeLocalField() || inputElement.isMonthField() || inputElement.isTimeField();
     }
     return node.isContentEditable();
@@ -2444,6 +2448,10 @@ void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information)
                     information.elementType = InputType::Search;
             }
         }
+#if ENABLE(INPUT_TYPE_COLOR)
+        else if (element.isColorControl())
+            information.elementType = InputType::Color;
+#endif
 
         information.isReadOnly = element.isReadOnly();
         information.value = element.value();