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

Side by Side Diff: Source/core/html/forms/ColorInputType.cpp

Issue 488763002: Introduce HTMLDataListOptionsCollection subclass for HTMLCollection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 20 matching lines...) Expand all
31 #include "config.h" 31 #include "config.h"
32 #include "core/html/forms/ColorInputType.h" 32 #include "core/html/forms/ColorInputType.h"
33 33
34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 34 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
35 #include "bindings/core/v8/ScriptController.h" 35 #include "bindings/core/v8/ScriptController.h"
36 #include "core/CSSPropertyNames.h" 36 #include "core/CSSPropertyNames.h"
37 #include "core/InputTypeNames.h" 37 #include "core/InputTypeNames.h"
38 #include "core/events/MouseEvent.h" 38 #include "core/events/MouseEvent.h"
39 #include "core/dom/shadow/ShadowRoot.h" 39 #include "core/dom/shadow/ShadowRoot.h"
40 #include "core/html/HTMLDataListElement.h" 40 #include "core/html/HTMLDataListElement.h"
41 #include "core/html/HTMLDataListOptionsCollection.h"
41 #include "core/html/HTMLDivElement.h" 42 #include "core/html/HTMLDivElement.h"
42 #include "core/html/HTMLInputElement.h" 43 #include "core/html/HTMLInputElement.h"
43 #include "core/html/HTMLOptionElement.h" 44 #include "core/html/HTMLOptionElement.h"
44 #include "core/page/Chrome.h" 45 #include "core/page/Chrome.h"
45 #include "core/rendering/RenderView.h" 46 #include "core/rendering/RenderView.h"
46 #include "platform/ColorChooser.h" 47 #include "platform/ColorChooser.h"
47 #include "platform/RuntimeEnabledFeatures.h" 48 #include "platform/RuntimeEnabledFeatures.h"
48 #include "platform/UserGestureIndicator.h" 49 #include "platform/UserGestureIndicator.h"
49 #include "platform/graphics/Color.h" 50 #include "platform/graphics/Color.h"
50 #include "wtf/PassOwnPtr.h" 51 #include "wtf/PassOwnPtr.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 bool ColorInputType::shouldShowSuggestions() const 230 bool ColorInputType::shouldShowSuggestions() const
230 { 231 {
231 return element().fastHasAttribute(listAttr); 232 return element().fastHasAttribute(listAttr);
232 } 233 }
233 234
234 Vector<ColorSuggestion> ColorInputType::suggestions() const 235 Vector<ColorSuggestion> ColorInputType::suggestions() const
235 { 236 {
236 Vector<ColorSuggestion> suggestions; 237 Vector<ColorSuggestion> suggestions;
237 HTMLDataListElement* dataList = element().dataList(); 238 HTMLDataListElement* dataList = element().dataList();
238 if (dataList) { 239 if (dataList) {
239 RefPtrWillBeRawPtr<HTMLCollection> options = dataList->options(); 240 RefPtrWillBeRawPtr<HTMLDataListOptionsCollection> options = dataList->op tions();
240 for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(opt ions->item(i)); i++) { 241 for (unsigned i = 0; HTMLOptionElement* option = options->item(i); i++) {
241 if (!element().isValidValue(option->value())) 242 if (!element().isValidValue(option->value()))
242 continue; 243 continue;
243 Color color; 244 Color color;
244 if (!color.setFromString(option->value())) 245 if (!color.setFromString(option->value()))
245 continue; 246 continue;
246 ColorSuggestion suggestion(color, option->label().left(maxSuggestion LabelLength)); 247 ColorSuggestion suggestion(color, option->label().left(maxSuggestion LabelLength));
247 suggestions.append(suggestion); 248 suggestions.append(suggestion);
248 if (suggestions.size() >= maxSuggestions) 249 if (suggestions.size() >= maxSuggestions)
249 break; 250 break;
250 } 251 }
251 } 252 }
252 return suggestions; 253 return suggestions;
253 } 254 }
254 255
255 } // namespace blink 256 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698