File indexing completed on 2024-04-28 15:23:15

0001 /*
0002  *  This file is part of the KDE libraries
0003  *  Copyright (C) 1999 Harri Porten (porten@kde.org)
0004  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
0005  *
0006  *  This library is free software; you can redistribute it and/or
0007  *  modify it under the terms of the GNU Library General Public
0008  *  License as published by the Free Software Foundation; either
0009  *  version 2 of the License, or (at your option) any later version.
0010  *
0011  *  This library is distributed in the hope that it will be useful,
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  *  Library General Public License for more details.
0015  *
0016  *  You should have received a copy of the GNU Library General Public
0017  *  License along with this library; if not, write to the Free Software
0018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  */
0020 
0021 #ifndef _KJS_PROXY_H_
0022 #define _KJS_PROXY_H_
0023 
0024 #include <QVariant>
0025 #include <QString>
0026 #include <wtf/RefPtr.h>
0027 
0028 class KHTMLPart;
0029 
0030 namespace DOM
0031 {
0032 class Node;
0033 class NodeImpl;
0034 class EventListener;
0035 class Event;
0036 }
0037 
0038 namespace KJS
0039 {
0040 class List;
0041 class Interpreter;
0042 class Completion;
0043 class ScriptInterpreter;
0044 }
0045 
0046 namespace KJSDebugger
0047 {
0048 class DebugWindow;
0049 }
0050 
0051 namespace khtml
0052 {
0053 class ChildFrame;
0054 }
0055 
0056 /**
0057  * @internal
0058  *
0059  * @short Proxy class serving as interface when being dlopen'ed.
0060  */
0061 class KJSProxy
0062 {
0063 public:
0064     KJSProxy(khtml::ChildFrame *frame);
0065     ~KJSProxy();
0066 
0067     QVariant evaluate(QString filename, int baseLine, const QString &, const DOM::Node &n,
0068                       KJS::Completion *completion = nullptr);
0069     void clear();
0070 
0071     DOM::EventListener *createHTMLEventHandler(QString sourceUrl, QString name, QString code, DOM::NodeImpl *node, bool svg = false);
0072     void finishedWithEvent(const DOM::Event &event);
0073     KJS::Interpreter *interpreter();
0074 
0075     bool isRunningScript();
0076 
0077     void setDebugEnabled(bool enabled);
0078     bool debugEnabled() const;
0079     void showDebugWindow(bool show = true);
0080 
0081     bool paused() const;
0082 
0083     void setEventHandlerLineno(int lineno)
0084     {
0085         m_handlerLineno = lineno;
0086     }
0087 
0088     // Helper method, to access the private KHTMLPart::jScript()
0089     static KJSProxy *proxy(KHTMLPart *part);
0090 private:
0091     void initScript();
0092     void applyUserAgent();
0093 
0094     khtml::ChildFrame *m_frame;
0095     int m_handlerLineno;
0096 
0097     KJS::ScriptInterpreter *m_script;
0098 #ifdef KJS_DEBUGGER
0099     WTF::RefPtr<KJSDebugger::DebugWindow> m_debugWindow;
0100 #endif
0101     bool m_debugEnabled;
0102     int m_running;
0103 #ifndef NDEBUG
0104     static int s_count;
0105 #endif
0106 };
0107 
0108 #endif