Commit 2e7006b1 authored by andersca@apple.com's avatar andersca@apple.com

Give each page a UserContentController

https://bugs.webkit.org/show_bug.cgi?id=127315

Reviewed by Andreas Kling.

Add a UserContentController object to PageGroup and have the page group set it on any
pages that are added to the page group.

This is another step towards moving handling of user content away from PageGroup and make it
possible for each page to have different user content.

* page/Page.cpp:
(WebCore::Page::~Page):
(WebCore::Page::setUserContentController):
* page/Page.h:
(WebCore::Page::userContentController):
* page/PageGroup.cpp:
(WebCore::PageGroup::PageGroup):
(WebCore::PageGroup::addPage):
(WebCore::PageGroup::removePage):
* page/PageGroup.h:
* page/UserContentController.cpp:
(WebCore::UserContentController::addPage):
(WebCore::UserContentController::removePage):
* page/UserContentController.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 631001b6
2014-01-20 Anders Carlsson <andersca@apple.com>
Give each page a UserContentController
https://bugs.webkit.org/show_bug.cgi?id=127315
Reviewed by Andreas Kling.
Add a UserContentController object to PageGroup and have the page group set it on any
pages that are added to the page group.
This is another step towards moving handling of user content away from PageGroup and make it
possible for each page to have different user content.
* page/Page.cpp:
(WebCore::Page::~Page):
(WebCore::Page::setUserContentController):
* page/Page.h:
(WebCore::Page::userContentController):
* page/PageGroup.cpp:
(WebCore::PageGroup::PageGroup):
(WebCore::PageGroup::addPage):
(WebCore::PageGroup::removePage):
* page/PageGroup.h:
* page/UserContentController.cpp:
(WebCore::UserContentController::addPage):
(WebCore::UserContentController::removePage):
* page/UserContentController.h:
2014-01-20 Jeremy Jones <jeremyj@apple.com>
Add AVKit fullscreen video interface.
......@@ -82,6 +82,7 @@
#include "StyleResolver.h"
#include "SubframeLoader.h"
#include "TextResourceDecoder.h"
#include "UserContentController.h"
#include "VisitedLinkState.h"
#include "VoidCallback.h"
#include "Widget.h"
......@@ -240,6 +241,9 @@ Page::~Page()
#ifndef NDEBUG
pageCounter.decrement();
#endif
if (m_userContentController)
m_userContentController->removePage(*this);
}
uint64_t Page::renderTreeSize() const
......@@ -1577,6 +1581,17 @@ bool Page::isAnyFrameHandlingBeforeUnloadEvent()
return m_framesHandlingBeforeUnloadEvent;
}
void Page::setUserContentController(UserContentController* userContentController)
{
if (m_userContentController)
m_userContentController->removePage(*this);
m_userContentController = userContentController;
if (m_userContentController)
m_userContentController->addPage(*this);
}
Page::PageClients::PageClients()
: alternativeTextClient(nullptr)
, chromeClient(nullptr)
......
......@@ -101,6 +101,7 @@ class ScrollableArea;
class ScrollingCoordinator;
class Settings;
class StorageNamespace;
class UserContentController;
class ValidationMessageClient;
typedef uint64_t LinkHash;
......@@ -418,6 +419,9 @@ public:
void setLastSpatialNavigationCandidateCount(unsigned count) { m_lastSpatialNavigationCandidatesCount = count; }
unsigned lastSpatialNavigationCandidateCount() const { return m_lastSpatialNavigationCandidatesCount; }
void setUserContentController(UserContentController*);
UserContentController* userContentController() { return m_userContentController.get(); }
private:
void initGroup();
......@@ -556,6 +560,8 @@ private:
unsigned m_lastSpatialNavigationCandidatesCount;
unsigned m_framesHandlingBeforeUnloadEvent;
RefPtr<UserContentController> m_userContentController;
};
inline PageGroup& Page::group()
......
......@@ -38,6 +38,7 @@
#include "SecurityOrigin.h"
#include "Settings.h"
#include "StorageNamespace.h"
#include "UserContentController.h"
#include <wtf/StdLibExtras.h>
#if ENABLE(VIDEO_TRACK)
......@@ -64,6 +65,7 @@ PageGroup::PageGroup(const String& name)
: m_name(name)
, m_visitedLinksPopulated(false)
, m_identifier(getUniqueIdentifier())
, m_userContentController(UserContentController::create())
, m_groupSettings(std::make_unique<GroupSettings>())
{
}
......@@ -169,12 +171,16 @@ void PageGroup::addPage(Page& page)
{
ASSERT(!m_pages.contains(&page));
m_pages.add(&page);
page.setUserContentController(m_userContentController.get());
}
void PageGroup::removePage(Page& page)
{
ASSERT(m_pages.contains(&page));
m_pages.remove(&page);
page.setUserContentController(nullptr);
}
bool PageGroup::isLinkVisited(LinkHash visitedLinkHash)
......
......@@ -42,6 +42,7 @@ namespace WebCore {
class Page;
class SecurityOrigin;
class StorageNamespace;
class UserContentController;
#if ENABLE(VIDEO_TRACK)
class CaptionPreferencesChangedListener;
......@@ -123,6 +124,7 @@ namespace WebCore {
RefPtr<StorageNamespace> m_localStorage;
HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageNamespace>> m_transientLocalStorageMap;
RefPtr<UserContentController> m_userContentController;
std::unique_ptr<UserScriptMap> m_userScripts;
std::unique_ptr<UserStyleSheetMap> m_userStyleSheets;
......
......@@ -26,6 +26,9 @@
#include "config.h"
#include "UserContentController.h"
#include "DOMWrapperWorld.h"
#include "UserScript.h"
namespace WebCore {
RefPtr<UserContentController> UserContentController::create()
......@@ -41,4 +44,16 @@ UserContentController::~UserContentController()
{
}
void UserContentController::addPage(Page& page)
{
ASSERT(!m_pages.contains(&page));
m_pages.add(&page);
}
void UserContentController::removePage(Page& page)
{
ASSERT(m_pages.contains(&page));
m_pages.remove(&page);
}
} // namespace WebCore
......@@ -26,18 +26,31 @@
#ifndef UserContentController_h
#define UserContentController_h
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class DOMWrapperWorld;
class Page;
class URL;
class UserScript;
class UserContentController : public RefCounted<UserContentController> {
public:
static RefPtr<UserContentController> create();
~UserContentController();
void addPage(Page&);
void removePage(Page&);
private:
UserContentController();
HashSet<Page*> m_pages;
};
} // namespace WebCore
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment