WebCore:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Add a mechanism to ask the InspectorClient for key/value setting pairs.
These settings can be strings, numbers, booleans or string vectors. The
settings are also bridged to and from JavaScript.
https://bugs.webkit.org/show_bug.cgi?id=21856
Reviewed by Darin Adler.
* WebCore.base.exp: Expose the String CFStringRef constructor.
* inspector/InspectorClient.h:
(WebCore::InspectorClient::populateSetting): Added, pure virtual.
(WebCore::InspectorClient::storeSetting): Ditto.
(WebCore::InspectorClient::removeSetting): Ditto.
* inspector/InspectorController.cpp:
(WebCore::setting): Calls InspectorController::setting and wraps the result in script types.
(WebCore::setSetting): Calls InspectorController::setSetting after converting from script types.
(WebCore::InspectorController::InspectorController): Increment a global static
to track the number of live InspectorControllers.
(WebCore::InspectorController::~InspectorController): Decrement the global static
that tracks the number of live InspectorControllers. Delete the setting cache if there
are no more live controllers.
(WebCore::InspectorController::setting): Check the cache and return the setting from there,
otherwise make a new Setting and ask the client to populate it.
(WebCore::InspectorController::setSetting): Change the cache and ask the client to store it.
(WebCore::InspectorController::windowScriptObjectAvailable): Add setting and setSetting
to the InspectorController script class.
* inspector/InspectorController.h:
(WebCore::InspectorController::Setting::Setting):
(WebCore::InspectorController::Setting::operator=):
(WebCore::InspectorController::Setting::type): Return m_type.
(WebCore::InspectorController::Setting::string): Return m_string. Assert the type is correct.
(WebCore::InspectorController::Setting::stringVector): Return m_stringVector.
Assert the type is correct.
(WebCore::InspectorController::Setting::doubleValue): Return m_simpleContent.m_double.
Assert the type is correct.
(WebCore::InspectorController::Setting::integerValue): Return m_simpleContent.m_integer.
Assert the type is correct.
(WebCore::InspectorController::Setting::booleanValue): Return m_simpleContent.m_boolean.
Assert the type is correct.
(WebCore::InspectorController::Setting::set): Overloaded for each data type, sets the right
field and the type.
* loader/EmptyClients.h:
(WebCore::EmptyInspectorClient::populateSetting): Added, empty method.
(WebCore::EmptyInspectorClient::storeSetting): Ditto.
(WebCore::EmptyInspectorClient::removeSetting): Ditto.
WebKit:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Implement new InspectorClient methods to work with Settings.
https://bugs.webkit.org/show_bug.cgi?id=21856
Reviewed by Darin Adler.
* WebKit.xcodeproj/project.pbxproj: Add the new InspectorClientCF.cpp file.
WebKit/gtk:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Stub out new InspectorClient methods.
https://bugs.webkit.org/show_bug.cgi?id=21856
Reviewed by Darin Adler.
* WebCoreSupport/InspectorClientGtk.cpp:
(WebKit::InspectorClient::populateSetting): Not implemented.
(WebKit::InspectorClient::storeSetting): Ditto.
(WebKit::InspectorClient::removeSetting): Ditto.
* WebCoreSupport/InspectorClientGtk.h:
WebKit/mac:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Implement new InspectorClient methods to work with Settings.
https://bugs.webkit.org/show_bug.cgi?id=21856
Reviewed by Darin Adler.
* WebCoreSupport/WebInspectorClient.h: Add the new methods and
guard the ObjC parts of the header.
WebKit/qt:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Stub out new InspectorClient methods.
https://bugs.webkit.org/show_bug.cgi?id=21856
Reviewed by Darin Adler.
* WebCoreSupport/InspectorClientQt.cpp:
(WebCore::InspectorClientQt::populateSetting): Not implemented.
(WebCore::InspectorClientQt::storeSetting): Ditto.
(WebCore::InspectorClientQt::removeSetting): Ditto.
* WebCoreSupport/InspectorClientQt.h:
WebKit/win:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Implement new InspectorClient methods to work with Settings.
https://bugs.webkit.org/show_bug.cgi?id=21856
Reviewed by Adam Roben.
* WebKit.vcproj/WebKit.vcproj: Add the new InspectorClientCF.cpp file.
* WebCoreSupport/WebInspectorClient.h: Add the new methods.
WebKit/wx:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Stub out new InspectorClient methods.
https://bugs.webkit.org/show_bug.cgi?id=21856
Reviewed by Darin Adler.
* WebKitSupport/InspectorClientWx.cpp:
(WebCore::InspectorClient::populateSetting): Not implemented.
(WebCore::InspectorClient::storeSetting): Ditto.
(WebCore::InspectorClient::removeSetting): Ditto.
* WebKitSupport/InspectorClientWx.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@37848
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Add a mechanism to ask the InspectorClient for key/value setting pairs.
+ These settings can be strings, numbers, booleans or string vectors. The
+ settings are also bridged to and from JavaScript.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Darin Adler.
+
+ * WebCore.base.exp: Expose the String CFStringRef constructor.
+ * inspector/InspectorClient.h:
+ (WebCore::InspectorClient::populateSetting): Added, pure virtual.
+ (WebCore::InspectorClient::storeSetting): Ditto.
+ (WebCore::InspectorClient::removeSetting): Ditto.
+ * inspector/InspectorController.cpp:
+ (WebCore::setting): Calls InspectorController::setting and wraps the result in script types.
+ (WebCore::setSetting): Calls InspectorController::setSetting after converting from script types.
+ (WebCore::InspectorController::InspectorController): Increment a global static
+ to track the number of live InspectorControllers.
+ (WebCore::InspectorController::~InspectorController): Decrement the global static
+ that tracks the number of live InspectorControllers. Delete the setting cache if there
+ are no more live controllers.
+ (WebCore::InspectorController::setting): Check the cache and return the setting from there,
+ otherwise make a new Setting and ask the client to populate it.
+ (WebCore::InspectorController::setSetting): Change the cache and ask the client to store it.
+ (WebCore::InspectorController::windowScriptObjectAvailable): Add setting and setSetting
+ to the InspectorController script class.
+ * inspector/InspectorController.h:
+ (WebCore::InspectorController::Setting::Setting):
+ (WebCore::InspectorController::Setting::operator=):
+ (WebCore::InspectorController::Setting::type): Return m_type.
+ (WebCore::InspectorController::Setting::string): Return m_string. Assert the type is correct.
+ (WebCore::InspectorController::Setting::stringVector): Return m_stringVector.
+ Assert the type is correct.
+ (WebCore::InspectorController::Setting::doubleValue): Return m_simpleContent.m_double.
+ Assert the type is correct.
+ (WebCore::InspectorController::Setting::integerValue): Return m_simpleContent.m_integer.
+ Assert the type is correct.
+ (WebCore::InspectorController::Setting::booleanValue): Return m_simpleContent.m_boolean.
+ Assert the type is correct.
+ (WebCore::InspectorController::Setting::set): Overloaded for each data type, sets the right
+ field and the type.
+ * loader/EmptyClients.h:
+ (WebCore::EmptyInspectorClient::populateSetting): Added, empty method.
+ (WebCore::EmptyInspectorClient::storeSetting): Ditto.
+ (WebCore::EmptyInspectorClient::removeSetting): Ditto.
+
2008-10-24 Cameron Zwarich <zwarich@apple.com>
Reviewed by Sam Weinig.
__ZN7WebCore6String6appendERKS0_
__ZN7WebCore6String6appendEc
__ZN7WebCore6StringC1EP8NSString
+__ZN7WebCore6StringC1EPK10__CFString
__ZN7WebCore6StringC1EPKc
__ZN7WebCore6StringC1EPKcj
__ZN7WebCore6StringC1ERKN3JSC7UStringE
#ifndef InspectorClient_h
#define InspectorClient_h
+#include "InspectorController.h"
+
namespace WebCore {
class Node;
virtual void hideHighlight() = 0;
virtual void inspectedURLChanged(const String& newURL) = 0;
+
+ virtual void populateSetting(const String& key, InspectorController::Setting&) = 0;
+ virtual void storeSetting(const String& key, const InspectorController::Setting&) = 0;
+ virtual void removeSetting(const String& key) = 0;
};
} // namespace WebCore
return toRef(JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), inspectedWindow));
}
+static JSValueRef setting(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef arguments[], JSValueRef* exception)
+{
+ InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
+ if (!controller)
+ return JSValueMakeUndefined(ctx);
+
+ JSValueRef keyValue = arguments[0];
+ if (!JSValueIsString(ctx, keyValue))
+ return JSValueMakeUndefined(ctx);
+
+ const InspectorController::Setting& setting = controller->setting(toString(ctx, keyValue, exception));
+
+ switch (setting.type()) {
+ default:
+ case InspectorController::Setting::NoType:
+ return JSValueMakeUndefined(ctx);
+ case InspectorController::Setting::StringType:
+ return JSValueMakeString(ctx, jsStringRef(setting.string()).get());
+ case InspectorController::Setting::DoubleType:
+ return JSValueMakeNumber(ctx, setting.doubleValue());
+ case InspectorController::Setting::IntegerType:
+ return JSValueMakeNumber(ctx, setting.integerValue());
+ case InspectorController::Setting::BooleanType:
+ return JSValueMakeBoolean(ctx, setting.booleanValue());
+ case InspectorController::Setting::StringVectorType: {
+ Vector<JSValueRef> stringValues;
+ const Vector<String>& strings = setting.stringVector();
+ const unsigned length = strings.size();
+ for (unsigned i = 0; i < length; ++i)
+ stringValues.append(JSValueMakeString(ctx, jsStringRef(strings[i]).get()));
+
+ JSObjectRef stringsArray = JSObjectMakeArray(ctx, stringValues.size(), stringValues.data(), exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+ return stringsArray;
+ }
+ }
+}
+
+static JSValueRef setSetting(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef arguments[], JSValueRef* exception)
+{
+ InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
+ if (!controller)
+ return JSValueMakeUndefined(ctx);
+
+ JSValueRef keyValue = arguments[0];
+ if (!JSValueIsString(ctx, keyValue))
+ return JSValueMakeUndefined(ctx);
+
+ InspectorController::Setting setting;
+
+ JSValueRef value = arguments[1];
+ switch (JSValueGetType(ctx, value)) {
+ default:
+ case kJSTypeUndefined:
+ case kJSTypeNull:
+ // Do nothing. The setting is already NoType.
+ ASSERT(setting.type() == InspectorController::Setting::NoType);
+ break;
+ case kJSTypeString:
+ setting.set(toString(ctx, value, exception));
+ break;
+ case kJSTypeNumber:
+ setting.set(JSValueToNumber(ctx, value, exception));
+ break;
+ case kJSTypeBoolean:
+ setting.set(JSValueToBoolean(ctx, value));
+ break;
+ case kJSTypeObject: {
+ JSObjectRef object = JSValueToObject(ctx, value, 0);
+ JSValueRef lengthValue = JSObjectGetProperty(ctx, object, jsStringRef("length").get(), exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+
+ Vector<String> strings;
+ const unsigned length = static_cast<unsigned>(JSValueToNumber(ctx, lengthValue, 0));
+ for (unsigned i = 0; i < length; ++i) {
+ JSValueRef itemValue = JSObjectGetPropertyAtIndex(ctx, object, i, exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+ strings.append(toString(ctx, itemValue, exception));
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+ }
+
+ setting.set(strings);
+ break;
+ }
+ }
+
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+
+ controller->setSetting(toString(ctx, keyValue, exception), setting);
+
+ return JSValueMakeUndefined(ctx);
+}
+
static JSValueRef localizedStrings(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments[]*/, JSValueRef* /*exception*/)
{
InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
// InspectorController Class
+static unsigned s_inspectorControllerCount;
+static HashMap<String, InspectorController::Setting*>* s_settingCache;
+
InspectorController::InspectorController(Page* page, InspectorClient* client)
: m_inspectedPage(page)
, m_client(client)
{
ASSERT_ARG(page, page);
ASSERT_ARG(client, client);
+ ++s_inspectorControllerCount;
}
InspectorController::~InspectorController()
deleteAllValues(m_frameResources);
deleteAllValues(m_consoleMessages);
+
+ ASSERT(s_inspectorControllerCount);
+ --s_inspectorControllerCount;
+
+ if (!s_inspectorControllerCount && s_settingCache) {
+ deleteAllValues(*s_settingCache);
+ delete s_settingCache;
+ s_settingCache = 0;
+ }
}
void InspectorController::inspectedPageDestroyed()
return m_inspectedPage->settings()->developerExtrasEnabled();
}
+const InspectorController::Setting& InspectorController::setting(const String& key) const
+{
+ if (!s_settingCache)
+ s_settingCache = new HashMap<String, Setting*>;
+
+ if (Setting* cachedSetting = s_settingCache->get(key))
+ return *cachedSetting;
+
+ Setting* newSetting = new Setting;
+ s_settingCache->set(key, newSetting);
+
+ m_client->populateSetting(key, *newSetting);
+
+ return *newSetting;
+}
+
+void InspectorController::setSetting(const String& key, const Setting& setting)
+{
+ if (setting.type() == Setting::NoType) {
+ if (s_settingCache) {
+ Setting* cachedSetting = s_settingCache->get(key);
+ if (cachedSetting) {
+ s_settingCache->remove(key);
+ delete cachedSetting;
+ }
+ }
+
+ m_client->removeSetting(key);
+ return;
+ }
+
+ if (!s_settingCache)
+ s_settingCache = new HashMap<String, Setting*>;
+
+ if (Setting* cachedSetting = s_settingCache->get(key))
+ *cachedSetting = setting;
+ else
+ s_settingCache->set(key, new Setting(setting));
+
+ m_client->storeSetting(key, setting);
+}
+
String InspectorController::localizedStringsURL()
{
if (!enabled())
#if ENABLE(DATABASE)
{ "databaseTableNames", WebCore::databaseTableNames, kJSPropertyAttributeNone },
#endif
+ { "setting", WebCore::setting, kJSPropertyAttributeNone },
+ { "setSetting", WebCore::setSetting, kJSPropertyAttributeNone },
{ "inspectedWindow", WebCore::inspectedWindow, kJSPropertyAttributeNone },
{ "localizedStringsURL", WebCore::localizedStrings, kJSPropertyAttributeNone },
{ "platform", WebCore::platform, kJSPropertyAttributeNone },
ScriptsPanel
} SpecialPanels;
+ struct Setting {
+ enum Type {
+ NoType, StringType, StringVectorType, DoubleType, IntegerType, BooleanType
+ };
+
+ Setting()
+ : m_type(NoType)
+ {
+ }
+
+ Type type() const { return m_type; }
+
+ String string() const { ASSERT(m_type == StringType); return m_string; }
+ const Vector<String>& stringVector() const { ASSERT(m_type == StringVectorType); return m_stringVector; }
+ double doubleValue() const { ASSERT(m_type == DoubleType); return m_simpleContent.m_double; }
+ long integerValue() const { ASSERT(m_type == IntegerType); return m_simpleContent.m_integer; }
+ bool booleanValue() const { ASSERT(m_type == BooleanType); return m_simpleContent.m_boolean; }
+
+ void set(const String& value) { m_type = StringType; m_string = value; }
+ void set(const Vector<String>& value) { m_type = StringVectorType; m_stringVector = value; }
+ void set(double value) { m_type = DoubleType; m_simpleContent.m_double = value; }
+ void set(long value) { m_type = IntegerType; m_simpleContent.m_integer = value; }
+ void set(bool value) { m_type = BooleanType; m_simpleContent.m_boolean = value; }
+
+ private:
+ Type m_type;
+
+ String m_string;
+ Vector<String> m_stringVector;
+
+ union {
+ double m_double;
+ long m_integer;
+ bool m_boolean;
+ } m_simpleContent;
+ };
+
InspectorController(Page*, InspectorClient*);
~InspectorController();
Page* inspectedPage() const { return m_inspectedPage; }
+ const Setting& setting(const String& key) const;
+ void setSetting(const String& key, const Setting&);
+
String localizedStringsURL();
void inspect(Node*);
class EmptyInspectorClient : public InspectorClient {
public:
- virtual ~EmptyInspectorClient() {}
+ virtual ~EmptyInspectorClient() { }
- virtual void inspectorDestroyed() {};
+ virtual void inspectorDestroyed() { }
virtual Page* createPage() { return 0; };
- virtual String localizedStringsURL() { return String(); };
+ virtual String localizedStringsURL() { return String(); }
- virtual void showWindow() {};
- virtual void closeWindow() {};
+ virtual void showWindow() { }
+ virtual void closeWindow() { }
- virtual void attachWindow() {};
- virtual void detachWindow() {};
+ virtual void attachWindow() { }
+ virtual void detachWindow() { }
- virtual void setAttachedWindowHeight(unsigned) {};
+ virtual void setAttachedWindowHeight(unsigned) { }
- virtual void highlight(Node*) {};
- virtual void hideHighlight() {};
- virtual void inspectedURLChanged(const String& newURL) {};
+ virtual void highlight(Node*) { }
+ virtual void hideHighlight() { }
+ virtual void inspectedURLChanged(const String& newURL) { }
+
+ virtual void populateSetting(const String& key, InspectorController::Setting&) { }
+ virtual void storeSetting(const String& key, const InspectorController::Setting&) { }
+ virtual void removeSetting(const String& key) { }
};
}
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Implement new InspectorClient methods to work with Settings.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Darin Adler.
+
+ * WebKit.xcodeproj/project.pbxproj: Add the new InspectorClientCF.cpp file.
+
2008-10-15 Mark Rowe <mrowe@apple.com>
Rubber-stamped by Brady Eidson.
1C68F670095B5FC100C2984E /* WebNodeHighlight.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C68F664095B5FC100C2984E /* WebNodeHighlight.m */; };
1C68F671095B5FC100C2984E /* WebNodeHighlightView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C68F665095B5FC100C2984E /* WebNodeHighlightView.h */; };
1C68F672095B5FC100C2984E /* WebNodeHighlightView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C68F666095B5FC100C2984E /* WebNodeHighlightView.m */; };
+ 1C7B0C660EB2464D00A28502 /* WebInspectorClientCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C7B0C650EB2464D00A28502 /* WebInspectorClientCF.cpp */; };
1C8CB07A0AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
1CA57D620AED6A470009BDD0 /* WebGraphicsExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA57D600AED6A470009BDD0 /* WebGraphicsExtras.h */; };
1CA57D630AED6A470009BDD0 /* WebGraphicsExtras.c in Sources */ = {isa = PBXBuildFile; fileRef = 1CA57D610AED6A470009BDD0 /* WebGraphicsExtras.c */; };
1C68F665095B5FC100C2984E /* WebNodeHighlightView.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNodeHighlightView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C68F666095B5FC100C2984E /* WebNodeHighlightView.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; indentWidth = 4; path = WebNodeHighlightView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C6CB03E0AA6391D00D23BFD /* MigrateHeaders.make */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = MigrateHeaders.make; path = mac/MigrateHeaders.make; sourceTree = "<group>"; };
+ 1C7B0C650EB2464D00A28502 /* WebInspectorClientCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebInspectorClientCF.cpp; path = cf/WebCoreSupport/WebInspectorClientCF.cpp; sourceTree = SOURCE_ROOT; };
1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebEditingDelegatePrivate.h; sourceTree = "<group>"; };
1C904FD20BA9DD0F0081E9D0 /* WebKit.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebKit.xcconfig; sourceTree = "<group>"; };
1C904FD30BA9DD0F0081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
51494CD50C7EBDE0004178C5 /* WebIconDatabaseClient.mm */,
9CE1F8A302A5C6F30ECA2ACD /* WebImageRendererFactory.m */,
06693DDA0BFBA85200216072 /* WebInspectorClient.h */,
+ 1C7B0C650EB2464D00A28502 /* WebInspectorClientCF.cpp */,
06693DDB0BFBA85200216072 /* WebInspectorClient.mm */,
9345D4EA0365C5B2008635CE /* WebJavaScriptTextInputPanel.h */,
9345D4EB0365C5B2008635CE /* WebJavaScriptTextInputPanel.m */,
1AEA6A510DC8CE2F003D12BF /* WebNetscapePluginEventHandlerCocoa.mm in Sources */,
1A2D754E0DE480B900F0A648 /* WebIconFetcher.mm in Sources */,
F834AAD80E64B1C700E2737C /* WebTextIterator.mm in Sources */,
+ 1C7B0C660EB2464D00A28502 /* WebInspectorClientCF.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Implement new InspectorClient methods to work with Settings.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/WebInspectorClientCF.cpp: Added.
+ (createKeyForPreferences): Helper to make the preference key.
+ (WebInspectorClient::populateSetting): Read the preference value from CFPreferences.
+ (WebInspectorClient::storeSetting): Write the setting value to CFPreferences.
+ (WebInspectorClient::removeSetting): Remove the preference from CFPreferences.
--- /dev/null
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebInspectorClient.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include <WebCore/PlatformString.h>
+
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+static inline CFStringRef createKeyForPreferences(const String& key)
+{
+ RetainPtr<CFStringRef> keyCFString(AdoptCF, key.createCFString());
+ return CFStringCreateWithFormat(0, 0, CFSTR("WebKit Web Inspector Setting - %@"), keyCFString.get());
+}
+
+void WebInspectorClient::populateSetting(const String& key, InspectorController::Setting& setting)
+{
+ RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key));
+ RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(preferencesKey.get(), kCFPreferencesCurrentApplication));
+
+ if (!value)
+ return;
+
+ CFTypeID type = CFGetTypeID(value.get());
+ if (type == CFStringGetTypeID())
+ setting.set(static_cast<String>(static_cast<CFStringRef>(value.get())));
+ else if (type == CFBooleanGetTypeID())
+ setting.set(static_cast<bool>(CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()))));
+ else if (type == CFNumberGetTypeID()) {
+ CFNumberRef number = static_cast<CFNumberRef>(value.get());
+ if (CFNumberIsFloatType(number)) {
+ double doubleNumber = 0.0;
+ CFNumberGetValue(static_cast<CFNumberRef>(value.get()), kCFNumberDoubleType, &doubleNumber);
+ setting.set(doubleNumber);
+ } else {
+ long longNumber = 0;
+ CFNumberGetValue(static_cast<CFNumberRef>(value.get()), kCFNumberLongType, &longNumber);
+ setting.set(longNumber);
+ }
+ } else if (type == CFArrayGetTypeID()) {
+ Vector<String> strings;
+
+ CFArrayRef array = static_cast<CFArrayRef>(value.get());
+ unsigned length = CFArrayGetCount(array);
+ for (unsigned i = 0; i < length; ++i) {
+ CFStringRef string = static_cast<CFStringRef>(CFArrayGetValueAtIndex(array, i));
+ if (CFGetTypeID(string) == CFStringGetTypeID())
+ strings.append(static_cast<String>(static_cast<CFStringRef>(string)));
+ }
+
+ setting.set(strings);
+ } else
+ ASSERT_NOT_REACHED();
+}
+
+void WebInspectorClient::storeSetting(const String& key, const InspectorController::Setting& setting)
+{
+ RetainPtr<CFPropertyListRef> objectToStore;
+
+ switch (setting.type()) {
+ default:
+ case InspectorController::Setting::NoType:
+ ASSERT_NOT_REACHED();
+ break;
+ case InspectorController::Setting::StringType:
+ objectToStore.adoptCF(setting.string().createCFString());
+ break;
+ case InspectorController::Setting::BooleanType:
+ objectToStore = (setting.booleanValue() ? kCFBooleanTrue : kCFBooleanFalse);
+ break;
+
+ case InspectorController::Setting::DoubleType: {
+ double value = setting.doubleValue();
+ objectToStore.adoptCF(CFNumberCreate(0, kCFNumberDoubleType, &value));
+ break;
+ }
+
+ case InspectorController::Setting::IntegerType: {
+ long value = setting.integerValue();
+ objectToStore.adoptCF(CFNumberCreate(0, kCFNumberLongType, &value));
+ break;
+ }
+
+ case InspectorController::Setting::StringVectorType: {
+ const Vector<String>& strings = setting.stringVector();
+ const unsigned length = strings.size();
+
+ RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, length, &kCFTypeArrayCallBacks));
+
+ for (unsigned i = 0; i < length; ++i) {
+ RetainPtr<CFStringRef> string(AdoptCF, strings[i].createCFString());
+ CFArraySetValueAtIndex(array.get(), i, string.get());
+ }
+
+ objectToStore = array;
+ break;
+ }
+ }
+
+ ASSERT(objectToStore);
+
+ RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key));
+ CFPreferencesSetAppValue(preferencesKey.get(), objectToStore.get(), kCFPreferencesCurrentApplication);
+}
+
+void WebInspectorClient::removeSetting(const String& key)
+{
+ RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key));
+ CFPreferencesSetAppValue(preferencesKey.get(), 0, kCFPreferencesCurrentApplication);
+}
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Stub out new InspectorClient methods.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/InspectorClientGtk.cpp:
+ (WebKit::InspectorClient::populateSetting): Not implemented.
+ (WebKit::InspectorClient::storeSetting): Ditto.
+ (WebKit::InspectorClient::removeSetting): Ditto.
+ * WebCoreSupport/InspectorClientGtk.h:
+
2008-10-22 Alp Toker <alp@nuanti.com>
Build fix for older GTK+ versions where GTK_TYPE_TARGET_LIST isn't
notImplemented();
}
+void InspectorClient::populateSetting(const String& key, InspectorController::Setting& setting)
+{
+ notImplemented();
+}
+
+void InspectorClient::storeSetting(const String& key, const InspectorController::Setting& setting)
+{
+ notImplemented();
+}
+
+void InspectorClient::removeSetting(const String& key)
+{
+ notImplemented();
+}
+
}
virtual void highlight(WebCore::Node*);
virtual void hideHighlight();
virtual void inspectedURLChanged(const WebCore::String& newURL);
+
+ virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&);
+ virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&);
+ virtual void removeSetting(const WebCore::String& key);
};
}
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Implement new InspectorClient methods to work with Settings.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/WebInspectorClient.h: Add the new methods and
+ guard the ObjC parts of the header.
+
2008-10-24 Darin Adler <darin@apple.com>
- finish rolling out https://bugs.webkit.org/show_bug.cgi?id=21732
#import <wtf/RetainPtr.h>
+#ifdef __OBJC__
@class WebInspectorWindowController;
@class WebView;
+#else
+class WebInspectorWindowController;
+class WebView;
+#endif
class WebInspectorClient : public WebCore::InspectorClient {
public:
virtual void hideHighlight();
virtual void inspectedURLChanged(const WebCore::String& newURL);
+ virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&);
+ virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&);
+ virtual void removeSetting(const WebCore::String& key);
+
private:
void updateWindowTitle() const;
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Stub out new InspectorClient methods.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/InspectorClientQt.cpp:
+ (WebCore::InspectorClientQt::populateSetting): Not implemented.
+ (WebCore::InspectorClientQt::storeSetting): Ditto.
+ (WebCore::InspectorClientQt::removeSetting): Ditto.
+ * WebCoreSupport/InspectorClientQt.h:
+
2008-10-24 Darin Adler <darin@apple.com>
- finish rolling out https://bugs.webkit.org/show_bug.cgi?id=21732
m_webPage->view()->setWindowTitle(caption.arg(m_inspectedURL));
}
+void InspectorClientQt::populateSetting(const String& key, InspectorController::Setting& setting)
+{
+ notImplemented();
+}
+
+void InspectorClientQt::storeSetting(const String& key, const InspectorController::Setting& setting)
+{
+ notImplemented();
+}
+
+void InspectorClientQt::removeSetting(const String& key)
+{
+ notImplemented();
+}
+
}
#include "InspectorClientQt.moc"
virtual void hideHighlight();
virtual void inspectedURLChanged(const String& newURL);
+ virtual void populateSetting(const String& key, InspectorController::Setting&);
+ virtual void storeSetting(const String& key, const InspectorController::Setting&);
+ virtual void removeSetting(const String& key);
+
private:
void updateWindowTitle();
QWebPage* m_inspectedWebPage;
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Implement new InspectorClient methods to work with Settings.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Adam Roben.
+
+ * WebKit.vcproj/WebKit.vcproj: Add the new InspectorClientCF.cpp file.
+ * WebCoreSupport/WebInspectorClient.h: Add the new methods.
+
2008-10-24 Darin Adler <darin@apple.com>
- finish rolling out https://bugs.webkit.org/show_bug.cgi?id=21732
virtual void inspectedURLChanged(const WebCore::String& newURL);
+ virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&);
+ virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&);
+ virtual void removeSetting(const WebCore::String& key);
+
private:
~WebInspectorClient();
RelativePath="..\WebCoreSupport\WebInspectorClient.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\cf\WebCoreSupport\WebInspectorClientCF.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\WebCoreSupport\WebInspectorDelegate.cpp"\r
>\r
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Stub out new InspectorClient methods.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Darin Adler.
+
+ * WebKitSupport/InspectorClientWx.cpp:
+ (WebCore::InspectorClient::populateSetting): Not implemented.
+ (WebCore::InspectorClient::storeSetting): Ditto.
+ (WebCore::InspectorClient::removeSetting): Ditto.
+ * WebKitSupport/InspectorClientWx.h:
+
2008-10-24 Darin Adler <darin@apple.com>
- finish rolling out https://bugs.webkit.org/show_bug.cgi?id=21732
notImplemented();
}
+void InspectorClient::populateSetting(const String& key, InspectorController::Setting& setting)
+{
+ notImplemented();
+}
+
+void InspectorClient::storeSetting(const String& key, const InspectorController::Setting& setting)
+{
+ notImplemented();
+}
+
+void InspectorClient::removeSetting(const String& key)
+{
+ notImplemented();
+}
+
};
virtual void hideHighlight();
virtual void inspectedURLChanged(const String& newURL);
+
+ virtual void populateSetting(const String& key, InspectorController::Setting&);
+ virtual void storeSetting(const String& key, const InspectorController::Setting&);
+ virtual void removeSetting(const String& key);
};
} // namespace WebCore