[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:40:24 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit f00dcdd14920ded18b30af424ce652d9d08b189f
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue May 18 23:15:30 2004 +0000

    WebKit:
    		Added WebKit portion of webView:windowScriptObjectAvailable:
    		implementation.  Still need to implement creating the WebScriptObject
    		wrapper on the WebCore side.
    
            Reviewed by Maciej.
    
    		Removed "_" from _setPageWidthForPrinting:.  This method facilitates
    		a work-around for carbon printing.  At some point we may make this
    		method public API.
    
            Reviewed by Chris.
    
            * WebCoreSupport.subproj/WebBridge.m:
            (-[WebBridge overrideMediaType]):
            (-[WebBridge windowObjectCleared]):
            * WebView.subproj/WebDefaultFrameLoadDelegate.m:
            (-[WebDefaultFrameLoadDelegate webView:windowScriptObjectAvailable:]):
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView setPageWidthForPrinting:]):
    
    WebCore:
    	Added stubs to get the WebScriptObject for the window
    	JS object.
    
    	Made updateRenderingForBindings more robust when handed a
    	nil root object.  This was causing a crash in DB.  Still need to
    	address root cause of nil root object.
    
            Reviewed by Maciej.
    
            * khtml/khtml_part.cpp:
            (KHTMLPart::begin):
            * kwq/KWQKHTMLPart.h:
            * kwq/KWQKHTMLPart.mm:
            (KWQKHTMLPart::windowScriptObject):
            (KWQKHTMLPart::partClearedInBegin):
            * kwq/WebCoreBridge.h:
            * kwq/WebCoreBridge.mm:
            (updateRenderingForBindings):
            (-[WebCoreBridge init]):
            (-[WebCoreBridge stringByEvaluatingJavaScriptFromString:]):
            (-[WebCoreBridge windowScriptObject]):
    
    JavaScriptCore:
    	Use KVC to set/get values instead of directly accessing
    	ivars.
    
            Reviewed by Maciej.
    
            * bindings/objc/WebScriptObject.mm:
            (-[WebScriptObject callWebScriptMethod:withArguments:]):
            (+[WebScriptObject _convertValueToObjcValue:KJS::root:Bindings::]):
            * bindings/objc/objc_runtime.mm:
            (ObjcField::valueFromInstance):
            (convertValueToObjcObject):
            (ObjcField::setValueToInstance):
    
    WebKitExamples:
    	Changed printing work-around to use a method that may be
    	made public at some point in the future.
    
            Reviewed by Chris.
    
            * CarbonWeb/TWebWindow.cp:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6626 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 0529e57..10ff84b 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,18 @@
+2004-05-18  Richard Williamson   <rjw at apple.com>
+
+	Use KVC to set/get values instead of directly accessing
+	ivars.
+
+        Reviewed by Maciej.
+
+        * bindings/objc/WebScriptObject.mm:
+        (-[WebScriptObject callWebScriptMethod:withArguments:]):
+        (+[WebScriptObject _convertValueToObjcValue:KJS::root:Bindings::]):
+        * bindings/objc/objc_runtime.mm:
+        (ObjcField::valueFromInstance):
+        (convertValueToObjcObject):
+        (ObjcField::setValueToInstance):
+
 2004-05-17  Richard Williamson   <rjw at apple.com>
 
 	Implemented new API for WebScriptObject.
diff --git a/JavaScriptCore/bindings/objc/WebScriptObject.mm b/JavaScriptCore/bindings/objc/WebScriptObject.mm
index fafe638..558bd75 100644
--- a/JavaScriptCore/bindings/objc/WebScriptObject.mm
+++ b/JavaScriptCore/bindings/objc/WebScriptObject.mm
@@ -121,10 +121,10 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
     }
 
     // Call the function object.    
+    Interpreter::lock();
     ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
     Object thisObj = Object(const_cast<ObjectImp*>(_private->imp));
     List argList = listFromNSArray(exec, args);
-    Interpreter::lock();
     Value result = funcImp->call (exec, thisObj, argList);
     Interpreter::unlock();
 
@@ -240,7 +240,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
 + (id)_convertValueToObjcValue:(KJS::Value)value root:(const Bindings::RootObject *)root
 {
     id result = 0;
-   
+
     // First see if we have a ObjC instance.
     if (value.type() == KJS::ObjectType){
         ObjectImp *objectImp = static_cast<ObjectImp*>(value.imp());
diff --git a/JavaScriptCore/bindings/objc/objc_runtime.mm b/JavaScriptCore/bindings/objc/objc_runtime.mm
index f4ff21d..0b4582f 100644
--- a/JavaScriptCore/bindings/objc/objc_runtime.mm
+++ b/JavaScriptCore/bindings/objc/objc_runtime.mm
@@ -82,142 +82,55 @@ RuntimeType ObjcField::type() const
 Value ObjcField::valueFromInstance(KJS::ExecState *exec, const Instance *instance) const
 {
     Value aValue;
-    char *ivarValuePtr = ((char *)(static_cast<const ObjcInstance*>(instance))->getObject() + _ivar->ivar_offset);
-
-    ObjcValueType ctype = objcValueTypeForType(_ivar->ivar_type);
-    switch (ctype){
-        case ObjcVoidType: {
-            aValue = Undefined();
-        }
-        break;
-        
-        case ObjcObjectType: {
-            ObjectStructPtr obj = *(ObjectStructPtr *)(ivarValuePtr);
-            if ([obj isKindOfClass:[WebScriptObject class]]) {
-                WebScriptObject *jsobject = (WebScriptObject *)obj;
-                aValue = Object([jsobject _imp]);
-            }
-            else {
-                Instance *anInstance = Instance::createBindingForLanguageInstance (Instance::ObjectiveCLanguage, (void *)obj);
-                aValue = Object(new RuntimeObjectImp(anInstance,true));
-            }
-        }
-        break;
-        
-        case ObjcCharType: {
-            char aChar = *(char *)(ivarValuePtr);
-            aValue = Number(aChar);
-        }
-        break;
-        
-        case ObjcShortType: {
-            short aShort = *(short *)(ivarValuePtr);
-            aValue = Number(aShort);
-        }
-        break;
-        
-        case ObjcIntType: {
-            int anInt = *(int *)(ivarValuePtr);
-            aValue = Number(anInt);
-        }
-        break;
-        
-        case ObjcLongType: {
-            long aLong = *(long *)(ivarValuePtr);
-            aValue = Number(aLong);
-        }
-        break;
+    id targetObject = (static_cast<const ObjcInstance*>(instance))->getObject();
+    id objcValue = nil;
+
+    NS_DURING
+    
+        NSString *key = [NSString stringWithCString:_ivar->ivar_name];
+        objcValue = [targetObject valueForKey:key];
         
-        case ObjcFloatType: {
-            float aFloat = *(float *)(ivarValuePtr);
-            aValue = Number(aFloat);
-        }
-        break;
+    NS_HANDLER
         
-        case ObjcDoubleType: {
-            double aDouble = *(double *)(ivarValuePtr);
-            aValue = Number(aDouble);
-        }
-        break;
+        Value exceptionValue = Error::create(exec, GeneralError, [[localException reason] lossyCString]);
+        exec->setException(exceptionValue);
         
-        case ObjcInvalidType:
-        default: {
-            aValue = Error::create(exec, TypeError, "Invalid ObjectiveC type.");
-            exec->setException(aValue);
-        }
-        break;
-    }
+    NS_ENDHANDLER
+
+    if (objcValue)
+        aValue = convertObjcValueToValue (exec, &objcValue, ObjcObjectType);
+
     return aValue;
 }
 
+static id convertValueToObjcObject (KJS::ExecState *exec, const KJS::Value &value)
+{
+    const Bindings::RootObject *root = rootForInterpreter(exec->interpreter());
+    if (!root) {
+        Bindings::RootObject *newRoot = new KJS::Bindings::RootObject(0);
+        newRoot->setInterpreter (exec->interpreter());
+        root = newRoot;
+    }
+    return [WebScriptObject _convertValueToObjcValue:value root:root];
+}
+
+
 void ObjcField::setValueToInstance(KJS::ExecState *exec, const Instance *instance, const KJS::Value &aValue) const
 {
-    char *ivarValuePtr = ((char *)(static_cast<const ObjcInstance*>(instance))->getObject() + _ivar->ivar_offset);
-
-    ObjcValueType ctype = objcValueTypeForType(_ivar->ivar_type);
-    ObjcValue result = convertValueToObjcValue(exec, aValue, ctype);
-    switch (ctype){
-        case ObjcVoidType: {
-        }
-        break;
-        
-        case ObjcObjectType: {
-            // First see if we have an ObjC instance.
-            if (aValue.type() == KJS::ObjectType){
-                ObjcValue result = convertValueToObjcValue(exec, aValue, objcValueTypeForType(_ivar->ivar_type));
-                
-                // Release the previous value.
-                [*(ObjectStructPtr *)(ivarValuePtr) autorelease];
-                
-                // Retain the new value.
-                *(ObjectStructPtr *)(ivarValuePtr) = [result.objectValue retain];
-            }
-            
-            // FIXME.  Deal with numbers.
-            
-            // FIXME.  Deal with arrays.
-            
-            // FIXME.  Deal with strings.
-        }
-        break;
-        
-        case ObjcCharType: {
-            *(char *)(ivarValuePtr) = result.charValue;
-        }
-        break;
-        
-        case ObjcShortType: {
-            *(short *)(ivarValuePtr) = result.shortValue;
-        }
-        break;
-        
-        case ObjcIntType: {
-            *(int *)(ivarValuePtr) = result.intValue;
-        }
-        break;
-        
-        case ObjcLongType: {
-            *(long *)(ivarValuePtr) = result.longValue;
-        }
-        break;
+    id targetObject = (static_cast<const ObjcInstance*>(instance))->getObject();
+    id value = convertValueToObjcObject(exec, aValue);
+    
+    NS_DURING
+    
+        NSString *key = [NSString stringWithCString:_ivar->ivar_name];
+        [targetObject setValue:value forKey:key];
         
-        case ObjcFloatType: {
-            *(float *)(ivarValuePtr) = result.floatValue;
-        }
-        break;
+    NS_HANDLER
         
-        case ObjcDoubleType: {
-            *(double *)(ivarValuePtr) = result.doubleValue;
-        }
-        break;
+        Value aValue = Error::create(exec, GeneralError, [[localException reason] lossyCString]);
+        exec->setException(aValue);
         
-        case ObjcInvalidType:
-        default: {
-            Object error = Error::create(exec, TypeError, "Invalid ObjectiveC type.");
-            exec->setException(error);
-        }
-        break;
-    }
+    NS_ENDHANDLER
 }
 
 // ---------------------- ObjcArray ----------------------
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 6b3f8d8..3c1df70 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,27 @@
+2004-05-18  Richard Williamson   <rjw at apple.com>
+
+	Added stubs to get the WebScriptObject for the window
+	JS object.
+	
+	Made updateRenderingForBindings more robust when handed a
+	nil root object.  This was causing a crash in DB.  Still need to
+	address root cause of nil root object.
+
+        Reviewed by Maciej.
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::begin):
+        * kwq/KWQKHTMLPart.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::windowScriptObject):
+        (KWQKHTMLPart::partClearedInBegin):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (updateRenderingForBindings):
+        (-[WebCoreBridge init]):
+        (-[WebCoreBridge stringByEvaluatingJavaScriptFromString:]):
+        (-[WebCoreBridge windowScriptObject]):
+
 2004-05-17  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Ken.
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index b755cf8..5098d83 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -1420,6 +1420,10 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
 
   clear();
 
+#if APPLE_CHANGE
+  KWQ(this)->partClearedInBegin();
+#endif
+
   // Only do this after clearing the part, so that JavaScript can
   // clean up properly if it was on for the last load.
 #if !APPLE_CHANGES
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index 247e89e..10db20b 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -72,6 +72,7 @@ typedef DOMElement ObjCDOMElement;
 @class NSString;
 @class NSView;
 @class WebCoreBridge;
+ at class WebScriptObject;
 
 #else
 
@@ -89,6 +90,7 @@ class NSResponder;
 class NSString;
 class NSView;
 class WebCoreBridge;
+class WebScriptObject;
 
 #endif
 
@@ -282,8 +284,11 @@ public:
     void postDidChangeSelectionNotification();
     void postDidChangeNotification();
 
+    WebScriptObject *windowScriptObject();
     void bindObject(void *object, QString name);
     
+    void partClearedInBegin();
+    
 private:
     virtual void khtmlMousePressEvent(khtml::MousePressEvent *);
     virtual void khtmlMouseDoubleClickEvent(khtml::MouseDoubleClickEvent *);
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 7bfaff6..8a6b1bd 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -62,6 +62,7 @@
 #import <JavaScriptCore/property_map.h>
 #import <JavaScriptCore/runtime.h>
 #import <JavaScriptCore/runtime_root.h>
+#import <JavaScriptCore/WebScriptObject.h>
 
 #undef _KWQ_TIMING
 
@@ -1130,6 +1131,12 @@ bool KWQKHTMLPart::tabsToAllControls() const
         return KWQKHTMLPart::currentEventIsKeyboardOptionTab();
 }
 
+WebScriptObject *KWQKHTMLPart::windowScriptObject()
+{
+    // FIXME:  Create a WindowScriptObject wrapper.
+    return 0;
+}
+
 void KWQKHTMLPart::bindObject(void *object, QString name)
 {
     if (d->m_doc && jScript()) {
@@ -1138,6 +1145,10 @@ void KWQKHTMLPart::bindObject(void *object, QString name)
     }
 }
 
+void KWQKHTMLPart::partClearedInBegin()
+{
+    [_bridge windowObjectCleared];
+}
 
 QMap<int, ScheduledAction*> *KWQKHTMLPart::pauseActions(const void *key)
 {
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 4ab44a5..d2e7ce5 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -58,6 +58,7 @@ typedef khtml::RenderPart KHTMLRenderPart;
 @class DOMNode;
 @class DOMRange;
 @class WebCoreSettings;
+ at class WebScriptObject;
 
 @protocol WebCoreDOMTreeCopier;
 @protocol WebCoreRenderTreeCopier;
@@ -295,6 +296,7 @@ typedef enum {
 - (void)applyStyle:(DOMCSSStyleDeclaration *)style;
 - (void)ensureCaretVisible;
 
+- (WebScriptObject *)windowScriptObject;
 - (void)bindObject:(id)object withName:(NSString *)name;
 
 @end
@@ -450,6 +452,8 @@ typedef enum {
 
 - (NSString *)overrideMediaType;
 
+- (void)windowObjectCleared;
+
 @end
 
 // This interface definition allows those who hold a WebCoreBridge * to call all the methods
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index e0745ec..f9f84a0 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -149,9 +149,20 @@ static RootObject *rootForView(void *v)
     return 0;
 }
 
+static pthread_t mainThread = 0;
+
 static void updateRenderingForBindings (KJS::ExecState *exec, KJS::ObjectImp *rootObject)
 {
+    if (pthread_self() != mainThread)
+        return;
+        
+    if (!rootObject)
+        return;
+        
     KJS::Window *window = static_cast<KJS::Window*>(rootObject);
+    if (!window)
+        return;
+        
     DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl*>(window->part()->document().handle());
     doc->updateRendering();
 }
@@ -180,6 +191,8 @@ static bool initializedKJS = FALSE;
     }
     
     if (!initializedKJS) {
+        mainThread = pthread_self();
+        
         KJS::Bindings::RootObject::setFindRootObjectForNativeHandleFunction (rootForView);
         
         KJS::Bindings::Instance::setDidExecuteFunction(updateRenderingForBindings);
@@ -1079,6 +1092,11 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return _part->executeScript(QString::fromNSString(string), true).asString().getNSString();
 }
 
+- (WebScriptObject *)windowScriptObject
+{
+    return _part->windowScriptObject();
+}
+
 - (void)bindObject:(id)object withName:(NSString *)name
 {
     // Create an empty document, if necessary.  
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 90cce53..da03e3d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,25 @@
+2004-05-18  Richard Williamson   <rjw at apple.com>
+
+		Added WebKit portion of webView:windowScriptObjectAvailable:
+		implementation.  Still need to implement creating the WebScriptObject
+		wrapper on the WebCore side.
+		
+        Reviewed by Maciej.
+
+		Removed "_" from _setPageWidthForPrinting:.  This method facilitates
+		a work-around for carbon printing.  At some point we may make this
+		method public API.
+		
+        Reviewed by Chris.
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge overrideMediaType]):
+        (-[WebBridge windowObjectCleared]):
+        * WebView.subproj/WebDefaultFrameLoadDelegate.m:
+        (-[WebDefaultFrameLoadDelegate webView:windowScriptObjectAvailable:]):
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView setPageWidthForPrinting:]):
+
 2004-05-18  Darin Adler  <darin at apple.com>
 
         Reviewed by John.
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 96a7c60..a38ed35 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -16,6 +16,7 @@
 #import <WebKit/WebEditingDelegate.h>
 #import <WebKit/WebFileButton.h>
 #import <WebKit/WebFormDelegate.h>
+#import <WebKit/WebFrameLoadDelegate.h>
 #import <WebKit/WebFramePrivate.h>
 #import <WebKit/WebFrameViewPrivate.h>
 #import <WebKit/WebHistoryItemPrivate.h>
@@ -1278,4 +1279,10 @@ static id <WebFormDelegate> formDelegate(WebBridge *self)
     return [[_frame webView] mediaStyle];
 }
 
+- (void)windowObjectCleared
+{
+    WebView *wv = [_frame webView];
+    [[wv _frameLoadDelegateForwarder] webView:wv windowScriptObjectAvailable:[self windowScriptObject]];
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebDefaultFrameLoadDelegate.m b/WebKit/WebView.subproj/WebDefaultFrameLoadDelegate.m
index 7b95939..ca41591 100644
--- a/WebKit/WebView.subproj/WebDefaultFrameLoadDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultFrameLoadDelegate.m
@@ -5,6 +5,7 @@
 #import <WebKit/WebDefaultFrameLoadDelegate.h>
 #import <WebKit/WebDataSource.h>
 #import <WebKit/WebFrame.h>
+#import <WebKit/WebScriptObject.h>
 
 @implementation WebDefaultFrameLoadDelegate
 
@@ -44,4 +45,6 @@ static WebDefaultFrameLoadDelegate *sharedDelegate = nil;
 
 - (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame { }
 
+- (void)webView:(WebView *)sender windowScriptObjectAvailable:(WebScriptObject *)obj { }
+
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 7641998..2d058d8 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -1930,7 +1930,7 @@ static WebHTMLView *lastHitView = nil;
     return [self _scaleFactorForPrintOperation:printOperation];
 }
 
-- (void)_setPageWidthForPrinting:(float)pageWidth
+- (void)setPageWidthForPrinting:(float)pageWidth
 {
     [self _setPrinting:NO minimumPageWidth:0. maximumPageWidth:0. adjustViewSize:NO];
     [self _setPrinting:YES minimumPageWidth:pageWidth maximumPageWidth:pageWidth adjustViewSize:YES];

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list