summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2017-03-30 15:27:58 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-03-31 10:31:00 +0000
commitbe770ca621f6463339b7d15be088e1b9acd851e5 (patch)
tree1a843019f693c100adea3f3acd47999f3eba2796
parenteaaf1391d58f17bde794d6c8634e092209898941 (diff)
Import WebKit commit 13ac532967b6ac2d18d6fc4ea72c4ca35eccff20
Change-Id: I12a5c8f98aeaac1b542ce20c0ff297c57b5d84d1 Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
-rw-r--r--Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp12
-rw-r--r--Source/WTF/wtf/PlatformQt.cmake14
-rw-r--r--Source/WTF/wtf/WorkQueue.cpp2
-rw-r--r--Source/WTF/wtf/WorkQueue.h13
-rw-r--r--Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp112
-rw-r--r--Source/WTF/wtf/threads/BinarySemaphore.h8
-rw-r--r--Source/WTF/wtf/threads/win/BinarySemaphoreWin.cpp75
-rw-r--r--Source/WTF/wtf/win/MainThreadWin.cpp76
-rw-r--r--Source/WTF/wtf/win/RunLoopWin.cpp176
-rw-r--r--Source/WTF/wtf/win/WTFDLL.cpp50
-rw-r--r--Source/WTF/wtf/win/WorkItemWin.cpp68
-rw-r--r--Source/WTF/wtf/win/WorkItemWin.h72
-rw-r--r--Source/WTF/wtf/win/WorkQueueWin.cpp281
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp14
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h2
-rw-r--r--Source/WebKit/CMakeLists.txt23
-rw-r--r--Source/WebKit/PlatformQt.cmake3
-rw-r--r--Source/WebKit/qt/Api/qwebsettings.cpp6
-rw-r--r--Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp10
-rw-r--r--Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp6
-rw-r--r--Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp4
-rw-r--r--Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp2
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp18
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp26
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h2
-rw-r--r--Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp14
-rw-r--r--Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.h12
-rw-r--r--Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp4
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebpage.cpp71
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebpage_p.h2
-rw-r--r--Source/cmake/OptionsQt.cmake4
-rw-r--r--Tools/qmake/projects/qtjpeg/qtjpeg.pro3
-rw-r--r--Tools/qmake/projects/qtpng/qtpng.pro3
-rw-r--r--Tools/qt/manifest.txt4
34 files changed, 1107 insertions, 85 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
index 2f3f12d6c..6aefe61e3 100644
--- a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
+++ b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
@@ -3739,6 +3739,8 @@ bool ByteCodeParser::parseBlock(unsigned limit)
Node* base = get(VirtualRegister(currentInstruction[2].u.operand));
Node* property = get(VirtualRegister(currentInstruction[3].u.operand));
bool compiledAsGetById = false;
+ GetByIdStatus getByIdStatus;
+ unsigned identifierNumber = 0;
{
ConcurrentJITLocker locker(m_inlineStackTop->m_profiledBlock->m_lock);
ByValInfo* byValInfo = m_inlineStackTop->m_byValInfos.get(CodeOrigin(currentCodeOrigin().bytecodeIndex));
@@ -3746,20 +3748,20 @@ bool ByteCodeParser::parseBlock(unsigned limit)
// At that time, there is no information.
if (byValInfo && byValInfo->stubInfo && !byValInfo->tookSlowPath && !m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadIdent)) {
compiledAsGetById = true;
- unsigned identifierNumber = m_graph.identifiers().ensure(byValInfo->cachedId.impl());
+ identifierNumber = m_graph.identifiers().ensure(byValInfo->cachedId.impl());
UniquedStringImpl* uid = m_graph.identifiers()[identifierNumber];
addToGraph(CheckIdent, OpInfo(uid), property);
- GetByIdStatus getByIdStatus = GetByIdStatus::computeForStubInfo(
+ getByIdStatus = GetByIdStatus::computeForStubInfo(
locker, m_inlineStackTop->m_profiledBlock,
byValInfo->stubInfo, currentCodeOrigin(), uid);
-
- handleGetById(currentInstruction[1].u.operand, prediction, base, identifierNumber, getByIdStatus);
}
}
- if (!compiledAsGetById) {
+ if (compiledAsGetById)
+ handleGetById(currentInstruction[1].u.operand, prediction, base, identifierNumber, getByIdStatus);
+ else {
ArrayMode arrayMode = getArrayMode(currentInstruction[4].u.arrayProfile, Array::Read);
Node* getByVal = addToGraph(GetByVal, OpInfo(arrayMode.asWord()), OpInfo(prediction), base, property);
m_exitOK = false; // GetByVal must be treated as if it clobbers exit state, since FixupPhase may make it generic.
diff --git a/Source/WTF/wtf/PlatformQt.cmake b/Source/WTF/wtf/PlatformQt.cmake
index 7efcd4015..636ad40c2 100644
--- a/Source/WTF/wtf/PlatformQt.cmake
+++ b/Source/WTF/wtf/PlatformQt.cmake
@@ -1,7 +1,6 @@
list(APPEND WTF_SOURCES
qt/MainThreadQt.cpp
qt/RunLoopQt.cpp
- qt/WorkQueueQt.cpp
text/qt/StringQt.cpp
)
@@ -30,6 +29,8 @@ endif ()
if (UNIX AND NOT APPLE)
list(APPEND WTF_SOURCES
UniStdExtras.cpp
+
+ qt/WorkQueueQt.cpp
)
endif ()
@@ -47,6 +48,15 @@ if (USE_GLIB)
endif ()
if (WIN32)
+ list(REMOVE_ITEM WTF_SOURCES
+ threads/BinarySemaphore.cpp
+ )
+ list(APPEND WTF_SOURCES
+ threads/win/BinarySemaphoreWin.cpp
+
+ win/WorkItemWin.cpp
+ win/WorkQueueWin.cpp
+ )
list(APPEND WTF_LIBRARIES
winmm
)
@@ -54,6 +64,8 @@ endif ()
if (APPLE)
list(APPEND WTF_SOURCES
+ cocoa/WorkQueueCocoa.cpp
+
text/cf/AtomicStringImplCF.cpp
text/cf/StringCF.cpp
text/cf/StringImplCF.cpp
diff --git a/Source/WTF/wtf/WorkQueue.cpp b/Source/WTF/wtf/WorkQueue.cpp
index 43b6450b2..e26ae3bf2 100644
--- a/Source/WTF/wtf/WorkQueue.cpp
+++ b/Source/WTF/wtf/WorkQueue.cpp
@@ -52,7 +52,7 @@ WorkQueue::~WorkQueue()
platformInvalidate();
}
-#if !PLATFORM(COCOA)
+#if !PLATFORM(COCOA) && !(PLATFORM(QT) && OS(DARWIN))
void WorkQueue::concurrentApply(size_t iterations, const std::function<void (size_t index)>& function)
{
if (!iterations)
diff --git a/Source/WTF/wtf/WorkQueue.h b/Source/WTF/wtf/WorkQueue.h
index ca93aa7f8..97e52897e 100644
--- a/Source/WTF/wtf/WorkQueue.h
+++ b/Source/WTF/wtf/WorkQueue.h
@@ -44,7 +44,7 @@
#include <wtf/glib/GRefPtr.h>
#elif PLATFORM(EFL)
#include <DispatchQueueEfl.h>
-#elif PLATFORM(QT)
+#elif PLATFORM(QT) && USE(UNIX_DOMAIN_SOCKETS)
#include <QSocketNotifier>
#elif OS(WINDOWS)
#include <wtf/HashMap.h>
@@ -52,7 +52,7 @@
#include <wtf/win/WorkItemWin.h>
#endif
-#if PLATFORM(QT)
+#if PLATFORM(QT) && USE(UNIX_DOMAIN_SOCKETS)
QT_BEGIN_NAMESPACE
class QProcess;
QT_END_NAMESPACE
@@ -87,9 +87,12 @@ public:
#elif PLATFORM(EFL)
void registerSocketEventHandler(int, std::function<void ()>);
void unregisterSocketEventHandler(int);
-#elif PLATFORM(QT)
+#elif PLATFORM(QT) && USE(UNIX_DOMAIN_SOCKETS)
QSocketNotifier* registerSocketEventHandler(int, QSocketNotifier::Type, std::function<void()>);
void dispatchOnTermination(QProcess*, std::function<void()>);
+#elif PLATFORM(QT) && OS(WINDOWS)
+ void registerHandle(HANDLE, const std::function<void()>&);
+ void unregisterAndCloseHandle(HANDLE);
#elif OS(DARWIN)
dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }
#endif
@@ -100,7 +103,7 @@ private:
void platformInitialize(const char* name, Type, QOS);
void platformInvalidate();
-#if PLATFORM(WIN)
+#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
static void CALLBACK handleCallback(void* context, BOOLEAN timerOrWaitFired);
static void CALLBACK timerCallback(void* context, BOOLEAN timerOrWaitFired);
static DWORD WINAPI workThreadCallback(void* context);
@@ -122,7 +125,7 @@ private:
Condition m_terminateRunLoopCondition;
#elif PLATFORM(EFL)
RefPtr<DispatchQueue> m_dispatchQueue;
-#elif PLATFORM(QT)
+#elif PLATFORM(QT) && USE(UNIX_DOMAIN_SOCKETS)
class WorkItemQt;
QThread* m_workThread;
friend class WorkItemQt;
diff --git a/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp b/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp
new file mode 100644
index 000000000..134961ec7
--- /dev/null
+++ b/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2010 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 "WorkQueue.h"
+
+namespace WTF {
+
+void WorkQueue::dispatch(std::function<void ()> function)
+{
+ ref();
+ dispatch_async(m_dispatchQueue, ^{
+ function();
+ deref();
+ });
+}
+
+void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, std::function<void ()> function)
+{
+ ref();
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.count()), m_dispatchQueue, ^{
+ function();
+ deref();
+ });
+}
+
+#if HAVE(QOS_CLASSES)
+static dispatch_qos_class_t dispatchQOSClass(WorkQueue::QOS qos)
+{
+ switch (qos) {
+ case WorkQueue::QOS::UserInteractive:
+ return QOS_CLASS_USER_INTERACTIVE;
+ case WorkQueue::QOS::UserInitiated:
+ return QOS_CLASS_USER_INITIATED;
+ case WorkQueue::QOS::Default:
+ return QOS_CLASS_DEFAULT;
+ case WorkQueue::QOS::Utility:
+ return QOS_CLASS_UTILITY;
+ case WorkQueue::QOS::Background:
+ return QOS_CLASS_BACKGROUND;
+ }
+}
+#else
+static dispatch_queue_t targetQueueForQOSClass(WorkQueue::QOS qos)
+{
+ switch (qos) {
+ case WorkQueue::QOS::UserInteractive:
+ case WorkQueue::QOS::UserInitiated:
+ return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
+ case WorkQueue::QOS::Utility:
+ return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
+ case WorkQueue::QOS::Background:
+ return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
+ case WorkQueue::QOS::Default:
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ }
+ ASSERT_NOT_REACHED();
+}
+#endif
+
+void WorkQueue::platformInitialize(const char* name, Type type, QOS qos)
+{
+ dispatch_queue_attr_t attr = type == Type::Concurrent ? DISPATCH_QUEUE_CONCURRENT : DISPATCH_QUEUE_SERIAL;
+#if HAVE(QOS_CLASSES)
+ attr = dispatch_queue_attr_make_with_qos_class(attr, dispatchQOSClass(qos), 0);
+#else
+ UNUSED_PARAM(qos);
+#endif
+ m_dispatchQueue = dispatch_queue_create(name, attr);
+#if !HAVE(QOS_CLASSES)
+ if (qos != WorkQueue::QOS::Default)
+ dispatch_set_target_queue(m_dispatchQueue, targetQueueForQOSClass(qos));
+#endif
+ dispatch_set_context(m_dispatchQueue, this);
+}
+
+void WorkQueue::platformInvalidate()
+{
+ dispatch_release(m_dispatchQueue);
+}
+
+void WorkQueue::concurrentApply(size_t iterations, const std::function<void (size_t index)>& function)
+{
+ dispatch_apply(iterations, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t index) {
+ function(index);
+ });
+}
+
+}
diff --git a/Source/WTF/wtf/threads/BinarySemaphore.h b/Source/WTF/wtf/threads/BinarySemaphore.h
index b5db5d7ad..9585dc978 100644
--- a/Source/WTF/wtf/threads/BinarySemaphore.h
+++ b/Source/WTF/wtf/threads/BinarySemaphore.h
@@ -41,11 +41,19 @@ public:
WTF_EXPORT_PRIVATE void signal();
WTF_EXPORT_PRIVATE bool wait(double absoluteTime);
+#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
+ HANDLE event() const { return m_event; }
+#endif
+
private:
+#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
+ HANDLE m_event;
+#else
bool m_isSet;
Mutex m_mutex;
ThreadCondition m_condition;
+#endif
};
} // namespace WTF
diff --git a/Source/WTF/wtf/threads/win/BinarySemaphoreWin.cpp b/Source/WTF/wtf/threads/win/BinarySemaphoreWin.cpp
new file mode 100644
index 000000000..0dad1ac5c
--- /dev/null
+++ b/Source/WTF/wtf/threads/win/BinarySemaphoreWin.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 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 "BinarySemaphore.h"
+
+namespace WTF {
+
+BinarySemaphore::BinarySemaphore()
+ : m_event(::CreateEventW(0, FALSE, FALSE, 0))
+{
+}
+
+BinarySemaphore::~BinarySemaphore()
+{
+ ::CloseHandle(m_event);
+}
+
+void BinarySemaphore::signal()
+{
+ ::SetEvent(m_event);
+}
+
+bool BinarySemaphore::wait(double absoluteTime)
+{
+ DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime);
+ if (!interval) {
+ // Consider the wait to have timed out, even if the event has already been signaled, to
+ // match the WTF::ThreadCondition implementation.
+ return false;
+ }
+
+ DWORD result = ::WaitForSingleObject(m_event, interval);
+ switch (result) {
+ case WAIT_OBJECT_0:
+ // The event was signaled.
+ return true;
+
+ case WAIT_TIMEOUT:
+ // The wait timed out.
+ return false;
+
+ case WAIT_FAILED:
+ ASSERT_WITH_MESSAGE(false, "::WaitForSingleObject failed with error %lu", ::GetLastError());
+ return false;
+
+ default:
+ ASSERT_WITH_MESSAGE(false, "::WaitForSingleObject returned unexpected result %lu", result);
+ return false;
+ }
+}
+
+} // namespace WTF
diff --git a/Source/WTF/wtf/win/MainThreadWin.cpp b/Source/WTF/wtf/win/MainThreadWin.cpp
new file mode 100644
index 000000000..f324e8b61
--- /dev/null
+++ b/Source/WTF/wtf/win/MainThreadWin.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Torch Mobile 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.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 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 "MainThread.h"
+
+#include "Assertions.h"
+#include "Threading.h"
+#include "WindowsExtras.h"
+
+namespace WTF {
+
+static HWND threadingWindowHandle;
+static UINT threadingFiredMessage;
+const LPCWSTR kThreadingWindowClassName = L"ThreadingWindowClass";
+
+LRESULT CALLBACK ThreadingWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ if (message == threadingFiredMessage)
+ dispatchFunctionsFromMainThread();
+ else
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ return 0;
+}
+
+void initializeMainThreadPlatform()
+{
+ if (threadingWindowHandle)
+ return;
+
+ WNDCLASSW wcex;
+ memset(&wcex, 0, sizeof(WNDCLASSW));
+ wcex.lpfnWndProc = ThreadingWindowWndProc;
+ wcex.lpszClassName = kThreadingWindowClassName;
+ RegisterClassW(&wcex);
+
+ threadingWindowHandle = CreateWindowW(kThreadingWindowClassName, 0, 0,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, 0, 0, 0);
+ threadingFiredMessage = RegisterWindowMessageW(L"com.apple.WebKit.MainThreadFired");
+
+ initializeCurrentThreadInternal("Main Thread");
+}
+
+void scheduleDispatchFunctionsOnMainThread()
+{
+ ASSERT(threadingWindowHandle);
+ PostMessage(threadingWindowHandle, threadingFiredMessage, 0, 0);
+}
+
+} // namespace WTF
diff --git a/Source/WTF/wtf/win/RunLoopWin.cpp b/Source/WTF/wtf/win/RunLoopWin.cpp
new file mode 100644
index 000000000..4b45ad458
--- /dev/null
+++ b/Source/WTF/wtf/win/RunLoopWin.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2010 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 "RunLoop.h"
+
+#include <wtf/CurrentTime.h>
+#include <wtf/WindowsExtras.h>
+
+namespace WTF {
+
+static const UINT PerformWorkMessage = WM_USER + 1;
+static const LPWSTR kRunLoopMessageWindowClassName = L"RunLoopMessageWindow";
+
+LRESULT CALLBACK RunLoop::RunLoopWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ if (RunLoop* runLoop = static_cast<RunLoop*>(getWindowPointer(hWnd, 0)))
+ return runLoop->wndProc(hWnd, message, wParam, lParam);
+
+ if (message == WM_CREATE) {
+ LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
+
+ // Associate the RunLoop with the window.
+ setWindowPointer(hWnd, 0, createStruct->lpCreateParams);
+ return 0;
+ }
+
+ return ::DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+LRESULT RunLoop::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message) {
+ case PerformWorkMessage:
+ performWork();
+ return 0;
+ case WM_TIMER:
+ RunLoop::TimerBase::timerFired(this, wParam);
+ return 0;
+ }
+
+ return ::DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+void RunLoop::run()
+{
+ MSG message;
+ while (BOOL result = ::GetMessage(&message, 0, 0, 0)) {
+ if (result == -1)
+ break;
+ ::TranslateMessage(&message);
+ ::DispatchMessage(&message);
+ }
+}
+
+void RunLoop::stop()
+{
+ ::PostQuitMessage(0);
+}
+
+bool RunLoop::registerRunLoopMessageWindowClass()
+{
+ // FIXME: This really only needs to be called once.
+
+ WNDCLASS windowClass = { 0 };
+ windowClass.lpfnWndProc = RunLoop::RunLoopWndProc;
+ windowClass.cbWndExtra = sizeof(RunLoop*);
+ windowClass.lpszClassName = kRunLoopMessageWindowClassName;
+
+ return !!::RegisterClass(&windowClass);
+}
+
+RunLoop::RunLoop()
+{
+ registerRunLoopMessageWindowClass();
+
+ m_runLoopMessageWindow = ::CreateWindow(kRunLoopMessageWindowClassName, 0, 0,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, 0, 0, this);
+ ASSERT(::IsWindow(m_runLoopMessageWindow));
+}
+
+RunLoop::~RunLoop()
+{
+ // FIXME: Tear down the work item queue here.
+}
+
+void RunLoop::wakeUp()
+{
+ // FIXME: No need to wake up the run loop if we've already called dispatch
+ // before the run loop has had the time to respond.
+ ::PostMessage(m_runLoopMessageWindow, PerformWorkMessage, reinterpret_cast<WPARAM>(this), 0);
+}
+
+// RunLoop::Timer
+
+void RunLoop::TimerBase::timerFired(RunLoop* runLoop, uint64_t ID)
+{
+ TimerMap::iterator it = runLoop->m_activeTimers.find(ID);
+ if (it == runLoop->m_activeTimers.end()) {
+ // The timer must have been stopped after the WM_TIMER message was posted to the message queue.
+ return;
+ }
+
+ TimerBase* timer = it->value;
+
+ if (!timer->m_isRepeating) {
+ runLoop->m_activeTimers.remove(it);
+ ::KillTimer(runLoop->m_runLoopMessageWindow, ID);
+ }
+
+ timer->fired();
+}
+
+static uint64_t generateTimerID()
+{
+ static uint64_t uniqueTimerID = 1;
+ return uniqueTimerID++;
+}
+
+RunLoop::TimerBase::TimerBase(RunLoop& runLoop)
+ : m_runLoop(runLoop)
+ , m_ID(generateTimerID())
+ , m_isRepeating(false)
+{
+}
+
+RunLoop::TimerBase::~TimerBase()
+{
+ stop();
+}
+
+void RunLoop::TimerBase::start(double nextFireInterval, bool repeat)
+{
+ m_isRepeating = repeat;
+ m_runLoop.m_activeTimers.set(m_ID, this);
+ ::SetTimer(m_runLoop.m_runLoopMessageWindow, m_ID, nextFireInterval * 1000, 0);
+}
+
+void RunLoop::TimerBase::stop()
+{
+ TimerMap::iterator it = m_runLoop.m_activeTimers.find(m_ID);
+ if (it == m_runLoop.m_activeTimers.end())
+ return;
+
+ m_runLoop.m_activeTimers.remove(it);
+ ::KillTimer(m_runLoop.m_runLoopMessageWindow, m_ID);
+}
+
+bool RunLoop::TimerBase::isActive() const
+{
+ return m_runLoop.m_activeTimers.contains(m_ID);
+}
+
+} // namespace WTF
diff --git a/Source/WTF/wtf/win/WTFDLL.cpp b/Source/WTF/wtf/win/WTFDLL.cpp
new file mode 100644
index 000000000..779e1b862
--- /dev/null
+++ b/Source/WTF/wtf/win/WTFDLL.cpp
@@ -0,0 +1,50 @@
+/*
+* Copyright (C) 2015 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. ``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
+* 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 <Windows.h>
+#include <math.h>
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+#if defined(_M_X64) || defined(__x86_64__)
+ // The VS2013 runtime has a bug where it mis-detects AVX-capable processors
+ // if the feature has been disabled in firmware. This causes us to crash
+ // in some of the math functions. For now, we disable those optimizations
+ // because Microsoft is not going to fix the problem in VS2013.
+ // FIXME: http://webkit.org/b/141449: Remove this workaround when we switch to VS2015+.
+ _set_FMA3_enable(0);
+#endif
+ break;
+
+ case DLL_PROCESS_DETACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ break;
+ }
+
+ return TRUE;
+}
diff --git a/Source/WTF/wtf/win/WorkItemWin.cpp b/Source/WTF/wtf/win/WorkItemWin.cpp
new file mode 100644
index 000000000..33ddf8ed9
--- /dev/null
+++ b/Source/WTF/wtf/win/WorkItemWin.cpp
@@ -0,0 +1,68 @@
+/*
+* Copyright (C) 2010, 2015 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 "WorkItemWin.h"
+
+#include <Windows.h>
+#include <wtf/Threading.h>
+#include <wtf/WorkQueue.h>
+
+namespace WTF {
+
+WorkItemWin::WorkItemWin(std::function<void()> function, WorkQueue* queue)
+ : m_function(function)
+ , m_queue(queue)
+{
+}
+
+RefPtr<WorkItemWin> WorkItemWin::create(std::function<void()> function, WorkQueue* queue)
+{
+ return adoptRef(new WorkItemWin(function, queue));
+}
+
+WorkItemWin::~WorkItemWin()
+{
+}
+
+HandleWorkItem::HandleWorkItem(HANDLE handle, const std::function<void()>& function, WorkQueue* queue)
+ : WorkItemWin(function, queue)
+ , m_handle(handle)
+ , m_waitHandle(0)
+{
+ ASSERT_ARG(handle, handle);
+}
+
+RefPtr<HandleWorkItem> HandleWorkItem::createByAdoptingHandle(HANDLE handle, const std::function<void()>& function, WorkQueue* queue)
+{
+ return adoptRef(new HandleWorkItem(handle, function, queue));
+}
+
+HandleWorkItem::~HandleWorkItem()
+{
+ ::CloseHandle(m_handle);
+}
+
+} // namespace WTF
diff --git a/Source/WTF/wtf/win/WorkItemWin.h b/Source/WTF/wtf/win/WorkItemWin.h
new file mode 100644
index 000000000..af3fa1799
--- /dev/null
+++ b/Source/WTF/wtf/win/WorkItemWin.h
@@ -0,0 +1,72 @@
+/*
+* Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
+* Portions Copyright (c) 2010 Motorola Mobility, 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.
+*/
+
+#ifndef WorkItemWin_h
+#define WorkItemWin_h
+
+#include <Windows.h>
+#include <functional>
+#include <wtf/RefPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
+
+namespace WTF {
+
+class WorkQueue;
+
+class WorkItemWin : public ThreadSafeRefCounted<WorkItemWin> {
+public:
+ static RefPtr<WorkItemWin> create(std::function<void()>, WorkQueue*);
+ virtual ~WorkItemWin();
+
+ std::function<void()>& function() { return m_function; }
+ WorkQueue* queue() const { return m_queue.get(); }
+
+protected:
+ WorkItemWin(std::function<void()>, WorkQueue*);
+
+private:
+ std::function<void()> m_function;
+ RefPtr<WorkQueue> m_queue;
+};
+
+class HandleWorkItem : public WorkItemWin {
+public:
+ static RefPtr<HandleWorkItem> createByAdoptingHandle(HANDLE, const std::function<void()>&, WorkQueue*);
+ virtual ~HandleWorkItem();
+
+ void setWaitHandle(HANDLE waitHandle) { m_waitHandle = waitHandle; }
+ HANDLE waitHandle() const { return m_waitHandle; }
+
+private:
+ HandleWorkItem(HANDLE, const std::function<void()>&, WorkQueue*);
+
+ HANDLE m_handle;
+ HANDLE m_waitHandle;
+};
+
+}
+
+#endif
diff --git a/Source/WTF/wtf/win/WorkQueueWin.cpp b/Source/WTF/wtf/win/WorkQueueWin.cpp
new file mode 100644
index 000000000..6e61cde69
--- /dev/null
+++ b/Source/WTF/wtf/win/WorkQueueWin.cpp
@@ -0,0 +1,281 @@
+/*
+* Copyright (C) 2010, 2015 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 "WorkQueue.h"
+
+#include <wtf/MathExtras.h>
+#include <wtf/Threading.h>
+#include <wtf/win/WorkItemWin.h>
+
+namespace WTF {
+
+void WorkQueue::handleCallback(void* context, BOOLEAN timerOrWaitFired)
+{
+ ASSERT_ARG(context, context);
+ ASSERT_ARG(timerOrWaitFired, !timerOrWaitFired);
+
+ WorkItemWin* item = static_cast<WorkItemWin*>(context);
+ RefPtr<WorkQueue> queue = item->queue();
+
+ {
+ MutexLocker lock(queue->m_workItemQueueLock);
+ queue->m_workItemQueue.append(item);
+
+ // If no other thread is performing work, we can do it on this thread.
+ if (!queue->tryRegisterAsWorkThread()) {
+ // Some other thread is performing work. Since we hold the queue lock, we can be sure
+ // that the work thread is not exiting due to an empty queue and will process the work
+ // item we just added to it. If we weren't holding the lock we'd have to signal
+ // m_performWorkEvent to make sure the work item got picked up.
+ return;
+ }
+ }
+
+ queue->performWorkOnRegisteredWorkThread();
+}
+
+DWORD WorkQueue::workThreadCallback(void* context)
+{
+ ASSERT_ARG(context, context);
+
+ WorkQueue* queue = static_cast<WorkQueue*>(context);
+
+ if (!queue->tryRegisterAsWorkThread())
+ return 0;
+
+ queue->performWorkOnRegisteredWorkThread();
+ return 0;
+}
+
+void WorkQueue::performWorkOnRegisteredWorkThread()
+{
+ ASSERT(m_isWorkThreadRegistered);
+
+ m_workItemQueueLock.lock();
+
+ while (!m_workItemQueue.isEmpty()) {
+ Vector<RefPtr<WorkItemWin>> workItemQueue;
+ m_workItemQueue.swap(workItemQueue);
+
+ // Allow more work to be scheduled while we're not using the queue directly.
+ m_workItemQueueLock.unlock();
+ for (auto& workItem : workItemQueue) {
+ workItem->function()();
+ deref();
+ }
+ m_workItemQueueLock.lock();
+ }
+
+ // One invariant we maintain is that any work scheduled while a work thread is registered will
+ // be handled by that work thread. Unregister as the work thread while the queue lock is still
+ // held so that no work can be scheduled while we're still registered.
+ unregisterAsWorkThread();
+
+ m_workItemQueueLock.unlock();
+}
+
+void WorkQueue::platformInitialize(const char* name, Type, QOS)
+{
+ m_isWorkThreadRegistered = 0;
+ m_timerQueue = ::CreateTimerQueue();
+ ASSERT_WITH_MESSAGE(m_timerQueue, "::CreateTimerQueue failed with error %lu", ::GetLastError());
+}
+
+bool WorkQueue::tryRegisterAsWorkThread()
+{
+ LONG result = ::InterlockedCompareExchange(&m_isWorkThreadRegistered, 1, 0);
+ ASSERT(!result || result == 1);
+ return !result;
+}
+
+void WorkQueue::unregisterAsWorkThread()
+{
+ LONG result = ::InterlockedCompareExchange(&m_isWorkThreadRegistered, 0, 1);
+ ASSERT_UNUSED(result, result == 1);
+}
+
+void WorkQueue::platformInvalidate()
+{
+#if !ASSERT_DISABLED
+ MutexLocker lock(m_handlesLock);
+ ASSERT(m_handles.isEmpty());
+#endif
+
+ // FIXME: We need to ensure that any timer-queue timers that fire after this point don't try to
+ // access this WorkQueue <http://webkit.org/b/44690>.
+ ::DeleteTimerQueueEx(m_timerQueue, 0);
+}
+
+void WorkQueue::dispatch(std::function<void()> function)
+{
+ MutexLocker locker(m_workItemQueueLock);
+ ref();
+ m_workItemQueue.append(WorkItemWin::create(function, this));
+
+ // Spawn a work thread to perform the work we just added. As an optimization, we avoid
+ // spawning the thread if a work thread is already registered. This prevents multiple work
+ // threads from being spawned in most cases. (Note that when a work thread has been spawned but
+ // hasn't registered itself yet, m_isWorkThreadRegistered will be false and we'll end up
+ // spawning a second work thread here. But work thread registration process will ensure that
+ // only one thread actually ends up performing work.)
+ if (!m_isWorkThreadRegistered)
+ ::QueueUserWorkItem(workThreadCallback, this, WT_EXECUTEDEFAULT);
+}
+
+struct TimerContext : public ThreadSafeRefCounted<TimerContext> {
+ static RefPtr<TimerContext> create() { return adoptRef(new TimerContext); }
+
+ WorkQueue* queue;
+ std::function<void()> function;
+ Mutex timerMutex;
+ HANDLE timer;
+
+private:
+ TimerContext()
+ : queue(nullptr)
+ , timer(0)
+ {
+ }
+};
+
+void WorkQueue::timerCallback(void* context, BOOLEAN timerOrWaitFired)
+{
+ ASSERT_ARG(context, context);
+ ASSERT_UNUSED(timerOrWaitFired, timerOrWaitFired);
+
+ // Balanced by leakRef in scheduleWorkAfterDelay.
+ RefPtr<TimerContext> timerContext = adoptRef(static_cast<TimerContext*>(context));
+
+ timerContext->queue->dispatch(timerContext->function);
+
+ MutexLocker lock(timerContext->timerMutex);
+ ASSERT(timerContext->timer);
+ ASSERT(timerContext->queue->m_timerQueue);
+ if (!::DeleteTimerQueueTimer(timerContext->queue->m_timerQueue, timerContext->timer, 0)) {
+ // Getting ERROR_IO_PENDING here means that the timer will be destroyed once the callback is done executing.
+ ASSERT_WITH_MESSAGE(::GetLastError() == ERROR_IO_PENDING, "::DeleteTimerQueueTimer failed with error %lu", ::GetLastError());
+ }
+}
+
+void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, std::function<void()> function)
+{
+ ASSERT(m_timerQueue);
+ ref();
+
+ RefPtr<TimerContext> context = TimerContext::create();
+ context->queue = this;
+ context->function = function;
+
+ {
+ // The timer callback could fire before ::CreateTimerQueueTimer even returns, so we protect
+ // context->timer with a mutex to ensure the timer callback doesn't access it before the
+ // timer handle has been stored in it.
+ MutexLocker lock(context->timerMutex);
+
+ int64_t milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
+
+ // From empirical testing, we've seen CreateTimerQueueTimer() sometimes fire up to 5+ ms early.
+ // This causes havoc for clients of this code that expect to not be called back until the
+ // specified duration has expired. Other folks online have also observed some slop in the
+ // firing times of CreateTimerQuqueTimer(). From the data posted at
+ // http://omeg.pl/blog/2011/11/on-winapi-timers-and-their-resolution, it appears that the slop
+ // can be up to about 10 ms. To ensure that we don't fire the timer early, we'll tack on a
+ // slop adjustment to the duration, and we'll use double the worst amount of slop observed
+ // so far.
+ const int64_t slopAdjustment = 20;
+ if (milliseconds)
+ milliseconds += slopAdjustment;
+
+ // Since our timer callback is quick, we can execute in the timer thread itself and avoid
+ // an extra thread switch over to a worker thread.
+ if (!::CreateTimerQueueTimer(&context->timer, m_timerQueue, timerCallback, context.get(), clampTo<DWORD>(milliseconds), 0, WT_EXECUTEINTIMERTHREAD)) {
+ ASSERT_WITH_MESSAGE(false, "::CreateTimerQueueTimer failed with error %lu", ::GetLastError());
+ return;
+ }
+ }
+
+ // The timer callback will handle destroying context.
+ context.release().leakRef();
+}
+
+void WorkQueue::unregisterWaitAndDestroyItemSoon(PassRefPtr<HandleWorkItem> item)
+{
+ // We're going to make a blocking call to ::UnregisterWaitEx before closing the handle. (The
+ // blocking version of ::UnregisterWaitEx is much simpler than the non-blocking version.) If we
+ // do this on the current thread, we'll deadlock if we're currently in a callback function for
+ // the wait we're unregistering. So instead we do it asynchronously on some other worker thread.
+
+ ::QueueUserWorkItem(unregisterWaitAndDestroyItemCallback, item.leakRef(), WT_EXECUTEDEFAULT);
+}
+
+DWORD WINAPI WorkQueue::unregisterWaitAndDestroyItemCallback(void* context)
+{
+ ASSERT_ARG(context, context);
+ RefPtr<HandleWorkItem> item = adoptRef(static_cast<HandleWorkItem*>(context));
+
+ // Now that we know we're not in a callback function for the wait we're unregistering, we can
+ // make a blocking call to ::UnregisterWaitEx.
+ if (!::UnregisterWaitEx(item->waitHandle(), INVALID_HANDLE_VALUE)) {
+ DWORD error = ::GetLastError();
+ ASSERT_NOT_REACHED();
+ }
+
+ return 0;
+}
+
+#if PLATFORM(QT)
+void WorkQueue::registerHandle(HANDLE handle, const std::function<void()>& function)
+{
+ RefPtr<HandleWorkItem> handleItem = HandleWorkItem::createByAdoptingHandle(handle, function, this);
+
+ {
+ MutexLocker lock(m_handlesLock);
+ ASSERT_ARG(handle, !m_handles.contains(handle));
+ m_handles.set(handle, handleItem);
+ }
+
+ HANDLE waitHandle;
+ if (!::RegisterWaitForSingleObject(&waitHandle, handle, handleCallback, handleItem.get(), INFINITE, WT_EXECUTEDEFAULT)) {
+ DWORD error = ::GetLastError();
+ ASSERT_NOT_REACHED();
+ }
+ handleItem->setWaitHandle(waitHandle);
+}
+
+void WorkQueue::unregisterAndCloseHandle(HANDLE handle)
+{
+ RefPtr<HandleWorkItem> item;
+ {
+ MutexLocker locker(m_handlesLock);
+ ASSERT_ARG(handle, m_handles.contains(handle));
+ item = m_handles.take(handle);
+ }
+
+ unregisterWaitAndDestroyItemSoon(item.release());
+}
+#endif
+
+} // namespace WTF
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
index 0812b585d..48130eba4 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
@@ -67,6 +67,15 @@ void TextureMapperImageBuffer::beginClip(const TransformationMatrix& matrix, con
#endif
}
+void TextureMapperImageBuffer::endClip()
+{
+ GraphicsContext* context = currentContext();
+ if (!context)
+ return;
+
+ context->restore();
+}
+
void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, unsigned /* exposedEdges */)
{
GraphicsContext* context = currentContext();
@@ -115,9 +124,10 @@ void TextureMapperImageBuffer::drawNumber(int /* number */, const Color&, const
notImplemented();
}
-PassRefPtr<BitmapTexture> BitmapTextureImageBuffer::applyFilters(TextureMapper&, const FilterOperations&)
+PassRefPtr<BitmapTexture> BitmapTextureImageBuffer::applyFilters(TextureMapper&, const FilterOperations& filters)
{
- ASSERT_NOT_REACHED();
+ ASSERT_UNUSED(filters, filters.isEmpty());
+
return this;
}
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
index 234b8eeec..519a4820d 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
@@ -39,7 +39,7 @@ public:
void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) final;
void beginClip(const TransformationMatrix&, const FloatRect&) final;
void bindSurface(BitmapTexture* surface) final { m_currentSurface = surface;}
- void endClip() final { graphicsContext()->restore(); }
+ void endClip() final;
IntRect clipBounds() final { return currentContext()->clipBounds(); }
IntSize maxTextureSize() const final;
PassRefPtr<BitmapTexture> createTexture() final { return BitmapTextureImageBuffer::create(); }
diff --git a/Source/WebKit/CMakeLists.txt b/Source/WebKit/CMakeLists.txt
index 081858daa..aff418d6d 100644
--- a/Source/WebKit/CMakeLists.txt
+++ b/Source/WebKit/CMakeLists.txt
@@ -54,17 +54,22 @@ set(WebKit_PRIVATE_HEADERS_LOCATION Headers/${PROJECT_VERSION}/QtWebKit/Private)
WEBKIT_FRAMEWORK(WebKit)
-set_target_properties(WebKit PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
-install(TARGETS WebKit EXPORT WebKitTargets
- DESTINATION "${LIB_INSTALL_DIR}"
- RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
-)
+if (${PORT} STREQUAL "Qt")
+ set_target_properties(WebKit PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
+ install(TARGETS WebKit EXPORT WebKitTargets
+ DESTINATION "${LIB_INSTALL_DIR}"
+ RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
+ )
+ if (MSVC)
+ install(FILES $<TARGET_PDB_FILE:WebKit> DESTINATION "${BIN_INSTALL_DIR}" OPTIONAL)
+ endif ()
+
+ if (NOT MSVC)
+ ADD_PREFIX_HEADER(WebKit "${WEBKIT_DIR}/qt/WebKitPrefix.h")
+ endif ()
+endif ()
add_dependencies(WebKit WebCore)
if (TARGET WebKitGUID)
add_dependencies(WebKit WebKitGUID)
endif ()
-
-if (NOT MSVC AND ${PORT} STREQUAL "Qt")
- ADD_PREFIX_HEADER(WebKit "${WEBKIT_DIR}/qt/WebKitPrefix.h")
-endif ()
diff --git a/Source/WebKit/PlatformQt.cmake b/Source/WebKit/PlatformQt.cmake
index 7e319fade..82fc4595a 100644
--- a/Source/WebKit/PlatformQt.cmake
+++ b/Source/WebKit/PlatformQt.cmake
@@ -680,6 +680,9 @@ install(TARGETS WebKitWidgets EXPORT Qt5WebKitWidgetsTargets
DESTINATION "${LIB_INSTALL_DIR}"
RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
)
+if (MSVC)
+ install(FILES $<TARGET_PDB_FILE:WebKitWidgets> DESTINATION "${BIN_INSTALL_DIR}" OPTIONAL)
+endif ()
if (NOT MSVC AND WIN32)
ADD_PREFIX_HEADER(WebKitWidgets "qt/WebKitWidgetsPrefix.h")
diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp
index ddb8f75fe..4bc481126 100644
--- a/Source/WebKit/qt/Api/qwebsettings.cpp
+++ b/Source/WebKit/qt/Api/qwebsettings.cpp
@@ -525,6 +525,8 @@ QWebSettings* QWebSettings::globalSettings()
This is disabled by default.
\value SiteSpecificQuirksEnabled This setting enables WebKit's workaround for broken sites. It is
enabled by default.
+ \value CSSRegionsEnabled This setting enables support for the CSS 3 Regions module. This
+ CSS module is currently only a draft and support for it is enabled by default.
\value ScrollAnimatorEnabled This setting enables animated scrolling. It is disabled by default.
\value CaretBrowsingEnabled This setting enables caret browsing. It is disabled by default.
\value NotificationsEnabled Specifies whether support for the HTML 5 web notifications is enabled
@@ -536,6 +538,10 @@ QWebSettings* QWebSettings::globalSettings()
strongly discouraged as it makes the browser more prone to malicious code. This setting is intended
primarily for site-specific browsers (i.e. when the user can't navigate to unsecure web page) and for testing
web applications before deployment.
+ \value WebGLEnabled This setting enables support for WebGL.
+ It is enabled by default.
+ \value HyperlinkAuditingEnabled This setting enables support for hyperlink auditing (<a ping>).
+ It is disabled by default.
*/
/*!
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index 1c6504993..37e66a0ef 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -416,7 +416,7 @@ void ChromeClientQt::invalidateRootView(const IntRect& windowRect)
{
#if USE(TILED_BACKING_STORE)
if (platformPageClient()) {
- WebCore::TiledBackingStore* backingStore = m_webPage->mainFrameAdapter()->frame->tiledBackingStore();
+ WebCore::TiledBackingStore* backingStore = m_webPage->mainFrameAdapter().frame->tiledBackingStore();
if (!backingStore)
return;
backingStore->invalidate(windowRect);
@@ -457,7 +457,7 @@ void ChromeClientQt::scroll(const IntSize& delta, const IntRect& scrollViewRect,
void ChromeClientQt::delegatedScrollRequested(const IntPoint& point)
{
- const QPoint ofs = m_webPage->mainFrameAdapter()->scrollPosition();
+ const QPoint ofs = m_webPage->mainFrameAdapter().scrollPosition();
IntSize currentPosition(ofs.x(), ofs.y());
int x = point.x() - currentPosition.width();
int y = point.y() - currentPosition.height();
@@ -620,7 +620,7 @@ void ChromeClientQt::scheduleAnimation()
void ChromeClientQt::serviceScriptedAnimations()
{
- m_webPage->mainFrameAdapter()->frame->view()->serviceScriptedAnimations(currentTime());
+ m_webPage->mainFrameAdapter().frame->view()->serviceScriptedAnimations(currentTime());
}
#endif
@@ -660,9 +660,9 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const
return IntRect();
if (!platformPageClient()->viewResizesToContentsEnabled()) {
- const QPoint ofs = m_webPage->mainFrameAdapter()->scrollPosition();
+ const QPoint ofs = m_webPage->mainFrameAdapter().scrollPosition();
IntSize offset(ofs.x(), ofs.y());
- return QRect(QPoint(offset.width(), offset.height()), m_webPage->mainFrameAdapter()->frameRect().size());
+ return QRect(QPoint(offset.width(), offset.height()), m_webPage->mainFrameAdapter().frameRect().size());
}
return enclosingIntRect(FloatRect(platformPageClient()->graphicsItemVisibleRect()));
diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index b45fb6b2a..76038cbc0 100644
--- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -102,7 +102,7 @@ static QString drtDescriptionSuitableForTestResult(WebCore::Frame* webCoreFrame)
QWebFrameAdapter* frame = QWebFrameAdapter::kit(webCoreFrame);
QString name = webCoreFrame->tree().uniqueName();
- bool isMainFrame = frame == frame->pageAdapter->mainFrameAdapter();
+ bool isMainFrame = frame == &frame->pageAdapter->mainFrameAdapter();
if (isMainFrame) {
if (!name.isEmpty())
return QString::fromLatin1("main frame \"%1\"").arg(name);
@@ -986,7 +986,7 @@ void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsi
&& !host.isEmpty()
&& (urlScheme == QLatin1String("http") || urlScheme == QLatin1String("https"))) {
- QUrl testURL = m_webFrame->pageAdapter->mainFrameAdapter()->frameLoaderClient->lastRequestedUrl();
+ QUrl testURL = m_webFrame->pageAdapter->mainFrameAdapter().frameLoaderClient->lastRequestedUrl();
QString testHost = testURL.host();
QString testURLScheme = testURL.scheme().toLower();
@@ -1136,7 +1136,7 @@ WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage(const WebCore::Navigatio
QWebPageAdapter* newPage = m_webFrame->pageAdapter->createWindow(/* modalDialog = */ false);
if (!newPage)
return 0;
- return newPage->mainFrameAdapter()->frame;
+ return newPage->mainFrameAdapter().frame;
}
void FrameLoaderClientQt::dispatchDecidePolicyForResponse(const WebCore::ResourceResponse& response, const WebCore::ResourceRequest&, FramePolicyFunction function)
diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
index 29879a08a..aaa248667 100644
--- a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
@@ -195,7 +195,7 @@ Inspector::FrontendChannel* InspectorClientQt::openLocalFrontend(WebCore::Inspec
m_frontendWebPage->page->setGroupName("__WebInspectorPageGroup__");
frontendChannel = this;
- inspectorPage->mainFrameAdapter()->load(QNetworkRequest(inspectorUrl));
+ inspectorPage->mainFrameAdapter().load(QNetworkRequest(inspectorUrl));
m_inspectedWebPage->setInspectorFrontend(view);
return frontendChannel;
@@ -238,7 +238,7 @@ void InspectorClientQt::highlight()
void InspectorClientQt::hideHighlight()
{
WebCore::Frame& frame = m_inspectedWebPage->page->mainFrame();
- QRect rect = m_inspectedWebPage->mainFrameAdapter()->frameRect();
+ QRect rect = m_inspectedWebPage->mainFrameAdapter().frameRect();
if (!rect.isEmpty())
frame.view()->invalidateRect(rect);
}
diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
index 45df842a5..bd9fee1f2 100644
--- a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
@@ -227,7 +227,7 @@ void InspectorServerRequestHandlerQt::tcpReadyRead()
indexHtml.append(QString::fromLatin1("<li><a href=\"/webkit/inspector/UserInterface/Main.html?page=%1\">%2</li>\n")
.arg(it.key())
- .arg(QUrl(it.value()->m_inspectedWebPage->mainFrameAdapter()->url).toString()));
+ .arg(QUrl(it.value()->m_inspectedWebPage->mainFrameAdapter().url).toString()));
}
indexHtml.append(QLatin1String("</ul></body></html>"));
response = indexHtml.toLatin1();
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
index de90866c6..e6145b6ff 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
@@ -465,7 +465,7 @@ QString QWebFrameAdapter::uniqueName() const
// This code is copied from ChromeClientGtk.cpp.
static void coalesceRectsIfPossible(const QRect& clipRect, QVector<QRect>& rects)
{
- const unsigned rectThreshold = 10;
+ const int rectThreshold = 10;
const float wastedSpaceThreshold = 0.75f;
bool useUnionedRect = (rects.size() <= 1) || (rects.size() > rectThreshold);
if (!useUnionedRect) {
@@ -474,8 +474,8 @@ static void coalesceRectsIfPossible(const QRect& clipRect, QVector<QRect>& rects
// is too large, then we will do individual rect painting instead.
float unionPixels = (clipRect.width() * clipRect.height());
float singlePixels = 0;
- for (size_t i = 0; i < rects.size(); ++i)
- singlePixels += rects[i].width() * rects[i].height();
+ for (auto& rect : rects)
+ singlePixels += rect.width() * rect.height();
float wastedSpace = 1 - (singlePixels / unionPixels);
if (wastedSpace <= wastedSpaceThreshold)
useUnionedRect = true;
@@ -924,7 +924,7 @@ QWebElement QWebHitTestResultPrivate::elementForInnerNode() const
QSize QWebFrameAdapter::customLayoutSize() const
{
- ASSERT(pageAdapter->mainFrameAdapter() == this);
+ ASSERT(&pageAdapter->mainFrameAdapter() == this);
FrameView* view = frame->view();
ASSERT(view);
if (view->useFixedLayout())
@@ -934,7 +934,7 @@ QSize QWebFrameAdapter::customLayoutSize() const
void QWebFrameAdapter::setCustomLayoutSize(const QSize& size)
{
- ASSERT(pageAdapter->mainFrameAdapter() == this);
+ ASSERT(&pageAdapter->mainFrameAdapter() == this);
FrameView* view = frame->view();
ASSERT(view);
@@ -949,7 +949,7 @@ void QWebFrameAdapter::setCustomLayoutSize(const QSize& size)
void QWebFrameAdapter::setFixedVisibleContentRect(const QRect& rect)
{
- ASSERT(pageAdapter->mainFrameAdapter() == this);
+ ASSERT(&pageAdapter->mainFrameAdapter() == this);
FrameView* view = frame->view();
ASSERT(view);
view->setFixedVisibleContentRect(rect);
@@ -957,7 +957,7 @@ void QWebFrameAdapter::setFixedVisibleContentRect(const QRect& rect)
void QWebFrameAdapter::setViewportSize(const QSize& size)
{
- ASSERT(pageAdapter->mainFrameAdapter() == this);
+ ASSERT(&pageAdapter->mainFrameAdapter() == this);
FrameView* view = frame->view();
ASSERT(view);
view->resize(size);
@@ -967,14 +967,14 @@ void QWebFrameAdapter::setViewportSize(const QSize& size)
void QWebFrameAdapter::setPaintsEntireContents(bool resizesToContents)
{
- ASSERT(pageAdapter->mainFrameAdapter() == this);
+ ASSERT(&pageAdapter->mainFrameAdapter() == this);
ASSERT(frame->view());
frame->view()->setPaintsEntireContents(resizesToContents);
}
void QWebFrameAdapter::setDelegatesScrolling(bool resizesToContents)
{
- ASSERT(pageAdapter->mainFrameAdapter() == this);
+ ASSERT(&pageAdapter->mainFrameAdapter() == this);
ASSERT(frame->view());
frame->view()->setDelegatesScrolling(resizesToContents);
}
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
index 4d2b30d37..a6d0267af 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
@@ -311,7 +311,7 @@ QWebPageAdapter::~QWebPageAdapter()
void QWebPageAdapter::deletePage()
{
// Before we delete the page, detach the mainframe's loader
- FrameLoader& loader = mainFrameAdapter()->frame->loader();
+ FrameLoader& loader = mainFrameAdapter().frame->loader();
loader.detachFromParent();
delete page;
page = 0;
@@ -399,7 +399,7 @@ void QWebPageAdapter::setContentEditable(bool editable)
page->setEditable(editable);
page->setTabKeyCyclesThroughElements(!editable);
- Frame* frame = mainFrameAdapter()->frame;
+ Frame* frame = mainFrameAdapter().frame;
if (editable) {
frame->editor().applyEditingStyleToBodyElement();
// FIXME: mac port calls this if there is no selectedDOMRange
@@ -488,7 +488,7 @@ void QWebPageAdapter::adjustPointForClicking(QMouseEvent* ev)
void QWebPageAdapter::mouseMoveEvent(QMouseEvent* ev)
{
- WebCore::Frame* frame = mainFrameAdapter()->frame;
+ WebCore::Frame* frame = mainFrameAdapter().frame;
if (!frame->view())
return;
if (ev->buttons() == Qt::NoButton)
@@ -500,7 +500,7 @@ void QWebPageAdapter::mouseMoveEvent(QMouseEvent* ev)
void QWebPageAdapter::mousePressEvent(QMouseEvent* ev)
{
- WebCore::Frame* frame = mainFrameAdapter()->frame;
+ WebCore::Frame* frame = mainFrameAdapter().frame;
if (!frame->view())
return;
@@ -533,7 +533,7 @@ void QWebPageAdapter::mousePressEvent(QMouseEvent* ev)
void QWebPageAdapter::mouseDoubleClickEvent(QMouseEvent *ev)
{
- WebCore::Frame* frame = mainFrameAdapter()->frame;
+ WebCore::Frame* frame = mainFrameAdapter().frame;
if (!frame->view())
return;
@@ -550,7 +550,7 @@ void QWebPageAdapter::mouseDoubleClickEvent(QMouseEvent *ev)
void QWebPageAdapter::mouseTripleClickEvent(QMouseEvent *ev)
{
- WebCore::Frame* frame = mainFrameAdapter()->frame;
+ WebCore::Frame* frame = mainFrameAdapter().frame;
if (!frame->view())
return;
@@ -564,7 +564,7 @@ void QWebPageAdapter::mouseTripleClickEvent(QMouseEvent *ev)
void QWebPageAdapter::mouseReleaseEvent(QMouseEvent *ev)
{
- WebCore::Frame* frame = mainFrameAdapter()->frame;
+ WebCore::Frame* frame = mainFrameAdapter().frame;
if (!frame->view())
return;
@@ -605,7 +605,7 @@ void QWebPageAdapter::handleSoftwareInputPanel(Qt::MouseButton button, const QPo
#ifndef QT_NO_WHEELEVENT
void QWebPageAdapter::wheelEvent(QWheelEvent *ev, int wheelScrollLines)
{
- WebCore::Frame* frame = mainFrameAdapter()->frame;
+ WebCore::Frame* frame = mainFrameAdapter().frame;
if (!frame->view())
return;
@@ -1027,7 +1027,7 @@ void QWebPageAdapter::didCloseInspector()
void QWebPageAdapter::updateActionInternal(QWebPageAdapter::MenuAction action, const char* commandName, bool* enabled, bool* checked)
{
- WebCore::FrameLoader& loader = mainFrameAdapter()->frame->loader();
+ WebCore::FrameLoader& loader = mainFrameAdapter().frame->loader();
WebCore::Editor& editor = page->focusController().focusedOrMainFrame().editor();
switch (action) {
@@ -1135,11 +1135,11 @@ void QWebPageAdapter::triggerAction(QWebPageAdapter::MenuAction action, QWebHitT
page->backForward().goForward();
break;
case Stop:
- mainFrameAdapter()->frame->loader().stopForUserCancel();
+ mainFrameAdapter().frame->loader().stopForUserCancel();
updateNavigationActions();
break;
case Reload:
- mainFrameAdapter()->frame->loader().reload(endToEndReload);
+ mainFrameAdapter().frame->loader().reload(endToEndReload);
break;
case SetTextDirectionDefault:
@@ -1454,7 +1454,7 @@ void QWebPageAdapter::focusInEvent(QFocusEvent *)
focusController.setActive(true);
focusController.setFocused(true);
if (!focusController.focusedFrame())
- focusController.setFocusedFrame(mainFrameAdapter()->frame);
+ focusController.setFocusedFrame(mainFrameAdapter().frame);
}
void QWebPageAdapter::focusOutEvent(QFocusEvent *)
@@ -1504,7 +1504,7 @@ bool QWebPageAdapter::handleShortcutOverrideEvent(QKeyEvent* event)
bool QWebPageAdapter::touchEvent(QTouchEvent* event)
{
#if ENABLE(TOUCH_EVENTS)
- Frame* frame = mainFrameAdapter()->frame;
+ Frame* frame = mainFrameAdapter().frame;
if (!frame->view() || !frame->document())
return false;
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
index 7174d0d96..5e46fcdd7 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
@@ -230,7 +230,7 @@ public:
virtual void updateNavigationActions() = 0;
virtual void clearCustomActions() = 0;
- virtual QWebFrameAdapter* mainFrameAdapter() = 0;
+ virtual QWebFrameAdapter& mainFrameAdapter() = 0;
virtual QObject* inspectorHandle() = 0;
virtual void setInspectorFrontend(QObject*) = 0;
diff --git a/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp
index 552fe6555..85bf84c1b 100644
--- a/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp
@@ -31,7 +31,7 @@
using namespace WebCore;
-TextureMapperLayerClientQt::TextureMapperLayerClientQt(QWebFrameAdapter* frame)
+TextureMapperLayerClientQt::TextureMapperLayerClientQt(QWebFrameAdapter& frame)
: m_frame(frame)
, m_syncTimer(*this, &TextureMapperLayerClientQt::syncLayers)
, m_rootTextureMapperLayer(0)
@@ -71,7 +71,7 @@ void TextureMapperLayerClientQt::setRootGraphicsLayer(GraphicsLayer* layer)
m_rootGraphicsLayer->setMasksToBounds(false);
m_rootGraphicsLayer->setSize(IntSize(1, 1));
TextureMapper::AccelerationMode mode = TextureMapper::SoftwareMode;
- if (m_frame->pageAdapter->client->makeOpenGLContextCurrentIfAvailable())
+ if (pageClient() && pageClient()->makeOpenGLContextCurrentIfAvailable())
mode = TextureMapper::OpenGLMode;
m_textureMapper = TextureMapper::create(mode);
m_rootTextureMapperLayer->setTextureMapper(m_textureMapper.get());
@@ -87,7 +87,7 @@ void TextureMapperLayerClientQt::syncLayers()
if (m_rootGraphicsLayer)
syncRootLayer();
- bool didSync = m_frame->frame->view()->flushCompositingStateIncludingSubframes();
+ bool didSync = m_frame.frame->view()->flushCompositingStateIncludingSubframes();
if (!m_rootGraphicsLayer)
return;
@@ -98,7 +98,8 @@ void TextureMapperLayerClientQt::syncLayers()
if (rootLayer()->descendantsOrSelfHaveRunningAnimations() && !m_syncTimer.isActive())
m_syncTimer.startOneShot(1.0 / 60.0);
- m_frame->pageAdapter->client->repaintViewport();
+ if (pageClient())
+ pageClient()->repaintViewport();
}
void TextureMapperLayerClientQt::renderCompositedLayers(GraphicsContext& context, const IntRect& clip)
@@ -145,3 +146,8 @@ void TextureMapperLayerClientQt::renderCompositedLayers(GraphicsContext& context
m_textureMapper->endClip();
m_textureMapper->endPainting();
}
+
+QWebPageClient* TextureMapperLayerClientQt::pageClient() const
+{
+ return m_frame.pageAdapter->client.data();
+}
diff --git a/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.h b/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.h
index f34a1b2ce..b4e810879 100644
--- a/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.h
+++ b/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.h
@@ -21,20 +21,21 @@
#ifndef TextureMapperLayerClientQt_h
#define TextureMapperLayerClientQt_h
-class QWebFrameAdapter;
-
#include "GraphicsLayer.h"
#include "TextureMapper.h"
#include "TextureMapperFPSCounter.h"
#include "Timer.h"
+class QWebFrameAdapter;
+class QWebPageClient;
+
namespace WebCore {
class TextureMapperLayer;
class TextureMapperLayerClientQt final : public GraphicsLayerClient {
public:
- TextureMapperLayerClientQt(QWebFrameAdapter*);
+ TextureMapperLayerClientQt(QWebFrameAdapter&);
~TextureMapperLayerClientQt();
void syncRootLayer();
TextureMapperLayer* rootLayer();
@@ -46,8 +47,11 @@ public:
void syncLayers();
void renderCompositedLayers(GraphicsContext&, const IntRect& clip);
+
private:
- QWebFrameAdapter* m_frame;
+ QWebPageClient* pageClient() const;
+
+ QWebFrameAdapter& m_frame;
std::unique_ptr<GraphicsLayer> m_rootGraphicsLayer;
Timer m_syncTimer;
WebCore::TextureMapperLayer* m_rootTextureMapperLayer;
diff --git a/Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp b/Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp
index 89ea0468e..79eb12d98 100644
--- a/Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp
+++ b/Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp
@@ -119,8 +119,8 @@ void QGraphicsWebViewPrivate::updateResizesToContentsForPage()
QObject::disconnect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
q, SLOT(_q_contentsSizeChanged(const QSize&)));
}
- page->d->mainFrameAdapter()->setPaintsEntireContents(resizesToContents);
- page->d->mainFrameAdapter()->setDelegatesScrolling(resizesToContents);
+ page->d->mainFrameAdapter().setPaintsEntireContents(resizesToContents);
+ page->d->mainFrameAdapter().setDelegatesScrolling(resizesToContents);
}
void QGraphicsWebViewPrivate::_q_contentsSizeChanged(const QSize& size)
diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.cpp b/Source/WebKit/qt/WidgetApi/qwebpage.cpp
index 5bb2f315d..11b5a9dd6 100644
--- a/Source/WebKit/qt/WidgetApi/qwebpage.cpp
+++ b/Source/WebKit/qt/WidgetApi/qwebpage.cpp
@@ -328,9 +328,9 @@ QWebFullScreenVideoHandler *QWebPagePrivate::createFullScreenVideoHandler()
}
#endif
-QWebFrameAdapter *QWebPagePrivate::mainFrameAdapter()
+QWebFrameAdapter& QWebPagePrivate::mainFrameAdapter()
{
- return q->mainFrame()->d;
+ return *q->mainFrame()->d;
}
QStringList QWebPagePrivate::chooseFiles(QWebFrameAdapter *frame, bool allowMultiple, const QStringList &suggestedFileNames)
@@ -1222,6 +1222,48 @@ QWebInspector* QWebPagePrivate::getOrCreateInspector()
\value WebModalDialog The window acts as modal dialog.
*/
+/*!
+ \enum QWebPage::PermissionPolicy
+
+ This enum describes the permission policies that the user may set for data or device access.
+
+ \value PermissionUnknown It is unknown whether the user grants or denies permission.
+ \value PermissionGrantedByUser The user has granted permission.
+ \value PermissionDeniedByUser The user has denied permission.
+
+ \sa featurePermissionRequested(), featurePermissionRequestCanceled(), setFeaturePermission(), Feature
+*/
+
+/*!
+ \enum QWebPage::Feature
+
+ This enum describes the platform feature access categories that the user may be asked to grant or deny access to.
+
+ \value Notifications Access to notifications
+ \value Geolocation Access to location hardware or service
+
+ \sa featurePermissionRequested(), featurePermissionRequestCanceled(), setFeaturePermission(), PermissionPolicy
+
+*/
+
+/*!
+ \fn void QWebPage::featurePermissionRequested(QWebFrame* frame, QWebPage::Feature feature);
+
+ This is signal is emitted when the given \a frame requests to make use of
+ the resource or device identified by \a feature.
+
+ \sa featurePermissionRequestCanceled(), setFeaturePermission()
+*/
+
+/*!
+ \fn void QWebPage::featurePermissionRequestCanceled(QWebFrame* frame, QWebPage::Feature feature);
+
+ This is signal is emitted when the given \a frame cancels a previously issued
+ request to make use of \a feature.
+
+ \sa featurePermissionRequested(), setFeaturePermission()
+
+*/
/*!
\class QWebPage::ViewportAttributes
@@ -1623,6 +1665,13 @@ bool QWebPage::shouldInterruptJavaScript()
#endif
}
+/*!
+ \fn void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, PermissionPolicy policy)
+
+ Sets the permission for the given \a frame to use \a feature to \a policy.
+
+ \sa featurePermissionRequested(), featurePermissionRequestCanceled()
+*/
void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, PermissionPolicy policy)
{
#if !ENABLE(NOTIFICATIONS) && !ENABLE(LEGACY_NOTIFICATIONS) && !ENABLE(GEOLOCATION)
@@ -1959,11 +2008,11 @@ void QWebPage::setViewportSize(const QSize &size) const
d->updateWindow();
- QWebFrameAdapter* mainFrame = d->mainFrameAdapter();
- if (!mainFrame->hasView())
+ QWebFrameAdapter& mainFrame = d->mainFrameAdapter();
+ if (!mainFrame.hasView())
return;
- mainFrame->setViewportSize(size);
+ mainFrame.setViewportSize(size);
}
void QWebPagePrivate::updateWindow()
@@ -2112,11 +2161,11 @@ void QWebPage::setPreferredContentsSize(const QSize& size) const
d->fixedLayoutSize = size;
- QWebFrameAdapter* mainFrame = d->mainFrameAdapter();
- if (!mainFrame->hasView())
+ QWebFrameAdapter& mainFrame = d->mainFrameAdapter();
+ if (!mainFrame.hasView())
return;
- mainFrame->setCustomLayoutSize(size);
+ mainFrame.setCustomLayoutSize(size);
}
/*
@@ -2131,11 +2180,11 @@ void QWebPage::setPreferredContentsSize(const QSize& size) const
*/
void QWebPage::setActualVisibleContentRect(const QRect& rect) const
{
- QWebFrameAdapter* mainFrame = d->mainFrameAdapter();
- if (!mainFrame->hasView())
+ QWebFrameAdapter& mainFrame = d->mainFrameAdapter();
+ if (!mainFrame.hasView())
return;
- mainFrame->setFixedVisibleContentRect(rect);
+ mainFrame.setFixedVisibleContentRect(rect);
}
/*!
diff --git a/Source/WebKit/qt/WidgetApi/qwebpage_p.h b/Source/WebKit/qt/WidgetApi/qwebpage_p.h
index 49e67af97..7b2c7ff6f 100644
--- a/Source/WebKit/qt/WidgetApi/qwebpage_p.h
+++ b/Source/WebKit/qt/WidgetApi/qwebpage_p.h
@@ -97,7 +97,7 @@ public:
#if USE(QT_MULTIMEDIA)
QWebFullScreenVideoHandler* createFullScreenVideoHandler() override;
#endif
- QWebFrameAdapter* mainFrameAdapter() override;
+ QWebFrameAdapter& mainFrameAdapter() override;
QStringList chooseFiles(QWebFrameAdapter*, bool allowMultiple, const QStringList& suggestedFileNames) override;
QColor colorSelectionRequested(const QColor& selectedColor) override;
std::unique_ptr<QWebSelectMethod> createSelectPopup() override;
diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake
index d57e9133c..a4b4fa4fe 100644
--- a/Source/cmake/OptionsQt.cmake
+++ b/Source/cmake/OptionsQt.cmake
@@ -458,6 +458,10 @@ if (WIN32 AND COMPILER_IS_GCC_OR_CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-keep-inline-dllexport")
endif ()
+if (APPLE)
+ SET_AND_EXPOSE_TO_BUILD(HAVE_QOS_CLASSES 1)
+endif ()
+
if (ENABLE_MATHML)
SET_AND_EXPOSE_TO_BUILD(ENABLE_OPENTYPE_MATH 1)
endif ()
diff --git a/Tools/qmake/projects/qtjpeg/qtjpeg.pro b/Tools/qmake/projects/qtjpeg/qtjpeg.pro
index a0c817a47..33aa665d3 100644
--- a/Tools/qmake/projects/qtjpeg/qtjpeg.pro
+++ b/Tools/qmake/projects/qtjpeg/qtjpeg.pro
@@ -5,8 +5,7 @@ TARGET = qtjpeg
CONFIG += \
static \
hide_symbols \
- exceptions_off rtti_off warn_off \
- installed
+ exceptions_off rtti_off warn_off
load(qt_helper_lib)
diff --git a/Tools/qmake/projects/qtpng/qtpng.pro b/Tools/qmake/projects/qtpng/qtpng.pro
index b6512f012..349034c56 100644
--- a/Tools/qmake/projects/qtpng/qtpng.pro
+++ b/Tools/qmake/projects/qtpng/qtpng.pro
@@ -9,8 +9,7 @@ TARGET = qtpng
CONFIG += \
static \
hide_symbols \
- exceptions_off rtti_off warn_off \
- installed
+ exceptions_off rtti_off warn_off
load(qt_helper_lib)
diff --git a/Tools/qt/manifest.txt b/Tools/qt/manifest.txt
index 5d06c4530..8ae73e35f 100644
--- a/Tools/qt/manifest.txt
+++ b/Tools/qt/manifest.txt
@@ -69,7 +69,8 @@ exclude Source/WebKit2/Resources
file Source/WebCore/English.lproj/mediaControlsLocalizedStrings.js
# Windows-specific code
-file Source/WTF/wtf/win/GDIObject.h
+file Source/WTF/wtf/threads/win/BinarySemaphoreWin.cpp
+file Source/WTF/wtf/win
file Source/WebCore/platform/graphics/win/LocalWindowsContext.h
file Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
file Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp
@@ -82,6 +83,7 @@ file Source/WebCore/platform/win/WebCoreInstanceHandle.h
# macOS-specific code
file Source/WTF/wtf/cf
+file Source/WTF/wtf/cocoa
file Source/WTF/wtf/text/cf
file Source/WebCore/platform/cf/SharedBufferCF.cpp