Commit 366d0866 authored by darin's avatar darin

WebCore:

	Rework plugin code to prepare to move more of it into WebKit.

	* khtml/rendering/render_applet.cpp:
	(RenderApplet::RenderApplet): Create a widget for the applet using
	the new simpler API.

	* kwq/kdecore/kconfig.h:
	* kwq/KWQKConfigBase.mm: Eliminate KConfigBase.
	Set things up so we are poised to handle the other non-plugin
	config keys easily in the future.

	* kwq/KWQKHTMLPart.mm: (KHTMLPart::requestObject): Use the new simpler
	IFPluginWidgetCreate API instead of the older WCPluginWidget one.

	* kwq/qt/qstring.h: Add simpler conversions to/from NSString.
	* kwq/KWQString.mm: (QString::fromNSString): New.

	* kwq/WCPluginWidget.h: Made this API simpler both for the C++
	side and the Objective-C side. There's now no class, and only one
	function that needs to be supplied (normally by WebKit).
	* kwq/WCJavaAppletWidget.h: Same thing for the Java case.

	* kwq/WCJavaAppletWidget.mm:
	(IFSetJavaAppletViewCreationFunction): New.
	(IFJavaAppletWidgetCreate): New. Most of the code that was in here
	is now moved into WebKit.
	* kwq/WCPluginWidget.mm:
	(IFSetPluginViewCreationFunction): New.
	(IFPluginWidgetCreate): New. Most of the code that was in here
	is now moved into WebKit.

	* libwebcore.exp: Update for new function names.

WebKit:

	Rework plugin code to prepare to move more of here from WebCore.

	* Plugins.subproj/IFPluginView.mm:
	(IFPluginViewCreate): New. Does all the work of creating an NSView
	for a plug-in, including stuff previously done in WebCore.
	(IFJavaAppletViewCreate): Same as above, for Java applets.
	(+[IFPluginView load]): Set up the function pointers using the new
	improved WebCore API.

	* Plugins.subproj/IFNullPluginView.mm:
	(-[IFNullPluginView load]): Remove this setup because now there's
	no separate call to set up a null plug-in.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1075 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent db94bcf5
:RU2002-04-25 Darin Adler <darin@apple.com>
* khtml/rendering/render_applet.cpp:
(RenderApplet::RenderApplet): Create a widget for the applet using
the new simpler API.
* kwq/kdecore/kconfig.h:
* kwq/KWQKConfigBase.mm: Eliminate KConfigBase.
Set things up so we are poised to handle the other non-plugin
config keys easily in the future.
* kwq/KWQKHTMLPart.mm: (KHTMLPart::requestObject): Use the new simpler
IFPluginWidgetCreate API instead of the older WCPluginWidget one.
* kwq/qt/qstring.h: Add simpler conversions to/from NSString.
* kwq/KWQString.mm: (QString::fromNSString): New.
* kwq/WCPluginWidget.h: Made this API simpler both for the C++
side and the Objective-C side. There's now no class, and only one
function that needs to be supplied (normally by WebKit).
* kwq/WCJavaAppletWidget.h: Same thing for the Java case.
* kwq/WCJavaAppletWidget.mm:
(IFSetJavaAppletViewCreationFunction): New.
(IFJavaAppletWidgetCreate): New. Most of the code that was in here
is now moved into WebKit.
* kwq/WCPluginWidget.mm:
(IFSetPluginViewCreationFunction): New.
(IFPluginWidgetCreate): New. Most of the code that was in here
is now moved into WebKit.
* libwebcore.exp: Update for new function names.
2002-04-24 Chris Blumenberg <cblu@apple.com>
Renamed [IFWebDataSource frame] to [IFWebDataSource webFrame]
......
:RU2002-04-25 Darin Adler <darin@apple.com>
* khtml/rendering/render_applet.cpp:
(RenderApplet::RenderApplet): Create a widget for the applet using
the new simpler API.
* kwq/kdecore/kconfig.h:
* kwq/KWQKConfigBase.mm: Eliminate KConfigBase.
Set things up so we are poised to handle the other non-plugin
config keys easily in the future.
* kwq/KWQKHTMLPart.mm: (KHTMLPart::requestObject): Use the new simpler
IFPluginWidgetCreate API instead of the older WCPluginWidget one.
* kwq/qt/qstring.h: Add simpler conversions to/from NSString.
* kwq/KWQString.mm: (QString::fromNSString): New.
* kwq/WCPluginWidget.h: Made this API simpler both for the C++
side and the Objective-C side. There's now no class, and only one
function that needs to be supplied (normally by WebKit).
* kwq/WCJavaAppletWidget.h: Same thing for the Java case.
* kwq/WCJavaAppletWidget.mm:
(IFSetJavaAppletViewCreationFunction): New.
(IFJavaAppletWidgetCreate): New. Most of the code that was in here
is now moved into WebKit.
* kwq/WCPluginWidget.mm:
(IFSetPluginViewCreationFunction): New.
(IFPluginWidgetCreate): New. Most of the code that was in here
is now moved into WebKit.
* libwebcore.exp: Update for new function names.
2002-04-24 Chris Blumenberg <cblu@apple.com>
Renamed [IFWebDataSource frame] to [IFWebDataSource webFrame]
......
:RU2002-04-25 Darin Adler <darin@apple.com>
* khtml/rendering/render_applet.cpp:
(RenderApplet::RenderApplet): Create a widget for the applet using
the new simpler API.
* kwq/kdecore/kconfig.h:
* kwq/KWQKConfigBase.mm: Eliminate KConfigBase.
Set things up so we are poised to handle the other non-plugin
config keys easily in the future.
* kwq/KWQKHTMLPart.mm: (KHTMLPart::requestObject): Use the new simpler
IFPluginWidgetCreate API instead of the older WCPluginWidget one.
* kwq/qt/qstring.h: Add simpler conversions to/from NSString.
* kwq/KWQString.mm: (QString::fromNSString): New.
* kwq/WCPluginWidget.h: Made this API simpler both for the C++
side and the Objective-C side. There's now no class, and only one
function that needs to be supplied (normally by WebKit).
* kwq/WCJavaAppletWidget.h: Same thing for the Java case.
* kwq/WCJavaAppletWidget.mm:
(IFSetJavaAppletViewCreationFunction): New.
(IFJavaAppletWidgetCreate): New. Most of the code that was in here
is now moved into WebKit.
* kwq/WCPluginWidget.mm:
(IFSetPluginViewCreationFunction): New.
(IFPluginWidgetCreate): New. Most of the code that was in here
is now moved into WebKit.
* libwebcore.exp: Update for new function names.
2002-04-24 Chris Blumenberg <cblu@apple.com>
Renamed [IFWebDataSource frame] to [IFWebDataSource webFrame]
......
......@@ -52,15 +52,13 @@ RenderApplet::RenderApplet(HTMLElementImpl *applet, QMap<QString, QString> args
#ifdef APPLE_CHANGES
// FIXME:MERGE Is this needed any more?
NodeImpl *child = element()->firstChild();
while(child) {
if(child->id() == ID_PARAM) {
for (NodeImpl *child = element()->firstChild(); child; child = child->nextSibling()) {
if (child->id() == ID_PARAM) {
HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>(child);
args.insert(p->name(), p->value());
}
child = child->nextSibling();
}
setQWidget( new WCJavaAppletWidget(args));
setQWidget(IFJavaAppletWidgetCreate(args));
#else /* APPLE_CHANGES not defined */
KJavaAppletContext *context = 0;
KHTMLView *_view = applet->getDocument()->view();
......
......@@ -26,117 +26,43 @@
#ifndef KCONFIG_H_
#define KCONFIG_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <qt/qstring.h>
#include <qobject.h>
#include <qcolor.h>
#include <qfont.h>
#include <qdatetime.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qvariant.h>
#include <qmap.h>
#include <qcolor.h>
#include <KWQStrList.h>
class QColor;
class QStringList;
// class KConfigBase ===========================================================
class KWQKConfigImpl;
class KConfigBase {
class KConfig {
public:
// structs -----------------------------------------------------------------
// typedefs ----------------------------------------------------------------
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
// static member functions -------------------------------------------------
// constructors, copy constructors, and destructors ------------------------
KConfigBase();
virtual ~KConfigBase();
// member functions --------------------------------------------------------
KConfig(const QString &n, bool bReadOnly=false, bool bUseKDEGlobals = true);
~KConfig();
void setGroup(const QString &pGroup);
void writeEntry(const QString &pKey, const QStringList &rValue,
char sep=',', bool bPersistent=true, bool bGlobal=false,
bool bNLS=false);
QString readEntry(const char *pKey,
const QString& aDefault=QString::null) const;
QString readEntry(const char *pKey, const QString& aDefault=QString::null) const;
int readNumEntry(const char *pKey, int nDefault=0) const;
unsigned int readUnsignedNumEntry(const char *pKey,
unsigned int nDefault=0) const;
unsigned int readUnsignedNumEntry(const char *pKey, unsigned int nDefault=0) const;
bool readBoolEntry(const char *pKey, bool nDefault=0) const;
QColor readColorEntry(const char *pKey, const QColor *pDefault=0L) const;
// used only for form completions
void writeEntry(const QString &pKey, const QStringList &rValue,
char sep=',', bool bPersistent=true, bool bGlobal=false,
bool bNLS=false);
QStringList readListEntry(const QString &pKey, char sep=',') const;
// operators ---------------------------------------------------------------
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
private:
// add copy constructor
// this private declaration prevents copying
#ifdef _KWQ_PEDANTIC_
KConfigBase(const KConfigBase &);
#endif
// add assignment operator
// this private declaration prevents assignment
#ifdef _KWQ_PEDANTIC_
KConfigBase &operator=(const KConfigBase &);
#endif
}; // class KConfigBase ========================================================
// class KConfig ===============================================================
class KConfig : public KConfigBase {
public:
// structs -----------------------------------------------------------------
// typedefs ----------------------------------------------------------------
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
// static member functions -------------------------------------------------
// constructors, copy constructors, and destructors ------------------------
KConfig(const QString &n, bool bReadOnly=false, bool bUseKDEGlobals = true);
virtual ~KConfig();
// member functions --------------------------------------------------------
// operators ---------------------------------------------------------------
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
private:
// add copy constructor
// this private declaration prevents copying
#ifdef _KWQ_PEDANTIC_
KConfig(const KConfig &);
#endif
// add assignment operator
// this private declaration prevents assignment
#ifdef _KWQ_PEDANTIC_
KConfig &operator=(const KConfig &);
#endif
KWQKConfigImpl *impl;
}; // class KConfig ============================================================
};
#endif
......@@ -23,78 +23,66 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <kwqdebug.h>
#include <kconfig.h>
#import <kconfig.h>
#import <kwqdebug.h>
#import <qcolor.h>
#import <qstringlist.h>
#import <WCPlugin.h>
#import <WCPluginDatabase.h>
enum files{
pluginsinfo
class KWQKConfigImpl
{
public:
bool isPluginInfo;
int pluginIndex;
};
int file;
unsigned group;
//FIX ME:
static QString *tempQString = NULL;
static QColor *tempQColor = NULL;
static QStringList *tempQStringList = NULL;
KConfigBase::KConfigBase()
KConfig::KConfig(const QString &n, bool bReadOnly, bool bUseKDEGlobals)
{
_logNotYetImplemented();
impl = new KWQKConfigImpl;
impl->isPluginInfo = n.contains("pluginsinfo");
impl->pluginIndex = 0;
}
KConfigBase::~KConfigBase()
KConfig::~KConfig()
{
_logNotYetImplemented();
delete impl;
}
void KConfigBase::setGroup(const QString &pGroup)
void KConfig::setGroup(const QString &pGroup)
{
_logPartiallyImplemented();
if(file == pluginsinfo){
group = pGroup.toUInt();
if (impl->isPluginInfo) {
impl->pluginIndex = pGroup.toUInt();
}
}
void KConfigBase::writeEntry(const QString &pKey, const QStringList &rValue,
void KConfig::writeEntry(const QString &pKey, const QStringList &rValue,
char sep=',', bool bPersistent=true, bool bGlobal=false,
bool bNLS=false)
{
_logNotYetImplemented();
}
QString KConfigBase::readEntry(const char *pKey,
const QString& aDefault=QString::null) const
QString KConfig::readEntry(const char *pKey, const QString& aDefault=QString::null) const
{
_logPartiallyImplemented();
if(file == pluginsinfo){
if (impl->isPluginInfo) {
WCPlugin *plugin;
NSArray *mimeTypes;
NSMutableString *bigMimeString;
NSString *bigMimeString2;
uint i;
plugin = [[[WCPluginDatabase installedPlugins] plugins] objectAtIndex:group];
if(strcmp(pKey, "name") == 0){
plugin = [[[WCPluginDatabase installedPlugins] plugins] objectAtIndex:impl->pluginIndex];
if (strcmp(pKey, "name") == 0) {
return NSSTRING_TO_QSTRING([plugin name]);
}else if(strcmp(pKey, "file") == 0){
} else if (strcmp(pKey, "file") == 0) {
return NSSTRING_TO_QSTRING([plugin filename]);
}else if(strcmp(pKey, "description") == 0){
} else if (strcmp(pKey, "description") == 0) {
return NSSTRING_TO_QSTRING([plugin pluginDescription]);
}else if(strcmp(pKey, "mime") == 0){
} else if (strcmp(pKey, "mime") == 0) {
mimeTypes = [plugin mimeTypes];
bigMimeString = [NSMutableString stringWithCapacity:1000];
for(i=0; i<[mimeTypes count]; i++){
bigMimeString = [NSMutableString string];
for(i = 0; i < [mimeTypes count]; i++) {
[bigMimeString appendString:[[mimeTypes objectAtIndex:i] objectAtIndex:0]]; // mime type
[bigMimeString appendString:@":"];
[bigMimeString appendString:[[mimeTypes objectAtIndex:i] objectAtIndex:1]]; // mime's extension
......@@ -102,78 +90,46 @@ QString KConfigBase::readEntry(const char *pKey,
[bigMimeString appendString:[[mimeTypes objectAtIndex:i] objectAtIndex:2]]; // mime's description
[bigMimeString appendString:@";"];
}
bigMimeString2 = [NSString stringWithString:bigMimeString];
[bigMimeString2 retain];
return NSSTRING_TO_QSTRING(bigMimeString2);
return NSSTRING_TO_QSTRING(bigMimeString);
}
}
if(tempQString == NULL) {
tempQString = new QString();
}
return *tempQString;
_logNotYetImplemented();
return QString();
}
int KConfigBase::readNumEntry(const char *pKey, int nDefault=0) const
int KConfig::readNumEntry(const char *pKey, int nDefault) const
{
_logPartiallyImplemented();
if(file == pluginsinfo){
if (impl->isPluginInfo) {
return [[[WCPluginDatabase installedPlugins] plugins] count];
}
return 0;
}
unsigned int KConfigBase::readUnsignedNumEntry(const char *pKey,
unsigned int nDefault=0) const
{
_logNotYetImplemented();
return 0;
return nDefault;
}
bool KConfigBase::readBoolEntry(const char *pKey, bool nDefault=0) const
unsigned int KConfig::readUnsignedNumEntry(const char *pKey, unsigned int nDefault) const
{
_logNotYetImplemented();
return FALSE;
return nDefault;
}
QColor KConfigBase::readColorEntry(const char *pKey, const QColor *pDefault=0L) const
bool KConfig::readBoolEntry(const char *pKey, bool nDefault) const
{
_logNotYetImplemented();
if (tempQColor == NULL) {
tempQColor = new QColor(0,0,0);
}
return *tempQColor;
return nDefault;
}
QStringList KConfigBase::readListEntry(const QString &pKey, char sep=',') const
QColor KConfig::readColorEntry(const char *pKey, const QColor *pDefault) const
{
_logNotYetImplemented();
if (tempQStringList == NULL) {
tempQStringList = new QStringList();
}
return *tempQStringList;
return pDefault ? *pDefault : QColor(0,0,0);
}
// class KConfig ===============================================================
KConfig::KConfig(const QString &n, bool bReadOnly=false, bool bUseKDEGlobals = true)
{
_logPartiallyImplemented();
if(n.contains(pluginsinfo)){
file = pluginsinfo;
}
}
KConfig::~KConfig()
QStringList KConfig::readListEntry(const QString &pKey, char sep) const
{
_logNotYetImplemented();
return QStringList();
}
......@@ -917,8 +917,7 @@ bool KHTMLPart::requestObject( khtml::RenderPart *frame, const QString &url, con
// The plugins array is an attempt to avoid multiple creations of the same plug-in.
// FIXME: Can't have multiple plug-ins with the same URL on a page
if(!d->plugins.contains(url)) {
WCPluginWidget *pluginWidget = new WCPluginWidget(completeURL(url).url(), serviceType, args, d->m_baseURL.url());
frame->setWidget(pluginWidget);
frame->setWidget(IFPluginWidgetCreate(completeURL(url).url(), serviceType, args, d->m_baseURL.url()));
d->plugins.append(url);
}
return true;
......
......@@ -917,8 +917,7 @@ bool KHTMLPart::requestObject( khtml::RenderPart *frame, const QString &url, con
// The plugins array is an attempt to avoid multiple creations of the same plug-in.
// FIXME: Can't have multiple plug-ins with the same URL on a page
if(!d->plugins.contains(url)) {
WCPluginWidget *pluginWidget = new WCPluginWidget(completeURL(url).url(), serviceType, args, d->m_baseURL.url());
frame->setWidget(pluginWidget);
frame->setWidget(IFPluginWidgetCreate(completeURL(url).url(), serviceType, args, d->m_baseURL.url()));
d->plugins.append(url);
}
return true;
......
......@@ -26,31 +26,6 @@
#ifndef QSTRING_H_
#define QSTRING_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// USING_BORROWED_QSTRING ======================================================
#ifdef USING_BORROWED_QSTRING
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
// These macros are TEMPORARY hacks to convert between NSString and QString.
// They should be replaced with correct implementations. They should only be
// used for immutable strings.
#define _FAST_QSTRING_TO_NSSTRING(aString) \
[NSString stringWithCString: aString.latin1()]
#define QSTRING_TO_NSSTRING(aString) \
[NSString stringWithCString: aString.latin1()]
#define QSTRING_TO_NSSTRING_LENGTH(aString,l) \
[NSString stringWithCString: aString.latin1() length: l]
#define NSSTRING_TO_QSTRING(aString) \
QString([aString cString])
#endif
#include <_qstring.h>
#else
#define Fixed MacFixed
#define Rect MacRect
#define Boolean MacBoolean
......@@ -61,27 +36,20 @@
#include "qcstring.h"
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
// Use with extreme caution. Only use _FAST_QSTRING_TO_NSSTRING if you
// understand the reference count of the QString's underlying CFString.
// In cases where QSTRING_TO_NSSTRING is called many times consider using
// _FAST_QSTRING_TO_NSSTRING to save on unnecessary autoreleasing.
#define _FAST_QSTRING_TO_NSSTRING(aString) \
((NSString *)(aString.getCFMutableString()))
#define QSTRING_TO_NSSTRING(aString) \
[[(NSString *)(aString.getCFMutableString()) retain] autorelease]
#define _FAST_QSTRING_TO_NSSTRING(aString) (aString).getNSString()
#define QSTRING_TO_NSSTRING(aString) (aString).getNSString()
#define QSTRING_TO_NSSTRING_LENGTH(aString,l) \
[[[(NSString *)(aString.getCFMutableString()) substringToIndex: l] retain] autorelease]
#define NSSTRING_TO_QSTRING(aString) \
QString::fromCFMutableString((CFMutableStringRef)aString)
#endif
[[[(aString).getNSString() substringToIndex: l] retain] autorelease]
#define NSSTRING_TO_QSTRING(aString) QString::fromNSString(aString)
class QString;
class QRegExp;
#ifdef __OBJC__
@class NSString;
#else
typedef void NSString;
#endif
// QChar class =================================================================
class QChar {
......@@ -349,12 +317,10 @@ public:
static QString number(double);
static QString fromLatin1(const char * /* NOTE: len NOT used */ );
#ifdef USING_BORROWED_KURL
static QString fromLocal8Bit(const char *, int len=-1);
#endif
static QString fromStringWithEncoding(const char *, int, CFStringEncoding);
static QString fromCFMutableString(CFMutableStringRef);
static QString fromCFString(CFStringRef);
static QString fromNSString(NSString *);
static QString gstring_toQString(CFMutableStringRef *ref, UniChar *uchars, int len);
static CFMutableStringRef gstring_toCFString(CFMutableStringRef *ref, UniChar *uchars, int len);
......@@ -367,7 +333,7 @@ public:
QString(const QChar *, uint);
QString(const char *);
QString(const char *, int len);
QString(const QString &);
~QString();
......@@ -475,6 +441,7 @@ public:
QString visual();
CFMutableStringRef getCFMutableString() const;
NSString *getNSString() const;
// operators ---------------------------------------------------------------
......@@ -611,10 +578,14 @@ inline QString::operator const char *() const
inline CFMutableStringRef QString::getCFMutableString() const
{
// not sure this is right, but if it is, it must be inline
return s;
}
inline NSString *QString::getNSString() const
{
return (NSString *)s;
}
inline bool operator==(const char *chs, const QString &qs)
{
return qs == chs;
......@@ -705,6 +676,4 @@ public:
}; // class QConstString =======================================================
#endif // USING_BORROWED_QSTRING
#endif
......@@ -143,13 +143,17 @@ QString QString::fromCFMutableString(CFMutableStringRef cfs)
QString QString::fromCFString(CFStringRef cfs)
{
CFMutableStringRef ref;
QString qs;
ref = CFStringCreateMutableCopy(NULL, 0, cfs);
qs = QString::fromCFMutableString(ref);
CFRelease(ref);
qs.s = CFStringCreateMutableCopy(NULL, 0, cfs);
return qs;
}
QString QString::fromNSString(NSString *nss)
{
QString qs;
qs.s = CFStringCreateMutableCopy(NULL, 0, (CFStringRef)nss);
return qs;
}
......
......@@ -26,41 +26,22 @@
#ifndef WCJavaAppletWidget_H_
#define WCJavaAppletWidget_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "qwidget.h"
#include "qstring.h"
#include <qmap.h>
// class WCJavaAppletWidget ===============================================================
class WCJavaAppletWidget : public QWidget {
public:
#include <qstring.h>
// typedefs ----------------------------------------------------------------
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
// static member functions -------------------------------------------------
// constructors, copy constructors, and destructors ------------------------
class QWidget;
WCJavaAppletWidget(QMap<QString, QString> args);
~WCJavaAppletWidget();
// member functions --------------------------------------------------------
// operators ---------------------------------------------------------------
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
#ifdef __OBJC__
@class NSDictionary;
@class NSView;
#else
typedef void NSDictionary;
typedef void NSView;
#endif
private:
WCJavaAppletWidget(const WCJavaAppletWidget &);
WCJavaAppletWidget &operator=(const WCJavaAppletWidget &);