[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:52 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 0317cec970d5809c622db8a5e2cd7c486b0057fa
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu May 20 22:13:48 2004 +0000
WebKit:
Fixed typo in header comment.
Reviewed by Ken.
* Plugins.subproj/WebScriptObject.h:
WebCore:
Implemented WebScriptObject/DOM wrapper voodoo. DOM wrappers
can now be referenced like any other WebScriptObject, meaning
you can do JS operations on them.
All added implementation of finalizeForWebScript.
Reviewed by Ken.
* kwq/DOM.mm:
(-[DOMObject _init]):
* kwq/DOMInternal.mm:
(-[WebScriptObject _init]):
(-[WebScriptObject _initializeScriptDOMNodeImp]):
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::KWQKHTMLPart):
(KWQKHTMLPart::bindingRootObject):
(KWQKHTMLPart::windowScriptObject):
JavaScriptCore:
Implemented WebScriptObject/DOM wrapper voodoo. DOM wrappers
can now be referenced like any other WebScriptObject, meaning
you can do JS operations on them.
All added implementation of finalizeForWebScript.
Reviewed by Ken.
* bindings/objc/WebScriptObject.h:
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject _initializeWithObjectImp:KJS::root:Bindings::]):
(-[WebScriptObject _initWithObjectImp:KJS::root:Bindings::]):
(-[WebScriptObject KJS::]):
(-[WebScriptObject dealloc]):
(-[WebScriptObject callWebScriptMethod:withArguments:]):
(-[WebScriptObject evaluateWebScript:]):
(-[WebScriptObject setValue:forKey:]):
(-[WebScriptObject valueForKey:]):
(-[WebScriptObject stringRepresentation]):
* bindings/objc/WebScriptObjectPrivate.h:
* bindings/objc/objc_instance.mm:
(ObjcInstance::~ObjcInstance):
WebBrowser:
Added some debugging for WebScriptObject, disabled by default.
Reviewed by Ken.
* LocationChangeHandler.m:
(-[LocationChangeHandler webView:windowScriptObjectAvailable:]):
(-[LocationChangeHandler webView:locationChangeDone:forDataSource:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index de3e8b9..95030d7 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,28 @@
+2004-05-20 Richard Williamson <rjw at apple.com>
+
+ Implemented WebScriptObject/DOM wrapper voodoo. DOM wrappers
+ can now be referenced like any other WebScriptObject, meaning
+ you can do JS operations on them.
+
+ All added implementation of finalizeForWebScript.
+
+ Reviewed by Ken.
+
+ * bindings/objc/WebScriptObject.h:
+ * bindings/objc/WebScriptObject.mm:
+ (-[WebScriptObject _initializeWithObjectImp:KJS::root:Bindings::]):
+ (-[WebScriptObject _initWithObjectImp:KJS::root:Bindings::]):
+ (-[WebScriptObject KJS::]):
+ (-[WebScriptObject dealloc]):
+ (-[WebScriptObject callWebScriptMethod:withArguments:]):
+ (-[WebScriptObject evaluateWebScript:]):
+ (-[WebScriptObject setValue:forKey:]):
+ (-[WebScriptObject valueForKey:]):
+ (-[WebScriptObject stringRepresentation]):
+ * bindings/objc/WebScriptObjectPrivate.h:
+ * bindings/objc/objc_instance.mm:
+ (ObjcInstance::~ObjcInstance):
+
2004-05-19 Richard Williamson <rjw at apple.com>
Removed extraneous tabs that were added (by XCode?).
diff --git a/JavaScriptCore/bindings/objc/WebScriptObject.h b/JavaScriptCore/bindings/objc/WebScriptObject.h
index 1d51452..f581d75 100644
--- a/JavaScriptCore/bindings/objc/WebScriptObject.h
+++ b/JavaScriptCore/bindings/objc/WebScriptObject.h
@@ -125,9 +125,9 @@
/*!
@method finalizeForWebScript
@discussion finalizeForScript is called on objects exposed to the script
- environment just before the script environment is reset. After calls to
- finalizeForScript the object will no longer be referenced by the script environment.
- Further any references to WebScriptObjects made by the exposed object will
+ 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.
*/
- (void)finalizeForWebScript;
diff --git a/JavaScriptCore/bindings/objc/WebScriptObject.mm b/JavaScriptCore/bindings/objc/WebScriptObject.mm
index 3bf919a..77bd951 100644
--- a/JavaScriptCore/bindings/objc/WebScriptObject.mm
+++ b/JavaScriptCore/bindings/objc/WebScriptObject.mm
@@ -42,16 +42,15 @@ using namespace KJS::Bindings;
if (Interpreter::shouldPrintExceptions()) \
NSLog (@"%s:%d: JavaScript exception: %s\n", __FILE__, __LINE__, exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii());
- at interface WebScriptObjectPrivate : NSObject
+ at implementation WebScriptObjectPrivate
+- (void)dealloc
{
- KJS::ObjectImp *imp;
- const Bindings::RootObject *root;
+ removeNativeReference (imp);
+
+ [super dealloc];
}
@end
- at implementation WebScriptObjectPrivate
- at end
-
@implementation WebScriptObject
static void _didExecute(WebScriptObject *obj)
@@ -62,6 +61,14 @@ static void _didExecute(WebScriptObject *obj)
func (exec, static_cast<KJS::ObjectImp*>(obj->_private->root->rootObjectImp()));
}
+- (void)_initializeWithObjectImp:(KJS::ObjectImp *)imp root:(const Bindings::RootObject *)root
+{
+ _private->imp = imp;
+ _private->root = root;
+
+ addNativeReference (root, imp);
+}
+
- _initWithObjectImp:(KJS::ObjectImp *)imp root:(const Bindings::RootObject *)root
{
assert (imp != 0);
@@ -70,24 +77,26 @@ static void _didExecute(WebScriptObject *obj)
self = [super init];
_private = [[WebScriptObjectPrivate alloc] init];
- _private->imp = imp;
- _private->root = root;
- addNativeReference (root, imp);
+ [self _initializeWithObjectImp:imp root:root];
return self;
}
- (KJS::ObjectImp *)_imp
{
+ if (!_private->imp && _private->isCreatedByDOMWrapper) {
+ // Associate the WebScriptObject with the JS wrapper for the ObjC DOM
+ // wrapper. This is done on lazily, on demand.
+ [self _initializeScriptDOMNodeImp];
+ }
return _private->imp;
}
- (void)dealloc
{
- if (_private)
- removeNativeReference (_private->imp);
[_private release];
+
[super dealloc];
}
@@ -117,7 +126,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
Value v = convertObjcValueToValue(exec, &name, ObjcObjectType);
Identifier identifier(v.toString(exec));
- Value func = _private->imp->get (exec, identifier);
+ Value func = [self _imp]->get (exec, identifier);
Interpreter::unlock();
if (func.isNull() || func.type() == UndefinedType) {
// Maybe throw an exception here?
@@ -127,7 +136,7 @@ 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));
+ Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
List argList = listFromNSArray(exec, args);
Value result = funcImp->call (exec, thisObj, argList);
Interpreter::unlock();
@@ -148,7 +157,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
- (id)evaluateWebScript:(NSString *)script
{
ExecState *exec = _private->root->interpreter()->globalExec();
- Object thisObj = Object(const_cast<ObjectImp*>(_private->imp));
+ Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
Interpreter::lock();
Value v = convertObjcValueToValue(exec, &script, ObjcObjectType);
KJS::Value result = _private->root->interpreter()->evaluate(v.toString(exec)).value();
@@ -171,7 +180,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
ExecState *exec = _private->root->interpreter()->globalExec();
Interpreter::lock();
Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
- _private->imp->put (exec, Identifier (v.toString(exec)), (convertObjcValueToValue(exec, &value, ObjcObjectType)));
+ [self _imp]->put (exec, Identifier (v.toString(exec)), (convertObjcValueToValue(exec, &value, ObjcObjectType)));
Interpreter::unlock();
if (exec->hadException()) {
@@ -186,7 +195,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
ExecState *exec = _private->root->interpreter()->globalExec();
Interpreter::lock();
Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
- Value result = _private->imp->get (exec, Identifier (v.toString(exec)));
+ Value result = [self _imp]->get (exec, Identifier (v.toString(exec)));
Interpreter::unlock();
if (exec->hadException()) {
@@ -206,7 +215,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
ExecState *exec = _private->root->interpreter()->globalExec();
Interpreter::lock();
Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
- _private->imp->deleteProperty (exec, Identifier (v.toString(exec)));
+ [self _imp]->deleteProperty (exec, Identifier (v.toString(exec)));
Interpreter::unlock();
if (exec->hadException()) {
@@ -219,7 +228,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
- (NSString *)stringRepresentation
{
Interpreter::lock();
- Object thisObj = Object(const_cast<ObjectImp*>(_private->imp));
+ Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
ExecState *exec = _private->root->interpreter()->globalExec();
id result = convertValueToObjcValue(exec, thisObj, ObjcObjectType).objectValue;
@@ -237,7 +246,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
{
ExecState *exec = _private->root->interpreter()->globalExec();
Interpreter::lock();
- Value result = _private->imp->get (exec, (unsigned)index);
+ Value result = [self _imp]->get (exec, (unsigned)index);
Interpreter::unlock();
if (exec->hadException()) {
@@ -256,7 +265,7 @@ static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
{
ExecState *exec = _private->root->interpreter()->globalExec();
Interpreter::lock();
- _private->imp->put (exec, (unsigned)index, (convertObjcValueToValue(exec, &value, ObjcObjectType)));
+ [self _imp]->put (exec, (unsigned)index, (convertObjcValueToValue(exec, &value, ObjcObjectType)));
Interpreter::unlock();
if (exec->hadException()) {
diff --git a/JavaScriptCore/bindings/objc/WebScriptObjectPrivate.h b/JavaScriptCore/bindings/objc/WebScriptObjectPrivate.h
index 480aecc..e72b708 100644
--- a/JavaScriptCore/bindings/objc/WebScriptObjectPrivate.h
+++ b/JavaScriptCore/bindings/objc/WebScriptObjectPrivate.h
@@ -14,8 +14,20 @@
@interface WebScriptObject (Private)
+ (id)_convertValueToObjcValue:(KJS::Value)value root:(const KJS::Bindings::RootObject *)root;
+- _init;
- _initWithObjectImp:(KJS::ObjectImp *)imp root:(const KJS::Bindings::RootObject *)root;
+- (void)_initializeWithObjectImp:(KJS::ObjectImp *)imp root:(const KJS::Bindings::RootObject *)root;
+- (void)_initializeScriptDOMNodeImp;
- (KJS::ObjectImp *)_imp;
@end
+ at interface WebScriptObjectPrivate : NSObject
+{
+ KJS::ObjectImp *imp;
+ const KJS::Bindings::RootObject *root;
+ BOOL isCreatedByDOMWrapper;
+}
+ at end
+
+
#endif
diff --git a/JavaScriptCore/bindings/objc/objc_instance.mm b/JavaScriptCore/bindings/objc/objc_instance.mm
index adac306..afb88d0 100644
--- a/JavaScriptCore/bindings/objc/objc_instance.mm
+++ b/JavaScriptCore/bindings/objc/objc_instance.mm
@@ -22,9 +22,10 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <Foundation/Foundation.h>
+#import <Foundation/Foundation.h>
-#include <objc_instance.h>
+#import <JavaScriptCore/objc_instance.h>
+#import <JavaScriptCore/WebScriptObject.h>
#ifdef NDEBUG
#define OBJC_LOG(formatAndArgs...) ((void)0)
@@ -48,6 +49,8 @@ ObjcInstance::ObjcInstance (ObjectStructPtr instance)
ObjcInstance::~ObjcInstance ()
{
+ if ([_instance respondsToSelector:@selector(finalizeForWebScript)])
+ [_instance finalizeForWebScript];
[_instance release];
}
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index a84a338..0f52ea8 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,18 @@
+2004-05-20 Richard Williamson <rjw at apple.com>
+
+ Reviewed by NOBODY (OOPS!).
+
+ * kwq/DOM.mm:
+ (-[DOMObject _init]):
+ * kwq/DOMInternal.mm:
+ (-[WebScriptObject _init]):
+ (-[WebScriptObject _initializeScriptDOMNodeImp]):
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::KWQKHTMLPart):
+ (KWQKHTMLPart::bindingRootObject):
+ (KWQKHTMLPart::windowScriptObject):
+
2004-05-20 Darin Adler <darin at apple.com>
Reviewed by Ken.
diff --git a/WebCore/kwq/DOM.mm b/WebCore/kwq/DOM.mm
index c1e9e19..63e50ce 100644
--- a/WebCore/kwq/DOM.mm
+++ b/WebCore/kwq/DOM.mm
@@ -47,6 +47,8 @@
#import <xml/dom2_rangeimpl.h>
#import <xml/dom2_viewsimpl.h>
+#import <JavaScriptCore/WebScriptObjectPrivate.h>
+
#import "DOMHTML.h"
#import "DOMInternal.h"
#import "KWQAssertions.h"
@@ -161,7 +163,7 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
- (id)_init
{
- return [super init];
+ return [super _init];
}
@end
diff --git a/WebCore/kwq/DOMInternal.mm b/WebCore/kwq/DOMInternal.mm
index 968e7cf..4674f00 100644
--- a/WebCore/kwq/DOMInternal.mm
+++ b/WebCore/kwq/DOMInternal.mm
@@ -28,9 +28,25 @@
#import <dom/dom2_range.h>
#import <dom/dom_exception.h>
#import <dom/dom_string.h>
+#import <xml/dom_docimpl.h>
#import <xml/dom_stringimpl.h>
+#import "kjs_proxy.h"
+
#import "KWQAssertions.h"
+#import "KWQKHTMLPart.h"
+
+#import <JavaScriptCore/interpreter.h>
+#import <JavaScriptCore/runtime_root.h>
+#import <JavaScriptCore/WebScriptObjectPrivate.h>
+
+//#import "kjs_dom.h"
+// We can't include kjs_dom.h here because of ObjC and C++ namespace compiler craziness.
+// kjs_dom.h:169: error: statically allocated instance of Objective-C class `DOMImplementation'
+// Declaring getDOMNode directly instead.
+namespace KJS {
+ Value getDOMNode(ExecState *exec, const DOM::Node &n);
+}
using DOM::DOMString;
using DOM::DOMStringImpl;
@@ -123,3 +139,50 @@ DOMString::DOMString(NSString *str)
//------------------------------------------------------------------------------------------
+ at implementation WebScriptObject (WebScriptObjectInternal)
+
+// Only called by DOMObject subclass.
+- _init
+{
+ self = [super init];
+
+ if (![self isKindOfClass:[DOMObject class]]) {
+ [NSException raise:NSGenericException format:@"+%@: _init is an internal initializer", [self class]];
+ return nil;
+ }
+
+ _private = [[WebScriptObjectPrivate alloc] init];
+ _private->isCreatedByDOMWrapper = YES;
+
+ return self;
+}
+
+- (void)_initializeScriptDOMNodeImp
+{
+ assert (_private->isCreatedByDOMWrapper);
+
+ if (![self isKindOfClass:[DOMNode class]]) {
+ // DOMObject can't map back to a document, and thus an interpreter,
+ // so for now only create wrappers for DOMNodes.
+ NSLog (@"%s:%d: We don't know how to create ObjC JS wrappers from DOMObjects yet.", __FILE__, __LINE__);
+ return;
+ }
+
+ // Extract the DOM::NodeImpl from the ObjectiveC wrapper.
+ DOMNode *n = (DOMNode *)self;
+ DOM::NodeImpl *nodeImpl = [n _nodeImpl];
+
+ // Dig up Interpreter and ExecState.
+ KHTMLPart *part = nodeImpl->getDocument()->part();
+ KJS::Interpreter *interpreter = KJSProxy::proxy(part)->interpreter();
+ KJS::ExecState *exec = interpreter->globalExec();
+
+ // Get (or create) a cached JS object for the DOM node.
+ KJS::ObjectImp *scriptImp = static_cast<KJS::ObjectImp *>(KJS::getDOMNode (exec, DOM::Node (nodeImpl)).imp());
+
+ [self _initializeWithObjectImp:scriptImp root:KWQ(part)->bindingRootObject()];
+}
+
+ at end
+
+
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index f0a748a..b8a2930 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -285,6 +285,8 @@ public:
void postDidChangeNotification();
bool isContentEditable() const;
+ KJS::Bindings::RootObject *bindingRootObject();
+
WebScriptObject *windowScriptObject();
void bindObject(void *object, QString name);
@@ -342,6 +344,8 @@ private:
friend class KHTMLPart;
+ KJS::Bindings::RootObject *_bindingRoot; // The root object used for objects
+ // bound outside the context of a plugin.
QPtrList<KJS::Bindings::RootObject> rootObjects;
WebScriptObject *_windowScriptObject;
};
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 8235c6f..947fe28 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -176,6 +176,7 @@ KWQKHTMLPart::KWQKHTMLPart()
, _windowWidget(NULL)
, _usesInactiveTextBackgroundColor(false)
, _showsFirstResponder(true)
+ , _bindingRoot(0)
, _windowScriptObject(0)
{
// Must init the cache before connecting to any signals
@@ -1135,15 +1136,23 @@ bool KWQKHTMLPart::tabsToAllControls() const
return KWQKHTMLPart::currentEventIsKeyboardOptionTab();
}
+KJS::Bindings::RootObject *KWQKHTMLPart::bindingRootObject()
+{
+ if (!_bindingRoot) {
+ _bindingRoot = new KJS::Bindings::RootObject(0); // The root gets deleted by JavaScriptCore.
+ KJS::ObjectImp *win = static_cast<KJS::ObjectImp *>(KJS::Window::retrieveWindow(this));
+ _bindingRoot->setRootObjectImp (win);
+ _bindingRoot->setInterpreter (KJSProxy::proxy(this)->interpreter());
+ addPluginRootObject (_bindingRoot);
+ }
+ return _bindingRoot;
+}
+
WebScriptObject *KWQKHTMLPart::windowScriptObject()
{
if (!_windowScriptObject) {
- KJS::Bindings::RootObject *root = new KJS::Bindings::RootObject(0); // The root gets deleted by JavaScriptCore.
KJS::ObjectImp *win = static_cast<KJS::ObjectImp *>(KJS::Window::retrieveWindow(this));
- root->setRootObjectImp (win);
- root->setInterpreter (KJSProxy::proxy(this)->interpreter());
- addPluginRootObject (root);
- _windowScriptObject = [[WebScriptObject alloc] _initWithObjectImp:win root:root];
+ _windowScriptObject = [[WebScriptObject alloc] _initWithObjectImp:win root:bindingRootObject()];
}
return _windowScriptObject;
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 852fddd..049420d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,11 @@
+2004-05-20 Richard Williamson <rjw at apple.com>
+
+ Fixed typo in header comment.
+
+ Reviewed by Ken.
+
+ * Plugins.subproj/WebScriptObject.h:
+
2004-05-19 Chris Blumenberg <cblu at apple.com>
Fixed: <rdar://problem/3462627>: (API: Need a way to disable/customize dragging)
diff --git a/WebKit/Plugins.subproj/WebScriptObject.h b/WebKit/Plugins.subproj/WebScriptObject.h
index 1d51452..f581d75 100644
--- a/WebKit/Plugins.subproj/WebScriptObject.h
+++ b/WebKit/Plugins.subproj/WebScriptObject.h
@@ -125,9 +125,9 @@
/*!
@method finalizeForWebScript
@discussion finalizeForScript is called on objects exposed to the script
- environment just before the script environment is reset. After calls to
- finalizeForScript the object will no longer be referenced by the script environment.
- Further any references to WebScriptObjects made by the exposed object will
+ 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.
*/
- (void)finalizeForWebScript;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list