[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

mitz at apple.com mitz at apple.com
Fri Jan 21 15:12:12 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 9a340cce82ff82bc1a39eea5f9d32042b3f20529
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jan 9 06:07:31 2011 +0000

    <rdar://problem/8812759> In WebKit2, PDF view settings (mode and scale) do not stick
    https://bugs.webkit.org/show_bug.cgi?id=52118
    
    Reviewed by Sam Weinig.
    
    * Shared/WebPreferencesStore.cpp:
    (WebKit::WebPreferencesStore::encode): Encode the double values map.
    (WebKit::WebPreferencesStore::decode): Decode the double values map.
    (WebKit::defaultValueForKey): Added double instance.
    (WebKit::WebPreferencesStore::setDoubleValueForKey): Added.
    (WebKit::WebPreferencesStore::getDoubleValueForKey): Added.
    * Shared/WebPreferencesStore.h: Added PDFScaleFactor and PDFDisplayMode preferences.
    * UIProcess/API/mac/PDFViewController.mm:
    (-[WKPDFView initWithFrame:PDFViewController:WebKit::]): Initialize the _pdfViewController ivar.
    (-[WKPDFView invalidate]): Changed 'nil' to '0' in assignment to a non-Objective-C pointer.
    (-[WKPDFView setDocument:]): Added.
    (-[WKPDFView _applyPDFPreferences]): Added.
    (-[WKPDFView _updatePreferences:]): Added.
    (-[WKPDFView _updatePreferencesSoon]): Added.
    (-[WKPDFView _scaleOrDisplayModeOrPageChanged:]): Added.
    (-[WKPDFView viewDidMoveToWindow]): Added. Starts observing the PDF view for changes to scale
    and display mode.
    (-[WKPDFView viewWillMoveToWindow:]): Added. Stops observing for changes.
    (WebKit::PDFViewController::setPDFDocumentData): Changed to call throguh -[WKPDFView setDocument:].
    * UIProcess/WebPreferences.cpp:
    (WebKit::WebPreferences::updateDoubleValueForKey): Added.
    * UIProcess/WebPreferences.h:
    * UIProcess/cf/WebPreferencesCF.cpp:
    (WebKit::WebPreferences::platformUpdateDoubleValueForKey): Added empty implementation.
    * UIProcess/gtk/WebPreferencesGtk.cpp:
    (WebKit::WebPreferences::platformUpdateDoubleValueForKey): Added stub.
    * UIProcess/mac/WebPreferencesMac.mm:
    (WebKit::setDoubleValueIfInUserDefaults): Added.
    (WebKit::WebPreferences::platformUpdateDoubleValueForKey): Added.
    * UIProcess/qt/WebPreferencesQt.cpp:
    (WebKit::WebPreferences::platformUpdateDoubleValueForKey): Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75344 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 0700aaa..d100e17 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,44 @@
 2011-01-08  Dan Bernstein  <mitz at apple.com>
 
+        Reviewed by Sam Weinig.
+
+        <rdar://problem/8812759> In WebKit2, PDF view settings (mode and scale) do not stick
+        https://bugs.webkit.org/show_bug.cgi?id=52118
+
+        * Shared/WebPreferencesStore.cpp:
+        (WebKit::WebPreferencesStore::encode): Encode the double values map.
+        (WebKit::WebPreferencesStore::decode): Decode the double values map.
+        (WebKit::defaultValueForKey): Added double instance.
+        (WebKit::WebPreferencesStore::setDoubleValueForKey): Added.
+        (WebKit::WebPreferencesStore::getDoubleValueForKey): Added.
+        * Shared/WebPreferencesStore.h: Added PDFScaleFactor and PDFDisplayMode preferences.
+        * UIProcess/API/mac/PDFViewController.mm:
+        (-[WKPDFView initWithFrame:PDFViewController:WebKit::]): Initialize the _pdfViewController ivar.
+        (-[WKPDFView invalidate]): Changed 'nil' to '0' in assignment to a non-Objective-C pointer.
+        (-[WKPDFView setDocument:]): Added.
+        (-[WKPDFView _applyPDFPreferences]): Added.
+        (-[WKPDFView _updatePreferences:]): Added.
+        (-[WKPDFView _updatePreferencesSoon]): Added.
+        (-[WKPDFView _scaleOrDisplayModeOrPageChanged:]): Added.
+        (-[WKPDFView viewDidMoveToWindow]): Added. Starts observing the PDF view for changes to scale
+        and display mode.
+        (-[WKPDFView viewWillMoveToWindow:]): Added. Stops observing for changes.
+        (WebKit::PDFViewController::setPDFDocumentData): Changed to call throguh -[WKPDFView setDocument:].
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::WebPreferences::updateDoubleValueForKey): Added.
+        * UIProcess/WebPreferences.h:
+        * UIProcess/cf/WebPreferencesCF.cpp:
+        (WebKit::WebPreferences::platformUpdateDoubleValueForKey): Added empty implementation.
+        * UIProcess/gtk/WebPreferencesGtk.cpp:
+        (WebKit::WebPreferences::platformUpdateDoubleValueForKey): Added stub.
+        * UIProcess/mac/WebPreferencesMac.mm:
+        (WebKit::setDoubleValueIfInUserDefaults): Added.
+        (WebKit::WebPreferences::platformUpdateDoubleValueForKey): Added.
+        * UIProcess/qt/WebPreferencesQt.cpp:
+        (WebKit::WebPreferences::platformUpdateDoubleValueForKey): Added.
+
+2011-01-08  Dan Bernstein  <mitz at apple.com>
+
         Reviewed by Maciej Stachowiak.
 
         In WebKit2, page zooming does not work with PDF
diff --git a/WebKit2/Shared/WebPreferencesStore.cpp b/WebKit2/Shared/WebPreferencesStore.cpp
index c15ee65..82b422b 100644
--- a/WebKit2/Shared/WebPreferencesStore.cpp
+++ b/WebKit2/Shared/WebPreferencesStore.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -55,12 +55,12 @@ WebPreferencesStore::WebPreferencesStore()
 
 void WebPreferencesStore::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
-    encoder->encode(CoreIPC::In(m_stringValues, m_boolValues, m_uint32Values));
+    encoder->encode(CoreIPC::In(m_stringValues, m_boolValues, m_uint32Values, m_doubleValues));
 }
 
 bool WebPreferencesStore::decode(CoreIPC::ArgumentDecoder* decoder, WebPreferencesStore& s)
 {
-    if (!decoder->decode(CoreIPC::Out(s.m_stringValues, s.m_boolValues, s.m_uint32Values)))
+    if (!decoder->decode(CoreIPC::Out(s.m_stringValues, s.m_boolValues, s.m_uint32Values, s.m_doubleValues)))
         return false;
 
     if (hasXSSAuditorEnabledTestRunnerOverride)
@@ -90,7 +90,7 @@ String defaultValueForKey(const String& key)
     static HashMap<String, String>& defaults = *new HashMap<String, String>;
     if (defaults.isEmpty()) {
 #define DEFINE_STRING_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
-    FOR_EACH_WEBKIT_STRING_PREFERENCE(DEFINE_STRING_DEFAULTS)
+        FOR_EACH_WEBKIT_STRING_PREFERENCE(DEFINE_STRING_DEFAULTS)
 #undef DEFINE_STRING_DEFAULTS
     }
 
@@ -103,7 +103,7 @@ bool defaultValueForKey(const String& key)
     static HashMap<String, bool>& defaults = *new HashMap<String, bool>;
     if (defaults.isEmpty()) {
 #define DEFINE_BOOL_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
-    FOR_EACH_WEBKIT_BOOL_PREFERENCE(DEFINE_BOOL_DEFAULTS)
+        FOR_EACH_WEBKIT_BOOL_PREFERENCE(DEFINE_BOOL_DEFAULTS)
 #undef DEFINE_BOOL_DEFAULTS
     }
 
@@ -116,13 +116,26 @@ uint32_t defaultValueForKey(const String& key)
     static HashMap<String, uint32_t>& defaults = *new HashMap<String, uint32_t>;
     if (defaults.isEmpty()) {
 #define DEFINE_UINT32_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
-    FOR_EACH_WEBKIT_UINT32_PREFERENCE(DEFINE_UINT32_DEFAULTS)
+        FOR_EACH_WEBKIT_UINT32_PREFERENCE(DEFINE_UINT32_DEFAULTS)
 #undef DEFINE_UINT32_DEFAULTS
     }
 
     return defaults.get(key);
 }
 
+template<>
+double defaultValueForKey(const String& key)
+{
+    static HashMap<String, double>& defaults = *new HashMap<String, double>;
+    if (defaults.isEmpty()) {
+#define DEFINE_DOUBLE_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
+        FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(DEFINE_DOUBLE_DEFAULTS)
+#undef DEFINE_DOUBLE_DEFAULTS
+    }
+
+    return defaults.get(key);
+}
+
 template<typename MapType>
 static typename MapType::MappedType valueForKey(const MapType& map, const typename MapType::KeyType& key)
 {
@@ -174,4 +187,14 @@ uint32_t WebPreferencesStore::getUInt32ValueForKey(const String& key) const
     return valueForKey(m_uint32Values, key);
 }
 
+bool WebPreferencesStore::setDoubleValueForKey(const String& key, double value) 
+{
+    return setValueForKey(m_doubleValues, key, value);
+}
+
+double WebPreferencesStore::getDoubleValueForKey(const String& key) const
+{
+    return valueForKey(m_doubleValues, key);
+}
+
 } // namespace WebKit
diff --git a/WebKit2/Shared/WebPreferencesStore.h b/WebKit2/Shared/WebPreferencesStore.h
index 331569d..28a6f48 100644
--- a/WebKit2/Shared/WebPreferencesStore.h
+++ b/WebKit2/Shared/WebPreferencesStore.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -66,12 +66,17 @@ namespace WebKit {
     macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false) \
     \
 
+#define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
+    macro(PDFScaleFactor, pdfScaleFactor, Double, double, 0) \
+    \
+
 #define FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
     macro(FontSmoothingLevel, fontSmoothingLevel, UInt32, uint32_t, FontSmoothingLevelMedium) \
     macro(MinimumFontSize, minimumFontSize, UInt32, uint32_t, 0) \
     macro(MinimumLogicalFontSize, minimumLogicalFontSize, UInt32, uint32_t, 9) \
     macro(DefaultFontSize, defaultFontSize, UInt32, uint32_t, 16) \
     macro(DefaultFixedFontSize, defaultFixedFontSize, UInt32, uint32_t, 13) \
+    macro(PDFDisplayMode, pdfDisplayMode, UInt32, uint32_t, 1) \
     \
 
 #if PLATFORM(WIN)
@@ -107,6 +112,7 @@ namespace WebKit {
 
 #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
     FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
+    FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
     FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
     FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
     \
@@ -138,12 +144,16 @@ struct WebPreferencesStore {
     bool setUInt32ValueForKey(const String& key, uint32_t value);
     uint32_t getUInt32ValueForKey(const String& key) const;
 
+    bool setDoubleValueForKey(const String& key, double value);
+    double getDoubleValueForKey(const String& key) const;
+
     static void overrideXSSAuditorEnabledForTestRunner(bool);
     static void removeTestRunnerOverrides();
 
     HashMap<String, String> m_stringValues;
     HashMap<String, bool> m_boolValues;
     HashMap<String, uint32_t> m_uint32Values;
+    HashMap<String, double> m_doubleValues;
 };
 
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/API/mac/PDFViewController.mm b/WebKit2/UIProcess/API/mac/PDFViewController.mm
index 7c41640..a92c2d4 100644
--- a/WebKit2/UIProcess/API/mac/PDFViewController.mm
+++ b/WebKit2/UIProcess/API/mac/PDFViewController.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 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,9 +26,21 @@
 #import "PDFViewController.h"
 
 #import "DataReference.h"
+#import "WKAPICast.h"
+#import "WKView.h"
+#import "WebPageGroup.h"
+#import "WebPageProxy.h"
+#import "WebPreferences.h"
 #import <PDFKit/PDFKit.h>
 #import <wtf/text/WTFString.h>
 
+// Redeclarations of PDFKit notifications. We can't use the API since we use a weak link to the framework.
+#define _webkit_PDFViewDisplayModeChangedNotification @"PDFViewDisplayModeChanged"
+#define _webkit_PDFViewScaleChangedNotification @"PDFViewScaleChanged"
+#define _webkit_PDFViewPageChangedNotification @"PDFViewChangedPage"
+
+using namespace WebKit;
+
 @class PDFDocument;
 @class PDFView;
 
@@ -40,28 +52,35 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
     
 @interface WKPDFView : NSView
 {
-    WebKit::PDFViewController* _pdfViewController;
+    PDFViewController* _pdfViewController;
 
     RetainPtr<NSView> _pdfPreviewView;
     PDFView *_pdfView;
+    BOOL _ignoreScaleAndDisplayModeAndPageNotifications;
+    BOOL _willUpdatePreferencesSoon;
 }
 
-- (id)initWithFrame:(NSRect)frame PDFViewController:(WebKit::PDFViewController*)pdfViewController;
+- (id)initWithFrame:(NSRect)frame PDFViewController:(PDFViewController*)pdfViewController;
 - (void)invalidate;
 - (PDFView *)pdfView;
+- (void)setDocument:(PDFDocument *)pdfDocument;
+
+- (void)_applyPDFPreferences;
 
 @end
 
 @implementation WKPDFView
 
-- (id)initWithFrame:(NSRect)frame PDFViewController:(WebKit::PDFViewController*)pdfViewController
+- (id)initWithFrame:(NSRect)frame PDFViewController:(PDFViewController*)pdfViewController
 {
     if ((self = [super initWithFrame:frame])) {
+        _pdfViewController = pdfViewController;
+
         [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
-    
-        Class previewViewClass = WebKit::PDFViewController::pdfPreviewViewClass();
+
+        Class previewViewClass = PDFViewController::pdfPreviewViewClass();
         ASSERT(previewViewClass);
-        
+
         _pdfPreviewView.adoptNS([[previewViewClass alloc] initWithFrame:frame]);
         [_pdfPreviewView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
         [self addSubview:_pdfPreviewView.get()];
@@ -74,7 +93,7 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
 
 - (void)invalidate
 {
-    _pdfViewController = nil;
+    _pdfViewController = 0;
 }
 
 - (PDFView *)pdfView
@@ -82,6 +101,83 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
     return _pdfView;
 }
 
+- (void)setDocument:(PDFDocument *)pdfDocument
+{
+    _ignoreScaleAndDisplayModeAndPageNotifications = YES;
+    [_pdfView setDocument:pdfDocument];
+    [self _applyPDFPreferences];
+    _ignoreScaleAndDisplayModeAndPageNotifications = NO;
+}
+
+- (void)_applyPDFPreferences
+{
+    if (!_pdfViewController)
+        return;
+
+    WebPreferences *preferences = toImpl([_pdfViewController->wkView() pageRef])->pageGroup()->preferences();
+
+    CGFloat scaleFactor = preferences->pdfScaleFactor();
+    if (!scaleFactor)
+        [_pdfView setAutoScales:YES];
+    else {
+        [_pdfView setAutoScales:NO];
+        [_pdfView setScaleFactor:scaleFactor];
+    }
+    [_pdfView setDisplayMode:preferences->pdfDisplayMode()];
+}
+
+- (void)_updatePreferences:(id)ignored
+{
+    _willUpdatePreferencesSoon = NO;
+
+    if (!_pdfViewController)
+        return;
+
+    WebPreferences* preferences = toImpl([_pdfViewController->wkView() pageRef])->pageGroup()->preferences();
+
+    CGFloat scaleFactor = [_pdfView autoScales] ? 0 : [_pdfView scaleFactor];
+    preferences->setPDFScaleFactor(scaleFactor);
+    preferences->setPDFDisplayMode([_pdfView displayMode]);
+}
+
+- (void)_updatePreferencesSoon
+{   
+    if (_willUpdatePreferencesSoon)
+        return;
+
+    [self performSelector:@selector(_updatePreferences:) withObject:nil afterDelay:0];
+    _willUpdatePreferencesSoon = YES;
+}
+
+- (void)_scaleOrDisplayModeOrPageChanged:(NSNotification *)notification
+{
+    ASSERT_ARG(notification, [notification object] == _pdfView);
+    if (!_ignoreScaleAndDisplayModeAndPageNotifications)
+        [self _updatePreferencesSoon];
+}
+
+- (void)viewDidMoveToWindow
+{
+    if (![self window])
+        return;
+
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+    [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewScaleChangedNotification object:_pdfView];
+    [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewDisplayModeChangedNotification object:_pdfView];
+    [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewPageChangedNotification object:_pdfView];
+}
+
+- (void)viewWillMoveToWindow:(NSWindow *)newWindow
+{
+    if (![self window])
+        return;
+
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+    [notificationCenter removeObserver:self name:_webkit_PDFViewScaleChangedNotification object:_pdfView];
+    [notificationCenter removeObserver:self name:_webkit_PDFViewDisplayModeChangedNotification object:_pdfView];
+    [notificationCenter removeObserver:self name:_webkit_PDFViewPageChangedNotification object:_pdfView];
+}
+
 @end
 
 namespace WebKit {
@@ -148,7 +244,7 @@ void PDFViewController::setPDFDocumentData(const String& mimeType, const CoreIPC
     }
 
     RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)data.get()]);
-    [m_pdfView setDocument:pdfDocument.get()];
+    [m_wkPDFView.get() setDocument:pdfDocument.get()];
 }
 
 double PDFViewController::zoomFactor() const
diff --git a/WebKit2/UIProcess/WebPreferences.cpp b/WebKit2/UIProcess/WebPreferences.cpp
index 363bc31..e33ebb2 100644
--- a/WebKit2/UIProcess/WebPreferences.cpp
+++ b/WebKit2/UIProcess/WebPreferences.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -78,6 +78,12 @@ void WebPreferences::updateUInt32ValueForKey(const String& key, uint32_t value)
     update(); // FIXME: Only send over the changed key and value.
 }
 
+void WebPreferences::updateDoubleValueForKey(const String& key, double value)
+{
+    platformUpdateDoubleValueForKey(key, value);
+    update(); // FIXME: Only send over the changed key and value.
+}
+
 #define DEFINE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
     void WebPreferences::set##KeyUpper(const Type& value) \
     { \
diff --git a/WebKit2/UIProcess/WebPreferences.h b/WebKit2/UIProcess/WebPreferences.h
index 25dd741..0f4943a 100644
--- a/WebKit2/UIProcess/WebPreferences.h
+++ b/WebKit2/UIProcess/WebPreferences.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -82,9 +82,11 @@ private:
     void updateStringValueForKey(const String& key, const String& value);
     void updateBoolValueForKey(const String& key, bool value);
     void updateUInt32ValueForKey(const String& key, uint32_t value);
+    void updateDoubleValueForKey(const String& key, double value);
     void platformUpdateStringValueForKey(const String& key, const String& value);
     void platformUpdateBoolValueForKey(const String& key, bool value);
     void platformUpdateUInt32ValueForKey(const String& key, uint32_t value);
+    void platformUpdateDoubleValueForKey(const String& key, double value);
 
     HashSet<WebPageGroup*> m_pageGroups;
     WebPreferencesStore m_store;
diff --git a/WebKit2/UIProcess/cf/WebPreferencesCF.cpp b/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
index c93d96e..7b89d04 100644
--- a/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
+++ b/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
@@ -45,6 +45,10 @@ void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t)
 {
 }
 
+void WebPreferences::platformUpdateDoubleValueForKey(const String&, double)
+{
+}
+
 } // namespace WebKit
 
 #endif // !PLATFORM(MAC)
diff --git a/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp b/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp
index 9ec46b0..3da7323 100644
--- a/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp
+++ b/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp
@@ -50,4 +50,9 @@ void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t)
     notImplemented();
 }
 
+void WebPreferences::platformUpdateDoubleValueForKey(const String&, double)
+{
+    notImplemented();
+}
+
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/mac/WebPreferencesMac.mm b/WebKit2/UIProcess/mac/WebPreferencesMac.mm
index 1a91af3..b954bd2 100644
--- a/WebKit2/UIProcess/mac/WebPreferencesMac.mm
+++ b/WebKit2/UIProcess/mac/WebPreferencesMac.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -68,6 +68,17 @@ static void setUInt32ValueIfInUserDefaults(const String& identifier, const Strin
     store.setUInt32ValueForKey(key, [object intValue]);
 }
 
+static void setDoubleValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
+{
+    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, key)];
+    if (!object)
+        return;
+    if (![object respondsToSelector:@selector(doubleValue)])
+        return;
+
+    store.setDoubleValueForKey(key, [object doubleValue]);
+}
+
 void WebPreferences::platformInitializeStore()
 {
     if (!m_identifier)
@@ -105,5 +116,12 @@ void WebPreferences::platformUpdateUInt32ValueForKey(const String& key, uint32_t
     [[NSUserDefaults standardUserDefaults] setInteger:value forKey:makeKey(m_identifier, key)];
 }
 
-} // namespace WebKit
+void WebPreferences::platformUpdateDoubleValueForKey(const String& key, double value)
+{
+    if (!m_identifier)
+        return;
 
+    [[NSUserDefaults standardUserDefaults] setDouble:value forKey:makeKey(m_identifier, key)];
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/qt/WebPreferencesQt.cpp b/WebKit2/UIProcess/qt/WebPreferencesQt.cpp
index c2fd76e..173cfd5 100644
--- a/WebKit2/UIProcess/qt/WebPreferencesQt.cpp
+++ b/WebKit2/UIProcess/qt/WebPreferencesQt.cpp
@@ -43,4 +43,8 @@ void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t)
 {
 }
 
+void WebPreferences::platformUpdateDoubleValueForKey(const String&, double)
+{
+}
+
 } // namespace WebKit

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list