Rename originsMatch in originSerializationsMatch
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Mar 2019 18:08:17 +0000 (18:08 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Mar 2019 18:08:17 +0000 (18:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195572

Reviewed by Jiewen Tan.

In addition to renaming, make use of SecurityOrigin::isSameOriginAs
where it makes more sense than to compare origin serialization.
The main difference is that isSameOriginAs will return false for two different unique origins
while originsSerializationsMatch will not.

* Modules/credentialmanagement/CredentialsContainer.cpp:
(WebCore::CredentialsContainer::doesHaveSameOriginAsItsAncestors):
* Modules/mediastream/RTCController.cpp:
(WebCore::matchDocumentOrigin):
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::certificatesFromConfiguration):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::shouldOpenExternalURLsPolicyToPropagate const):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest):
* page/SecurityOrigin.cpp:
(WebCore::serializedOriginsMatch):
(WebCore::originsMatch): Deleted.
* page/SecurityOrigin.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242804 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
Source/WebCore/Modules/mediastream/RTCController.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/page/SecurityOrigin.cpp
Source/WebCore/page/SecurityOrigin.h

index 00b57a5..eadeedb 100644 (file)
@@ -1,3 +1,30 @@
+2019-03-12  Youenn Fablet  <youenn@apple.com>
+
+        Rename originsMatch in originSerializationsMatch
+        https://bugs.webkit.org/show_bug.cgi?id=195572
+
+        Reviewed by Jiewen Tan.
+
+        In addition to renaming, make use of SecurityOrigin::isSameOriginAs
+        where it makes more sense than to compare origin serialization.
+        The main difference is that isSameOriginAs will return false for two different unique origins
+        while originsSerializationsMatch will not.
+
+        * Modules/credentialmanagement/CredentialsContainer.cpp:
+        (WebCore::CredentialsContainer::doesHaveSameOriginAsItsAncestors):
+        * Modules/mediastream/RTCController.cpp:
+        (WebCore::matchDocumentOrigin):
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::certificatesFromConfiguration):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::shouldOpenExternalURLsPolicyToPropagate const):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest):
+        * page/SecurityOrigin.cpp:
+        (WebCore::serializedOriginsMatch):
+        (WebCore::originsMatch): Deleted.
+        * page/SecurityOrigin.h:
+
 2019-03-12  Zalan Bujtas  <zalan@apple.com>
 
         [Synthetic Click] Dispatch mouseout soon after mouseup
index cb2760c..7081478 100644 (file)
@@ -54,7 +54,7 @@ bool CredentialsContainer::doesHaveSameOriginAsItsAncestors()
 
     auto& origin = m_document->securityOrigin();
     for (auto* document = m_document->parentDocument(); document; document = document->parentDocument()) {
-        if (!originsMatch(document->securityOrigin(), origin))
+        if (!origin.isSameOriginAs(document->securityOrigin()))
             return false;
     }
     return true;
index cdb777e..70d40c6 100644 (file)
@@ -57,9 +57,9 @@ void RTCController::remove(RTCPeerConnection& connection)
 
 static inline bool matchDocumentOrigin(Document& document, SecurityOrigin& topOrigin, SecurityOrigin& clientOrigin)
 {
-    if (originsMatch(topOrigin, document.securityOrigin()))
+    if (topOrigin.isSameOriginAs(document.securityOrigin()))
         return true;
-    return originsMatch(topOrigin, document.topOrigin()) && originsMatch(clientOrigin, document.securityOrigin());
+    return topOrigin.isSameOriginAs(document.topOrigin()) && clientOrigin.isSameOriginAs(document.securityOrigin());
 }
 
 bool RTCController::shouldDisableICECandidateFiltering(Document& document)
index fd58e0f..a2eb881 100644 (file)
@@ -311,7 +311,7 @@ ExceptionOr<Vector<MediaEndpointConfiguration::CertificatePEM>> RTCPeerConnectio
     Vector<MediaEndpointConfiguration::CertificatePEM> certificates;
     certificates.reserveInitialCapacity(configuration.certificates.size());
     for (auto& certificate : configuration.certificates) {
-        if (!originsMatch(origin, certificate->origin()))
+        if (!origin.isSameOriginAs(certificate->origin()))
             return Exception { InvalidAccessError, "Certificate does not have a valid origin" };
 
         if (currentMilliSeconds > certificate->expires())
index b0f94a5..1b2e21d 100644 (file)
@@ -2083,7 +2083,7 @@ ShouldOpenExternalURLsPolicy DocumentLoader::shouldOpenExternalURLsPolicyToPropa
         return m_shouldOpenExternalURLsPolicy;
 
     if (auto* currentDocument = document()) {
-        if (originsMatch(currentDocument->securityOrigin(), currentDocument->topOrigin()))
+        if (currentDocument->securityOrigin().isSameOriginAs(currentDocument->topOrigin()))
             return m_shouldOpenExternalURLsPolicy;
     }
 
index f426303..7d8c24d 100644 (file)
@@ -638,7 +638,7 @@ bool CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest(const Ca
         break;
     }
 
-    if (resource.options().mode != request.options().mode || !originsMatch(request.origin(), resource.origin()))
+    if (resource.options().mode != request.options().mode || !serializedOriginsMatch(request.origin(), resource.origin()))
         return true;
 
     if (resource.options().redirect != request.options().redirect && resource.hasRedirections())
index 5356653..3990323 100644 (file)
@@ -491,7 +491,7 @@ static inline bool areOriginsMatching(const SecurityOrigin& origin1, const Secur
 }
 
 // This function mimics the result of string comparison of serialized origins.
-bool originsMatch(const SecurityOrigin& origin1, const SecurityOrigin& origin2)
+bool serializedOriginsMatch(const SecurityOrigin& origin1, const SecurityOrigin& origin2)
 {
     if (&origin1 == &origin2)
         return true;
@@ -500,12 +500,12 @@ bool originsMatch(const SecurityOrigin& origin1, const SecurityOrigin& origin2)
     return areOriginsMatching(origin1, origin2);
 }
 
-bool originsMatch(const SecurityOrigin* origin1, const SecurityOrigin* origin2)
+bool serializedOriginsMatch(const SecurityOrigin* origin1, const SecurityOrigin* origin2)
 {
     if (!origin1 || !origin2)
         return origin1 == origin2;
 
-    return originsMatch(*origin1, *origin2);
+    return serializedOriginsMatch(*origin1, *origin2);
 }
 
 Ref<SecurityOrigin> SecurityOrigin::createFromString(const String& originString)
index ed2d9fb..c3355d1 100644 (file)
@@ -240,8 +240,8 @@ private:
 bool shouldTreatAsPotentiallyTrustworthy(const URL&);
 
 // Returns true if the Origin header values serialized from these two origins would be the same.
-bool originsMatch(const SecurityOrigin&, const SecurityOrigin&);
-bool originsMatch(const SecurityOrigin*, const SecurityOrigin*);
+bool serializedOriginsMatch(const SecurityOrigin&, const SecurityOrigin&);
+bool serializedOriginsMatch(const SecurityOrigin*, const SecurityOrigin*);
 
 template<class Encoder> inline void SecurityOrigin::encode(Encoder& encoder) const
 {