diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2017-10-14 00:59:13 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-10-13 22:23:05 +0000 |
commit | 778e0c7c940f8a22f9a43290aef378fb707ca088 (patch) | |
tree | 6c5d94b52c655e1bee56720005236e917603b63b /Source | |
parent | 30af5bd74a1c035f0b3efc73767c0d2bef21333a (diff) | |
download | qtwebkit-778e0c7c940f8a22f9a43290aef378fb707ca088.tar.gz |
Import WebKit commit 85c24b4e854b971f0705bb3411cfd4c0b821f491
Change-Id: I3f9320f43d5d1fc5169a6c1b9dcea454974d6578
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source')
39 files changed, 403 insertions, 194 deletions
diff --git a/Source/WebCore/Scripts/make-js-file-arrays.py b/Source/JavaScriptCore/Scripts/make-js-file-arrays.py index 3116a11bb..65056646a 100755 --- a/Source/WebCore/Scripts/make-js-file-arrays.py +++ b/Source/JavaScriptCore/Scripts/make-js-file-arrays.py @@ -41,24 +41,30 @@ def chunk(list, chunkSize): def main(): - parser = OptionParser(usage="usage: %prog [--no-minify] header source [input [input...]]") + parser = OptionParser(usage="usage: %prog [options] header source [input [input...]]") parser.add_option('--no-minify', action='store_true', help='Do not run the input files through jsmin') + parser.add_option('-n', '--namespace', help='Namespace to use') (options, arguments) = parser.parse_args() + if not options.namespace: + print 'Error: must provide a namespace' + parser.print_usage() + exit(-1) if len(arguments) < 3: print 'Error: must provide at least 3 arguments' parser.print_usage() exit(-1) + namespace = options.namespace headerPath = arguments[0] sourcePath = arguments[1] inputPaths = arguments[2:] headerFile = open(headerPath, 'w') - print >> headerFile, 'namespace WebCore {' + print >> headerFile, 'namespace {0:s} {{'.format(namespace) sourceFile = open(sourcePath, 'w') print >> sourceFile, '#include "{0:s}"'.format(os.path.basename(headerPath)) - print >> sourceFile, 'namespace WebCore {' + print >> sourceFile, 'namespace {0:s} {{'.format(namespace) jsm = JavascriptMinify() @@ -84,8 +90,8 @@ def main(): print >> sourceFile, '};' - print >> headerFile, '}' - print >> sourceFile, '}' + print >> headerFile, '}} // namespace {0:s}'.format(namespace) + print >> sourceFile, '}} // namespace {0:s}'.format(namespace) if __name__ == '__main__': main() diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp index 9e613a212..7d57590b4 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -458,7 +458,10 @@ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->c putDirectWithoutTransition(vm, vm.propertyNames->TypeError, m_typeErrorConstructor.get(), DontEnum); putDirectWithoutTransition(vm, vm.propertyNames->URIError, m_URIErrorConstructor.get(), DontEnum); +#if !PLATFORM(QT) + // Disable ES6 Proxy because our implementation is not compliant with what real world code expects putDirectWithoutTransition(vm, vm.propertyNames->Proxy, ProxyConstructor::create(vm, ProxyConstructor::createStructure(vm, this, m_functionPrototype.get())), DontEnum); +#endif #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \ diff --git a/Source/WTF/wtf/DateMath.cpp b/Source/WTF/wtf/DateMath.cpp index ebcecac6e..80086b379 100644 --- a/Source/WTF/wtf/DateMath.cpp +++ b/Source/WTF/wtf/DateMath.cpp @@ -84,6 +84,7 @@ #include <limits> #include <stdint.h> #include <time.h> +#include <wtf/Optional.h> #include <wtf/text/StringBuilder.h> #if OS(WINDOWS) @@ -892,13 +893,10 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT return std::numeric_limits<double>::quiet_NaN(); dateString = newPosStr; - if (!*dateString) - return std::numeric_limits<double>::quiet_NaN(); - if (day < 0) return std::numeric_limits<double>::quiet_NaN(); - int year = 0; + Optional<int> year; if (day > 31) { // ### where is the boundary and what happens below? if (*dateString != '/') @@ -962,9 +960,11 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT return std::numeric_limits<double>::quiet_NaN(); // '99 23:12:40 GMT' - if (year <= 0 && *dateString) { - if (!parseInt(dateString, &newPosStr, 10, &year)) + if (*dateString && !year) { + int result = 0; + if (!parseInt(dateString, &newPosStr, 10, &result)) return std::numeric_limits<double>::quiet_NaN(); + year = result; } // Don't fail if the time is missing. @@ -979,7 +979,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT if (*newPosStr != ':') return std::numeric_limits<double>::quiet_NaN(); // There was no year; the number was the hour. - year = -1; + year = Nullopt; } else { // in the normal case (we parsed the year), advance to the next number dateString = ++newPosStr; @@ -1049,9 +1049,11 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT } // The year may be after the time but before the time zone. - if (isASCIIDigit(*dateString) && year == -1) { - if (!parseInt(dateString, &newPosStr, 10, &year)) + if (isASCIIDigit(*dateString) && !year) { + int result = 0; + if (!parseInt(dateString, &newPosStr, 10, &result)) return std::numeric_limits<double>::quiet_NaN(); + year = result; dateString = newPosStr; skipSpacesAndComments(dateString); } @@ -1103,9 +1105,11 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT skipSpacesAndComments(dateString); - if (*dateString && year == -1) { - if (!parseInt(dateString, &newPosStr, 10, &year)) + if (*dateString && !year) { + int result = 0; + if (!parseInt(dateString, &newPosStr, 10, &result)) return std::numeric_limits<double>::quiet_NaN(); + year = result; dateString = newPosStr; skipSpacesAndComments(dateString); } @@ -1115,14 +1119,28 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT return std::numeric_limits<double>::quiet_NaN(); // Y2K: Handle 2 digit years. - if (year >= 0 && year < 100) { - if (year < 50) - year += 2000; - else - year += 1900; + if (year) { + int yearValue = year.value(); + if (yearValue >= 0 && yearValue < 100) { + if (yearValue < 50) + yearValue += 2000; + else + yearValue += 1900; + } + year = yearValue; + } else { + // We select 2000 as default value. This is because of the following reasons. + // 1. Year 2000 was used for the initial value of the variable `year`. While it won't be posed to users in WebKit, + // V8 used this 2000 as its default value. (As of April 2017, V8 is using the year 2001 and Spider Monkey is + // not doing this kind of fallback.) + // 2. It is a leap year. When using `new Date("Feb 29")`, we assume that people want to save month and day. + // Leap year can save user inputs if they is valid. If we use the current year instead, the current year + // may not be a leap year. In that case, `new Date("Feb 29").getMonth()` becomes 2 (March). + year = 2000; } + ASSERT(year); - return ymdhmsToSeconds(year, month + 1, day, hour, minute, second) * msPerSecond; + return ymdhmsToSeconds(year.value(), month + 1, day, hour, minute, second) * msPerSecond; } double parseDateFromNullTerminatedCharacters(const char* dateString) diff --git a/Source/WTF/wtf/PlatformQt.cmake b/Source/WTF/wtf/PlatformQt.cmake index 32c8d2c70..684119455 100644 --- a/Source/WTF/wtf/PlatformQt.cmake +++ b/Source/WTF/wtf/PlatformQt.cmake @@ -4,7 +4,7 @@ list(APPEND WTF_SOURCES text/qt/StringQt.cpp ) -QTWEBKIT_GENERATE_MOC_FILES_CPP(qt/MainThreadQt.cpp qt/RunLoopQt.cpp) +QTWEBKIT_GENERATE_MOC_FILES_CPP(WTF qt/MainThreadQt.cpp qt/RunLoopQt.cpp) list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES ${Qt5Core_INCLUDE_DIRS} @@ -33,7 +33,7 @@ if (UNIX AND NOT APPLE) qt/WorkQueueQt.cpp ) - QTWEBKIT_GENERATE_MOC_FILES_CPP(qt/WorkQueueQt.cpp) + QTWEBKIT_GENERATE_MOC_FILES_CPP(WTF qt/WorkQueueQt.cpp) endif () if (USE_GLIB) diff --git a/Source/WTF/wtf/text/StringImpl.h b/Source/WTF/wtf/text/StringImpl.h index 5781c1c08..a1be75637 100644 --- a/Source/WTF/wtf/text/StringImpl.h +++ b/Source/WTF/wtf/text/StringImpl.h @@ -619,25 +619,7 @@ public: *destination = *source; return; } - - if (numCharacters <= s_copyCharsInlineCutOff) { - unsigned i = 0; -#if (CPU(X86) || CPU(X86_64)) - const unsigned charsPerInt = sizeof(uint32_t) / sizeof(T); - - if (numCharacters > charsPerInt) { - unsigned stopCount = numCharacters & ~(charsPerInt - 1); - - const uint32_t* srcCharacters = reinterpret_cast<const uint32_t*>(source); - uint32_t* destCharacters = reinterpret_cast<uint32_t*>(destination); - for (unsigned j = 0; i < stopCount; i += charsPerInt, ++j) - destCharacters[j] = srcCharacters[j]; - } -#endif - for (; i < numCharacters; ++i) - destination[i] = source[i]; - } else - memcpy(destination, source, numCharacters * sizeof(T)); + memcpy(destination, source, numCharacters * sizeof(T)); } ALWAYS_INLINE static void copyChars(UChar* destination, const LChar* source, unsigned numCharacters) @@ -855,9 +837,6 @@ private: return *tailPointer<StringImpl*>(); } - // This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings. - static const unsigned s_copyCharsInlineCutOff = 20; - enum class CaseConvertType { Upper, Lower }; template<CaseConvertType type, typename CharacterType> static Ref<StringImpl> convertASCIICase(StringImpl&, const CharacterType*, unsigned); diff --git a/Source/WTF/wtf/win/WorkItemWin.cpp b/Source/WTF/wtf/win/WorkItemWin.cpp index 33ddf8ed9..7a67ecfaf 100644 --- a/Source/WTF/wtf/win/WorkItemWin.cpp +++ b/Source/WTF/wtf/win/WorkItemWin.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "WorkItemWin.h" -#include <Windows.h> #include <wtf/Threading.h> #include <wtf/WorkQueue.h> diff --git a/Source/WTF/wtf/win/WorkItemWin.h b/Source/WTF/wtf/win/WorkItemWin.h index af3fa1799..92308d832 100644 --- a/Source/WTF/wtf/win/WorkItemWin.h +++ b/Source/WTF/wtf/win/WorkItemWin.h @@ -27,8 +27,8 @@ #ifndef WorkItemWin_h #define WorkItemWin_h -#include <Windows.h> #include <functional> +#include <windows.h> #include <wtf/RefPtr.h> #include <wtf/ThreadSafeRefCounted.h> diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index 7d0ad0433..e1efb9991 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -3558,9 +3558,11 @@ if (WebCore_USER_AGENT_SCRIPTS) MAKE_JS_FILE_ARRAYS( ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentScriptsData.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentScripts.h + WebCore WebCore_USER_AGENT_SCRIPTS WebCore_USER_AGENT_SCRIPTS_DEPENDENCIES ) + list(APPEND WebCore_DERIVED_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentScriptsData.cpp) endif () # Generate plug-in resources diff --git a/Source/WebCore/PlatformQt.cmake b/Source/WebCore/PlatformQt.cmake index c5466b6c7..f0e68cf9e 100644 --- a/Source/WebCore/PlatformQt.cmake +++ b/Source/WebCore/PlatformQt.cmake @@ -110,6 +110,7 @@ list(APPEND WebCore_SOURCES platform/network/NetworkStorageSessionStub.cpp platform/network/MIMESniffing.cpp + platform/network/qt/BlobUrlConversion.cpp platform/network/qt/CookieJarQt.cpp platform/network/qt/CredentialStorageQt.cpp platform/network/qt/DNSQt.cpp @@ -162,19 +163,19 @@ list(APPEND WebCore_SOURCES platform/text/qt/TextBreakIteratorInternalICUQt.cpp ) -QTWEBKIT_GENERATE_MOC_FILES_CPP( +QTWEBKIT_GENERATE_MOC_FILES_CPP(WebCore platform/network/qt/DNSQt.cpp platform/qt/MainThreadSharedTimerQt.cpp ) -QTWEBKIT_GENERATE_MOC_FILES_H( +QTWEBKIT_GENERATE_MOC_FILES_H(WebCore platform/network/qt/CookieJarQt.h platform/network/qt/QNetworkReplyHandler.h platform/network/qt/QtMIMETypeSniffer.h ) -QTWEBKIT_GENERATE_MOC_FILE_H(platform/network/qt/NetworkStateNotifierPrivate.h platform/network/qt/NetworkStateNotifierQt.cpp) -QTWEBKIT_GENERATE_MOC_FILE_H(platform/network/qt/SocketStreamHandlePrivate.h platform/network/qt/SocketStreamHandleQt.cpp) +QTWEBKIT_GENERATE_MOC_FILE_H(WebCore platform/network/qt/NetworkStateNotifierPrivate.h platform/network/qt/NetworkStateNotifierQt.cpp) +QTWEBKIT_GENERATE_MOC_FILE_H(WebCore platform/network/qt/SocketStreamHandlePrivate.h platform/network/qt/SocketStreamHandleQt.cpp) if (COMPILER_IS_GCC_OR_CLANG) set_source_files_properties( @@ -182,6 +183,12 @@ if (COMPILER_IS_GCC_OR_CLANG) PROPERTIES COMPILE_FLAGS "-frtti -UQT_NO_DYNAMIC_CAST" ) + + set_source_files_properties( + platform/network/qt/BlobUrlConversion.cpp + PROPERTIES + COMPILE_FLAGS "-fexceptions -UQT_NO_EXCEPTIONS" + ) endif () if (ENABLE_DEVICE_ORIENTATION) @@ -197,7 +204,7 @@ if (ENABLE_GAMEPAD_DEPRECATED) list(APPEND WebCore_SOURCES platform/qt/GamepadsQt.cpp ) - QTWEBKIT_GENERATE_MOC_FILES_CPP(platform/qt/GamepadsQt.cpp) + QTWEBKIT_GENERATE_MOC_FILES_CPP(WebCore platform/qt/GamepadsQt.cpp) endif () if (ENABLE_GRAPHICS_CONTEXT_3D) @@ -221,7 +228,7 @@ if (ENABLE_NETSCAPE_PLUGIN_API) platform/win/WebCoreInstanceHandle.cpp ) list(APPEND WebCore_LIBRARIES - Shlwapi + shlwapi version ) elseif (PLUGIN_BACKEND_XLIB) @@ -374,7 +381,7 @@ if (USE_QT_MULTIMEDIA) list(APPEND WebCore_LIBRARIES ${Qt5Multimedia_LIBRARIES} ) - QTWEBKIT_GENERATE_MOC_FILES_H(platform/graphics/qt/MediaPlayerPrivateQt.h) + QTWEBKIT_GENERATE_MOC_FILES_H(WebCore platform/graphics/qt/MediaPlayerPrivateQt.h) endif () if (ENABLE_VIDEO) diff --git a/Source/WebCore/bridge/qt/qt_class.cpp b/Source/WebCore/bridge/qt/qt_class.cpp index 5efebc0fd..1554f8d63 100644 --- a/Source/WebCore/bridge/qt/qt_class.cpp +++ b/Source/WebCore/bridge/qt/qt_class.cpp @@ -108,7 +108,7 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, PropertyName id return jsUndefined(); int flags = metaMethod.methodType() == QMetaMethod::Signal ? QtRuntimeMethod::MethodIsSignal : 0; - QtRuntimeMethod* method = new QtRuntimeMethod(context, static_cast<QtInstance*>(inst)->getObject(), normal, index, flags, qtinst); + QtRuntimeMethod* method = new QtRuntimeMethod(static_cast<QtInstance*>(inst)->getObject(), normal, index, flags, qtinst); qtinst->m_methods.insert(name, method); JSValue obj = toJS(method->jsObjectRef(context, &exception)); if (exception) diff --git a/Source/WebCore/bridge/qt/qt_runtime.cpp b/Source/WebCore/bridge/qt/qt_runtime.cpp index 84335e8ca..4859faee3 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.cpp +++ b/Source/WebCore/bridge/qt/qt_runtime.cpp @@ -1230,7 +1230,7 @@ static JSClassRef prototypeForSignalsAndSlots() return cls; } -QtRuntimeMethod::QtRuntimeMethod(JSContextRef ctx, QObject* object, const QByteArray& identifier, int index, int flags, QtInstance* instance) +QtRuntimeMethod::QtRuntimeMethod(QObject* object, const QByteArray& identifier, int index, int flags, QtInstance* instance) : m_object(object) , m_identifier(identifier) , m_index(index) diff --git a/Source/WebCore/bridge/qt/qt_runtime.h b/Source/WebCore/bridge/qt/qt_runtime.h index 34a97244a..c9d675c3f 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.h +++ b/Source/WebCore/bridge/qt/qt_runtime.h @@ -84,7 +84,7 @@ public: AllowPrivate = 2 }; - QtRuntimeMethod(JSContextRef, QObject*, const QByteArray& identifier, int signalIndex, int flags, QtInstance*); + QtRuntimeMethod(QObject*, const QByteArray& identifier, int signalIndex, int flags, QtInstance*); ~QtRuntimeMethod(); static JSValueRef call(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp index ef9bb394e..82d35c1a8 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp @@ -1446,7 +1446,7 @@ Ref<Inspector::Protocol::DOM::EventListener> InspectorDOMAgent::buildObjectForEv JSC::JSLockHolder lock(scriptListener->isolatedWorld().vm()); state = execStateFromNode(scriptListener->isolatedWorld(), &node->document()); handler = scriptListener->jsFunction(&node->document()); - if (handler) { + if (handler && state) { body = handler->toString(state)->value(state); if (auto function = JSC::jsDynamicCast<JSC::JSFunction*>(handler)) { if (!function->isHostOrBuiltinFunction()) { diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp index 35127c647..fb4a63e0b 100644 --- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp +++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp @@ -823,10 +823,17 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida logMemoryCacheResourceRequest(frame(), DiagnosticLoggingKeys::inMemoryCacheKey(), DiagnosticLoggingKeys::unusedReasonErrorKey()); return Reload; } - - // For resources that are not yet loaded we ignore the cache policy. - if (existingResource->isLoading()) + + if (existingResource->isLoading()) { + // Do not use cached main resources that are still loading because sharing + // loading CachedResources in this case causes issues with regards to cancellation. + // If one of the DocumentLoader clients decides to cancel the load, then the load + // would be cancelled for all other DocumentLoaders as well. + if (type == CachedResource::Type::MainResource) + return Reload; + // For cached subresources that are still loading we ignore the cache policy. return Use; + } auto revalidationDecision = existingResource->makeRevalidationDecision(cachePolicy(type)); logResourceRevalidationDecision(revalidationDecision, frame()); diff --git a/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp b/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp index c502a0c3b..8ae96b94c 100644 --- a/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp +++ b/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp @@ -29,7 +29,11 @@ #if ENABLE(GRAPHICS_CONTEXT_3D) #include "TemporaryOpenGLSetting.h" -#if USE(OPENGL_ES_2) +#if PLATFORM(QT) +#define FUNCTIONS m_functions +#include "OpenGLShimsQt.h" +#define glIsEnabled(...) m_functions->glIsEnabled(__VA_ARGS__) +#elif USE(OPENGL_ES_2) #include <GLES2/gl2.h> #include "OpenGLESShims.h" #elif PLATFORM(IOS) @@ -38,10 +42,6 @@ #include <OpenGL/gl.h> #elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) #include "OpenGLShims.h" -#elif PLATFORM(QT) -#define FUNCTIONS m_functions -#include "OpenGLShimsQt.h" -#define glIsEnabled(...) m_functions->glIsEnabled(__VA_ARGS__) #endif namespace WebCore { diff --git a/Source/WebCore/platform/network/qt/BlobUrlConversion.cpp b/Source/WebCore/platform/network/qt/BlobUrlConversion.cpp new file mode 100644 index 000000000..8f61eaeb9 --- /dev/null +++ b/Source/WebCore/platform/network/qt/BlobUrlConversion.cpp @@ -0,0 +1,98 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + Copyright (C) 2017 Konstantin Tokarev <annulen@yandex.ru> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "BlobUrlConversion.h" + +#include "BlobData.h" +#include "BlobRegistryImpl.h" + +#include <QUrl> +#include <wtf/text/Base64.h> + +namespace WebCore { + +static bool appendBlobResolved(Vector<char>& out, const URL& url, QString* contentType = 0) +{ + RefPtr<BlobData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(url); + if (!blobData) + return false; + + if (contentType) + *contentType = blobData->contentType(); + + BlobDataItemList::const_iterator it = blobData->items().begin(); + const BlobDataItemList::const_iterator itend = blobData->items().end(); + for (; it != itend; ++it) { + const BlobDataItem& blobItem = *it; + if (blobItem.type() == BlobDataItem::Type::Data) { + if (!out.tryAppend(reinterpret_cast<const char*>(blobItem.data().data()->data()) + blobItem.offset(), blobItem.length())) + return false; + } else if (blobItem.type() == BlobDataItem::Type::File) { + // File types are not allowed here, so just ignore it. + RELEASE_ASSERT_WITH_MESSAGE(false, "File types are not allowed here"); + } else + ASSERT_NOT_REACHED(); + } + return true; +} + +static QUrl resolveBlobUrl(const URL& url) +{ + RefPtr<BlobData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(url); + if (!blobData) + return QUrl(); + + Vector<char> data; + QString contentType; + if (!appendBlobResolved(data, url, &contentType)) { + qWarning("Failed to convert blob data to base64: cannot allocate memory for continuous blob data"); + return QUrl(); + } + + // QByteArray::{from,to}Base64 are prone to integer overflow, this is the maximum size that can be safe + size_t maxBase64Size = std::numeric_limits<int>::max() / 3 - 1; + + Vector<char> base64; + WTF::base64Encode(data, base64, WTF::Base64URLPolicy); + if (base64.isEmpty() || base64.size() > maxBase64Size) { + qWarning("Failed to convert blob data to base64: data is too large"); + return QUrl(); + } + + QString dataUri(QStringLiteral("data:")); + dataUri.append(contentType); + dataUri.append(QStringLiteral(";base64,")); + dataUri.reserve(dataUri.size() + base64.size()); + dataUri.append(QLatin1String(base64.data(), base64.size())); + return QUrl(dataUri); +} + +QUrl convertBlobToDataUrl(const QUrl& url) +{ + QT_TRY { + return resolveBlobUrl(url); + } QT_CATCH(const std::bad_alloc &) { + qWarning("Failed to convert blob data to base64: not enough memory"); + } + return QUrl(); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/network/qt/BlobUrlConversion.h b/Source/WebCore/platform/network/qt/BlobUrlConversion.h new file mode 100644 index 000000000..2dbd0a680 --- /dev/null +++ b/Source/WebCore/platform/network/qt/BlobUrlConversion.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + Copyright (C) 2017 Konstantin Tokarev <annulen@yandex.ru> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +QT_BEGIN_NAMESPACE +class QUrl; +QT_END_NAMESPACE + +namespace WebCore { + +QUrl convertBlobToDataUrl(const QUrl&); + +} diff --git a/Source/WebCore/platform/network/qt/CookieJarQt.cpp b/Source/WebCore/platform/network/qt/CookieJarQt.cpp index 3b08c06cd..d1cf87fdd 100644 --- a/Source/WebCore/platform/network/qt/CookieJarQt.cpp +++ b/Source/WebCore/platform/network/qt/CookieJarQt.cpp @@ -42,12 +42,21 @@ #include <QNetworkCookie> #include <QStringList> #include <QVariant> +#include <wtf/text/StringBuilder.h> #include <wtf/text/WTFString.h> namespace WebCore { static SharedCookieJarQt* s_sharedCookieJarQt = 0; +static void appendCookie(StringBuilder& builder, const QNetworkCookie& cookie) +{ + if (!builder.isEmpty()) + builder.append("; "); + QByteArray rawData = cookie.toRawForm(QNetworkCookie::NameAndValueOnly); + builder.append(rawData.constData(), rawData.length()); +} + void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const String& value) { QNetworkCookieJar* jar = session.context() ? session.context()->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared(); @@ -59,7 +68,8 @@ void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstPar if (!thirdPartyCookiePolicyPermits(session.context(), urlForCookies, firstPartyUrl)) return; - QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toLatin1()); + CString cookieString = value.latin1(); + QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QByteArray::fromRawData(cookieString.data(), cookieString.length())); QList<QNetworkCookie>::Iterator it = cookies.begin(); while (it != cookies.end()) { if (it->isHttpOnly()) @@ -86,14 +96,13 @@ String cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty if (cookies.isEmpty()) return String(); - QStringList resultCookies; - foreach (const QNetworkCookie& networkCookie, cookies) { - if (networkCookie.isHttpOnly()) + StringBuilder builder; + for (const auto& cookie : cookies) { + if (cookie.isHttpOnly()) continue; - resultCookies.append(QString::fromLatin1(networkCookie.toRawForm(QNetworkCookie::NameAndValueOnly).constData())); + appendCookie(builder, cookie); } - - return resultCookies.join(QLatin1String("; ")); + return builder.toString(); } String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& url) @@ -106,11 +115,10 @@ String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const if (cookies.isEmpty()) return String(); - QStringList resultCookies; - foreach (QNetworkCookie networkCookie, cookies) - resultCookies.append(QString::fromLatin1(networkCookie.toRawForm(QNetworkCookie::NameAndValueOnly).constData())); - - return resultCookies.join(QLatin1String("; ")); + StringBuilder builder; + for (const auto& cookie : cookies) + appendCookie(builder, cookie); + return builder.toString(); } bool cookiesEnabled(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& /*url*/) diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index cd096bfe7..1b60c5131 100644 --- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -647,7 +647,10 @@ void QNetworkReplyHandler::redirect(ResourceResponse& response, const QUrl& redi { ASSERT(!m_queue.deferSignals()); - QUrl newUrl = m_replyWrapper->reply()->url().resolved(redirection); + QUrl currentUrl = m_replyWrapper->reply()->url(); + QUrl newUrl = currentUrl.resolved(redirection); + if (currentUrl.hasFragment()) + newUrl.setFragment(currentUrl.fragment()); ResourceHandleClient* client = m_resourceHandle->client(); ASSERT(client); diff --git a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp index 655724a4c..b7f9447bc 100644 --- a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp @@ -18,14 +18,11 @@ */ #include "config.h" -#include "NetworkingContext.h" #include "ResourceRequest.h" -#include "ThirdPartyCookiesQt.h" - -#include "BlobData.h" -#include "BlobRegistryImpl.h" -#include <qglobal.h> +#include "BlobUrlConversion.h" +#include "NetworkingContext.h" +#include "ThirdPartyCookiesQt.h" #include <QNetworkRequest> #include <QUrl> @@ -43,44 +40,11 @@ unsigned initializeMaximumHTTPConnectionCountPerHost() return 6 * (1 + 3 + 2); } -static void appendBlobResolved(QByteArray& data, const QUrl& url, QString* contentType = 0) +static QUrl toQUrl(const URL& url) { - RefPtr<BlobData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(url); - if (!blobData) - return; - - if (contentType) - *contentType = blobData->contentType(); - - BlobDataItemList::const_iterator it = blobData->items().begin(); - const BlobDataItemList::const_iterator itend = blobData->items().end(); - for (; it != itend; ++it) { - const BlobDataItem& blobItem = *it; - if (blobItem.type() == BlobDataItem::Type::Data) - data.append(reinterpret_cast<const char*>(blobItem.data().data()->data()) + static_cast<int>(blobItem.offset()), static_cast<int>(blobItem.length())); - else if (blobItem.type() == BlobDataItem::Type::File) { - // File types are not allowed here, so just ignore it. - RELEASE_ASSERT_WITH_MESSAGE(false, "File types are not allowed here"); - } else - ASSERT_NOT_REACHED(); - } -} - -static void resolveBlobUrl(const QUrl& url, QUrl& resolvedUrl) -{ - RefPtr<BlobData> blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(url); - if (!blobData) - return; - - QByteArray data; - QString contentType; - appendBlobResolved(data, url, &contentType); - - QString dataUri(QStringLiteral("data:")); - dataUri.append(contentType); - dataUri.append(QStringLiteral(";base64,")); - dataUri.append(QString::fromLatin1(data.toBase64())); - resolvedUrl = QUrl(dataUri); + if (url.protocolIsBlob()) + return convertBlobToDataUrl(url); + return url; } static inline QByteArray stringToByteArray(const String& string) @@ -93,11 +57,7 @@ static inline QByteArray stringToByteArray(const String& string) QNetworkRequest ResourceRequest::toNetworkRequest(NetworkingContext *context) const { QNetworkRequest request; - QUrl newurl = url(); - - if (newurl.scheme() == QLatin1String("blob")) - resolveBlobUrl(url(), newurl); - + QUrl newurl = toQUrl(url()); request.setUrl(newurl); request.setOriginatingObject(context ? context->originatingObject() : 0); diff --git a/Source/WebCore/platform/qt/UserAgentQt.cpp b/Source/WebCore/platform/qt/UserAgentQt.cpp index 4b8876220..fc5eab7a8 100644 --- a/Source/WebCore/platform/qt/UserAgentQt.cpp +++ b/Source/WebCore/platform/qt/UserAgentQt.cpp @@ -37,7 +37,7 @@ namespace WebCore { This implementation returns the following value: - "Mozilla/5.0 (%Platform%%Security%%Subplatform%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Version/9.0 Safari/%WebKitVersion%" + "Mozilla/5.0 (%Platform%%Security%%Subplatform%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Version/10.0 Safari/%WebKitVersion%" In this string the following values are replaced the first time the function is called: \list @@ -58,7 +58,7 @@ String UserAgentQt::standardUserAgent(const String &applicationNameForUserAgent, if (ua.isNull()) { - ua = QStringLiteral("Mozilla/5.0 (%1%2%3) AppleWebKit/%4 (KHTML, like Gecko) %99 Version/9.0 Safari/%5"); + ua = QStringLiteral("Mozilla/5.0 (%1%2%3) AppleWebKit/%4 (KHTML, like Gecko) %99 Version/10.0 Safari/%5"); // Platform. ua = ua.arg( diff --git a/Source/WebCore/rendering/line/BreakingContext.h b/Source/WebCore/rendering/line/BreakingContext.h index 799d2c063..fff452898 100644 --- a/Source/WebCore/rendering/line/BreakingContext.h +++ b/Source/WebCore/rendering/line/BreakingContext.h @@ -559,9 +559,9 @@ inline void BreakingContext::handleReplaced() m_ignoringSpaces = true; } if (downcast<RenderListMarker>(*m_current.renderer()).isInside()) - m_width.addUncommittedWidth(replacedLogicalWidth); + m_width.addUncommittedReplacedWidth(replacedLogicalWidth); } else - m_width.addUncommittedWidth(replacedLogicalWidth); + m_width.addUncommittedReplacedWidth(replacedLogicalWidth); if (is<RenderRubyRun>(*m_current.renderer())) { m_width.applyOverhang(downcast<RenderRubyRun>(m_current.renderer()), m_lastObject, m_nextObject); downcast<RenderRubyRun>(m_current.renderer())->updatePriorContextFromCachedBreakIterator(m_renderTextInfo.lineBreakIterator); @@ -748,7 +748,7 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool bool breakNBSP = m_autoWrap && m_currentStyle->nbspMode() == SPACE; // Auto-wrapping text should wrap in the middle of a word only if it could not wrap before the word, // which is only possible if the word is the first thing on the line. - bool breakWords = m_currentStyle->breakWords() && ((m_autoWrap && !m_width.hasCommitted()) || m_currWS == PRE); + bool breakWords = m_currentStyle->breakWords() && ((m_autoWrap && (!m_width.committedWidth() && !m_width.hasCommittedReplaced())) || m_currWS == PRE); bool midWordBreak = false; bool breakAll = m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWrap; bool keepAllWords = m_currentStyle->wordBreak() == KeepAllWordBreak; diff --git a/Source/WebCore/rendering/line/LineWidth.cpp b/Source/WebCore/rendering/line/LineWidth.cpp index 71e05cb23..b28406d63 100644 --- a/Source/WebCore/rendering/line/LineWidth.cpp +++ b/Source/WebCore/rendering/line/LineWidth.cpp @@ -128,6 +128,10 @@ void LineWidth::commit() { m_committedWidth += m_uncommittedWidth; m_uncommittedWidth = 0; + if (m_hasUncommittedReplaced) { + m_hasCommittedReplaced = true; + m_hasUncommittedReplaced = false; + } m_hasCommitted = true; } diff --git a/Source/WebCore/rendering/line/LineWidth.h b/Source/WebCore/rendering/line/LineWidth.h index 370b3a0f8..bcb274c8e 100644 --- a/Source/WebCore/rendering/line/LineWidth.h +++ b/Source/WebCore/rendering/line/LineWidth.h @@ -60,6 +60,7 @@ public: float logicalLeftOffset() const { return m_left; } bool hasCommitted() const { return m_hasCommitted; } + bool hasCommittedReplaced() const { return m_hasCommittedReplaced; } void updateAvailableWidth(LayoutUnit minimumHeight = 0); void shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject&); @@ -67,6 +68,11 @@ public: { m_uncommittedWidth += delta; } + void addUncommittedReplacedWidth(float delta) + { + addUncommittedWidth(delta); + m_hasUncommittedReplaced = true; + } void commit(); void applyOverhang(RenderRubyRun*, RenderObject* startRenderer, RenderObject* endRenderer); void fitBelowFloats(bool isFirstLine = false); @@ -92,6 +98,8 @@ private: float m_availableWidth { 0 }; bool m_isFirstLine { true }; bool m_hasCommitted { false }; + bool m_hasCommittedReplaced { false }; + bool m_hasUncommittedReplaced { false }; IndentTextOrNot m_shouldIndentText; }; diff --git a/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h b/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h index 6177281c3..0fd56cc65 100644 --- a/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h +++ b/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h @@ -68,6 +68,8 @@ public: m_baseVal = nullptr; else if (&property == m_animVal) m_animVal = nullptr; + if (!m_baseVal && !m_animVal) + detachListWrappers(m_values.size()); } int findItem(SVGProperty* property) diff --git a/Source/WebKit/PlatformQt.cmake b/Source/WebKit/PlatformQt.cmake index 3e50b2552..a192fbd48 100644 --- a/Source/WebKit/PlatformQt.cmake +++ b/Source/WebKit/PlatformQt.cmake @@ -16,10 +16,22 @@ macro(generate_version_header _file _var _prefix) set_source_files_properties(${_file} PROPERTIES GENERATED TRUE) endmacro() +macro(append_lib_names_to_list _lib_names_list) + foreach (_lib_filename ${ARGN}) + get_filename_component(_lib_name_we ${_lib_filename} NAME_WE) + if (NOT MSVC) + string(REGEX REPLACE "^lib" "" _lib_name_we ${_lib_name_we}) + endif () + list(APPEND ${_lib_names_list} ${_lib_name_we}) + endforeach () +endmacro() + if (${JavaScriptCore_LIBRARY_TYPE} MATCHES STATIC) add_definitions(-DSTATICALLY_LINKED_WITH_WTF -DSTATICALLY_LINKED_WITH_JavaScriptCore) endif () +QTWEBKIT_SKIP_AUTOMOC(WebKit) + list(APPEND WebKit_INCLUDE_DIRECTORIES "${WEBCORE_DIR}" "${DERIVED_SOURCES_DIR}" @@ -446,23 +458,21 @@ if (ENABLE_PRINT_SUPPORT) endif () if (QT_STATIC_BUILD) - if (MSVC) - set(LIB_PREFIX "lib") - endif () set(WEBKITWIDGETS_PKGCONGIG_DEPS "${WEBKITWIDGETS_PKGCONGIG_DEPS} Qt5PrintSupport") set(WEBKITWIDGETS_PRI_DEPS "${WEBKITWIDGETS_PRI_DEPS} printsupport") - set(EXTRA_LIBS_NAMES WebCore JavaScriptCore WTF xml2) + set(EXTRA_LIBS_NAMES WebCore JavaScriptCore WTF) + append_lib_names_to_list(EXTRA_LIBS_NAMES ${LIBXML2_LIBRARIES} ${SQLITE_LIBRARIES} ${ZLIB_LIBRARIES}) if (NOT USE_SYSTEM_MALLOC) list(APPEND EXTRA_LIBS_NAMES bmalloc) endif () if (ENABLE_XSLT) - list(APPEND EXTRA_LIBS_NAMES xslt) + append_lib_names_to_list(EXTRA_LIBS_NAMES ${LIBXSLT_LIBRARIES}) endif () if (USE_LIBHYPHEN) - list(APPEND EXTRA_LIBS_NAMES hyphen) + append_lib_names_to_list(EXTRA_LIBS_NAMES ${HYPHEN_LIBRARIES}) endif () if (USE_WEBP) - list(APPEND EXTRA_LIBS_NAMES webp) + append_lib_names_to_list(EXTRA_LIBS_NAMES ${WEBP_LIBRARIES}) endif () if (USE_WOFF2) list(APPEND EXTRA_LIBS_NAMES woff2 brotli) @@ -470,6 +480,7 @@ if (QT_STATIC_BUILD) if (APPLE) list(APPEND EXTRA_LIBS_NAMES icucore) endif () + list(REMOVE_DUPLICATES EXTRA_LIBS_NAMES) foreach (LIB_NAME ${EXTRA_LIBS_NAMES}) set(WEBKIT_PKGCONGIG_DEPS "${WEBKIT_PKGCONGIG_DEPS} ${LIB_PREFIX}${LIB_NAME}") set(WEBKIT_PRI_EXTRA_LIBS "${WEBKIT_PRI_EXTRA_LIBS} -l${LIB_PREFIX}${LIB_NAME}") @@ -786,6 +797,7 @@ if (COMPILER_IS_GCC_OR_CLANG) set_source_files_properties( qt/Api/qwebdatabase.cpp qt/Api/qwebelement.cpp + qt/Api/qwebfullscreenrequest.cpp qt/Api/qwebhistory.cpp qt/Api/qwebhistoryinterface.cpp qt/Api/qwebpluginfactory.cpp @@ -795,7 +807,6 @@ if (COMPILER_IS_GCC_OR_CLANG) qt/WidgetApi/qgraphicswebview.cpp qt/WidgetApi/qwebframe.cpp - qt/WidgetApi/qwebfullscreenrequest.cpp qt/WidgetApi/qwebinspector.cpp qt/WidgetApi/qwebpage.cpp qt/WidgetApi/qwebview.cpp diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 50f91e203..7312792ce 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -1233,7 +1233,9 @@ void FrameLoaderClientQt::startDownload(const WebCore::ResourceRequest& request, if (!m_webFrame) return; - m_webFrame->pageAdapter->emitDownloadRequested(request.toNetworkRequest(m_frame->loader().networkingContext())); + QNetworkRequest r = request.toNetworkRequest(m_frame->loader().networkingContext()); + if (r.url().isValid()) + m_webFrame->pageAdapter->emitDownloadRequested(r); } RefPtr<Frame> FrameLoaderClientQt::createFrame(const URL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp index 79dfb906f..72563a1f9 100644 --- a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp @@ -357,7 +357,7 @@ void InspectorServerRequestHandlerQt::webSocketReadyRead() if (m_inspectorClient) { InspectorController& inspectorController = m_inspectorClient->m_inspectedWebPage->page->inspectorController(); - inspectorController.dispatchMessageFromFrontend(QString::fromUtf8(payload)); + inspectorController.dispatchMessageFromFrontend(String::fromUTF8(payload.data(), payload.size())); } } } diff --git a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp index e6145b6ff..df28e9f21 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp @@ -961,6 +961,8 @@ void QWebFrameAdapter::setViewportSize(const QSize& size) FrameView* view = frame->view(); ASSERT(view); view->resize(size); + if (view->needsLayout()) + view->layout(); view->adjustViewSize(); } diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp index ab9fb1382..89e872fb2 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp @@ -434,6 +434,9 @@ bool QWebPageAdapter::findText(const QString& subString, FindFlag options) if (options & FindBeginsInSelection) webCoreFindOptions |= WebCore::StartInSelection; + if (options & FindAtWordEndingsOnly) + webCoreFindOptions |= WebCore::AtWordEnds; + if (options & HighlightAllOccurrences) { if (subString.isEmpty()) { page->unmarkAllTextMatches(); diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h index 969ce8700..1b7199a9c 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h +++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h @@ -122,7 +122,8 @@ public: HighlightAllOccurrences = 8, FindAtWordBeginningsOnly = 16, TreatMedialCapitalAsWordBeginning = 32, - FindBeginsInSelection = 64 + FindBeginsInSelection = 64, + FindAtWordEndingsOnly = 128 }; // valid values matching those from ScrollTypes.h diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.cpp b/Source/WebKit/qt/WidgetApi/qwebpage.cpp index be8bd3edb..f8d8c0abc 100644 --- a/Source/WebKit/qt/WidgetApi/qwebpage.cpp +++ b/Source/WebKit/qt/WidgetApi/qwebpage.cpp @@ -3161,6 +3161,50 @@ bool QWebPage::extension(Extension extension, const ExtensionOption *option, Ext } #endif + if (extension == ErrorPageExtension) { + auto* errorOption = static_cast<const ErrorPageExtensionOption*>(option); + + QString errorCode; + switch (errorOption->domain) { + case QWebPage::Http: + errorCode = tr("HTTP Error %0").arg(errorOption->error); + break; + case QWebPage::QtNetwork: + errorCode = tr("QtNetwork Error %0").arg(errorOption->error); + break; + case QWebPage::WebKit: + errorCode = tr("WebKit Error %0").arg(errorOption->error); + break; + } + + QString pageHeader = errorOption->errorString; + if (pageHeader.isEmpty()) + pageHeader = errorCode; + else if (pageHeader.endsWith(QLatin1Char('.'))) + pageHeader.chop(1); + + auto* pageOutput = static_cast<ErrorPageExtensionReturn*>(output); + pageOutput->baseUrl = errorOption->url; + QString escapedUrl = errorOption->url.toDisplayString().toHtmlEscaped(); + pageOutput->content = QStringLiteral("<html><head>" + "<meta charset=\"utf-8\">" + "<title>%0</title>" + "<style>" + "html{font-family:sans;background:#EEE;color:#000;}" + "body{max-width:600px;margin:150px auto 0;padding:10px;}" + "pre{text-align:right;color:#999;}" + "</style>" + "</head><body>" + "<h1>%0</h1><hr>" + "<p>%1</p><pre>%2</pre>" + "</body></html>").arg( + pageHeader.toHtmlEscaped(), + tr("Failed to load URL %0.").toHtmlEscaped().arg(QLatin1String("<a href=\"") + escapedUrl + QLatin1String("\">") + escapedUrl + QLatin1String("</a>")), + errorCode.toHtmlEscaped()).toUtf8(); + + return true; + } + return false; } @@ -3172,11 +3216,10 @@ bool QWebPage::extension(Extension extension, const ExtensionOption *option, Ext bool QWebPage::supportsExtension(Extension extension) const { #ifndef QT_NO_FILEDIALOG - return extension == ChooseMultipleFilesExtension; -#else - Q_UNUSED(extension); - return false; + if (extension == ChooseMultipleFilesExtension) + return true; #endif + return extension == ErrorPageExtension; } /*! diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.h b/Source/WebKit/qt/WidgetApi/qwebpage.h index bff0852d7..c3e469102 100644 --- a/Source/WebKit/qt/WidgetApi/qwebpage.h +++ b/Source/WebKit/qt/WidgetApi/qwebpage.h @@ -207,7 +207,9 @@ public: HighlightAllOccurrences = 8, FindAtWordBeginningsOnly = 16, TreatMedialCapitalAsWordBeginning = 32, - FindBeginsInSelection = 64 + FindBeginsInSelection = 64, + FindAtWordEndingsOnly = 128, + FindExactMatchOnly = (FindAtWordBeginningsOnly | FindAtWordEndingsOnly) }; Q_DECLARE_FLAGS(FindFlags, FindFlag) diff --git a/Source/WebKit2/PlatformQt.cmake b/Source/WebKit2/PlatformQt.cmake index 5243ef2d8..6bd0627f0 100644 --- a/Source/WebKit2/PlatformQt.cmake +++ b/Source/WebKit2/PlatformQt.cmake @@ -17,6 +17,8 @@ if (${JavaScriptCore_LIBRARY_TYPE} MATCHES STATIC) add_definitions(-DSTATICALLY_LINKED_WITH_WTF -DSTATICALLY_LINKED_WITH_JavaScriptCore) endif () +QTWEBKIT_SKIP_AUTOMOC(WebKit2) + #set(WebKit2_USE_PREFIX_HEADER ON) list(APPEND WebKit2_INCLUDE_DIRECTORIES @@ -280,25 +282,27 @@ list(APPEND WebProcess_SOURCES qt/MainQt.cpp ) +if (NOT SHARED_CORE) + set(WebProcess_LIBRARIES + WebKit + ) + set(NetworkProcess_LIBRARIES + WebKit + ) + set(DatabaseProcess_LIBRARIES + WebKit + ) + set(PluginProcess_LIBRARIES + WebKit + ) +endif () + # FIXME: Allow building without widgets -set(WebProcess_LIBRARIES - WebKit +list(APPEND WebProcess_LIBRARIES Qt5::Widgets WebKitWidgets ) -set(NetworkProcess_LIBRARIES - WebKit -) - -set(DatabaseProcess_LIBRARIES - WebKit -) - -set(PluginProcess_LIBRARIES - WebKit -) - list(APPEND NetworkProcess_SOURCES NetworkProcess/EntryPoint/qt/NetworkProcessMain.cpp ) diff --git a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp index c6f96f094..14c4db5a3 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp @@ -40,10 +40,11 @@ ****************************************************************************/ #include "config.h" -#include "qwebchannelwebkittransport_p.h" #if ENABLE(QT_WEBCHANNEL) +#include "qwebchannelwebkittransport_p.h" + #include "qquickwebview_p.h" #include <QJsonDocument> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt b/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt index 899a9e038..210342ef5 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt +++ b/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt @@ -84,6 +84,12 @@ set(qmltests_LIBRARIES ${Qt5Test_LIBRARIES} ) +if (SHARED_CORE) + list(APPEND qmltests_LIBRARIES + WebKit2 + ) +endif () + add_executable(tst_qmltests_WebView ${qmltests_SOURCES}) target_compile_definitions(tst_qmltests_WebView PRIVATE ${tst_qmltests_WebView_DEFINITIONS}) target_link_libraries(tst_qmltests_WebView ${qmltests_LIBRARIES}) diff --git a/Source/cmake/OptionsCommon.cmake b/Source/cmake/OptionsCommon.cmake index 529e2bc0d..9c4f00ecd 100644 --- a/Source/cmake/OptionsCommon.cmake +++ b/Source/cmake/OptionsCommon.cmake @@ -32,10 +32,6 @@ if (COMPILER_IS_GCC_OR_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -fno-strict-aliasing") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-strict-aliasing -fno-rtti") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - if (NOT (COMPILER_IS_CLANG AND "${CLANG_VERSION}" VERSION_LESS 4.0.0)) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-expansion-to-defined") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-expansion-to-defined") - endif () endif () if (COMPILER_IS_CLANG AND CMAKE_GENERATOR STREQUAL "Ninja") diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index 457fff566..3fe374647 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -60,7 +60,16 @@ macro(QT_ADD_EXTRA_WEBKIT_TARGET_EXPORT target) endif () endmacro() -macro(QTWEBKIT_GENERATE_MOC_FILES_CPP) +macro(QTWEBKIT_SKIP_AUTOMOC _target) + foreach (_src ${${_target}_SOURCES}) + set_property(SOURCE ${_src} PROPERTY SKIP_AUTOMOC ON) + endforeach () +endmacro() + +macro(QTWEBKIT_GENERATE_MOC_FILES_CPP _target) + if (${ARGC} LESS 2) + message(FATAL_ERROR "QTWEBKIT_GENERATE_MOC_FILES_CPP must be called with at least 2 arguments") + endif () foreach (_file ${ARGN}) get_filename_component(_ext ${_file} EXT) if (NOT _ext STREQUAL ".cpp") @@ -68,12 +77,12 @@ macro(QTWEBKIT_GENERATE_MOC_FILES_CPP) endif () get_filename_component(_name_we ${_file} NAME_WE) set(_moc_name "${CMAKE_CURRENT_BINARY_DIR}/${_name_we}.moc") - qt5_generate_moc(${_file} ${_moc_name}) + qt5_generate_moc(${_file} ${_moc_name} TARGET ${_target}) ADD_SOURCE_DEPENDENCIES(${_file} ${_moc_name}) endforeach () endmacro() -macro(QTWEBKIT_GENERATE_MOC_FILE_H _header _source) +macro(QTWEBKIT_GENERATE_MOC_FILE_H _target _header _source) get_filename_component(_header_ext ${_header} EXT) get_filename_component(_source_ext ${_source} EXT) if ((NOT _header_ext STREQUAL ".h") OR (NOT _source_ext STREQUAL ".cpp")) @@ -81,16 +90,19 @@ macro(QTWEBKIT_GENERATE_MOC_FILE_H _header _source) endif () get_filename_component(_name_we ${_header} NAME_WE) set(_moc_name "${CMAKE_CURRENT_BINARY_DIR}/moc_${_name_we}.cpp") - qt5_generate_moc(${_header} ${_moc_name}) + qt5_generate_moc(${_header} ${_moc_name} TARGET ${_target}) ADD_SOURCE_DEPENDENCIES(${_source} ${_moc_name}) endmacro() -macro(QTWEBKIT_GENERATE_MOC_FILES_H) +macro(QTWEBKIT_GENERATE_MOC_FILES_H _target) + if (${ARGC} LESS 2) + message(FATAL_ERROR "QTWEBKIT_GENERATE_MOC_FILES_H must be called with at least 2 arguments") + endif () foreach (_header ${ARGN}) get_filename_component(_header_dir ${_header} DIRECTORY) get_filename_component(_name_we ${_header} NAME_WE) set(_source "${_header_dir}/${_name_we}.cpp") - QTWEBKIT_GENERATE_MOC_FILE_H(${_header} ${_source}) + QTWEBKIT_GENERATE_MOC_FILE_H(${_target} ${_header} ${_source}) endforeach () endmacro() @@ -558,6 +570,14 @@ if (COMPILER_IS_GCC_OR_CLANG AND UNIX) endif () endif () +# Improvised backport of r222112 - not needed with current WebKit +# -Wexpansion-to-defined produces false positives with GCC but not Clang +# https://bugs.webkit.org/show_bug.cgi?id=167643#c13 +if (CMAKE_COMPILER_IS_GNUCXX AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.0.0")) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-expansion-to-defined") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-expansion-to-defined") +endif () + if (WIN32 AND COMPILER_IS_GCC_OR_CLANG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-keep-inline-dllexport") endif () @@ -611,13 +631,8 @@ if (ENABLE_OPENGL) SET_AND_EXPOSE_TO_BUILD(ENABLE_GRAPHICS_CONTEXT_3D TRUE) # TODO: Add proper support of DynamicGL detection to Qt and use it - if (WIN32) - if (QT_USES_GLES2_ONLY) - # FIXME: Fix build with ANGLE-only Qt - message(FATAL_ERROR "Only dynamic GL is supported on Windows at the moment") - else () - set(Qt5Gui_OPENGL_IMPLEMENTATION GL) - endif () + if (WIN32 AND NOT QT_USES_GLES2_ONLY) + set(Qt5Gui_OPENGL_IMPLEMENTATION GL) endif () endif () diff --git a/Source/cmake/WebKitMacros.cmake b/Source/cmake/WebKitMacros.cmake index 858e2e47d..07e31432a 100644 --- a/Source/cmake/WebKitMacros.cmake +++ b/Source/cmake/WebKitMacros.cmake @@ -377,22 +377,12 @@ macro(GENERATE_WEBKIT2_MESSAGE_SOURCES _output_source _input_files) endforeach () endmacro() -macro(MAKE_JS_FILE_ARRAYS _output_cpp _output_h _scripts _scripts_dependencies) - if (NOT CMAKE_VERSION VERSION_LESS 3.1) - set(_python_path ${CMAKE_COMMAND} -E env "PYTHONPATH=${JavaScriptCore_SCRIPTS_DIR}") - elseif (WIN32) - set(_python_path set "PYTHONPATH=${JavaScriptCore_SCRIPTS_DIR}" &&) - else () - set(_python_path "PYTHONPATH=${JavaScriptCore_SCRIPTS_DIR}") - endif () - +macro(MAKE_JS_FILE_ARRAYS _output_cpp _output_h _namespace _scripts _scripts_dependencies) add_custom_command( OUTPUT ${_output_h} ${_output_cpp} - MAIN_DEPENDENCY ${WEBCORE_DIR}/Scripts/make-js-file-arrays.py - DEPENDS ${${_scripts}} - COMMAND ${_python_path} ${PYTHON_EXECUTABLE} ${WEBCORE_DIR}/Scripts/make-js-file-arrays.py ${_output_h} ${_output_cpp} ${${_scripts}} + DEPENDS ${JavaScriptCore_SCRIPTS_DIR}/make-js-file-arrays.py ${${_scripts}} + COMMAND ${PYTHON_EXECUTABLE} ${JavaScriptCore_SCRIPTS_DIR}/make-js-file-arrays.py -n ${_namespace} ${_output_h} ${_output_cpp} ${${_scripts}} VERBATIM) - list(APPEND WebCore_DERIVED_SOURCES ${_output_cpp}) ADD_SOURCE_DEPENDENCIES(${${_scripts_dependencies}} ${_output_h} ${_output_cpp}) endmacro() |