[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

darin at apple.com darin at apple.com
Wed Dec 22 13:39:17 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 62290c68bdea3f500826fa6086d14cbc22a57789
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 22 17:26:02 2010 +0000

    2010-09-21  Darin Adler  <darin at apple.com>
    
            Reviewed by Anders Carlsson.
    
            Fix some Objective-C GC problems and use RetainPtr instead of HardRetain/Release
            https://bugs.webkit.org/show_bug.cgi?id=46220
    
            * Misc/WebNSFileManagerExtras.m:
            (setMetaData): Use CFRelease instead of HardRelease.
            (-[NSFileManager _webkit_setMetadataURL:referrer:atPath:]): Use CFStringCreateCopy
            instead of -[NSObject copy] combined with HardRetainWithNSRelease.
    2010-09-21  Darin Adler  <darin at apple.com>
    
            Reviewed by Anders Carlsson.
    
            Fix some Objective-C GC problems and use RetainPtr instead of HardRetain/Release
            https://bugs.webkit.org/show_bug.cgi?id=46220
    
            * WebCore.exp.in: Updated.
    
            * bindings/objc/ObjCEventListener.h: Use a RetainPtr for m_listener, since that
            will do a CFRetain, which is right for GC rather than an -[NSObject retain],
            which is not.
            * bindings/objc/ObjCEventListener.mm:
            (WebCore::ObjCEventListener::ObjCEventListener): Removed explicit retain.
            (WebCore::ObjCEventListener::~ObjCEventListener): Removed explicit release and
            added get().
            (WebCore::ObjCEventListener::handleEvent): Added get();
    
            * bridge/objc/objc_instance.mm:
            (ObjcInstance::setGlobalException): Use copy/release instead of
            HardRetain/HardRelease.
            (ObjcInstance::moveGlobalExceptionToExecState): Ditto.
    
            * platform/Cursor.h: Use RetainPtr for PlatformCursor on Mac.
    
            * platform/Cursor.cpp:
            (WebCore::Cursor::platformCursor): Moved this to CursorMac for the Mac.
    
            * platform/Widget.cpp: Removed retain/releasePlatformWidget and made them
            both inlines in the header file.
    
            * platform/Widget.h: Fixed includes and added an include of RetainPtr.
            Made platformWidget and setPlatformWidget non-inline on the Mac platform.
            Made releasePlatformWidget and retainPlatformWidget empty inline functions
            for non-GTK platforms.
    
            * platform/graphics/mac/ImageMac.mm: Removed unneeded FoundationExtras.h
            include.
    
            * platform/mac/ClipboardMac.mm:
            (WebCore::cocoaTypeFromHTMLClipboardType): use RetainPtr for the return type.
            (WebCore::ClipboardMac::clearData): Use RetainPtr.
            (WebCore::ClipboardMac::getData): Ditto.
            (WebCore::ClipboardMac::setData): Ditto.
    
            * platform/mac/CursorMac.mm:
            (WebCore::createCustomCursor): Use RetainPtr for the return type.
            (WebCore::Cursor::ensurePlatformCursor): Removed all the calls to HardRetain
            since m_platformCursor is now a RetainPtr.
            (WebCore::Cursor::Cursor): Ditto.
            (WebCore::Cursor::operator=): Ditto. Also HardRelease.
            (WebCore::Cursor::~Cursor): Ditto.
            (WebCore::Cursor::platformCursor): Use get here.
    
            * platform/mac/FoundationExtras.h: Removed all the functions except for
            HardAutorelease. Later we can remove that one too.
    
            * platform/mac/ThemeMac.mm:
            (WebCore::setUpButtonCell): Changed this function to have a return value.
            Otherwise we end up taking a pointer (actually a reference) to a global
            variable, which does not do the right thing for GC.
            (WebCore::nonDefaultButton): Added.
            (WebCore::defaultButton): Added.
            (WebCore::button): Changed to call two separate functions with two separate
            global variables to avoid the problem with pointers to globals.
    
            * platform/mac/WidgetMac.mm:
            (WebCore::Widget::~Widget): Removed unneeded call to releasePlatformWidget.
            (WebCore::Widget::platformWidget): Non-inline so we can comipile the header
            plain non-Objective-C C++.
            (WebCore::Widget::setPlatformWidget): Ditto.
    
            * platform/network/mac/WebCoreURLResponse.mm:
            (mimeTypeFromUTITree): Use RetainPtr for the return type.
            (-[NSURLResponse adjustMIMETypeIfNecessary]): Use RetainPtr.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68054 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 47a6690..447ac9e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,79 @@
+2010-09-21  Darin Adler  <darin at apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Fix some Objective-C GC problems and use RetainPtr instead of HardRetain/Release
+        https://bugs.webkit.org/show_bug.cgi?id=46220
+
+        * WebCore.exp.in: Updated.
+
+        * bindings/objc/ObjCEventListener.h: Use a RetainPtr for m_listener, since that
+        will do a CFRetain, which is right for GC rather than an -[NSObject retain],
+        which is not.
+        * bindings/objc/ObjCEventListener.mm:
+        (WebCore::ObjCEventListener::ObjCEventListener): Removed explicit retain.
+        (WebCore::ObjCEventListener::~ObjCEventListener): Removed explicit release and
+        added get().
+        (WebCore::ObjCEventListener::handleEvent): Added get();
+
+        * bridge/objc/objc_instance.mm:
+        (ObjcInstance::setGlobalException): Use copy/release instead of
+        HardRetain/HardRelease.
+        (ObjcInstance::moveGlobalExceptionToExecState): Ditto.
+
+        * platform/Cursor.h: Use RetainPtr for PlatformCursor on Mac.
+
+        * platform/Cursor.cpp:
+        (WebCore::Cursor::platformCursor): Moved this to CursorMac for the Mac.
+
+        * platform/Widget.cpp: Removed retain/releasePlatformWidget and made them
+        both inlines in the header file.
+
+        * platform/Widget.h: Fixed includes and added an include of RetainPtr.
+        Made platformWidget and setPlatformWidget non-inline on the Mac platform.
+        Made releasePlatformWidget and retainPlatformWidget empty inline functions
+        for non-GTK platforms.
+
+        * platform/graphics/mac/ImageMac.mm: Removed unneeded FoundationExtras.h
+        include.
+
+        * platform/mac/ClipboardMac.mm:
+        (WebCore::cocoaTypeFromHTMLClipboardType): use RetainPtr for the return type.
+        (WebCore::ClipboardMac::clearData): Use RetainPtr.
+        (WebCore::ClipboardMac::getData): Ditto.
+        (WebCore::ClipboardMac::setData): Ditto.
+
+        * platform/mac/CursorMac.mm:
+        (WebCore::createCustomCursor): Use RetainPtr for the return type.
+        (WebCore::Cursor::ensurePlatformCursor): Removed all the calls to HardRetain
+        since m_platformCursor is now a RetainPtr.
+        (WebCore::Cursor::Cursor): Ditto.
+        (WebCore::Cursor::operator=): Ditto. Also HardRelease.
+        (WebCore::Cursor::~Cursor): Ditto.
+        (WebCore::Cursor::platformCursor): Use get here.
+
+        * platform/mac/FoundationExtras.h: Removed all the functions except for
+        HardAutorelease. Later we can remove that one too.
+
+        * platform/mac/ThemeMac.mm:
+        (WebCore::setUpButtonCell): Changed this function to have a return value.
+        Otherwise we end up taking a pointer (actually a reference) to a global
+        variable, which does not do the right thing for GC.
+        (WebCore::nonDefaultButton): Added.
+        (WebCore::defaultButton): Added.
+        (WebCore::button): Changed to call two separate functions with two separate
+        global variables to avoid the problem with pointers to globals.
+
+        * platform/mac/WidgetMac.mm:
+        (WebCore::Widget::~Widget): Removed unneeded call to releasePlatformWidget.
+        (WebCore::Widget::platformWidget): Non-inline so we can comipile the header
+        plain non-Objective-C C++.
+        (WebCore::Widget::setPlatformWidget): Ditto.
+
+        * platform/network/mac/WebCoreURLResponse.mm:
+        (mimeTypeFromUTITree): Use RetainPtr for the return type.
+        (-[NSURLResponse adjustMIMETypeIfNecessary]): Use RetainPtr.
+
 2010-09-22  Martin Robinson  <mrobinson at igalia.com>
 
         Reviewed by Xan Lopez.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 2a5ad5b..208a645 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -651,8 +651,7 @@ __ZN7WebCore6Loader20servePendingRequestsENS0_8PriorityE
 __ZN7WebCore6Widget12setFrameRectERKNS_7IntRectE
 __ZN7WebCore6Widget16removeFromParentEv
 __ZN7WebCore6Widget17frameRectsChangedEv
-__ZN7WebCore6Widget20retainPlatformWidgetEv
-__ZN7WebCore6Widget21releasePlatformWidgetEv
+__ZN7WebCore6Widget17setPlatformWidgetEP6NSView
 __ZN7WebCore6Widget4hideEv
 __ZN7WebCore6Widget4showEv
 __ZN7WebCore6Widget5paintEPNS_15GraphicsContextERKNS_7IntRectE
@@ -1037,6 +1036,7 @@ __ZNK7WebCore6Editor7canCopyEv
 __ZNK7WebCore6Editor7canEditEv
 __ZNK7WebCore6Editor8canPasteEv
 __ZNK7WebCore6Editor9canDeleteEv
+__ZNK7WebCore6Widget14platformWidgetEv
 __ZNK7WebCore6Widget23convertToContainingViewERKNS_7IntRectE
 __ZNK7WebCore6Widget23convertToContainingViewERKNS_8IntPointE
 __ZNK7WebCore6Widget25convertFromContainingViewERKNS_7IntRectE
@@ -1145,7 +1145,6 @@ _wkSignalCFReadStreamEnd
 _wkSignalCFReadStreamError
 _wkSignalCFReadStreamHasBytes
 
-
 #if ENABLE(3D_RENDERING)
 _WebCoreHas3DRendering
 #endif
diff --git a/WebCore/bindings/objc/ObjCEventListener.h b/WebCore/bindings/objc/ObjCEventListener.h
index 434ef45..5a2941f 100644
--- a/WebCore/bindings/objc/ObjCEventListener.h
+++ b/WebCore/bindings/objc/ObjCEventListener.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006, 2008 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2006, 2008, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <sam.weinig at gmail.com>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,8 +28,8 @@
 #define ObjCEventListener_h
 
 #include "EventListener.h"
-
-#include <wtf/PassRefPtr.h>
+#include <wtf/Forward.h>
+#include <wtf/RetainPtr.h>
 
 @protocol DOMEventListener;
 
@@ -37,7 +37,8 @@ namespace WebCore {
 
     class ObjCEventListener : public EventListener {
     public:
-        static PassRefPtr<ObjCEventListener> wrap(id <DOMEventListener>);
+        typedef id<DOMEventListener> ObjCListener;
+        static PassRefPtr<ObjCEventListener> wrap(ObjCListener);
 
         static const ObjCEventListener* cast(const EventListener* listener)
         {
@@ -46,17 +47,15 @@ namespace WebCore {
                 : 0;
         }
 
-        virtual bool operator==(const EventListener& other);
-
     private:
-        static ObjCEventListener* find(id <DOMEventListener>);
+        static ObjCEventListener* find(ObjCListener);
 
-        ObjCEventListener(id <DOMEventListener>);
+        ObjCEventListener(ObjCListener);
         virtual ~ObjCEventListener();
-
+        virtual bool operator==(const EventListener&);
         virtual void handleEvent(ScriptExecutionContext*, Event*);
 
-        id <DOMEventListener> m_listener;
+        RetainPtr<ObjCListener> m_listener;
     };
 
 } // namespace WebCore
diff --git a/WebCore/bindings/objc/ObjCEventListener.mm b/WebCore/bindings/objc/ObjCEventListener.mm
index c1b8aa5..6e2a9fa 100644
--- a/WebCore/bindings/objc/ObjCEventListener.mm
+++ b/WebCore/bindings/objc/ObjCEventListener.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2006 James G. Speth (speth at end.com)
  * Copyright (C) 2006 Samuel Weinig (sam.weinig at gmail.com)
  *
@@ -40,7 +40,7 @@ namespace WebCore {
 typedef HashMap<id, ObjCEventListener*> ListenerMap;
 static ListenerMap* listenerMap;
 
-ObjCEventListener* ObjCEventListener::find(id <DOMEventListener> listener)
+ObjCEventListener* ObjCEventListener::find(ObjCListener listener)
 {
     ListenerMap* map = listenerMap;
     if (!map)
@@ -48,7 +48,7 @@ ObjCEventListener* ObjCEventListener::find(id <DOMEventListener> listener)
     return map->get(listener);
 }
 
-PassRefPtr<ObjCEventListener> ObjCEventListener::wrap(id <DOMEventListener> listener)
+PassRefPtr<ObjCEventListener> ObjCEventListener::wrap(ObjCListener listener)
 {
     RefPtr<ObjCEventListener> wrapper = find(listener);
     if (wrapper)
@@ -56,9 +56,9 @@ PassRefPtr<ObjCEventListener> ObjCEventListener::wrap(id <DOMEventListener> list
     return adoptRef(new ObjCEventListener(listener));
 }
 
-ObjCEventListener::ObjCEventListener(id <DOMEventListener> listener)
+ObjCEventListener::ObjCEventListener(ObjCListener listener)
     : EventListener(ObjCEventListenerType)
-    , m_listener([listener retain])
+    , m_listener(listener)
 {
     ListenerMap* map = listenerMap;
     if (!map) {
@@ -70,13 +70,13 @@ ObjCEventListener::ObjCEventListener(id <DOMEventListener> listener)
 
 ObjCEventListener::~ObjCEventListener()
 {
-    listenerMap->remove(m_listener);
-    [m_listener release];
+    listenerMap->remove(m_listener.get());
 }
 
 void ObjCEventListener::handleEvent(ScriptExecutionContext*, Event* event)
 {
-    [m_listener handleEvent:kit(event)];
+    ObjCListener listener = m_listener.get();
+    [listener handleEvent:kit(event)];
 }
 
 bool ObjCEventListener::operator==(const EventListener& listener)
diff --git a/WebCore/bridge/objc/objc_instance.mm b/WebCore/bridge/objc/objc_instance.mm
index 6c56458..989d9eb 100644
--- a/WebCore/bridge/objc/objc_instance.mm
+++ b/WebCore/bridge/objc/objc_instance.mm
@@ -27,7 +27,6 @@
 #import "objc_instance.h"
 
 #import "runtime_method.h"
-#import "FoundationExtras.h"
 #import "ObjCRuntimeObject.h"
 #import "WebScriptObject.h"
 #import <objc/objc-auto.h>
@@ -70,9 +69,9 @@ RuntimeObject* ObjcInstance::newRuntimeObject(ExecState* exec)
 
 void ObjcInstance::setGlobalException(NSString* exception, JSGlobalObject* exceptionEnvironment)
 {
-    HardRelease(s_exception);
-    HardRetain(exception);
-    s_exception = exception;
+    NSString *oldException = s_exception;
+    s_exception = [exception copy];
+    [oldException release];
 
     s_exceptionEnvironment = exceptionEnvironment;
 }
@@ -89,9 +88,8 @@ void ObjcInstance::moveGlobalExceptionToExecState(ExecState* exec)
         throwError(exec, s_exception);
     }
 
-    HardRelease(s_exception);
-    s_exception = 0;
-
+    [s_exception release];
+    s_exception = nil;
     s_exceptionEnvironment = 0;
 }
 
diff --git a/WebCore/platform/Cursor.cpp b/WebCore/platform/Cursor.cpp
index 3f17ad9..dac5c24 100644
--- a/WebCore/platform/Cursor.cpp
+++ b/WebCore/platform/Cursor.cpp
@@ -253,12 +253,16 @@ Cursor::Cursor(Type type)
 {
 }
 
+#if !PLATFORM(MAC)
+
 PlatformCursor Cursor::platformCursor() const
 {
     ensurePlatformCursor();
     return m_platformCursor;
 }
 
+#endif
+
 const Cursor& pointerCursor()
 {
     DEFINE_STATIC_LOCAL(Cursor, c, (Cursor::Pointer));
diff --git a/WebCore/platform/Cursor.h b/WebCore/platform/Cursor.h
index 92d3596..a962bbb 100644
--- a/WebCore/platform/Cursor.h
+++ b/WebCore/platform/Cursor.h
@@ -35,6 +35,8 @@ typedef struct HICON__* HICON;
 typedef HICON HCURSOR;
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
+#elif PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
 #elif PLATFORM(GTK)
 #include "GRefPtrGtk.h"
 #elif PLATFORM(QT)
@@ -82,7 +84,7 @@ namespace WebCore {
     };
     typedef RefPtr<SharedCursor> PlatformCursor;
 #elif PLATFORM(MAC)
-    typedef NSCursor* PlatformCursor;
+    typedef NSCursor *PlatformCursor;
 #elif PLATFORM(GTK)
     typedef PlatformRefPtr<GdkCursor> PlatformCursor;
 #elif PLATFORM(EFL)
@@ -183,7 +185,11 @@ namespace WebCore {
         IntPoint m_hotSpot;
 #endif
 
+#if !PLATFORM(MAC)
         mutable PlatformCursor m_platformCursor;
+#else
+        mutable RetainPtr<NSCursor> m_platformCursor;
+#endif
     };
 
     IntPoint determineHotSpot(Image*, const IntPoint& specifiedHotSpot);
diff --git a/WebCore/platform/Widget.cpp b/WebCore/platform/Widget.cpp
index 49ffa02..77560ff 100644
--- a/WebCore/platform/Widget.cpp
+++ b/WebCore/platform/Widget.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 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
@@ -127,16 +127,6 @@ IntPoint Widget::convertFromContainingWindowToRoot(const Widget*, const IntPoint
 }
 #endif
 
-#if !PLATFORM(MAC) && !PLATFORM(GTK)
-void Widget::releasePlatformWidget()
-{
-}
-
-void Widget::retainPlatformWidget()
-{
-}
-#endif
-
 IntRect Widget::convertToContainingView(const IntRect& localRect) const
 {
     if (const ScrollView* parentScrollView = parent()) {
diff --git a/WebCore/platform/Widget.h b/WebCore/platform/Widget.h
index 0eb0c69..3f9a045 100644
--- a/WebCore/platform/Widget.h
+++ b/WebCore/platform/Widget.h
@@ -27,6 +27,22 @@
 #ifndef Widget_h
 #define Widget_h
 
+#include "IntRect.h"
+#include <wtf/Forward.h>
+#include <wtf/RefCounted.h>
+
+#if PLATFORM(CHROMIUM)
+#include "PlatformWidget.h"
+#endif
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+#endif
+
+#if PLATFORM(QT)
+#include <qglobal.h>
+#endif
+
 #if PLATFORM(MAC)
 #ifdef __OBJC__
 @class NSView;
@@ -35,7 +51,7 @@
 class NSView;
 class NSWindow;
 #endif
-typedef NSView* PlatformWidget;
+typedef NSView *PlatformWidget;
 #endif
 
 #if PLATFORM(WIN)
@@ -51,7 +67,6 @@ typedef GtkWidget* PlatformWidget;
 #endif
 
 #if PLATFORM(QT)
-#include <qglobal.h>
 QT_BEGIN_NAMESPACE
 class QWidget;
 QT_END_NAMESPACE
@@ -72,10 +87,6 @@ typedef BView* PlatformWidget;
 typedef void* PlatformWidget;
 #endif
 
-#if PLATFORM(CHROMIUM)
-#include "PlatformWidget.h"
-#endif
-
 #if PLATFORM(EFL)
 typedef struct _Evas_Object Evas_Object;
 typedef struct _Evas Evas;
@@ -90,13 +101,6 @@ typedef QWebPageClient* PlatformPageClient;
 typedef PlatformWidget PlatformPageClient;
 #endif
 
-#include "IntPoint.h"
-#include "IntRect.h"
-#include "IntSize.h"
-
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
-
 namespace WebCore {
 
 class Cursor;
@@ -127,15 +131,9 @@ public:
     Widget(PlatformWidget = 0);
     virtual ~Widget();
 
-    PlatformWidget platformWidget() const { return m_widget; }
-    void setPlatformWidget(PlatformWidget widget)
-    {
-        if (widget != m_widget) {
-            releasePlatformWidget();
-            m_widget = widget;
-            retainPlatformWidget();
-        }
-    }
+    PlatformWidget platformWidget() const;
+    void setPlatformWidget(PlatformWidget);
+
 #if PLATFORM(HAIKU)
     PlatformWidget topLevelPlatformWidget() const { return m_topLevelPlatformWidget; }
     void setTopLevelPlatformWidget(PlatformWidget widget)
@@ -251,7 +249,11 @@ private:
 
 private:
     ScrollView* m_parent;
+#if !PLATFORM(MAC)
     PlatformWidget m_widget;
+#else
+    RetainPtr<NSView> m_widget;
+#endif
     bool m_selfVisible;
     bool m_parentVisible;
 
@@ -274,6 +276,36 @@ private:
 #endif
 };
 
+#if !PLATFORM(MAC)
+
+inline PlatformWidget Widget::platformWidget() const
+{
+    return m_widget;
+}
+
+inline void Widget::setPlatformWidget(PlatformWidget widget)
+{
+    if (widget != m_widget) {
+        releasePlatformWidget();
+        m_widget = widget;
+        retainPlatformWidget();
+    }
+}
+
+#endif
+
+#if !PLATFORM(GTK)
+
+inline void Widget::releasePlatformWidget()
+{
+}
+
+inline void Widget::retainPlatformWidget()
+{
+}
+
+#endif
+
 } // namespace WebCore
 
 #endif // Widget_h
diff --git a/WebCore/platform/graphics/mac/ImageMac.mm b/WebCore/platform/graphics/mac/ImageMac.mm
index 96b93be..6ad3080 100644
--- a/WebCore/platform/graphics/mac/ImageMac.mm
+++ b/WebCore/platform/graphics/mac/ImageMac.mm
@@ -27,7 +27,6 @@
 #import "BitmapImage.h"
 
 #import "FloatRect.h"
-#import "FoundationExtras.h"
 #import "GraphicsContext.h"
 #import "PlatformString.h"
 #import "SharedBuffer.h"
diff --git a/WebCore/platform/mac/ClipboardMac.mm b/WebCore/platform/mac/ClipboardMac.mm
index 85d470c..10d196a 100644
--- a/WebCore/platform/mac/ClipboardMac.mm
+++ b/WebCore/platform/mac/ClipboardMac.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 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
@@ -31,7 +31,6 @@
 #import "DragController.h"
 #import "DragData.h"
 #import "Editor.h"
-#import "FoundationExtras.h"
 #import "FileList.h"
 #import "Frame.h"
 #import "Image.h"
@@ -70,7 +69,7 @@ bool ClipboardMac::hasData()
     return m_pasteboard && [m_pasteboard.get() types] && [[m_pasteboard.get() types] count] > 0;
 }
     
-static NSString *cocoaTypeFromHTMLClipboardType(const String& type)
+static RetainPtr<NSString> cocoaTypeFromHTMLClipboardType(const String& type)
 {
     String qType = type.stripWhiteSpace();
 
@@ -93,11 +92,11 @@ static NSString *cocoaTypeFromHTMLClipboardType(const String& type)
     if (utiType) {
         CFStringRef pbType = UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassNSPboardType);
         if (pbType)
-            return HardAutorelease(pbType);
+            return (NSString *)pbType;
     }
 
-   // No mapping, just pass the whole string though
-    return qType;
+    // No mapping, just pass the whole string though
+    return (NSString *)qType;
 }
 
 static String utiTypeFromCocoaType(NSString *type)
@@ -151,9 +150,8 @@ void ClipboardMac::clearData(const String& type)
 
     // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
 
-    NSString *cocoaType = cocoaTypeFromHTMLClipboardType(type);
-    if (cocoaType)
-        [m_pasteboard.get() setString:@"" forType:cocoaType];
+    if (RetainPtr<NSString> cocoaType = cocoaTypeFromHTMLClipboardType(type))
+        [m_pasteboard.get() setString:@"" forType:cocoaType.get()];
 }
 
 void ClipboardMac::clearAllData()
@@ -218,19 +216,19 @@ String ClipboardMac::getData(const String& type, bool& success) const
     if (policy() != ClipboardReadable)
         return String();
 
-    NSString *cocoaType = cocoaTypeFromHTMLClipboardType(type);
+    RetainPtr<NSString> cocoaType = cocoaTypeFromHTMLClipboardType(type);
     NSString *cocoaValue = nil;
 
     // Grab the value off the pasteboard corresponding to the cocoaType
-    if ([cocoaType isEqualToString:NSURLPboardType]) {
+    if ([cocoaType.get() isEqualToString:NSURLPboardType]) {
         // "URL" and "text/url-list" both map to NSURLPboardType in cocoaTypeFromHTMLClipboardType(), "URL" only wants the first URL
         bool onlyFirstURL = (type == "URL");
         NSArray *absoluteURLs = absoluteURLsFromPasteboard(m_pasteboard.get(), onlyFirstURL);
         cocoaValue = [absoluteURLs componentsJoinedByString:@"\n"];
-    } else if ([cocoaType isEqualToString:NSStringPboardType]) {
-        cocoaValue = [[m_pasteboard.get() stringForType:cocoaType] precomposedStringWithCanonicalMapping];
+    } else if ([cocoaType.get() isEqualToString:NSStringPboardType]) {
+        cocoaValue = [[m_pasteboard.get() stringForType:cocoaType.get()] precomposedStringWithCanonicalMapping];
     } else if (cocoaType)
-        cocoaValue = [m_pasteboard.get() stringForType:cocoaType];
+        cocoaValue = [m_pasteboard.get() stringForType:cocoaType.get()];
 
     // Enforce changeCount ourselves for security.  We check after reading instead of before to be
     // sure it doesn't change between our testing the change count and accessing the data.
@@ -248,10 +246,10 @@ bool ClipboardMac::setData(const String &type, const String &data)
         return false;
     // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
 
-    NSString *cocoaType = cocoaTypeFromHTMLClipboardType(type);
+    RetainPtr<NSString> cocoaType = cocoaTypeFromHTMLClipboardType(type);
     NSString *cocoaData = data;
 
-    if ([cocoaType isEqualToString:NSURLPboardType]) {
+    if ([cocoaType.get() isEqualToString:NSURLPboardType]) {
         [m_pasteboard.get() addTypes:[NSArray arrayWithObject:NSURLPboardType] owner:nil];
         NSURL *url = [[NSURL alloc] initWithString:cocoaData];
         [url writeToPasteboard:m_pasteboard.get()];
@@ -268,8 +266,8 @@ bool ClipboardMac::setData(const String &type, const String &data)
 
     if (cocoaType) {
         // everything else we know of goes on the pboard as a string
-        [m_pasteboard.get() addTypes:[NSArray arrayWithObject:cocoaType] owner:nil];
-        return [m_pasteboard.get() setString:cocoaData forType:cocoaType];
+        [m_pasteboard.get() addTypes:[NSArray arrayWithObject:cocoaType.get()] owner:nil];
+        return [m_pasteboard.get() setString:cocoaData forType:cocoaType.get()];
     }
 
     return false;
diff --git a/WebCore/platform/mac/CursorMac.mm b/WebCore/platform/mac/CursorMac.mm
index 1b4c1b1..c006cbc 100644
--- a/WebCore/platform/mac/CursorMac.mm
+++ b/WebCore/platform/mac/CursorMac.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 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
@@ -27,7 +27,6 @@
 #import "Cursor.h"
 
 #import "BlockExceptions.h"
-#import "FoundationExtras.h"
 #import <wtf/StdLibExtras.h>
 
 @interface WebCoreCursorBundle : NSObject { }
@@ -41,14 +40,14 @@ namespace WebCore {
 // Simple NSCursor calls shouldn't need protection,
 // but creating a cursor with a bad image might throw.
 
-static NSCursor* createCustomCursor(Image* image, const IntPoint& hotSpot)
+static RetainPtr<NSCursor> createCustomCursor(Image* image, const IntPoint& hotSpot)
 {
     // FIXME: The cursor won't animate.  Not sure if that's a big deal.
-    NSImage* img = image->getNSImage();
-    if (!img)
+    NSImage* nsImage = image->getNSImage();
+    if (!nsImage)
         return 0;
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    return [[NSCursor alloc] initWithImage:img hotSpot:hotSpot];
+    return RetainPtr<NSCursor>(AdoptNS, [[NSCursor alloc] initWithImage:nsImage hotSpot:hotSpot]);
     END_BLOCK_OBJC_EXCEPTIONS;
     return 0;
 }
@@ -81,118 +80,118 @@ void Cursor::ensurePlatformCursor() const
 
     switch (m_type) {
     case Cursor::Pointer:
-        m_platformCursor = HardRetain([NSCursor arrowCursor]);
+        m_platformCursor = [NSCursor arrowCursor];
         break;
     case Cursor::Cross:
-        m_platformCursor = HardRetain(leakNamedCursor("crossHairCursor", 11, 11));
+        m_platformCursor = leakNamedCursor("crossHairCursor", 11, 11);
         break;
     case Cursor::Hand:
-        m_platformCursor = HardRetain(leakNamedCursor("linkCursor", 6, 1));
+        m_platformCursor = leakNamedCursor("linkCursor", 6, 1);
         break;
     case Cursor::IBeam:
-        m_platformCursor = HardRetain([NSCursor IBeamCursor]);
+        m_platformCursor = [NSCursor IBeamCursor];
         break;
     case Cursor::Wait:
-        m_platformCursor = HardRetain(leakNamedCursor("waitCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("waitCursor", 7, 7);
         break;
     case Cursor::Help:
-        m_platformCursor = HardRetain(leakNamedCursor("helpCursor", 8, 8));
+        m_platformCursor = leakNamedCursor("helpCursor", 8, 8);
         break;
     case Cursor::Move:
     case Cursor::MiddlePanning:
-        m_platformCursor = HardRetain(leakNamedCursor("moveCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("moveCursor", 7, 7);
         break;
     case Cursor::EastResize:
     case Cursor::EastPanning:
-        m_platformCursor = HardRetain(leakNamedCursor("eastResizeCursor", 14, 7));
+        m_platformCursor = leakNamedCursor("eastResizeCursor", 14, 7);
         break;
     case Cursor::NorthResize:
     case Cursor::NorthPanning:
-        m_platformCursor = HardRetain(leakNamedCursor("northResizeCursor", 7, 1));
+        m_platformCursor = leakNamedCursor("northResizeCursor", 7, 1);
         break;
     case Cursor::NorthEastResize:
     case Cursor::NorthEastPanning:
-        m_platformCursor = HardRetain(leakNamedCursor("northEastResizeCursor", 14, 1));
+        m_platformCursor = leakNamedCursor("northEastResizeCursor", 14, 1);
         break;
     case Cursor::NorthWestResize:
     case Cursor::NorthWestPanning:
-        m_platformCursor = HardRetain(leakNamedCursor("northWestResizeCursor", 0, 0));
+        m_platformCursor = leakNamedCursor("northWestResizeCursor", 0, 0);
         break;
     case Cursor::SouthResize:
     case Cursor::SouthPanning:
-        m_platformCursor = HardRetain(leakNamedCursor("southResizeCursor", 7, 14));
+        m_platformCursor = leakNamedCursor("southResizeCursor", 7, 14);
         break;
     case Cursor::SouthEastResize:
     case Cursor::SouthEastPanning:
-        m_platformCursor = HardRetain(leakNamedCursor("southEastResizeCursor", 14, 14));
+        m_platformCursor = leakNamedCursor("southEastResizeCursor", 14, 14);
         break;
     case Cursor::SouthWestResize:
     case Cursor::SouthWestPanning:
-        m_platformCursor = HardRetain(leakNamedCursor("southWestResizeCursor", 1, 14));
+        m_platformCursor = leakNamedCursor("southWestResizeCursor", 1, 14);
         break;
     case Cursor::WestResize:
-        m_platformCursor = HardRetain(leakNamedCursor("westResizeCursor", 1, 7));
+        m_platformCursor = leakNamedCursor("westResizeCursor", 1, 7);
         break;
     case Cursor::NorthSouthResize:
-        m_platformCursor = HardRetain(leakNamedCursor("northSouthResizeCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("northSouthResizeCursor", 7, 7);
         break;
     case Cursor::EastWestResize:
     case Cursor::WestPanning:
-        m_platformCursor = HardRetain(leakNamedCursor("eastWestResizeCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("eastWestResizeCursor", 7, 7);
         break;
     case Cursor::NorthEastSouthWestResize:
-        m_platformCursor = HardRetain(leakNamedCursor("northEastSouthWestResizeCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("northEastSouthWestResizeCursor", 7, 7);
         break;
     case Cursor::NorthWestSouthEastResize:
-        m_platformCursor = HardRetain(leakNamedCursor("northWestSouthEastResizeCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("northWestSouthEastResizeCursor", 7, 7);
         break;
     case Cursor::ColumnResize:
-        m_platformCursor = HardRetain([NSCursor resizeLeftRightCursor]);
+        m_platformCursor = [NSCursor resizeLeftRightCursor];
         break;
     case Cursor::RowResize:
-        m_platformCursor = HardRetain([NSCursor resizeUpDownCursor]);
+        m_platformCursor = [NSCursor resizeUpDownCursor];
         break;
     case Cursor::VerticalText:
-        m_platformCursor = HardRetain(leakNamedCursor("verticalTextCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("verticalTextCursor", 7, 7);
         break;
     case Cursor::Cell:
-        m_platformCursor = HardRetain(leakNamedCursor("cellCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("cellCursor", 7, 7);
         break;
     case Cursor::ContextMenu:
-        m_platformCursor = HardRetain(leakNamedCursor("contextMenuCursor", 3, 2));
+        m_platformCursor = leakNamedCursor("contextMenuCursor", 3, 2);
         break;
     case Cursor::Alias:
-        m_platformCursor = HardRetain(leakNamedCursor("aliasCursor", 11, 3));
+        m_platformCursor = leakNamedCursor("aliasCursor", 11, 3);
         break;
     case Cursor::Progress:
-        m_platformCursor = HardRetain(leakNamedCursor("progressCursor", 3, 2));
+        m_platformCursor = leakNamedCursor("progressCursor", 3, 2);
         break;
     case Cursor::NoDrop:
-        m_platformCursor = HardRetain(leakNamedCursor("noDropCursor", 3, 1));
+        m_platformCursor = leakNamedCursor("noDropCursor", 3, 1);
         break;
     case Cursor::Copy:
-        m_platformCursor = HardRetain(leakNamedCursor("copyCursor", 3, 2));
+        m_platformCursor = leakNamedCursor("copyCursor", 3, 2);
         break;
     case Cursor::None:
-        m_platformCursor = HardRetain(leakNamedCursor("noneCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("noneCursor", 7, 7);
         break;
     case Cursor::NotAllowed:
-        m_platformCursor = HardRetain(leakNamedCursor("notAllowedCursor", 11, 11));
+        m_platformCursor = leakNamedCursor("notAllowedCursor", 11, 11);
         break;
     case Cursor::ZoomIn:
-        m_platformCursor = HardRetain(leakNamedCursor("zoomInCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("zoomInCursor", 7, 7);
         break;
     case Cursor::ZoomOut:
-        m_platformCursor = HardRetain(leakNamedCursor("zoomOutCursor", 7, 7));
+        m_platformCursor = leakNamedCursor("zoomOutCursor", 7, 7);
         break;
     case Cursor::Grab:
-        m_platformCursor = HardRetain([NSCursor openHandCursor]);
+        m_platformCursor = [NSCursor openHandCursor];
         break;
     case Cursor::Grabbing:
-        m_platformCursor = HardRetain([NSCursor closedHandCursor]);
+        m_platformCursor = [NSCursor closedHandCursor];
         break;
     case Cursor::Custom:
-        m_platformCursor = HardRetainWithNSRelease(createCustomCursor(m_image.get(), m_hotSpot));
+        m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot);
         break;
     }
 }
@@ -201,7 +200,7 @@ Cursor::Cursor(const Cursor& other)
     : m_type(other.m_type)
     , m_image(other.m_image)
     , m_hotSpot(other.m_hotSpot)
-    , m_platformCursor(HardRetain(other.m_platformCursor))
+    , m_platformCursor(other.m_platformCursor)
 {
 }
 
@@ -210,16 +209,18 @@ Cursor& Cursor::operator=(const Cursor& other)
     m_type = other.m_type;
     m_image = other.m_image;
     m_hotSpot = other.m_hotSpot;
-
-    HardRetain(other.m_platformCursor);
-    HardRelease(m_platformCursor);
     m_platformCursor = other.m_platformCursor;
     return *this;
 }
 
 Cursor::~Cursor()
 {
-    HardRelease(m_platformCursor);
+}
+
+NSCursor *Cursor::platformCursor() const
+{
+    ensurePlatformCursor();
+    return m_platformCursor.get();
 }
 
 } // namespace WebCore
diff --git a/WebCore/platform/mac/FoundationExtras.h b/WebCore/platform/mac/FoundationExtras.h
index 85ce8d7..39b12ea 100644
--- a/WebCore/platform/mac/FoundationExtras.h
+++ b/WebCore/platform/mac/FoundationExtras.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,50 +26,15 @@
 #import <CoreFoundation/CFBase.h>
 #import <Foundation/NSObject.h>
 
-// nil-checked CFRetain/CFRelease covers for Objective-C ids
-
-// Use CFRetain, CFRelease, HardRetain, or HardRelease instead of
-// -[NSObject retain] and -[NSObject release] if you want to store
-// a pointer to an Objective-C object into memory that won't
-// be scanned for GC, like a C++ object.
-
-static inline id HardRetain(id obj)
-{
-    if (obj) CFRetain(obj);
-    return obj;
-}
-
-static inline void HardRelease(id obj)
-{
-    if (obj) CFRelease(obj);
-}
-
-// As if CF and Foundation had logically separate reference counts,
-// this function first increments the CF retain count, and then
-// decrements the NS retain count. This is needed to handle cases where
-// -retain/-release aren't equivalent to CFRetain/HardRelease, such as
-// when GC is used.
-
-// Use HardRetainWithNSRelease after allocating and initializing a NSObject
-// if you want to store a pointer to that object into memory that won't
-// be scanned for GC, like a C++ object.
-
-static inline id HardRetainWithNSRelease(id obj)
-{
-    HardRetain(obj);
-    [obj release];
-    return obj;
-}
-
 // Use HardAutorelease to return an object made by a CoreFoundation
 // "create" or "copy" function as an autoreleased and garbage collected
 // object. CF objects need to be "made collectable" for autorelease to work
 // properly under GC.
 
-static inline id HardAutorelease(CFTypeRef obj)
+static inline id HardAutorelease(CFTypeRef object)
 {
-    if (obj)
-        CFMakeCollectable(obj);
-    [(id)obj autorelease];
-    return (id)obj;
+    if (object)
+        CFMakeCollectable(object);
+    [(id)object autorelease];
+    return (id)object;
 }
diff --git a/WebCore/platform/mac/ThemeMac.mm b/WebCore/platform/mac/ThemeMac.mm
index c57e8df..61f2481 100644
--- a/WebCore/platform/mac/ThemeMac.mm
+++ b/WebCore/platform/mac/ThemeMac.mm
@@ -375,7 +375,7 @@ static const int* buttonMargins(NSControlSize controlSize)
     return margins[controlSize];
 }
 
-static void setupButtonCell(NSButtonCell *&buttonCell, ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor)
+static NSButtonCell *setUpButtonCell(NSButtonCell *buttonCell, ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor)
 {
     if (!buttonCell) {
         buttonCell = [[NSButtonCell alloc] init];
@@ -404,14 +404,25 @@ static void setupButtonCell(NSButtonCell *&buttonCell, ControlPart part, Control
 
     // Update the various states we respond to.
     updateStates(buttonCell, states);
+
+    return buttonCell;
 }
     
+static NSButtonCell *nonDefaultButton(ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor)
+{
+    static NSButtonCell *cell = setUpButtonCell(cell, part, states, zoomedRect, zoomFactor);    
+    return cell;
+}
+
+static NSButtonCell *defaultButton(ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor)
+{
+    static NSButtonCell *cell = setUpButtonCell(cell, part, states, zoomedRect, zoomFactor);    
+    return cell;
+}
+
 static NSButtonCell *button(ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor)
 {
-    bool isDefault = states & DefaultState;
-    static NSButtonCell *cells[2];
-    setupButtonCell(cells[isDefault], part, states, zoomedRect, zoomFactor);    
-    return cells[isDefault];
+    return ((states & DefaultState) ? nonDefaultButton : defaultButton)(part, states, zoomedRect, zoomFactor);
 }
 
 static void paintButton(ControlPart part, ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView)
diff --git a/WebCore/platform/mac/WidgetMac.mm b/WebCore/platform/mac/WidgetMac.mm
index 2598591..e8bb81d 100644
--- a/WebCore/platform/mac/WidgetMac.mm
+++ b/WebCore/platform/mac/WidgetMac.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 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
@@ -35,7 +35,6 @@
 #import "Cursor.h"
 #import "Document.h"
 #import "Font.h"
-#import "FoundationExtras.h"
 #import "Frame.h"
 #import "GraphicsContext.h"
 #import "NotImplemented.h"
@@ -100,7 +99,6 @@ Widget::Widget(NSView *view)
 
 Widget::~Widget()
 {
-    releasePlatformWidget();
     delete m_data;
 }
 
@@ -354,16 +352,18 @@ IntPoint Widget::convertFromContainingWindowToRoot(const Widget* rootWidget, con
     return point;
 }
 
-void Widget::releasePlatformWidget()
+NSView *Widget::platformWidget() const
 {
-    HardRelease(m_widget);
-    m_data->previousVisibleRect = NSZeroRect;
+    return m_widget.get();
 }
 
-void Widget::retainPlatformWidget()
+void Widget::setPlatformWidget(NSView *widget)
 {
-    HardRetain(m_widget);
+    if (widget == m_widget)
+        return;
+
+    m_widget = widget;
+    m_data->previousVisibleRect = NSZeroRect;
 }
 
 } // namespace WebCore
-
diff --git a/WebCore/platform/network/mac/WebCoreURLResponse.mm b/WebCore/platform/network/mac/WebCoreURLResponse.mm
index 9be4714..e287e5f 100644
--- a/WebCore/platform/network/mac/WebCoreURLResponse.mm
+++ b/WebCore/platform/network/mac/WebCoreURLResponse.mm
@@ -29,7 +29,6 @@
 #import "config.h"
 #import "WebCoreURLResponse.h"
 
-#import "FoundationExtras.h"
 #import "MIMETypeRegistry.h"
 #import <objc/objc-class.h>
 #import <wtf/Assertions.h>
@@ -327,12 +326,12 @@ static NSDictionary *createExtensionToMIMETypeMap()
     ];
 }
 
-static NSString *mimeTypeFromUTITree(CFStringRef uti)
+static RetainPtr<NSString> mimeTypeFromUTITree(CFStringRef uti)
 {
     // Check if this UTI has a MIME type.
     RetainPtr<CFStringRef> mimeType(AdoptCF, UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType));
     if (mimeType)
-        return (NSString *)HardAutorelease(mimeType.releaseRef());
+        return (NSString *)mimeType.get();
     
     // If not, walk the ancestory of this UTI via its "ConformsTo" tags and return the first MIME type we find.
     RetainPtr<CFDictionaryRef> decl(AdoptCF, UTTypeCopyDeclaration(uti));
@@ -354,7 +353,7 @@ static NSString *mimeTypeFromUTITree(CFStringRef uti)
             if (CFGetTypeID(object) != CFStringGetTypeID())
                 continue;
 
-            if (NSString *mimeType = mimeTypeFromUTITree((CFStringRef)object))
+            if (RetainPtr<NSString> mimeType = mimeTypeFromUTITree((CFStringRef)object))
                 return mimeType;
         }
     }
@@ -366,13 +365,13 @@ static NSString *mimeTypeFromUTITree(CFStringRef uti)
 
 -(void)adjustMIMETypeIfNecessary
 {
-    NSString *result = [self MIMEType];
-    NSString *originalResult = result;
+    RetainPtr<NSString> result = [self MIMEType];
+    RetainPtr<NSString> originalResult = result;
 
 #ifdef BUILDING_ON_TIGER
     // When content sniffing is disabled, Tiger's CFNetwork automatically returns application/octet-stream for certain
     // extensions even when scouring the UTI maps would end up with a better result, so we'll give a chance for that to happen.
-    if ([[self URL] isFileURL] && [result caseInsensitiveCompare:@"application/octet-stream"] == NSOrderedSame)
+    if ([[self URL] isFileURL] && [result.get() caseInsensitiveCompare:@"application/octet-stream"] == NSOrderedSame)
         result = nil;
 #endif
 
@@ -403,7 +402,7 @@ static NSString *mimeTypeFromUTITree(CFStringRef uti)
 #ifndef BUILDING_ON_TIGER
     // <rdar://problem/5321972> Plain text document from HTTP server detected as application/octet-stream
     // Make the best guess when deciding between "generic binary" and "generic text" using a table of known binary MIME types.
-    if ([result isEqualToString:@"application/octet-stream"] && [self respondsToSelector:@selector(allHeaderFields)] && [[[self performSelector:@selector(allHeaderFields)] objectForKey:@"Content-Type"] hasPrefix:@"text/plain"]) {
+    if ([result.get() isEqualToString:@"application/octet-stream"] && [self respondsToSelector:@selector(allHeaderFields)] && [[[self performSelector:@selector(allHeaderFields)] objectForKey:@"Content-Type"] hasPrefix:@"text/plain"]) {
         static NSSet *binaryExtensions = createBinaryExtensionsSet();
         if (![binaryExtensions containsObject:[[[self suggestedFilename] pathExtension] lowercaseString]])
             result = @"text/plain";
@@ -413,12 +412,12 @@ static NSString *mimeTypeFromUTITree(CFStringRef uti)
 
 #ifdef BUILDING_ON_LEOPARD
     // Workaround for <rdar://problem/5539824>
-    if ([result isEqualToString:@"text/xml"])
+    if ([result.get() isEqualToString:@"text/xml"])
         result = @"application/xml";
 #endif
 
     if (result != originalResult)
-        [self _setMIMEType:result];
+        [self _setMIMEType:result.get()];
 }
 
 @end
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 3f0bb82..d95b4d0 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,15 @@
+2010-09-21  Darin Adler  <darin at apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Fix some Objective-C GC problems and use RetainPtr instead of HardRetain/Release
+        https://bugs.webkit.org/show_bug.cgi?id=46220
+
+        * Misc/WebNSFileManagerExtras.m:
+        (setMetaData): Use CFRelease instead of HardRelease.
+        (-[NSFileManager _webkit_setMetadataURL:referrer:atPath:]): Use CFStringCreateCopy
+        instead of -[NSObject copy] combined with HardRetainWithNSRelease.
+
 2010-09-22  Balazs Kelemen  <kb at inf.u-szeged.hu>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit/mac/Misc/WebNSFileManagerExtras.m b/WebKit/mac/Misc/WebNSFileManagerExtras.m
index f10781b..598e044 100644
--- a/WebKit/mac/Misc/WebNSFileManagerExtras.m
+++ b/WebKit/mac/Misc/WebNSFileManagerExtras.m
@@ -31,7 +31,6 @@
 #import "WebKitNSStringExtras.h"
 #import "WebNSURLExtras.h"
 #import <JavaScriptCore/Assertions.h>
-#import <WebCore/FoundationExtras.h>
 #import <WebKitSystemInterface.h>
 #import <sys/stat.h>
 
@@ -87,19 +86,22 @@
 
 typedef struct MetaDataInfo
 {
-    NSString *URLString;
-    NSString *referrer;
-    NSString *path;
+    CFStringRef URLString;
+    CFStringRef referrer;
+    CFStringRef path;
 } MetaDataInfo;
 
 static void *setMetaData(void* context)
 {
     MetaDataInfo *info = (MetaDataInfo *)context;
-    WKSetMetadataURL(info->URLString, info->referrer, info->path);
-    
-    HardRelease(info->URLString);
-    HardRelease(info->referrer);
-    HardRelease(info->path);
+    WKSetMetadataURL((NSString *)info->URLString, (NSString *)info->referrer, (NSString *)info->path);
+
+    if (info->URLString)
+        CFRelease(info->URLString);
+    if (info->referrer)
+        CFRelease(info->referrer);
+    if (info->path)
+        CFRelease(info->path);
     
     free(info);
     return 0;
@@ -124,9 +126,9 @@ static void *setMetaData(void* context)
 
     MetaDataInfo *info = malloc(sizeof(MetaDataInfo));
     
-    info->URLString = HardRetainWithNSRelease([URLString copy]);
-    info->referrer = HardRetainWithNSRelease([referrer copy]);
-    info->path = HardRetainWithNSRelease([path copy]);
+    info->URLString = CFStringCreateCopy(0, (CFStringRef)URLString);
+    info->referrer = CFStringCreateCopy(0, (CFStringRef)referrer);
+    info->path = CFStringCreateCopy(0, (CFStringRef)path);
 
     pthread_create(&tid, &attr, setMetaData, info);
     pthread_attr_destroy(&attr);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list