diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-03 23:33:55 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-03 23:33:55 +0000 |
commit | 8a93111c16314b823c4a3e506cb4893b8a24898c (patch) | |
tree | 39600e3d765bfae79d7c6e156efa090ac06be903 /webkit | |
parent | e2bc4e3a7b54c26689379b01a61e72e7b86a8213 (diff) | |
download | chromium_src-8a93111c16314b823c4a3e506cb4893b8a24898c.zip chromium_src-8a93111c16314b823c4a3e506cb4893b8a24898c.tar.gz chromium_src-8a93111c16314b823c4a3e506cb4893b8a24898c.tar.bz2 |
Fork platform/mac/WebCoreObjCExtras.c -> webkit/pending/WebCoreObjCExtras.mm
Submitted patch upstream: https://bugs.webkit.org/show_bug.cgi?id=21350
Review URL: http://codereview.chromium.org/6251
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/pending/WebCoreObjCExtras.mm | 82 | ||||
-rw-r--r-- | webkit/webkit.xcodeproj/project.pbxproj | 8 |
2 files changed, 86 insertions, 4 deletions
diff --git a/webkit/pending/WebCoreObjCExtras.mm b/webkit/pending/WebCoreObjCExtras.mm new file mode 100644 index 0000000..105c462 --- /dev/null +++ b/webkit/pending/WebCoreObjCExtras.mm @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2007 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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. + */ + +#include "config.h" +#include "WebCoreObjCExtras.h" + +#include <objc/objc-auto.h> +#include <objc/objc-runtime.h> +#include <wtf/Assertions.h> +#include <wtf/MainThread.h> +#include <wtf/Threading.h> + +void WebCoreObjCFinalizeOnMainThread(Class cls) +{ +#if !defined(BUILDING_ON_TIGER) && !defined(DONT_FINALIZE_ON_MAIN_THREAD) + objc_finalizeOnMainThread(cls); +#endif + + // The reason we call initializeThreading here is that we'd like to have + // threading initialized early, otherwise WebCoreObjCScheduleDeallocateOnMainThread + // will crash + WTF::initializeThreading(); +} + +#ifdef BUILDING_ON_TIGER +static inline IMP method_getImplementation(Method method) +{ + return method->method_imp; +} +#endif + +typedef std::pair<Class, id> ClassAndIdPair; + +static void deallocCallback(void* context) +{ + ClassAndIdPair* pair = static_cast<ClassAndIdPair*>(context); + + Method method = class_getInstanceMethod(pair->first, @selector(dealloc)); + + IMP imp = method_getImplementation(method); + imp(pair->second, @selector(dealloc)); + + delete pair; +} + +bool WebCoreObjCScheduleDeallocateOnMainThread(Class cls, id object) +{ + ASSERT([object isKindOfClass:cls]); + + if (pthread_main_np() != 0) + return false; + + ClassAndIdPair* pair = new ClassAndIdPair(cls, object); + callOnMainThread(deallocCallback, pair); + return true; +} + diff --git a/webkit/webkit.xcodeproj/project.pbxproj b/webkit/webkit.xcodeproj/project.pbxproj index a055e5d..46a0b5a 100644 --- a/webkit/webkit.xcodeproj/project.pbxproj +++ b/webkit/webkit.xcodeproj/project.pbxproj @@ -328,6 +328,7 @@ AB0240650E9565F7006D59C8 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB0240640E9565F7006D59C8 /* DocumentLoaderMac.cpp */; }; AB332F3E0E9548900020F882 /* AccessibilityObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82761F810E3FAC700030D324 /* AccessibilityObject.cpp */; }; AB332F4D0E95497E0020F882 /* AnimationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB332F4B0E95497E0020F882 /* AnimationController.cpp */; }; + B50F5BE00E96D3F800AD71A6 /* WebCoreObjCExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = B50F5BDF0E96D3F800AD71A6 /* WebCoreObjCExtras.mm */; }; B5599D0F0E95929900E2A85A /* SVGFEColorMatrixElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5599D0E0E95929900E2A85A /* SVGFEColorMatrixElement.cpp */; }; B5599D130E95942900E2A85A /* SVGDocumentExtensions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5599D120E95942900E2A85A /* SVGDocumentExtensions.cpp */; }; B5599D160E9594E800E2A85A /* SVGImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5599D140E9594E800E2A85A /* SVGImage.cpp */; }; @@ -730,7 +731,6 @@ E456250B0E268E87005E4685 /* SystemTimeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E90FC0D7F3CC2001ECF42 /* SystemTimeMac.cpp */; }; E456250F0E268E87005E4685 /* WebCoreKeyGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E91020D7F3CC2001ECF42 /* WebCoreKeyGenerator.m */; }; E45625100E268E87005E4685 /* WebCoreNSStringExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E91040D7F3CC2001ECF42 /* WebCoreNSStringExtras.mm */; }; - E45625110E268E87005E4685 /* WebCoreObjCExtras.c in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E91050D7F3CC2001ECF42 /* WebCoreObjCExtras.c */; }; E45625120E268E87005E4685 /* WebCoreSystemInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E91080D7F3CC2001ECF42 /* WebCoreSystemInterface.mm */; }; E45625130E268E87005E4685 /* WebCoreTextRenderer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E910A0D7F3CC2001ECF42 /* WebCoreTextRenderer.mm */; }; E45625140E268E87005E4685 /* WebCoreView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E910C0D7F3CC2001ECF42 /* WebCoreView.m */; }; @@ -2687,7 +2687,6 @@ 7B5E91020D7F3CC2001ECF42 /* WebCoreKeyGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebCoreKeyGenerator.m; sourceTree = "<group>"; }; 7B5E91030D7F3CC2001ECF42 /* WebCoreNSStringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreNSStringExtras.h; sourceTree = "<group>"; }; 7B5E91040D7F3CC2001ECF42 /* WebCoreNSStringExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSStringExtras.mm; sourceTree = "<group>"; }; - 7B5E91050D7F3CC2001ECF42 /* WebCoreObjCExtras.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = WebCoreObjCExtras.c; sourceTree = "<group>"; }; 7B5E91060D7F3CC2001ECF42 /* WebCoreObjCExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreObjCExtras.h; sourceTree = "<group>"; }; 7B5E91070D7F3CC2001ECF42 /* WebCoreSystemInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreSystemInterface.h; sourceTree = "<group>"; }; 7B5E91080D7F3CC2001ECF42 /* WebCoreSystemInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreSystemInterface.mm; sourceTree = "<group>"; }; @@ -3562,6 +3561,7 @@ AB0240640E9565F7006D59C8 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; }; AB332F4B0E95497E0020F882 /* AnimationController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AnimationController.cpp; path = animation/AnimationController.cpp; sourceTree = "<group>"; }; AB332F4C0E95497E0020F882 /* AnimationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnimationController.h; path = animation/AnimationController.h; sourceTree = "<group>"; }; + B50F5BDF0E96D3F800AD71A6 /* WebCoreObjCExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebCoreObjCExtras.mm; path = pending/WebCoreObjCExtras.mm; sourceTree = SOURCE_ROOT; }; B5599D0D0E95929900E2A85A /* SVGFEColorMatrixElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SVGFEColorMatrixElement.h; path = ../third_party/WebKit/WebCore/svg/SVGFEColorMatrixElement.h; sourceTree = SOURCE_ROOT; }; B5599D0E0E95929900E2A85A /* SVGFEColorMatrixElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SVGFEColorMatrixElement.cpp; path = ../third_party/WebKit/WebCore/svg/SVGFEColorMatrixElement.cpp; sourceTree = SOURCE_ROOT; }; B5599D110E95942900E2A85A /* SVGDocumentExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGDocumentExtensions.h; sourceTree = "<group>"; }; @@ -4923,7 +4923,7 @@ 7B5E91020D7F3CC2001ECF42 /* WebCoreKeyGenerator.m */, 7B5E91030D7F3CC2001ECF42 /* WebCoreNSStringExtras.h */, 7B5E91040D7F3CC2001ECF42 /* WebCoreNSStringExtras.mm */, - 7B5E91050D7F3CC2001ECF42 /* WebCoreObjCExtras.c */, + B50F5BDF0E96D3F800AD71A6 /* WebCoreObjCExtras.mm */, 7B5E91060D7F3CC2001ECF42 /* WebCoreObjCExtras.h */, 7B5E91070D7F3CC2001ECF42 /* WebCoreSystemInterface.h */, 7B5E91080D7F3CC2001ECF42 /* WebCoreSystemInterface.mm */, @@ -7847,7 +7847,7 @@ E456241C0E268E87005E4685 /* VisiblePosition.cpp in Sources */, E456250F0E268E87005E4685 /* WebCoreKeyGenerator.m in Sources */, E45625100E268E87005E4685 /* WebCoreNSStringExtras.mm in Sources */, - E45625110E268E87005E4685 /* WebCoreObjCExtras.c in Sources */, + B50F5BE00E96D3F800AD71A6 /* WebCoreObjCExtras.mm in Sources */, E45625120E268E87005E4685 /* WebCoreSystemInterface.mm in Sources */, E45625130E268E87005E4685 /* WebCoreTextRenderer.mm in Sources */, E456268E0E268E87005E4685 /* WebCoreURLResponse.mm in Sources */, |