+2006-07-29 Darin Adler <darin@apple.com>
+
+ - Removed tabs from these source files that still had them.
+ We don't use them; that way source files look fine in editors
+ that have tabs set to 8 spaces or to 4 spaces.
+ - Removed allow-tabs Subversion property from the files too.
+
+ * bindings/NP_jsobject.cpp:
+ * bindings/c/c_utility.cpp:
+ * bindings/jni/jni_runtime.cpp:
+ * bindings/jni/jni_utility.cpp:
+ * bindings/objc/objc_utility.mm:
+ * bindings/runtime.cpp:
+ * bindings/runtime_method.cpp:
+ * bindings/testbindings.cpp:
+ * bindings/testbindings.mm:
+ * kjs/date_object.cpp:
+ * kjs/function.cpp:
+ * kjs/list.cpp:
+ * kjs/nodes.cpp:
+ * kjs/nodes.h:
+ * kjs/string_object.cpp:
+ * kjs/ustring.cpp:
+
2006-07-29 Darin Adler <darin@apple.com>
* tests/mozilla/expected.html: Update test results now that regress-185165.js
static bool _isSafeScript(JavaScriptObject* obj)
{
if (obj->originExecutionContext) {
- Interpreter* originInterpreter = obj->originExecutionContext->interpreter();
- if (originInterpreter)
- return originInterpreter->isSafeScript(obj->executionContext->interpreter());
+ Interpreter* originInterpreter = obj->originExecutionContext->interpreter();
+ if (originInterpreter)
+ return originInterpreter->isSafeScript(obj->executionContext->interpreter());
}
return true;
}
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = (JavaScriptObject*)o;
- if (!_isSafeScript(obj))
- return false;
+ if (!_isSafeScript(obj))
+ return false;
PrivateIdentifier* i = (PrivateIdentifier*)methodName;
if (!i->isString)
return false;
- // Special case the "eval" method.
- if (methodName == _NPN_GetStringIdentifier("eval")) {
- if (argCount != 1)
- return false;
- if (args[0].type != NPVariantType_String)
- return false;
- return _NPN_Evaluate(npp, o, (NPString *)&args[0].value.stringValue, result);
- }
+ // Special case the "eval" method.
+ if (methodName == _NPN_GetStringIdentifier("eval")) {
+ if (argCount != 1)
+ return false;
+ if (args[0].type != NPVariantType_String)
+ return false;
+ return _NPN_Evaluate(npp, o, (NPString *)&args[0].value.stringValue, result);
+ }
// Lookup the function object.
ExecState* exec = obj->executionContext->interpreter()->globalExec();
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = (JavaScriptObject*)o;
- if (!_isSafeScript(obj))
- return false;
+ if (!_isSafeScript(obj))
+ return false;
ExecState* exec = obj->executionContext->interpreter()->globalExec();
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = (JavaScriptObject*)o;
- if (!_isSafeScript(obj))
- return false;
+ if (!_isSafeScript(obj))
+ return false;
ExecState* exec = obj->executionContext->interpreter()->globalExec();
PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = (JavaScriptObject*)o;
- if (!_isSafeScript(obj))
- return false;
+ if (!_isSafeScript(obj))
+ return false;
ExecState* exec = obj->executionContext->interpreter()->globalExec();
JSLock lock;
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = (JavaScriptObject*)o;
- if (!_isSafeScript(obj))
- return false;
+ if (!_isSafeScript(obj))
+ return false;
ExecState* exec = obj->executionContext->interpreter()->globalExec();
PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = (JavaScriptObject*)o;
- if (!_isSafeScript(obj))
- return false;
+ if (!_isSafeScript(obj))
+ return false;
ExecState* exec = obj->executionContext->interpreter()->globalExec();
PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = (JavaScriptObject*)o;
- if (!_isSafeScript(obj))
- return false;
+ if (!_isSafeScript(obj))
+ return false;
PrivateIdentifier* i = (PrivateIdentifier*)methodName;
if (!i->isString)
CInstance* instance = static_cast<CInstance*>(imp->getInternalInstance());
NPObject* obj = instance->getObject();
_NPN_RetainObject(obj);
- OBJECT_TO_NPVARIANT(obj, *result);
+ OBJECT_TO_NPVARIANT(obj, *result);
} else {
- Interpreter *originInterpreter = exec->dynamicInterpreter();
+ Interpreter *originInterpreter = exec->dynamicInterpreter();
const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
- Interpreter *interpreter = 0;
- if (originInterpreter->isGlobalObject(value)) {
- interpreter = originInterpreter->interpreterForGlobalObject(value);
- }
+ Interpreter *interpreter = 0;
+ if (originInterpreter->isGlobalObject(value)) {
+ interpreter = originInterpreter->interpreterForGlobalObject(value);
+ }
- if (!interpreter)
- interpreter = originInterpreter;
-
+ if (!interpreter)
+ interpreter = originInterpreter;
+
const Bindings::RootObject *executionContext = rootForInterpreter(interpreter);
if (!executionContext) {
Bindings::RootObject *newExecutionContext = new Bindings::RootObject(0);
executionContext = newExecutionContext;
}
- NPObject* obj = (NPObject *)exec->dynamicInterpreter()->createLanguageInstanceForValue(exec, Instance::CLanguage, value->toObject(exec), originExecutionContext, executionContext);
- OBJECT_TO_NPVARIANT(obj, *result);
- }
+ NPObject* obj = (NPObject *)exec->dynamicInterpreter()->createLanguageInstanceForValue(exec, Instance::CLanguage, value->toObject(exec), originExecutionContext, executionContext);
+ OBJECT_TO_NPVARIANT(obj, *result);
+ }
}
else
VOID_TO_NPVARIANT(*result);
bzero (&result, sizeof(jvalue));
jclass cls = env->GetObjectClass(fieldJInstance);
if ( cls != NULL ) {
- jmethodID mid = env->GetMethodID(cls, name, sig);
- if ( mid != NULL )
- {
- const RootObject *execContext = instance->executionContext();
- if (execContext && execContext->nativeHandle()) {
- JSValue *exceptionDescription = NULL;
- jvalue args[1];
-
- args[0].l = jinstance;
- dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription);
- if (exceptionDescription)
- throwError(exec, GeneralError, exceptionDescription->toString(exec));
- }
- }
+ jmethodID mid = env->GetMethodID(cls, name, sig);
+ if ( mid != NULL )
+ {
+ const RootObject *execContext = instance->executionContext();
+ if (execContext && execContext->nativeHandle()) {
+ JSValue *exceptionDescription = NULL;
+ jvalue args[1];
+
+ args[0].l = jinstance;
+ dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription);
+ if (exceptionDescription)
+ throwError(exec, GeneralError, exceptionDescription->toString(exec));
+ }
+ }
}
return result;
}
switch (_JNIType) {
case object_type: {
- jvalue result = dispatchValueFromInstance (exec, instance, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", object_type);
- jobject anObject = result.l;
+ jvalue result = dispatchValueFromInstance (exec, instance, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", object_type);
+ jobject anObject = result.l;
const char *arrayType = type();
if (arrayType[0] == '[') {
jsresult = JavaArray::convertJObjectToArray (exec, anObject, arrayType, instance->executionContext());
}
else if (anObject != 0){
- jsresult = Instance::createRuntimeObject(Instance::JavaLanguage, anObject, instance->executionContext());
+ jsresult = Instance::createRuntimeObject(Instance::JavaLanguage, anObject, instance->executionContext());
}
}
break;
case int_type: {
jint value;
- jvalue result = dispatchValueFromInstance (exec, instance, "getInt", "(Ljava/lang/Object;)I", int_type);
- value = result.i;
+ jvalue result = dispatchValueFromInstance (exec, instance, "getInt", "(Ljava/lang/Object;)I", int_type);
+ value = result.i;
jsresult = jsNumber((int)value);
- }
- break;
+ }
+ break;
case long_type:
case float_type:
case double_type: {
jdouble value;
- jvalue result = dispatchValueFromInstance (exec, instance, "getDouble", "(Ljava/lang/Object;)D", double_type);
- value = result.i;
+ jvalue result = dispatchValueFromInstance (exec, instance, "getDouble", "(Ljava/lang/Object;)D", double_type);
+ value = result.i;
jsresult = jsNumber((double)value);
}
break;
jclass cls = env->GetObjectClass(fieldJInstance);
if ( cls != NULL ) {
- jmethodID mid = env->GetMethodID(cls, name, sig);
- if ( mid != NULL )
- {
- const RootObject *execContext = instance->executionContext();
- if (execContext && execContext->nativeHandle()) {
- JSValue *exceptionDescription = NULL;
- jvalue args[2];
- jvalue result;
-
- args[0].l = jinstance;
- args[1] = javaValue;
- dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription);
- if (exceptionDescription)
- throwError(exec, GeneralError, exceptionDescription->toString(exec));
- }
- }
+ jmethodID mid = env->GetMethodID(cls, name, sig);
+ if ( mid != NULL )
+ {
+ const RootObject *execContext = instance->executionContext();
+ if (execContext && execContext->nativeHandle()) {
+ JSValue *exceptionDescription = NULL;
+ jvalue args[2];
+ jvalue result;
+
+ args[0].l = jinstance;
+ args[1] = javaValue;
+ dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription);
+ if (exceptionDescription)
+ throwError(exec, GeneralError, exceptionDescription->toString(exec));
+ }
+ }
}
}
switch (_JNIType) {
case object_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V");
}
break;
case boolean_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "setBoolean", "(Ljava/lang/Object;Z)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "setBoolean", "(Ljava/lang/Object;Z)V");
}
break;
case byte_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "setByte", "(Ljava/lang/Object;B)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "setByte", "(Ljava/lang/Object;B)V");
}
break;
case char_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "setChar", "(Ljava/lang/Object;C)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "setChar", "(Ljava/lang/Object;C)V");
}
break;
case short_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "setShort", "(Ljava/lang/Object;S)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "setShort", "(Ljava/lang/Object;S)V");
}
break;
case int_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "setInt", "(Ljava/lang/Object;I)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "setInt", "(Ljava/lang/Object;I)V");
}
break;
case long_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "setLong", "(Ljava/lang/Object;J)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "setLong", "(Ljava/lang/Object;J)V");
}
break;
case float_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "setFloat", "(Ljava/lang/Object;F)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "setFloat", "(Ljava/lang/Object;F)V");
}
break;
case double_type: {
- dispatchSetValueToInstance (exec, instance, javaValue, "setDouble", "(Ljava/lang/Object;D)V");
+ dispatchSetValueToInstance (exec, instance, javaValue, "setDouble", "(Ljava/lang/Object;D)V");
}
break;
default:
{
JNIEnv *env = getJNIEnv();
jmethodID mid = 0;
-
+
if ( env != NULL) {
jclass cls = env->GetObjectClass(obj);
if ( cls != NULL ) {
mid = env->GetMethodID(cls, name, sig);
- if (!mid) {
+ if (!mid) {
env->ExceptionClear();
- mid = env->GetStaticMethodID(cls, name, sig);
- if (!mid) {
- env->ExceptionClear();
- }
- }
+ mid = env->GetStaticMethodID(cls, name, sig);
+ if (!mid) {
+ env->ExceptionClear();
+ }
+ }
}
env->DeleteLocalRef(cls);
}
if (!s) {
env->ExceptionDescribe();
env->ExceptionClear();
- fprintf (stderr, "\n");
+ fprintf (stderr, "\n");
}
return s;
}
if (!s) {
env->ExceptionDescribe();
env->ExceptionClear();
- fprintf (stderr, "\n");
+ fprintf (stderr, "\n");
}
return s;
}
// First see if we have a Java instance.
if (value->isObject()){
JSObject *objectImp = static_cast<JSObject*>(value);
- if (objectImp->classInfo() == &RuntimeObjectImp::info) {
- RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value);
- JavaInstance *instance = static_cast<JavaInstance*>(imp->getInternalInstance());
- result.l = instance->javaInstance();
- }
- else if (objectImp->classInfo() == &RuntimeArray::info) {
- RuntimeArray *imp = static_cast<RuntimeArray *>(value);
- JavaArray *array = static_cast<JavaArray*>(imp->getConcreteArray());
- result.l = array->javaArray();
- }
+ if (objectImp->classInfo() == &RuntimeObjectImp::info) {
+ RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value);
+ JavaInstance *instance = static_cast<JavaInstance*>(imp->getInternalInstance());
+ result.l = instance->javaInstance();
+ }
+ else if (objectImp->classInfo() == &RuntimeArray::info) {
+ RuntimeArray *imp = static_cast<RuntimeArray *>(value);
+ JavaArray *array = static_cast<JavaArray*>(imp->getConcreteArray());
+ result.l = array->javaArray();
+ }
}
// Now convert value to a string if the target type is a java.lang.string, and we're not
// converting from a Null.
if (result.l == 0 && strcmp(javaClassName, "java.lang.String") == 0) {
#ifdef CONVERT_NULL_TO_EMPTY_STRING
- if (value->isNull()) {
- JNIEnv *env = getJNIEnv();
- jchar buf[2];
- jobject javaString = env->functions->NewString (env, buf, 0);
- result.l = javaString;
- }
- else
+ if (value->isNull()) {
+ JNIEnv *env = getJNIEnv();
+ jchar buf[2];
+ jobject javaString = env->functions->NewString (env, buf, 0);
+ result.l = javaString;
+ }
+ else
#else
- if (!value->isNull())
+ if (!value->isNull())
#endif
- {
- UString stringValue = value->toString(exec);
- JNIEnv *env = getJNIEnv();
- jobject javaString = env->functions->NewString (env, (const jchar *)stringValue.data(), stringValue.size());
- result.l = javaString;
- }
+ {
+ UString stringValue = value->toString(exec);
+ JNIEnv *env = getJNIEnv();
+ jobject javaString = env->functions->NewString (env, (const jchar *)stringValue.data(), stringValue.size());
+ result.l = javaString;
+ }
}
}
break;
*dp = *sp;
} else if (*sp == '_')
*dp = ':';
- else
+ else
*dp = *sp;
// If a future coder puts funny ++ operators above, we might write off the end
double d = 0;
if (value->isNumber() || value->isString() || value->isBoolean())
- d = value->toNumber(exec);
-
+ d = value->toNumber(exec);
+
switch (type){
case ObjcObjectType: {
- Interpreter *originInterpreter = exec->dynamicInterpreter();
+ Interpreter *originInterpreter = exec->dynamicInterpreter();
const RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
- Interpreter *interpreter = 0;
- if (originInterpreter->isGlobalObject(value)) {
- interpreter = originInterpreter->interpreterForGlobalObject (value);
- }
+ Interpreter *interpreter = 0;
+ if (originInterpreter->isGlobalObject(value)) {
+ interpreter = originInterpreter->interpreterForGlobalObject (value);
+ }
- if (!interpreter)
- interpreter = originInterpreter;
-
+ if (!interpreter)
+ interpreter = originInterpreter;
+
const RootObject *executionContext = rootForInterpreter(interpreter);
if (!executionContext) {
RootObject *newExecutionContext = new RootObject(0);
void *createObjcInstanceForValue(JSValue *value, const RootObject *origin, const RootObject *current)
{
if (!value->isObject())
- return 0;
+ return 0;
if (!webScriptObjectClass)
webScriptObjectClass = NSClassFromString(@"WebScriptObject");
JSObject *object = static_cast<JSObject *>(value);
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
void deleteMethodList(CFAllocatorRef, const void* value)
{
- const MethodList* methodList = static_cast<const MethodList*>(value);
- int end = methodList->length();
- for (int i = 0; i < end; i++) {
- delete methodList->methodAt(i);
- }
-
- delete methodList;
+ const MethodList* methodList = static_cast<const MethodList*>(value);
+ int end = methodList->length();
+ for (int i = 0; i < end; i++)
+ delete methodList->methodAt(i);
+ delete methodList;
}
void deleteMethod(CFAllocatorRef, const void* value)
Instance *newInstance = 0;
switch (language) {
- case Instance::JavaLanguage: {
- newInstance = new Bindings::JavaInstance((jobject)nativeInstance, executionContext);
- break;
- }
- case Instance::ObjectiveCLanguage: {
- newInstance = new Bindings::ObjcInstance((ObjectStructPtr)nativeInstance);
- break;
- }
- case Instance::CLanguage: {
- newInstance = new Bindings::CInstance((NPObject *)nativeInstance);
- break;
- }
- default:
- break;
+ case Instance::JavaLanguage: {
+ newInstance = new Bindings::JavaInstance((jobject)nativeInstance, executionContext);
+ break;
+ }
+ case Instance::ObjectiveCLanguage: {
+ newInstance = new Bindings::ObjcInstance((ObjectStructPtr)nativeInstance);
+ break;
+ }
+ case Instance::CLanguage: {
+ newInstance = new Bindings::CInstance((NPObject *)nativeInstance);
+ break;
+ }
+ default:
+ break;
}
if (newInstance)
- newInstance->setExecutionContext(executionContext);
-
+ newInstance->setExecutionContext(executionContext);
+
return newInstance;
}
void *result = 0;
if (!value->isObject())
- return 0;
+ return 0;
JSObject *imp = static_cast<JSObject*>(value);
switch (language) {
- case Instance::ObjectiveCLanguage: {
- result = createObjcInstanceForValue(value, origin, current);
- break;
- }
- case Instance::CLanguage: {
- result = _NPN_CreateScriptObject(0, imp, origin, current);
- break;
- }
- case Instance::JavaLanguage: {
- // FIXME: factor creation of jni_jsobjects, also remove unnecessary thread
- // invocation code.
- break;
- }
- default:
- break;
+ case Instance::ObjectiveCLanguage: {
+ result = createObjcInstanceForValue(value, origin, current);
+ break;
+ }
+ case Instance::CLanguage: {
+ result = _NPN_CreateScriptObject(0, imp, origin, current);
+ break;
+ }
+ case Instance::JavaLanguage: {
+ // FIXME: factor creation of jni_jsobjects, also remove unnecessary thread
+ // invocation code.
+ break;
+ }
+ default:
+ break;
}
return result;
JSValue *RuntimeMethod::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
if (_methodList.length() > 0) {
- RuntimeObjectImp *imp;
-
- // If thisObj is the DOM object for a plugin, get the corresponding
- // runtime object from the DOM object.
- if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info) {
- JSValue *runtimeObject = thisObj->get(exec, "__apple_runtime_object");
- imp = static_cast<RuntimeObjectImp*>(runtimeObject);
- }
- else {
- imp = static_cast<RuntimeObjectImp*>(thisObj);
- }
+ RuntimeObjectImp *imp;
+
+ // If thisObj is the DOM object for a plugin, get the corresponding
+ // runtime object from the DOM object.
+ if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info) {
+ JSValue *runtimeObject = thisObj->get(exec, "__apple_runtime_object");
+ imp = static_cast<RuntimeObjectImp*>(runtimeObject);
+ }
+ else {
+ imp = static_cast<RuntimeObjectImp*>(thisObj);
+ }
if (imp) {
Instance *instance = imp->getInternalInstance();
{
return Completion(Normal, jsUndefined());
}
-
// ------------------ NP Interface definition --------------------
typedef struct
{
- NPObject object;
- double doubleValue;
- int intValue;
- NPVariant stringValue;
- bool boolValue;
+ NPObject object;
+ double doubleValue;
+ int intValue;
+ NPVariant stringValue;
+ bool boolValue;
} MyObject;
static bool identifiersInitialized = false;
-#define ID_DOUBLE_VALUE 0
-#define ID_INT_VALUE 1
-#define ID_STRING_VALUE 2
-#define ID_BOOLEAN_VALUE 3
-#define ID_NULL_VALUE 4
-#define ID_UNDEFINED_VALUE 5
-#define NUM_PROPERTY_IDENTIFIERS 6
+#define ID_DOUBLE_VALUE 0
+#define ID_INT_VALUE 1
+#define ID_STRING_VALUE 2
+#define ID_BOOLEAN_VALUE 3
+#define ID_NULL_VALUE 4
+#define ID_UNDEFINED_VALUE 5
+#define NUM_PROPERTY_IDENTIFIERS 6
static NPIdentifier myPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
static const NPUTF8 *myPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
- "doubleValue",
- "intValue",
- "stringValue",
- "booleanValue",
- "nullValue",
- "undefinedValue"
+ "doubleValue",
+ "intValue",
+ "stringValue",
+ "booleanValue",
+ "nullValue",
+ "undefinedValue"
};
-#define ID_LOG_MESSAGE 0
-#define ID_SET_DOUBLE_VALUE 1
-#define ID_SET_INT_VALUE 2
-#define ID_SET_STRING_VALUE 3
-#define ID_SET_BOOLEAN_VALUE 4
-#define ID_GET_DOUBLE_VALUE 5
-#define ID_GET_INT_VALUE 6
-#define ID_GET_STRING_VALUE 7
-#define ID_GET_BOOLEAN_VALUE 8
-#define NUM_METHOD_IDENTIFIERS 9
+#define ID_LOG_MESSAGE 0
+#define ID_SET_DOUBLE_VALUE 1
+#define ID_SET_INT_VALUE 2
+#define ID_SET_STRING_VALUE 3
+#define ID_SET_BOOLEAN_VALUE 4
+#define ID_GET_DOUBLE_VALUE 5
+#define ID_GET_INT_VALUE 6
+#define ID_GET_STRING_VALUE 7
+#define ID_GET_BOOLEAN_VALUE 8
+#define NUM_METHOD_IDENTIFIERS 9
static NPIdentifier myMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
static const NPUTF8 *myMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
- "logMessage",
- "setDoubleValue",
- "setIntValue",
- "setStringValue",
- "setBooleanValue",
- "getDoubleValue",
- "getIntValue",
- "getStringValue",
- "getBooleanValue"
+ "logMessage",
+ "setDoubleValue",
+ "setIntValue",
+ "setStringValue",
+ "setBooleanValue",
+ "getDoubleValue",
+ "getIntValue",
+ "getStringValue",
+ "getBooleanValue"
};
static void initializeIdentifiers()
{
- NPN_GetStringIdentifiers (myPropertyIdentifierNames, NUM_PROPERTY_IDENTIFIERS, myPropertyIdentifiers);
- NPN_GetStringIdentifiers (myMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, myMethodIdentifiers);
+ NPN_GetStringIdentifiers (myPropertyIdentifierNames, NUM_PROPERTY_IDENTIFIERS, myPropertyIdentifiers);
+ NPN_GetStringIdentifiers (myMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, myMethodIdentifiers);
};
bool myHasProperty (NPClass *theClass, NPIdentifier name)
-{
- int i;
- for (i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++) {
- if (name == myPropertyIdentifiers[i]){
- return true;
- }
- }
- return false;
+{
+ int i;
+ for (i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++) {
+ if (name == myPropertyIdentifiers[i]){
+ return true;
+ }
+ }
+ return false;
}
bool myHasMethod (NPClass *theClass, NPIdentifier name)
{
- int i;
- for (i = 0; i < NUM_METHOD_IDENTIFIERS; i++) {
- if (name == myMethodIdentifiers[i]){
- return true;
- }
- }
- return false;
+ int i;
+ for (i = 0; i < NUM_METHOD_IDENTIFIERS; i++) {
+ if (name == myMethodIdentifiers[i]){
+ return true;
+ }
+ }
+ return false;
}
void logMessage (const NPVariant *message)
{
if (message->type == NPVariantStringType) {
- char msgBuf[1024];
- strncpy (msgBuf, message->value.stringValue.UTF8Characters, message->value.stringValue.UTF8Length);
- msgBuf[message->value.stringValue.UTF8Length] = 0;
+ char msgBuf[1024];
+ strncpy (msgBuf, message->value.stringValue.UTF8Characters, message->value.stringValue.UTF8Length);
+ msgBuf[message->value.stringValue.UTF8Length] = 0;
printf ("%s\n", msgBuf);
}
else if (message->type == NPVariantDoubleType)
void setDoubleValue (MyObject *obj, const NPVariant *variant)
{
- if (!NPN_VariantToDouble (variant, &obj->doubleValue)) {
- NPUTF8 *msg = "Attempt to set double value with invalid type.";
- NPString aString;
- aString.UTF8Characters = msg;
- aString.UTF8Length = strlen (msg);
- NPN_SetException ((NPObject *)obj, &aString);
- }
+ if (!NPN_VariantToDouble (variant, &obj->doubleValue)) {
+ NPUTF8 *msg = "Attempt to set double value with invalid type.";
+ NPString aString;
+ aString.UTF8Characters = msg;
+ aString.UTF8Length = strlen (msg);
+ NPN_SetException ((NPObject *)obj, &aString);
+ }
}
void setIntValue (MyObject *obj, const NPVariant *variant)
{
- if (!NPN_VariantToInt32 (variant, &obj->intValue)) {
- NPUTF8 *msg = "Attempt to set int value with invalid type.";
- NPString aString;
- aString.UTF8Characters = msg;
- aString.UTF8Length = strlen (msg);
- NPN_SetException ((NPObject *)obj, &aString);
- }
+ if (!NPN_VariantToInt32 (variant, &obj->intValue)) {
+ NPUTF8 *msg = "Attempt to set int value with invalid type.";
+ NPString aString;
+ aString.UTF8Characters = msg;
+ aString.UTF8Length = strlen (msg);
+ NPN_SetException ((NPObject *)obj, &aString);
+ }
}
void setStringValue (MyObject *obj, const NPVariant *variant)
{
- NPN_ReleaseVariantValue (&obj->stringValue);
- NPN_InitializeVariantWithVariant (&obj->stringValue, variant);
+ NPN_ReleaseVariantValue (&obj->stringValue);
+ NPN_InitializeVariantWithVariant (&obj->stringValue, variant);
}
void setBooleanValue (MyObject *obj, const NPVariant *variant)
{
- if (!NPN_VariantToBool (variant, (NPBool *)&obj->boolValue)) {
- NPUTF8 *msg = "Attempt to set bool value with invalid type.";
- NPString aString;
- aString.UTF8Characters = msg;
- aString.UTF8Length = strlen (msg);
- NPN_SetException ((NPObject *)obj, &aString);
- }
+ if (!NPN_VariantToBool (variant, (NPBool *)&obj->boolValue)) {
+ NPUTF8 *msg = "Attempt to set bool value with invalid type.";
+ NPString aString;
+ aString.UTF8Characters = msg;
+ aString.UTF8Length = strlen (msg);
+ NPN_SetException ((NPObject *)obj, &aString);
+ }
}
void getDoubleValue (MyObject *obj, NPVariant *variant)
{
- NPN_InitializeVariantWithDouble (variant, obj->doubleValue);
+ NPN_InitializeVariantWithDouble (variant, obj->doubleValue);
}
void getIntValue (MyObject *obj, NPVariant *variant)
{
- NPN_InitializeVariantWithInt32 (variant, obj->intValue);
+ NPN_InitializeVariantWithInt32 (variant, obj->intValue);
}
void getStringValue (MyObject *obj, NPVariant *variant)
{
- NPN_InitializeVariantWithVariant (variant, &obj->stringValue);
+ NPN_InitializeVariantWithVariant (variant, &obj->stringValue);
}
void getBooleanValue (MyObject *obj, NPVariant *variant)
{
- NPN_InitializeVariantWithBool (variant, obj->boolValue);
+ NPN_InitializeVariantWithBool (variant, obj->boolValue);
}
void myGetProperty (MyObject *obj, NPIdentifier name, NPVariant *variant)
{
- if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]){
- getDoubleValue (obj, variant);
- }
- else if (name == myPropertyIdentifiers[ID_INT_VALUE]){
- getIntValue (obj, variant);
- }
- else if (name == myPropertyIdentifiers[ID_STRING_VALUE]){
- getStringValue (obj, variant);
- }
- else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]){
- getBooleanValue (obj, variant);
- }
- else if (name == myPropertyIdentifiers[ID_NULL_VALUE]){
- return NPN_InitializeVariantAsNull (variant);
- }
- else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]){
- return NPN_InitializeVariantAsUndefined (variant);
- }
- else
- NPN_InitializeVariantAsUndefined(variant);
+ if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]){
+ getDoubleValue (obj, variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_INT_VALUE]){
+ getIntValue (obj, variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_STRING_VALUE]){
+ getStringValue (obj, variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]){
+ getBooleanValue (obj, variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_NULL_VALUE]){
+ return NPN_InitializeVariantAsNull (variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]){
+ return NPN_InitializeVariantAsUndefined (variant);
+ }
+ else
+ NPN_InitializeVariantAsUndefined(variant);
}
void mySetProperty (MyObject *obj, NPIdentifier name, const NPVariant *variant)
{
- if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]) {
- setDoubleValue (obj, variant);
- }
- else if (name == myPropertyIdentifiers[ID_INT_VALUE]) {
- setIntValue (obj, variant);
- }
- else if (name == myPropertyIdentifiers[ID_STRING_VALUE]) {
- setStringValue (obj, variant);
- }
- else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]) {
- setBooleanValue (obj, variant);
- }
- else if (name == myPropertyIdentifiers[ID_NULL_VALUE]) {
- // Do nothing!
- }
- else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]) {
- // Do nothing!
- }
+ if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]) {
+ setDoubleValue (obj, variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_INT_VALUE]) {
+ setIntValue (obj, variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_STRING_VALUE]) {
+ setStringValue (obj, variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]) {
+ setBooleanValue (obj, variant);
+ }
+ else if (name == myPropertyIdentifiers[ID_NULL_VALUE]) {
+ // Do nothing!
+ }
+ else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]) {
+ // Do nothing!
+ }
}
void myInvoke (MyObject *obj, NPIdentifier name, NPVariant *args, unsigned argCount, NPVariant *result)
{
- if (name == myMethodIdentifiers[ID_LOG_MESSAGE]) {
- if (argCount == 1 && NPN_VariantIsString(&args[0]))
- logMessage (&args[0]);
- NPN_InitializeVariantAsVoid (result);
- }
- else if (name == myMethodIdentifiers[ID_SET_DOUBLE_VALUE]) {
- if (argCount == 1 && NPN_VariantIsDouble (&args[0]))
- setDoubleValue (obj, &args[0]);
- NPN_InitializeVariantAsVoid (result);
- }
- else if (name == myMethodIdentifiers[ID_SET_INT_VALUE]) {
- if (argCount == 1 && (NPN_VariantIsDouble (&args[0]) || NPN_VariantIsInt32 (&args[0])))
- setIntValue (obj, &args[0]);
- NPN_InitializeVariantAsVoid (result);
- }
- else if (name == myMethodIdentifiers[ID_SET_STRING_VALUE]) {
- if (argCount == 1 && NPN_VariantIsString (&args[0]))
- setStringValue (obj, &args[0]);
- NPN_InitializeVariantAsVoid (result);
- }
- else if (name == myMethodIdentifiers[ID_SET_BOOLEAN_VALUE]) {
- if (argCount == 1 && NPN_VariantIsBool (&args[0]))
- setBooleanValue (obj, &args[0]);
- NPN_InitializeVariantAsVoid (result);
- }
- else if (name == myMethodIdentifiers[ID_GET_DOUBLE_VALUE]) {
- getDoubleValue (obj, result);
- }
- else if (name == myMethodIdentifiers[ID_GET_INT_VALUE]) {
- getIntValue (obj, result);
- }
- else if (name == myMethodIdentifiers[ID_GET_STRING_VALUE]) {
- getStringValue (obj, result);
- }
- else if (name == myMethodIdentifiers[ID_GET_BOOLEAN_VALUE]) {
- getBooleanValue (obj, result);
- }
- else
- NPN_InitializeVariantAsUndefined (result);
+ if (name == myMethodIdentifiers[ID_LOG_MESSAGE]) {
+ if (argCount == 1 && NPN_VariantIsString(&args[0]))
+ logMessage (&args[0]);
+ NPN_InitializeVariantAsVoid (result);
+ }
+ else if (name == myMethodIdentifiers[ID_SET_DOUBLE_VALUE]) {
+ if (argCount == 1 && NPN_VariantIsDouble (&args[0]))
+ setDoubleValue (obj, &args[0]);
+ NPN_InitializeVariantAsVoid (result);
+ }
+ else if (name == myMethodIdentifiers[ID_SET_INT_VALUE]) {
+ if (argCount == 1 && (NPN_VariantIsDouble (&args[0]) || NPN_VariantIsInt32 (&args[0])))
+ setIntValue (obj, &args[0]);
+ NPN_InitializeVariantAsVoid (result);
+ }
+ else if (name == myMethodIdentifiers[ID_SET_STRING_VALUE]) {
+ if (argCount == 1 && NPN_VariantIsString (&args[0]))
+ setStringValue (obj, &args[0]);
+ NPN_InitializeVariantAsVoid (result);
+ }
+ else if (name == myMethodIdentifiers[ID_SET_BOOLEAN_VALUE]) {
+ if (argCount == 1 && NPN_VariantIsBool (&args[0]))
+ setBooleanValue (obj, &args[0]);
+ NPN_InitializeVariantAsVoid (result);
+ }
+ else if (name == myMethodIdentifiers[ID_GET_DOUBLE_VALUE]) {
+ getDoubleValue (obj, result);
+ }
+ else if (name == myMethodIdentifiers[ID_GET_INT_VALUE]) {
+ getIntValue (obj, result);
+ }
+ else if (name == myMethodIdentifiers[ID_GET_STRING_VALUE]) {
+ getStringValue (obj, result);
+ }
+ else if (name == myMethodIdentifiers[ID_GET_BOOLEAN_VALUE]) {
+ getBooleanValue (obj, result);
+ }
+ else
+ NPN_InitializeVariantAsUndefined (result);
}
NPObject *myAllocate ()
{
- MyObject *newInstance = (MyObject *)malloc (sizeof(MyObject));
-
- if (!identifiersInitialized) {
- identifiersInitialized = true;
- initializeIdentifiers();
- }
-
-
- newInstance->doubleValue = 666.666;
- newInstance->intValue = 1234;
- newInstance->boolValue = true;
- newInstance->stringValue.value.stringValue.UTF8Length = strlen ("Hello world");
- newInstance->stringValue.value.stringValue.UTF8Characters = strdup ("Hello world");
-
- return (NPObject *)newInstance;
+ MyObject *newInstance = (MyObject *)malloc (sizeof(MyObject));
+
+ if (!identifiersInitialized) {
+ identifiersInitialized = true;
+ initializeIdentifiers();
+ }
+
+
+ newInstance->doubleValue = 666.666;
+ newInstance->intValue = 1234;
+ newInstance->boolValue = true;
+ newInstance->stringValue.value.stringValue.UTF8Length = strlen ("Hello world");
+ newInstance->stringValue.value.stringValue.UTF8Characters = strdup ("Hello world");
+
+ return (NPObject *)newInstance;
}
void myInvalidate ()
{
- // Make sure we've released any remainging references to JavaScript
- // objects.
+ // Make sure we've released any remaining references to JavaScript objects.
}
void myDeallocate (MyObject *obj)
{
- free ((void *)obj);
+ free ((void *)obj);
}
static NPClass _myFunctionPtrs = {
- kNPClassStructVersionCurrent,
- (NPAllocateFunctionPtr) myAllocate,
- (NPDeallocateFunctionPtr) myDeallocate,
- (NPInvalidateFunctionPtr) myInvalidate,
- (NPHasMethodFunctionPtr) myHasMethod,
- (NPInvokeFunctionPtr) myInvoke,
- (NPHasPropertyFunctionPtr) myHasProperty,
- (NPGetPropertyFunctionPtr) myGetProperty,
- (NPSetPropertyFunctionPtr) mySetProperty,
+ kNPClassStructVersionCurrent,
+ (NPAllocateFunctionPtr) myAllocate,
+ (NPDeallocateFunctionPtr) myDeallocate,
+ (NPInvalidateFunctionPtr) myInvalidate,
+ (NPHasMethodFunctionPtr) myHasMethod,
+ (NPInvokeFunctionPtr) myInvoke,
+ (NPHasPropertyFunctionPtr) myHasProperty,
+ (NPGetPropertyFunctionPtr) myGetProperty,
+ (NPSetPropertyFunctionPtr) mySetProperty,
};
static NPClass *myFunctionPtrs = &_myFunctionPtrs;
@interface MyFirstInterface : NSObject
{
- int myInt;
- MySecondInterface *mySecondInterface;
- id jsobject;
- NSString *string;
+ int myInt;
+ MySecondInterface *mySecondInterface;
+ id jsobject;
+ NSString *string;
}
- (int)getInt;
/*
- (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args;
{
- NSLog (@"Call to undefined method %@", name);
- NSLog (@"%d args\n", [args count]);
- int i;
- for (i = 0; i < [args count]; i++) {
- NSLog (@"%d: %@\n", i, [args objectAtIndex:i]);
- }
- return @"success";
+ NSLog (@"Call to undefined method %@", name);
+ NSLog (@"%d args\n", [args count]);
+ int i;
+ for (i = 0; i < [args count]; i++) {
+ NSLog (@"%d: %@\n", i, [args objectAtIndex:i]);
+ }
+ return @"success";
}
*/
/*
- (id)valueForUndefinedKey:(NSString *)key
{
- NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key);
- return @"aValue";
+ NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key);
+ return @"aValue";
}
*/
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
- NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key);
+ NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key);
}
- init
- (NSString *)getString
{
- return string;
+ return string;
}
- (MySecondInterface *)getMySecondInterface
static CFDateFormatterStyle styleFromArgString(const UString& string, CFDateFormatterStyle defaultStyle)
{
if (string == "short")
- return kCFDateFormatterShortStyle;
+ return kCFDateFormatterShortStyle;
if (string == "medium")
- return kCFDateFormatterMediumStyle;
+ return kCFDateFormatterMediumStyle;
if (string == "long")
- return kCFDateFormatterLongStyle;
+ return kCFDateFormatterLongStyle;
if (string == "full")
- return kCFDateFormatterFullStyle;
+ return kCFDateFormatterFullStyle;
return defaultStyle;
}
UString arg0String = args[0]->toString(exec);
if (arg0String == "custom" && !args[1]->isUndefined()) {
- useCustomFormat = true;
- customFormatString = args[1]->toString(exec);
+ useCustomFormat = true;
+ customFormatString = args[1]->toString(exec);
} else if (includeDate && includeTime && !args[1]->isUndefined()) {
- dateStyle = styleFromArgString(arg0String, dateStyle);
- timeStyle = styleFromArgString(args[1]->toString(exec), timeStyle);
+ dateStyle = styleFromArgString(arg0String, dateStyle);
+ timeStyle = styleFromArgString(args[1]->toString(exec), timeStyle);
} else if (includeDate && !args[0]->isUndefined()) {
- dateStyle = styleFromArgString(arg0String, dateStyle);
+ dateStyle = styleFromArgString(arg0String, dateStyle);
} else if (includeTime && !args[0]->isUndefined()) {
- timeStyle = styleFromArgString(arg0String, timeStyle);
+ timeStyle = styleFromArgString(arg0String, timeStyle);
}
CFLocaleRef locale = CFLocaleCopyCurrent();
CFRelease(locale);
if (useCustomFormat) {
- CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, (UniChar *)customFormatString.data(), customFormatString.size());
- CFDateFormatterSetFormat(formatter, customFormatCFString);
- CFRelease(customFormatCFString);
+ CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, (UniChar *)customFormatString.data(), customFormatString.size());
+ CFDateFormatterSetFormat(formatter, customFormatCFString);
+ CFRelease(customFormatCFString);
}
CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, time - kCFAbsoluteTimeIntervalSince1970);
/* Source for date_object.lut.h
We use a negative ID to denote the "UTC" variant.
@begin dateTable 61
- toString DateProtoFunc::ToString DontEnum|Function 0
- toUTCString -DateProtoFunc::ToUTCString DontEnum|Function 0
- toDateString DateProtoFunc::ToDateString DontEnum|Function 0
- toTimeString DateProtoFunc::ToTimeString DontEnum|Function 0
- toLocaleString DateProtoFunc::ToLocaleString DontEnum|Function 0
- toLocaleDateString DateProtoFunc::ToLocaleDateString DontEnum|Function 0
- toLocaleTimeString DateProtoFunc::ToLocaleTimeString DontEnum|Function 0
- valueOf DateProtoFunc::ValueOf DontEnum|Function 0
- getTime DateProtoFunc::GetTime DontEnum|Function 0
- getFullYear DateProtoFunc::GetFullYear DontEnum|Function 0
- getUTCFullYear -DateProtoFunc::GetFullYear DontEnum|Function 0
- toGMTString -DateProtoFunc::ToGMTString DontEnum|Function 0
- getMonth DateProtoFunc::GetMonth DontEnum|Function 0
- getUTCMonth -DateProtoFunc::GetMonth DontEnum|Function 0
- getDate DateProtoFunc::GetDate DontEnum|Function 0
- getUTCDate -DateProtoFunc::GetDate DontEnum|Function 0
- getDay DateProtoFunc::GetDay DontEnum|Function 0
- getUTCDay -DateProtoFunc::GetDay DontEnum|Function 0
- getHours DateProtoFunc::GetHours DontEnum|Function 0
- getUTCHours -DateProtoFunc::GetHours DontEnum|Function 0
- getMinutes DateProtoFunc::GetMinutes DontEnum|Function 0
- getUTCMinutes -DateProtoFunc::GetMinutes DontEnum|Function 0
- getSeconds DateProtoFunc::GetSeconds DontEnum|Function 0
- getUTCSeconds -DateProtoFunc::GetSeconds DontEnum|Function 0
- getMilliseconds DateProtoFunc::GetMilliSeconds DontEnum|Function 0
- getUTCMilliseconds -DateProtoFunc::GetMilliSeconds DontEnum|Function 0
- getTimezoneOffset DateProtoFunc::GetTimezoneOffset DontEnum|Function 0
- setTime DateProtoFunc::SetTime DontEnum|Function 1
- setMilliseconds DateProtoFunc::SetMilliSeconds DontEnum|Function 1
- setUTCMilliseconds -DateProtoFunc::SetMilliSeconds DontEnum|Function 1
- setSeconds DateProtoFunc::SetSeconds DontEnum|Function 2
- setUTCSeconds -DateProtoFunc::SetSeconds DontEnum|Function 2
- setMinutes DateProtoFunc::SetMinutes DontEnum|Function 3
- setUTCMinutes -DateProtoFunc::SetMinutes DontEnum|Function 3
- setHours DateProtoFunc::SetHours DontEnum|Function 4
- setUTCHours -DateProtoFunc::SetHours DontEnum|Function 4
- setDate DateProtoFunc::SetDate DontEnum|Function 1
- setUTCDate -DateProtoFunc::SetDate DontEnum|Function 1
- setMonth DateProtoFunc::SetMonth DontEnum|Function 2
- setUTCMonth -DateProtoFunc::SetMonth DontEnum|Function 2
- setFullYear DateProtoFunc::SetFullYear DontEnum|Function 3
- setUTCFullYear -DateProtoFunc::SetFullYear DontEnum|Function 3
- setYear DateProtoFunc::SetYear DontEnum|Function 1
- getYear DateProtoFunc::GetYear DontEnum|Function 0
+ toString DateProtoFunc::ToString DontEnum|Function 0
+ toUTCString -DateProtoFunc::ToUTCString DontEnum|Function 0
+ toDateString DateProtoFunc::ToDateString DontEnum|Function 0
+ toTimeString DateProtoFunc::ToTimeString DontEnum|Function 0
+ toLocaleString DateProtoFunc::ToLocaleString DontEnum|Function 0
+ toLocaleDateString DateProtoFunc::ToLocaleDateString DontEnum|Function 0
+ toLocaleTimeString DateProtoFunc::ToLocaleTimeString DontEnum|Function 0
+ valueOf DateProtoFunc::ValueOf DontEnum|Function 0
+ getTime DateProtoFunc::GetTime DontEnum|Function 0
+ getFullYear DateProtoFunc::GetFullYear DontEnum|Function 0
+ getUTCFullYear -DateProtoFunc::GetFullYear DontEnum|Function 0
+ toGMTString -DateProtoFunc::ToGMTString DontEnum|Function 0
+ getMonth DateProtoFunc::GetMonth DontEnum|Function 0
+ getUTCMonth -DateProtoFunc::GetMonth DontEnum|Function 0
+ getDate DateProtoFunc::GetDate DontEnum|Function 0
+ getUTCDate -DateProtoFunc::GetDate DontEnum|Function 0
+ getDay DateProtoFunc::GetDay DontEnum|Function 0
+ getUTCDay -DateProtoFunc::GetDay DontEnum|Function 0
+ getHours DateProtoFunc::GetHours DontEnum|Function 0
+ getUTCHours -DateProtoFunc::GetHours DontEnum|Function 0
+ getMinutes DateProtoFunc::GetMinutes DontEnum|Function 0
+ getUTCMinutes -DateProtoFunc::GetMinutes DontEnum|Function 0
+ getSeconds DateProtoFunc::GetSeconds DontEnum|Function 0
+ getUTCSeconds -DateProtoFunc::GetSeconds DontEnum|Function 0
+ getMilliseconds DateProtoFunc::GetMilliSeconds DontEnum|Function 0
+ getUTCMilliseconds -DateProtoFunc::GetMilliSeconds DontEnum|Function 0
+ getTimezoneOffset DateProtoFunc::GetTimezoneOffset DontEnum|Function 0
+ setTime DateProtoFunc::SetTime DontEnum|Function 1
+ setMilliseconds DateProtoFunc::SetMilliSeconds DontEnum|Function 1
+ setUTCMilliseconds -DateProtoFunc::SetMilliSeconds DontEnum|Function 1
+ setSeconds DateProtoFunc::SetSeconds DontEnum|Function 2
+ setUTCSeconds -DateProtoFunc::SetSeconds DontEnum|Function 2
+ setMinutes DateProtoFunc::SetMinutes DontEnum|Function 3
+ setUTCMinutes -DateProtoFunc::SetMinutes DontEnum|Function 3
+ setHours DateProtoFunc::SetHours DontEnum|Function 4
+ setUTCHours -DateProtoFunc::SetHours DontEnum|Function 4
+ setDate DateProtoFunc::SetDate DontEnum|Function 1
+ setUTCDate -DateProtoFunc::SetDate DontEnum|Function 1
+ setMonth DateProtoFunc::SetMonth DontEnum|Function 2
+ setUTCMonth -DateProtoFunc::SetMonth DontEnum|Function 2
+ setFullYear DateProtoFunc::SetFullYear DontEnum|Function 3
+ setUTCFullYear -DateProtoFunc::SetFullYear DontEnum|Function 3
+ setYear DateProtoFunc::SetYear DontEnum|Function 1
+ getYear DateProtoFunc::GetYear DontEnum|Function 0
@end
*/
// ECMA 15.9.4
return NaN;
dateString = newPosStr;
} else if (*dateString == '/' && month == -1) {
- dateString++;
+ dateString++;
// This looks like a MM/DD/YYYY date, not an RFC date.
month = day - 1; // 0-based
day = strtol(dateString, &newPosStr, 10);
#ifdef KJS_VERBOSE
fprintf(stderr, "---------------------------------------------------\n"
- "processing parameters for %s call\n",
- name().isEmpty() ? "(internal)" : name().ascii());
+ "processing parameters for %s call\n",
+ name().isEmpty() ? "(internal)" : name().ascii());
#endif
if (param) {
while (p) {
if (it != args.end()) {
#ifdef KJS_VERBOSE
- fprintf(stderr, "setting parameter %s ", p->name.ascii());
- printInfo(exec,"to", *it);
+ fprintf(stderr, "setting parameter %s ", p->name.ascii());
+ printInfo(exec,"to", *it);
#endif
- variable->put(exec, p->name, v);
- v = ++it;
+ variable->put(exec, p->name, v);
+ v = ++it;
} else
- variable->put(exec, p->name, jsUndefined());
+ variable->put(exec, p->name, jsUndefined());
p = p->next.get();
}
}
const ClassInfo DeclaredFunctionImp::info = {"Function", &FunctionImp::info, 0, 0};
DeclaredFunctionImp::DeclaredFunctionImp(ExecState *exec, const Identifier &n,
- FunctionBodyNode *b, const ScopeChain &sc)
+ FunctionBodyNode *b, const ScopeChain &sc)
: FunctionImp(exec, n, b)
{
setScope(sc);
if (k <= len - 6 && p[1] == 'u'
&& isxdigit(p[2].uc) && isxdigit(p[3].uc)
&& isxdigit(p[4].uc) && isxdigit(p[5].uc)) {
- charLen = 6;
- u = Lexer::convertUnicode(p[2].uc, p[3].uc, p[4].uc, p[5].uc);
+ charLen = 6;
+ u = Lexer::convertUnicode(p[2].uc, p[3].uc, p[4].uc, p[5].uc);
}
}
if (charLen && (u.uc == 0 || u.uc >= 128 || !strchr(do_not_unescape, u.low()))) {
if (*c == UChar('%') && k <= len - 6 && *(c+1) == UChar('u')) {
if (Lexer::isHexDigit((c+2)->uc) && Lexer::isHexDigit((c+3)->uc) &&
Lexer::isHexDigit((c+4)->uc) && Lexer::isHexDigit((c+5)->uc)) {
- u = Lexer::convertUnicode((c+2)->uc, (c+3)->uc,
- (c+4)->uc, (c+5)->uc);
- c = &u;
- k += 5;
+ u = Lexer::convertUnicode((c+2)->uc, (c+3)->uc,
+ (c+4)->uc, (c+5)->uc);
+ c = &u;
+ k += 5;
}
} else if (*c == UChar('%') && k <= len - 3 &&
Lexer::isHexDigit((c+1)->uc) && Lexer::isHexDigit((c+2)->uc)) {
return escapedString;
}
-
} // namespace
{
int inlineSize = min(size, inlineValuesSize);
for (int i = 0; i != inlineSize; ++i) {
- if (!values[i]->marked()) {
- values[i]->mark();
- }
+ if (!values[i]->marked()) {
+ values[i]->mark();
+ }
}
int overflowSize = size - inlineSize;
for (int i = 0; i != overflowSize; ++i) {
- if (!overflow[i]->marked()) {
- overflow[i]->mark();
- }
+ if (!overflow[i]->marked()) {
+ overflow[i]->mark();
+ }
}
}
{
// Find a free one in the pool.
if (poolUsed < poolSize) {
- ListImp *imp = poolFreeList ? poolFreeList : &pool[0];
- poolFreeList = imp->nextInFreeList ? imp->nextInFreeList : imp + 1;
- imp->state = usedInPool;
- poolUsed++;
- return imp;
+ ListImp *imp = poolFreeList ? poolFreeList : &pool[0];
+ poolFreeList = imp->nextInFreeList ? imp->nextInFreeList : imp + 1;
+ imp->state = usedInPool;
+ poolUsed++;
+ return imp;
}
HeapListImp *imp = new HeapListImp;
if (imp->state == usedInPool) {
imp->state = unusedInPool;
- imp->nextInFreeList = poolFreeList;
- poolFreeList = imp;
- poolUsed--;
+ imp->nextInFreeList = poolFreeList;
+ poolFreeList = imp;
+ poolUsed--;
} else {
assert(imp->state == usedOnHeap);
HeapListImp *list = static_cast<HeapListImp *>(imp);
"Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, expr2.get());
JSObject *o2(static_cast<JSObject*>(v2));
- if (!o2->implementsHasInstance()) {
+ if (!o2->implementsHasInstance())
// According to the spec, only some types of objects "implement" the [[HasInstance]] property.
// But we are supposed to throw an exception where the object does not "have" the [[HasInstance]]
// property. It seems that all object have the property, but not all implement it, so in this
// case we return false (consistent with mozilla)
return jsBoolean(false);
- // return throwError(exec, TypeError,
- // "Object does not implement the [[HasInstance]] method." );
- }
return jsBoolean(o2->hasInstance(exec, v1));
}
v = expr2->evaluate(exec);
KJS_CHECKEXCEPTION
if (!v->toBoolean(exec))
- return Completion(Normal, cval);
+ return Completion(Normal, cval);
}
// bail out on error
KJS_CHECKEXCEPTION
v = clause->evaluate(exec);
KJS_CHECKEXCEPTION
if (strictEqual(exec, input, v)) {
- res = clause->evalStatements(exec);
- if (res.complType() != Normal)
- return res;
- while (a) {
- res = a->getClause()->evalStatements(exec);
- if (res.complType() != Normal)
- return res;
- a = a->getNext();
- }
- break;
+ res = clause->evalStatements(exec);
+ if (res.complType() != Normal)
+ return res;
+ while (a) {
+ res = a->getClause()->evalStatements(exec);
+ if (res.complType() != Normal)
+ return res;
+ a = a->getNext();
+ }
+ break;
}
}
if (strictEqual(exec, input, v)) {
res = clause->evalStatements(exec);
if (res.complType() != Normal)
- return res;
+ return res;
goto step18;
}
}
class SourceStream;
enum Operator { OpEqual,
- OpEqEq,
- OpNotEq,
- OpStrEq,
- OpStrNEq,
- OpPlusEq,
- OpMinusEq,
- OpMultEq,
- OpDivEq,
+ OpEqEq,
+ OpNotEq,
+ OpStrEq,
+ OpStrNEq,
+ OpPlusEq,
+ OpMinusEq,
+ OpMultEq,
+ OpDivEq,
OpPlusPlus,
- OpMinusMinus,
- OpLess,
- OpLessEq,
- OpGreater,
- OpGreaterEq,
- OpAndEq,
- OpXOrEq,
- OpOrEq,
- OpModEq,
+ OpMinusMinus,
+ OpLess,
+ OpLessEq,
+ OpGreater,
+ OpGreaterEq,
+ OpAndEq,
+ OpXOrEq,
+ OpOrEq,
+ OpModEq,
OpAnd,
OpOr,
- OpBitAnd,
- OpBitXOr,
- OpBitOr,
- OpLShift,
- OpRShift,
- OpURShift,
- OpIn,
- OpInstanceOf
+ OpBitAnd,
+ OpBitXOr,
+ OpBitOr,
+ OpLShift,
+ OpRShift,
+ OpURShift,
+ OpIn,
+ OpInstanceOf
};
class Node {
const ClassInfo StringPrototype::info = {"String", &StringInstance::info, &stringTable, 0};
/* Source for string_object.lut.h
@begin stringTable 26
- toString StringProtoFunc::ToString DontEnum|Function 0
- valueOf StringProtoFunc::ValueOf DontEnum|Function 0
- charAt StringProtoFunc::CharAt DontEnum|Function 1
- charCodeAt StringProtoFunc::CharCodeAt DontEnum|Function 1
- concat StringProtoFunc::Concat DontEnum|Function 1
- indexOf StringProtoFunc::IndexOf DontEnum|Function 1
- lastIndexOf StringProtoFunc::LastIndexOf DontEnum|Function 1
- match StringProtoFunc::Match DontEnum|Function 1
- replace StringProtoFunc::Replace DontEnum|Function 2
- search StringProtoFunc::Search DontEnum|Function 1
- slice StringProtoFunc::Slice DontEnum|Function 2
- split StringProtoFunc::Split DontEnum|Function 2
- substr StringProtoFunc::Substr DontEnum|Function 2
- substring StringProtoFunc::Substring DontEnum|Function 2
- toLowerCase StringProtoFunc::ToLowerCase DontEnum|Function 0
- toUpperCase StringProtoFunc::ToUpperCase DontEnum|Function 0
- toLocaleLowerCase StringProtoFunc::ToLocaleLowerCase DontEnum|Function 0
- toLocaleUpperCase StringProtoFunc::ToLocaleUpperCase DontEnum|Function 0
+ toString StringProtoFunc::ToString DontEnum|Function 0
+ valueOf StringProtoFunc::ValueOf DontEnum|Function 0
+ charAt StringProtoFunc::CharAt DontEnum|Function 1
+ charCodeAt StringProtoFunc::CharCodeAt DontEnum|Function 1
+ concat StringProtoFunc::Concat DontEnum|Function 1
+ indexOf StringProtoFunc::IndexOf DontEnum|Function 1
+ lastIndexOf StringProtoFunc::LastIndexOf DontEnum|Function 1
+ match StringProtoFunc::Match DontEnum|Function 1
+ replace StringProtoFunc::Replace DontEnum|Function 2
+ search StringProtoFunc::Search DontEnum|Function 1
+ slice StringProtoFunc::Slice DontEnum|Function 2
+ split StringProtoFunc::Split DontEnum|Function 2
+ substr StringProtoFunc::Substr DontEnum|Function 2
+ substring StringProtoFunc::Substring DontEnum|Function 2
+ toLowerCase StringProtoFunc::ToLowerCase DontEnum|Function 0
+ toUpperCase StringProtoFunc::ToUpperCase DontEnum|Function 0
+ toLocaleLowerCase StringProtoFunc::ToLocaleLowerCase DontEnum|Function 0
+ toLocaleUpperCase StringProtoFunc::ToLocaleUpperCase DontEnum|Function 0
#
# Under here: html extension, should only exist if KJS_PURE_ECMA is not defined
# I guess we need to generate two hashtables in the .lut.h file, and use #ifdef
# to select the right one... TODO. #####
- big StringProtoFunc::Big DontEnum|Function 0
- small StringProtoFunc::Small DontEnum|Function 0
- blink StringProtoFunc::Blink DontEnum|Function 0
- bold StringProtoFunc::Bold DontEnum|Function 0
- fixed StringProtoFunc::Fixed DontEnum|Function 0
- italics StringProtoFunc::Italics DontEnum|Function 0
- strike StringProtoFunc::Strike DontEnum|Function 0
- sub StringProtoFunc::Sub DontEnum|Function 0
- sup StringProtoFunc::Sup DontEnum|Function 0
- fontcolor StringProtoFunc::Fontcolor DontEnum|Function 1
- fontsize StringProtoFunc::Fontsize DontEnum|Function 1
- anchor StringProtoFunc::Anchor DontEnum|Function 1
- link StringProtoFunc::Link DontEnum|Function 1
+ big StringProtoFunc::Big DontEnum|Function 0
+ small StringProtoFunc::Small DontEnum|Function 0
+ blink StringProtoFunc::Blink DontEnum|Function 0
+ bold StringProtoFunc::Bold DontEnum|Function 0
+ fixed StringProtoFunc::Fixed DontEnum|Function 0
+ italics StringProtoFunc::Italics DontEnum|Function 0
+ strike StringProtoFunc::Strike DontEnum|Function 0
+ sub StringProtoFunc::Sub DontEnum|Function 0
+ sup StringProtoFunc::Sup DontEnum|Function 0
+ fontcolor StringProtoFunc::Fontcolor DontEnum|Function 1
+ fontsize StringProtoFunc::Fontsize DontEnum|Function 1
+ anchor StringProtoFunc::Anchor DontEnum|Function 1
+ link StringProtoFunc::Link DontEnum|Function 1
@end
*/
// ECMA 15.5.4
} else {
// Exec
if ((reg->flags() & RegExp::Global) == 0) {
- // case without 'g' flag is handled like RegExp.prototype.exec
- if (mstr.isNull()) {
- result = jsNull();
- } else {
- result = regExpObj->arrayOfMatches(exec,mstr);
- }
+ // case without 'g' flag is handled like RegExp.prototype.exec
+ if (mstr.isNull()) {
+ result = jsNull();
+ } else {
+ result = regExpObj->arrayOfMatches(exec,mstr);
+ }
} else {
- // return array of matches
- List list;
- int lastIndex = 0;
- while (pos >= 0) {
+ // return array of matches
+ List list;
+ int lastIndex = 0;
+ while (pos >= 0) {
if (mstr.isNull())
list.append(jsUndefined());
else
- list.append(jsString(mstr));
- lastIndex = pos;
- pos += mstr.isEmpty() ? 1 : mstr.size();
- mstr = regExpObj->performMatch(reg, u, pos, &pos);
- }
- if (imp)
- imp->put(exec, "lastIndex", jsNumber(lastIndex), DontDelete|DontEnum);
- if (list.isEmpty()) {
- // if there are no matches at all, it's important to return
- // Null instead of an empty array, because this matches
- // other browsers and because Null is a false value.
- result = jsNull();
- } else {
- result = exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
- }
+ list.append(jsString(mstr));
+ lastIndex = pos;
+ pos += mstr.isEmpty() ? 1 : mstr.size();
+ mstr = regExpObj->performMatch(reg, u, pos, &pos);
+ }
+ if (imp)
+ imp->put(exec, "lastIndex", jsNumber(lastIndex), DontDelete|DontEnum);
+ if (list.isEmpty()) {
+ // if there are no matches at all, it's important to return
+ // Null instead of an empty array, because this matches
+ // other browsers and because Null is a false value.
+ result = jsNull();
+ } else {
+ result = exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
+ }
}
}
delete tmpReg;
if (a0->isObject() && static_cast<JSObject *>(a0)->inherits(&RegExpImp::info)) {
RegExp *reg = static_cast<RegExpImp *>(a0)->regExp();
if (u.isEmpty() && !reg->match(u, 0).isNull()) {
- // empty string matched by regexp -> empty array
- res->put(exec,lengthPropertyName, jsNumber(0));
- break;
+ // empty string matched by regexp -> empty array
+ res->put(exec,lengthPropertyName, jsNumber(0));
+ break;
}
pos = 0;
while (static_cast<uint32_t>(i) != limit && pos < u.size()) {
- // TODO: back references
+ // TODO: back references
int mpos;
int *ovector = 0L;
- UString mstr = reg->match(u, pos, &mpos, &ovector);
+ UString mstr = reg->match(u, pos, &mpos, &ovector);
delete [] ovector; ovector = 0L;
- if (mpos < 0)
- break;
- pos = mpos + (mstr.isEmpty() ? 1 : mstr.size());
- if (mpos != p0 || !mstr.isEmpty()) {
- res->put(exec,i, jsString(u.substr(p0, mpos-p0)));
- p0 = mpos + mstr.size();
- i++;
- }
+ if (mpos < 0)
+ break;
+ pos = mpos + (mstr.isEmpty() ? 1 : mstr.size());
+ if (mpos != p0 || !mstr.isEmpty()) {
+ res->put(exec,i, jsString(u.substr(p0, mpos-p0)));
+ p0 = mpos + mstr.size();
+ i++;
+ }
}
} else {
u2 = a0->toString(exec);
if (u2.isEmpty()) {
- if (u.isEmpty()) {
- // empty separator matches empty string -> empty array
- put(exec,lengthPropertyName, jsNumber(0));
- break;
- } else {
- while (static_cast<uint32_t>(i) != limit && i < u.size()-1)
- res->put(exec, i++, jsString(u.substr(p0++, 1)));
- }
+ if (u.isEmpty()) {
+ // empty separator matches empty string -> empty array
+ put(exec,lengthPropertyName, jsNumber(0));
+ break;
+ } else {
+ while (static_cast<uint32_t>(i) != limit && i < u.size()-1)
+ res->put(exec, i++, jsString(u.substr(p0++, 1)));
+ }
} else {
- while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) {
- res->put(exec, i, jsString(u.substr(p0, pos-p0)));
- p0 = pos + u2.size();
- i++;
- }
+ while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) {
+ res->put(exec, i, jsString(u.substr(p0, pos-p0)));
+ p0 = pos + u2.size();
+ i++;
+ }
}
}
// add remaining string, if any
// b is empty
m_rep = a.m_rep;
} else if (aOffset + aSize == a.usedCapacity() && 4 * aSize >= bSize &&
- (-bOffset != b.usedPreCapacity() || aSize >= bSize)) {
+ (-bOffset != b.usedPreCapacity() || aSize >= bSize)) {
// - a reaches the end of its buffer so it qualifies for shared append
// - also, it's at least a quarter the length of b - appending to a much shorter
// string does more harm than good
strcpy(buf + i, result);
i += length;
for (int j = 0; j < decimalPoint - length; j++) {
- buf[i++] = '0';
+ buf[i++] = '0';
}
buf[i] = '\0';
} else {
d = 0.0;
while (*(++c)) {
if (*c >= '0' && *c <= '9')
- d = d * 16.0 + *c - '0';
+ d = d * 16.0 + *c - '0';
else if ((*c >= 'A' && *c <= 'F') || (*c >= 'a' && *c <= 'f'))
- d = d * 16.0 + (*c & 0xdf) - 'A' + 10.0;
+ d = d * 16.0 + (*c & 0xdf) - 'A' + 10.0;
else
- break;
+ break;
}
} else {
// regular number ?
// infinity ?
d = 1.0;
if (*c == '+')
- c++;
+ c++;
else if (*c == '-') {
- d = -1.0;
- c++;
+ d = -1.0;
+ c++;
}
if (strncmp(c, "Infinity", 8) != 0)
- return NaN;
+ return NaN;
d = d * Inf;
c += 8;
}
return false;
return (memcmp(s1.m_rep->data(), s2.m_rep->data(),
- s1.m_rep->len * sizeof(UChar)) == 0);
+ s1.m_rep->len * sizeof(UChar)) == 0);
}
bool operator==(const UString& s1, const char *s2)
+2006-07-29 Darin Adler <darin@apple.com>
+
+ - Removed tabs from these source files that still had them.
+ We don't use them; that way source files look fine in editors
+ that have tabs set to 8 spaces or to 4 spaces.
+ - Removed allow-tabs Subversion property from the files too.
+
+ * bindings/objc/WebScriptObject.h:
+ * bindings/objc/WebScriptObject.mm:
+ * platform/FontData.cpp:
+
2006-07-29 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Darin.
/*
- Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
+ Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
Public header file.
*/
#import <Foundation/Foundation.h>
-// NSObject (WebScripting) -----------------------------------------------------
+// NSObject (WebScripting) -----------------------------------------------------
/*
The methods in WebScripting are optionally implemented by classes whose
- interfaces are exported (wrapped) to a web scripting environment. The
+ interfaces are exported (wrapped) to a web scripting environment. The
scripting environment currently supported by WebKit uses the JavaScript
language.
-
- Instances automatically reflect their interfaces in the scripting environment. This
+
+ Instances automatically reflect their interfaces in the scripting environment. This
automatic reflection can be overridden using the class methods defined in the WebScripting
informal protocol.
-
+
Access to the attributes of an instance is done using KVC. Specifically the following
KVC methods:
-
+
- (void)setValue:(id)value forKey:(NSString *)key
- (id)valueForKey:(NSString *)key
-
+
Instances may also intercept property set/get operations and method invocations that are
- made by the scripting environment, but not reflected. This is done using the KVC
+ made by the scripting environment, but not reflected. This is done using the KVC
methods:
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
- (id)valueForUndefinedKey:(NSString *)key
-
+
If clients need to raise an exception in the script environment
- they can call [WebScriptObject throwException:]. Note that throwing an
+ they can call [WebScriptObject throwException:]. Note that throwing an
exception using this method will only succeed if the method that throws the exception
is being called within the scope of a script invocation.
-
- By default all attributes, as defined by KVC, will be exposed. However, a
+
+ By default all attributes, as defined by KVC, will be exposed. However, a
class may further exclude properties that they do not want to expose
to web script.
-
- Not all methods are exposed. Only those methods whose parameters and return
- type meets the export criteria will exposed. Valid types are Objective-C instances
- and scalars. Other types are not allowed. Classes may further exclude method
+
+ Not all methods are exposed. Only those methods whose parameters and return
+ type meets the export criteria will exposed. Valid types are Objective-C instances
+ and scalars. Other types are not allowed. Classes may further exclude method
that they do not want to expose.
-
+
Types will be converted to appropriate types in the scripting environment.
After any KVC coercion occurs the Objective-C types will converted to a type
- appropriate for the script environment. For JavaScript NSNumber will be
- converted to numbers. NSString will be converted to strings. NSArray will
- be mapped to a special read-only array. NSNull will be converted to null.
- WebUndefined will be converted to undefined. WebScriptObjects will be unwrapped.
+ appropriate for the script environment. For JavaScript NSNumber will be
+ converted to numbers. NSString will be converted to strings. NSArray will
+ be mapped to a special read-only array. NSNull will be converted to null.
+ WebUndefined will be converted to undefined. WebScriptObjects will be unwrapped.
Instances of other classes will be wrapped when passed to the script environment
- and unwrapped when returned to Objective-C. Similar conversion happens in the
+ and unwrapped when returned to Objective-C. Similar conversion happens in the
other direction.
*/
@interface NSObject (WebScripting)
@method webScriptNameForSelector:
@param aSelector The selector that will be exposed to the script environment.
@discussion Use the returned string as the exported name for the selector
- in the script environment. It is the responsibility of the class to ensure
- uniqueness of the returned name. If nil is returned or this
+ in the script environment. It is the responsibility of the class to ensure
+ uniqueness of the returned name. If nil is returned or this
method is not implemented the default name for the selector will
- be used. The default name concatenates the components of the
+ be used. The default name concatenates the components of the
Objective-C selector name and replaces ':' with '_'. '_' characters
- are escaped with an additional '$', i.e. '_' becomes "$_". '$' are
+ are escaped with an additional '$', i.e. '_' becomes "$_". '$' are
also escaped, i.e.
Objective-C name Default script name
moveTo:: move__
/*!
@method isSelectorExcludedFromWebScript:
- @param aSelect The selector the will be exposed to the script environment.
- @discussion Return YES to prevent the selector appearing in the script
- environment. Return NO to expose the selector in the script environment.
+ @param aSelector The selector the will be exposed to the script environment.
+ @discussion Return YES to prevent the selector appearing in the script
+ environment. Return NO to expose the selector in the script environment.
If this method is not implemented on the class no selectors will be exposed.
@result Returns YES to hide the selector, NO to expose the selector.
*/
/*!
@method webScriptNameForKey:
@param name The name of the instance variable that will be exposed to the
- script environment. Only that properties that meet the export criteria will
+ script environment. Only that properties that meet the export criteria will
be exposed.
@discussion Provide an alternate name for a property.
@result Returns the name to be used to represent the specified property in the
@param args The args to pass the method.
@discussion If a script attempt to invoke a method that is not an exposed
method, scriptInvocation:withArgs: will be called.
- @result The return value of the invocation. The value will be converted as appropriate
+ @result The return value of the invocation. The value will be converted as appropriate
for the script environment.
*/
- (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args;
/*!
@method finalizeForWebScript
@discussion finalizeForScript is called on objects exposed to the script
- environment just before the script environment releases the object. After calls to
+ environment just before the script environment releases the object. After calls to
finalizeForWebScript the object will no longer be referenced by the script environment.
Further, any references to WebScriptObjects made by the exposed object will
be invalid and have undefined consequences.
@end
-// WebScriptObject --------------------------------------------------
+// WebScriptObject --------------------------------------------------
@class WebScriptObjectPrivate;
/*!
@class WebScriptObject
@discussion WebScriptObjects are used to wrap script objects passed from
- script environments to Objective-C. WebScriptObjects cannot be created
- directly. In normal uses of WebKit, you gain access to the script
+ script environments to Objective-C. WebScriptObjects cannot be created
+ directly. In normal uses of WebKit, you gain access to the script
environment using the "windowScriptObject" method on WebView.
-
+
The following KVC methods are commonly used to access properties of the
WebScriptObject:
-
- - (void)setValue:(id)value forKey:(NSString *)key
- - (id)valueForKey:(NSString *)key
-
- As it possible to remove attributes from web script objects the following
- additional method augments the basic KVC methods:
-
- - (void)removeWebScriptKey:(NSString *)name;
-
- Also the sparse array access allowed in web script objects doesn't map well to NSArray, so
- the following methods can be used to access index based properties:
-
- - (id)webScriptValueAtIndex:(unsigned int)index;
- - (void)setWebScriptValueAtIndex:(unsigned int)index value:(id)value;
+
+ - (void)setValue:(id)value forKey:(NSString *)key
+ - (id)valueForKey:(NSString *)key
+
+ As it possible to remove attributes from web script objects the following
+ additional method augments the basic KVC methods:
+
+ - (void)removeWebScriptKey:(NSString *)name;
+
+ Also, the sparse array access allowed in web script objects doesn't map well to NSArray, so
+ the following methods can be used to access index based properties:
+
+ - (id)webScriptValueAtIndex:(unsigned)index;
+ - (void)setWebScriptValueAtIndex:(unsigned)index value:(id)value;
*/
@interface WebScriptObject : NSObject
{
/*!
@method evaluateWebScript:
@param script The script to execute in the target script environment.
- @discussion The script will be executed in the target script environment. The format
+ @discussion The script will be executed in the target script environment. The format
of the script is dependent of the target script environment.
@result Returns the result of evaluating the script in the script environment.
Returns WebUndefined when an exception is thrown in the script environment.
/*!
@method toString
- @discussion Converts the target object to a string representation. The coercion
+ @discussion Converts the target object to a string representation. The coercion
of non string objects type is dependent on the script environment.
@result Returns the string representation of the object.
*/
/*!
@method propertyAtIndex:
- @param index The index of the property to return. Index based access is dependent
+ @param index The index of the property to return. Index based access is dependent
@discussion Gets the value of the property at the specified index.
@result The value of the property. Returns WebUndefined when an exception is
thrown in the script environment.
*/
-- (id)webScriptValueAtIndex:(unsigned int)index;
+- (id)webScriptValueAtIndex:(unsigned)index;
/*!
@method setPropertyAtIndex:value:
@param value The value of the property to set.
@discussion Sets the property value at the specified index.
*/
-- (void)setWebScriptValueAtIndex:(unsigned int)index value:(id)value;
+- (void)setWebScriptValueAtIndex:(unsigned)index value:(id)value;
/*!
@method setException:
- (BOOL)_isSafeScript
{
if ([self _originExecutionContext]) {
- Interpreter *originInterpreter = [self _originExecutionContext]->interpreter();
- if (originInterpreter)
- return originInterpreter->isSafeScript([self _executionContext]->interpreter());
+ Interpreter *originInterpreter = [self _originExecutionContext]->interpreter();
+ if (originInterpreter)
+ return originInterpreter->isSafeScript([self _executionContext]->interpreter());
}
return true;
}
return nil;
if (![self _isSafeScript])
- return nil;
+ return nil;
// Lookup the function object.
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
return nil;
if (![self _isSafeScript])
- return nil;
+ return nil;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
ASSERT(!exec->hadException());
return;
if (![self _isSafeScript])
- return;
+ return;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
ASSERT(!exec->hadException());
return nil;
if (![self _isSafeScript])
- return nil;
+ return nil;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
ASSERT(!exec->hadException());
return;
if (![self _isSafeScript])
- return;
+ return;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
ASSERT(!exec->hadException());
{
if (![self _isSafeScript])
// This is a workaround for a gcc 3.3 internal compiler error.
- return @"Undefined";
+ return @"Undefined";
JSLock lock;
JSObject *thisObj = const_cast<JSObject*>([self _imp]);
return nil;
if (![self _isSafeScript])
- return nil;
+ return nil;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
ASSERT(!exec->hadException());
return;
if (![self _isSafeScript])
- return;
+ return;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
ASSERT(!exec->hadException());
// First see if we have a ObjC instance.
if (value->isObject()) {
JSObject *objectImp = static_cast<JSObject*>(value);
- Interpreter *interpreter = executionContext->interpreter();
- ExecState *exec = interpreter->globalExec();
+ Interpreter *interpreter = executionContext->interpreter();
+ ExecState *exec = interpreter->globalExec();
JSLock lock;
-
+
if (objectImp->classInfo() != &RuntimeObjectImp::info) {
- JSValue *runtimeObject = objectImp->get(exec, "__apple_runtime_object");
- if (runtimeObject && runtimeObject->isObject())
- objectImp = static_cast<RuntimeObjectImp*>(runtimeObject);
- }
+ JSValue *runtimeObject = objectImp->get(exec, "__apple_runtime_object");
+ if (runtimeObject && runtimeObject->isObject())
+ objectImp = static_cast<RuntimeObjectImp*>(runtimeObject);
+ }
if (objectImp->classInfo() == &RuntimeObjectImp::info) {
RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(objectImp);
+2006-07-29 Darin Adler <darin@apple.com>
+
+ - Removed tabs from these source files that still had them.
+ We don't use them; that way source files look fine in editors
+ that have tabs set to 8 spaces or to 4 spaces.
+ - Removed allow-tabs Subversion property from the files too.
+
+ * DefaultDelegates/WebDefaultPolicyDelegate.m:
+ * History/WebHistory.m:
+ * Misc/WebDownload.m:
+ * Misc/WebIconDatabase.m:
+ * Misc/WebKitErrors.m:
+ * Misc/WebKitLogging.m:
+ * Misc/WebNSDataExtras.m:
+ * Misc/WebNSFileManagerExtras.m:
+ * Panels/WebPanelAuthenticationHandler.m:
+ * Plugins/WebBaseNetscapePluginView.m:
+ * Plugins/npfunctions.h:
+ * WebCoreSupport/WebSubresourceLoader.m:
+ * WebView/WebMainResourceLoader.m:
+ * WebView/WebView.h:
+ * WebView/WebView.m:
+
2006-07-29 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Darin.
- (void)webView: (WebView *)wv decidePolicyForMIMEType:(NSString *)type
request:(NSURLRequest *)request
frame:(WebFrame *)frame
- decisionListener:(WebPolicyDecisionListener *)listener;
+ decisionListener:(WebPolicyDecisionListener *)listener;
{
if ([[request URL] isFileURL]) {
- BOOL isDirectory;
- [[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&isDirectory];
-
- if (isDirectory) {
- [listener ignore];
- } else if([WebView canShowMIMEType:type]) {
- [listener use];
- } else{
- [listener ignore];
- }
+ BOOL isDirectory;
+ [[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&isDirectory];
+
+ if (isDirectory) {
+ [listener ignore];
+ } else if([WebView canShowMIMEType:type]) {
+ [listener use];
+ } else{
+ [listener ignore];
+ }
} else if ([WebView canShowMIMEType:type]) {
[listener use];
} else {
WebNavigationType navType = [[actionInformation objectForKey:WebActionNavigationTypeKey] intValue];
if ([WebView _canHandleRequest:request]) {
- [listener use];
+ [listener use];
} else if (navType == WebNavigationTypePlugInRequest) {
- [listener use];
+ [listener use];
} else {
- // A file URL shouldn't fall through to here, but if it did,
- // it would be a security risk to open it.
- if (![[request URL] isFileURL]) {
- [[NSWorkspace sharedWorkspace] openURL:[request URL]];
- }
+ // A file URL shouldn't fall through to here, but if it did,
+ // it would be a security risk to open it.
+ if (![[request URL] isFileURL]) {
+ [[NSWorkspace sharedWorkspace] openURL:[request URL]];
+ }
[listener ignore];
}
}
NSString *FileVersionKey = @"WebHistoryFileVersion";
NSString *DatesArrayKey = @"WebHistoryDates";
-#define currentFileVersion 1
+#define currentFileVersion 1
@implementation WebHistoryPrivate
- (WebHistoryItem *)itemForURL:(NSURL *)URL
{
return [self itemForURLString:[URL _web_originalDataAsString]];
-}
+}
#pragma mark ARCHIVING/UNARCHIVING
BOOL needToAddSlash = FALSE;
if (length >= 6 &&
- matchLetter(latin1[0], 'h') &&
- matchLetter(latin1[1], 't') &&
- matchLetter(latin1[2], 't') &&
- matchLetter(latin1[3], 'p') &&
- (latin1[4] == ':'
- || (matchLetter(latin1[4], 's') && latin1[5] == ':'))) {
- int pos = latin1[4] == ':' ? 5 : 6;
- // skip possible initial two slashes
- if (latin1[pos] == '/' && latin1[pos + 1] == '/') {
- pos += 2;
- }
-
- char *nextSlash = strchr(latin1 + pos, '/');
- if (nextSlash == NULL) {
- needToAddSlash = TRUE;
- }
+ matchLetter(latin1[0], 'h') &&
+ matchLetter(latin1[1], 't') &&
+ matchLetter(latin1[2], 't') &&
+ matchLetter(latin1[3], 'p') &&
+ (latin1[4] == ':'
+ || (matchLetter(latin1[4], 's') && latin1[5] == ':'))) {
+ int pos = latin1[4] == ':' ? 5 : 6;
+ // skip possible initial two slashes
+ if (latin1[pos] == '/' && latin1[pos + 1] == '/') {
+ pos += 2;
+ }
+
+ char *nextSlash = strchr(latin1 + pos, '/');
+ if (nextSlash == NULL) {
+ needToAddSlash = TRUE;
+ }
}
if (needToAddSlash) {
- if (length + 1 <= 2048) {
- strBuffer = staticStrBuffer;
- } else {
- strBuffer = malloc(length + 2);
- }
- memcpy(strBuffer, latin1, length + 1);
- strBuffer[length] = '/';
- strBuffer[length+1] = '\0';
- length++;
+ if (length + 1 <= 2048) {
+ strBuffer = staticStrBuffer;
+ } else {
+ strBuffer = malloc(length + 2);
+ }
+ memcpy(strBuffer, latin1, length + 1);
+ strBuffer[length] = '/';
+ strBuffer[length+1] = '\0';
+ length++;
- latin1Str = strBuffer;
+ latin1Str = strBuffer;
}
CFStringRef str = CFStringCreateWithCStringNoCopy(NULL, latin1Str, kCFStringEncodingWindowsLatin1, kCFAllocatorNull);
CFRelease(str);
if (strBuffer != staticStrBuffer) {
- free(strBuffer);
+ free(strBuffer);
}
return result;
BOOL needToAddSlash = FALSE;
if (length >= 6 &&
- matchUnicodeLetter(unicode[0], 'h') &&
- matchUnicodeLetter(unicode[1], 't') &&
- matchUnicodeLetter(unicode[2], 't') &&
- matchUnicodeLetter(unicode[3], 'p') &&
- (unicode[4] == ':'
- || (matchLetter(unicode[4], 's') && unicode[5] == ':'))) {
-
- unsigned pos = unicode[4] == ':' ? 5 : 6;
-
- // skip possible initial two slashes
- if (pos + 1 < length && unicode[pos] == '/' && unicode[pos + 1] == '/') {
- pos += 2;
- }
+ matchUnicodeLetter(unicode[0], 'h') &&
+ matchUnicodeLetter(unicode[1], 't') &&
+ matchUnicodeLetter(unicode[2], 't') &&
+ matchUnicodeLetter(unicode[3], 'p') &&
+ (unicode[4] == ':'
+ || (matchLetter(unicode[4], 's') && unicode[5] == ':'))) {
+
+ unsigned pos = unicode[4] == ':' ? 5 : 6;
+
+ // skip possible initial two slashes
+ if (pos + 1 < length && unicode[pos] == '/' && unicode[pos + 1] == '/') {
+ pos += 2;
+ }
- while (pos < length && unicode[pos] != '/') {
- pos++;
- }
+ while (pos < length && unicode[pos] != '/') {
+ pos++;
+ }
- if (pos == length) {
- needToAddSlash = TRUE;
- }
+ if (pos == length) {
+ needToAddSlash = TRUE;
+ }
}
if (needToAddSlash) {
- if (length + 1 <= 1024) {
- strBuffer = staticStrBuffer;
- } else {
- strBuffer = malloc(sizeof(UniChar) * (length + 1));
- }
- memcpy(strBuffer, unicode, 2 * length);
- strBuffer[length] = '/';
- length++;
+ if (length + 1 <= 1024) {
+ strBuffer = staticStrBuffer;
+ } else {
+ strBuffer = malloc(sizeof(UniChar) * (length + 1));
+ }
+ memcpy(strBuffer, unicode, 2 * length);
+ strBuffer[length] = '/';
+ length++;
- unicodeStr = strBuffer;
+ unicodeStr = strBuffer;
}
CFStringRef str = CFStringCreateWithCharactersNoCopy(NULL, unicodeStr, length, kCFAllocatorNull);
CFRelease(str);
if (strBuffer != staticStrBuffer) {
- free(strBuffer);
+ free(strBuffer);
}
return result;
delegate:(id)delegate
proxy:(NSURLConnectionDelegateProxy *)proxy;
- (id)_initWithRequest:(NSURLRequest *)request
- delegate:(id)delegate
- directory:(NSString *)directory;
-
+ delegate:(id)delegate
+ directory:(NSString *)directory;
@end
@interface WebDownloadInternal : NSObject
- (BOOL)respondsToSelector:(SEL)selector
{
if (selector == @selector(downloadDidBegin:) ||
- selector == @selector(download:willSendRequest:redirectResponse:) ||
- selector == @selector(download:didReceiveResponse:) ||
- selector == @selector(download:didReceiveDataOfLength:) ||
- selector == @selector(download:shouldDecodeSourceDataOfMIMEType:) ||
- selector == @selector(download:decideDestinationWithSuggestedFilename:) ||
- selector == @selector(download:didCreateDestination:) ||
- selector == @selector(downloadDidFinish:) ||
- selector == @selector(download:didFailWithError:) ||
- selector == @selector(download:shouldBeginChildDownloadOfSource:delegate:) ||
- selector == @selector(download:didBeginChildDownload:)) {
- return [realDelegate respondsToSelector:selector];
+ selector == @selector(download:willSendRequest:redirectResponse:) ||
+ selector == @selector(download:didReceiveResponse:) ||
+ selector == @selector(download:didReceiveDataOfLength:) ||
+ selector == @selector(download:shouldDecodeSourceDataOfMIMEType:) ||
+ selector == @selector(download:decideDestinationWithSuggestedFilename:) ||
+ selector == @selector(download:didCreateDestination:) ||
+ selector == @selector(downloadDidFinish:) ||
+ selector == @selector(download:didFailWithError:) ||
+ selector == @selector(download:shouldBeginChildDownloadOfSource:delegate:) ||
+ selector == @selector(download:didBeginChildDownload:)) {
+ return [realDelegate respondsToSelector:selector];
}
return [super respondsToSelector:selector];
- (void)download:(NSURLDownload *)download didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
if ([realDelegate respondsToSelector:@selector(download:didReceiveAuthenticationChallenge:)]) {
- [realDelegate download:download didReceiveAuthenticationChallenge:challenge];
+ [realDelegate download:download didReceiveAuthenticationChallenge:challenge];
} else {
- NSWindow *window = nil;
- if ([realDelegate respondsToSelector:@selector(downloadWindowForAuthenticationSheet:)]) {
- window = [realDelegate downloadWindowForAuthenticationSheet:(WebDownload *)download];
- }
+ NSWindow *window = nil;
+ if ([realDelegate respondsToSelector:@selector(downloadWindowForAuthenticationSheet:)]) {
+ window = [realDelegate downloadWindowForAuthenticationSheet:(WebDownload *)download];
+ }
- [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window];
+ [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window];
}
}
- (void)download:(NSURLDownload *)download didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
if ([realDelegate respondsToSelector:@selector(download:didCancelAuthenticationChallenge:)]) {
- [realDelegate download:download didCancelAuthenticationChallenge:challenge];
+ [realDelegate download:download didCancelAuthenticationChallenge:challenge];
} else {
- [[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:challenge];
+ [[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:challenge];
}
}
self = [super init];
if (self != nil) {
// _webInternal can be set up before init by _setRealDelegate
- if (_webInternal == nil) {
+ if (_webInternal == nil) {
_webInternal = [[WebDownloadInternal alloc] init];
}
}
#import "WebTypesInternal.h"
-NSString * const WebIconDatabaseVersionKey = @"WebIconDatabaseVersion";
-NSString * const WebURLToIconURLKey = @"WebSiteURLToIconURLKey";
+NSString * const WebIconDatabaseVersionKey = @"WebIconDatabaseVersion";
+NSString * const WebURLToIconURLKey = @"WebSiteURLToIconURLKey";
NSString * const ObsoleteIconsOnDiskKey = @"WebIconsOnDisk";
NSString * const ObsoleteIconURLToURLsKey = @"WebIconURLToSiteURLs";
NSMutableDictionary *icons = [self _iconsForIconURLString:iconURLString];
if (!icons) {
- if (![_private->iconURLsWithNoIcons containsObject:iconURLString]) {
+ if (![_private->iconURLsWithNoIcons containsObject:iconURLString]) {
// We used to have this icon, but don't have it anymore for some reason. (Bug? Deleted from
// disk behind our back?). Forget that we ever had it so it will be re-fetched next time.
- LOG_ERROR("WebIconDatabase used to contain %@, but the icon file is missing. Now forgetting that we ever knew about this icon.", iconURLString);
+ LOG_ERROR("WebIconDatabase used to contain %@, but the icon file is missing. Now forgetting that we ever knew about this icon.", iconURLString);
[self _forgetIconForIconURLString:iconURLString];
- }
+ }
return [self defaultIconWithSize:size];
}
#endif
return (([_private->iconURLToIcons objectForKey:iconURL] ||
- [_private->iconURLsWithNoIcons containsObject:iconURL] ||
+ [_private->iconURLsWithNoIcons containsObject:iconURL] ||
[_private->iconsOnDiskWithURLs containsObject:iconURL]) &&
[self _totalRetainCountForIconURLString:iconURL] > 0);
}
int v = 0;
// no version means first version
if (version == nil) {
- v = 1;
+ v = 1;
} else if ([version isKindOfClass:[NSNumber class]]) {
- v = [version intValue];
+ v = [version intValue];
}
// Get the site URL to icon URL dictionary from the file DB.
ASSERT(iconURLString);
if ([_private->iconURLsWithNoIcons containsObject:iconURLString])
- return nil;
+ return nil;
NSMutableDictionary *icons = [_private->iconURLToIcons objectForKey:iconURLString];
if (icons)
- return icons;
-
+ return icons;
+
// Not in memory, check disk
if(![_private->iconsOnDiskWithURLs containsObject:iconURLString])
return nil;
NSData *iconData = [_private->fileDatabase objectForKey:iconURLString];
if ([iconData isKindOfClass:[NSNull class]]) {
- [_private->iconURLsWithNoIcons addObject:iconURLString];
- return nil;
+ [_private->iconURLsWithNoIcons addObject:iconURLString];
+ return nil;
}
if (iconData) {
NSString *WebKitErrorDomain = @"WebKitErrorDomain";
-NSString * const WebKitErrorMIMETypeKey = @"WebKitErrorMIMETypeKey";
-NSString * const WebKitErrorPlugInNameKey = @"WebKitErrorPlugInNameKey";
-NSString * const WebKitErrorPlugInPageURLStringKey = @"WebKitErrorPlugInPageURLStringKey";
+NSString * const WebKitErrorMIMETypeKey = @"WebKitErrorMIMETypeKey";
+NSString * const WebKitErrorPlugInNameKey = @"WebKitErrorPlugInNameKey";
+NSString * const WebKitErrorPlugInPageURLStringKey = @"WebKitErrorPlugInPageURLStringKey";
// Policy errors
#define WebKitErrorDescriptionCannotShowMIMEType UI_STRING("Cannot show content with specified mime type", "WebKitErrorCannotShowMIMEType description")
NSDictionary *descriptionsDict;
NSString *localizedDesc;
NSDictionary *dict;
- // insert a localized string here for those folks not savvy to our category methods
+ // insert a localized string here for those folks not savvy to our category methods
descriptionsDict = [descriptions objectForKey:domain];
localizedDesc = descriptionsDict ? [descriptionsDict objectForKey:[NSNumber numberWithInt:code]] : nil;
dict = [NSDictionary dictionaryWithObjectsAndKeys:
}
if (pluginPageURL) {
[userInfo setObject:[pluginPageURL _web_userVisibleString] forKey:WebKitErrorPlugInPageURLStringKey];
- }
+ }
if (pluginName) {
[userInfo setObject:pluginName forKey:WebKitErrorPlugInNameKey];
}
+ (void)_webkit_addErrorsWithCodesAndDescriptions:(NSDictionary *)dictionary inDomain:(NSString *)domain
{
- if (!descriptions)
- descriptions = [[NSMutableDictionary alloc] init];
+ if (!descriptions)
+ descriptions = [[NSMutableDictionary alloc] init];
[descriptions setObject:dictionary forKey:domain];
}
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
// Policy errors
- WebKitErrorDescriptionCannotShowMIMEType, [NSNumber numberWithInt: WebKitErrorCannotShowMIMEType],
- WebKitErrorDescriptionCannotShowURL, [NSNumber numberWithInt: WebKitErrorCannotShowURL],
- WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange,[NSNumber numberWithInt: WebKitErrorFrameLoadInterruptedByPolicyChange],
+ WebKitErrorDescriptionCannotShowMIMEType, [NSNumber numberWithInt: WebKitErrorCannotShowMIMEType],
+ WebKitErrorDescriptionCannotShowURL, [NSNumber numberWithInt: WebKitErrorCannotShowURL],
+ WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange, [NSNumber numberWithInt: WebKitErrorFrameLoadInterruptedByPolicyChange],
// Plug-in and java errors
- WebKitErrorDescriptionCannotFindPlugin, [NSNumber numberWithInt: WebKitErrorCannotFindPlugIn],
- WebKitErrorDescriptionCannotLoadPlugin, [NSNumber numberWithInt: WebKitErrorCannotLoadPlugIn],
- WebKitErrorDescriptionJavaUnavailable, [NSNumber numberWithInt: WebKitErrorJavaUnavailable],
- WebKitErrorDescriptionPlugInCancelledConnection,[NSNumber numberWithInt: WebKitErrorPlugInCancelledConnection],
- WebKitErrorDescriptionPlugInWillHandleLoad, [NSNumber numberWithInt: WebKitErrorPlugInWillHandleLoad],
+ WebKitErrorDescriptionCannotFindPlugin, [NSNumber numberWithInt: WebKitErrorCannotFindPlugIn],
+ WebKitErrorDescriptionCannotLoadPlugin, [NSNumber numberWithInt: WebKitErrorCannotLoadPlugIn],
+ WebKitErrorDescriptionJavaUnavailable, [NSNumber numberWithInt: WebKitErrorJavaUnavailable],
+ WebKitErrorDescriptionPlugInCancelledConnection, [NSNumber numberWithInt: WebKitErrorPlugInCancelledConnection],
+ WebKitErrorDescriptionPlugInWillHandleLoad, [NSNumber numberWithInt: WebKitErrorPlugInWillHandleLoad],
nil];
[NSError _webkit_addErrorsWithCodesAndDescriptions:dict inDomain:WebKitErrorDomain];
#import "WebKitLogging.h"
-WTFLogChannel WebKitLogTiming = { 0x00000020, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogLoading = { 0x00000040, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogFontCache = { 0x00000100, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogFontSubstitution = { 0x00000200, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogDownload = { 0x00000800, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogDocumentLoad = { 0x00001000, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogPlugins = { 0x00002000, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogEvents = { 0x00010000, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogView = { 0x00020000, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogRedirect = { 0x00040000, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogTiming = { 0x00000020, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogLoading = { 0x00000040, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogFontCache = { 0x00000100, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogFontSubstitution = { 0x00000200, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogDownload = { 0x00000800, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogDocumentLoad = { 0x00001000, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogPlugins = { 0x00002000, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogEvents = { 0x00010000, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogView = { 0x00020000, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogRedirect = { 0x00040000, "WebKitLogLevel", WTFLogChannelOff };
WTFLogChannel WebKitLogPageCache = { 0x00080000, "WebKitLogLevel", WTFLogChannelOff };
WTFLogChannel WebKitLogCacheSizes = { 0x00100000, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogFormDelegate = { 0x00200000, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogFormDelegate = { 0x00200000, "WebKitLogLevel", WTFLogChannelOff };
WTFLogChannel WebKitLogFileDatabaseActivity = { 0x00400000, "WebKitLogLevel", WTFLogChannelOff };
WTFLogChannel WebKitLogHistory = { 0x00800000, "WebKitLogLevel", WTFLogChannelOff };
WTFLogChannel WebKitLogBindings = { 0x01000000, "WebKitLogLevel", WTFLogChannelOff };
-WTFLogChannel WebKitLogFontSelection = { 0x02000000, "WebKitLogLevel", WTFLogChannelOff };
+WTFLogChannel WebKitLogFontSelection = { 0x02000000, "WebKitLogLevel", WTFLogChannelOff };
WTFLogChannel WebKitLogEncoding = { 0x04000000, "WebKitLogLevel", WTFLogChannelOff };
WTFLogChannel WebKitLogLiveConnect = { 0x08000000, "WebKitLogLevel", WTFLogChannelOff };
WTFLogChannel WebKitLogBackForward = { 0x10000000, "WebKitLogLevel", WTFLogChannelOff };
break;
}
- // We are trying to identify RSS or Atom. RSS has a top-level
- // element of either <rss> or <rdf>. However, there are
- // non-RSS RDF files, so in the case of <rdf> we further look
- // for a <channel> element. In the case of an Atom file, a
- // top-level <feed> element is all we need to see. Only tags
- // starting with <? or <! can precede the root element. We
- // bail if we don't find an <rss>, <feed> or <rdf> element
- // right after those.
+ // We are trying to identify RSS or Atom. RSS has a top-level
+ // element of either <rss> or <rdf>. However, there are
+ // non-RSS RDF files, so in the case of <rdf> we further look
+ // for a <channel> element. In the case of an Atom file, a
+ // top-level <feed> element is all we need to see. Only tags
+ // starting with <? or <! can precede the root element. We
+ // bail if we don't find an <rss>, <feed> or <rdf> element
+ // right after those.
- if (foundRDF) {
- if (strncasecmp(hit, "<channel", strlen("<channel")) == 0) {
- return @"application/rss+xml";
- }
- } else if (strncasecmp(hit, "<rdf", strlen("<rdf")) == 0) {
- foundRDF = TRUE;
- } else if (strncasecmp(hit, "<rss", strlen("<rss")) == 0) {
- return @"application/rss+xml";
- } else if (strncasecmp(hit, "<feed", strlen("<feed")) == 0) {
- return @"application/atom+xml";
- } else if (strncasecmp(hit, "<?", strlen("<?")) != 0 && strncasecmp(hit, "<!", strlen("<!")) != 0) {
- return nil;
- }
+ if (foundRDF) {
+ if (strncasecmp(hit, "<channel", strlen("<channel")) == 0) {
+ return @"application/rss+xml";
+ }
+ } else if (strncasecmp(hit, "<rdf", strlen("<rdf")) == 0) {
+ foundRDF = TRUE;
+ } else if (strncasecmp(hit, "<rss", strlen("<rss")) == 0) {
+ return @"application/rss+xml";
+ } else if (strncasecmp(hit, "<feed", strlen("<feed")) == 0) {
+ return @"application/atom+xml";
+ } else if (strncasecmp(hit, "<?", strlen("<?")) != 0 && strncasecmp(hit, "<!", strlen("<!")) != 0) {
+ return nil;
+ }
// Skip the "<" and continue.
remaining -= (hit + 1) - p;
}
// If we found a "<", look for "<html>" or "<a " or "<script".
- if (strncasecmp(hit, "<html>", strlen("<html>")) == 0 ||
- strncasecmp(hit, "<a ", strlen("<a ")) == 0 ||
+ if (strncasecmp(hit, "<html>", strlen("<html>")) == 0 ||
+ strncasecmp(hit, "<a ", strlen("<a ")) == 0 ||
strncasecmp(hit, "<script", strlen("<script")) == 0 ||
strncasecmp(hit, "<title>", strlen("<title>")) == 0) {
return @"text/html";
// Be really optimistic - assume that in the common case, the directory exists.
BOOL isDirectory;
if ([self fileExistsAtPath:path isDirectory:&isDirectory] && isDirectory) {
- return YES;
+ return YES;
}
// Assume the next most common case is that the parent directory already exists
if ([self createDirectoryAtPath:path attributes:attributes]) {
- return YES;
+ return YES;
}
// Do it the hard way
{
// Be optimistic - try just creating the file first, assuming intermediate directories exist.
if ([self createFileAtPath:path contents:contents attributes:attributes]) {
- return YES;
+ return YES;
}
return ([self _webkit_createIntermediateDirectoriesForPath:path attributes:directoryAttributes] && [self createFileAtPath:path contents:contents attributes:attributes]);
// For mysterious reasons, MNT_DOVOLFS is the flag for "supports resource fork"
if ((statfs([path fileSystemRepresentation], &buf) == 0) && !(buf.f_flags & MNT_DOVOLFS)) {
- NSString *lastPathComponent = [path lastPathComponent];
- if ([lastPathComponent length] != 0 && ![lastPathComponent isEqualToString:@"/"]) {
- NSString *resourcePath = [[path stringByDeletingLastPathComponent] stringByAppendingString:[@"._" stringByAppendingString:lastPathComponent]];
- if (unlink([resourcePath fileSystemRepresentation]) != 0) {
- result = NO;
- }
- }
+ NSString *lastPathComponent = [path lastPathComponent];
+ if ([lastPathComponent length] != 0 && ![lastPathComponent isEqualToString:@"/"]) {
+ NSString *resourcePath = [[path stringByDeletingLastPathComponent] stringByAppendingString:[@"._" stringByAppendingString:lastPathComponent]];
+ if (unlink([resourcePath fileSystemRepresentation]) != 0) {
+ result = NO;
+ }
+ }
}
return result;
+ (id)sharedHandler
{
- if (sharedHandler == nil) {
- sharedHandler = [[self alloc] init];
- }
-
+ if (sharedHandler == nil)
+ sharedHandler = [[self alloc] init];
return sharedHandler;
}
if (self != nil) {
windowToPanel = [[NSMutableDictionary alloc] init];
challengeToWindow = [[NSMutableDictionary alloc] init];
- windowToChallengeQueue = [[NSMutableDictionary alloc] init];
+ windowToChallengeQueue = [[NSMutableDictionary alloc] init];
}
return self;
}
{
NSMutableArray *queue = [windowToChallengeQueue objectForKey:window];
if (queue == nil) {
- queue = [[NSMutableArray alloc] init];
- [windowToChallengeQueue _webkit_setObject:queue forUncopiedKey:window];
- [queue release];
+ queue = [[NSMutableArray alloc] init];
+ [windowToChallengeQueue _webkit_setObject:queue forUncopiedKey:window];
+ [queue release];
}
[queue addObject:challenge];
}
{
NSMutableArray *queue = [windowToChallengeQueue objectForKey:window];
if (queue == nil) {
- return;
+ return;
}
NSURLAuthenticationChallenge *challenge = [[queue objectAtIndex:0] retain];
[queue removeObjectAtIndex:0];
if ([queue count] == 0) {
- [windowToChallengeQueue removeObjectForKey:window];
+ [windowToChallengeQueue removeObjectForKey:window];
}
NSURLCredential *latestCredential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]];
if ([latestCredential hasPassword]) {
- [[challenge sender] useCredential:latestCredential forAuthenticationChallenge:challenge];
- [challenge release];
- return;
+ [[challenge sender] useCredential:latestCredential forAuthenticationChallenge:challenge];
+ [challenge release];
+ return;
}
-
+
[self startAuthentication:challenge window:(window == WebModalDialogPretendWindow ? nil : window)];
[challenge release];
}
id window = w ? (id)w : (id)WebModalDialogPretendWindow;
if ([windowToPanel objectForKey:window] != nil) {
- [self enqueueChallenge:challenge forWindow:window];
+ [self enqueueChallenge:challenge forWindow:window];
return;
}
// unlikely (how would you be loading a page if you had an error
// sheet up?)
if ([w attachedSheet] != nil) {
- [[challenge sender] cancelAuthenticationChallenge:challenge];
- return;
+ [[challenge sender] cancelAuthenticationChallenge:challenge];
+ return;
}
WebAuthenticationPanel *panel = [[WebAuthenticationPanel alloc] initWithCallback:self selector:@selector(_authenticationDoneWithChallenge:result:)];
}
if (credential == nil) {
- [[challenge sender] cancelAuthenticationChallenge:challenge];
+ [[challenge sender] cancelAuthenticationChallenge:challenge];
} else {
- [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
+ [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
}
[self tryNextChallengeForWindow:window];
#import <objc/objc-runtime.h>
// Send null events 50 times a second when active, so plug-ins like Flash get high frame rates.
-#define NullEventIntervalActive 0.02
-#define NullEventIntervalNotActive 0.25
+#define NullEventIntervalActive 0.02
+#define NullEventIntervalNotActive 0.25
#define LoginWindowDidSwitchFromUserNotification @"WebLoginWindowDidSwitchFromUserNotification"
#define LoginWindowDidSwitchToUserNotification @"WebLoginWindowDidSwitchToUserNotification"
+ (void)initialize
{
- WKSendUserChangeNotifications();
+ WKSendUserChangeNotifications();
}
#pragma mark EVENTS
- (void)keyUp:(NSEvent *)theEvent
{
- WKSendKeyEventToTSM(theEvent);
+ WKSendKeyEventToTSM(theEvent);
// TSM won't send keyUp events so we have to send them ourselves.
// Only send keyUp events after we receive the TSM callback because this is what plug-in expect from OS 9.
[plugin release];
plugin = thePlugin;
- NPP_New = [plugin NPP_New];
- NPP_Destroy = [plugin NPP_Destroy];
- NPP_SetWindow = [plugin NPP_SetWindow];
- NPP_NewStream = [plugin NPP_NewStream];
- NPP_WriteReady = [plugin NPP_WriteReady];
- NPP_Write = [plugin NPP_Write];
- NPP_StreamAsFile = [plugin NPP_StreamAsFile];
+ NPP_New = [plugin NPP_New];
+ NPP_Destroy = [plugin NPP_Destroy];
+ NPP_SetWindow = [plugin NPP_SetWindow];
+ NPP_NewStream = [plugin NPP_NewStream];
+ NPP_WriteReady = [plugin NPP_WriteReady];
+ NPP_Write = [plugin NPP_Write];
+ NPP_StreamAsFile = [plugin NPP_StreamAsFile];
NPP_DestroyStream = [plugin NPP_DestroyStream];
- NPP_HandleEvent = [plugin NPP_HandleEvent];
- NPP_URLNotify = [plugin NPP_URLNotify];
- NPP_GetValue = [plugin NPP_GetValue];
- NPP_SetValue = [plugin NPP_SetValue];
- NPP_Print = [plugin NPP_Print];
+ NPP_HandleEvent = [plugin NPP_HandleEvent];
+ NPP_URLNotify = [plugin NPP_URLNotify];
+ NPP_GetValue = [plugin NPP_GetValue];
+ NPP_SetValue = [plugin NPP_SetValue];
+ NPP_Print = [plugin NPP_Print];
}
- (void)setMIMEType:(NSString *)theMIMEType
CGrafPtr port = GetWindowPort(windowRef);
Rect bounds;
GetPortBounds(port, &bounds);
- WKCallDrawingNotification(port, &bounds);
+ WKCallDrawingNotification(port, &bounds);
}
#endif /* NP_NO_QUICKDRAW */
// If the blank line is somewhere in the middle of postData, everything before is the header.
NSData *headerData = [postData subdataWithRange:NSMakeRange(0, location)];
NSMutableDictionary *header = [headerData _webkit_parseRFC822HeaderFields];
- unsigned dataLength = [postData length] - location;
+ unsigned dataLength = [postData length] - location;
- // Sometimes plugins like to set Content-Length themselves when they post,
- // but WebFoundation does not like that. So we will remove the header
- // and instead truncate the data to the requested length.
- NSString *contentLength = [header objectForKey:@"Content-Length"];
+ // Sometimes plugins like to set Content-Length themselves when they post,
+ // but WebFoundation does not like that. So we will remove the header
+ // and instead truncate the data to the requested length.
+ NSString *contentLength = [header objectForKey:@"Content-Length"];
- if (contentLength != nil) {
- dataLength = MIN((unsigned)[contentLength intValue], dataLength);
- }
- [header removeObjectForKey:@"Content-Length"];
+ if (contentLength != nil)
+ dataLength = MIN((unsigned)[contentLength intValue], dataLength);
+ [header removeObjectForKey:@"Content-Length"];
if ([header count] > 0) {
[request setAllHTTPHeaderFields:header];
-#ifndef _NPFUNCTIONS_H_
-#define _NPFUNCTIONS_H_
+#ifndef NPFUNCTIONS_H
+#define NPFUNCTIONS_H
#include <WebKit/npruntime.h>
#include <WebKit/npapi.h>
extern "C" {
#endif
-typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* URL, const char* window, void* notifyData);
+typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* URL, const char* window, void* notifyData);
typedef NPError (*NPN_PostURLNotifyProcPtr)(NPP instance, const char* URL, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData);
-typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList);
-typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
+typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList);
+typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
typedef int32 (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32 len, void* buffer);
typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
typedef void (*NPN_StatusProcPtr)(NPP instance, const char* message);
typedef void (*NPN_MemFreeProcPtr)(void* ptr);
typedef uint32 (*NPN_MemFlushProcPtr)(uint32 size);
typedef void (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages);
-typedef NPError (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value);
-typedef NPError (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *value);
+typedef NPError (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value);
+typedef NPError (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *value);
typedef void (*NPN_InvalidateRectProcPtr)(NPP instance, NPRect *rect);
typedef void (*NPN_InvalidateRegionProcPtr)(NPP instance, NPRegion region);
typedef void (*NPN_ForceRedrawProcPtr)(NPP instance);
-typedef NPError (*NPN_GetURLProcPtr)(NPP instance, const char* URL, const char* window);
+typedef NPError (*NPN_GetURLProcPtr)(NPP instance, const char* URL, const char* window);
typedef NPError (*NPN_PostURLProcPtr)(NPP instance, const char* URL, const char* window, uint32 len, const char* buf, NPBool file);
typedef void* (*NPN_GetJavaEnvProcPtr)(void);
typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance);
typedef bool (*NPN_RemovePropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier propertyName);
typedef void (*NPN_SetExceptionProcPtr) (NPObject *obj, const NPUTF8 *message);
-typedef NPError (*NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
-typedef NPError (*NPP_DestroyProcPtr)(NPP instance, NPSavedData** save);
-typedef NPError (*NPP_SetWindowProcPtr)(NPP instance, NPWindow* window);
-typedef NPError (*NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
-typedef NPError (*NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
-typedef void (*NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname);
+typedef NPError (*NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
+typedef NPError (*NPP_DestroyProcPtr)(NPP instance, NPSavedData** save);
+typedef NPError (*NPP_SetWindowProcPtr)(NPP instance, NPWindow* window);
+typedef NPError (*NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
+typedef NPError (*NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
+typedef void (*NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname);
typedef int32 (*NPP_WriteReadyProcPtr)(NPP instance, NPStream* stream);
typedef int32 (*NPP_WriteProcPtr)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer);
typedef void (*NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint);
typedef int16 (*NPP_HandleEventProcPtr)(NPP instance, void* event);
typedef void (*NPP_URLNotifyProcPtr)(NPP instance, const char* URL, NPReason reason, void* notifyData);
-typedef NPError (*NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value);
-typedef NPError (*NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value);
+typedef NPError (*NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value);
+typedef NPError (*NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value);
typedef void (*NPP_ShutdownProcPtr)(void);
typedef void *(*NPP_GetJavaClassProcPtr)(void);
-typedef void* JRIGlobalRef; //not using this right now
+typedef void* JRIGlobalRef; //not using this right now
typedef struct _NPNetscapeFuncs {
uint16 size;
#if defined(XP_MACOSX)
typedef NPError (*NP_InitializeFuncPtr)(NPNetscapeFuncs*);
typedef NPError (*NP_GetEntryPointsFuncPtr)(NPPluginFuncs*);
-typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
+typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
typedef NPError (*MainFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownProcPtr*);
#endif
}
+ (WebSubresourceLoader *)startLoadingResource:(id <WebCoreResourceLoader>)rLoader
- withRequest:(NSMutableURLRequest *)newRequest
+ withRequest:(NSMutableURLRequest *)newRequest
customHeaders:(NSDictionary *)customHeaders
- referrer:(NSString *)referrer
- forDataSource:(WebDataSource *)source
+ referrer:(NSString *)referrer
+ forDataSource:(WebDataSource *)source
{
WebSubresourceLoader *loader = [[[self alloc] initWithLoader:rLoader dataSource:source] autorelease];
NSEnumerator *e = [customHeaders keyEnumerator];
NSString *key;
while ((key = [e nextObject])) {
- [newRequest addValue:[customHeaders objectForKey:key] forHTTPHeaderField:key];
+ [newRequest addValue:[customHeaders objectForKey:key] forHTTPHeaderField:key];
}
// Use the original request's cache policy for two reasons:
NSURLRequest *clientRequest = [super willSendRequest:newRequest redirectResponse:redirectResponse];
if (clientRequest != nil && oldURL != [clientRequest URL] && ![oldURL isEqual:[clientRequest URL]])
- [coreLoader redirectedToURL:[clientRequest URL]];
+ [coreLoader redirectedToURL:[clientRequest URL]];
return clientRequest;
}
-(void)continueAfterNavigationPolicy:(NSURLRequest *)_request formState:(WebFormState *)state
{
if (!_request) {
- [self stopLoadingForPolicyChange];
+ [self stopLoadingForPolicyChange];
}
}
{
// Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks (4120255).
BOOL isRemote = ![URL isFileURL] && ![WebDataProtocol _webIsDataProtocolURL:URL];
- BOOL isRemoteWebArchive = isRemote && [MIMEType _webkit_isCaseInsensitiveEqualToString:@"application/x-webarchive"];
+ BOOL isRemoteWebArchive = isRemote && [MIMEType _webkit_isCaseInsensitiveEqualToString:@"application/x-webarchive"];
if (![WebDataSource _canShowMIMEType:MIMEType] || isRemoteWebArchive) {
- [[dataSource webFrame] _handleUnimplementablePolicyWithErrorCode:WebKitErrorCannotShowMIMEType forURL:URL];
+ [[dataSource webFrame] _handleUnimplementablePolicyWithErrorCode:WebKitErrorCannotShowMIMEType forURL:URL];
// Check reachedTerminalState since the load may have already been cancelled inside of _handleUnimplementablePolicyWithErrorCode::.
if (!reachedTerminalState) {
[self stopLoadingForPolicyChange];
}
- return;
- }
+ return;
+ }
break;
}
case WebPolicyDownload:
return;
case WebPolicyIgnore:
- [self stopLoadingForPolicyChange];
- return;
+ [self stopLoadingForPolicyChange];
+ return;
default:
- ASSERT_NOT_REACHED();
+ ASSERT_NOT_REACHED();
}
[self retain];
-(void)checkContentPolicyForResponse:(NSURLResponse *)r
{
WebPolicyDecisionListener *l = [[WebPolicyDecisionListener alloc]
- _initWithTarget:self action:@selector(continueAfterContentPolicy:)];
+ _initWithTarget:self action:@selector(continueAfterContentPolicy:)];
listener = l;
policyResponse = [r retain];
NSURLResponse *resp = [[NSURLResponse alloc] initWithURL:URL MIMEType:MIMEType
expectedContentLength:0 textEncodingName:nil];
- [self didReceiveResponse:resp];
- [resp release];
+ [self didReceiveResponse:resp];
+ [resp release];
} else {
connection = [[NSURLConnection alloc] initWithRequest:r delegate:proxy];
}
// Element dictionary keys
extern NSString *WebElementDOMNodeKey; // DOMNode of the element
-extern NSString *WebElementFrameKey; // WebFrame of the element
-extern NSString *WebElementImageAltStringKey; // NSString of the ALT attribute of the image element
-extern NSString *WebElementImageKey; // NSImage of the image element
-extern NSString *WebElementImageRectKey; // NSValue of an NSRect, the rect of the image element
-extern NSString *WebElementImageURLKey; // NSURL of the image element
-extern NSString *WebElementIsSelectedKey; // NSNumber of BOOL indicating whether the element is selected or not
-extern NSString *WebElementLinkURLKey; // NSURL of the link if the element is within an anchor
-extern NSString *WebElementLinkTargetFrameKey; // WebFrame of the target of the anchor
-extern NSString *WebElementLinkTitleKey; // NSString of the title of the anchor
-extern NSString *WebElementLinkLabelKey; // NSString of the text within the anchor
+extern NSString *WebElementFrameKey; // WebFrame of the element
+extern NSString *WebElementImageAltStringKey; // NSString of the ALT attribute of the image element
+extern NSString *WebElementImageKey; // NSImage of the image element
+extern NSString *WebElementImageRectKey; // NSValue of an NSRect, the rect of the image element
+extern NSString *WebElementImageURLKey; // NSURL of the image element
+extern NSString *WebElementIsSelectedKey; // NSNumber of BOOL indicating whether the element is selected or not
+extern NSString *WebElementLinkURLKey; // NSURL of the link if the element is within an anchor
+extern NSString *WebElementLinkTargetFrameKey; // WebFrame of the target of the anchor
+extern NSString *WebElementLinkTitleKey; // NSString of the title of the anchor
+extern NSString *WebElementLinkLabelKey; // NSString of the text within the anchor
/*
@discussion Notifications sent by WebView to mark the progress of loads.
- (void)_addToAllWebViewsSet
{
if (!allWebViewsSet)
- allWebViewsSet = CFSetCreateMutable(NULL, 0, &NonRetainingSetCallbacks);
+ allWebViewsSet = CFSetCreateMutable(NULL, 0, &NonRetainingSetCallbacks);
CFSetSetValue(allWebViewsSet, self);
}
NSRect htmlViewRect = [[[[self mainFrame] frameView] documentView] frame];
if (debugWidget) {
- while (debugWidget) {
- sleep (1);
- }
+ while (debugWidget) {
+ sleep (1);
+ }
}
NSLog (@"%s: rect: (%0.f,%0.f) %0.f %0.f, htmlViewRect: (%0.f,%0.f) %0.f %0.f\n",
- __PRETTY_FUNCTION__, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height,
- htmlViewRect.origin.x, htmlViewRect.origin.y, htmlViewRect.size.width, htmlViewRect.size.height
- );
+ __PRETTY_FUNCTION__, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height,
+ htmlViewRect.origin.x, htmlViewRect.origin.y, htmlViewRect.size.width, htmlViewRect.size.height
+ );
[super drawRect:rect];
}
// in the back forward list, and go to the current one.
WebBackForwardList *bfList = [self backForwardList];
- ASSERT(![bfList currentItem]); // destination list should be empty
+ ASSERT(![bfList currentItem]); // destination list should be empty
WebBackForwardList *otherBFList = [otherView backForwardList];
if (![otherBFList currentItem]) {
- return; // empty back forward list, bail
+ return; // empty back forward list, bail
}
WebHistoryItem *newItemToGoTo = nil;
}
case WebDashboardBehaviorAllowWheelScrolling: {
_private->dashboardBehaviorAllowWheelScrolling = flag;
- break;
+ break;
}
}
}
if (!self)
return nil;
- target = t; // Non retained.
+ target = t; // Non retained.
defaultTarget = dt;
templateClass = aClass;
return self;
frameName = [decoder decodeObjectForKey:@"FrameName"];
groupName = [decoder decodeObjectForKey:@"GroupName"];
preferences = [decoder decodeObjectForKey:@"Preferences"];
- useBackForwardList = [decoder decodeBoolForKey:@"UseBackForwardList"];
+ useBackForwardList = [decoder decodeBoolForKey:@"UseBackForwardList"];
} else {
int version;
[decoder decodeValueOfObjCType:@encode(int) at:&version];
[encoder encodeObject:[[self mainFrame] name] forKey:@"FrameName"];
[encoder encodeObject:[self groupName] forKey:@"GroupName"];
[encoder encodeObject:[self preferences] forKey:@"Preferences"];
- [encoder encodeBool:_private->useBackForwardList forKey:@"UseBackForwardList"];
+ [encoder encodeBool:_private->useBackForwardList forKey:@"UseBackForwardList"];
} else {
int version = WebViewVersion;
[encoder encodeValueOfObjCType:@encode(int) at:&version];
return [[[self mainFrame] _bridge] windowScriptObject];
}
-
// Get the appropriate user-agent string for a particular URL.
// Since we no longer automatically spoof, this no longer requires looking at the URL.
- (NSString *)userAgentForURL:(NSURL *)URL
[[self mainFrame] reload];
}
-#define MinimumTextSizeMultiplier 0.5
-#define MaximumTextSizeMultiplier 3.0
-#define TextSizeMultiplierRatio 1.2
+#define MinimumTextSizeMultiplier 0.5
+#define MaximumTextSizeMultiplier 3.0
+#define TextSizeMultiplierRatio 1.2
- (BOOL)canMakeTextSmaller
{
SEL action = [item action];
if (action == @selector(goBack:)) {
- return [self canGoBack];
+ return [self canGoBack];
} else if (action == @selector(goForward:)) {
- return [self canGoForward];
+ return [self canGoForward];
} else if (action == @selector(makeTextLarger:)) {
- return [self canMakeTextLarger];
+ return [self canMakeTextLarger];
} else if (action == @selector(makeTextSmaller:)) {
- return [self canMakeTextSmaller];
+ return [self canMakeTextSmaller];
} else if (action == @selector(makeTextStandardSize:)) {
- return [self canMakeTextStandardSize];
+ return [self canMakeTextStandardSize];
} else if (action == @selector(reload:)) {
- return [[self mainFrame] dataSource] != nil;
+ return [[self mainFrame] dataSource] != nil;
} else if (action == @selector(stopLoading:)) {
- return [self _isLoading];
+ return [self _isLoading];
} else if (action == @selector(toggleContinuousSpellChecking:)) {
BOOL checkMark = NO;
BOOL retVal = NO;
- if ([self _continuousCheckingAllowed]) {
+ if ([self _continuousCheckingAllowed]) {
checkMark = [self isContinuousSpellCheckingEnabled];
retVal = YES;
}