[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:42:50 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 4646749ff8ecb634efcc6f650911232566eb1efc
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu May 22 03:52:50 2003 +0000

            *** Public API Change ***
            The fix for 3265442 requires new API.  This API is an addition
            that is 100% compatible with the existing API.
    
            Provide support for IB to palettize WebView.
    
            Fixed 3265442.
            Fixed 3263106.
    
            Reviewed by Chris.
    
            * WebView.subproj/WebPreferences.h:
            * WebView.subproj/WebPreferences.m:
            (-[WebPreferencesPrivate dealloc]):
            (-[WebPreferences init]):
            (-[WebPreferences initWithIdentifier:]):
            (-[WebPreferences initWithCoder:]):
            (-[WebPreferences encodeWithCoder:]):
            (+[WebPreferences standardPreferences]):
            (-[WebPreferences dealloc]):
            (-[WebPreferences identifier]):
            (-[WebPreferences _stringValueForKey:]):
            (-[WebPreferences _setStringValue:forKey:]):
            (-[WebPreferences _integerValueForKey:]):
            (-[WebPreferences _setIntegerValue:forKey:]):
            (-[WebPreferences _boolValueForKey:]):
            (-[WebPreferences _setBoolValue:forKey:]):
            (-[WebPreferences autosaves]):
            (+[WebPreferences _getInstanceForIdentifier:]):
            (+[WebPreferences _setInstance:forIdentifier:]):
            (+[WebPreferences _removeReferenceForIdentifier:]):
            (-[WebPreferences _postPreferencesChangesNotification]):
            (-[NSMutableDictionary _checkLastReferenceForIdentifier:]):
            * WebView.subproj/WebPreferencesPrivate.h:
            * WebView.subproj/WebView.h:
            * WebView.subproj/WebView.m:
            (-[WebView _commonInitializationFrameName:groupName:]):
            (-[WebView initWithCoder:]):
            (-[WebView encodeWithCoder:]):
            (-[WebView dealloc]):
            (-[WebView setPreferencesIdentifier:]):
            (-[WebView preferencesIdentifier]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4410 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c143adc..dc371e6 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,6 +1,51 @@
+2003-05-21  Richard Williamson   <rjw at apple.com>
+
+        *** Public API Change ***
+        The fix for 3265442 requires new API.  This API is an addition
+        that is 100% compatible with the existing API.
+        
+        Provide support for IB to palettize WebView.
+        
+        Fixed 3265442.
+        Fixed 3263106.
+        
+        Reviewed by Chris.
+
+        * WebView.subproj/WebPreferences.h:
+        * WebView.subproj/WebPreferences.m:
+        (-[WebPreferencesPrivate dealloc]):
+        (-[WebPreferences init]):
+        (-[WebPreferences initWithIdentifier:]):
+        (-[WebPreferences initWithCoder:]):
+        (-[WebPreferences encodeWithCoder:]):
+        (+[WebPreferences standardPreferences]):
+        (-[WebPreferences dealloc]):
+        (-[WebPreferences identifier]):
+        (-[WebPreferences _stringValueForKey:]):
+        (-[WebPreferences _setStringValue:forKey:]):
+        (-[WebPreferences _integerValueForKey:]):
+        (-[WebPreferences _setIntegerValue:forKey:]):
+        (-[WebPreferences _boolValueForKey:]):
+        (-[WebPreferences _setBoolValue:forKey:]):
+        (-[WebPreferences autosaves]):
+        (+[WebPreferences _getInstanceForIdentifier:]):
+        (+[WebPreferences _setInstance:forIdentifier:]):
+        (+[WebPreferences _removeReferenceForIdentifier:]):
+        (-[WebPreferences _postPreferencesChangesNotification]):
+        (-[NSMutableDictionary _checkLastReferenceForIdentifier:]):
+        * WebView.subproj/WebPreferencesPrivate.h:
+        * WebView.subproj/WebView.h:
+        * WebView.subproj/WebView.m:
+        (-[WebView _commonInitializationFrameName:groupName:]):
+        (-[WebView initWithCoder:]):
+        (-[WebView encodeWithCoder:]):
+        (-[WebView dealloc]):
+        (-[WebView setPreferencesIdentifier:]):
+        (-[WebView preferencesIdentifier]):
+
 2003-05-21  Chris Blumenberg  <cblu at apple.com>
 
-		Fixed data source leak when viewing standalone plug-in content.
+        Fixed data source leak when viewing standalone plug-in content.
 
         Reviewed by rjw.
 
diff --git a/WebKit/WebView.subproj/WebPreferences.h b/WebKit/WebView.subproj/WebPreferences.h
index 1b08395..1ec5e98 100644
--- a/WebKit/WebView.subproj/WebPreferences.h
+++ b/WebKit/WebView.subproj/WebPreferences.h
@@ -7,14 +7,17 @@
 
 #import <Foundation/Foundation.h>
 
+ at class WebPreferencesPrivate;
+
 extern NSString *WebPreferencesChangedNotification;
 
 /*!
     @class WebPreferences
 */
- at interface WebPreferences: NSObject
+ at interface WebPreferences: NSObject <NSCoding>
 {
-    NSMutableDictionary *values;
+ at private
+    WebPreferencesPrivate *_private;
 }
 
 /*!
@@ -23,6 +26,22 @@ extern NSString *WebPreferencesChangedNotification;
 + (WebPreferences *)standardPreferences;
 
 /*!
+    @method initWithIdentifier:
+    @param anIdentifier The prefix to add to the user defaults keys for the WebPreferences.
+    @discussion WebViews can share instances of WebPreferences by using an instance of WebPreferences with
+    the same identifier.  Typically, instance are not created directly.  Instead you set the preferences
+    identifier on a WebView.
+    @result Returns a new instance of WebPreferences of a previously allocated instance with the same identifier.
+*/
+- (id)initWithIdentifier:(NSString *)anIdentifier;
+
+/*!
+    @method identifier
+    @result Returns the identifier for this WebPreferences.
+*/
+- (NSString *)identifier;
+
+/*!
     @method standardFontFamily
 */
 - (NSString *)standardFontFamily;
@@ -232,4 +251,18 @@ extern NSString *WebPreferencesChangedNotification;
 */
 - (BOOL)loadsImagesAutomatically;
 
+/*!
+    @method setAutosavesPreferences:
+    @param flag 
+    @discussion If autosave preferences is YES the settings represented by
+    WebPreferences will be stored in the user defaults database.
+*/
+- (void)setAutosaves:(BOOL)flag;
+
+/*!
+    @method autosavesPreferences
+    @result The value of the autosave preferences flag.
+*/
+- (BOOL)autosaves;
+
 @end
diff --git a/WebKit/WebView.subproj/WebPreferences.m b/WebKit/WebView.subproj/WebPreferences.m
index 7ad89eb..9498e26 100644
--- a/WebKit/WebView.subproj/WebPreferences.m
+++ b/WebKit/WebView.subproj/WebPreferences.m
@@ -3,7 +3,7 @@
         Copyright 2001, 2002, Apple Computer, Inc. All rights reserved.
 */
 
-#import "WebPreferences.h"
+#import <WebKit/WebPreferencesPrivate.h>
 
 #import <Foundation/NSDictionary_NSURLExtras.h>
 
@@ -40,35 +40,113 @@
 
 NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotification";
 
- at implementation WebPreferences
+#define KEY(x) [(_private->identifier?_private->identifier:@"") stringByAppendingString:x]
 
-- (void)_postPreferencesChangesNotification
+enum { WebPreferencesVersion = 1 };
+
+ at interface WebPreferencesPrivate : NSObject
 {
-    [[NSNotificationCenter defaultCenter]
-        postNotificationName:WebPreferencesChangedNotification object:self
-                    userInfo:nil];
+ at public
+    NSMutableDictionary *values;
+    NSString *identifier;
+    BOOL autosaves;
 }
+ at end
 
-// Only used tp initialize the shared instance.
-- _init
+ at implementation WebPreferencesPrivate
+- (void)dealloc
 {
-    [super init];
-    return self;
+    [values release];
+    [identifier release];
+    [super dealloc];
 }
+ at end
+
+ at implementation WebPreferences
 
 - init
 {
+    return [self initWithIdentifier:nil];
+}
+
+- (id)initWithIdentifier:(NSString *)anIdentifier
+{
     [super init];
-    values = [[NSMutableDictionary alloc] init];
+    
+    if (anIdentifier == nil)
+        anIdentifier = @"";
+        
+    _private = [[WebPreferencesPrivate alloc] init];
+    
+    WebPreferences *instance = [[self class] _getInstanceForIdentifier:anIdentifier];
+    if (instance){
+        [self release];
+        return instance;
+    }
+
+    _private->values = [[NSMutableDictionary alloc] init];
+    _private->identifier = [anIdentifier copy];
+    
+    [[self class] _setInstance:self forIdentifier:_private->identifier];
+
+    [[NSNotificationCenter defaultCenter]
+       postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
+
     return self;
 }
 
+- (id)initWithCoder:(NSCoder *)decoder
+{
+    int version;
+    id result = nil;
+
+NS_DURING
+
+    _private = [[WebPreferencesPrivate alloc] init];
+    [decoder decodeValueOfObjCType:@encode(int) at:&version];
+    if (version == 1){
+        _private->identifier = [decoder decodeObject];
+
+        // If we load a nib multiple times, or have instances in multiple
+        // nibs with the same name, the first guy up wins.
+        WebPreferences *instance = [[self class] _getInstanceForIdentifier:_private->identifier];
+        if (instance){
+            [self release];
+            result = instance;
+        }
+        else {
+            _private->values = [decoder decodeObject];
+            result = self;
+        }
+    }
+    
+NS_HANDLER
+
+    result = nil;
+
+NS_ENDHANDLER
+
+    if (result == nil)
+        [self release];
+
+    return result;
+}
+
+- (void)encodeWithCoder:(NSCoder *)encoder
+{
+    int version = WebPreferencesVersion;
+    [encoder encodeValueOfObjCType:@encode(int) at:&version];
+    [encoder encodeObject:_private->identifier];
+    [encoder encodeObject:_private->values];
+}
+
 + (WebPreferences *)standardPreferences
 {
     static WebPreferences *_standardPreferences = nil;
 
     if (_standardPreferences == nil) {
-        _standardPreferences = [[WebPreferences alloc] _init];
+        _standardPreferences = [[WebPreferences alloc] init];
+        [_standardPreferences setAutosaves:YES];
         [_standardPreferences _postPreferencesChangesNotification];
     }
 
@@ -113,61 +191,72 @@ NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotificatio
 
 - (void)dealloc
 {
-    [values release];
+    [_private release];
     [super dealloc];
 }
 
+- (NSString *)identifier
+{
+    return _private->identifier;
+}
+
 - (NSString *)_stringValueForKey: (NSString *)key
 {
-    NSString *s = [values objectForKey:key];
+    NSString *_key = KEY(key);
+    NSString *s = [_private->values objectForKey:_key];
     if (s)
         return s;
-    return [[NSUserDefaults standardUserDefaults] stringForKey:key];
+    return [[NSUserDefaults standardUserDefaults] stringForKey:_key];
 }
 
 - (void)_setStringValue: (NSString *)value forKey: (NSString *)key
 {
-    if (self == [WebPreferences standardPreferences])
-        [[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
-    else {
-        [values setObject: value forKey: key];
-    }
+    NSString *_key = KEY(key);
+    if (_private->autosaves)
+        [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key];
+
+    [_private->values setObject: value forKey:_key];
+
     [self _postPreferencesChangesNotification];
 }
 
 - (int)_integerValueForKey: (NSString *)key
 {
-    NSNumber *n = [values objectForKey:key];
+    NSString *_key = KEY(key);
+    NSNumber *n = [_private->values objectForKey:_key];
     if (n)
         return [n intValue];
-    return [[NSUserDefaults standardUserDefaults] integerForKey:key];
+    return [[NSUserDefaults standardUserDefaults] integerForKey:_key];
 }
 
 - (void)_setIntegerValue: (int)value forKey: (NSString *)key
 {
-    if (self == [WebPreferences standardPreferences])
-        [[NSUserDefaults standardUserDefaults] setInteger:value forKey:key];
-    else{
-        [values _web_setInt: value forKey: key];
-    }
+    NSString *_key = KEY(key);
+    if (_private->autosaves)
+        [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
+
+    [_private->values _web_setInt: value forKey: _key];
+
     [self _postPreferencesChangesNotification];
 }
 
 - (int)_boolValueForKey: (NSString *)key
 {
-    NSNumber *n = [values objectForKey:key];
+    NSString *_key = KEY(key);
+    NSNumber *n = [_private->values objectForKey:_key];
     if (n)
         return [n boolValue];
-    return [[NSUserDefaults standardUserDefaults] integerForKey:key];
+    return [[NSUserDefaults standardUserDefaults] integerForKey:_key];
 }
 
 - (void)_setBoolValue: (BOOL)value forKey: (NSString *)key
 {
-    if (self == [WebPreferences standardPreferences])
-        [[NSUserDefaults standardUserDefaults] setBool:value forKey:key];
-    else{
-        [values _web_setBool: value forKey: key];
-    }
+    NSString *_key = KEY(key);
+    if (_private->autosaves)
+        [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key];
+
+    [_private->values _web_setBool: value forKey: _key];
+
     [self _postPreferencesChangesNotification];
 }
 
@@ -361,6 +450,16 @@ NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotificatio
     return [self _boolValueForKey: WebKitDisplayImagesKey];
 }
 
+- (void)setAutosaves:(BOOL)flag;
+{
+    _private->autosaves = flag;
+}
+
+- (BOOL)autosaves
+{
+    return _private->autosaves;
+}
+
 @end
 
 @implementation WebPreferences (WebPrivate)
@@ -400,4 +499,42 @@ NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotificatio
     return [[NSUserDefaults standardUserDefaults] boolForKey:WebKitResourceTimedLayoutEnabledPreferenceKey];
 }
 
+static NSMutableDictionary *webPreferencesInstances = nil;
+
++ (WebPreferences *)_getInstanceForIdentifier:(NSString *)ident
+{
+    WebPreferences *instance = [webPreferencesInstances objectForKey:ident];
+    return instance;
+}
+
++ (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)ident
+{
+    if (!webPreferencesInstances)
+        webPreferencesInstances = [[NSMutableDictionary alloc] init];
+    [webPreferencesInstances setObject:instance forKey:ident];
+}
+
++ (void)_removeReferenceForIdentifier:(NSString *)ident
+{
+    [webPreferencesInstances performSelector:@selector(_checkLastReferenceForIdentifier) withObject:ident afterDelay:.1];
+}
+
+- (void)_postPreferencesChangesNotification
+{
+    [[NSNotificationCenter defaultCenter]
+        postNotificationName:WebPreferencesChangedNotification object:self
+                    userInfo:nil];
+}
+
+
 @end
+
+ at implementation NSMutableDictionary (WebPrivate)
+- (void)_checkLastReferenceForIdentifier:(NSString *)identifier
+{
+    WebPreferences *instance = [webPreferencesInstances objectForKey:identifier];
+    if ([instance retainCount] == 1)
+        [webPreferencesInstances removeObjectForKey:identifier];
+}
+ at end
+
diff --git a/WebKit/WebView.subproj/WebPreferencesPrivate.h b/WebKit/WebView.subproj/WebPreferencesPrivate.h
index 4b8f1d8..1c0ffd0 100644
--- a/WebKit/WebView.subproj/WebPreferencesPrivate.h
+++ b/WebKit/WebView.subproj/WebPreferencesPrivate.h
@@ -15,5 +15,8 @@
 - (int)_pageCacheSize;
 - (int)_objectCacheSize;
 - (void)_postPreferencesChangesNotification;
++ (WebPreferences *)_getInstanceForIdentifier:(NSString *)identifier;
++ (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)identifier;
++ (void)_removeReferenceForIdentifier:(NSString *)identifier;
 
 @end
diff --git a/WebKit/WebView.subproj/WebView.h b/WebKit/WebView.subproj/WebView.h
index 8698df8..4e674b7 100644
--- a/WebKit/WebView.subproj/WebView.h
+++ b/WebKit/WebView.subproj/WebView.h
@@ -317,6 +317,22 @@ extern NSString *WebElementLinkLabelKey;	// NSString of the text within the anch
 - (WebPreferences *)preferences;
 
 /*!
+    @method setPreferencesIdentifier:
+    @param anIdentifier The string to use a prefix for storing values for this WebView in the user
+    defaults database.
+    @discussion If the WebPreferences for this WebView are stored in the user defaults database, the
+    string set in this method will be used a key prefix.
+*/
+- (void)setPreferencesIdentifier:(NSString *)anIdentifier;
+
+/*!
+    @method preferencesIdentifier
+    @result Returns the WebPreferences key prefix.
+*/
+- (NSString *)preferencesIdentifier;
+
+
+/*!
     @method setHostWindow:
     @param hostWindow The host window for the web view.
     @discussion Parts of WebKit (such as plug-ins and JavaScript) depend on a window to function
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index d5875d7..e588236 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -22,7 +22,7 @@
 #import <WebKit/WebNSViewExtras.h>
 #import <WebKit/WebPluginDatabase.h>
 #import <WebKit/WebPolicyDelegate.h>
-#import <WebKit/WebPreferences.h>
+#import <WebKit/WebPreferencesPrivate.h>
 #import <WebKit/WebResourceLoadDelegate.h>
 #import <WebKit/WebTextView.h>
 #import <WebKit/WebTextRepresentation.h>
@@ -53,6 +53,7 @@ NSString *WebElementLinkLabelKey = 		@"WebElementLinkLabel";
 NSString *WebElementLinkTitleKey = 		@"WebElementLinkTitle";
 
 
+enum { WebViewVersion = 1 };
 
 
 @implementation WebView
@@ -86,8 +87,14 @@ NSString *WebElementLinkTitleKey = 		@"WebElementLinkTitle";
     return [WebFrameView _canShowMIMETypeAsHTML:MIMEType];
 }
 
-- (void)_commonInitialization: (WebFrameView *)wv frameName:(NSString *)frameName groupName:(NSString *)groupName
+- (void)_commonInitializationFrameName:(NSString *)frameName groupName:(NSString *)groupName
 {
+    NSRect f = [self frame];
+    WebFrameView *wv = [[WebFrameView alloc] initWithFrame: NSMakeRect(0,0,f.size.width,f.size.height)];
+    [wv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+    [self addSubview: wv];
+    [wv release];
+
     _private = [[WebViewPrivate alloc] init];
     _private->mainFrame = [[WebFrame alloc] initWithName: frameName webFrameView: wv  webView: self];
     [self setGroupName:groupName];
@@ -100,6 +107,8 @@ NSString *WebElementLinkTitleKey = 		@"WebElementLinkTitle";
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:)
                                                  name:WebPreferencesChangedNotification object:[self preferences]];
+
+    [self _registerDraggedTypes];
 }
 
 - init
@@ -116,15 +125,52 @@ NSString *WebElementLinkTitleKey = 		@"WebElementLinkTitle";
 - initWithFrame: (NSRect)f frameName: (NSString *)frameName groupName: (NSString *)groupName;
 {
     [super initWithFrame: f];
-    WebFrameView *wv = [[WebFrameView alloc] initWithFrame: NSMakeRect(0,0,f.size.width,f.size.height)];
-    [wv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
-    [self addSubview: wv];
-    [self _commonInitialization: wv frameName:frameName groupName:groupName];
-    [wv release];
-    [self _registerDraggedTypes];
+    [self _commonInitializationFrameName:frameName groupName:groupName];
     return self;
 }
 
+- (id)initWithCoder:(NSCoder *)decoder
+{
+    id result = nil;
+    int version;
+
+NS_DURING
+    self = [super initWithCoder:decoder];
+
+    [decoder decodeValueOfObjCType:@encode(int) at:&version];
+    if (version == 1){
+        NSString *frameName = [decoder decodeObject];
+        NSString *groupName = [decoder decodeObject];
+        [self _commonInitializationFrameName:frameName groupName:groupName];
+        
+        [self setPreferences: [decoder decodeObject]];
+        
+        result = self;
+    }
+
+NS_HANDLER
+
+    result = nil;
+
+NS_ENDHANDLER
+
+    if (result == nil)
+        [self release];
+        
+    return result;
+}
+
+- (void)encodeWithCoder:(NSCoder *)encoder
+{
+    [super encodeWithCoder:encoder];
+
+    int version = WebViewVersion;
+    [encoder encodeValueOfObjCType:@encode(int) at:&version];
+    [encoder encodeObject:[[self mainFrame] name]];
+    [encoder encodeObject:[self groupName]];
+    [encoder encodeObject:[self preferences]];
+}
+
 - (void)dealloc
 {
     [self _close];
@@ -133,6 +179,8 @@ NSString *WebElementLinkTitleKey = 		@"WebElementLinkTitle";
     
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     
+    [WebPreferences _removeReferenceForIdentifier: [self preferencesIdentifier]];
+    
     [_private release];
     [super dealloc];
 }
@@ -153,6 +201,19 @@ NSString *WebElementLinkTitleKey = 		@"WebElementLinkTitle";
     return _private->preferences ? _private->preferences : [WebPreferences standardPreferences];
 }
 
+- (void)setPreferencesIdentifier:(NSString *)anIdentifier
+{
+    if (![anIdentifier isEqual: [[self preferences] identifier]]){
+        [self setPreferences: [[WebPreferences alloc] initWithIdentifier:anIdentifier]];
+    }
+}
+
+- (NSString *)preferencesIdentifier
+{
+    return [[self preferences] identifier];
+}
+
+
 - (void)setUIDelegate:delegate
 {
     _private->UIDelegate = delegate;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list