Commit e8dfefaf authored by weinig@apple.com's avatar weinig@apple.com

Convert PageGroup to using std::unique_ptr

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

Reviewed by Anders Carlsson.

* page/CaptionUserPreferences.cpp:
* page/CaptionUserPreferences.h:
* page/CaptionUserPreferencesMediaAF.cpp:
* page/CaptionUserPreferencesMediaAF.h:
* page/Frame.cpp:
* page/GroupSettings.h:
* page/Page.cpp:
* page/PageGroup.cpp:
* page/PageGroup.h:
* page/UserScriptTypes.h:
* page/UserStyleSheetTypes.h:
* workers/DedicatedWorkerGlobalScope.h:
* workers/DedicatedWorkerThread.cpp:
* workers/DedicatedWorkerThread.h:
* workers/SharedWorkerGlobalScope.cpp:
* workers/SharedWorkerGlobalScope.h:
* workers/SharedWorkerThread.cpp:
* workers/SharedWorkerThread.h:
* workers/WorkerGlobalScope.cpp:
* workers/WorkerGlobalScope.h:
* workers/WorkerThread.cpp:
* workers/WorkerThread.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 620e8573
2013-10-01 Sam Weinig <sam@webkit.org>
Convert PageGroup to using std::unique_ptr
https://bugs.webkit.org/show_bug.cgi?id=122184
Reviewed by Anders Carlsson.
* page/CaptionUserPreferences.cpp:
* page/CaptionUserPreferences.h:
* page/CaptionUserPreferencesMediaAF.cpp:
* page/CaptionUserPreferencesMediaAF.h:
* page/Frame.cpp:
* page/GroupSettings.h:
* page/Page.cpp:
* page/PageGroup.cpp:
* page/PageGroup.h:
* page/UserScriptTypes.h:
* page/UserStyleSheetTypes.h:
* workers/DedicatedWorkerGlobalScope.h:
* workers/DedicatedWorkerThread.cpp:
* workers/DedicatedWorkerThread.h:
* workers/SharedWorkerGlobalScope.cpp:
* workers/SharedWorkerGlobalScope.h:
* workers/SharedWorkerThread.cpp:
* workers/SharedWorkerThread.h:
* workers/WorkerGlobalScope.cpp:
* workers/WorkerGlobalScope.h:
* workers/WorkerThread.cpp:
* workers/WorkerThread.h:
2013-10-01 Tim Horton <timothy_horton@apple.com> 2013-10-01 Tim Horton <timothy_horton@apple.com>
Tiled drawing GraphicsLayer tree dumps should match non-tiled more closely Tiled drawing GraphicsLayer tree dumps should match non-tiled more closely
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
namespace WebCore { namespace WebCore {
CaptionUserPreferences::CaptionUserPreferences(PageGroup* group) CaptionUserPreferences::CaptionUserPreferences(PageGroup& group)
: m_pageGroup(group) : m_pageGroup(group)
, m_displayMode(ForcedOnly) , m_displayMode(ForcedOnly)
, m_timer(this, &CaptionUserPreferences::timerFired) , m_timer(this, &CaptionUserPreferences::timerFired)
...@@ -79,7 +79,7 @@ void CaptionUserPreferences::setCaptionDisplayMode(CaptionUserPreferences::Capti ...@@ -79,7 +79,7 @@ void CaptionUserPreferences::setCaptionDisplayMode(CaptionUserPreferences::Capti
bool CaptionUserPreferences::userPrefersCaptions() const bool CaptionUserPreferences::userPrefersCaptions() const
{ {
Page* page = *(pageGroup()->pages().begin()); Page* page = *(m_pageGroup.pages().begin());
if (!page) if (!page)
return false; return false;
...@@ -88,7 +88,7 @@ bool CaptionUserPreferences::userPrefersCaptions() const ...@@ -88,7 +88,7 @@ bool CaptionUserPreferences::userPrefersCaptions() const
void CaptionUserPreferences::setUserPrefersCaptions(bool preference) void CaptionUserPreferences::setUserPrefersCaptions(bool preference)
{ {
Page* page = *(pageGroup()->pages().begin()); Page* page = *(m_pageGroup.pages().begin());
if (!page) if (!page)
return; return;
...@@ -98,7 +98,7 @@ void CaptionUserPreferences::setUserPrefersCaptions(bool preference) ...@@ -98,7 +98,7 @@ void CaptionUserPreferences::setUserPrefersCaptions(bool preference)
bool CaptionUserPreferences::userPrefersSubtitles() const bool CaptionUserPreferences::userPrefersSubtitles() const
{ {
Page* page = *(pageGroup()->pages().begin()); Page* page = *(pageGroup().pages().begin());
if (!page) if (!page)
return false; return false;
...@@ -107,7 +107,7 @@ bool CaptionUserPreferences::userPrefersSubtitles() const ...@@ -107,7 +107,7 @@ bool CaptionUserPreferences::userPrefersSubtitles() const
void CaptionUserPreferences::setUserPrefersSubtitles(bool preference) void CaptionUserPreferences::setUserPrefersSubtitles(bool preference)
{ {
Page* page = *(pageGroup()->pages().begin()); Page* page = *(m_pageGroup.pages().begin());
if (!page) if (!page)
return; return;
...@@ -117,7 +117,7 @@ void CaptionUserPreferences::setUserPrefersSubtitles(bool preference) ...@@ -117,7 +117,7 @@ void CaptionUserPreferences::setUserPrefersSubtitles(bool preference)
bool CaptionUserPreferences::userPrefersTextDescriptions() const bool CaptionUserPreferences::userPrefersTextDescriptions() const
{ {
Page* page = *(pageGroup()->pages().begin()); Page* page = *(m_pageGroup.pages().begin());
if (!page) if (!page)
return false; return false;
...@@ -126,7 +126,7 @@ bool CaptionUserPreferences::userPrefersTextDescriptions() const ...@@ -126,7 +126,7 @@ bool CaptionUserPreferences::userPrefersTextDescriptions() const
void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference) void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference)
{ {
Page* page = *(pageGroup()->pages().begin()); Page* page = *(m_pageGroup.pages().begin());
if (!page) if (!page)
return; return;
...@@ -136,7 +136,7 @@ void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference) ...@@ -136,7 +136,7 @@ void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference)
void CaptionUserPreferences::captionPreferencesChanged() void CaptionUserPreferences::captionPreferencesChanged()
{ {
m_pageGroup->captionPreferencesChanged(); m_pageGroup.captionPreferencesChanged();
} }
Vector<String> CaptionUserPreferences::preferredLanguages() const Vector<String> CaptionUserPreferences::preferredLanguages() const
...@@ -238,13 +238,13 @@ void CaptionUserPreferences::updateCaptionStyleSheetOveride() ...@@ -238,13 +238,13 @@ void CaptionUserPreferences::updateCaptionStyleSheetOveride()
// Identify our override style sheet with a unique URL - a new scheme and a UUID. // Identify our override style sheet with a unique URL - a new scheme and a UUID.
DEFINE_STATIC_LOCAL(URL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23")); DEFINE_STATIC_LOCAL(URL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"));
pageGroup()->removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL); m_pageGroup.removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL);
String captionsOverrideStyleSheet = captionsStyleSheetOverride(); String captionsOverrideStyleSheet = captionsStyleSheetOverride();
if (captionsOverrideStyleSheet.isEmpty()) if (captionsOverrideStyleSheet.isEmpty())
return; return;
pageGroup()->addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, Vector<String>(), m_pageGroup.addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, Vector<String>(),
Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments); Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments);
} }
......
...@@ -43,7 +43,7 @@ class TextTrackList; ...@@ -43,7 +43,7 @@ class TextTrackList;
class CaptionUserPreferences { class CaptionUserPreferences {
public: public:
static PassOwnPtr<CaptionUserPreferences> create(PageGroup* group) { return adoptPtr(new CaptionUserPreferences(group)); } CaptionUserPreferences(PageGroup&);
virtual ~CaptionUserPreferences(); virtual ~CaptionUserPreferences();
enum CaptionDisplayMode { enum CaptionDisplayMode {
...@@ -87,17 +87,16 @@ public: ...@@ -87,17 +87,16 @@ public:
virtual bool testingMode() const { return m_testingMode; } virtual bool testingMode() const { return m_testingMode; }
virtual void setTestingMode(bool override) { m_testingMode = override; } virtual void setTestingMode(bool override) { m_testingMode = override; }
PageGroup* pageGroup() const { return m_pageGroup; } PageGroup& pageGroup() const { return m_pageGroup; }
protected: protected:
CaptionUserPreferences(PageGroup*);
void updateCaptionStyleSheetOveride(); void updateCaptionStyleSheetOveride();
private: private:
void timerFired(Timer<CaptionUserPreferences>*); void timerFired(Timer<CaptionUserPreferences>*);
void notify(); void notify();
PageGroup* m_pageGroup; PageGroup& m_pageGroup;
CaptionDisplayMode m_displayMode; CaptionDisplayMode m_displayMode;
Timer<CaptionUserPreferences> m_timer; Timer<CaptionUserPreferences> m_timer;
String m_userPreferredLanguage; String m_userPreferredLanguage;
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "LocalizedStrings.h" #include "LocalizedStrings.h"
#include "Logging.h" #include "Logging.h"
#include "MediaControlElements.h" #include "MediaControlElements.h"
#include "PageGroup.h"
#include "SoftLinking.h" #include "SoftLinking.h"
#include "TextTrackCue.h" #include "TextTrackCue.h"
#include "TextTrackList.h" #include "TextTrackList.h"
...@@ -141,7 +140,7 @@ static void userCaptionPreferencesChangedNotificationCallback(CFNotificationCent ...@@ -141,7 +140,7 @@ static void userCaptionPreferencesChangedNotificationCallback(CFNotificationCent
} }
#endif #endif
CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF(PageGroup* group) CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF(PageGroup& group)
: CaptionUserPreferences(group) : CaptionUserPreferences(group)
#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
, m_listeningForPreferenceChanges(false) , m_listeningForPreferenceChanges(false)
......
...@@ -37,7 +37,7 @@ namespace WebCore { ...@@ -37,7 +37,7 @@ namespace WebCore {
class CaptionUserPreferencesMediaAF : public CaptionUserPreferences { class CaptionUserPreferencesMediaAF : public CaptionUserPreferences {
public: public:
static PassOwnPtr<CaptionUserPreferencesMediaAF> create(PageGroup* group) { return adoptPtr(new CaptionUserPreferencesMediaAF(group)); } CaptionUserPreferencesMediaAF(PageGroup&);
virtual ~CaptionUserPreferencesMediaAF(); virtual ~CaptionUserPreferencesMediaAF();
#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
...@@ -67,8 +67,6 @@ public: ...@@ -67,8 +67,6 @@ public:
virtual String displayNameForTrack(TextTrack*) const OVERRIDE; virtual String displayNameForTrack(TextTrack*) const OVERRIDE;
private: private:
CaptionUserPreferencesMediaAF(PageGroup*);
#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
String captionsWindowCSS() const; String captionsWindowCSS() const;
String captionsBackgroundCSS() const; String captionsBackgroundCSS() const;
......
...@@ -535,8 +535,8 @@ void Frame::injectUserScripts(UserScriptInjectionTime injectionTime) ...@@ -535,8 +535,8 @@ void Frame::injectUserScripts(UserScriptInjectionTime injectionTime)
const UserScriptMap* userScripts = m_page->group().userScripts(); const UserScriptMap* userScripts = m_page->group().userScripts();
if (!userScripts) if (!userScripts)
return; return;
UserScriptMap::const_iterator end = userScripts->end();
for (UserScriptMap::const_iterator it = userScripts->begin(); it != end; ++it) for (auto it = userScripts->begin(), end = userScripts->end(); it != end; ++it)
injectUserScriptsForWorld(it->key.get(), *it->value, injectionTime); injectUserScriptsForWorld(it->key.get(), *it->value, injectionTime);
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#ifndef GroupSettings_h #ifndef GroupSettings_h
#define GroupSettings_h #define GroupSettings_h
#include <wtf/PassOwnPtr.h>
#include <wtf/text/WTFString.h> #include <wtf/text/WTFString.h>
namespace WebCore { namespace WebCore {
...@@ -36,10 +35,7 @@ class PageGroup; ...@@ -36,10 +35,7 @@ class PageGroup;
class GroupSettings { class GroupSettings {
WTF_MAKE_NONCOPYABLE(GroupSettings); WTF_MAKE_FAST_ALLOCATED; WTF_MAKE_NONCOPYABLE(GroupSettings); WTF_MAKE_FAST_ALLOCATED;
public: public:
static PassOwnPtr<GroupSettings> create() GroupSettings();
{
return adoptPtr(new GroupSettings());
}
void setLocalStorageQuotaBytes(unsigned); void setLocalStorageQuotaBytes(unsigned);
unsigned localStorageQuotaBytes() const { return m_localStorageQuotaBytes; } unsigned localStorageQuotaBytes() const { return m_localStorageQuotaBytes; }
...@@ -51,8 +47,6 @@ public: ...@@ -51,8 +47,6 @@ public:
const String& indexedDBDatabasePath() const { return m_indexedDBDatabasePath; } const String& indexedDBDatabasePath() const { return m_indexedDBDatabasePath; }
private: private:
GroupSettings();
unsigned m_localStorageQuotaBytes; unsigned m_localStorageQuotaBytes;
String m_indexedDBDatabasePath; String m_indexedDBDatabasePath;
int64_t m_indexedDBQuotaBytes; int64_t m_indexedDBQuotaBytes;
......
...@@ -434,7 +434,7 @@ void Page::setGroupName(const String& name) ...@@ -434,7 +434,7 @@ void Page::setGroupName(const String& name)
if (m_group && !m_group->name().isEmpty()) { if (m_group && !m_group->name().isEmpty()) {
ASSERT(m_group != m_singlePageGroup.get()); ASSERT(m_group != m_singlePageGroup.get());
ASSERT(!m_singlePageGroup); ASSERT(!m_singlePageGroup);
m_group->removePage(this); m_group->removePage(*this);
} }
if (name.isEmpty()) if (name.isEmpty())
...@@ -442,7 +442,7 @@ void Page::setGroupName(const String& name) ...@@ -442,7 +442,7 @@ void Page::setGroupName(const String& name)
else { else {
m_singlePageGroup = nullptr; m_singlePageGroup = nullptr;
m_group = PageGroup::pageGroup(name); m_group = PageGroup::pageGroup(name);
m_group->addPage(this); m_group->addPage(*this);
} }
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "SecurityOrigin.h" #include "SecurityOrigin.h"
#include "Settings.h" #include "Settings.h"
#include "StorageNamespace.h" #include "StorageNamespace.h"
#include <wtf/StdLibExtras.h>
#if ENABLE(VIDEO_TRACK) #if ENABLE(VIDEO_TRACK)
#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) #if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
...@@ -63,16 +64,16 @@ PageGroup::PageGroup(const String& name) ...@@ -63,16 +64,16 @@ PageGroup::PageGroup(const String& name)
: m_name(name) : m_name(name)
, m_visitedLinksPopulated(false) , m_visitedLinksPopulated(false)
, m_identifier(getUniqueIdentifier()) , m_identifier(getUniqueIdentifier())
, m_groupSettings(GroupSettings::create()) , m_groupSettings(std::make_unique<GroupSettings>())
{ {
} }
PageGroup::PageGroup(Page& page) PageGroup::PageGroup(Page& page)
: m_visitedLinksPopulated(false) : m_visitedLinksPopulated(false)
, m_identifier(getUniqueIdentifier()) , m_identifier(getUniqueIdentifier())
, m_groupSettings(GroupSettings::create()) , m_groupSettings(std::make_unique<GroupSettings>())
{ {
addPage(&page); addPage(page);
} }
PageGroup::~PageGroup() PageGroup::~PageGroup()
...@@ -106,9 +107,7 @@ void PageGroup::closeLocalStorage() ...@@ -106,9 +107,7 @@ void PageGroup::closeLocalStorage()
if (!pageGroups) if (!pageGroups)
return; return;
PageGroupMap::iterator end = pageGroups->end(); for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) {
for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) {
if (it->value->hasLocalStorage()) if (it->value->hasLocalStorage())
it->value->localStorage()->close(); it->value->localStorage()->close();
} }
...@@ -119,8 +118,7 @@ void PageGroup::clearLocalStorageForAllOrigins() ...@@ -119,8 +118,7 @@ void PageGroup::clearLocalStorageForAllOrigins()
if (!pageGroups) if (!pageGroups)
return; return;
PageGroupMap::iterator end = pageGroups->end(); for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) {
for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) {
if (it->value->hasLocalStorage()) if (it->value->hasLocalStorage())
it->value->localStorage()->clearAllOriginsForDeletion(); it->value->localStorage()->clearAllOriginsForDeletion();
} }
...@@ -131,8 +129,7 @@ void PageGroup::clearLocalStorageForOrigin(SecurityOrigin* origin) ...@@ -131,8 +129,7 @@ void PageGroup::clearLocalStorageForOrigin(SecurityOrigin* origin)
if (!pageGroups) if (!pageGroups)
return; return;
PageGroupMap::iterator end = pageGroups->end(); for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) {
for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) {
if (it->value->hasLocalStorage()) if (it->value->hasLocalStorage())
it->value->localStorage()->clearOriginForDeletion(origin); it->value->localStorage()->clearOriginForDeletion(origin);
} }
...@@ -143,8 +140,7 @@ void PageGroup::closeIdleLocalStorageDatabases() ...@@ -143,8 +140,7 @@ void PageGroup::closeIdleLocalStorageDatabases()
if (!pageGroups) if (!pageGroups)
return; return;
PageGroupMap::iterator end = pageGroups->end(); for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) {
for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) {
if (it->value->hasLocalStorage()) if (it->value->hasLocalStorage())
it->value->localStorage()->closeIdleLocalStorageDatabases(); it->value->localStorage()->closeIdleLocalStorageDatabases();
} }
...@@ -155,8 +151,7 @@ void PageGroup::syncLocalStorage() ...@@ -155,8 +151,7 @@ void PageGroup::syncLocalStorage()
if (!pageGroups) if (!pageGroups)
return; return;
PageGroupMap::iterator end = pageGroups->end(); for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) {
for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) {
if (it->value->hasLocalStorage()) if (it->value->hasLocalStorage())
it->value->localStorage()->sync(); it->value->localStorage()->sync();
} }
...@@ -170,18 +165,16 @@ unsigned PageGroup::numberOfPageGroups() ...@@ -170,18 +165,16 @@ unsigned PageGroup::numberOfPageGroups()
return pageGroups->size(); return pageGroups->size();
} }
void PageGroup::addPage(Page* page) void PageGroup::addPage(Page& page)
{ {
ASSERT(page); ASSERT(!m_pages.contains(&page));
ASSERT(!m_pages.contains(page)); m_pages.add(&page);
m_pages.add(page);
} }
void PageGroup::removePage(Page* page) void PageGroup::removePage(Page& page)
{ {
ASSERT(page); ASSERT(m_pages.contains(&page));
ASSERT(m_pages.contains(page)); m_pages.remove(&page);
m_pages.remove(page);
} }
bool PageGroup::isLinkVisited(LinkHash visitedLinkHash) bool PageGroup::isLinkVisited(LinkHash visitedLinkHash)
...@@ -273,13 +266,13 @@ void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& sourc ...@@ -273,13 +266,13 @@ void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& sourc
{ {
ASSERT_ARG(world, world); ASSERT_ARG(world, world);
OwnPtr<UserScript> userScript = adoptPtr(new UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames)); auto userScript = std::make_unique<UserScript>(source, url, whitelist, blacklist, injectionTime, injectedFrames);
if (!m_userScripts) if (!m_userScripts)
m_userScripts = adoptPtr(new UserScriptMap); m_userScripts = std::make_unique<UserScriptMap>();
OwnPtr<UserScriptVector>& scriptsInWorld = m_userScripts->add(world, nullptr).iterator->value; std::unique_ptr<UserScriptVector>& scriptsInWorld = m_userScripts->add(world, nullptr).iterator->value;
if (!scriptsInWorld) if (!scriptsInWorld)
scriptsInWorld = adoptPtr(new UserScriptVector); scriptsInWorld = std::make_unique<UserScriptVector>();
scriptsInWorld->append(userScript.release()); scriptsInWorld->append(std::move(userScript));
} }
void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const URL& url, void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const URL& url,
...@@ -290,13 +283,13 @@ void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& s ...@@ -290,13 +283,13 @@ void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& s
{ {
ASSERT_ARG(world, world); ASSERT_ARG(world, world);
OwnPtr<UserStyleSheet> userStyleSheet = adoptPtr(new UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level)); auto userStyleSheet = std::make_unique<UserStyleSheet>(source, url, whitelist, blacklist, injectedFrames, level);
if (!m_userStyleSheets) if (!m_userStyleSheets)
m_userStyleSheets = adoptPtr(new UserStyleSheetMap); m_userStyleSheets = std::make_unique<UserStyleSheetMap>();
OwnPtr<UserStyleSheetVector>& styleSheetsInWorld = m_userStyleSheets->add(world, nullptr).iterator->value; std::unique_ptr<UserStyleSheetVector>& styleSheetsInWorld = m_userStyleSheets->add(world, nullptr).iterator->value;
if (!styleSheetsInWorld) if (!styleSheetsInWorld)
styleSheetsInWorld = adoptPtr(new UserStyleSheetVector); styleSheetsInWorld = std::make_unique<UserStyleSheetVector>();
styleSheetsInWorld->append(userStyleSheet.release()); styleSheetsInWorld->append(std::move(userStyleSheet));
if (injectionTime == InjectInExistingDocuments) if (injectionTime == InjectInExistingDocuments)
invalidateInjectedStyleSheetCacheInAllFrames(); invalidateInjectedStyleSheetCacheInAllFrames();
...@@ -309,11 +302,11 @@ void PageGroup::removeUserScriptFromWorld(DOMWrapperWorld* world, const URL& url ...@@ -309,11 +302,11 @@ void PageGroup::removeUserScriptFromWorld(DOMWrapperWorld* world, const URL& url
if (!m_userScripts) if (!m_userScripts)
return; return;
UserScriptMap::iterator it = m_userScripts->find(world); auto it = m_userScripts->find(world);
if (it == m_userScripts->end()) if (it == m_userScripts->end())
return; return;
UserScriptVector* scripts = it->value.get(); auto scripts = it->value.get();
for (int i = scripts->size() - 1; i >= 0; --i) { for (int i = scripts->size() - 1; i >= 0; --i) {
if (scripts->at(i)->url() == url) if (scripts->at(i)->url() == url)
scripts->remove(i); scripts->remove(i);
...@@ -330,12 +323,12 @@ void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld* world, const URL& ...@@ -330,12 +323,12 @@ void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld* world, const URL&
if (!m_userStyleSheets) if (!m_userStyleSheets)
return; return;
UserStyleSheetMap::iterator it = m_userStyleSheets->find(world); auto it = m_userStyleSheets->find(world);
bool sheetsChanged = false; bool sheetsChanged = false;
if (it == m_userStyleSheets->end()) if (it == m_userStyleSheets->end())
return; return;
UserStyleSheetVector* stylesheets = it->value.get(); auto stylesheets = it->value.get();
for (int i = stylesheets->size() - 1; i >= 0; --i) { for (int i = stylesheets->size() - 1; i >= 0; --i) {
if (stylesheets->at(i)->url() == url) { if (stylesheets->at(i)->url() == url) {
stylesheets->remove(i); stylesheets->remove(i);
...@@ -377,10 +370,10 @@ void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld* world) ...@@ -377,10 +370,10 @@ void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld* world)
void PageGroup::removeAllUserContent() void PageGroup::removeAllUserContent()
{ {
m_userScripts.clear(); m_userScripts = nullptr;
if (m_userStyleSheets) { if (m_userStyleSheets) {
m_userStyleSheets.clear(); m_userStyleSheets = nullptr;
invalidateInjectedStyleSheetCacheInAllFrames(); invalidateInjectedStyleSheetCacheInAllFrames();
} }
} }
...@@ -388,8 +381,7 @@ void PageGroup::removeAllUserContent() ...@@ -388,8 +381,7 @@ void PageGroup::removeAllUserContent()
void PageGroup::invalidateInjectedStyleSheetCacheInAllFrames() void PageGroup::invalidateInjectedStyleSheetCacheInAllFrames()
{ {
// Clear our cached sheets and have them just reparse. // Clear our cached sheets and have them just reparse.
HashSet<Page*>::const_iterator end = m_pages.end(); for (auto it = m_pages.begin(), end = m_pages.end(); it != end; ++it) {
for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) {