Title: [149562] trunk/Source/WebKit/mac
Revision
149562
Author
[email protected]
Date
2013-05-04 12:04:27 -0700 (Sat, 04 May 2013)

Log Message

Get rid of -[NSMutableDictionary _webkit_setObject:forUncopiedKey:]
https://bugs.webkit.org/show_bug.cgi?id=115592

Reviewed by Beth Dakin.

Using CFDictionarySetValue to set a key without having to copy it is not supported. Use NSMapTable with strong pointers instead.

* Misc/WebNSDictionaryExtras.h:
* Misc/WebNSDictionaryExtras.m:
* Panels/WebPanelAuthenticationHandler.h:
(NSURLAuthenticationChallenge):
* Panels/WebPanelAuthenticationHandler.m:
(-[WebPanelAuthenticationHandler init]):
(-[WebPanelAuthenticationHandler enqueueChallenge:forWindow:]):
(-[WebPanelAuthenticationHandler tryNextChallengeForWindow:]):
(-[WebPanelAuthenticationHandler startAuthentication:window:]):
(-[WebPanelAuthenticationHandler cancelAuthentication:]):
* Plugins/WebNetscapePluginView.h:
* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView destroyPlugin]):
(-[WebNetscapePluginView initWithFrame:pluginPackage:URL:baseURL:MIMEType:attributeKeys:attributeValues:loadManually:element:WebCore::]):
(-[WebNetscapePluginView webFrame:didFinishLoadWithReason:]):
(-[WebNetscapePluginView loadPluginRequest:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (149561 => 149562)


--- trunk/Source/WebKit/mac/ChangeLog	2013-05-04 18:46:20 UTC (rev 149561)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-05-04 19:04:27 UTC (rev 149562)
@@ -1,3 +1,29 @@
+2013-05-04  Anders Carlsson  <[email protected]>
+
+        Get rid of -[NSMutableDictionary _webkit_setObject:forUncopiedKey:]
+        https://bugs.webkit.org/show_bug.cgi?id=115592
+
+        Reviewed by Beth Dakin.
+
+        Using CFDictionarySetValue to set a key without having to copy it is not supported. Use NSMapTable with strong pointers instead.
+
+        * Misc/WebNSDictionaryExtras.h:
+        * Misc/WebNSDictionaryExtras.m:
+        * Panels/WebPanelAuthenticationHandler.h:
+        (NSURLAuthenticationChallenge):
+        * Panels/WebPanelAuthenticationHandler.m:
+        (-[WebPanelAuthenticationHandler init]):
+        (-[WebPanelAuthenticationHandler enqueueChallenge:forWindow:]):
+        (-[WebPanelAuthenticationHandler tryNextChallengeForWindow:]):
+        (-[WebPanelAuthenticationHandler startAuthentication:window:]):
+        (-[WebPanelAuthenticationHandler cancelAuthentication:]):
+        * Plugins/WebNetscapePluginView.h:
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView destroyPlugin]):
+        (-[WebNetscapePluginView initWithFrame:pluginPackage:URL:baseURL:MIMEType:attributeKeys:attributeValues:loadManually:element:WebCore::]):
+        (-[WebNetscapePluginView webFrame:didFinishLoadWithReason:]):
+        (-[WebNetscapePluginView loadPluginRequest:]):
+
 2011-05-01  Ryosuke Niwa  <[email protected]>
 
         [Mac] WebKit doesn't enable or disable autocorrections when system preferences are changed

Modified: trunk/Source/WebKit/mac/Misc/WebNSDictionaryExtras.h (149561 => 149562)


--- trunk/Source/WebKit/mac/Misc/WebNSDictionaryExtras.h	2013-05-04 18:46:20 UTC (rev 149561)
+++ trunk/Source/WebKit/mac/Misc/WebNSDictionaryExtras.h	2013-05-04 19:04:27 UTC (rev 149562)
@@ -39,7 +39,6 @@
 @end
 
 @interface NSMutableDictionary (WebNSDictionaryExtras)
-- (void)_webkit_setObject:(id)object forUncopiedKey:(id)key;
 - (void)_webkit_setInt:(int)value forKey:(id)key;
 - (void)_webkit_setFloat:(float)value forKey:(id)key;
 - (void)_webkit_setBool:(BOOL)value forKey:(id)key;

Modified: trunk/Source/WebKit/mac/Misc/WebNSDictionaryExtras.m (149561 => 149562)


--- trunk/Source/WebKit/mac/Misc/WebNSDictionaryExtras.m	2013-05-04 18:46:20 UTC (rev 149561)
+++ trunk/Source/WebKit/mac/Misc/WebNSDictionaryExtras.m	2013-05-04 19:04:27 UTC (rev 149562)
@@ -82,10 +82,6 @@
 @end
 
 @implementation NSMutableDictionary (WebNSDictionaryExtras)
--(void)_webkit_setObject:(id)object forUncopiedKey:(id)key
-{
-    CFDictionarySetValue((CFMutableDictionaryRef)self, key, object);
-}
 
 -(void)_webkit_setInt:(int)value forKey:(id)key
 {

Modified: trunk/Source/WebKit/mac/Panels/WebPanelAuthenticationHandler.h (149561 => 149562)


--- trunk/Source/WebKit/mac/Panels/WebPanelAuthenticationHandler.h	2013-05-04 18:46:20 UTC (rev 149561)
+++ trunk/Source/WebKit/mac/Panels/WebPanelAuthenticationHandler.h	2013-05-04 19:04:27 UTC (rev 149562)
@@ -33,9 +33,9 @@
 
 @interface WebPanelAuthenticationHandler : NSObject
 {
-    NSMutableDictionary *windowToPanel;
-    NSMutableDictionary *challengeToWindow;
-    NSMutableDictionary *windowToChallengeQueue;
+    NSMapTable *windowToPanel;
+    NSMapTable *challengeToWindow;
+    NSMapTable *windowToChallengeQueue;
 }
 
 + (id)sharedHandler;

Modified: trunk/Source/WebKit/mac/Panels/WebPanelAuthenticationHandler.m (149561 => 149562)


--- trunk/Source/WebKit/mac/Panels/WebPanelAuthenticationHandler.m	2013-05-04 18:46:20 UTC (rev 149561)
+++ trunk/Source/WebKit/mac/Panels/WebPanelAuthenticationHandler.m	2013-05-04 19:04:27 UTC (rev 149562)
@@ -30,7 +30,6 @@
 
 #import <Foundation/NSURLAuthenticationChallenge.h>
 #import <WebKit/WebAuthenticationPanel.h>
-#import <WebKit/WebNSDictionaryExtras.h>
 #import <wtf/Assertions.h>
 
 static NSString *WebModalDialogPretendWindow = @"WebModalDialogPretendWindow";
@@ -50,10 +49,11 @@
 {
     self = [super init];
     if (self != nil) {
-        windowToPanel = [[NSMutableDictionary alloc] init];
-        challengeToWindow = [[NSMutableDictionary alloc] init];
-        windowToChallengeQueue = [[NSMutableDictionary alloc] init];
+        windowToPanel = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsStrongMemory capacity:0];
+        challengeToWindow = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsStrongMemory capacity:0];
+        windowToChallengeQueue = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsStrongMemory capacity:0];
     }
+
     return self;
 }
 
@@ -68,9 +68,9 @@
 -(void)enqueueChallenge:(NSURLAuthenticationChallenge *)challenge forWindow:(id)window
 {
     NSMutableArray *queue = [windowToChallengeQueue objectForKey:window];
-    if (queue == nil) {
+    if (!queue) {
         queue = [[NSMutableArray alloc] init];
-        [windowToChallengeQueue _webkit_setObject:queue forUncopiedKey:window];
+        [windowToChallengeQueue setObject:queue forKey:window];
         [queue release];
     }
     [queue addObject:challenge];
@@ -79,15 +79,13 @@
 -(void)tryNextChallengeForWindow:(id)window
 {
     NSMutableArray *queue = [windowToChallengeQueue objectForKey:window];
-    if (queue == nil) {
+    if (!queue)
         return;
-    }
 
     NSURLAuthenticationChallenge *challenge = [[queue objectAtIndex:0] retain];
     [queue removeObjectAtIndex:0];
-    if ([queue count] == 0) {
+    if (![queue count])
         [windowToChallengeQueue removeObjectForKey:window];
-    }
 
     NSURLCredential *latestCredential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]];
 
@@ -122,24 +120,24 @@
     }
 
     WebAuthenticationPanel *panel = [[WebAuthenticationPanel alloc] initWithCallback:self selector:@selector(_authenticationDoneWithChallenge:result:)];
-    [challengeToWindow _webkit_setObject:window forUncopiedKey:challenge];
-    [windowToPanel _webkit_setObject:panel forUncopiedKey:window];
+    [challengeToWindow setObject:window forKey:challenge];
+    [windowToPanel setObject:panel forKey:window];
     [panel release];
     
-    if (window == WebModalDialogPretendWindow) {
+    if (window == WebModalDialogPretendWindow)
         [panel runAsModalDialogWithChallenge:challenge];
-    } else {
+    else
         [panel runAsSheetOnWindow:window withChallenge:challenge];
-    }
 }
 
 -(void)cancelAuthentication:(NSURLAuthenticationChallenge *)challenge
 {
     id window = [challengeToWindow objectForKey:challenge];
-    if (window != nil) {
-        WebAuthenticationPanel *panel = [windowToPanel objectForKey:window];
-        [panel cancel:self];
-    }
+    if (!window)
+        return;
+
+    WebAuthenticationPanel *panel = [windowToPanel objectForKey:window];
+    [panel cancel:self];
 }
 
 -(void)_authenticationDoneWithChallenge:(NSURLAuthenticationChallenge *)challenge result:(NSURLCredential *)credential

Modified: trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.h (149561 => 149562)


--- trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.h	2013-05-04 18:46:20 UTC (rev 149561)
+++ trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.h	2013-05-04 19:04:27 UTC (rev 149562)
@@ -96,7 +96,7 @@
     int32_t specifiedWidth;
             
     HashSet<RefPtr<WebNetscapePluginStream> > streams;
-    RetainPtr<NSMutableDictionary> _pendingFrameLoads;
+    RetainPtr<NSMapTable> _pendingFrameLoads;
     
     BOOL _isFlash;
     BOOL _isSilverlight;

Modified: trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm (149561 => 149562)


--- trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm	2013-05-04 18:46:20 UTC (rev 149561)
+++ trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm	2013-05-04 19:04:27 UTC (rev 149562)
@@ -1188,8 +1188,9 @@
     copyToVector(streams, streamsCopy);
     for (size_t i = 0; i < streamsCopy.size(); i++)
         streamsCopy[i]->stop();
-    
-    [[_pendingFrameLoads.get() allKeys] makeObjectsPerformSelector:@selector(_setInternalLoadDelegate:) withObject:nil];
+
+    for (WebFrame *frame in [_pendingFrameLoads keyEnumerator])
+        [frame _setInternalLoadDelegate:nil];
     [NSObject cancelPreviousPerformRequestsWithTarget:self];
 
     // Setting the window type to 0 ensures that NPP_SetWindow will be called if the plug-in is restarted.
@@ -1335,9 +1336,9 @@
     self = [super initWithFrame:frame pluginPackage:pluginPackage URL:URL baseURL:baseURL MIMEType:MIME attributeKeys:keys attributeValues:values loadManually:loadManually element:element];
     if (!self)
         return nil;
- 
-    _pendingFrameLoads = adoptNS([[NSMutableDictionary alloc] init]);
-    
+
+    _pendingFrameLoads = adoptNS([[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsStrongMemory capacity:0]);
+
     // load the plug-in if it is not already loaded
     if (![pluginPackage load]) {
         [self release];
@@ -1620,7 +1621,7 @@
 {
     ASSERT(_isStarted);
     
-    WebPluginRequest *pluginRequest = [_pendingFrameLoads.get() objectForKey:webFrame];
+    WebPluginRequest *pluginRequest = [_pendingFrameLoads objectForKey:webFrame];
     ASSERT(pluginRequest != nil);
     ASSERT([pluginRequest sendNotification]);
         
@@ -1631,7 +1632,7 @@
     }
     [self didCallPlugInFunction];
     
-    [_pendingFrameLoads.get() removeObjectForKey:webFrame];
+    [_pendingFrameLoads removeObjectForKey:webFrame];
     [webFrame _setInternalLoadDelegate:nil];
 }
 
@@ -1697,7 +1698,7 @@
                 ASSERT([view isKindOfClass:[WebNetscapePluginView class]]);
                 [view webFrame:frame didFinishLoadWithReason:NPRES_USER_BREAK];
             }
-            [_pendingFrameLoads.get() _webkit_setObject:pluginRequest forUncopiedKey:frame];
+            [_pendingFrameLoads setObject:pluginRequest forKey:frame];
             [frame _setInternalLoadDelegate:self];
         }
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to