[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
mjs at apple.com
mjs at apple.com
Wed Mar 17 17:58:50 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit e4e5c88c8856f9f1f4f5c5cd397e89287cb3c70d
Author: mjs at apple.com <mjs at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Feb 25 04:07:37 2010 +0000
2010-02-24 Maciej Stachowiak <mjs at apple.com>
Reviewed by Oliver Hunt.
Cache JavaScript wrappers inline in DOM nodes
https://bugs.webkit.org/show_bug.cgi?id=35226
<rdar://problem/7664202>
7.4% speedup on Dromaeo DOM Core tests.
2.3% speedup on Hixie DOM Core tests.
This fixes the following things from the last attempt:
- Now builds in both debug and release and passes all tests
- Properly use a WeakGCPtr, not just a raw pointer, in ScriptWrappable
- Properly look in the appropriate per-document or per-world map
- Added an assert that would have caught any of the problems I found
- Handle clearing the inline cache properly in all cases
* bindings/js/JSDOMBinding.cpp:
(WebCore::cacheDOMObjectWrapper): Adjust for name changes.
(WebCore::forgetDOMNode): Clear wrapper pointer.
(WebCore::cacheDOMNodeWrapper): Cache inline too if caching for normal world.
* bindings/js/JSDOMBinding.h:
(WebCore::Document::getWrapperCache): Inlined.
(WebCore::domObjectWrapperMapFor): Renamed to start with lowercase. Moved to header to inline.
* bindings/js/JSDOMWrapper.h: Added.
(WebCore::DOMObject::DOMObject): Factored this out of JSDOMBinding.h to avoid include
cycle. I think the class should be renamed, I picked a forward-looking header name because
we already have a DOMObject.h
* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapperInline): Renamed version of original createWrapper.
(WebCore::createWrapper): Call createWrapperInline. Out-of-line version.
(WebCore::toJSNewlyCreated): Call createWrapperInline instead of createWrapper.
* bindings/js/JSNodeCustom.h: Added.
(WebCore::getCachedDOMNodeWrapper): Moved from JSDOMBinding.cpp and moved here,
so it could inline everywhere without creating an include cycle. Consider inline
cache.
(WebCore::toJS): Moved to header to inline.
* bindings/js/ScriptWrappable.h:
(WebCore::ScriptWrappable::ScriptWrappable): Implement this in the obvious
way for JavaScriptCore. (Using a WeakGCPtr).
(WebCore::ScriptWrappable::wrapper):
(WebCore::ScriptWrappable::setWrapper):
(WebCore::ScriptWrappable::clearWrapper):
* bindings/scripts/CodeGeneratorJS.pm: Include CustomHeader heaaders
in the header, not just the impl file, so they can add inlining.
* dom/Node.idl: Add CustomHeader directive.
Add new files to build.
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55215 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6ab318f..e8b257a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,61 @@
+2010-02-24 Maciej Stachowiak <mjs at apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Cache JavaScript wrappers inline in DOM nodes
+ https://bugs.webkit.org/show_bug.cgi?id=35226
+
+ <rdar://problem/7664202>
+
+ 7.4% speedup on Dromaeo DOM Core tests.
+ 2.3% speedup on Hixie DOM Core tests.
+
+ This fixes the following things from the last attempt:
+ - Now builds in both debug and release and passes all tests
+ - Properly use a WeakGCPtr, not just a raw pointer, in ScriptWrappable
+ - Properly look in the appropriate per-document or per-world map
+ - Added an assert that would have caught any of the problems I found
+ - Handle clearing the inline cache properly in all cases
+
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::cacheDOMObjectWrapper): Adjust for name changes.
+ (WebCore::forgetDOMNode): Clear wrapper pointer.
+ (WebCore::cacheDOMNodeWrapper): Cache inline too if caching for normal world.
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::Document::getWrapperCache): Inlined.
+ (WebCore::domObjectWrapperMapFor): Renamed to start with lowercase. Moved to header to inline.
+ * bindings/js/JSDOMWrapper.h: Added.
+ (WebCore::DOMObject::DOMObject): Factored this out of JSDOMBinding.h to avoid include
+ cycle. I think the class should be renamed, I picked a forward-looking header name because
+ we already have a DOMObject.h
+ * bindings/js/JSNodeCustom.cpp:
+ (WebCore::createWrapperInline): Renamed version of original createWrapper.
+ (WebCore::createWrapper): Call createWrapperInline. Out-of-line version.
+ (WebCore::toJSNewlyCreated): Call createWrapperInline instead of createWrapper.
+ * bindings/js/JSNodeCustom.h: Added.
+ (WebCore::getCachedDOMNodeWrapper): Moved from JSDOMBinding.cpp and moved here,
+ so it could inline everywhere without creating an include cycle. Consider inline
+ cache.
+ (WebCore::toJS): Moved to header to inline.
+ * bindings/js/ScriptWrappable.h:
+ (WebCore::ScriptWrappable::ScriptWrappable): Implement this in the obvious
+ way for JavaScriptCore. (Using a WeakGCPtr).
+ (WebCore::ScriptWrappable::wrapper):
+ (WebCore::ScriptWrappable::setWrapper):
+ (WebCore::ScriptWrappable::clearWrapper):
+ * bindings/scripts/CodeGeneratorJS.pm: Include CustomHeader heaaders
+ in the header, not just the impl file, so they can add inlining.
+ * dom/Node.idl: Add CustomHeader directive.
+
+ Add new files to build.
+
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+
+
2010-02-24 Jochen Eisinger <jochen at chromium.org>
Reviewed by Jeremy Orlow.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index c4bbc6a..92f8103 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -380,6 +380,7 @@ webcore_sources += \
WebCore/bindings/js/JSDOMWindowCustom.h \
WebCore/bindings/js/JSDOMWindowShell.cpp \
WebCore/bindings/js/JSDOMWindowShell.h \
+ WebCore/bindings/js/JSDOMWrapper.h \
WebCore/bindings/js/JSDocumentCustom.cpp \
WebCore/bindings/js/JSDocumentFragmentCustom.cpp \
WebCore/bindings/js/JSElementCustom.cpp \
@@ -437,6 +438,7 @@ webcore_sources += \
WebCore/bindings/js/JSNamedNodeMapCustom.cpp \
WebCore/bindings/js/JSNavigatorCustom.cpp \
WebCore/bindings/js/JSNodeCustom.cpp \
+ WebCore/bindings/js/JSNodeCustom.h \
WebCore/bindings/js/JSNodeFilterCondition.cpp \
WebCore/bindings/js/JSNodeFilterCondition.h \
WebCore/bindings/js/JSNodeFilterCustom.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 4c423c5..b3bd08a 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -514,6 +514,7 @@
'bindings/js/JSDOMWindowCustom.h',
'bindings/js/JSDOMWindowShell.cpp',
'bindings/js/JSDOMWindowShell.h',
+ 'bindings/js/JSDOMWrapper.h',
'bindings/js/JSElementCustom.cpp',
'bindings/js/JSEventCustom.cpp',
'bindings/js/JSEventListener.cpp',
@@ -568,6 +569,7 @@
'bindings/js/JSNamedNodesCollection.h',
'bindings/js/JSNavigatorCustom.cpp',
'bindings/js/JSNodeCustom.cpp',
+ 'bindings/js/JSNodeCustom.h',
'bindings/js/JSNodeFilterCondition.cpp',
'bindings/js/JSNodeFilterCondition.h',
'bindings/js/JSNodeFilterCustom.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 9caaba9..a10683d 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -1018,6 +1018,7 @@ HEADERS += \
bindings/js/JSDOMWindowBase.h \
bindings/js/JSDOMWindowCustom.h \
bindings/js/JSDOMWindowShell.h \
+ bindings/js/JSDOMWrapper.h \
bindings/js/JSEventListener.h \
bindings/js/JSEventSourceConstructor.h \
bindings/js/JSEventTarget.h \
@@ -1031,6 +1032,7 @@ HEADERS += \
bindings/js/JSLazyEventListener.h \
bindings/js/JSLocationCustom.h \
bindings/js/JSMessageChannelConstructor.h \
+ bindings/js/JSNodeCustom.h \
bindings/js/JSNodeFilterCondition.h \
bindings/js/JSOptionConstructor.h \
bindings/js/JSPluginElementFunctions.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index dd936d8..e537e35 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -35968,6 +35968,10 @@
>
</File>
<File
+ RelativePath="..\bindings\js\JSDOMWrapper.h"
+ >
+ </File>
+ <File
RelativePath="..\bindings\js\JSDOMWindowShell.cpp"
>
<FileConfiguration
@@ -38096,6 +38100,10 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\bindings\js\JSNodeCustom.h"
+ >
+ </File>
+ <File
RelativePath="..\bindings\js\JSNodeFilterCondition.cpp"
>
<FileConfiguration
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 588b2b5..04d4029 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1240,6 +1240,7 @@
65DF323B09D1DE65000BE325 /* JSCanvasPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65DF323509D1DE65000BE325 /* JSCanvasPattern.cpp */; };
65DF323C09D1DE65000BE325 /* JSCanvasPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DF323609D1DE65000BE325 /* JSCanvasPattern.h */; };
65DF326109D1E199000BE325 /* UserAgentStyleSheetsData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 656581AF09D14EE6000E61D7 /* UserAgentStyleSheetsData.cpp */; };
+ 65E0E9441133C89F00B4CB10 /* JSDOMWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
6E21C6C01126338500A7BE02 /* GraphicsContext3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */; };
6E21C6C21126339900A7BE02 /* GraphicsContext3DCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */; };
@@ -6658,6 +6659,7 @@
65DF323409D1DE65000BE325 /* JSCanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCanvasGradient.h; sourceTree = "<group>"; };
65DF323509D1DE65000BE325 /* JSCanvasPattern.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSCanvasPattern.cpp; sourceTree = "<group>"; };
65DF323609D1DE65000BE325 /* JSCanvasPattern.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCanvasPattern.h; sourceTree = "<group>"; };
+ 65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMWrapper.h; sourceTree = "<group>"; };
65F80697054D9F86008BF776 /* BlockExceptions.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BlockExceptions.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3D.cpp; sourceTree = "<group>"; };
@@ -14609,6 +14611,7 @@
BC1A3793097C6FB10019F3D8 /* js */ = {
isa = PBXGroup;
children = (
+ 65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */,
BCCE58A71061E82F008FB35A /* Callback Objects */,
BCCE58B41061E925008FB35A /* Constructors */,
BC4EDEF70C08F414007EDD49 /* Custom */,
@@ -18549,6 +18552,7 @@
9F2A322E1125A0A2003C3056 /* JavaScriptProfileNode.h in Headers */,
7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */,
7AFD4FF4113277B60035B883 /* ScriptDebugListener.h in Headers */,
+ 65E0E9441133C89F00B4CB10 /* JSDOMWrapper.h in Headers */,
5962297A1133EFE200DC4CBB /* GeolocationPositionCache.h in Headers */,
0BC2C7781134A8FC000B2F61 /* CanvasSurface.h in Headers */,
);
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp
index abba405..24e176e 100644
--- a/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/WebCore/bindings/js/JSDOMBinding.cpp
@@ -80,17 +80,6 @@ using namespace HTMLNames;
typedef Document::JSWrapperCache JSWrapperCache;
typedef Document::JSWrapperCacheMap JSWrapperCacheMap;
-inline JSWrapperCache* Document::getWrapperCache(DOMWrapperWorld* world)
-{
- if (world->isNormal()) {
- if (JSWrapperCache* wrapperCache = m_normalWorldWrapperCache)
- return wrapperCache;
- ASSERT(!m_wrapperCacheMap.contains(world));
- } else if (JSWrapperCache* wrapperCache = m_wrapperCacheMap.get(world))
- return wrapperCache;
- return createWrapperCache(world);
-}
-
// For debugging, keep a set of wrappers currently cached, and check that
// all are uncached before they are destroyed. This helps us catch bugs like:
// - wrappers being deleted without being removed from the cache
@@ -221,11 +210,6 @@ const JSC::HashTable* getHashTableForGlobalData(JSGlobalData& globalData, const
return DOMObjectHashTableMap::mapFor(globalData).get(staticTable);
}
-static inline DOMObjectWrapperMap& DOMObjectWrapperMapFor(JSC::ExecState* exec)
-{
- return currentWorld(exec)->m_wrappers;
-}
-
bool hasCachedDOMObjectWrapperUnchecked(JSGlobalData* globalData, void* objectHandle)
{
for (JSGlobalDataWorldIterator worldIter(globalData); worldIter; ++worldIter) {
@@ -246,13 +230,13 @@ bool hasCachedDOMObjectWrapper(JSGlobalData* globalData, void* objectHandle)
DOMObject* getCachedDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle)
{
- return DOMObjectWrapperMapFor(exec).get(objectHandle);
+ return domObjectWrapperMapFor(exec).get(objectHandle);
}
void cacheDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle, DOMObject* wrapper)
{
willCacheWrapper(wrapper);
- DOMObjectWrapperMapFor(exec).set(objectHandle, wrapper);
+ domObjectWrapperMapFor(exec).set(objectHandle, wrapper);
}
bool hasCachedDOMNodeWrapperUnchecked(Document* document, Node* node)
@@ -268,13 +252,6 @@ bool hasCachedDOMNodeWrapperUnchecked(Document* document, Node* node)
return false;
}
-JSNode* getCachedDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node)
-{
- if (document)
- return document->getWrapperCache(currentWorld(exec))->get(node);
- return static_cast<JSNode*>(DOMObjectWrapperMapFor(exec).get(node));
-}
-
void forgetDOMObject(DOMObject* wrapper, void* objectHandle)
{
JSC::JSGlobalData* globalData = Heap::heap(wrapper)->globalData();
@@ -299,6 +276,8 @@ void forgetDOMObject(DOMObject* wrapper, void* objectHandle)
void forgetDOMNode(JSNode* wrapper, Node* node, Document* document)
{
+ node->clearWrapper(wrapper);
+
if (!document) {
forgetDOMObject(wrapper, node);
return;
@@ -316,13 +295,15 @@ void forgetDOMNode(JSNode* wrapper, Node* node, Document* document)
void cacheDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node, JSNode* wrapper)
{
- if (!document) {
- willCacheWrapper(wrapper);
- DOMObjectWrapperMapFor(exec).set(node, wrapper);
- return;
- }
willCacheWrapper(wrapper);
- document->getWrapperCache(currentWorld(exec))->set(node, wrapper);
+
+ if (!document)
+ domObjectWrapperMapFor(exec).set(node, wrapper);
+ else
+ document->getWrapperCache(currentWorld(exec))->set(node, wrapper);
+
+ if (currentWorld(exec)->isNormal())
+ node->setWrapper(wrapper);
}
void forgetAllDOMNodesForDocument(Document* document)
diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h
index 807bf82..62d71d4 100644
--- a/WebCore/bindings/js/JSDOMBinding.h
+++ b/WebCore/bindings/js/JSDOMBinding.h
@@ -23,6 +23,7 @@
#define JSDOMBinding_h
#include "JSDOMGlobalObject.h"
+#include "JSDOMWrapper.h"
#include "JSSVGContextCache.h"
#include "Document.h"
#include <runtime/Completion.h>
@@ -52,21 +53,6 @@ namespace WebCore {
class SVGElement;
#endif
- // Base class for all objects in this binding except Window.
- class DOMObject : public JSC::JSObject {
- protected:
- explicit DOMObject(NonNullPassRefPtr<JSC::Structure> structure)
- : JSObject(structure)
- {
- }
-
- virtual bool defineOwnProperty(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&, bool);
-
-#ifndef NDEBUG
- virtual ~DOMObject();
-#endif
- };
-
// FIXME: This class should collapse into DOMObject once all DOMObjects are
// updated to store a globalObject pointer.
class DOMObjectWithGlobalPointer : public DOMObject {
@@ -446,6 +432,24 @@ namespace WebCore {
return jsStringSlowCase(exec, stringCache, stringImpl);
}
+ inline DOMObjectWrapperMap& domObjectWrapperMapFor(JSC::ExecState* exec)
+ {
+ return currentWorld(exec)->m_wrappers;
+ }
+
+
+
+ inline Document::JSWrapperCache* Document::getWrapperCache(DOMWrapperWorld* world)
+ {
+ if (world->isNormal()) {
+ if (Document::JSWrapperCache* wrapperCache = m_normalWorldWrapperCache)
+ return wrapperCache;
+ ASSERT(!m_wrapperCacheMap.contains(world));
+ } else if (Document::JSWrapperCache* wrapperCache = m_wrapperCacheMap.get(world))
+ return wrapperCache;
+ return createWrapperCache(world);
+ }
+
} // namespace WebCore
#endif // JSDOMBinding_h
diff --git a/WebCore/bindings/js/JSDOMWrapper.h b/WebCore/bindings/js/JSDOMWrapper.h
new file mode 100644
index 0000000..dfb6d8c
--- /dev/null
+++ b/WebCore/bindings/js/JSDOMWrapper.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten at kde.org)
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Samuel Weinig <sam at webkit.org>
+ * Copyright (C) 2009 Google, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef JSDOMWrapper_h
+#define JSDOMWrapper_h
+
+#include <JavaScriptCore/JSObject.h>
+
+namespace WebCore {
+
+// Base class for all objects in this binding except Window.
+class DOMObject : public JSC::JSObject {
+protected:
+ explicit DOMObject(NonNullPassRefPtr<JSC::Structure> structure)
+ : JSObject(structure)
+ {
+ }
+
+ virtual bool defineOwnProperty(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&, bool);
+
+#ifndef NDEBUG
+ virtual ~DOMObject();
+#endif
+};
+
+} // namespace WebCore
+
+#endif // JSDOMWrapper_h
diff --git a/WebCore/bindings/js/JSNodeCustom.cpp b/WebCore/bindings/js/JSNodeCustom.cpp
index 46a30a4..134c581 100644
--- a/WebCore/bindings/js/JSNodeCustom.cpp
+++ b/WebCore/bindings/js/JSNodeCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -172,7 +172,7 @@ void JSNode::markChildren(MarkStack& markStack)
markDOMNodeWrapper(markStack, m_impl->document(), nodeToMark);
}
-static ALWAYS_INLINE JSValue createWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
+static ALWAYS_INLINE JSValue createWrapperInline(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
{
ASSERT(node);
ASSERT(!getCachedDOMNodeWrapper(exec, node->document(), node));
@@ -228,25 +228,18 @@ static ALWAYS_INLINE JSValue createWrapper(ExecState* exec, JSDOMGlobalObject* g
return wrapper;
}
-
-JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
+
+JSValue createWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
{
- if (!node)
- return jsNull();
-
- return createWrapper(exec, globalObject, node);
+ return createWrapperInline(exec, globalObject, node);
}
-JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
+JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
{
if (!node)
return jsNull();
-
- JSNode* wrapper = getCachedDOMNodeWrapper(exec, node->document(), node);
- if (wrapper)
- return wrapper;
-
- return createWrapper(exec, globalObject, node);
+
+ return createWrapperInline(exec, globalObject, node);
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSNodeCustom.h b/WebCore/bindings/js/JSNodeCustom.h
new file mode 100644
index 0000000..9d06ae6
--- /dev/null
+++ b/WebCore/bindings/js/JSNodeCustom.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSNodeCustom_h
+#define JSNodeCustom_h
+
+#include "JSDOMBinding.h"
+#include <wtf/AlwaysInline.h>
+
+namespace WebCore {
+
+inline JSNode* getCachedDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node)
+{
+ if (currentWorld(exec)->isNormal()) {
+ ASSERT(node->wrapper() == (document ? document->getWrapperCache(currentWorld(exec))->get(node) : domObjectWrapperMapFor(exec).get(node)));
+ return static_cast<JSNode*>(node->wrapper());
+ }
+
+ if (document)
+ return document->getWrapperCache(currentWorld(exec))->get(node);
+ return static_cast<JSNode*>(domObjectWrapperMapFor(exec).get(node));
+}
+
+JSC::JSValue createWrapper(JSC::ExecState*, JSDOMGlobalObject*, Node*);
+
+inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
+{
+ if (!node)
+ return JSC::jsNull();
+
+ JSNode* wrapper = getCachedDOMNodeWrapper(exec, node->document(), node);
+ if (wrapper)
+ return wrapper;
+
+ return createWrapper(exec, globalObject, node);
+}
+
+}
+
+#endif // JSDOMNodeCustom_h
diff --git a/WebCore/bindings/js/ScriptWrappable.h b/WebCore/bindings/js/ScriptWrappable.h
index d70cab7..eff6759 100644
--- a/WebCore/bindings/js/ScriptWrappable.h
+++ b/WebCore/bindings/js/ScriptWrappable.h
@@ -31,11 +31,33 @@
#ifndef ScriptWrappable_h
#define ScriptWrappable_h
+#include "JSDOMWrapper.h"
+#include <JavaScriptCore/WeakGCPtr.h>
+
namespace WebCore {
class ScriptWrappable {
public:
- ScriptWrappable() { }
+ ScriptWrappable() : m_wrapper(0) { }
+
+ DOMObject* wrapper() const
+ {
+ return m_wrapper.get();
+ }
+
+ void setWrapper(DOMObject* wrapper)
+ {
+ ASSERT(wrapper);
+ m_wrapper = wrapper;
+ }
+
+ void clearWrapper(DOMObject* wrapper)
+ {
+ m_wrapper.clear(wrapper);
+ }
+
+private:
+ JSC::WeakGCPtr<DOMObject> m_wrapper;
};
} // namespace WebCore
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index 94fc2b8..ece6df2 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -32,6 +32,7 @@ my $writeDependencies = 0;
my @headerContentHeader = ();
my @headerContent = ();
my %headerIncludes = ();
+my %headerTrailingIncludes = ();
my @implContentHeader = ();
my @implContent = ();
@@ -551,7 +552,9 @@ sub GenerateHeader
# Prototype
push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);\n") unless ($dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"});
- $implIncludes{"${className}Custom.h"} = 1 if $dataNode->extendedAttributes->{"CustomHeader"} || $dataNode->extendedAttributes->{"CustomPutFunction"} || $dataNode->extendedAttributes->{"DelegatingPutFunction"};
+ $headerTrailingIncludes{"${className}Custom.h"} = 1 if $dataNode->extendedAttributes->{"CustomHeader"};
+
+ $implIncludes{"${className}Custom.h"} = 1 if !$dataNode->extendedAttributes->{"CustomHeader"} && ($dataNode->extendedAttributes->{"CustomPutFunction"} || $dataNode->extendedAttributes->{"DelegatingPutFunction"});
my $hasGetter = $numAttributes > 0
|| !($dataNode->extendedAttributes->{"OmitConstructor"}
@@ -2246,12 +2249,23 @@ sub WriteData
}
print $HEADER @headerContent;
+
+ @includes = ();
+ foreach my $include (keys %headerTrailingIncludes) {
+ $include = "\"$include\"" unless $include =~ /^["<]/; # "
+ push @includes, $include;
+ }
+ foreach my $include (sort @includes) {
+ print $HEADER "#include $include\n";
+ }
+
close($HEADER);
undef($HEADER);
@headerContentHeader = ();
@headerContent = ();
%headerIncludes = ();
+ %headerTrailingIncludes = ();
}
if (defined($DEPS)) {
diff --git a/WebCore/dom/Node.idl b/WebCore/dom/Node.idl
index ca7874a..0489316 100644
--- a/WebCore/dom/Node.idl
+++ b/WebCore/dom/Node.idl
@@ -21,6 +21,7 @@
module core {
interface [
+ CustomHeader,
CustomMarkFunction,
CustomPushEventHandlerScope,
CustomToJS,
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list