Move isDefaultPortForProtocol from URLParser.cpp back to URL.cpp
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Nov 2016 23:59:03 +0000 (23:59 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Nov 2016 23:59:03 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164439

Reviewed by Daniel Bates.

No change in behaviour.

* platform/URL.cpp:
(WebCore::defaultPortForProtocol):
(WebCore::isDefaultPortForProtocol):
* platform/URLParser.cpp:
(WebCore::URLParser::defaultPortForProtocol):
(WebCore::URLParser::parsePort):
(WebCore::defaultPortForProtocol): Deleted.
(WebCore::isDefaultPortForProtocol): Deleted.
* platform/URLParser.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/URL.cpp
Source/WebCore/platform/URLParser.cpp
Source/WebCore/platform/URLParser.h

index b9ad351..e90c082 100644 (file)
@@ -1,3 +1,22 @@
+2016-11-04  Alex Christensen  <achristensen@webkit.org>
+
+        Move isDefaultPortForProtocol from URLParser.cpp back to URL.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=164439
+
+        Reviewed by Daniel Bates.
+
+        No change in behaviour.
+
+        * platform/URL.cpp:
+        (WebCore::defaultPortForProtocol):
+        (WebCore::isDefaultPortForProtocol):
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::defaultPortForProtocol):
+        (WebCore::URLParser::parsePort):
+        (WebCore::defaultPortForProtocol): Deleted.
+        (WebCore::isDefaultPortForProtocol): Deleted.
+        * platform/URLParser.h:
+
 2016-11-04  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Safari does not emit composition end if blurred for dead key / Japanese IME
index b319049..6388654 100644 (file)
@@ -800,6 +800,16 @@ static void assertProtocolIsGood(StringView protocol)
 
 #endif
 
+Optional<uint16_t> defaultPortForProtocol(StringView protocol)
+{
+    return URLParser::defaultPortForProtocol(protocol);
+}
+
+bool isDefaultPortForProtocol(uint16_t port, StringView protocol)
+{
+    return defaultPortForProtocol(protocol) == port;
+}
+
 bool URL::protocolIs(const char* protocol) const
 {
     assertProtocolIsGood(StringView(reinterpret_cast<const LChar*>(protocol), strlen(protocol)));
index 4bdd978..9a94b5a 100644 (file)
@@ -624,7 +624,7 @@ void URLParser::encodeQuery(const Vector<UChar>& source, const TextEncoding& enc
     }
 }
 
-Optional<uint16_t> defaultPortForProtocol(StringView scheme)
+Optional<uint16_t> URLParser::defaultPortForProtocol(StringView scheme)
 {
     static const uint16_t ftpPort = 21;
     static const uint16_t gopherPort = 70;
@@ -689,11 +689,6 @@ Optional<uint16_t> defaultPortForProtocol(StringView scheme)
     }
 }
 
-bool isDefaultPortForProtocol(uint16_t port, StringView protocol)
-{
-    return defaultPortForProtocol(protocol) == port;
-}
-
 enum class Scheme {
     WS,
     WSS,
@@ -2560,7 +2555,8 @@ bool URLParser::parsePort(CodePointIterator<CharacterType>& iterator)
     if (!port && digitCount > 1)
         syntaxViolation(colonIterator);
 
-    if (UNLIKELY(isDefaultPortForProtocol(port, parsedDataView(0, m_url.m_schemeEnd))))
+    ASSERT(port == static_cast<uint16_t>(port));
+    if (UNLIKELY(defaultPortForProtocol(parsedDataView(0, m_url.m_schemeEnd)) == static_cast<uint16_t>(port)))
         syntaxViolation(colonIterator);
     else {
         appendToASCIIBuffer(':');
index d57cde1..75381b3 100644 (file)
@@ -49,6 +49,9 @@ public:
     static String serialize(const URLEncodedForm&);
 
 private:
+    static Optional<uint16_t> defaultPortForProtocol(StringView);
+    friend Optional<uint16_t> defaultPortForProtocol(StringView);
+
     URL m_url;
     Vector<LChar> m_asciiBuffer;
     bool m_urlIsSpecial { false };