Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(986)

Unified Diff: Source/core/html/forms/ColorInputType.cpp

Issue 23236002: Prepare for color input datalist support on Android (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/forms/ColorInputType.h ('k') | Source/core/rendering/RenderThemeChromiumAndroid.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/forms/ColorInputType.cpp
diff --git a/Source/core/html/forms/ColorInputType.cpp b/Source/core/html/forms/ColorInputType.cpp
index 548556814b670c031366277aca86c75dcdb39d9b..a7aedbc424d0635463303470ad25655672dcecae 100644
--- a/Source/core/html/forms/ColorInputType.cpp
+++ b/Source/core/html/forms/ColorInputType.cpp
@@ -53,6 +53,11 @@ namespace WebCore {
using namespace HTMLNames;
+// Upper limit of number of datalist suggestions shown.
+static const unsigned maxSuggestions = 1000;
+// Upper limit for the length of the labels for datalist suggestions.
+static const unsigned maxSuggestionLabelLength = 1000;
+
static bool isValidColorString(const String& value)
{
if (value.isEmpty())
@@ -225,9 +230,9 @@ bool ColorInputType::shouldShowSuggestions() const
return false;
}
-Vector<Color> ColorInputType::suggestions() const
+Vector<ColorSuggestion> ColorInputType::suggestions() const
{
- Vector<Color> suggestions;
+ Vector<ColorSuggestion> suggestions;
if (RuntimeEnabledFeatures::dataListElementEnabled()) {
HTMLDataListElement* dataList = element().dataList();
if (dataList) {
@@ -238,7 +243,10 @@ Vector<Color> ColorInputType::suggestions() const
Color color(option->value());
if (!color.isValid())
continue;
- suggestions.append(color);
+ ColorSuggestion suggestion(color, option->label().left(maxSuggestionLabelLength));
+ suggestions.append(suggestion);
+ if (suggestions.size() >= maxSuggestions)
+ break;
}
}
}
« no previous file with comments | « Source/core/html/forms/ColorInputType.h ('k') | Source/core/rendering/RenderThemeChromiumAndroid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698