Permalink
Browse files

script evaluator support for gtk

  • Loading branch information...
1 parent 9daba02 commit 6bdcb7f6de12bceb6e9a89d5747c0ef3e71e6bd6 Marshall Culpepper committed Feb 6, 2009
View
@@ -308,6 +308,8 @@ webkitgtk_h_api += \
WebKit/gtk/webkit/webkitwebframe.h \
WebKit/gtk/webkit/webkitwebhistoryitem.h \
WebKit/gtk/webkit/webkitwebinspector.h \
+ WebKit/gtk/webkit/webkitwebscriptevaluator.h \
+ WebKit/gtk/webkit/webkitwebscriptelement.h \
WebKit/gtk/webkit/webkitwebsettings.h \
WebKit/gtk/webkit/webkitwebwindowfeatures.h \
WebKit/gtk/webkit/webkitwebview.h
@@ -341,6 +343,7 @@ webkitgtk_sources += \
WebKit/gtk/webkit/webkitwebframe.cpp \
WebKit/gtk/webkit/webkitwebhistoryitem.cpp \
WebKit/gtk/webkit/webkitwebinspector.cpp \
+ WebKit/gtk/webkit/webkitwebscriptelement.cpp \
WebKit/gtk/webkit/webkitwebsettings.cpp \
WebKit/gtk/webkit/webkitwebview.cpp \
WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
@@ -638,6 +638,8 @@ webcore_sources += \
WebCore/dom/RegisteredEventListener.h \
WebCore/dom/ScriptElement.cpp \
WebCore/dom/ScriptElement.h \
+ WebCore/dom/ScriptEvaluator.cpp \
+ WebCore/dom/ScriptEvaluator.cpp \
WebCore/dom/ScriptExecutionContext.cpp \
WebCore/dom/ScriptExecutionContext.h \
WebCore/dom/SelectorNodeList.cpp \
@@ -0,0 +1,28 @@
+#include "config.h"
+#include "StringHash.h"
+#include <wtf/Vector.h>
+#include "webkitwebscriptelement.h"
+#include "webkitwebscriptevaluator.h"
+#include "ScriptSourceCode.h"
+#include "ScriptEvaluator.h"
+#include "ScriptElement.h"
+#include "CString.h"
+
+EvaluatorAdapter::EvaluatorAdapter(WebKitWebScriptEvaluator *evaluator)
+ : evaluator(evaluator)
+{
+
+}
+
+bool EvaluatorAdapter::matchesMimeType(const WebCore::String &mimeType) {
+ return evaluator->matchesMimeType(mimeType.utf8().data());
+}
+
+void EvaluatorAdapter::evaluate(const WebCore::String &mimeType, const WebCore::ScriptSourceCode& sourceCode)
+{
+ evaluator->evaluate(mimeType.utf8().data(), sourceCode.jsSourceCode().toString().ascii());
+}
+
+WEBKIT_API void addScriptEvaluator(WebKitWebScriptEvaluator *evaluator) {
+ WebCore::ScriptElement::addScriptEvaluator(new EvaluatorAdapter(evaluator));
+}
@@ -0,0 +1,28 @@
+#ifndef WebScriptElement_h
+#define WebScriptElement_h
+
+#include "webkit.h"
+#include "ScriptEvaluator.h"
+
+namespace WebCore {
+ class String;
+ class ScriptSourceCode;
+}
+
+class WebKitWebScriptEvaluator;
+
+class EvaluatorAdapter : public WebCore::ScriptEvaluator {
+public:
+ EvaluatorAdapter(WebKitWebScriptEvaluator *evaluator);
+
+ virtual bool matchesMimeType(const WebCore::String &mimeType);
+
+ virtual void evaluate(const WebCore::String &mimeType, const WebCore::ScriptSourceCode& sourceCode);
+
+protected:
+ WebKitWebScriptEvaluator *evaluator;
+};
+
+WEBKIT_API void addScriptEvaluator(WebKitWebScriptEvaluator *evaluator);
+
+#endif
@@ -0,0 +1,11 @@
+#ifndef WebScriptEvaluator_h
+#define WebScriptEvaluator_h
+
+class WebKitWebScriptEvaluator
+{
+public:
+ virtual bool matchesMimeType(const gchar * mimeType) = 0;
+ virtual void evaluate(const gchar *mimeType, const gchar *sourceCode) = 0;
+};
+
+#endif

0 comments on commit 6bdcb7f

Please sign in to comment.