Changeset 271153 in webkit
- Timestamp:
- Jan 5, 2021 10:15:39 AM (3 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r271148 r271153 1 2021-01-05 Alex Christensen <achristensen@webkit.org> 2 3 Use WeakHashSet<Page> instead of HashSet<Page*> 4 https://bugs.webkit.org/show_bug.cgi?id=220102 5 6 Reviewed by Darin Adler. 7 8 The former is more resistent to using a raw pointer after the object has been freed. 9 10 * inspector/PageDebugger.cpp: 11 (WebCore::PageDebugger::setJavaScriptPaused): 12 * page/CaptionUserPreferences.cpp: 13 (WebCore::CaptionUserPreferences::currentPage const): 14 (WebCore::CaptionUserPreferences::userPrefersCaptions const): 15 (WebCore::CaptionUserPreferences::setUserPrefersCaptions): 16 (WebCore::CaptionUserPreferences::userPrefersSubtitles const): 17 (WebCore::CaptionUserPreferences::setUserPrefersSubtitles): 18 (WebCore::CaptionUserPreferences::userPrefersTextDescriptions const): 19 (WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions): 20 (WebCore::CaptionUserPreferences::updateCaptionStyleSheetOverride): 21 * page/FrameTree.cpp: 22 (WebCore::FrameTree::find const): 23 * page/PageGroup.cpp: 24 (WebCore::PageGroup::addPage): 25 (WebCore::PageGroup::removePage): 26 (WebCore::PageGroup::captionPreferencesChanged): 27 * page/PageGroup.h: 28 (WebCore::PageGroup::pages const): 29 (WebCore::PageGroup:: const): Deleted. 30 * page/PageGroupLoadDeferrer.cpp: 31 (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): 32 * page/UserContentProvider.cpp: 33 (WebCore::UserContentProvider::~UserContentProvider): 34 (WebCore::UserContentProvider::addPage): 35 (WebCore::UserContentProvider::removePage): 36 (WebCore::UserContentProvider::registerForUserMessageHandlerInvalidation): 37 (WebCore::UserContentProvider::unregisterForUserMessageHandlerInvalidation): 38 (WebCore::UserContentProvider::invalidateAllRegisteredUserMessageHandlerInvalidationClients): 39 (WebCore::UserContentProvider::invalidateInjectedStyleSheetCacheInAllFramesInAllPages): 40 * page/UserContentProvider.h: 41 * page/VisitedLinkStore.cpp: 42 (WebCore::VisitedLinkStore::~VisitedLinkStore): 43 (WebCore::VisitedLinkStore::addPage): 44 (WebCore::VisitedLinkStore::removePage): 45 (WebCore::VisitedLinkStore::invalidateStylesForAllLinks): 46 (WebCore::VisitedLinkStore::invalidateStylesForLink): 47 * page/VisitedLinkStore.h: 48 * plugins/PluginInfoProvider.cpp: 49 (WebCore::PluginInfoProvider::~PluginInfoProvider): 50 (WebCore::PluginInfoProvider::clearPagesPluginData): 51 (WebCore::PluginInfoProvider::refresh): 52 (WebCore::PluginInfoProvider::addPage): 53 (WebCore::PluginInfoProvider::removePage): 54 * plugins/PluginInfoProvider.h: 55 * storage/StorageEventDispatcher.cpp: 56 (WebCore::StorageEventDispatcher::dispatchLocalStorageEvents): 57 (WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames): 58 1 59 2021-01-05 Andres Gonzalez <andresg_22@apple.com> 2 60 -
trunk/Source/WebCore/inspector/PageDebugger.cpp
r266077 r271153 149 149 { 150 150 for (auto& page : pageGroup.pages()) { 151 for ( Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext())151 for (auto* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) 152 152 setJavaScriptPaused(*frame, paused); 153 153 154 if (auto* frontendClient = page ->inspectorController().inspectorFrontendClient()) {154 if (auto* frontendClient = page.inspectorController().inspectorFrontendClient()) { 155 155 if (paused) 156 156 frontendClient->pagePaused(); -
trunk/Source/WebCore/page/CaptionUserPreferences.cpp
r262695 r271153 101 101 Page* CaptionUserPreferences::currentPage() const 102 102 { 103 if (m_pageGroup.pages().isEmpty()) 104 return nullptr; 105 106 return *(m_pageGroup.pages().begin()); 103 for (auto& page : m_pageGroup.pages()) 104 return &page; 105 return nullptr; 107 106 } 108 107 109 108 bool CaptionUserPreferences::userPrefersCaptions() const 110 109 { 111 Page* page = currentPage();110 auto* page = currentPage(); 112 111 if (!page) 113 112 return false; … … 118 117 void CaptionUserPreferences::setUserPrefersCaptions(bool preference) 119 118 { 120 Page* page = currentPage();119 auto* page = currentPage(); 121 120 if (!page) 122 121 return; … … 128 127 bool CaptionUserPreferences::userPrefersSubtitles() const 129 128 { 130 Page* page = currentPage();129 auto* page = currentPage(); 131 130 if (!page) 132 131 return false; … … 137 136 void CaptionUserPreferences::setUserPrefersSubtitles(bool preference) 138 137 { 139 Page* page = currentPage();138 auto* page = currentPage(); 140 139 if (!page) 141 140 return; … … 147 146 bool CaptionUserPreferences::userPrefersTextDescriptions() const 148 147 { 149 Page* page = currentPage();148 auto* page = currentPage(); 150 149 if (!page) 151 150 return false; … … 156 155 void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference) 157 156 { 158 Page* page = currentPage();157 auto* page = currentPage(); 159 158 if (!page) 160 159 return; … … 407 406 String captionsOverrideStyleSheet = captionsStyleSheetOverride(); 408 407 for (auto& page : m_pageGroup.pages()) 409 page ->setCaptionUserPreferencesStyleSheet(captionsOverrideStyleSheet);408 page.setCaptionUserPreferencesStyleSheet(captionsOverrideStyleSheet); 410 409 } 411 410 -
trunk/Source/WebCore/page/FrameTree.cpp
r269435 r271153 270 270 return nullptr; 271 271 272 for (auto *otherPage : page->group().pages()) {273 if ( otherPage == page)272 for (auto& otherPage : page->group().pages()) { 273 if (&otherPage == page) 274 274 continue; 275 for (auto* frame = &otherPage ->mainFrame(); frame; frame = frame->tree().traverseNext()) {275 for (auto* frame = &otherPage.mainFrame(); frame; frame = frame->tree().traverseNext()) { 276 276 if (frame->tree().uniqueName() == name && isFrameFamiliarWith(activeFrame, *frame)) 277 277 return frame; -
trunk/Source/WebCore/page/PageGroup.cpp
r262695 r271153 92 92 void PageGroup::addPage(Page& page) 93 93 { 94 ASSERT(!m_pages.contains( &page));95 m_pages.add( &page);94 ASSERT(!m_pages.contains(page)); 95 m_pages.add(page); 96 96 } 97 97 98 98 void PageGroup::removePage(Page& page) 99 99 { 100 ASSERT(m_pages.contains( &page));101 m_pages.remove( &page);100 ASSERT(m_pages.contains(page)); 101 m_pages.remove(page); 102 102 } 103 103 … … 106 106 { 107 107 for (auto& page : m_pages) 108 page ->captionPreferencesChanged();108 page.captionPreferencesChanged(); 109 109 BackForwardCache::singleton().markPagesForCaptionPreferencesChanged(); 110 110 } -
trunk/Source/WebCore/page/PageGroup.h
r262695 r271153 26 26 #pragma once 27 27 28 #include <wtf/HashSet.h>29 28 #include <wtf/Noncopyable.h> 29 #include <wtf/WeakHashSet.h> 30 30 #include <wtf/text/WTFString.h> 31 31 … … 46 46 WEBCORE_EXPORT static PageGroup* pageGroup(const String& groupName); 47 47 48 const HashSet<Page*>& pages() const { return m_pages; }48 const WeakHashSet<Page>& pages() const { return m_pages; } 49 49 50 50 void addPage(Page&); … … 61 61 private: 62 62 String m_name; 63 HashSet<Page*> m_pages;63 WeakHashSet<Page> m_pages; 64 64 65 65 unsigned m_identifier; -
trunk/Source/WebCore/page/PageGroupLoadDeferrer.cpp
r233611 r271153 34 34 { 35 35 for (auto& otherPage : page.group().pages()) { 36 if ((deferSelf || otherPage != &page)) {37 if (!otherPage ->defersLoading()) {38 m_deferredFrames.append(&otherPage ->mainFrame());36 if ((deferSelf || &otherPage != &page)) { 37 if (!otherPage.defersLoading()) { 38 m_deferredFrames.append(&otherPage.mainFrame()); 39 39 40 40 // This code is not logically part of load deferring, but we do not want JS code executed beneath modal 41 41 // windows or sheets, which is exactly when PageGroupLoadDeferrer is used. 42 for ( Frame* frame = &otherPage->mainFrame(); frame; frame = frame->tree().traverseNext())42 for (auto* frame = &otherPage.mainFrame(); frame; frame = frame->tree().traverseNext()) 43 43 frame->document()->suspendScheduledTasks(ReasonForSuspension::WillDeferLoading); 44 44 } -
trunk/Source/WebCore/page/UserContentProvider.cpp
r262683 r271153 47 47 UserContentProvider::~UserContentProvider() 48 48 { 49 ASSERT(m_pages. isEmpty());49 ASSERT(m_pages.computesEmpty()); 50 50 } 51 51 52 52 void UserContentProvider::addPage(Page& page) 53 53 { 54 ASSERT(!m_pages.contains( &page));54 ASSERT(!m_pages.contains(page)); 55 55 56 m_pages.add( &page);56 m_pages.add(page); 57 57 } 58 58 59 59 void UserContentProvider::removePage(Page& page) 60 60 { 61 ASSERT(m_pages.contains( &page));61 ASSERT(m_pages.contains(page)); 62 62 63 m_pages.remove( &page);63 m_pages.remove(page); 64 64 } 65 65 66 66 void UserContentProvider::registerForUserMessageHandlerInvalidation(UserContentProviderInvalidationClient& invalidationClient) 67 67 { 68 ASSERT(!m_userMessageHandlerInvalidationClients.contains( &invalidationClient));68 ASSERT(!m_userMessageHandlerInvalidationClients.contains(invalidationClient)); 69 69 70 70 m_userMessageHandlerInvalidationClients.add(&invalidationClient); … … 73 73 void UserContentProvider::unregisterForUserMessageHandlerInvalidation(UserContentProviderInvalidationClient& invalidationClient) 74 74 { 75 ASSERT(m_userMessageHandlerInvalidationClients.contains( &invalidationClient));75 ASSERT(m_userMessageHandlerInvalidationClients.contains(invalidationClient)); 76 76 77 m_userMessageHandlerInvalidationClients.remove( &invalidationClient);77 m_userMessageHandlerInvalidationClients.remove(invalidationClient); 78 78 } 79 79 … … 81 81 { 82 82 for (auto& client : m_userMessageHandlerInvalidationClients) 83 client ->didInvalidate(*this);83 client.didInvalidate(*this); 84 84 } 85 85 … … 87 87 { 88 88 for (auto& page : m_pages) 89 page ->invalidateInjectedStyleSheetCacheInAllFrames();89 page.invalidateInjectedStyleSheetCacheInAllFrames(); 90 90 } 91 91 -
trunk/Source/WebCore/page/UserContentProvider.h
r244794 r271153 31 31 #include <wtf/HashSet.h> 32 32 #include <wtf/RefCounted.h> 33 #include <wtf/WeakHashSet.h> 34 #include <wtf/WeakPtr.h> 33 35 34 36 #if ENABLE(CONTENT_EXTENSIONS) … … 57 59 class UserContentProvider; 58 60 59 class UserContentProviderInvalidationClient {61 class UserContentProviderInvalidationClient : public CanMakeWeakPtr<UserContentProviderInvalidationClient> { 60 62 public: 61 63 virtual ~UserContentProviderInvalidationClient() … … 99 101 100 102 private: 101 HashSet<Page*> m_pages;102 HashSet<UserContentProviderInvalidationClient*> m_userMessageHandlerInvalidationClients;103 WeakHashSet<Page> m_pages; 104 WeakHashSet<UserContentProviderInvalidationClient> m_userMessageHandlerInvalidationClients; 103 105 }; 104 106 -
trunk/Source/WebCore/page/VisitedLinkStore.cpp
r222664 r271153 37 37 VisitedLinkStore::~VisitedLinkStore() 38 38 { 39 ASSERT(m_pages. isEmpty());39 ASSERT(m_pages.computesEmpty()); 40 40 } 41 41 42 42 void VisitedLinkStore::addPage(Page& page) 43 43 { 44 ASSERT(!m_pages.contains( &page));44 ASSERT(!m_pages.contains(page)); 45 45 46 m_pages.add( &page);46 m_pages.add(page); 47 47 } 48 48 49 49 void VisitedLinkStore::removePage(Page& page) 50 50 { 51 ASSERT(m_pages.contains( &page));51 ASSERT(m_pages.contains(page)); 52 52 53 m_pages.remove( &page);53 m_pages.remove(page); 54 54 } 55 55 … … 57 57 { 58 58 for (auto& page : m_pages) 59 page ->invalidateStylesForAllLinks();59 page.invalidateStylesForAllLinks(); 60 60 } 61 61 … … 63 63 { 64 64 for (auto& page : m_pages) 65 page ->invalidateStylesForLink(linkHash);65 page.invalidateStylesForLink(linkHash); 66 66 } 67 67 -
trunk/Source/WebCore/page/VisitedLinkStore.h
r254739 r271153 27 27 28 28 #include <wtf/Forward.h> 29 #include <wtf/HashSet.h>30 29 #include <wtf/RefCounted.h> 30 #include <wtf/WeakHashSet.h> 31 31 32 32 namespace WebCore { … … 51 51 52 52 private: 53 HashSet<Page*> m_pages;53 WeakHashSet<Page> m_pages; 54 54 }; 55 55 -
trunk/Source/WebCore/plugins/PluginInfoProvider.cpp
r233563 r271153 36 36 PluginInfoProvider::~PluginInfoProvider() 37 37 { 38 ASSERT(m_pages. isEmpty());38 ASSERT(m_pages.computesEmpty()); 39 39 } 40 40 … … 42 42 { 43 43 for (auto& page : m_pages) 44 page ->clearPluginData();44 page.clearPluginData(); 45 45 } 46 46 … … 52 52 53 53 for (auto& page : m_pages) { 54 page ->clearPluginData();54 page.clearPluginData(); 55 55 56 56 if (!reloadPages) 57 57 continue; 58 58 59 for ( Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {59 for (auto* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) { 60 60 if (frame->loader().subframeLoader().containsPlugins()) 61 framesNeedingReload.append(page ->mainFrame());61 framesNeedingReload.append(page.mainFrame()); 62 62 } 63 63 } … … 69 69 void PluginInfoProvider::addPage(Page& page) 70 70 { 71 ASSERT(!m_pages.contains( &page));71 ASSERT(!m_pages.contains(page)); 72 72 73 m_pages.add( &page);73 m_pages.add(page); 74 74 } 75 75 76 76 void PluginInfoProvider::removePage(Page& page) 77 77 { 78 ASSERT(m_pages.contains( &page));78 ASSERT(m_pages.contains(page)); 79 79 80 m_pages.remove( &page);80 m_pages.remove(page); 81 81 } 82 82 -
trunk/Source/WebCore/plugins/PluginInfoProvider.h
r239427 r271153 27 27 28 28 #include "PluginData.h" 29 #include <wtf/ HashSet.h>29 #include <wtf/WeakHashSet.h> 30 30 31 31 namespace WebCore { … … 47 47 virtual void refreshPlugins() = 0; 48 48 49 HashSet<Page*> m_pages;49 WeakHashSet<Page> m_pages; 50 50 }; 51 51 -
trunk/Source/WebCore/storage/StorageEventDispatcher.cpp
r260709 r271153 70 70 // Send events to every page. 71 71 for (auto& pageInGroup : page->group().pages()) { 72 for ( Frame* frame = &pageInGroup->mainFrame(); frame; frame = frame->tree().traverseNext()) {72 for (auto* frame = &pageInGroup.mainFrame(); frame; frame = frame->tree().traverseNext()) { 73 73 if (!frame->document()) 74 74 continue; … … 96 96 { 97 97 for (auto& page : pageGroup.pages()) 98 InspectorInstrumentation::didDispatchDOMStorageEvent( *page, key, oldValue, newValue, StorageType::Local, securityOrigin.securityOrigin().ptr());98 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, StorageType::Local, securityOrigin.securityOrigin().ptr()); 99 99 100 100 for (auto& frame : frames) { -
trunk/Source/WebKit/ChangeLog
r271149 r271153 1 2021-01-05 Alex Christensen <achristensen@webkit.org> 2 3 Use WeakHashSet<Page> instead of HashSet<Page*> 4 https://bugs.webkit.org/show_bug.cgi?id=220102 5 6 Reviewed by Darin Adler. 7 8 * WebProcess/InjectedBundle/InjectedBundle.cpp: 9 (WebKit::InjectedBundle::setAsynchronousSpellCheckingEnabled): 10 (WebKit::InjectedBundle::setUserStyleSheetLocation): 11 (WebKit::InjectedBundle::liveDocumentURLs): 12 * WebProcess/WebStorage/StorageAreaMap.cpp: 13 (WebKit::StorageAreaMap::dispatchLocalStorageEvent): 14 1 15 2021-01-05 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp
r269236 r271153 171 171 void InjectedBundle::setAsynchronousSpellCheckingEnabled(WebPageGroupProxy* pageGroup, bool enabled) 172 172 { 173 const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); 174 for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) 175 (*iter)->settings().setAsynchronousSpellCheckingEnabled(enabled); 173 for (auto& page : PageGroup::pageGroup(pageGroup->identifier())->pages()) 174 page.settings().setAsynchronousSpellCheckingEnabled(enabled); 176 175 } 177 176 … … 288 287 void InjectedBundle::setUserStyleSheetLocation(WebPageGroupProxy* pageGroup, const String& location) 289 288 { 290 const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); 291 for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) 292 (*iter)->settings().setUserStyleSheetLocation(URL(URL(), location)); 289 for (auto& page : PageGroup::pageGroup(pageGroup->identifier())->pages()) 290 page.settings().setUserStyleSheetLocation(URL(URL(), location)); 293 291 } 294 292 … … 344 342 345 343 if (excludeDocumentsInPageGroupPages) { 346 for ( const auto*page : PageGroup::pageGroup(pageGroup->identifier())->pages()) {347 for ( const auto* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {344 for (auto& page : PageGroup::pageGroup(pageGroup->identifier())->pages()) { 345 for (auto* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) { 348 346 if (!frame->document()) 349 347 continue; -
trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp
r262058 r271153 338 338 // Namespace IDs for local storage namespaces are equivalent to web page group IDs. 339 339 auto& pageGroup = *WebProcess::singleton().webPageGroup(m_namespace.pageGroupID())->corePageGroup(); 340 for (auto *page : pageGroup.pages())341 frames.appendVector(framesForEventDispatching( *page, m_securityOrigin, StorageType::Local, storageAreaImplID));340 for (auto& page : pageGroup.pages()) 341 frames.appendVector(framesForEventDispatching(page, m_securityOrigin, StorageType::Local, storageAreaImplID)); 342 342 343 343 StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin->data());
Note: See TracChangeset
for help on using the changeset viewer.