[EFL][DRT] Implement setValueForUser and setAutofilled.
[WebKit-https.git] / Source / WebKit / efl / WebCoreSupport / DumpRenderTreeSupportEfl.cpp
index 2a4a9fcc9216db172d3ee4caa625757b4c699874..fd3d6b50b8788f30cd7ba410c82d89cfa4a747bb 100644 (file)
 #include <FindOptions.h>
 #include <FloatSize.h>
 #include <FrameView.h>
+#include <HTMLInputElement.h>
 #include <IntRect.h>
+#include <JSElement.h>
 #include <PrintContext.h>
 #include <RenderTreeAsText.h>
 #include <Settings.h>
 #include <bindings/js/GCController.h>
 #include <history/HistoryItem.h>
 #include <workers/WorkerThread.h>
+#include <wtf/OwnArrayPtr.h>
 #include <wtf/text/AtomicString.h>
 
 unsigned DumpRenderTreeSupportEfl::activeAnimationsCount(const Evas_Object* ewkFrame)
@@ -279,6 +282,35 @@ void DumpRenderTreeSupportEfl::suspendAnimations(Evas_Object* ewkFrame)
         animationController->suspendAnimations();
 }
 
+void DumpRenderTreeSupportEfl::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
+{
+    JSC::ExecState* exec = toJS(context);
+    WebCore::Element* element = WebCore::toElement(toJS(exec, nodeObject));
+    if (!element)
+        return;
+    WebCore::HTMLInputElement* inputElement = element->toInputElement();
+    if (!inputElement)
+        return;
+
+    size_t bufferSize = JSStringGetMaximumUTF8CStringSize(value);
+    OwnArrayPtr<char> valueBuffer = adoptArrayPtr(new char[bufferSize]);
+    JSStringGetUTF8CString(value, valueBuffer.get(), bufferSize);
+    inputElement->setValueForUser(String::fromUTF8(valueBuffer.get()));
+}
+
+void DumpRenderTreeSupportEfl::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool autofilled)
+{
+    JSC::ExecState* exec = toJS(context);
+    WebCore::Element* element = WebCore::toElement(toJS(exec, nodeObject));
+    if (!element)
+        return;
+    WebCore::HTMLInputElement* inputElement = element->toInputElement();
+    if (!inputElement)
+        return;
+
+    inputElement->setAutofilled(autofilled);
+}
+
 bool DumpRenderTreeSupportEfl::findString(const Evas_Object* ewkView, const char* text, WebCore::FindOptions options)
 {
     WebCore::Page* page = EWKPrivate::corePage(ewkView);