tizen beta release
[framework/web/webkit-efl.git] / Source / WebKit / qt / WebCoreSupport / DumpRenderTreeSupportQt.cpp
index 4a5cab4..38ad59e 100755 (executable)
@@ -45,6 +45,8 @@
 #include "FrameView.h"
 #if USE(JSC)
 #include "GCController.h"
+#include "JSNode.h"
+#include "qt_runtime.h"
 #elif USE(V8)
 #include "V8GCController.h"
 #include "V8Proxy.h"
@@ -56,6 +58,7 @@
 #include "GeolocationPosition.h"
 #include "HistoryItem.h"
 #include "HTMLInputElement.h"
+#include "InitWebCoreQt.h"
 #include "InspectorController.h"
 #include "NodeList.h"
 #include "NotificationPresenterClientQt.h"
 #include "PrintContext.h"
 #include "RenderListItem.h"
 #include "RenderTreeAsText.h"
+#include "SchemeRegistry.h"
 #include "ScriptController.h"
 #include "ScriptSourceCode.h"
 #include "ScriptValue.h"
 #include "SecurityOrigin.h"
+#include "SecurityPolicy.h"
 #include "Settings.h"
 #if ENABLE(SVG)
 #include "SVGDocumentExtensions.h"
@@ -147,6 +152,41 @@ QDRTNode& QDRTNode::operator=(const QDRTNode& other)
     return *this;
 }
 
+#if USE(JSC)
+QDRTNode QtDRTNodeRuntime::create(WebCore::Node* node)
+{
+    return QDRTNode(node);
+}
+
+WebCore::Node* QtDRTNodeRuntime::get(const QDRTNode& node)
+{
+    return node.m_node;
+}
+
+static QVariant convertJSValueToNodeVariant(JSC::JSObject* object, int *distance, HashSet<JSC::JSObject*>*)
+{
+    if (!object || !object->inherits(&JSNode::s_info))
+        return QVariant();
+    return QVariant::fromValue<QDRTNode>(QtDRTNodeRuntime::create((static_cast<JSNode*>(object))->impl()));
+}
+
+static JSC::JSValue convertNodeVariantToJSValue(JSC::ExecState* exec, WebCore::JSDOMGlobalObject* globalObject, const QVariant& variant)
+{
+    return toJS(exec, globalObject, QtDRTNodeRuntime::get(variant.value<QDRTNode>()));
+}
+#endif
+
+void QtDRTNodeRuntime::initialize()
+{
+    static bool initialized = false;
+    if (initialized)
+        return;
+    initialized = true;
+#if USE(JSC)
+    int id = qRegisterMetaType<QDRTNode>();
+    JSC::Bindings::registerCustomType(id, convertJSValueToNodeVariant, convertNodeVariantToJSValue);
+#endif
+}
 
 DumpRenderTreeSupportQt::DumpRenderTreeSupportQt()
 {
@@ -156,6 +196,12 @@ DumpRenderTreeSupportQt::~DumpRenderTreeSupportQt()
 {
 }
 
+void DumpRenderTreeSupportQt::initialize()
+{
+    WebCore::initializeWebCoreQt();
+    QtDRTNodeRuntime::initialize();
+}
+
 void DumpRenderTreeSupportQt::overwritePluginDirectories()
 {
     PluginDatabase* db = PluginDatabase::installedPlugins(/* populate */ false);
@@ -463,22 +509,22 @@ void DumpRenderTreeSupportQt::resumeActiveDOMObjects(QWebFrame* frame)
 
 void DumpRenderTreeSupportQt::whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains)
 {
-    SecurityOrigin::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains);
+    SecurityPolicy::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains);
 }
 
 void DumpRenderTreeSupportQt::removeWhiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains)
 {
-    SecurityOrigin::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains);
+    SecurityPolicy::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains);
 }
 
 void DumpRenderTreeSupportQt::resetOriginAccessWhiteLists()
 {
-    SecurityOrigin::resetOriginAccessWhitelists();
+    SecurityPolicy::resetOriginAccessWhitelists();
 }
 
 void DumpRenderTreeSupportQt::setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme)
 {
-    SecurityOrigin::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme);
+    SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme);
 }
 
 void DumpRenderTreeSupportQt::setCaretBrowsingEnabled(QWebPage* page, bool value)
@@ -765,6 +811,8 @@ QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, int deviceDPI, c
         /* device-height */ deviceSize.height(),
         /* device-dpi    */ deviceDPI,
         availableSize);
+    WebCore::restrictMinimumScaleFactorToViewportSize(conf, availableSize);
+    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(conf);
 
     QString res;
     res = res.sprintf("viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n",
@@ -1033,6 +1081,7 @@ void DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled(QWebPage* page
         corePage->settings()->setInteractiveFormValidationEnabled(enable);
 }
 
+#ifndef QT_NO_MENU
 static QStringList iterateContextMenu(QMenu* menu)
 {
     if (!menu)
@@ -1050,6 +1099,7 @@ static QStringList iterateContextMenu(QMenu* menu)
     }
     return items;
 }
+#endif
 
 QStringList DumpRenderTreeSupportQt::contextMenu(QWebPage* page)
 {
@@ -1075,9 +1125,10 @@ void DumpRenderTreeSupportQt::setMinimumTimerInterval(QWebPage* page, double int
 }
 
 #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
-bool DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(QNetworkCookieJar* jar, const QUrl& url, const QUrl& firstPartyUrl)
+bool DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(QWebPage *page, const QUrl& url, const QUrl& firstPartyUrl)
 {
-    return thirdPartyCookiePolicyPermits(jar, url, firstPartyUrl);
+    Page* corePage = QWebPagePrivate::core(page);
+    return thirdPartyCookiePolicyPermits(corePage->mainFrame()->loader()->networkingContext(), url, firstPartyUrl);
 }
 #endif
 
@@ -1163,10 +1214,18 @@ void DumpRenderTreeSupportQt::injectInternalsObject(QWebFrame* frame)
     JSContextRef context = toRef(exec);
     WebCoreTestSupport::injectInternalsObject(context);
 #elif USE(V8)
+    v8::HandleScope handleScope;
     WebCoreTestSupport::injectInternalsObject(V8Proxy::mainWorldContext(coreFrame));
 #endif
 }
 
+void DumpRenderTreeSupportQt::injectInternalsObject(JSContextRef context)
+{
+#if USE(JSC)
+    WebCoreTestSupport::injectInternalsObject(context);
+#endif
+}
+
 void DumpRenderTreeSupportQt::resetInternalsObject(QWebFrame* frame)
 {
     WebCore::Frame* coreFrame = QWebFramePrivate::core(frame);
@@ -1182,10 +1241,27 @@ void DumpRenderTreeSupportQt::resetInternalsObject(QWebFrame* frame)
     JSContextRef context = toRef(exec);
     WebCoreTestSupport::resetInternalsObject(context);
 #elif USE(V8)
+    v8::HandleScope handleScope;
     WebCoreTestSupport::resetInternalsObject(V8Proxy::mainWorldContext(coreFrame));
 #endif
 }
 
+bool DumpRenderTreeSupportQt::defaultHixie76WebSocketProtocolEnabled()
+{
+    return true;
+}
+
+void DumpRenderTreeSupportQt::setHixie76WebSocketProtocolEnabled(QWebPage* page, bool enabled)
+{
+#if ENABLE(WEB_SOCKETS)
+    if (Page* corePage = QWebPagePrivate::core(page))
+        corePage->settings()->setUseHixie76WebSocketProtocol(enabled);
+#else
+    UNUSED_PARAM(page);
+    UNUSED_PARAM(enabled);
+#endif
+}
+
 // Provide a backward compatibility with previously exported private symbols as of QtWebKit 4.6 release
 
 void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* frame)