Add runtime flag for using URLParser
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Aug 2016 20:19:39 +0000 (20:19 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Aug 2016 20:19:39 +0000 (20:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161363

Reviewed by Sam Weinig.

Source/WebCore:

No new tests.  No change in default behavior.

* PlatformMac.cmake:
* platform/URL.cpp:
(WebCore::URL::URL):
(WebCore::URL::init):
(WebCore::URL::setProtocol):
(WebCore::URL::setHost):
(WebCore::URL::removePort):
(WebCore::URL::setPort):
(WebCore::URL::setHostAndPort):
(WebCore::URL::setUser):
(WebCore::URL::setPass):
(WebCore::URL::setFragmentIdentifier):
(WebCore::URL::removeFragmentIdentifier):
(WebCore::URL::setQuery):
(WebCore::URL::setPath):
(WebCore::URL::parse):
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::setEnabled):
(WebCore::URLParser::enabled):
* platform/URLParser.h:
* platform/cf/URLCF.cpp:
(WebCore::URL::URL):
* platform/cocoa/URLParserCocoa.mm: Added.
(WebCore::URLParser::URLParserEnabled):
* platform/mac/URLMac.mm:
(WebCore::URL::URL):

Source/WebKit2:

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::initializeNetworkProcess):
* NetworkProcess/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode):
(WebKit::NetworkProcessCreationParameters::decode):
* NetworkProcess/NetworkProcessCreationParameters.h:
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* Shared/Cocoa/WebKit2InitializeCocoa.mm: Added.
(WebKit::platformInitializeWebKit2):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
(WebKit::XPCServiceInitializer):
* Shared/WebKit2Initialize.cpp:
(WebKit::InitializeWebKit2):
* Shared/WebKit2Initialize.h:
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* Shared/efl/WebKit2InitializeEFL.cpp: Added.
(WebKit::platformInitializeWebKit2):
* Shared/gtk/WebKit2InitializeGTK.cpp: Added.
(WebKit::platformInitializeWebKit2):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureNetworkProcess):
(WebKit::WebProcessPool::createNewWebProcess):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):

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

26 files changed:
Source/WebCore/ChangeLog
Source/WebCore/PlatformMac.cmake
Source/WebCore/platform/URL.cpp
Source/WebCore/platform/URLParser.cpp
Source/WebCore/platform/URLParser.h
Source/WebCore/platform/cf/URLCF.cpp
Source/WebCore/platform/cocoa/URLParserCocoa.mm [new file with mode: 0644]
Source/WebCore/platform/mac/URLMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.cpp
Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.cpp
Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.h
Source/WebKit2/PlatformEfl.cmake
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/PlatformMac.cmake
Source/WebKit2/Shared/Cocoa/WebKit2InitializeCocoa.mm [new file with mode: 0644]
Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h
Source/WebKit2/Shared/WebKit2Initialize.cpp
Source/WebKit2/Shared/WebKit2Initialize.h
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/Shared/efl/WebKit2InitializeEFL.cpp [new file with mode: 0644]
Source/WebKit2/Shared/gtk/WebKit2InitializeGTK.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebProcess.cpp

index c17f411..92b4441 100644 (file)
@@ -1,3 +1,40 @@
+2016-08-31  Alex Christensen  <achristensen@webkit.org>
+
+        Add runtime flag for using URLParser
+        https://bugs.webkit.org/show_bug.cgi?id=161363
+
+        Reviewed by Sam Weinig.
+
+        No new tests.  No change in default behavior.
+
+        * PlatformMac.cmake:
+        * platform/URL.cpp:
+        (WebCore::URL::URL):
+        (WebCore::URL::init):
+        (WebCore::URL::setProtocol):
+        (WebCore::URL::setHost):
+        (WebCore::URL::removePort):
+        (WebCore::URL::setPort):
+        (WebCore::URL::setHostAndPort):
+        (WebCore::URL::setUser):
+        (WebCore::URL::setPass):
+        (WebCore::URL::setFragmentIdentifier):
+        (WebCore::URL::removeFragmentIdentifier):
+        (WebCore::URL::setQuery):
+        (WebCore::URL::setPath):
+        (WebCore::URL::parse):
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        (WebCore::URLParser::setEnabled):
+        (WebCore::URLParser::enabled):
+        * platform/URLParser.h:
+        * platform/cf/URLCF.cpp:
+        (WebCore::URL::URL):
+        * platform/cocoa/URLParserCocoa.mm: Added.
+        (WebCore::URLParser::URLParserEnabled):
+        * platform/mac/URLMac.mm:
+        (WebCore::URL::URL):
+
 2016-08-31  Youenn Fablet  <youenn@apple.com>
 
         [Fetch API] Fetch API should be able to load data URL in Same Origin mode
index d67e464..f94418e 100644 (file)
@@ -329,6 +329,7 @@ list(APPEND WebCore_SOURCES
     platform/cocoa/SystemVersion.mm
     platform/cocoa/TelephoneNumberDetectorCocoa.cpp
     platform/cocoa/ThemeCocoa.mm
+    platform/cocoa/URLParserCocoa.mm
     platform/cocoa/VNodeTrackerCocoa.cpp
     platform/cocoa/WebCoreNSErrorExtras.mm
 
index c8d6e6d..b3a8f91 100644 (file)
@@ -30,6 +30,7 @@
 #include "DecodeEscapeSequences.h"
 #include "MIMETypeRegistry.h"
 #include "TextEncoding.h"
+#include "URLParser.h"
 #include "UUID.h"
 #include <stdio.h>
 #include <unicode/uidna.h>
@@ -438,27 +439,42 @@ void URL::invalidate()
 
 URL::URL(ParsedURLStringTag, const String& url)
 {
-    parse(url);
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(url);
+        ASSERT(url.isEmpty() && m_string.isEmpty() || url == m_string); // FIXME: Investigate parsing non-null empty ParsedURLStrings.
+    } else {
+        parse(url);
 #if OS(WINDOWS)
-    // FIXME(148598): Work around Windows local file handling bug in CFNetwork
-    ASSERT(isLocalFile() || url == m_string);
+        // FIXME(148598): Work around Windows local file handling bug in CFNetwork
+        ASSERT(isLocalFile() || url == m_string);
 #else
-    ASSERT(url == m_string);
+        ASSERT(url == m_string);
 #endif
+    }
 }
 
 URL::URL(const URL& base, const String& relative)
 {
-    init(base, relative, UTF8Encoding());
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(relative, base);
+    } else
+        init(base, relative, UTF8Encoding());
 }
 
 URL::URL(const URL& base, const String& relative, const TextEncoding& encoding)
 {
-    // For UTF-{7,16,32}, we want to use UTF-8 for the query part as 
-    // we do when submitting a form. A form with GET method
-    // has its contents added to a URL as query params and it makes sense
-    // to be consistent.
-    init(base, relative, encoding.encodingForFormSubmission());
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(relative, base, encoding);
+    } else {
+        // For UTF-{7,16,32}, we want to use UTF-8 for the query part as
+        // we do when submitting a form. A form with GET method
+        // has its contents added to a URL as query params and it makes sense
+        // to be consistent.
+        init(base, relative, encoding.encodingForFormSubmission());
+    }
 }
 
 static bool shouldTrimFromURL(UChar c)
@@ -471,6 +487,9 @@ static bool shouldTrimFromURL(UChar c)
 
 void URL::init(const URL& base, const String& relative, const TextEncoding& encoding)
 {
+    if (URLParser::enabled())
+        ASSERT_NOT_REACHED();
+
     // Allow resolutions with a null or empty base URL, but not with any other invalid one.
     // FIXME: Is this a good rule?
     if (!base.m_isValid && !base.isEmpty()) {
@@ -829,11 +848,20 @@ bool URL::setProtocol(const String& s)
         return false;
 
     if (!m_isValid) {
-        parse(newProtocol + ':' + m_string);
+        if (URLParser::enabled()) {
+            URLParser parser;
+            *this = parser.parse(makeString(newProtocol, ":", m_string));
+        } else
+            parse(newProtocol + ':' + m_string);
         return true;
     }
 
-    parse(newProtocol + m_string.substring(m_schemeEnd));
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(makeString(newProtocol, m_string.substring(m_schemeEnd)));
+    } else
+        parse(newProtocol + m_string.substring(m_schemeEnd));
+
     return true;
 }
 
@@ -900,14 +928,22 @@ void URL::setHost(const String& s)
     builder.append(StringView(encodedHostName.data(), encodedHostName.size()));
     builder.append(m_string.substring(m_hostEnd));
     
-    parse(builder.toString());
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(builder.toString());
+    } else
+        parse(builder.toString());
 }
 
 void URL::removePort()
 {
     if (m_hostEnd == m_portEnd)
         return;
-    parse(m_string.left(m_hostEnd) + m_string.substring(m_portEnd));
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(m_string.left(m_hostEnd) + m_string.substring(m_portEnd));
+    } else
+        parse(m_string.left(m_hostEnd) + m_string.substring(m_portEnd));
 }
 
 void URL::setPort(unsigned short i)
@@ -918,7 +954,11 @@ void URL::setPort(unsigned short i)
     bool colonNeeded = m_portEnd == m_hostEnd;
     unsigned portStart = (colonNeeded ? m_hostEnd : m_hostEnd + 1);
 
-    parse(m_string.left(portStart) + (colonNeeded ? ":" : "") + String::number(i) + m_string.substring(m_portEnd));
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(makeString(m_string.left(portStart), (colonNeeded ? ":" : ""), String::number(i), m_string.substring(m_portEnd)));
+    } else
+        parse(m_string.left(portStart) + (colonNeeded ? ":" : "") + String::number(i) + m_string.substring(m_portEnd));
 }
 
 void URL::setHostAndPort(const String& hostAndPort)
@@ -959,7 +999,11 @@ void URL::setHostAndPort(const String& hostAndPort)
     }
     builder.append(m_string.substring(m_portEnd));
 
-    parse(builder.toString());
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(builder.toString());
+    } else
+        parse(builder.toString());
 }
 
 void URL::setUser(const String& user)
@@ -978,14 +1022,23 @@ void URL::setUser(const String& user)
         // Add '@' if we didn't have one before.
         if (end == m_hostEnd || (end == m_passwordEnd && m_string[end] != '@'))
             u.append('@');
-        parse(m_string.left(m_userStart) + u + m_string.substring(end));
+        if (URLParser::enabled()) {
+            URLParser parser;
+            *this = parser.parse(makeString(m_string.left(m_userStart), u, m_string.substring(end)));
+        } else
+            parse(m_string.left(m_userStart) + u + m_string.substring(end));
     } else {
         // Remove '@' if we now have neither user nor password.
         if (m_userEnd == m_passwordEnd && end != m_hostEnd && m_string[end] == '@')
             end += 1;
         // We don't want to parse in the extremely common case where we are not going to make a change.
-        if (m_userStart != end)
-            parse(m_string.left(m_userStart) + m_string.substring(end));
+        if (m_userStart != end) {
+            if (URLParser::enabled()) {
+                URLParser parser;
+                *this = parser.parse(makeString(m_string.left(m_userStart), m_string.substring(end)));
+            } else
+                parse(m_string.left(m_userStart) + m_string.substring(end));
+        }
     }
 }
 
@@ -1002,14 +1055,23 @@ void URL::setPass(const String& password)
         // Eat the existing '@' since we are going to add our own.
         if (end != m_hostEnd && m_string[end] == '@')
             end += 1;
-        parse(m_string.left(m_userEnd) + p + m_string.substring(end));
+        if (URLParser::enabled()) {
+            URLParser parser;
+            *this = parser.parse(makeString(m_string.left(m_userEnd), p, m_string.substring(end)));
+        } else
+            parse(m_string.left(m_userEnd) + p + m_string.substring(end));
     } else {
         // Remove '@' if we now have neither user nor password.
         if (m_userStart == m_userEnd && end != m_hostEnd && m_string[end] == '@')
             end += 1;
         // We don't want to parse in the extremely common case where we are not going to make a change.
-        if (m_userEnd != end)
-            parse(m_string.left(m_userEnd) + m_string.substring(end));
+        if (m_userEnd != end) {
+            if (URLParser::enabled()) {
+                URLParser parser;
+                *this = parser.parse(makeString(m_string.left(m_userEnd), m_string.substring(end)));
+            } else
+                parse(m_string.left(m_userEnd) + m_string.substring(end));
+        }
     }
 }
 
@@ -1019,14 +1081,23 @@ void URL::setFragmentIdentifier(const String& s)
         return;
 
     // FIXME: Non-ASCII characters must be encoded and escaped to match parse() expectations.
-    parse(m_string.left(m_queryEnd) + "#" + s);
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(makeString(m_string.left(m_queryEnd), "#", s));
+    } else
+        parse(m_string.left(m_queryEnd) + "#" + s);
 }
 
 void URL::removeFragmentIdentifier()
 {
     if (!m_isValid)
         return;
-    parse(m_string.left(m_queryEnd));
+    if (URLParser::enabled()) {
+        // FIXME: We shouldn't need to parse here.
+        URLParser parser;
+        *this = parser.parse(m_string.left(m_queryEnd));
+    } else
+        parse(m_string.left(m_queryEnd));
 }
     
 void URL::setQuery(const String& query)
@@ -1038,10 +1109,19 @@ void URL::setQuery(const String& query)
     // Usually, the query is encoded using document encoding, not UTF-8, but we don't have
     // access to the document in this function.
     // https://webkit.org/b/161176
-    if ((query.isEmpty() || query[0] != '?') && !query.isNull())
-        parse(m_string.left(m_pathEnd) + "?" + query + m_string.substring(m_queryEnd));
-    else
-        parse(m_string.left(m_pathEnd) + query + m_string.substring(m_queryEnd));
+    if ((query.isEmpty() || query[0] != '?') && !query.isNull()) {
+        if (URLParser::enabled()) {
+            URLParser parser;
+            *this = parser.parse(makeString(m_string.left(m_pathEnd), "?", query, m_string.substring(m_queryEnd)));
+        } else
+            parse(m_string.left(m_pathEnd) + "?" + query + m_string.substring(m_queryEnd));
+    } else {
+        if (URLParser::enabled()) {
+            URLParser parser;
+            *this = parser.parse(makeString(m_string.left(m_pathEnd), query, m_string.substring(m_queryEnd)));
+        } else
+            parse(m_string.left(m_pathEnd) + query + m_string.substring(m_queryEnd));
+    }
 
 }
 
@@ -1056,7 +1136,11 @@ void URL::setPath(const String& s)
     if (path.isEmpty() || path[0] != '/')
         path = "/" + path;
 
-    parse(m_string.left(m_portEnd) + encodeWithURLEscapeSequences(path) + m_string.substring(m_pathEnd));
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(makeString(m_string.left(m_portEnd), encodeWithURLEscapeSequences(path), m_string.substring(m_pathEnd)));
+    } else
+        parse(m_string.left(m_portEnd) + encodeWithURLEscapeSequences(path) + m_string.substring(m_pathEnd));
 }
 
 String decodeURLEscapeSequences(const String& string)
@@ -1187,6 +1271,8 @@ static inline bool hasSlashDotOrDotDot(const char* str)
 
 void URL::parse(const String& string)
 {
+    if (URLParser::enabled())
+        ASSERT_NOT_REACHED();
     checkEncodedString(string);
 
     CharBuffer buffer(string.length() + 1);
@@ -1354,6 +1440,8 @@ static bool isCanonicalHostnameLowercaseForScheme(const char* scheme, size_t sch
 
 void URL::parse(const char* url, const String* originalString)
 {
+    if (URLParser::enabled())
+        ASSERT_NOT_REACHED();
     if (!url || url[0] == '\0') {
         // valid URL must be non-empty
         m_string = originalString ? *originalString : url;
index b46f35e..c78ffc4 100644 (file)
@@ -130,6 +130,7 @@ void URLParser::copyURLPartsUntil(const URL& base, URLPart part)
     
 URL URLParser::parse(const String& input, const URL& base, const TextEncoding&)
 {
+    LOG(URLParser, "Parsing URL <%s> base <%s>", input.utf8().data(), base.string().utf8().data());
     m_url = { };
     m_buffer.clear();
     m_authorityOrHostBuffer.clear();
@@ -527,6 +528,7 @@ URL URLParser::parse(const String& input, const URL& base, const TextEncoding&)
 
     m_url.m_string = m_buffer.toString();
     m_url.m_isValid = true;
+    LOG(URLParser, "Parsed URL <%s>", m_url.m_string.utf8().data());
     return m_url;
 }
 
@@ -745,4 +747,16 @@ bool URLParser::allValuesEqual(const URL& a, const URL& b)
         && a.m_fragmentEnd == b.m_fragmentEnd;
 }
 
+static bool urlParserEnabled = false;
+
+void URLParser::setEnabled(bool enabled)
+{
+    urlParserEnabled = enabled;
+}
+
+bool URLParser::enabled()
+{
+    return urlParserEnabled;
+}
+
 } // namespace WebCore
index 2bed378..ae6703e 100644 (file)
@@ -36,6 +36,9 @@ class URLParser {
 public:
     WEBCORE_EXPORT URL parse(const String&, const URL& = { }, const TextEncoding& = UTF8Encoding());
     WEBCORE_EXPORT static bool allValuesEqual(const URL&, const URL&);
+
+    WEBCORE_EXPORT static bool enabled();
+    WEBCORE_EXPORT static void setEnabled(bool);
 private:
     URL m_url;
     StringBuilder m_buffer;
index 04def84..bfb3890 100644 (file)
@@ -27,6 +27,7 @@
 #include "URL.h"
 
 #include "CFURLExtras.h"
+#include "URLParser.h"
 #include <CoreFoundation/CFURL.h>
 #include <wtf/text/CString.h>
 
@@ -46,7 +47,11 @@ URL::URL(CFURLRef url)
     // FIXME: Why is it OK to ignore base URL here?
     CString urlBytes;
     getURLBytes(url, urlBytes);
-    parse(urlBytes.data());
+    if (URLParser::enabled()) {
+        URLParser parser;
+        parser.parse(urlBytes.data());
+    } else
+        parse(urlBytes.data());
 }
 
 #if !USE(FOUNDATION)
diff --git a/Source/WebCore/platform/cocoa/URLParserCocoa.mm b/Source/WebCore/platform/cocoa/URLParserCocoa.mm
new file mode 100644 (file)
index 0000000..db47801
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "URLParser.h"
+
+namespace WebCore {
+    
+bool URLParser::URLParserEnabled()
+{
+    static bool use = [[NSUserDefaults standardUserDefaults] boolForKey:@"URLParserEnabled"];
+    return use;
+}
+
+}
index e5a7d61..5c082e8 100644 (file)
@@ -27,6 +27,7 @@
 #import "URL.h"
 
 #import "CFURLExtras.h"
+#import "URLParser.h"
 #import <wtf/ObjcRuntimeExtras.h>
 #import <wtf/text/CString.h>
 
@@ -42,7 +43,11 @@ URL::URL(NSURL *url)
     // FIXME: Why is it OK to ignore base URL here?
     CString urlBytes;
     getURLBytes(reinterpret_cast<CFURLRef>(url), urlBytes);
-    parse(urlBytes.data());
+    if (URLParser::enabled()) {
+        URLParser parser;
+        *this = parser.parse(urlBytes.data());
+    } else
+        parse(urlBytes.data());
 }
 
 URL::operator NSURL *() const
index 7b1c2b4..ceac203 100644 (file)
@@ -1,3 +1,41 @@
+2016-08-31  Alex Christensen  <achristensen@webkit.org>
+
+        Add runtime flag for using URLParser
+        https://bugs.webkit.org/show_bug.cgi?id=161363
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeNetworkProcess):
+        * NetworkProcess/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode):
+        (WebKit::NetworkProcessCreationParameters::decode):
+        * NetworkProcess/NetworkProcessCreationParameters.h:
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * PlatformMac.cmake:
+        * Shared/Cocoa/WebKit2InitializeCocoa.mm: Added.
+        (WebKit::platformInitializeWebKit2):
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
+        (WebKit::XPCServiceInitializer):
+        * Shared/WebKit2Initialize.cpp:
+        (WebKit::InitializeWebKit2):
+        * Shared/WebKit2Initialize.h:
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * Shared/efl/WebKit2InitializeEFL.cpp: Added.
+        (WebKit::platformInitializeWebKit2):
+        * Shared/gtk/WebKit2InitializeGTK.cpp: Added.
+        (WebKit::platformInitializeWebKit2):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::ensureNetworkProcess):
+        (WebKit::WebProcessPool::createNewWebProcess):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+
 2016-08-30  Anders Carlsson  <andersca@apple.com>
 
         Use Connection::sendWithReply for the SecItem shim messages
index bca3f47..cfe05f4 100644 (file)
@@ -59,6 +59,7 @@
 #include <WebCore/SecurityOriginData.h>
 #include <WebCore/SecurityOriginHash.h>
 #include <WebCore/SessionID.h>
+#include <WebCore/URLParser.h>
 #include <wtf/OptionSet.h>
 #include <wtf/RunLoop.h>
 #include <wtf/text/CString.h>
@@ -196,6 +197,8 @@ void NetworkProcess::lowMemoryHandler(Critical critical)
 
 void NetworkProcess::initializeNetworkProcess(NetworkProcessCreationParameters&& parameters)
 {
+    URLParser::setEnabled(parameters.urlParserEnabled);
+
     platformInitializeNetworkProcess(parameters);
 
     WTF::setCurrentThreadIsUserInitiated();
index bcdba74..413b7d8 100644 (file)
@@ -63,6 +63,7 @@ void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const
 #endif
     encoder << shouldSuppressMemoryPressureHandler;
     encoder << shouldUseTestingNetworkSession;
+    encoder << urlParserEnabled;
     encoder << urlSchemesRegisteredForCustomProtocols;
 #if PLATFORM(COCOA)
     encoder << parentProcessName;
@@ -128,6 +129,8 @@ bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProc
         return false;
     if (!decoder.decode(result.shouldUseTestingNetworkSession))
         return false;
+    if (!decoder.decode(result.urlParserEnabled))
+        return false;
     if (!decoder.decode(result.urlSchemesRegisteredForCustomProtocols))
         return false;
 #if PLATFORM(COCOA)
index e4722b8..895e0a5 100644 (file)
@@ -72,6 +72,7 @@ struct NetworkProcessCreationParameters {
 #endif
     bool shouldSuppressMemoryPressureHandler { false };
     bool shouldUseTestingNetworkSession;
+    bool urlParserEnabled { false };
 
     Vector<String> urlSchemesRegisteredForCustomProtocols;
 
index faa7bb3..c17af03 100644 (file)
@@ -47,6 +47,7 @@ list(APPEND WebKit2_SOURCES
     Shared/efl/NativeWebWheelEventEfl.cpp
     Shared/efl/ProcessExecutablePathEfl.cpp
     Shared/efl/WebEventFactory.cpp
+    Shared/efl/WebKit2InitializeEFL.cpp
 
     Shared/linux/WebMemorySamplerLinux.cpp
 
index 0980f55..c001a11 100644 (file)
@@ -74,6 +74,7 @@ list(APPEND WebKit2_SOURCES
     Shared/gtk/ProcessExecutablePathGtk.cpp
     Shared/gtk/WebContextMenuItemGtk.cpp
     Shared/gtk/WebEventFactory.cpp
+    Shared/gtk/WebKit2InitializeGTK.cpp
 
     Shared/linux/WebMemorySamplerLinux.cpp
 
@@ -773,6 +774,7 @@ if (ENABLE_PLUGIN_PROCESS_GTK2)
         Shared/gtk/NativeWebWheelEventGtk.cpp
         Shared/gtk/ProcessExecutablePathGtk.cpp
         Shared/gtk/WebEventFactory.cpp
+        Shared/gtk/WebKit2InitializeGTK.cpp
 
         Shared/soup/WebCoreArgumentCodersSoup.cpp
 
index 54ae4a7..9be28b7 100644 (file)
@@ -99,6 +99,7 @@ list(APPEND WebKit2_SOURCES
     Shared/Cocoa/CompletionHandlerCallChecker.mm
     Shared/Cocoa/DataDetectionResult.mm
     Shared/Cocoa/LoadParametersCocoa.mm
+    Shared/Cocoa/WebKit2InitializeCocoa.mm
     Shared/Cocoa/WKNSArray.mm
     Shared/Cocoa/WKNSData.mm
     Shared/Cocoa/WKNSDictionary.mm
diff --git a/Source/WebKit2/Shared/Cocoa/WebKit2InitializeCocoa.mm b/Source/WebKit2/Shared/Cocoa/WebKit2InitializeCocoa.mm
new file mode 100644 (file)
index 0000000..86b5143
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WebKit2Initialize.h"
+
+#import <WebCore/RuntimeApplicationChecks.h>
+#import <WebCore/URLParser.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void platformInitializeWebKit2(ProcessType processType)
+{
+    static dispatch_once_t initOnce;
+    
+    // We don't want to use NSUserDefaults in the child processes.
+    if (processType == UIProcess) {
+        dispatch_once(&initOnce, ^ {
+            URLParser::setEnabled([[NSUserDefaults standardUserDefaults] boolForKey:@"URLParserEnabled"]);
+        });
+    }
+}
+
+}
index 6d42455..9c80e0f 100644 (file)
@@ -75,7 +75,7 @@ void XPCServiceInitializer(OSObjectPtr<xpc_connection_t> connection, xpc_object_
     // so ensure that we have an outstanding transaction here.
     xpc_transaction_begin();
 
-    InitializeWebKit2();
+    InitializeWebKit2(ChildProcess);
 
     if (!delegate.checkEntitlements())
         exit(EXIT_FAILURE);
index 6e81d8a..47dfc9f 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "LogInitialization.h"
 #include <WebCore/LogInitialization.h>
+#include <WebCore/URLParser.h>
 #include <runtime/InitializeThreading.h>
 #include <wtf/MainThread.h>
 #include <wtf/RunLoop.h>
 
 namespace WebKit {
 
-void InitializeWebKit2()
+void InitializeWebKit2(ProcessType processType)
 {
 #if PLATFORM(COCOA)
     InitWebCoreSystemInterface();
 #endif
+    platformInitializeWebKit2(processType);
 #if PLATFORM(IOS)
     InitWebCoreThreadSystemInterface();
 #endif
index db91d07..e053b5f 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebKit2Initialize_h
-#define WebKit2Initialize_h
+#pragma once
 
 namespace WebKit {
 
-void InitializeWebKit2();
-
+enum ProcessType {
+    ChildProcess,
+    UIProcess,
 };
 
-#endif // WebKit2Initialize_h
+void InitializeWebKit2(ProcessType = UIProcess);
+void platformInitializeWebKit2(ProcessType);
+
+};
index 2198fc9..a755260 100644 (file)
@@ -115,6 +115,7 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << uiProcessBundleResourcePathExtensionHandle;
     encoder << shouldEnableJIT;
     encoder << shouldEnableFTLJIT;
+    encoder << urlParserEnabled;
     encoder << !!bundleParameterData;
     if (bundleParameterData)
         encoder << bundleParameterData->dataReference();
@@ -259,6 +260,8 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat
         return false;
     if (!decoder.decode(parameters.shouldEnableFTLJIT))
         return false;
+    if (!decoder.decode(parameters.urlParserEnabled))
+        return false;
 
     bool hasBundleParameterData;
     if (!decoder.decode(hasBundleParameterData))
index c26c4bf..bdf4631 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebProcessCreationParameters_h
-#define WebProcessCreationParameters_h
+#pragma once
 
 #include "CacheModel.h"
 #include "SandboxExtension.h"
@@ -108,6 +107,7 @@ struct WebProcessCreationParameters {
     bool shouldSuppressMemoryPressureHandler { false };
     bool shouldUseFontSmoothing;
     bool resourceLoadStatisticsEnabled { false };
+    bool urlParserEnabled { false };
 
     Vector<String> fontWhitelist;
 
@@ -177,5 +177,3 @@ struct WebProcessCreationParameters {
 };
 
 } // namespace WebKit
-
-#endif // WebProcessCreationParameters_h
diff --git a/Source/WebKit2/Shared/efl/WebKit2InitializeEFL.cpp b/Source/WebKit2/Shared/efl/WebKit2InitializeEFL.cpp
new file mode 100644 (file)
index 0000000..14f0763
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebKit2Initialize.h"
+
+namespace WebKit {
+
+void platformInitializeWebKit2(ProcessType)
+{
+}
+
+}
diff --git a/Source/WebKit2/Shared/gtk/WebKit2InitializeGTK.cpp b/Source/WebKit2/Shared/gtk/WebKit2InitializeGTK.cpp
new file mode 100644 (file)
index 0000000..14f0763
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebKit2Initialize.h"
+
+namespace WebKit {
+
+void platformInitializeWebKit2(ProcessType)
+{
+}
+
+}
index b782812..013b7d5 100644 (file)
@@ -69,6 +69,7 @@
 #include <WebCore/LogInitialization.h>
 #include <WebCore/ResourceRequest.h>
 #include <WebCore/SessionID.h>
+#include <WebCore/URLParser.h>
 #include <runtime/JSCInlines.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MainThread.h>
@@ -386,6 +387,8 @@ NetworkProcessProxy& WebProcessPool::ensureNetworkProcess()
 
     parameters.shouldUseTestingNetworkSession = m_shouldUseTestingNetworkSession;
 
+    parameters.urlParserEnabled = URLParser::enabled();
+    
     // Add any platform specific parameters
     platformInitializeNetworkProcess(parameters);
 
@@ -547,6 +550,8 @@ WebProcessProxy& WebProcessPool::createNewWebProcess()
 
     WebProcessCreationParameters parameters;
 
+    parameters.urlParserEnabled = URLParser::enabled();
+    
     parameters.injectedBundlePath = injectedBundlePath();
     if (!parameters.injectedBundlePath.isEmpty())
         SandboxExtension::createHandle(parameters.injectedBundlePath, SandboxExtension::ReadOnly, parameters.injectedBundlePathExtensionHandle);
index c4e9877..eeb5fcc 100644 (file)
                5C20CBA01BB1ECD800895BB1 /* NetworkSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C20CB9E1BB0DD1800895BB1 /* NetworkSession.h */; };
                5C298DA01C3DF02100470AFE /* PendingDownload.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C298D9E1C3DEF2900470AFE /* PendingDownload.h */; };
                5C7706741D1138380012700F /* WebSocketProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C7706731D111D8B0012700F /* WebSocketProvider.cpp */; };
+               5C79439B1D762D62003102D4 /* WebKit2InitializeCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C79439A1D762CDF003102D4 /* WebKit2InitializeCocoa.mm */; };
                5C85C7881C3F23CE0061A4FA /* PendingDownload.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C85C7861C3F23C50061A4FA /* PendingDownload.cpp */; };
                5CBC9B8D1C65279C00A8FDCF /* NetworkDataTaskCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */; };
                5CBC9B8E1C652CA000A8FDCF /* NetworkDataTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */; };
                5C20CB9E1BB0DD1800895BB1 /* NetworkSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkSession.h; path = NetworkProcess/NetworkSession.h; sourceTree = "<group>"; };
                5C298D9E1C3DEF2900470AFE /* PendingDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PendingDownload.h; path = NetworkProcess/Downloads/PendingDownload.h; sourceTree = "<group>"; };
                5C7706731D111D8B0012700F /* WebSocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketProvider.cpp; path = Network/WebSocketProvider.cpp; sourceTree = "<group>"; };
+               5C79439A1D762CDF003102D4 /* WebKit2InitializeCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKit2InitializeCocoa.mm; sourceTree = "<group>"; };
                5C7C88DC1D0F41A0009D2F6D /* WebSocketProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketProvider.h; path = Network/WebSocketProvider.h; sourceTree = "<group>"; };
                5C85C7861C3F23C50061A4FA /* PendingDownload.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PendingDownload.cpp; path = NetworkProcess/Downloads/PendingDownload.cpp; sourceTree = "<group>"; };
                5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkDataTask.h; path = NetworkProcess/NetworkDataTask.h; sourceTree = "<group>"; };
                37C4C0901814B37B003688B9 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
+                               5C79439A1D762CDF003102D4 /* WebKit2InitializeCocoa.mm */,
                                1A1EF1971A1D5B420023200A /* APIDataCocoa.mm */,
                                378E1A3B181ED6FF0031007A /* APIObject.mm */,
                                37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */,
                                BC407605124FF0270068F20A /* WKString.cpp in Sources */,
                                BC407619124FF0370068F20A /* WKStringCF.mm in Sources */,
                                26F10BE919187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.m in Sources */,
+                               5C79439B1D762D62003102D4 /* WebKit2InitializeCocoa.mm in Sources */,
                                2DD67A361BD861060053B251 /* WKTextFinderClient.mm in Sources */,
                                0FCB4E6918BBE3D9000FCFC9 /* WKTextInputWindowController.mm in Sources */,
                                BC407607124FF0270068F20A /* WKType.cpp in Sources */,
index 0d16e76..8457fd7 100644 (file)
 #include <WebCore/SchemeRegistry.h>
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/Settings.h>
+#include <WebCore/URLParser.h>
 #include <WebCore/UserGestureIndicator.h>
 #include <unistd.h>
 #include <wtf/CurrentTime.h>
@@ -260,6 +261,8 @@ void WebProcess::initializeConnection(IPC::Connection* connection)
 
 void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
 {
+    URLParser::setEnabled(parameters.urlParserEnabled);
+    
     ASSERT(m_pageMap.isEmpty());
 
 #if OS(LINUX)