diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/page/PageGroup.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/page/PageGroup.cpp')
-rw-r--r-- | Source/WebCore/page/PageGroup.cpp | 229 |
1 files changed, 11 insertions, 218 deletions
diff --git a/Source/WebCore/page/PageGroup.cpp b/Source/WebCore/page/PageGroup.cpp index 8a1cd2081..5aa435141 100644 --- a/Source/WebCore/page/PageGroup.cpp +++ b/Source/WebCore/page/PageGroup.cpp @@ -26,24 +26,18 @@ #include "config.h" #include "PageGroup.h" -#include "Chrome.h" -#include "ChromeClient.h" #include "DOMWrapperWorld.h" #include "Document.h" -#include "DocumentStyleSheetCollection.h" -#include "GroupSettings.h" #include "MainFrame.h" #include "Page.h" #include "PageCache.h" -#include "SecurityOrigin.h" -#include "Settings.h" #include "StorageNamespace.h" -#include "UserContentController.h" -#include "VisitedLinkProvider.h" +#include <heap/HeapInlines.h> +#include <runtime/StructureInlines.h> #include <wtf/StdLibExtras.h> #if ENABLE(VIDEO_TRACK) -#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) +#if PLATFORM(MAC) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) #include "CaptionUserPreferencesMediaAF.h" #else #include "CaptionUserPreferences.h" @@ -60,35 +54,24 @@ static unsigned getUniqueIdentifier() // -------- -static bool shouldTrackVisitedLinks = false; - PageGroup::PageGroup(const String& name) : m_name(name) - , m_visitedLinkProvider(VisitedLinkProvider::create()) - , m_visitedLinksPopulated(false) , m_identifier(getUniqueIdentifier()) - , m_userContentController(UserContentController::create()) - , m_groupSettings(std::make_unique<GroupSettings>()) { } PageGroup::PageGroup(Page& page) - : m_visitedLinkProvider(VisitedLinkProvider::create()) - , m_visitedLinksPopulated(false) - , m_identifier(getUniqueIdentifier()) - , m_userContentController(UserContentController::create()) - , m_groupSettings(std::make_unique<GroupSettings>()) + : m_identifier(getUniqueIdentifier()) { addPage(page); } PageGroup::~PageGroup() { - removeAllUserContent(); } typedef HashMap<String, PageGroup*> PageGroupMap; -static PageGroupMap* pageGroups = 0; +static PageGroupMap* pageGroups = nullptr; PageGroup* PageGroup::pageGroup(const String& groupName) { @@ -108,227 +91,37 @@ PageGroup* PageGroup::pageGroup(const String& groupName) return result.iterator->value; } -void PageGroup::closeLocalStorage() -{ - if (!pageGroups) - return; - - for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) { - if (it->value->hasLocalStorage()) - it->value->localStorage()->close(); - } -} - -void PageGroup::clearLocalStorageForAllOrigins() -{ - if (!pageGroups) - return; - - for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) { - if (it->value->hasLocalStorage()) - it->value->localStorage()->clearAllOriginsForDeletion(); - } -} - -void PageGroup::clearLocalStorageForOrigin(SecurityOrigin* origin) -{ - if (!pageGroups) - return; - - for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) { - if (it->value->hasLocalStorage()) - it->value->localStorage()->clearOriginForDeletion(origin); - } -} - -void PageGroup::closeIdleLocalStorageDatabases() -{ - if (!pageGroups) - return; - - for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) { - if (it->value->hasLocalStorage()) - it->value->localStorage()->closeIdleLocalStorageDatabases(); - } -} - -void PageGroup::syncLocalStorage() -{ - if (!pageGroups) - return; - - for (auto it = pageGroups->begin(), end = pageGroups->end(); it != end; ++it) { - if (it->value->hasLocalStorage()) - it->value->localStorage()->sync(); - } -} - 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) -{ - if (!m_visitedLinksPopulated) { - m_visitedLinksPopulated = true; - ASSERT(!m_pages.isEmpty()); - (*m_pages.begin())->chrome().client().populateVisitedLinks(); - } - return m_visitedLinkHashes.contains(visitedLinkHash); -} - -void PageGroup::addVisitedLinkHash(LinkHash hash) -{ - if (shouldTrackVisitedLinks) - addVisitedLink(hash); -} - -inline void PageGroup::addVisitedLink(LinkHash hash) -{ - ASSERT(shouldTrackVisitedLinks); - if (!m_visitedLinkHashes.add(hash).isNewEntry) - return; - Page::visitedStateChanged(this, hash); - pageCache()->markPagesForVistedLinkStyleRecalc(); -} - -void PageGroup::addVisitedLink(const URL& url) -{ - if (!shouldTrackVisitedLinks) - return; - ASSERT(!url.isEmpty()); - addVisitedLink(visitedLinkHash(url.string())); -} - -void PageGroup::addVisitedLink(const UChar* characters, size_t length) -{ - if (!shouldTrackVisitedLinks) - return; - addVisitedLink(visitedLinkHash(characters, length)); -} - -void PageGroup::removeVisitedLink(const URL& url) -{ - LinkHash hash = visitedLinkHash(url.string()); - ASSERT(m_visitedLinkHashes.contains(hash)); - m_visitedLinkHashes.remove(hash); - - Page::allVisitedStateChanged(this); - pageCache()->markPagesForVistedLinkStyleRecalc(); -} - -void PageGroup::removeVisitedLinks() -{ - m_visitedLinksPopulated = false; - if (m_visitedLinkHashes.isEmpty()) - return; - m_visitedLinkHashes.clear(); - Page::allVisitedStateChanged(this); - pageCache()->markPagesForVistedLinkStyleRecalc(); -} - -void PageGroup::removeAllVisitedLinks() -{ - Page::removeAllVisitedLinks(); - pageCache()->markPagesForVistedLinkStyleRecalc(); -} - -void PageGroup::setShouldTrackVisitedLinks(bool shouldTrack) -{ - if (shouldTrackVisitedLinks == shouldTrack) - return; - shouldTrackVisitedLinks = shouldTrack; - if (!shouldTrackVisitedLinks) - removeAllVisitedLinks(); -} - -StorageNamespace* PageGroup::localStorage() -{ - if (!m_localStorage) - m_localStorage = StorageNamespace::localStorageNamespace(this); - - return m_localStorage.get(); -} - -StorageNamespace* PageGroup::transientLocalStorage(SecurityOrigin* topOrigin) -{ - auto result = m_transientLocalStorageMap.add(topOrigin, nullptr); - - if (result.isNewEntry) - result.iterator->value = StorageNamespace::transientLocalStorageNamespace(this, topOrigin); - - return result.iterator->value.get(); -} - -void PageGroup::addUserScriptToWorld(DOMWrapperWorld& world, const String& source, const URL& url, const Vector<String>& whitelist, const Vector<String>& blacklist, UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames) -{ - auto userScript = std::make_unique<UserScript>(source, url, whitelist, blacklist, injectionTime, injectedFrames); - m_userContentController->addUserScript(world, std::move(userScript)); -} - -void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld& world, const String& source, const URL& url, const Vector<String>& whitelist, const Vector<String>& blacklist, UserContentInjectedFrames injectedFrames, UserStyleLevel level, UserStyleInjectionTime injectionTime) -{ - auto userStyleSheet = std::make_unique<UserStyleSheet>(source, url, whitelist, blacklist, injectedFrames, level); - m_userContentController->addUserStyleSheet(world, std::move(userStyleSheet), injectionTime); - -} - -void PageGroup::removeUserScriptFromWorld(DOMWrapperWorld& world, const URL& url) -{ - m_userContentController->removeUserScript(world, url); -} - -void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld& world, const URL& url) -{ - m_userContentController->removeUserStyleSheet(world, url); -} - -void PageGroup::removeUserScriptsFromWorld(DOMWrapperWorld& world) -{ - m_userContentController->removeUserScripts(world); -} - -void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld& world) -{ - m_userContentController->removeUserStyleSheets(world); -} - -void PageGroup::removeAllUserContent() -{ - m_userContentController->removeAllUserContent(); } #if ENABLE(VIDEO_TRACK) void PageGroup::captionPreferencesChanged() { - for (auto it = m_pages.begin(), end = m_pages.end(); it != end; ++it) - (*it)->captionPreferencesChanged(); - pageCache()->markPagesForCaptionPreferencesChanged(); + for (auto& page : m_pages) + page->captionPreferencesChanged(); + PageCache::singleton().markPagesForCaptionPreferencesChanged(); } -CaptionUserPreferences* PageGroup::captionPreferences() +CaptionUserPreferences& PageGroup::captionPreferences() { if (!m_captionPreferences) { -#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) +#if PLATFORM(MAC) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) m_captionPreferences = std::make_unique<CaptionUserPreferencesMediaAF>(*this); #else m_captionPreferences = std::make_unique<CaptionUserPreferences>(*this); #endif } - return m_captionPreferences.get(); + return *m_captionPreferences.get(); } #endif |