[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
weinig at apple.com
weinig at apple.com
Wed Dec 22 17:56:28 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 5da5bc8089fd6bd1dda9d9d3ba3602eb267757d9
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 3 00:30:58 2010 +0000
WebKit2 Preferences should be held off the PageGroup, not the Context
https://bugs.webkit.org/show_bug.cgi?id=50414
Reviewed by Anders Carlsson.
WebKit2:
- In addition, this now makes the preference held off the PageGroup have
the identifier of the PageGroup and autosave to disk (only on the mac
for now).
- Adds ability to create an arbitrary preference that can be autosaved
via a new WKPreferencesCreateWithIdentifier function.
* UIProcess/API/C/WKContext.cpp:
* UIProcess/API/C/WKContext.h:
Remove preference related code.
* UIProcess/API/C/WKPageGroup.cpp:
(WKPageGroupSetPreferences):
(WKPageGroupGetPreferences):
* UIProcess/API/C/WKPageGroup.h:
Add getter/setter for preferences.
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesCreateWithIdentifier):
* UIProcess/API/C/WKPreferences.h:
Add WKPreferencesCreateWithIdentifier and remove WKPreferencesCreateCopy which is
unused.
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
(WebKit::WebContext::~WebContext):
* UIProcess/WebContext.h:
Remove preference related code.
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::WebPageGroup):
(WebKit::WebPageGroup::addPage):
(WebKit::WebPageGroup::removePage):
(WebKit::WebPageGroup::setPreferences):
(WebKit::WebPageGroup::preferences):
(WebKit::WebPageGroup::preferencesDidChange):
* UIProcess/WebPageGroup.h:
Add preference and page tracking.
* UIProcess/WebPageNamespace.cpp:
* UIProcess/WebPageNamespace.h:
Remove preference change notification code.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::~WebPageProxy):
Add/remove self from page group set.
(WebKit::WebPageProxy::preferencesDidChange):
(WebKit::WebPageProxy::creationParameters):
Get preferences from the pageGroup.
* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::WebPreferences):
(WebKit::WebPreferences::addPageGroup):
(WebKit::WebPreferences::removePageGroup):
(WebKit::WebPreferences::update):
* UIProcess/WebPreferences.h:
(WebKit::WebPreferences::create):
Change to track page groups instead of contexts.
* UIProcess/mac/WebPreferencesMac.mm:
(WebKit::makeKey): Add ".WebKit2" prefix for keys.
WebKitTools:
Update for API changes.
* WebKitTestRunner/PlatformWebView.h:
* WebKitTestRunner/TestController.cpp:
(WTR::createOtherPage):
(WTR::TestController::initialize):
(WTR::TestController::resetStateToConsistentValues):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::PlatformWebView):
* WebKitTestRunner/win/PlatformWebViewWin.cpp:
(WTR::PlatformWebView::PlatformWebView):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73215 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 621ab7b..0457e64 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,73 @@
+2010-12-02 Sam Weinig <sam at webkit.org>
+
+ Reviewed by Anders Carlsson.
+
+ WebKit2 Preferences should be held off the PageGroup, not the Context
+ https://bugs.webkit.org/show_bug.cgi?id=50414
+
+ - In addition, this now makes the preference held off the PageGroup have
+ the identifier of the PageGroup and autosave to disk (only on the mac
+ for now).
+ - Adds ability to create an arbitrary preference that can be autosaved
+ via a new WKPreferencesCreateWithIdentifier function.
+
+ * UIProcess/API/C/WKContext.cpp:
+ * UIProcess/API/C/WKContext.h:
+ Remove preference related code.
+
+ * UIProcess/API/C/WKPageGroup.cpp:
+ (WKPageGroupSetPreferences):
+ (WKPageGroupGetPreferences):
+ * UIProcess/API/C/WKPageGroup.h:
+ Add getter/setter for preferences.
+
+ * UIProcess/API/C/WKPreferences.cpp:
+ (WKPreferencesCreateWithIdentifier):
+ * UIProcess/API/C/WKPreferences.h:
+ Add WKPreferencesCreateWithIdentifier and remove WKPreferencesCreateCopy which is
+ unused.
+
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::WebContext):
+ (WebKit::WebContext::~WebContext):
+ * UIProcess/WebContext.h:
+ Remove preference related code.
+
+ * UIProcess/WebPageGroup.cpp:
+ (WebKit::WebPageGroup::WebPageGroup):
+ (WebKit::WebPageGroup::addPage):
+ (WebKit::WebPageGroup::removePage):
+ (WebKit::WebPageGroup::setPreferences):
+ (WebKit::WebPageGroup::preferences):
+ (WebKit::WebPageGroup::preferencesDidChange):
+ * UIProcess/WebPageGroup.h:
+ Add preference and page tracking.
+
+ * UIProcess/WebPageNamespace.cpp:
+ * UIProcess/WebPageNamespace.h:
+ Remove preference change notification code.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ (WebKit::WebPageProxy::~WebPageProxy):
+ Add/remove self from page group set.
+
+ (WebKit::WebPageProxy::preferencesDidChange):
+ (WebKit::WebPageProxy::creationParameters):
+ Get preferences from the pageGroup.
+
+ * UIProcess/WebPreferences.cpp:
+ (WebKit::WebPreferences::WebPreferences):
+ (WebKit::WebPreferences::addPageGroup):
+ (WebKit::WebPreferences::removePageGroup):
+ (WebKit::WebPreferences::update):
+ * UIProcess/WebPreferences.h:
+ (WebKit::WebPreferences::create):
+ Change to track page groups instead of contexts.
+
+ * UIProcess/mac/WebPreferencesMac.mm:
+ (WebKit::makeKey): Add ".WebKit2" prefix for keys.
+
2010-12-02 Anders Carlsson <andersca at apple.com>
Reviewed by Sam Weinig.
diff --git a/WebKit2/UIProcess/API/C/WKContext.cpp b/WebKit2/UIProcess/API/C/WKContext.cpp
index ba32317..3752fa8 100644
--- a/WebKit2/UIProcess/API/C/WKContext.cpp
+++ b/WebKit2/UIProcess/API/C/WKContext.cpp
@@ -28,7 +28,6 @@
#include "WKAPICast.h"
#include "WebContext.h"
-#include "WebPreferences.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/text/WTFString.h>
@@ -62,16 +61,6 @@ WKContextRef WKContextGetSharedThreadContext()
return toAPI(WebContext::sharedThreadContext());
}
-void WKContextSetPreferences(WKContextRef contextRef, WKPreferencesRef preferencesRef)
-{
- toImpl(contextRef)->setPreferences(toImpl(preferencesRef));
-}
-
-WKPreferencesRef WKContextGetPreferences(WKContextRef contextRef)
-{
- return toAPI(toImpl(contextRef)->preferences());
-}
-
void WKContextSetInjectedBundleClient(WKContextRef contextRef, const WKContextInjectedBundleClient* wkClient)
{
if (wkClient && wkClient->version)
diff --git a/WebKit2/UIProcess/API/C/WKContext.h b/WebKit2/UIProcess/API/C/WKContext.h
index 2970a6a..6bf9142 100644
--- a/WebKit2/UIProcess/API/C/WKContext.h
+++ b/WebKit2/UIProcess/API/C/WKContext.h
@@ -103,9 +103,6 @@ WK_EXPORT WKContextRef WKContextCreate();
WK_EXPORT WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef path);
WK_EXPORT WKContextRef WKContextGetSharedProcessContext();
-WK_EXPORT void WKContextSetPreferences(WKContextRef context, WKPreferencesRef preferences);
-WK_EXPORT WKPreferencesRef WKContextGetPreferences(WKContextRef context);
-
WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKContextInjectedBundleClient* client);
WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClient* client);
WK_EXPORT void WKContextSetDownloadClient(WKContextRef context, const WKContextDownloadClient* client);
diff --git a/WebKit2/UIProcess/API/C/WKPageGroup.cpp b/WebKit2/UIProcess/API/C/WKPageGroup.cpp
index 305fbc4..6c10014 100644
--- a/WebKit2/UIProcess/API/C/WKPageGroup.cpp
+++ b/WebKit2/UIProcess/API/C/WKPageGroup.cpp
@@ -27,6 +27,7 @@
#include "WKAPICast.h"
#include "WebPageGroup.h"
+#include "WebPreferences.h"
using namespace WebKit;
@@ -41,7 +42,17 @@ WKPageGroupRef WKPageGroupCreateWithIdentifier(WKStringRef identifier)
return toAPI(pageGroup.release().leakRef());
}
-WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup)
+WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroupRef)
{
- return toCopiedAPI(toImpl(pageGroup)->identifier());
+ return toCopiedAPI(toImpl(pageGroupRef)->identifier());
+}
+
+void WKPageGroupSetPreferences(WKPageGroupRef pageGroupRef, WKPreferencesRef preferencesRef)
+{
+ toImpl(pageGroupRef)->setPreferences(toImpl(preferencesRef));
+}
+
+WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroupRef)
+{
+ return toAPI(toImpl(pageGroupRef)->preferences());
}
diff --git a/WebKit2/UIProcess/API/C/WKPageGroup.h b/WebKit2/UIProcess/API/C/WKPageGroup.h
index 8433d33..705df08 100644
--- a/WebKit2/UIProcess/API/C/WKPageGroup.h
+++ b/WebKit2/UIProcess/API/C/WKPageGroup.h
@@ -38,6 +38,9 @@ WK_EXPORT WKPageGroupRef WKPageGroupCreateWithIdentifier(WKStringRef identifier)
WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup);
+WK_EXPORT void WKPageGroupSetPreferences(WKPageGroupRef pageGroup, WKPreferencesRef preferences);
+WK_EXPORT WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroup);
+
#ifdef __cplusplus
}
#endif
diff --git a/WebKit2/UIProcess/API/C/WKPreferences.cpp b/WebKit2/UIProcess/API/C/WKPreferences.cpp
index 1553664..dccbd14 100644
--- a/WebKit2/UIProcess/API/C/WKPreferences.cpp
+++ b/WebKit2/UIProcess/API/C/WKPreferences.cpp
@@ -44,9 +44,9 @@ WKPreferencesRef WKPreferencesCreate()
return toAPI(preferences.release().leakRef());
}
-WKPreferencesRef WKPreferencesCreateCopy(WKPreferencesRef preferencesRef)
+WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifierRef)
{
- RefPtr<WebPreferences> preferences = WebPreferences::copy(toImpl(preferencesRef));
+ RefPtr<WebPreferences> preferences = WebPreferences::create(toWTFString(identifierRef));
return toAPI(preferences.release().releaseRef());
}
diff --git a/WebKit2/UIProcess/API/C/WKPreferences.h b/WebKit2/UIProcess/API/C/WKPreferences.h
index 00478b1..0e33066 100644
--- a/WebKit2/UIProcess/API/C/WKPreferences.h
+++ b/WebKit2/UIProcess/API/C/WKPreferences.h
@@ -39,7 +39,7 @@ extern "C" {
WK_EXPORT WKTypeID WKPreferencesGetTypeID();
WK_EXPORT WKPreferencesRef WKPreferencesCreate();
-WK_EXPORT WKPreferencesRef WKPreferencesCreateCopy(WKPreferencesRef);
+WK_EXPORT WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifier);
// Defaults to true.
WK_EXPORT void WKPreferencesSetJavaScriptEnabled(WKPreferencesRef preferences, bool javaScriptEnabled);
diff --git a/WebKit2/UIProcess/API/qt/qwkpage.cpp b/WebKit2/UIProcess/API/qt/qwkpage.cpp
index bba2cc4..8b9d0fc 100644
--- a/WebKit2/UIProcess/API/qt/qwkpage.cpp
+++ b/WebKit2/UIProcess/API/qt/qwkpage.cpp
@@ -46,6 +46,7 @@
#include <WebCore/Cursor.h>
#include <WebCore/FloatRect.h>
#include <WebKit2/WKFrame.h>
+#include <WebKit2/WKPageGroup.h>
#include <WebKit2/WKRetainPtr.h>
using namespace WebKit;
@@ -462,8 +463,8 @@ WKPageRef QWKPage::pageRef() const
QWKPreferences* QWKPage::preferences() const
{
if (!d->preferences) {
- WKContextRef contextRef = WKPageNamespaceGetContext(toAPI(d->page->pageNamespace()));
- d->preferences = QWKPreferencesPrivate::createPreferences(contextRef);
+ WKPageGroupRef pageGroupRef = WKPageGetPageGroup(pageRef());
+ d->preferences = QWKPreferencesPrivate::createPreferences(pageGroupRef);
}
return d->preferences;
diff --git a/WebKit2/UIProcess/API/qt/qwkpreferences.cpp b/WebKit2/UIProcess/API/qt/qwkpreferences.cpp
index 11271ff..a4c942b 100644
--- a/WebKit2/UIProcess/API/qt/qwkpreferences.cpp
+++ b/WebKit2/UIProcess/API/qt/qwkpreferences.cpp
@@ -19,17 +19,17 @@
#include "qwkpreferences.h"
-#include "WKContext.h"
+#include "WKPageGroup.h"
#include "WKPreferences.h"
#include "WKStringQt.h"
#include "WKRetainPtr.h"
#include "qwkpreferences_p.h"
-QWKPreferences* QWKPreferencesPrivate::createPreferences(WKContextRef contextRef)
+QWKPreferences* QWKPreferencesPrivate::createPreferences(WKPageGroupRef pageGroupRef)
{
QWKPreferences* prefs = new QWKPreferences;
- prefs->d->ref = WKContextGetPreferences(contextRef);
+ prefs->d->ref = WKContextGetPreferences(pageGroupRef);
return prefs;
}
diff --git a/WebKit2/UIProcess/API/qt/qwkpreferences_p.h b/WebKit2/UIProcess/API/qt/qwkpreferences_p.h
index 7030c55..7fe2389 100644
--- a/WebKit2/UIProcess/API/qt/qwkpreferences_p.h
+++ b/WebKit2/UIProcess/API/qt/qwkpreferences_p.h
@@ -21,7 +21,7 @@
class QWKPreferencesPrivate {
public:
- static QWKPreferences* createPreferences(WKContextRef contextRef);
+ static QWKPreferences* createPreferences(WKPageGroupRef);
static QWKPreferences* createSharedPreferences();
WKPreferencesRef ref;
diff --git a/WebKit2/UIProcess/WebContext.cpp b/WebKit2/UIProcess/WebContext.cpp
index 69f492a..5d071f1 100644
--- a/WebKit2/UIProcess/WebContext.cpp
+++ b/WebKit2/UIProcess/WebContext.cpp
@@ -35,7 +35,6 @@
#include "WebCoreArgumentCoders.h"
#include "WebPageGroup.h"
#include "WebPageNamespace.h"
-#include "WebPreferences.h"
#include "WebProcessCreationParameters.h"
#include "WebProcessManager.h"
#include "WebProcessMessages.h"
@@ -89,9 +88,6 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
{
addLanguageChangeObserver(this, languageChanged);
- m_preferences = WebPreferences::shared();
- m_preferences->addContext(this);
-
#ifndef NDEBUG
webContextCounter.increment();
#endif
@@ -100,7 +96,6 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
WebContext::~WebContext()
{
ASSERT(m_pageNamespaces.isEmpty());
- m_preferences->removeContext(this);
removeLanguageChangeObserver(this);
WebProcessManager::shared().contextWasDestroyed(this);
@@ -235,36 +230,6 @@ void WebContext::pageNamespaceWasDestroyed(WebPageNamespace* pageNamespace)
m_pageNamespaces.remove(pageNamespace);
}
-void WebContext::setPreferences(WebPreferences* preferences)
-{
- ASSERT(preferences);
-
- if (preferences == m_preferences)
- return;
-
- m_preferences->removeContext(this);
- m_preferences = preferences;
- m_preferences->addContext(this);
-
- // FIXME: Update all Pages/PageNamespace with the new WebPreferences.
-}
-
-WebPreferences* WebContext::preferences() const
-{
- return m_preferences.get();
-}
-
-void WebContext::preferencesDidChange()
-{
- if (!m_process)
- return;
-
- for (HashSet<WebPageNamespace*>::iterator it = m_pageNamespaces.begin(), end = m_pageNamespaces.end(); it != end; ++it) {
- WebPageNamespace* pageNamespace = *it;
- pageNamespace->preferencesDidChange();
- }
-}
-
void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
{
if (!m_process || !m_process->canSendMessage()) {
diff --git a/WebKit2/UIProcess/WebContext.h b/WebKit2/UIProcess/WebContext.h
index 7c7bef0..617c62c 100644
--- a/WebKit2/UIProcess/WebContext.h
+++ b/WebKit2/UIProcess/WebContext.h
@@ -50,7 +50,6 @@ class DownloadProxy;
class WebPageGroup;
class WebPageNamespace;
class WebPageProxy;
-class WebPreferences;
struct WebProcessCreationParameters;
class WebContext : public APIObject {
@@ -80,10 +79,6 @@ public:
WebPageNamespace* createPageNamespace();
void pageNamespaceWasDestroyed(WebPageNamespace*);
- void setPreferences(WebPreferences*);
- WebPreferences* preferences() const;
- void preferencesDidChange();
-
const String& injectedBundlePath() const { return m_injectedBundlePath; }
void setInjectedBundleInitializationUserData(PassRefPtr<APIObject> userData) { m_injectedBundleInitializationUserData = userData; }
@@ -159,7 +154,6 @@ private:
RefPtr<WebProcessProxy> m_process;
HashSet<WebPageNamespace*> m_pageNamespaces;
- RefPtr<WebPreferences> m_preferences;
RefPtr<WebPageGroup> m_defaultPageGroup;
diff --git a/WebKit2/UIProcess/WebPageGroup.cpp b/WebKit2/UIProcess/WebPageGroup.cpp
index 796010d..3f52d1d 100644
--- a/WebKit2/UIProcess/WebPageGroup.cpp
+++ b/WebKit2/UIProcess/WebPageGroup.cpp
@@ -25,6 +25,8 @@
#include "WebPageGroup.h"
+#include "WebPageProxy.h"
+#include "WebPreferences.h"
#include <wtf/HashMap.h>
#include <wtf/text/StringConcatenate.h>
@@ -44,7 +46,6 @@ static WebPageGroupMap& webPageGroupMap()
return map;
}
-
PassRefPtr<WebPageGroup> WebPageGroup::create(const String& identifier, bool visibleToInjectedBundle)
{
RefPtr<WebPageGroup> pageGroup = adoptRef(new WebPageGroup(identifier, visibleToInjectedBundle));
@@ -62,11 +63,16 @@ WebPageGroup* WebPageGroup::get(uint64_t pageGroupID)
WebPageGroup::WebPageGroup(const String& identifier, bool visibleToInjectedBundle)
{
m_data.pageGroupID = generatePageGroupID();
- if (!identifier.isNull())
+
+ if (!identifier.isNull()) {
m_data.identifer = identifier;
- else
+ m_preferences = WebPreferences::create(identifier);
+ } else {
m_data.identifer = m_data.identifer = makeString("__uniquePageGroupID-", String::number(m_data.pageGroupID));
- m_data.visibleToInjectedBundle = visibleToInjectedBundle;
+ m_preferences = WebPreferences::create();
+ }
+
+ m_data.visibleToInjectedBundle = visibleToInjectedBundle;
}
WebPageGroup::~WebPageGroup()
@@ -74,4 +80,39 @@ WebPageGroup::~WebPageGroup()
webPageGroupMap().remove(pageGroupID());
}
+void WebPageGroup::addPage(WebPageProxy* page)
+{
+ m_pages.add(page);
+}
+
+void WebPageGroup::removePage(WebPageProxy* page)
+{
+ m_pages.remove(page);
+}
+
+void WebPageGroup::setPreferences(WebPreferences* preferences)
+{
+ if (preferences == m_preferences)
+ return;
+
+ m_preferences->removePageGroup(this);
+ m_preferences = preferences;
+ m_preferences->addPageGroup(this);
+
+ preferencesDidChange();
+}
+
+WebPreferences* WebPageGroup::preferences() const
+{
+ return m_preferences.get();
+}
+
+void WebPageGroup::preferencesDidChange()
+{
+ for (HashSet<WebPageProxy*>::iterator it = m_pages.begin(), end = m_pages.end(); it != end; ++it) {
+ WebPageProxy* page = *it;
+ page->preferencesDidChange();
+ }
+}
+
} // namespace WebKit
diff --git a/WebKit2/UIProcess/WebPageGroup.h b/WebKit2/UIProcess/WebPageGroup.h
index 3467cbc..7859dfc 100644
--- a/WebKit2/UIProcess/WebPageGroup.h
+++ b/WebKit2/UIProcess/WebPageGroup.h
@@ -28,10 +28,14 @@
#include "APIObject.h"
#include "WebPageGroupData.h"
-#include <wtf/PassRefPtr.h>
+#include <wtf/Forward.h>
+#include <wtf/HashSet.h>
namespace WebKit {
+class WebPreferences;
+class WebPageProxy;
+
class WebPageGroup : public APIObject {
public:
static const Type APIType = TypePageGroup;
@@ -41,10 +45,17 @@ public:
virtual ~WebPageGroup();
+ void addPage(WebPageProxy*);
+ void removePage(WebPageProxy*);
+
const String& identifier() const { return m_data.identifer; }
uint64_t pageGroupID() const { return m_data.pageGroupID; }
- const WebPageGroupData& data() { return m_data;; }
+ const WebPageGroupData& data() { return m_data; }
+
+ void setPreferences(WebPreferences*);
+ WebPreferences* preferences() const;
+ void preferencesDidChange();
private:
WebPageGroup(const String& identifier, bool visibleToInjectedBundle);
@@ -52,6 +63,8 @@ private:
virtual Type type() const { return APIType; }
WebPageGroupData m_data;
+ RefPtr<WebPreferences> m_preferences;
+ HashSet<WebPageProxy*> m_pages;
};
} // namespace WebKit
diff --git a/WebKit2/UIProcess/WebPageNamespace.cpp b/WebKit2/UIProcess/WebPageNamespace.cpp
index 2aade94..6bf047f 100644
--- a/WebKit2/UIProcess/WebPageNamespace.cpp
+++ b/WebKit2/UIProcess/WebPageNamespace.cpp
@@ -25,11 +25,10 @@
#include "WebPageNamespace.h"
+#include "WKContextPrivate.h"
#include "WebProcessManager.h"
#include "WebProcessProxy.h"
-#include "WKContextPrivate.h"
-
#ifndef NDEBUG
#include <wtf/RefCountedLeakCounter.h>
#endif
@@ -63,12 +62,6 @@ WebPageProxy* WebPageNamespace::createWebPage(WebPageGroup* group)
return m_context->createWebPage(this, group);
}
-void WebPageNamespace::preferencesDidChange()
-{
- for (WebProcessProxy::pages_const_iterator it = process()->pages_begin(), end = process()->pages_end(); it != end; ++it)
- (*it)->preferencesDidChange();
-}
-
void WebPageNamespace::getStatistics(WKContextStatistics* statistics)
{
if (!process())
diff --git a/WebKit2/UIProcess/WebPageNamespace.h b/WebKit2/UIProcess/WebPageNamespace.h
index 61645be..11b577b 100644
--- a/WebKit2/UIProcess/WebPageNamespace.h
+++ b/WebKit2/UIProcess/WebPageNamespace.h
@@ -54,8 +54,6 @@ public:
WebContext* context() const { return m_context.get(); }
WebProcessProxy* process() const { return m_context->process(); }
- void preferencesDidChange();
-
void getStatistics(WKContextStatistics*);
private:
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index 1e65bd0..7132f2b 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -110,10 +110,14 @@ WebPageProxy::WebPageProxy(WebPageNamespace* pageNamespace, WebPageGroup* pageGr
#ifndef NDEBUG
webPageProxyCounter.increment();
#endif
+
+ m_pageGroup->addPage(this);
}
WebPageProxy::~WebPageProxy()
{
+ m_pageGroup->removePage(this);
+
#ifndef NDEBUG
webPageProxyCounter.decrement();
#endif
@@ -663,8 +667,9 @@ void WebPageProxy::preferencesDidChange()
return;
// FIXME: It probably makes more sense to send individual preference changes.
- // However, WebKitTestRunner depends on getting a preference change notification even if nothing changed in UI process, so that overrides get removed.
- process()->send(Messages::WebPage::PreferencesDidChange(pageNamespace()->context()->preferences()->store()), m_pageID);
+ // However, WebKitTestRunner depends on getting a preference change notification
+ // even if nothing changed in UI process, so that overrides get removed.
+ process()->send(Messages::WebPage::PreferencesDidChange(pageGroup()->preferences()->store()), m_pageID);
}
#if ENABLE(TILED_BACKING_STORE)
@@ -1496,8 +1501,8 @@ WebPageCreationParameters WebPageProxy::creationParameters(const IntSize& size)
{
WebPageCreationParameters parameters;
parameters.viewSize = size;
- parameters.store = pageNamespace()->context()->preferences()->store();
parameters.drawingAreaInfo = m_drawingArea->info();
+ parameters.store = m_pageGroup->preferences()->store();
parameters.pageGroupData = m_pageGroup->data();
#if PLATFORM(WIN)
diff --git a/WebKit2/UIProcess/WebPreferences.cpp b/WebKit2/UIProcess/WebPreferences.cpp
index f02c860..363bc31 100644
--- a/WebKit2/UIProcess/WebPreferences.cpp
+++ b/WebKit2/UIProcess/WebPreferences.cpp
@@ -25,23 +25,13 @@
#include "WebPreferences.h"
-#include "WebContext.h"
+#include "WebPageGroup.h"
namespace WebKit {
-WebPreferences* WebPreferences::shared()
-{
- static WebPreferences* sharedPreferences = WebPreferences::create().leakRef();
- return sharedPreferences;
-}
-
WebPreferences::WebPreferences()
{
-}
-
-WebPreferences::WebPreferences(WebPreferences* preferences)
- : m_store(preferences->m_store)
-{
+ platformInitializeStore();
}
WebPreferences::WebPreferences(const String& identifier)
@@ -54,19 +44,19 @@ WebPreferences::~WebPreferences()
{
}
-void WebPreferences::addContext(WebContext* context)
+void WebPreferences::addPageGroup(WebPageGroup* pageGroup)
{
- m_contexts.add(context);
+ m_pageGroups.add(pageGroup);
}
-void WebPreferences::removeContext(WebContext* context)
+void WebPreferences::removePageGroup(WebPageGroup* pageGroup)
{
- m_contexts.remove(context);
+ m_pageGroups.remove(pageGroup);
}
void WebPreferences::update()
{
- for (HashSet<WebContext*>::iterator it = m_contexts.begin(), end = m_contexts.end(); it != end; ++it)
+ for (HashSet<WebPageGroup*>::iterator it = m_pageGroups.begin(), end = m_pageGroups.end(); it != end; ++it)
(*it)->preferencesDidChange();
}
diff --git a/WebKit2/UIProcess/WebPreferences.h b/WebKit2/UIProcess/WebPreferences.h
index 5deb382..25dd741 100644
--- a/WebKit2/UIProcess/WebPreferences.h
+++ b/WebKit2/UIProcess/WebPreferences.h
@@ -39,31 +39,28 @@
namespace WebKit {
-class WebContext;
+class WebPageGroup;
class WebPreferences : public APIObject {
public:
static const Type APIType = TypePreferences;
- static WebPreferences* shared();
-
static PassRefPtr<WebPreferences> create()
{
return adoptRef(new WebPreferences);
}
- static PassRefPtr<WebPreferences> copy(WebPreferences* preferences)
+ static PassRefPtr<WebPreferences> create(const String& identifier)
{
- return adoptRef(new WebPreferences(preferences));
+ return adoptRef(new WebPreferences(identifier));
}
virtual ~WebPreferences();
- void addContext(WebContext*);
- void removeContext(WebContext*);
+ void addPageGroup(WebPageGroup*);
+ void removePageGroup(WebPageGroup*);
const WebPreferencesStore& store() const { return m_store; }
-
#define DECLARE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
void set##KeyUpper(const Type& value); \
Type KeyLower() const; \
@@ -74,7 +71,6 @@ public:
private:
WebPreferences();
- WebPreferences(WebPreferences*);
WebPreferences(const String& identifier);
void platformInitializeStore();
@@ -90,7 +86,7 @@ private:
void platformUpdateBoolValueForKey(const String& key, bool value);
void platformUpdateUInt32ValueForKey(const String& key, uint32_t value);
- HashSet<WebContext*> m_contexts;
+ HashSet<WebPageGroup*> m_pageGroups;
WebPreferencesStore m_store;
String m_identifier;
};
diff --git a/WebKit2/UIProcess/mac/WebPreferencesMac.mm b/WebKit2/UIProcess/mac/WebPreferencesMac.mm
index 92d87fd..1a91af3 100644
--- a/WebKit2/UIProcess/mac/WebPreferencesMac.mm
+++ b/WebKit2/UIProcess/mac/WebPreferencesMac.mm
@@ -32,7 +32,7 @@ namespace WebKit {
static inline NSString* makeKey(const String& identifier, const String& baseKey)
{
- return nsStringFromWebCoreString(makeString(identifier, baseKey));
+ return nsStringFromWebCoreString(makeString(identifier, ".WebKit2", baseKey));
}
static void setStringValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 09194b2..607709c 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,23 @@
+2010-12-02 Sam Weinig <sam at webkit.org>
+
+ Reviewed by Anders Carlsson.
+
+ WebKit2 Preferences should be held off the PageGroup, not the Context
+ https://bugs.webkit.org/show_bug.cgi?id=50414
+
+ Update for API changes.
+
+ * WebKitTestRunner/PlatformWebView.h:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::createOtherPage):
+ (WTR::TestController::initialize):
+ (WTR::TestController::resetStateToConsistentValues):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+ (WTR::PlatformWebView::PlatformWebView):
+ * WebKitTestRunner/win/PlatformWebViewWin.cpp:
+ (WTR::PlatformWebView::PlatformWebView):
+
2010-12-02 Dirk Pranke <dpranke at chromium.org>
Reviewed by Tony Chang.
diff --git a/WebKitTools/WebKitTestRunner/PlatformWebView.h b/WebKitTools/WebKitTestRunner/PlatformWebView.h
index 72de868..abdf96e 100644
--- a/WebKitTools/WebKitTestRunner/PlatformWebView.h
+++ b/WebKitTools/WebKitTestRunner/PlatformWebView.h
@@ -52,7 +52,7 @@ namespace WTR {
class PlatformWebView {
public:
- PlatformWebView(WKPageNamespaceRef);
+ PlatformWebView(WKPageNamespaceRef, WKPageGroupRef);
~PlatformWebView();
WKPageRef page();
diff --git a/WebKitTools/WebKitTestRunner/TestController.cpp b/WebKitTools/WebKitTestRunner/TestController.cpp
index 3ac97e2..0c49346 100644
--- a/WebKitTools/WebKitTestRunner/TestController.cpp
+++ b/WebKitTools/WebKitTestRunner/TestController.cpp
@@ -106,7 +106,7 @@ static void closeOtherPage(WKPageRef page, const void* clientInfo)
static WKPageRef createOtherPage(WKPageRef oldPage, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*)
{
- PlatformWebView* view = new PlatformWebView(WKPageGetPageNamespace(oldPage));
+ PlatformWebView* view = new PlatformWebView(WKPageGetPageNamespace(oldPage), WKPageGetPageGroup(oldPage));
WKPageRef newPage = view->page();
view->resizeTo(800, 600);
@@ -194,6 +194,9 @@ void TestController::initialize(int argc, const char* argv[])
initializeInjectedBundlePath();
initializeTestPluginDirectory();
+ WKRetainPtr<WKStringRef> pageGroupIdentifier(AdoptWK, WKStringCreateWithUTF8CString("WebKitTestRunnerPageGroup"));
+ m_pageGroup.adopt(WKPageGroupCreateWithIdentifier(pageGroupIdentifier.get()));
+
m_context.adopt(WKContextCreateWithInjectedBundlePath(injectedBundlePath()));
platformInitializeContext();
@@ -208,7 +211,7 @@ void TestController::initialize(int argc, const char* argv[])
_WKContextSetAdditionalPluginsDirectory(m_context.get(), testPluginDirectory());
m_pageNamespace.adopt(WKPageNamespaceCreate(m_context.get()));
- m_mainWebView = adoptPtr(new PlatformWebView(m_pageNamespace.get()));
+ m_mainWebView = adoptPtr(new PlatformWebView(m_pageNamespace.get(), m_pageGroup.get()));
WKPageUIClient pageUIClient = {
0,
@@ -272,7 +275,7 @@ bool TestController::resetStateToConsistentValues()
// FIXME: This function should also ensure that there is only one page open.
// Reset preferences
- WKPreferencesRef preferences = WKContextGetPreferences(m_context.get());
+ WKPreferencesRef preferences = WKPageGroupGetPreferences(m_pageGroup.get());
WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
WKPreferencesSetXSSAuditorEnabled(preferences, false);
diff --git a/WebKitTools/WebKitTestRunner/TestController.h b/WebKitTools/WebKitTestRunner/TestController.h
index 4c05bf4..91ef404 100644
--- a/WebKitTools/WebKitTestRunner/TestController.h
+++ b/WebKitTools/WebKitTestRunner/TestController.h
@@ -97,6 +97,7 @@ private:
OwnPtr<PlatformWebView> m_mainWebView;
WKRetainPtr<WKContextRef> m_context;
WKRetainPtr<WKPageNamespaceRef> m_pageNamespace;
+ WKRetainPtr<WKPageGroupRef> m_pageGroup;
enum State {
Initial,
diff --git a/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm b/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
index 6080c1f..c2ba87f 100644
--- a/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
+++ b/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
@@ -27,10 +27,10 @@
namespace WTR {
-PlatformWebView::PlatformWebView(WKPageNamespaceRef namespaceRef)
+PlatformWebView::PlatformWebView(WKPageNamespaceRef namespaceRef, WKPageGroupRef pageGroupRef)
{
NSRect rect = NSMakeRect(0, 0, 800, 600);
- m_view = [[WKView alloc] initWithFrame:rect pageNamespaceRef:namespaceRef];
+ m_view = [[WKView alloc] initWithFrame:rect pageNamespaceRef:namespaceRef pageGroupRef:pageGroupRef];
NSRect windowRect = NSOffsetRect(rect, -10000, [[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
m_window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
diff --git a/WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp b/WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp
index 7334d4a..236ab4b 100644
--- a/WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp
+++ b/WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp
@@ -47,13 +47,13 @@ static void registerWindowClass()
RegisterClassExW(&wndClass);
}
-PlatformWebView::PlatformWebView(WKPageNamespaceRef namespaceRef)
+PlatformWebView::PlatformWebView(WKPageNamespaceRef namespaceRef, WKPageGroupRef pageGroupRef)
{
registerWindowClass();
RECT viewRect = {0, 0, 800, 600};
m_window = CreateWindowExW(0, hostWindowClassName, L"WebKitTestRunner", WS_OVERLAPPEDWINDOW, 0 /*XOFFSET*/, 0 /*YOFFSET*/, viewRect.right, viewRect.bottom, 0, 0, GetModuleHandle(0), 0);
- m_view = WKViewCreate(viewRect, namespaceRef, 0 /*pageGroupRef*/, m_window);
+ m_view = WKViewCreate(viewRect, namespaceRef, pageGroupRef, m_window);
}
PlatformWebView::~PlatformWebView()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list