WebKit Bugzilla
Attachment 347406 Details for
Bug 188669
: [Datalist][iOS] Display suggestions for input[type=color]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188669-20180817161004.patch (text/plain), 14.80 KB, created by
Aditya Keerthi
on 2018-08-17 16:10:05 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Aditya Keerthi
Created:
2018-08-17 16:10:05 PDT
Size:
14.80 KB
patch
obsolete
>Subversion Revision: 234997 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 40a21a5d39fcd9359254c1122ccdad8c0c3021c4..f4e894874aa57a3e829661f7e8ebc6ce41c611f1 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,24 @@ >+2018-08-17 Aditya Keerthi <akeerthi@apple.com> >+ >+ [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-16 Ryosuke Niwa <rniwa@webkit.org> > > Replace canBubble and cancelable booleans in Event by enum classes >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index ac352a45bb061fd7e09f9196290afaaf9c4d1af2..5fbdb6b8b7963201b92ddd2a22987231b92f94ea 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,31 @@ >+2018-08-17 Aditya Keerthi <akeerthi@apple.com> >+ >+ [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-16 Ryosuke Niwa <rniwa@webkit.org> > > Replace canBubble and cancelable booleans in Event by enum classes >diff --git a/Source/WebCore/html/ColorInputType.cpp b/Source/WebCore/html/ColorInputType.cpp >index 14157821690e3852c970b05bd92382bb1d1195b0..3f8e20c99298b4a491d7a48805fca71b4aa79232 100644 >--- a/Source/WebCore/html/ColorInputType.cpp >+++ b/Source/WebCore/html/ColorInputType.cpp >@@ -281,7 +281,7 @@ bool ColorInputType::shouldShowSuggestions() const > #endif > } > >-Vector<Color> ColorInputType::suggestions() const >+Vector<Color> ColorInputType::suggestedColors() const > { > Vector<Color> suggestions; > #if ENABLE(DATALIST_ELEMENT) >diff --git a/Source/WebCore/html/ColorInputType.h b/Source/WebCore/html/ColorInputType.h >index cdae3cb94041930bf065d20f9885d294594d53a5..d89236cfce555872b40022a2fabba8a9c0654ae5 100644 >--- a/Source/WebCore/html/ColorInputType.h >+++ b/Source/WebCore/html/ColorInputType.h >@@ -50,7 +50,7 @@ private: > 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; >diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp >index 91bae95d422989ca3a182833e194daf7dc6f5bac..bd102a57b8fc8290ba88c500fd7775e53771279b 100644 >--- a/Source/WebCore/html/HTMLInputElement.cpp >+++ b/Source/WebCore/html/HTMLInputElement.cpp >@@ -1601,6 +1601,11 @@ void HTMLInputElement::selectColor(StringView color) > m_inputType->selectColor(color); > } > >+Vector<Color> HTMLInputElement::suggestedColors() const >+{ >+ return m_inputType->suggestedColors(); >+} >+ > #if ENABLE(DATALIST_ELEMENT) > > RefPtr<HTMLElement> HTMLInputElement::list() const >diff --git a/Source/WebCore/html/HTMLInputElement.h b/Source/WebCore/html/HTMLInputElement.h >index fedb742425598b6523da1dfc5a02fa7429d574cf..e32b3893eb4ac796c66e08c1bda7f3e4729ec8d3 100644 >--- a/Source/WebCore/html/HTMLInputElement.h >+++ b/Source/WebCore/html/HTMLInputElement.h >@@ -296,6 +296,7 @@ public: > > 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; > >diff --git a/Source/WebCore/html/InputType.cpp b/Source/WebCore/html/InputType.cpp >index 52317fa9ca74af850cf4bfe039bdd5e315664f15..dc1be9a340aa8f053235b5aa07d56217aa1284b5 100644 >--- a/Source/WebCore/html/InputType.cpp >+++ b/Source/WebCore/html/InputType.cpp >@@ -1131,6 +1131,11 @@ void InputType::selectColor(StringView) > { > } > >+Vector<Color> InputType::suggestedColors() const >+{ >+ return { }; >+} >+ > RefPtr<TextControlInnerTextElement> InputType::innerTextElement() const > { > return nullptr; >diff --git a/Source/WebCore/html/InputType.h b/Source/WebCore/html/InputType.h >index 828b4c05fa0269d482c6a62a67d4dbd32d62fb45..c7a9addd287bd80f488173105138386d39fe27c2 100644 >--- a/Source/WebCore/html/InputType.h >+++ b/Source/WebCore/html/InputType.h >@@ -270,6 +270,7 @@ public: > 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 >diff --git a/Source/WebCore/platform/ColorChooserClient.h b/Source/WebCore/platform/ColorChooserClient.h >index 48d4b27b462b91cd58b6df757ed4f94401394209..9b3b898163e27b0a6962495d227b9c9b5691db2c 100644 >--- a/Source/WebCore/platform/ColorChooserClient.h >+++ b/Source/WebCore/platform/ColorChooserClient.h >@@ -48,7 +48,7 @@ public: > 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 >diff --git a/Source/WebKit/Shared/AssistedNodeInformation.cpp b/Source/WebKit/Shared/AssistedNodeInformation.cpp >index 1cd7ac8fc9f6676cc620a856620775cb0de057f8..79adb680fe47121d129f9241d7e66afb2abed0d5 100644 >--- a/Source/WebKit/Shared/AssistedNodeInformation.cpp >+++ b/Source/WebKit/Shared/AssistedNodeInformation.cpp >@@ -96,6 +96,9 @@ void AssistedNodeInformation::encode(IPC::Encoder& encoder) const > 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 @@ bool AssistedNodeInformation::decode(IPC::Decoder& decoder, AssistedNodeInformat > 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 >diff --git a/Source/WebKit/Shared/AssistedNodeInformation.h b/Source/WebKit/Shared/AssistedNodeInformation.h >index 6b0ce17a1afb1ec2b83f208dd1710109e89b86b3..1e7aac77b008194d19418404116cea24a1ce31fd 100644 >--- a/Source/WebKit/Shared/AssistedNodeInformation.h >+++ b/Source/WebKit/Shared/AssistedNodeInformation.h >@@ -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 @@ struct AssistedNodeInformation { > String placeholder; > String label; > String ariaLabel; >+#if ENABLE(INPUT_TYPE_COLOR) && ENABLE(DATALIST_ELEMENT) >+ Vector<WebCore::Color> suggestedColors; >+#endif > > uint64_t assistedNodeIdentifier { 0 }; > >diff --git a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >index 53fc009b5d4b7fa6e88fc13b656022567f076ed0..8d2b2ecdd45eb509135e37f5b44dba2fcea3af55 100644 >--- a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >+++ b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >@@ -45,6 +45,9 @@ static const CGFloat colorSelectionIndicatorBorderWidth = 4; > 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 @@ using namespace WebKit; > > + (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 @@ using namespace WebKit; > [_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()]; >@@ -229,13 +246,13 @@ using namespace WebKit; > > // On iPad, round one corner of the indicator if it's at the corner 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)]; >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp >index bd7f86470cea82deb74bc0a7393c173ad5a0c9b7..22371f2b3484cd84a8a844eb29e593309b824f4b 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebColorChooser.cpp >@@ -43,7 +43,7 @@ WebColorChooser::WebColorChooser(WebPage* page, ColorChooserClient* client, cons > , 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 @@ void WebColorChooser::reattachColorChooser(const Color& color) > 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) >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index a9cadce820488f8c3645d1c26dbaa653d98c80be..26186fb9870e17e45056bca0392baaf485bfff61 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -2451,8 +2451,12 @@ void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information) > } > } > #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();
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 188669
:
347281
|
347393
|
347399
|
347406
|
347411