Diff
Modified: trunk/Source/WebCore/ChangeLog (235003 => 235004)
--- trunk/Source/WebCore/ChangeLog 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebCore/ChangeLog 2018-08-18 00:43:23 UTC (rev 235004)
@@ -1,3 +1,24 @@
+2018-08-17 Aditya Keerthi <[email protected]>
+
+ [Datalist][iOS] Display suggestions for input[type=color]
+ https://bugs.webkit.org/show_bug.cgi?id=188669
+
+ Reviewed by Tim Horton.
+
+ Expose suggestedColors() in HTMLInputElement in order to allow the UIProcess to
+ access the list of suggested colors from a <datalist> element.
+
+ * html/ColorInputType.cpp:
+ (WebCore::ColorInputType::suggestedColors const):
+ * html/ColorInputType.h:
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::suggestedColors const):
+ * html/HTMLInputElement.h:
+ * html/InputType.cpp:
+ (WebCore::InputType::suggestedColors const):
+ * html/InputType.h:
+ * platform/ColorChooserClient.h:
+
2018-08-17 Alex Christensen <[email protected]>
Clean up CSSSelectorList after r234825
Modified: trunk/Source/WebCore/html/ColorInputType.cpp (235003 => 235004)
--- trunk/Source/WebCore/html/ColorInputType.cpp 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebCore/html/ColorInputType.cpp 2018-08-18 00:43:23 UTC (rev 235004)
@@ -281,7 +281,7 @@
#endif
}
-Vector<Color> ColorInputType::suggestions() const
+Vector<Color> ColorInputType::suggestedColors() const
{
Vector<Color> suggestions;
#if ENABLE(DATALIST_ELEMENT)
Modified: trunk/Source/WebCore/html/ColorInputType.h (235003 => 235004)
--- trunk/Source/WebCore/html/ColorInputType.h 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebCore/html/ColorInputType.h 2018-08-18 00:43:23 UTC (rev 235004)
@@ -50,7 +50,7 @@
IntRect elementRectRelativeToRootView() const final;
Color currentColor() final;
bool shouldShowSuggestions() const final;
- Vector<Color> suggestions() const final;
+ Vector<Color> suggestedColors() const final;
bool isMouseFocusable() const final;
bool isKeyboardFocusable(KeyboardEvent*) const final;
bool isColorControl() const final;
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (235003 => 235004)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2018-08-18 00:43:23 UTC (rev 235004)
@@ -1601,6 +1601,11 @@
m_inputType->selectColor(color);
}
+Vector<Color> HTMLInputElement::suggestedColors() const
+{
+ return m_inputType->suggestedColors();
+}
+
#if ENABLE(DATALIST_ELEMENT)
RefPtr<HTMLElement> HTMLInputElement::list() const
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (235003 => 235004)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2018-08-18 00:43:23 UTC (rev 235004)
@@ -296,6 +296,7 @@
Color valueAsColor() const; // Returns transparent color if not type=color.
WEBCORE_EXPORT void selectColor(StringView); // Does nothing if not type=color. Simulates user selection of color; intended for testing.
+ WEBCORE_EXPORT Vector<Color> suggestedColors() const;
String defaultToolTip() const;
Modified: trunk/Source/WebCore/html/InputType.cpp (235003 => 235004)
--- trunk/Source/WebCore/html/InputType.cpp 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebCore/html/InputType.cpp 2018-08-18 00:43:23 UTC (rev 235004)
@@ -1131,6 +1131,11 @@
{
}
+Vector<Color> InputType::suggestedColors() const
+{
+ return { };
+}
+
RefPtr<TextControlInnerTextElement> InputType::innerTextElement() const
{
return nullptr;
Modified: trunk/Source/WebCore/html/InputType.h (235003 => 235004)
--- trunk/Source/WebCore/html/InputType.h 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebCore/html/InputType.h 2018-08-18 00:43:23 UTC (rev 235004)
@@ -270,6 +270,7 @@
virtual bool supportsSelectionAPI() const;
virtual Color valueAsColor() const;
virtual void selectColor(StringView);
+ virtual Vector<Color> suggestedColors() const;
// Parses the specified string for the type, and return
// the Decimal value for the parsing result if the parsing
Modified: trunk/Source/WebCore/platform/ColorChooserClient.h (235003 => 235004)
--- trunk/Source/WebCore/platform/ColorChooserClient.h 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebCore/platform/ColorChooserClient.h 2018-08-18 00:43:23 UTC (rev 235004)
@@ -48,7 +48,7 @@
virtual IntRect elementRectRelativeToRootView() const = 0;
virtual Color currentColor() = 0;
virtual bool shouldShowSuggestions() const = 0;
- virtual Vector<Color> suggestions() const = 0;
+ virtual Vector<Color> suggestedColors() const = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (235003 => 235004)
--- trunk/Source/WebKit/ChangeLog 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebKit/ChangeLog 2018-08-18 00:43:23 UTC (rev 235004)
@@ -1,3 +1,31 @@
+2018-08-17 Aditya Keerthi <[email protected]>
+
+ [Datalist][iOS] Display suggestions for input[type=color]
+ https://bugs.webkit.org/show_bug.cgi?id=188669
+
+ Reviewed by Tim Horton.
+
+ An input[type=color] element that has an associated datalist element should
+ display the color values provided on iOS. Similar to macOS, we now support 1-12
+ suggested colors, that will be displayed at the top of the color picker.
+
+ Also ensured that we get rounded corners on both sides of a color swatch if it is
+ the only one in its row.
+
+ * Shared/AssistedNodeInformation.cpp: Added suggestedColors field.
+ (WebKit::AssistedNodeInformation::encode const):
+ (WebKit::AssistedNodeInformation::decode):
+ * Shared/AssistedNodeInformation.h:
+ * UIProcess/ios/forms/WKFormColorPicker.mm:
+ (+[WKColorPicker defaultTopColorMatrix]):
+ (-[WKColorPicker initWithView:]): Use the list of suggestedColors if it exists.
+ (-[WKColorPicker drawSelectionIndicatorForColorButton:]):
+ * WebProcess/WebCoreSupport/WebColorChooser.cpp:
+ (WebKit::WebColorChooser::WebColorChooser):
+ (WebKit::WebColorChooser::reattachColorChooser):
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::getAssistedNodeInformation):
+
2018-08-17 Ryan Haddad <[email protected]>
Unreviewed, rolling out r234991.
Modified: trunk/Source/WebKit/Shared/AssistedNodeInformation.cpp (235003 => 235004)
--- trunk/Source/WebKit/Shared/AssistedNodeInformation.cpp 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebKit/Shared/AssistedNodeInformation.cpp 2018-08-18 00:43:23 UTC (rev 235004)
@@ -96,6 +96,9 @@
encoder << label;
encoder << ariaLabel;
encoder << assistedNodeIdentifier;
+#if ENABLE(INPUT_TYPE_COLOR) && ENABLE(DATALIST_ELEMENT)
+ encoder << suggestedColors;
+#endif
}
bool AssistedNodeInformation::decode(IPC::Decoder& decoder, AssistedNodeInformation& result)
@@ -199,6 +202,11 @@
if (!decoder.decode(result.assistedNodeIdentifier))
return false;
+#if ENABLE(INPUT_TYPE_COLOR) && ENABLE(DATALIST_ELEMENT)
+ if (!decoder.decode(result.suggestedColors))
+ return false;
+#endif
+
return true;
}
#endif
Modified: trunk/Source/WebKit/Shared/AssistedNodeInformation.h (235003 => 235004)
--- trunk/Source/WebKit/Shared/AssistedNodeInformation.h 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebKit/Shared/AssistedNodeInformation.h 2018-08-18 00:43:23 UTC (rev 235004)
@@ -28,6 +28,7 @@
#include "ArgumentCoders.h"
#include <WebCore/AutocapitalizeTypes.h>
#include <WebCore/Autofill.h>
+#include <WebCore/Color.h>
#include <WebCore/IntRect.h>
#include <WebCore/URL.h>
#include <wtf/text/WTFString.h>
@@ -122,6 +123,9 @@
String placeholder;
String label;
String ariaLabel;
+#if ENABLE(INPUT_TYPE_COLOR) && ENABLE(DATALIST_ELEMENT)
+ Vector<WebCore::Color> suggestedColors;
+#endif
uint64_t assistedNodeIdentifier { 0 };
Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm (235003 => 235004)
--- trunk/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm 2018-08-18 00:43:23 UTC (rev 235004)
@@ -45,6 +45,9 @@
static const CGFloat colorSelectionIndicatorCornerRadius = 9;
static const CGFloat pickerWidthForPopover = 280;
static const CGFloat topColorMatrixPadding = 5;
+#if ENABLE(DATALIST_ELEMENT)
+static const size_t maxColorSuggestions = 12;
+#endif
using namespace WebKit;
@@ -162,7 +165,7 @@
+ (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]]];
+ 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
@@ -190,7 +193,21 @@
[_mainColorMatrix setDelegate:self];
[_colorPicker addSubview:_mainColorMatrix.get()];
- _topColorMatrix = adoptNS([[WKColorMatrixView alloc] initWithFrame:CGRectMake(0, 0, colorPickerSize.width, swatchHeight) colorMatrix:[[self class] defaultTopColorMatrix]]);
+ NSArray<NSArray<UIColor *> *> *topColorMatrix = [[self class] defaultTopColorMatrix];
+
+#if ENABLE(DATALIST_ELEMENT)
+ size_t numColorSuggestions = view.assistedNodeInformation.suggestedColors.size();
+ if (numColorSuggestions) {
+ NSMutableArray<UIColor *> *colors = [NSMutableArray array];
+ for (size_t i = 0; i < std::min(numColorSuggestions, maxColorSuggestions); i++) {
+ WebCore::Color color = view.assistedNodeInformation.suggestedColors[i];
+ [colors addObject:[UIColor colorWithCGColor:cachedCGColor(color)]];
+ }
+ topColorMatrix = @[ colors ];
+ }
+#endif
+
+ _topColorMatrix = adoptNS([[WKColorMatrixView alloc] initWithFrame:CGRectMake(0, 0, colorPickerSize.width, swatchHeight) colorMatrix:topColorMatrix]);
[_topColorMatrix setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[_topColorMatrix setDelegate:self];
[_colorPicker addSubview:_topColorMatrix.get()];
@@ -227,15 +244,15 @@
bool maxXEqual = std::abs(CGRectGetMaxX(frame) - CGRectGetMaxX(colorPickerBounds)) < FLT_EPSILON;
bool maxYEqual = std::abs(CGRectGetMaxY(frame) - CGRectGetMaxY(colorPickerBounds)) < FLT_EPSILON;
- // On iPad, round one corner of the indicator if it's at the corner of the picker, to match the popover.
+ // On iPad, round the corners of the indicator that border the corners of the picker, to match the popover.
if (minXEqual && minYEqual)
- roundCorner = UIRectCornerTopLeft;
- else if (maxXEqual && minYEqual)
- roundCorner = UIRectCornerTopRight;
- else if (minXEqual && maxYEqual)
- roundCorner = UIRectCornerBottomLeft;
- else if (maxXEqual && maxYEqual)
- roundCorner = UIRectCornerBottomRight;
+ roundCorner |= UIRectCornerTopLeft;
+ if (maxXEqual && minYEqual)
+ roundCorner |= UIRectCornerTopRight;
+ if (minXEqual && maxYEqual)
+ roundCorner |= UIRectCornerBottomLeft;
+ if (maxXEqual && maxYEqual)
+ roundCorner |= UIRectCornerBottomRight;
}
UIBezierPath *cornerMaskPath = [UIBezierPath bezierPathWithRoundedRect:colorButton.bounds byRoundingCorners:roundCorner cornerRadii:CGSizeMake(colorSelectionIndicatorCornerRadius, colorSelectionIndicatorCornerRadius)];
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp (235003 => 235004)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp 2018-08-18 00:43:23 UTC (rev 235004)
@@ -43,7 +43,7 @@
, m_page(page)
{
m_page->setActiveColorChooser(this);
- WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowColorPicker(initialColor, client->elementRectRelativeToRootView(), client->suggestions()), m_page->pageID());
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowColorPicker(initialColor, client->elementRectRelativeToRootView(), client->suggestedColors()), 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_colorChooserClient->suggestions()), m_page->pageID());
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowColorPicker(color, m_colorChooserClient->elementRectRelativeToRootView(), m_colorChooserClient->suggestedColors()), m_page->pageID());
}
void WebColorChooser::setSelectedColor(const Color& color)
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (235003 => 235004)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2018-08-18 00:25:01 UTC (rev 235003)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2018-08-18 00:43:23 UTC (rev 235004)
@@ -2451,9 +2451,13 @@
}
}
#if ENABLE(INPUT_TYPE_COLOR)
- else if (element.isColorControl())
+ else if (element.isColorControl()) {
information.elementType = InputType::Color;
+#if ENABLE(DATALIST_ELEMENT)
+ information.suggestedColors = element.suggestedColors();
#endif
+ }
+#endif
information.isReadOnly = element.isReadOnly();
information.value = element.value();