Skip to content
Permalink
Browse files
Begin work on making preferences per page instead of per page group
https://bugs.webkit.org/show_bug.cgi?id=128349

Reviewed by Andreas Kling.

* UIProcess/API/C/WKPageGroup.cpp:
(WKPageGroupGetPreferences):
* UIProcess/API/C/mac/WKPagePrivateMac.cpp:
(WKPageIsURLKnownHSTSHost):
* UIProcess/API/mac/WKView.mm:
(-[WKView _preferencesDidChange]):
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::createWebPage):
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorPageGroups::createInspectorPageGroup):
(WebKit::WebInspectorProxy::attach):
(WebKit::WebInspectorProxy::detach):
(WebKit::WebInspectorProxy::setAttachedWindowHeight):
(WebKit::WebInspectorProxy::setAttachedWindowWidth):
(WebKit::WebInspectorProxy::createInspectorPage):
(WebKit::WebInspectorProxy::shouldOpenAttached):
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::preferences):
* UIProcess/WebPageGroup.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::create):
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::isProcessSuppressible):
(WebKit::WebPageProxy::canShowMIMEType):
(WebKit::WebPageProxy::preferencesDidChange):
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::preferences):
(WebKit::WebPageProxy::setPreferences):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::createWebPage):
* UIProcess/mac/ViewGestureController.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::createInspectorWindow):
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
(WebKit::WebInspectorProxy::windowFrameDidChange):
(WebKit::WebInspectorProxy::platformAttach):

Canonical link: https://commits.webkit.org/146373@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Feb 7, 2014
1 parent 6680a03 commit bf2bf1748d4bab7838a8bd01c02bc7f9c75be59f
@@ -1,3 +1,50 @@
2014-02-06 Anders Carlsson <andersca@apple.com>

Begin work on making preferences per page instead of per page group
https://bugs.webkit.org/show_bug.cgi?id=128349

Reviewed by Andreas Kling.

* UIProcess/API/C/WKPageGroup.cpp:
(WKPageGroupGetPreferences):
* UIProcess/API/C/mac/WKPagePrivateMac.cpp:
(WKPageIsURLKnownHSTSHost):
* UIProcess/API/mac/WKView.mm:
(-[WKView _preferencesDidChange]):
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::createWebPage):
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorPageGroups::createInspectorPageGroup):
(WebKit::WebInspectorProxy::attach):
(WebKit::WebInspectorProxy::detach):
(WebKit::WebInspectorProxy::setAttachedWindowHeight):
(WebKit::WebInspectorProxy::setAttachedWindowWidth):
(WebKit::WebInspectorProxy::createInspectorPage):
(WebKit::WebInspectorProxy::shouldOpenAttached):
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::preferences):
* UIProcess/WebPageGroup.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::create):
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::isProcessSuppressible):
(WebKit::WebPageProxy::canShowMIMEType):
(WebKit::WebPageProxy::preferencesDidChange):
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::preferences):
(WebKit::WebPageProxy::setPreferences):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::createWebPage):
* UIProcess/mac/ViewGestureController.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::createInspectorWindow):
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
(WebKit::WebInspectorProxy::windowFrameDidChange):
(WebKit::WebInspectorProxy::platformAttach):

2014-02-06 Gavin Barraclough <barraclough@apple.com>

Remove ChildProcess::m_activeTasks
@@ -55,7 +55,7 @@ void WKPageGroupSetPreferences(WKPageGroupRef pageGroupRef, WKPreferencesRef pre

WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroupRef)
{
return toAPI(toImpl(pageGroupRef)->preferences());
return toAPI(&toImpl(pageGroupRef)->preferences());
}

void WKPageGroupAddUserStyleSheet(WKPageGroupRef pageGroupRef, WKStringRef sourceRef, WKURLRef baseURL, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames injectedFrames)
@@ -42,7 +42,7 @@ pid_t WKPageGetProcessIdentifier(WKPageRef pageRef)
bool WKPageIsURLKnownHSTSHost(WKPageRef page, WKURLRef url)
{
WebPageProxy* webPageProxy = toImpl(page);
bool privateBrowsingEnabled = webPageProxy->pageGroup().preferences()->privateBrowsingEnabled();
bool privateBrowsingEnabled = webPageProxy->pageGroup().preferences().privateBrowsingEnabled();

return webPageProxy->process().context().isURLKnownHSTSHost(toImpl(url)->string(), privateBrowsingEnabled);
}
@@ -2241,7 +2241,7 @@ - (void)_didRelaunchProcess

- (void)_preferencesDidChange
{
BOOL needsViewFrameInWindowCoordinates = _data->_page->pageGroup().preferences()->pluginsEnabled();
BOOL needsViewFrameInWindowCoordinates = _data->_page->preferences().pluginsEnabled();

if (!!needsViewFrameInWindowCoordinates == !!_data->_needsViewFrameInWindowCoordinates)
return;
@@ -2947,7 +2947,7 @@ - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupR

_data->_intrinsicContentSize = NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);

_data->_needsViewFrameInWindowCoordinates = _data->_page->pageGroup().preferences()->pluginsEnabled();
_data->_needsViewFrameInWindowCoordinates = _data->_page->preferences().pluginsEnabled();

[self _registerDraggedTypes];

@@ -785,7 +785,7 @@ PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient& pageClient, WebPa
PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient& pageClient, WebPageGroup* pageGroup, WebPageProxy* relatedPage)
{
WebPageGroup* group = pageGroup ? pageGroup : &m_defaultPageGroup.get();
return createWebPage(pageClient, group, group->preferences()->privateBrowsingEnabled() ? API::Session::legacyPrivateSession() : API::Session::defaultSession(), relatedPage);
return createWebPage(pageClient, group, group->preferences().privateBrowsingEnabled() ? API::Session::legacyPrivateSession() : API::Session::defaultSession(), relatedPage);
}

DownloadProxy* WebContext::download(WebPageProxy* initiatingPage, const ResourceRequest& request)
@@ -105,11 +105,11 @@ class WebInspectorPageGroups {

#ifndef NDEBUG
// Allow developers to inspect the Web Inspector in debug builds.
pageGroup->preferences()->setDeveloperExtrasEnabled(true);
pageGroup->preferences()->setLogsPageMessagesToSystemConsoleEnabled(true);
pageGroup->preferences().setDeveloperExtrasEnabled(true);
pageGroup->preferences().setLogsPageMessagesToSystemConsoleEnabled(true);
#endif

pageGroup->preferences()->setApplicationChromeModeEnabled(true);
pageGroup->preferences().setApplicationChromeModeEnabled(true);

return pageGroup.release();
}
@@ -270,10 +270,10 @@ void WebInspectorProxy::attach(AttachmentSide side)
m_isAttached = true;
m_attachmentSide = side;

inspectorPageGroup()->preferences()->setInspectorAttachmentSide(side);
inspectorPageGroup()->preferences().setInspectorAttachmentSide(side);

if (m_isVisible)
inspectorPageGroup()->preferences()->setInspectorStartsAttached(true);
inspectorPageGroup()->preferences().setInspectorStartsAttached(true);

switch (m_attachmentSide) {
case AttachmentSideBottom:
@@ -296,7 +296,7 @@ void WebInspectorProxy::detach()
m_isAttached = false;

if (m_isVisible)
inspectorPageGroup()->preferences()->setInspectorStartsAttached(false);
inspectorPageGroup()->preferences().setInspectorStartsAttached(false);

m_page->process().send(Messages::WebInspector::Detached(), m_page->pageID());

@@ -305,13 +305,13 @@ void WebInspectorProxy::detach()

void WebInspectorProxy::setAttachedWindowHeight(unsigned height)
{
inspectorPageGroup()->preferences()->setInspectorAttachedHeight(height);
inspectorPageGroup()->preferences().setInspectorAttachedHeight(height);
platformSetAttachedWindowHeight(height);
}

void WebInspectorProxy::setAttachedWindowWidth(unsigned width)
{
inspectorPageGroup()->preferences()->setInspectorAttachedWidth(width);
inspectorPageGroup()->preferences().setInspectorAttachedWidth(width);
platformSetAttachedWindowWidth(width);
}

@@ -429,7 +429,7 @@ void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCr
return;

m_isAttached = shouldOpenAttached();
m_attachmentSide = static_cast<AttachmentSide>(inspectorPageGroup()->preferences()->inspectorAttachmentSide());
m_attachmentSide = static_cast<AttachmentSide>(inspectorPageGroup()->preferences().inspectorAttachmentSide());

WebPageProxy* inspectorPage = platformCreateInspectorPage();
ASSERT(inspectorPage);
@@ -563,7 +563,7 @@ bool WebInspectorProxy::canAttach()

bool WebInspectorProxy::shouldOpenAttached()
{
return inspectorPageGroup()->preferences()->inspectorStartsAttached() && canAttach();
return inspectorPageGroup()->preferences().inspectorStartsAttached() && canAttach();
}

#if ENABLE(INSPECTOR_SERVER)
@@ -114,7 +114,7 @@ void WebPageGroup::setPreferences(WebPreferences* preferences)
}
}

WebPreferences* WebPageGroup::preferences() const
WebPreferences& WebPageGroup::preferences() const
{
if (!m_preferences) {
if (!m_data.identifer.isNull())
@@ -123,7 +123,8 @@ WebPreferences* WebPageGroup::preferences() const
m_preferences = WebPreferences::create();
m_preferences->addPageGroup(const_cast<WebPageGroup*>(this));
}
return m_preferences.get();

return *m_preferences;
}

void WebPageGroup::preferencesDidChange()
@@ -56,7 +56,7 @@ class WebPageGroup : public API::ObjectImpl<API::Object::Type::PageGroup> {
const WebPageGroupData& data() { return m_data; }

void setPreferences(WebPreferences*);
WebPreferences* preferences() const;
WebPreferences& preferences() const;
void preferencesDidChange();

void addUserStyleSheet(const String& source, const String& baseURL, API::Array* whitelist, API::Array* blacklist, WebCore::UserContentInjectedFrames, WebCore::UserStyleLevel);
@@ -241,18 +241,19 @@ static const char* webKeyboardEventTypeString(WebEvent::Type type)
}
#endif // !LOG_DISABLED

PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient& pageClient, WebProcessProxy& process, WebPageGroup& pageGroup, API::Session& session, uint64_t pageID)
PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient& pageClient, WebProcessProxy& process, WebPageGroup& pageGroup, WebPreferences& preferences, API::Session& session, uint64_t pageID)
{
return adoptRef(new WebPageProxy(pageClient, process, pageGroup, session, pageID));
return adoptRef(new WebPageProxy(pageClient, process, pageGroup, preferences, session, pageID));
}

WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, WebPageGroup& pageGroup, API::Session& session, uint64_t pageID)
WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, WebPageGroup& pageGroup, WebPreferences& preferences, API::Session& session, uint64_t pageID)
: m_pageClient(pageClient)
, m_loaderClient(std::make_unique<API::LoaderClient>())
, m_policyClient(std::make_unique<API::PolicyClient>())
, m_uiClient(std::make_unique<API::UIClient>())
, m_process(process)
, m_pageGroup(pageGroup)
, m_preferences(preferences)
, m_mainFrame(nullptr)
, m_userAgent(standardUserAgent())
, m_geolocationPermissionRequestManager(*this)
@@ -552,7 +553,7 @@ void WebPageProxy::initializeWebPage()

bool WebPageProxy::isProcessSuppressible() const
{
return (m_viewState & ViewState::IsVisuallyIdle) && m_pageGroup->preferences()->pageVisibilityBasedProcessSuppressionEnabled();
return (m_viewState & ViewState::IsVisuallyIdle) && m_preferences->pageVisibilityBasedProcessSuppressionEnabled();
}

void WebPageProxy::close()
@@ -855,7 +856,7 @@ bool WebPageProxy::canShowMIMEType(const String& mimeType)
#if ENABLE(NETSCAPE_PLUGIN_API)
String newMimeType = mimeType;
PluginModuleInfo plugin = m_process->context().pluginInfoStore().findPlugin(newMimeType, URL());
if (!plugin.path.isNull() && m_pageGroup->preferences()->pluginsEnabled())
if (!plugin.path.isNull() && m_preferences->pluginsEnabled())
return true;
#endif // ENABLE(NETSCAPE_PLUGIN_API)

@@ -2064,7 +2065,7 @@ void WebPageProxy::preferencesDidChange()
// even if nothing changed in UI process, so that overrides get removed.

// Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
m_process->send(Messages::WebPage::PreferencesDidChange(pageGroup().preferences()->store()), m_pageID, m_isPerformingDOMPrintOperation ? IPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
m_process->send(Messages::WebPage::PreferencesDidChange(m_preferences->store()), m_pageID, m_isPerformingDOMPrintOperation ? IPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
}

void WebPageProxy::didCreateMainFrame(uint64_t frameID)
@@ -3908,7 +3909,7 @@ WebPageCreationParameters WebPageProxy::creationParameters()
parameters.viewSize = m_pageClient.viewSize();
parameters.viewState = m_viewState;
parameters.drawingAreaType = m_drawingArea->type();
parameters.store = m_pageGroup->preferences()->store();
parameters.store = m_preferences->store();
parameters.pageGroupData = m_pageGroup->data();
parameters.drawsBackground = m_drawsBackground;
parameters.drawsTransparentBackground = m_drawsTransparentBackground;
@@ -54,6 +54,7 @@
#include "WebHitTestResult.h"
#include "WebPageContextMenuClient.h"
#include "WebPageCreationParameters.h"
#include "WebPreferences.h"
#include <WebCore/AlternativeTextClient.h> // FIXME: Needed by WebPageProxyMessages.h for DICTATION_ALTERNATIVES.
#include "WebPageProxyMessages.h"
#include "WebPopupMenuProxy.h"
@@ -330,7 +331,7 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
, public IPC::MessageSender {
public:

static PassRefPtr<WebPageProxy> create(PageClient&, WebProcessProxy&, WebPageGroup&, API::Session&, uint64_t pageID);
static PassRefPtr<WebPageProxy> create(PageClient&, WebProcessProxy&, WebPageGroup&, WebPreferences&, API::Session&, uint64_t pageID);
virtual ~WebPageProxy();

void setSession(API::Session&);
@@ -723,6 +724,9 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
WebProcessProxy& process() { return m_process.get(); }
PlatformProcessIdentifier processIdentifier() const;

WebPreferences& preferences() { return m_preferences.get(); }
void setPreferences(WebPreferences& preferences) { m_preferences = preferences; }

WebPageGroup& pageGroup() { return m_pageGroup.get(); }

bool isValid() const;
@@ -872,7 +876,7 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
#endif

private:
WebPageProxy(PageClient&, WebProcessProxy&, WebPageGroup&, API::Session&, uint64_t pageID);
WebPageProxy(PageClient&, WebProcessProxy&, WebPageGroup&, WebPreferences&, API::Session&, uint64_t pageID);
void platformInitialize();

void updateViewState(WebCore::ViewState::Flags flagsToUpdate = WebCore::ViewState::AllFlags);
@@ -1193,6 +1197,8 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>

Ref<WebProcessProxy> m_process;
Ref<WebPageGroup> m_pageGroup;
Ref<WebPreferences> m_preferences;

RefPtr<WebFrameProxy> m_mainFrame;
RefPtr<WebFrameProxy> m_focusedFrame;
RefPtr<WebFrameProxy> m_frameSetLargestFrame;
@@ -39,6 +39,7 @@
#include "WebContext.h"
#include "WebNavigationDataStore.h"
#include "WebNotificationManagerProxy.h"
#include "WebPageGroup.h"
#include "WebPageProxy.h"
#include "WebPluginSiteDataManager.h"
#include "WebProcessMessages.h"
@@ -170,7 +171,7 @@ WebPageProxy* WebProcessProxy::webPage(uint64_t pageID)
PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, WebPageGroup& pageGroup, API::Session& session)
{
uint64_t pageID = generatePageID();
RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, *this, pageGroup, session, pageID);
RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, *this, pageGroup, pageGroup.preferences(), session, pageID);
m_pageMap.set(pageID, webPage.get());
globalPageMap().set(pageID, webPage.get());
#if PLATFORM(MAC)
@@ -402,7 +402,7 @@ static float maximumRectangleComponentDelta(FloatRect a, FloatRect b)
[m_swipeSnapshotLayer setName:@"Gesture Swipe Snapshot Layer"];
[m_swipeSnapshotLayer web_disableAllActions];

if (m_webPageProxy.pageGroup().preferences()->viewGestureDebuggingEnabled()) {
if (m_webPageProxy.preferences().viewGestureDebuggingEnabled()) {
CAFilter* filter = [CAFilter filterWithType:kCAFilterGaussianBlur];
[filter setValue:[NSNumber numberWithFloat:3] forKey:@"inputRadius"];
[m_swipeSnapshotLayer setFilters:@[filter]];
@@ -285,7 +285,7 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters
NSRect windowFrame = NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight);

// Restore the saved window frame, if there was one.
NSString *savedWindowFrameString = page()->pageGroup().preferences()->inspectorWindowFrame();
NSString *savedWindowFrameString = page()->pageGroup().preferences().inspectorWindowFrame();
NSRect savedWindowFrame = NSRectFromString(savedWindowFrameString);
if (!NSIsEmptyRect(savedWindowFrame))
windowFrame = savedWindowFrame;
@@ -375,16 +375,16 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters

switch (m_attachmentSide) {
case AttachmentSideBottom:
initialRect = NSMakeRect(0, 0, NSWidth(inspectedViewFrame), inspectorPageGroup()->preferences()->inspectorAttachedHeight());
initialRect = NSMakeRect(0, 0, NSWidth(inspectedViewFrame), inspectorPageGroup()->preferences().inspectorAttachedHeight());
break;
case AttachmentSideRight:
initialRect = NSMakeRect(0, 0, inspectorPageGroup()->preferences()->inspectorAttachedWidth(), NSHeight(inspectedViewFrame));
initialRect = NSMakeRect(0, 0, inspectorPageGroup()->preferences().inspectorAttachedWidth(), NSHeight(inspectedViewFrame));
break;
}
} else {
initialRect = NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight);

NSString *windowFrameString = page()->pageGroup().preferences()->inspectorWindowFrame();
NSString *windowFrameString = page()->pageGroup().preferences().inspectorWindowFrame();
NSRect windowFrame = NSRectFromString(windowFrameString);
if (!NSIsEmptyRect(windowFrame))
initialRect = [NSWindow contentRectForFrameRect:windowFrame styleMask:windowStyleMask];
@@ -606,7 +606,7 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters
return;

NSString *frameString = NSStringFromRect([m_inspectorWindow frame]);
page()->pageGroup().preferences()->setInspectorWindowFrame(frameString);
page()->pageGroup().preferences().setInspectorWindowFrame(frameString);
}

void WebInspectorProxy::inspectedViewFrameDidChange(CGFloat currentDimension)
@@ -689,10 +689,10 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters

switch (m_attachmentSide) {
case AttachmentSideBottom:
currentDimension = inspectorPageGroup()->preferences()->inspectorAttachedHeight();
currentDimension = inspectorPageGroup()->preferences().inspectorAttachedHeight();
break;
case AttachmentSideRight:
currentDimension = inspectorPageGroup()->preferences()->inspectorAttachedWidth();
currentDimension = inspectorPageGroup()->preferences().inspectorAttachedWidth();
break;
}

0 comments on commit bf2bf17

Please sign in to comment.