Title: [280594] trunk/Source/WebCore
- Revision
- 280594
- Author
- [email protected]
- Date
- 2021-08-03 09:42:24 -0700 (Tue, 03 Aug 2021)
Log Message
Use WeakPtr instead of manual raw pointer management in URLSearchParams
https://bugs.webkit.org/show_bug.cgi?id=228723
Patch by Alex Christensen <[email protected]> on 2021-08-03
Reviewed by Chris Dumez.
This is less error prone.
* html/DOMURL.cpp:
(WebCore::DOMURL::~DOMURL): Deleted.
* html/DOMURL.h:
* html/URLSearchParams.cpp:
(WebCore::URLSearchParams::URLSearchParams):
* html/URLSearchParams.h:
(WebCore::URLSearchParams::associatedURLDestroyed): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (280593 => 280594)
--- trunk/Source/WebCore/ChangeLog 2021-08-03 15:59:27 UTC (rev 280593)
+++ trunk/Source/WebCore/ChangeLog 2021-08-03 16:42:24 UTC (rev 280594)
@@ -1,3 +1,20 @@
+2021-08-03 Alex Christensen <[email protected]>
+
+ Use WeakPtr instead of manual raw pointer management in URLSearchParams
+ https://bugs.webkit.org/show_bug.cgi?id=228723
+
+ Reviewed by Chris Dumez.
+
+ This is less error prone.
+
+ * html/DOMURL.cpp:
+ (WebCore::DOMURL::~DOMURL): Deleted.
+ * html/DOMURL.h:
+ * html/URLSearchParams.cpp:
+ (WebCore::URLSearchParams::URLSearchParams):
+ * html/URLSearchParams.h:
+ (WebCore::URLSearchParams::associatedURLDestroyed): Deleted.
+
2021-08-03 Youenn Fablet <[email protected]>
ReadableStream's pipeTo() and pipeThrough() don't handle options in spec-perfect way
Modified: trunk/Source/WebCore/html/DOMURL.cpp (280593 => 280594)
--- trunk/Source/WebCore/html/DOMURL.cpp 2021-08-03 15:59:27 UTC (rev 280593)
+++ trunk/Source/WebCore/html/DOMURL.cpp 2021-08-03 16:42:24 UTC (rev 280594)
@@ -67,11 +67,7 @@
return create(url, base.href());
}
-DOMURL::~DOMURL()
-{
- if (m_searchParams)
- m_searchParams->associatedURLDestroyed();
-}
+DOMURL::~DOMURL() = default;
ExceptionOr<void> DOMURL::setHref(const String& url)
{
Modified: trunk/Source/WebCore/html/DOMURL.h (280593 => 280594)
--- trunk/Source/WebCore/html/DOMURL.h 2021-08-03 15:59:27 UTC (rev 280593)
+++ trunk/Source/WebCore/html/DOMURL.h 2021-08-03 16:42:24 UTC (rev 280594)
@@ -29,6 +29,7 @@
#include "ExceptionOr.h"
#include "URLDecomposition.h"
#include <wtf/URL.h>
+#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -37,7 +38,7 @@
class URLRegistrable;
class URLSearchParams;
-class DOMURL final : public RefCounted<DOMURL>, public URLDecomposition {
+class DOMURL final : public RefCounted<DOMURL>, public CanMakeWeakPtr<DOMURL>, public URLDecomposition {
public:
static ExceptionOr<Ref<DOMURL>> create(const String& url, const String& base);
static ExceptionOr<Ref<DOMURL>> create(const String& url, const DOMURL& base);
Modified: trunk/Source/WebCore/html/URLSearchParams.cpp (280593 => 280594)
--- trunk/Source/WebCore/html/URLSearchParams.cpp 2021-08-03 15:59:27 UTC (rev 280593)
+++ trunk/Source/WebCore/html/URLSearchParams.cpp 2021-08-03 16:42:24 UTC (rev 280594)
@@ -31,7 +31,7 @@
namespace WebCore {
URLSearchParams::URLSearchParams(const String& init, DOMURL* associatedURL)
- : m_associatedURL(associatedURL)
+ : m_associatedURL(makeWeakPtr(associatedURL))
, m_pairs(init.startsWith('?') ? WTF::URLParser::parseURLEncodedForm(StringView(init).substring(1)) : WTF::URLParser::parseURLEncodedForm(init))
{
}
Modified: trunk/Source/WebCore/html/URLSearchParams.h (280593 => 280594)
--- trunk/Source/WebCore/html/URLSearchParams.h 2021-08-03 15:59:27 UTC (rev 280593)
+++ trunk/Source/WebCore/html/URLSearchParams.h 2021-08-03 16:42:24 UTC (rev 280594)
@@ -27,6 +27,7 @@
#include "ExceptionOr.h"
#include <wtf/Variant.h>
#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -41,7 +42,6 @@
return adoptRef(*new URLSearchParams(string, associatedURL));
}
- void associatedURLDestroyed() { m_associatedURL = nullptr; }
void append(const String& name, const String& value);
void remove(const String& name);
String get(const String& name) const;
@@ -69,7 +69,7 @@
URLSearchParams(const Vector<WTF::KeyValuePair<String, String>>&);
void updateURL();
- DOMURL* m_associatedURL { nullptr };
+ WeakPtr<DOMURL> m_associatedURL;
Vector<WTF::KeyValuePair<String, String>> m_pairs;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes