Title: [123601] trunk/Source/WebCore
- Revision
- 123601
- Author
- [email protected]
- Date
- 2012-07-25 04:03:38 -0700 (Wed, 25 Jul 2012)
Log Message
Add methods to ColorChooserClient so the color chooser can show suggestions
https://bugs.webkit.org/show_bug.cgi?id=92114
Reviewed by Kent Tamura.
Added methods to ColorChooserClient so the color chooser can ask the
client for suggestions and current color.
No new tests. The methods are not used yet.
* html/ColorInputType.cpp:
(WebCore::ColorInputType::currentColor): Returns what color the color
chooser should display.
(WebCore):
(WebCore::ColorInputType::shouldShowSuggestions): Returns if the UI for
suggestions should be shown.
(WebCore::ColorInputType::suggestions): Returns a list of colors to be
suggested to the user.
* html/ColorInputType.h:
(ColorInputType):
* html/HTMLInputElement.h:
(HTMLInputElement): Made dataList() public.
* platform/ColorChooserClient.h:
(ColorChooserClient):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (123600 => 123601)
--- trunk/Source/WebCore/ChangeLog 2012-07-25 10:35:26 UTC (rev 123600)
+++ trunk/Source/WebCore/ChangeLog 2012-07-25 11:03:38 UTC (rev 123601)
@@ -1,3 +1,30 @@
+2012-07-25 Keishi Hattori <[email protected]>
+
+ Add methods to ColorChooserClient so the color chooser can show suggestions
+ https://bugs.webkit.org/show_bug.cgi?id=92114
+
+ Reviewed by Kent Tamura.
+
+ Added methods to ColorChooserClient so the color chooser can ask the
+ client for suggestions and current color.
+
+ No new tests. The methods are not used yet.
+
+ * html/ColorInputType.cpp:
+ (WebCore::ColorInputType::currentColor): Returns what color the color
+ chooser should display.
+ (WebCore):
+ (WebCore::ColorInputType::shouldShowSuggestions): Returns if the UI for
+ suggestions should be shown.
+ (WebCore::ColorInputType::suggestions): Returns a list of colors to be
+ suggested to the user.
+ * html/ColorInputType.h:
+ (ColorInputType):
+ * html/HTMLInputElement.h:
+ (HTMLInputElement): Made dataList() public.
+ * platform/ColorChooserClient.h:
+ (ColorChooserClient):
+
2012-07-25 Kentaro Hara <[email protected]>
Replace int with long in test IDL files
Modified: trunk/Source/WebCore/html/ColorInputType.cpp (123600 => 123601)
--- trunk/Source/WebCore/html/ColorInputType.cpp 2012-07-25 10:35:26 UTC (rev 123600)
+++ trunk/Source/WebCore/html/ColorInputType.cpp 2012-07-25 11:03:38 UTC (rev 123601)
@@ -35,8 +35,10 @@
#include "Chrome.h"
#include "Color.h"
#include "ElementShadow.h"
+#include "HTMLDataListElement.h"
#include "HTMLDivElement.h"
#include "HTMLInputElement.h"
+#include "HTMLOptionElement.h"
#include "MouseEvent.h"
#include "RenderObject.h"
#include "RenderView.h"
@@ -50,6 +52,8 @@
namespace WebCore {
+using namespace HTMLNames;
+
static bool isValidColorString(const String& value)
{
if (value.isEmpty())
@@ -204,6 +208,38 @@
return pixelSnappedIntRect(renderer->view()->frameView()->contentsToWindow(renderer->absoluteBoundingBoxRect()));
}
+Color ColorInputType::currentColor()
+{
+ return valueAsColor();
+}
+
+bool ColorInputType::shouldShowSuggestions() const
+{
+#if ENABLE(DATALIST_ELEMENT)
+ return element()->fastHasAttribute(listAttr);
+#endif
+}
+
+Vector<Color> ColorInputType::suggestions() const
+{
+ Vector<Color> suggestions;
+#if ENABLE(DATALIST_ELEMENT)
+ HTMLDataListElement* dataList = element()->dataList();
+ if (dataList) {
+ RefPtr<HTMLCollection> options = dataList->options();
+ for (unsigned i = 0; HTMLOptionElement* option = static_cast<HTMLOptionElement*>(options->item(i)); i++) {
+ if (!element()->isValidValue(option->value()))
+ continue;
+ Color color(option->value());
+ if (!color.isValid())
+ continue;
+ suggestions.append(color);
+ }
+ }
+#endif
+ return suggestions;
+}
+
} // namespace WebCore
#endif // ENABLE(INPUT_TYPE_COLOR)
Modified: trunk/Source/WebCore/html/ColorInputType.h (123600 => 123601)
--- trunk/Source/WebCore/html/ColorInputType.h 2012-07-25 10:35:26 UTC (rev 123600)
+++ trunk/Source/WebCore/html/ColorInputType.h 2012-07-25 11:03:38 UTC (rev 123601)
@@ -47,6 +47,9 @@
virtual void didChooseColor(const Color&) OVERRIDE;
virtual void didEndChooser() OVERRIDE;
virtual IntRect elementRectRelativeToWindow() const OVERRIDE;
+ virtual Color currentColor() OVERRIDE;
+ virtual bool shouldShowSuggestions() const OVERRIDE;
+ virtual Vector<Color> suggestions() const OVERRIDE;
private:
ColorInputType(HTMLInputElement* element) : BaseClickableWithKeyInputType(element) { }
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (123600 => 123601)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2012-07-25 10:35:26 UTC (rev 123600)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2012-07-25 11:03:38 UTC (rev 123601)
@@ -236,6 +236,7 @@
#if ENABLE(DATALIST_ELEMENT)
HTMLElement* list() const;
+ HTMLDataListElement* dataList() const;
void listAttributeTargetChanged();
#endif
@@ -363,7 +364,6 @@
virtual void subtreeHasChanged();
#if ENABLE(DATALIST_ELEMENT)
- HTMLDataListElement* dataList() const;
void resetListAttributeTargetObserver();
#endif
void parseMaxLengthAttribute(const Attribute&);
Modified: trunk/Source/WebCore/platform/ColorChooserClient.h (123600 => 123601)
--- trunk/Source/WebCore/platform/ColorChooserClient.h 2012-07-25 10:35:26 UTC (rev 123600)
+++ trunk/Source/WebCore/platform/ColorChooserClient.h 2012-07-25 11:03:38 UTC (rev 123601)
@@ -7,6 +7,7 @@
#include "IntRect.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
namespace WebCore {
@@ -19,6 +20,9 @@
virtual void didChooseColor(const Color&) = 0;
virtual void didEndChooser() = 0;
virtual IntRect elementRectRelativeToWindow() const = 0;
+ virtual Color currentColor() = 0;
+ virtual bool shouldShowSuggestions() const = 0;
+ virtual Vector<Color> suggestions() const = 0;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes