2
* Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
#ifndef WebSettings_p_h
20
#define WebSettings_p_h
22
#include "WebSettings.h"
24
#include <wtf/HashMap.h>
25
#include <wtf/text/StringHash.h>
27
#define synthesizeAccessorsForPrimitiveValuePrefixAndType(prefix, type) \
28
void set##prefix(const String& key, type newValue) { \
30
if (get##prefix(key) == newValue) \
33
copyOnWrite = false; \
34
impl = new WebSettingsPrivateImpl(*impl); \
36
PrimitiveValue primitiveValue; \
37
primitiveValue.prefix##Value = newValue; \
38
impl->primitiveValues.set(key, primitiveValue); \
40
delegate->didChangeSettings(sender); \
42
type get##prefix(const String& key) const { \
44
if (!impl->primitiveValues.contains(key)) \
45
return static_cast<type>(false); \
46
return impl->primitiveValues.get(key).prefix##Value; \
49
namespace BlackBerry {
52
struct WebSettingsPrivate {
53
union PrimitiveValue {
54
WebSettings::TextReflowMode TextReflowModeValue;
58
unsigned UnsignedValue;
59
unsigned long long UnsignedLongLongValue;
62
struct WebSettingsPrivateImpl {
63
HashMap<String, PrimitiveValue> primitiveValues;
64
HashMap<String, String> stringValues;
67
WebSettingsPrivateImpl* impl;
68
WebSettingsDelegate* delegate;
74
synthesizeAccessorsForPrimitiveValuePrefixAndType(TextReflowMode, WebSettings::TextReflowMode);
76
synthesizeAccessorsForPrimitiveValuePrefixAndType(Boolean, bool);
78
synthesizeAccessorsForPrimitiveValuePrefixAndType(Double, double);
80
synthesizeAccessorsForPrimitiveValuePrefixAndType(Integer, int);
82
synthesizeAccessorsForPrimitiveValuePrefixAndType(Unsigned, unsigned);
84
synthesizeAccessorsForPrimitiveValuePrefixAndType(UnsignedLongLong, unsigned long long);
86
String getString(const String& key) const
89
if (!impl->stringValues.contains(key))
91
return impl->stringValues.get(key);
94
void setString(const String& key, const String& newValue)
97
if (getString(key) == newValue)
102
impl = new WebSettingsPrivateImpl(*impl);
105
impl->stringValues.set(key, newValue);
107
delegate->didChangeSettings(sender);
111
} // namespace WebKit
112
} // namespace BlackBerry
114
#endif // WebSettings_p_h