Title: [269861] branches/safari-610.3.7.1-branch/Source
- Revision
- 269861
- Author
- [email protected]
- Date
- 2020-11-16 10:41:18 -0800 (Mon, 16 Nov 2020)
Log Message
Cherry-pick r268979. rdar://problem/71446624
Use a WeakHashSet for Document::m_captionPreferencesChangedElements
https://bugs.webkit.org/show_bug.cgi?id=218170
Reviewed by Eric Carlson.
Source/WebCore:
Refactoring to move from raw pointer to weak pointer.
For that purpose, we use WeakHashSet and WeakHashSet::forEach for extra safety.
No observable change of behavior.
* dom/Document.cpp:
(WebCore::Document::registerForCaptionPreferencesChangedCallbacks):
(WebCore::Document::unregisterForCaptionPreferencesChangedCallbacks):
(WebCore::Document::captionPreferencesChanged):
* dom/Document.h:
Source/WTF:
* wtf/WeakHashSet.h:
Add a static cast for classes inheriting CanMakeWeakPtr like done for the set iterator.
Update code to compile in WinCairo.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-610.3.7.1-branch/Source/WTF/ChangeLog (269860 => 269861)
--- branches/safari-610.3.7.1-branch/Source/WTF/ChangeLog 2020-11-16 18:40:10 UTC (rev 269860)
+++ branches/safari-610.3.7.1-branch/Source/WTF/ChangeLog 2020-11-16 18:41:18 UTC (rev 269861)
@@ -1,3 +1,44 @@
+2020-11-16 Alan Coon <[email protected]>
+
+ Cherry-pick r268979. rdar://problem/71446624
+
+ Use a WeakHashSet for Document::m_captionPreferencesChangedElements
+ https://bugs.webkit.org/show_bug.cgi?id=218170
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ Refactoring to move from raw pointer to weak pointer.
+ For that purpose, we use WeakHashSet and WeakHashSet::forEach for extra safety.
+ No observable change of behavior.
+
+ * dom/Document.cpp:
+ (WebCore::Document::registerForCaptionPreferencesChangedCallbacks):
+ (WebCore::Document::unregisterForCaptionPreferencesChangedCallbacks):
+ (WebCore::Document::captionPreferencesChanged):
+ * dom/Document.h:
+
+ Source/WTF:
+
+ * wtf/WeakHashSet.h:
+ Add a static cast for classes inheriting CanMakeWeakPtr like done for the set iterator.
+ Update code to compile in WinCairo.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-10-26 Youenn Fablet <[email protected]>
+
+ Use a WeakHashSet for Document::m_captionPreferencesChangedElements
+ https://bugs.webkit.org/show_bug.cgi?id=218170
+
+ Reviewed by Eric Carlson.
+
+ * wtf/WeakHashSet.h:
+ Add a static cast for classes inheriting CanMakeWeakPtr like done for the set iterator.
+ Update code to compile in WinCairo.
+
2020-10-27 Russell Epstein <[email protected]>
Apply patch. rdar://problem/70733375
Modified: branches/safari-610.3.7.1-branch/Source/WTF/wtf/WeakHashSet.h (269860 => 269861)
--- branches/safari-610.3.7.1-branch/Source/WTF/wtf/WeakHashSet.h 2020-11-16 18:40:10 UTC (rev 269860)
+++ branches/safari-610.3.7.1-branch/Source/WTF/wtf/WeakHashSet.h 2020-11-16 18:41:18 UTC (rev 269861)
@@ -139,7 +139,11 @@
void forEach(const Function<void(T&)>& callback)
{
- for (auto& item : map(m_set, [](auto& item) { return makeWeakPtr(item->template get<T>()); })) {
+ auto items = map(m_set, [](const Ref<WeakPtrImpl<Counter>>& item) {
+ auto* pointer = static_cast<T*>(item->template get<T>());
+ return makeWeakPtr(pointer);
+ });
+ for (auto& item : items) {
if (item && m_set.contains(*item.m_impl))
callback(*item);
}
Modified: branches/safari-610.3.7.1-branch/Source/WebCore/ChangeLog (269860 => 269861)
--- branches/safari-610.3.7.1-branch/Source/WebCore/ChangeLog 2020-11-16 18:40:10 UTC (rev 269860)
+++ branches/safari-610.3.7.1-branch/Source/WebCore/ChangeLog 2020-11-16 18:41:18 UTC (rev 269861)
@@ -1,3 +1,50 @@
+2020-11-16 Alan Coon <[email protected]>
+
+ Cherry-pick r268979. rdar://problem/71446624
+
+ Use a WeakHashSet for Document::m_captionPreferencesChangedElements
+ https://bugs.webkit.org/show_bug.cgi?id=218170
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ Refactoring to move from raw pointer to weak pointer.
+ For that purpose, we use WeakHashSet and WeakHashSet::forEach for extra safety.
+ No observable change of behavior.
+
+ * dom/Document.cpp:
+ (WebCore::Document::registerForCaptionPreferencesChangedCallbacks):
+ (WebCore::Document::unregisterForCaptionPreferencesChangedCallbacks):
+ (WebCore::Document::captionPreferencesChanged):
+ * dom/Document.h:
+
+ Source/WTF:
+
+ * wtf/WeakHashSet.h:
+ Add a static cast for classes inheriting CanMakeWeakPtr like done for the set iterator.
+ Update code to compile in WinCairo.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-10-26 Youenn Fablet <[email protected]>
+
+ Use a WeakHashSet for Document::m_captionPreferencesChangedElements
+ https://bugs.webkit.org/show_bug.cgi?id=218170
+
+ Reviewed by Eric Carlson.
+
+ Refactoring to move from raw pointer to weak pointer.
+ For that purpose, we use WeakHashSet and WeakHashSet::forEach for extra safety.
+ No observable change of behavior.
+
+ * dom/Document.cpp:
+ (WebCore::Document::registerForCaptionPreferencesChangedCallbacks):
+ (WebCore::Document::unregisterForCaptionPreferencesChangedCallbacks):
+ (WebCore::Document::captionPreferencesChanged):
+ * dom/Document.h:
+
2020-11-06 Kocsen Chung <[email protected]>
Cherry-pick r269121. rdar://problem/71120565
Modified: branches/safari-610.3.7.1-branch/Source/WebCore/dom/Document.cpp (269860 => 269861)
--- branches/safari-610.3.7.1-branch/Source/WebCore/dom/Document.cpp 2020-11-16 18:40:10 UTC (rev 269860)
+++ branches/safari-610.3.7.1-branch/Source/WebCore/dom/Document.cpp 2020-11-16 18:41:18 UTC (rev 269861)
@@ -5542,18 +5542,20 @@
if (page())
page()->group().captionPreferences().setInterestedInCaptionPreferenceChanges();
- m_captionPreferencesChangedElements.add(&element);
+ m_captionPreferencesChangedElements.add(element);
}
void Document::unregisterForCaptionPreferencesChangedCallbacks(HTMLMediaElement& element)
{
- m_captionPreferencesChangedElements.remove(&element);
+ m_captionPreferencesChangedElements.remove(element);
}
void Document::captionPreferencesChanged()
{
- for (auto* element : m_captionPreferencesChangedElements)
- element->captionPreferencesChanged();
+ ASSERT(!m_captionPreferencesChangedElements.hasNullReferences());
+ m_captionPreferencesChangedElements.forEach([](HTMLMediaElement& element) {
+ element.captionPreferencesChanged();
+ });
}
void Document::setMediaElementShowingTextTrack(const HTMLMediaElement& element)
Modified: branches/safari-610.3.7.1-branch/Source/WebCore/dom/Document.h (269860 => 269861)
--- branches/safari-610.3.7.1-branch/Source/WebCore/dom/Document.h 2020-11-16 18:40:10 UTC (rev 269860)
+++ branches/safari-610.3.7.1-branch/Source/WebCore/dom/Document.h 2020-11-16 18:41:18 UTC (rev 269861)
@@ -1828,7 +1828,7 @@
#endif
#if ENABLE(VIDEO)
- HashSet<HTMLMediaElement*> m_captionPreferencesChangedElements;
+ WeakHashSet<HTMLMediaElement> m_captionPreferencesChangedElements;
WeakPtr<HTMLMediaElement> m_mediaElementShowingTextTrack;
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes