diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-11-08 15:51:03 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:31:13 +0000 |
commit | 8f2cfe80a5fb6632b4bbb9181db28f0505058128 (patch) | |
tree | 51ed8e62f4c49597f1b695dcc01137cce0b8a812 | |
parent | 5ae3854f795ac5c1a0f104bd8b66ed6f988181cd (diff) | |
download | qtwebkit-8f2cfe80a5fb6632b4bbb9181db28f0505058128.tar.gz |
Imported WebKit commit 26dda242e41e9b4d348fc3573d86f58b9e8b51b9
Change-Id: I00833927c575184923449ab99c85c46fec94dc19
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
-rw-r--r-- | .qmake.conf | 5 | ||||
-rw-r--r-- | Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp | 10 | ||||
-rw-r--r-- | Source/WebCore/platform/network/qt/ResourceHandleQt.cpp | 21 | ||||
-rw-r--r-- | Source/WebKit/PlatformQt.cmake | 1 | ||||
-rw-r--r-- | Tools/qmake/mkspecs/features/functions.prf | 122 | ||||
-rw-r--r-- | Tools/qmake/projects/generate_cmake_toolchain_file.pro | 50 | ||||
-rw-r--r-- | Tools/qmake/projects/qtjpeg/qtjpeg.pro | 24 | ||||
-rw-r--r-- | Tools/qmake/projects/qtpng/qtpng.pro | 49 | ||||
-rw-r--r-- | Tools/qmake/projects/run_cmake.pro | 69 | ||||
-rw-r--r-- | Tools/qt/manifest.txt | 4 | ||||
-rw-r--r-- | WebKit.pro | 20 |
11 files changed, 368 insertions, 7 deletions
diff --git a/.qmake.conf b/.qmake.conf new file mode 100644 index 000000000..44b1ec1f4 --- /dev/null +++ b/.qmake.conf @@ -0,0 +1,5 @@ +load(qt_build_config) +QMAKEPATH += $$PWD/Tools/qmake + +ROOT_WEBKIT_DIR = $$PWD +ROOT_BUILD_DIR = $$shadowed($$PWD) diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index 306f99e0e..69c72309f 100644 --- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -30,6 +30,7 @@ #include "ResourceHandleInternal.h" #include "ResourceRequest.h" #include "ResourceResponse.h" +#include "SharedBuffer.h" #include <QDateTime> #include <QFile> #include <QFileInfo> @@ -672,21 +673,22 @@ void QNetworkReplyHandler::forwardData() return; qint64 bytesAvailable = m_replyWrapper->reply()->bytesAvailable(); - char* buffer = new char[8128]; // smaller than 8192 to fit within 8k including overhead. + Vector<char> buffer(8128); // smaller than 8192 to fit within 8k including overhead. while (bytesAvailable > 0 && !m_queue.deferSignals()) { - qint64 readSize = m_replyWrapper->reply()->read(buffer, 8128); + qint64 readSize = m_replyWrapper->reply()->read(buffer.data(), buffer.size()); if (readSize <= 0) break; + buffer.shrink(readSize); bytesAvailable -= readSize; + // FIXME: https://bugs.webkit.org/show_bug.cgi?id=19793 // -1 means we do not provide any data about transfer size to inspector so it would use // Content-Length headers or content size to show transfer size. - client->didReceiveData(m_resourceHandle, buffer, readSize, -1); + client->didReceiveBuffer(m_resourceHandle, SharedBuffer::adoptVector(buffer), -1); // Check if the request has been aborted or this reply-handler was otherwise released. if (wasAborted() || !m_replyWrapper) break; } - delete[] buffer; if (bytesAvailable > 0 && m_replyWrapper) m_queue.requeue(&QNetworkReplyHandler::forwardData); } diff --git a/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp b/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp index 674265a69..64c5e47e8 100644 --- a/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp @@ -49,7 +49,7 @@ namespace WebCore { -class WebCoreSynchronousLoader : public ResourceHandleClient { +class WebCoreSynchronousLoader final : public ResourceHandleClient { public: WebCoreSynchronousLoader(ResourceError& error, ResourceResponse& response, Vector<char>& data) : m_error(error) @@ -59,7 +59,8 @@ public: void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&) override; void didReceiveResponse(ResourceHandle*, const ResourceResponse& response) override { m_response = response; } - void didReceiveData(ResourceHandle*, const char* data, unsigned length, int) override { m_data.append(data, length); } + void didReceiveData(ResourceHandle*, const char*, unsigned, int) override; + void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int /*encodedDataLength*/) override; void didFinishLoading(ResourceHandle*, double /*finishTime*/) override {} void didFail(ResourceHandle*, const ResourceError& error) override { m_error = error; } private: @@ -79,6 +80,22 @@ void WebCoreSynchronousLoader::willSendRequest(ResourceHandle* handle, ResourceR } } +void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char*, unsigned, int) +{ + ASSERT_NOT_REACHED(); +} + +void WebCoreSynchronousLoader::didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int) +{ + // This pattern is suggested by SharedBuffer.h. + const char* segment; + unsigned position = 0; + while (unsigned length = buffer->getSomeData(segment, position)) { + m_data.append(segment, length); + position += length; + } +} + ResourceHandleInternal::~ResourceHandleInternal() { } diff --git a/Source/WebKit/PlatformQt.cmake b/Source/WebKit/PlatformQt.cmake index 81f7e95f6..8c051974b 100644 --- a/Source/WebKit/PlatformQt.cmake +++ b/Source/WebKit/PlatformQt.cmake @@ -214,6 +214,7 @@ list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Positioning_INCLUDE_DIRS} + ${SQLITE_INCLUDE_DIR} ) # Build the include path with duplicates removed list(REMOVE_DUPLICATES WebKit_SYSTEM_INCLUDE_DIRECTORIES) diff --git a/Tools/qmake/mkspecs/features/functions.prf b/Tools/qmake/mkspecs/features/functions.prf new file mode 100644 index 000000000..daab9b8b5 --- /dev/null +++ b/Tools/qmake/mkspecs/features/functions.prf @@ -0,0 +1,122 @@ +EOL = $$escape_expand(\\n) + +WEBKIT_SUBDIR = $$relative_path($$_PRO_FILE_PWD_, $$ROOT_WEBKIT_DIR) +QTBASE_DIR = $$ROOT_WEBKIT_DIR/../qtbase + +defineTest(isQtMinimum) { + !equals(QT_MAJOR_VERSION, $$1): return(false) + count(ARGS, 1, greaterThan) { + lessThan(QT_MINOR_VERSION, $$2): return(false) + } + return(true) +} + +!isQtMinimum(5, 8) { + defineTest(qtConfig) { + contains(QT_CONFIG, $$1): return(true) + return(false) + } +} + +defineTest(isVersionAtLeast) { + have_version = $$split(1, .) + want_version = $$split(2, .) + num_components = $$size(have_version) + + # FIXME: Off-by-one. Mostly harmless, but still replace it with 0..$$num_add($$num_digits, -1) when Qt 5.7 compatibility is dropped. + for (i, 0..$$num_components) { + have_component = $$member(have_version, $$i) + want_component = $$member(want_version, $$i) + greaterThan(have_component, $$want_component): return(true) + lessThan(have_component, $$want_component): return(false) + } + return(true) +} + +defineReplace(cmakeVersion) { + cmake_version_output = $$system("cmake --version", lines) + cmake_version_string = $$first(cmake_version_output) + # Format is "cmake version X.Y.Z" + cmake_version_words = $$split(cmake_version_string) + return($$last(cmake_version_words)) +} + +defineReplace(appleSdkVersion) { + return($$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version ProductVersion 2>/dev/null")) +} + +defineTest(isPlatformSupported) { + cross_compile: skipBuild("cross-compilation of QtWebKit with qmake is not supported yet") + + requiredPrograms = cmake gperf python perl bison ruby flex + for(program, requiredPrograms): \ + !programExistsInPath($$program): \ + skipBuild("Missing $$program from PATH") + + cmake_version = $$cmakeVersion() + !isVersionAtLeast($$cmake_version, "2.8.12") { + skipBuild("Using cmake version $$cmake_version, but at least cmake 2.8.12 is required to build QtWebKit.") + } + + win32 { + winrt { + skipBuild("WinRT is not supported.") + } + msvc { + !isVersionAtLeast($$MSVC_VER, "14.0") { + skipBuild("QtWebKit on Windows requires MSVC 2015.") + } + } else { + isGCCVersionSupported() + } + } else: macos { + # We require macOS 10.10 (darwin version 14.0.0) or newer + darwin_major_version = $$section(QMAKE_HOST.version, ., 0, 0) + lessThan(darwin_major_version, 14) { + skipBuild("QtWebKit requires macOS version 10.10 or newer.") + } + sdk_version = $$appleSdkVersion() + !isVersionAtLeast($$sdk_version, "10.10") { + skipBuild("QtWebKit requires an macOS SDK version of 10.10 or newer. Current version is $${sdk_version}.") + } + } else { + android: skipBuild("Android is not supported.") + uikit: skipBuild("UIKit platforms are not supported.") + qnx: skipBuild("QNX is not supported.") + + gcc:!clang: isGCCVersionSupported() + } + + !contains(QT_CONFIG, c++11) { + skipBuild("C++11 support is required in order to build QtWebKit.") + } + + isEmpty(skipBuildReason): return(true) + return(false) +} + +defineTest(isGCCVersionSupported) { + gcc_version = $${QT_GCC_MAJOR_VERSION}.$${QT_GCC_MINOR_VERSION} + isVersionAtLeast($$gcc_version, "4.9"): return(true) + skipBuild("Using gcc version $$gcc_version, but at least gcc version 4.9 is required to build QtWebKit.") + return(false) +} + +defineTest(programExistsInPath) { + equals(QMAKE_HOST.os, Windows): program = $${1}.exe + else: program = $$1 + + PATH = $$(PATH) + paths = $$split(PATH, $$QMAKE_DIRLIST_SEP) + + GNUTOOLS_DIR = $$ROOT_WEBKIT_DIR/../gnuwin32/bin + exists($$GNUTOOLS_DIR): paths += $$GNUTOOLS_DIR + + for(p, paths): exists($$p/$$program): return(true) + return(false) +} + +defineTest(skipBuild) { + skipBuildReason = "$$skipBuildReason$${EOL} * $$1" + export(skipBuildReason) +} diff --git a/Tools/qmake/projects/generate_cmake_toolchain_file.pro b/Tools/qmake/projects/generate_cmake_toolchain_file.pro new file mode 100644 index 000000000..db26391b0 --- /dev/null +++ b/Tools/qmake/projects/generate_cmake_toolchain_file.pro @@ -0,0 +1,50 @@ +load(functions) + +TEMPLATE = aux + +cross_compile { + linux { + SYSTEM_NAME = Linux + } else: macos { + # We don't support uikit platforms for now, and they certainly won't work + # with the simplistic toolchain file we are generating here. + SYSTEM_NAME = Darwin + } else: win32 { + SYSTEM_NAME = Windows + } else: freebsd { + SYSTEM_NAME = FreeBSD + } else: netbsd { + SYSTEM_NAME = NetBSD + } else: openbsd { + SYSTEM_NAME = OpenBSD + } else { + error("Unknown platform, cannot produce toolchain file for CMake") + } + + TOOLCHAIN_FILE_VARS += \ + "CMAKE_SYSTEM_NAME $$SYSTEM_NAME" \ + "CMAKE_SYSTEM_PROCESSOR $$QT_ARCH" + + isEmpty(CMAKE_SYSROOT): CMAKE_SYSROOT = $$[QT_SYSROOT] + !isEmpty(CMAKE_SYSROOT): TOOLCHAIN_FILE_VARS += \ + "CMAKE_FIND_ROOT_PATH $$CMAKE_SYSROOT" \ + "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER" \ + "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY" \ + "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY" +} + +TOOLCHAIN_FILE_VARS += \ + "CMAKE_C_COMPILER \"$$QMAKE_CC\"" \ + "CMAKE_CXX_COMPILER \"$$QMAKE_CXX\"" + +CONANBUILDINFO_PATH = $$ROOT_BUILD_DIR/conanbuildinfo.cmake +exists($$CONANBUILDINFO_PATH): TOOLCHAIN_FILE_VARS += "CONANBUILDINFO_PATH $$CONANBUILDINFO_PATH" + +for (var, TOOLCHAIN_FILE_VARS): TOOLCHAIN_FILE_CONTENTS += "set($$var)" + +TOOLCHAIN_FILE = $$ROOT_BUILD_DIR/qmake_toolchain.cmake + +!build_pass { + log("$${EOL}Generating CMake toolchain file $$TOOLCHAIN_FILE $${EOL}$${EOL}"$$join(TOOLCHAIN_FILE_CONTENTS, $${EOL})$${EOL}$${EOL}) + write_file($$TOOLCHAIN_FILE, TOOLCHAIN_FILE_CONTENTS)|error() +} diff --git a/Tools/qmake/projects/qtjpeg/qtjpeg.pro b/Tools/qmake/projects/qtjpeg/qtjpeg.pro new file mode 100644 index 000000000..89d3e6113 --- /dev/null +++ b/Tools/qmake/projects/qtjpeg/qtjpeg.pro @@ -0,0 +1,24 @@ +load(functions) + +TARGET = qtjpeg + +CONFIG += \ + static \ + hide_symbols \ + exceptions_off rtti_off warn_off \ + installed + +# Poor man's qt_helper_lib +TEMPLATE = lib +CONFIG += staticlib +CONFIG -= qt + +# In debug_and_release build we need only one copy of library, let it be release +debug_and_release { + CONFIG -= debug_and_release debug + CONFIG += release +} + +DESTDIR = $$ROOT_BUILD_DIR/lib + +include($$QTBASE_DIR/src/3rdparty/libjpeg.pri) diff --git a/Tools/qmake/projects/qtpng/qtpng.pro b/Tools/qmake/projects/qtpng/qtpng.pro new file mode 100644 index 000000000..88b6f9672 --- /dev/null +++ b/Tools/qmake/projects/qtpng/qtpng.pro @@ -0,0 +1,49 @@ +# This file was copied from qtbase/src/3rdparty/libpng/libpng.pro +# in order to build a copy of libqtpng specifically for QtWebKit module +# Must be kept in sync with qtbase + +load(functions) + +TARGET = qtpng + +CONFIG += \ + static \ + hide_symbols \ + exceptions_off rtti_off warn_off \ + installed + +# Poor man's qt_helper_lib +TEMPLATE = lib +CONFIG += staticlib +CONFIG -= qt + +# In debug_and_release build we need only one copy of library, let it be release +debug_and_release { + CONFIG -= debug_and_release debug + CONFIG += release +} + +DESTDIR = $$ROOT_BUILD_DIR/lib +PNGDIR = $$QTBASE_DIR/src/3rdparty/libpng + +DEFINES += PNG_ARM_NEON_OPT=0 +SOURCES += \ + $$PNGDIR/png.c \ + $$PNGDIR/pngerror.c \ + $$PNGDIR/pngget.c \ + $$PNGDIR/pngmem.c \ + $$PNGDIR/pngpread.c \ + $$PNGDIR/pngread.c \ + $$PNGDIR/pngrio.c \ + $$PNGDIR/pngrtran.c \ + $$PNGDIR/pngrutil.c \ + $$PNGDIR/pngset.c \ + $$PNGDIR/pngtrans.c \ + $$PNGDIR/pngwio.c \ + $$PNGDIR/pngwrite.c \ + $$PNGDIR/pngwtran.c \ + $$PNGDIR/pngwutil.c + +TR_EXCLUDE += $$PWD/* + +include($$QTBASE_DIR/src/3rdparty/zlib_dependency.pri) diff --git a/Tools/qmake/projects/run_cmake.pro b/Tools/qmake/projects/run_cmake.pro new file mode 100644 index 000000000..d564ad262 --- /dev/null +++ b/Tools/qmake/projects/run_cmake.pro @@ -0,0 +1,69 @@ +load(functions) + +ROOT_QT_BUILD_DIR = $$ROOT_BUILD_DIR/.. + +TEMPLATE = aux + +CONFIG(debug, debug|release) { + configuration = Debug +} else { + configuration = Release +} + +cmake_build_dir = $$system_quote($$system_path($$ROOT_BUILD_DIR/$$lower($$configuration))) +toolchain_file = $$system_quote($$system_path($$ROOT_BUILD_DIR/qmake_toolchain.cmake)) + +build_pass|!debug_and_release { + CMAKE_CONFIG += \ + PORT=Qt \ + CMAKE_BUILD_TYPE=$$configuration \ + CMAKE_TOOLCHAIN_FILE=$$toolchain_file \ + CMAKE_PREFIX_PATH=\"$$[QT_INSTALL_PREFIX];$$ROOT_QT_BUILD_DIR/qtbase;$$ROOT_QT_BUILD_DIR/qtlocation;$$ROOT_QT_BUILD_DIR/qtsensors\" \ + CMAKE_INSTALL_PREFIX=\"$$[QT_INSTALL_PREFIX]\" \ + KDE_INSTALL_LIBDIR=\"$$relative_path($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])\" \ + USE_LIBHYPHEN=OFF + + QT_FOR_CONFIG += gui-private + !qtConfig(system-jpeg):exists($$QTBASE_DIR) { + CMAKE_CONFIG += \ + QT_BUNDLED_JPEG=1 \ + JPEG_INCLUDE_DIR=$$system_path($$QTBASE_DIR/src/3rdparty/libjpeg) \ + JPEG_LIBRARIES=$$system_path($$ROOT_BUILD_DIR/lib/libqtjpeg.$$QMAKE_EXTENSION_STATICLIB) + } + + !qtConfig(system-png):qtConfig(png):exists($$QTBASE_DIR) { + CMAKE_CONFIG += \ + QT_BUNDLED_PNG=1 \ + PNG_INCLUDE_DIRS=$$system_path($$QTBASE_DIR/src/3rdparty/libpng) \ + PNG_LIBRARIES=$$system_path($$ROOT_BUILD_DIR/lib/libqtpng.$$QMAKE_EXTENSION_STATICLIB) + } + + !qtConfig(system-zlib):exists($$QTBASE_DIR) { + CMAKE_CONFIG += \ + QT_BUNDLED_ZLIB=1 \ + ZLIB_INCLUDE_DIRS=$$system_path($$QTBASE_DIR/src/3rdparty/zlib) + } + + equals(QMAKE_HOST.os, Windows): cmake_args += "-G \"NMake Makefiles JOM\"" + + !silent: make_args += "VERBOSE=1" + + # Append additional platform options defined in CMAKE_CONFIG + for (config, CMAKE_CONFIG): cmake_args += "-D$$config" + + cmake_cmd_base = "$$QMAKE_MKDIR $$cmake_build_dir && cd $$cmake_build_dir &&" + + log("$${EOL}Running $$cmake_env cmake $$ROOT_WEBKIT_DIR $$cmake_args $${EOL}$${EOL}") + !system("$$cmake_cmd_base $$cmake_env cmake $$ROOT_WEBKIT_DIR $$cmake_args"): error("Running cmake failed") + + log("$${EOL}WebKit is now configured for building. Just run 'make'.$${EOL}$${EOL}") + + + default_target.target = first + default_target.commands = cd $$cmake_build_dir && $(MAKE) $$make_args + QMAKE_EXTRA_TARGETS += default_target + + install_target.target = install + install_target.commands = cd $$cmake_build_dir && $(MAKE) install $$make_args DESTDIR=$(INSTALL_ROOT) + QMAKE_EXTRA_TARGETS += install_target +} diff --git a/Tools/qt/manifest.txt b/Tools/qt/manifest.txt index 5e7b65b76..211fc29f4 100644 --- a/Tools/qt/manifest.txt +++ b/Tools/qt/manifest.txt @@ -112,6 +112,7 @@ file Source/WebCore/Resources/aliasCursor.png file Source/WebCore/platform/audio/resources/Composite.wav directory Tools/qt +directory Tools/qmake directory Tools/ImageDiff directory Tools/MiniBrowser directory Tools/TestWebKitAPI @@ -135,4 +136,5 @@ file Tools/Scripts/webkit-build-directory file Tools/Scripts/webkitdirs.pm file Tools/Scripts/webkitperl/FeatureList.pm file Tools/jhbuild/jhbuildutils.py - +file WebKit.pro +file .qmake.conf diff --git a/WebKit.pro b/WebKit.pro new file mode 100644 index 000000000..375d4d77b --- /dev/null +++ b/WebKit.pro @@ -0,0 +1,20 @@ +load(functions) + +TEMPLATE = subdirs +CONFIG += ordered +PROJECTS_DIR = Tools/qmake/projects + +isPlatformSupported() { + QT_FOR_CONFIG += gui-private + !qtConfig(system-png):qtConfig(png):exists($$QTBASE_DIR): \ + SUBDIRS += $$PROJECTS_DIR/qtpng + + !qtConfig(system-jpeg):exists($$QTBASE_DIR): \ + SUBDIRS += $$PROJECTS_DIR/qtjpeg + + SUBDIRS += \ + $$PROJECTS_DIR/generate_cmake_toolchain_file.pro \ + $$PROJECTS_DIR/run_cmake.pro +} else { + !build_pass: log("$${EOL}The WebKit build was disabled for the following reasons: $$skipBuildReason $${EOL}$${EOL}") +} |