diff -Nru webkit2gtk-2.16.1/debian/changelog webkit2gtk-2.16.2/debian/changelog --- webkit2gtk-2.16.1/debian/changelog 2017-05-08 18:17:20.000000000 +0000 +++ webkit2gtk-2.16.2/debian/changelog 2017-05-13 22:16:26.000000000 +0000 @@ -1,3 +1,13 @@ +webkit2gtk (2.16.2-0ubuntu0.17.04.1) zesty; urgency=medium + + * New upstream release (LP: #1690536) + * Drop patches applied in new release + - fix-ftbfs-x32.patch + - fix-google-login.patch + - fix-new-youtube.patch + + -- Jeremy Bicha Sat, 13 May 2017 18:16:26 -0400 + webkit2gtk (2.16.1-1ubuntu0.17.04.1) zesty; urgency=medium * Add fix-google-login.patch: diff -Nru webkit2gtk-2.16.1/debian/patches/fix-ftbfs-x32.patch webkit2gtk-2.16.2/debian/patches/fix-ftbfs-x32.patch --- webkit2gtk-2.16.1/debian/patches/fix-ftbfs-x32.patch 2017-05-08 18:17:20.000000000 +0000 +++ webkit2gtk-2.16.2/debian/patches/fix-ftbfs-x32.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -From: Thorsten Glaser -Subject: Fix FTBFS in x32 -Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=856498 -Index: webkitgtk/Source/WTF/wtf/Platform.h -=================================================================== ---- webkitgtk.orig/Source/WTF/wtf/Platform.h -+++ webkitgtk/Source/WTF/wtf/Platform.h -@@ -679,7 +679,7 @@ - #endif - - #if !defined(USE_JSVALUE64) && !defined(USE_JSVALUE32_64) --#if (CPU(X86_64) && (OS(UNIX) || OS(WINDOWS))) \ -+#if (CPU(X86_64) && !defined(__ILP32__) && (OS(UNIX) || OS(WINDOWS))) \ - || (CPU(IA64) && !CPU(IA64_32)) \ - || CPU(ALPHA) \ - || CPU(ARM64) \ diff -Nru webkit2gtk-2.16.1/debian/patches/fix-google-login.patch webkit2gtk-2.16.2/debian/patches/fix-google-login.patch --- webkit2gtk-2.16.1/debian/patches/fix-google-login.patch 2017-05-08 18:17:20.000000000 +0000 +++ webkit2gtk-2.16.2/debian/patches/fix-google-login.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -From: Michael Catanzaro -Subject: [GTK] Cannot sign in with new Google sign-in page -Bug: https://bugs.webkit.org/show_bug.cgi?id=171770 -Bug-Ubuntu: https://launchpad.net/bugs/1687019 - Reviewed by Carlos Garcia Campos. - - Google's new authentication page does not work with the Firefox user - agent that's required to make various Google websites work. Special-case - accounts.google.com so that it receives our standard user agent. - -Index: webkitgtk/Source/WebCore/platform/UserAgentQuirks.cpp -=================================================================== ---- webkitgtk/Source/WebCore/platform/UserAgentQuirks.cpp (revision 216342) -+++ webkitgtk/Source/WebCore/platform/UserAgentQuirks.cpp (revision 216343) -@@ -42,6 +42,7 @@ - // https://webkit.org/b/142074 carefully before changing. Test that Earth - // view is available in Google Maps. Test Google Calendar. Test downloading -- // the Hangouts browser plugin. Change platformVersionForUAString() to -- // return "FreeBSD amd64" and test Maps and Calendar again. -+ // the Hangouts browser plugin. Test logging out and logging in to a Google -+ // account. Change platformVersionForUAString() to return "FreeBSD amd64" -+ // and test everything again. - if (baseDomain.startsWith("google.")) - return true; -@@ -76,5 +77,5 @@ - static bool urlRequiresFirefoxBrowser(const URL& url) - { -- return isGoogle(url); -+ return isGoogle(url) && url.host() != "accounts.google.com"; - } - diff -Nru webkit2gtk-2.16.1/debian/patches/fix-new-youtube.patch webkit2gtk-2.16.2/debian/patches/fix-new-youtube.patch --- webkit2gtk-2.16.1/debian/patches/fix-new-youtube.patch 2017-05-08 18:17:20.000000000 +0000 +++ webkit2gtk-2.16.2/debian/patches/fix-new-youtube.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -From: Michael Catanzaro -Subject: YouTube user agent quirk breaks new YouTube -Bug: https://bugs.webkit.org/show_bug.cgi?id=171603 - Reviewed by Carlos Garcia Campos. - - Our user agent quirk to make YouTube 360 work breaks the new YouTube UI, causing it to - attempt to use the obsolete custom elements v0 API. WebKit only supports the v1 API. We - have to remove this quirk. - -Index: webkitgtk/Source/WebCore/platform/UserAgentQuirks.cpp -=================================================================== ---- webkitgtk/Source/WebCore/platform/UserAgentQuirks.cpp (revision 216138) -+++ webkitgtk/Source/WebCore/platform/UserAgentQuirks.cpp (revision 216139) -@@ -65,8 +65,4 @@ - // https://bugs.webkit.org/show_bug.cgi?id=147296 - if (baseDomain == "typekit.net" || baseDomain == "typekit.com") -- return true; -- -- // Needed for YouTube 360 with WebKitGTK+ and WPE (requires ENABLE_MEDIA_SOURCE). -- if (baseDomain == "youtube.com") - return true; - diff -Nru webkit2gtk-2.16.1/debian/patches/series webkit2gtk-2.16.2/debian/patches/series --- webkit2gtk-2.16.1/debian/patches/series 2017-05-08 18:17:20.000000000 +0000 +++ webkit2gtk-2.16.2/debian/patches/series 2017-05-13 22:16:26.000000000 +0000 @@ -2,6 +2,3 @@ fix-ftbfs-alpha.patch fix-ftbfs-armel.patch fix-ftbfs-hurd.patch -fix-ftbfs-x32.patch -fix-google-login.patch -fix-new-youtube.patch diff -Nru webkit2gtk-2.16.1/Documentation/webkit2gtk-4.0/html/index.html webkit2gtk-2.16.2/Documentation/webkit2gtk-4.0/html/index.html --- webkit2gtk-2.16.1/Documentation/webkit2gtk-4.0/html/index.html 2017-04-04 07:34:15.000000000 +0000 +++ webkit2gtk-2.16.2/Documentation/webkit2gtk-4.0/html/index.html 2017-05-09 08:22:06.000000000 +0000 @@ -14,7 +14,7 @@
-

for WebKit2GTK+ 2.16.1

+

for WebKit2GTK+ 2.16.2


diff -Nru webkit2gtk-2.16.1/Documentation/webkit2gtk-4.0/html/webkit2gtk-4.0-WebKitVersion.html webkit2gtk-2.16.2/Documentation/webkit2gtk-4.0/html/webkit2gtk-4.0-WebKitVersion.html --- webkit2gtk-2.16.1/Documentation/webkit2gtk-4.0/html/webkit2gtk-4.0-WebKitVersion.html 2017-04-04 07:34:05.000000000 +0000 +++ webkit2gtk-2.16.2/Documentation/webkit2gtk-4.0/html/webkit2gtk-4.0-WebKitVersion.html 2017-05-09 08:21:56.000000000 +0000 @@ -177,7 +177,7 @@

WEBKIT_MICRO_VERSION

-
#define WEBKIT_MICRO_VERSION (1)
+
#define WEBKIT_MICRO_VERSION (2)
 

Like webkit_get_micro_version(), but from the headers used at application compile time, rather than from the library linked diff -Nru webkit2gtk-2.16.1/Documentation/webkitdomgtk-4.0/html/index.html webkit2gtk-2.16.2/Documentation/webkitdomgtk-4.0/html/index.html --- webkit2gtk-2.16.1/Documentation/webkitdomgtk-4.0/html/index.html 2017-04-04 07:33:45.000000000 +0000 +++ webkit2gtk-2.16.2/Documentation/webkitdomgtk-4.0/html/index.html 2017-05-09 08:21:36.000000000 +0000 @@ -14,7 +14,7 @@

-

for WebKitDOMGTK+ 2.16.1

+

for WebKitDOMGTK+ 2.16.2


diff -Nru webkit2gtk-2.16.1/NEWS webkit2gtk-2.16.2/NEWS --- webkit2gtk-2.16.1/NEWS 2017-04-04 07:41:30.000000000 +0000 +++ webkit2gtk-2.16.2/NEWS 2017-05-09 07:56:50.000000000 +0000 @@ -1,4 +1,16 @@ ================== +WebKitGTK+ 2.16.2 +================== + + - Update user agent quirks to make Youtube and new Google login page work. + - Fix rendering of animated PNGs. + - Fix playing of some live streams. + - Update several web inspector icons. + - Fix the build with NPAPI plugins enabled but X11 disabled. + - Fix the build with OpenGL disabled. + - Fix several crashes and rendering issues. + +================== WebKitGTK+ 2.16.1 ================== diff -Nru webkit2gtk-2.16.1/Source/bmalloc/bmalloc/bmalloc.h webkit2gtk-2.16.2/Source/bmalloc/bmalloc/bmalloc.h --- webkit2gtk-2.16.1/Source/bmalloc/bmalloc/bmalloc.h 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/bmalloc/bmalloc/bmalloc.h 2017-05-08 12:35:15.000000000 +0000 @@ -76,7 +76,7 @@ scavengeThisThread(); std::unique_lock lock(PerProcess::mutex()); - PerProcess::get()->scavenge(lock, std::chrono::milliseconds(0)); + PerProcess::get()->scavenge(lock, Sync); } inline bool isEnabled() diff -Nru webkit2gtk-2.16.1/Source/bmalloc/bmalloc/Heap.cpp webkit2gtk-2.16.2/Source/bmalloc/bmalloc/Heap.cpp --- webkit2gtk-2.16.1/Source/bmalloc/bmalloc/Heap.cpp 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/bmalloc/bmalloc/Heap.cpp 2017-05-08 12:35:17.000000000 +0000 @@ -36,7 +36,6 @@ Heap::Heap(std::lock_guard&) : m_vmPageSizePhysical(vmPageSizePhysical()) - , m_isAllocatingPages(false) , m_scavenger(*this, &Heap::concurrentScavenge) , m_debugHeap(nullptr) { @@ -108,52 +107,63 @@ void Heap::concurrentScavenge() { - std::unique_lock lock(PerProcess::mutex()); - #if BOS(DARWIN) - if (auto requestedQOSClass = PerProcess::getFastCase()->takeRequestedScavengerThreadQOSClass()) - pthread_set_qos_class_self_np(requestedQOSClass, 0); + pthread_set_qos_class_self_np(m_requestedScavengerThreadQOSClass, 0); #endif - scavenge(lock, scavengeSleepDuration); + std::unique_lock lock(PerProcess::mutex()); + + scavenge(lock, Async); } -void Heap::scavenge(std::unique_lock& lock, std::chrono::milliseconds sleepDuration) +void Heap::scavenge(std::unique_lock& lock, ScavengeMode scavengeMode) { - waitUntilFalse(lock, sleepDuration, m_isAllocatingPages); + m_isAllocatingPages.fill(false); + m_isAllocatingLargePages = false; - scavengeSmallPages(lock, sleepDuration); - scavengeLargeObjects(lock, sleepDuration); + if (scavengeMode == Async) + sleep(lock, scavengeSleepDuration); - sleep(lock, sleepDuration); + scavengeSmallPages(lock, scavengeMode); + scavengeLargeObjects(lock, scavengeMode); } -void Heap::scavengeSmallPages(std::unique_lock& lock, std::chrono::milliseconds sleepDuration) +void Heap::scavengeSmallPages(std::unique_lock& lock, ScavengeMode scavengeMode) { - for (auto& smallPages : m_smallPages) { + for (size_t pageClass = 0; pageClass < pageClassCount; pageClass++) { + auto& smallPages = m_smallPages[pageClass]; + while (!smallPages.isEmpty()) { + if (m_isAllocatingPages[pageClass]) { + m_scavenger.run(); + break; + } + SmallPage* page = smallPages.pop(); - size_t pageClass = m_pageClasses[page->sizeClass()]; - m_vmHeap.deallocateSmallPage(lock, pageClass, page); - waitUntilFalse(lock, sleepDuration, m_isAllocatingPages); + m_vmHeap.deallocateSmallPage(lock, pageClass, page, scavengeMode); } } } -void Heap::scavengeLargeObjects(std::unique_lock& lock, std::chrono::milliseconds sleepDuration) +void Heap::scavengeLargeObjects(std::unique_lock& lock, ScavengeMode scavengeMode) { auto& ranges = m_largeFree.ranges(); for (size_t i = ranges.size(); i-- > 0; i = std::min(i, ranges.size())) { + if (m_isAllocatingLargePages) { + m_scavenger.run(); + break; + } + auto range = ranges.pop(i); - lock.unlock(); + if (scavengeMode == Async) + lock.unlock(); vmDeallocatePhysicalPagesSloppy(range.begin(), range.size()); - lock.lock(); + if (scavengeMode == Async) + lock.lock(); range.setPhysicalSize(0); ranges.push(range); - - waitUntilFalse(lock, sleepDuration, m_isAllocatingPages); } } @@ -167,7 +177,7 @@ if (!m_smallPages[pageClass].isEmpty()) return m_smallPages[pageClass].pop(); - m_isAllocatingPages = true; + m_isAllocatingPages[pageClass] = true; SmallPage* page = m_vmHeap.allocateSmallPage(lock, pageClass); m_objectTypes.set(Chunk::get(page), ObjectType::Small); @@ -336,7 +346,7 @@ } if (range.physicalSize() < range.size()) { - m_isAllocatingPages = true; + m_isAllocatingLargePages = true; vmAllocatePhysicalPagesSloppy(range.begin() + range.physicalSize(), range.size() - range.physicalSize()); range.setPhysicalSize(range.size()); diff -Nru webkit2gtk-2.16.1/Source/bmalloc/bmalloc/Heap.h webkit2gtk-2.16.2/Source/bmalloc/bmalloc/Heap.h --- webkit2gtk-2.16.1/Source/bmalloc/bmalloc/Heap.h 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/bmalloc/bmalloc/Heap.h 2017-05-08 12:35:15.000000000 +0000 @@ -66,10 +66,9 @@ size_t largeSize(std::lock_guard&, void*); void shrinkLarge(std::lock_guard&, const Range&, size_t); - void scavenge(std::unique_lock&, std::chrono::milliseconds sleepDuration); + void scavenge(std::unique_lock&, ScavengeMode); #if BOS(DARWIN) - qos_class_t takeRequestedScavengerThreadQOSClass() { return std::exchange(m_requestedScavengerThreadQOSClass, QOS_CLASS_UNSPECIFIED); } void setScavengerThreadQOSClass(qos_class_t overrideClass) { m_requestedScavengerThreadQOSClass = overrideClass; } #endif @@ -103,8 +102,8 @@ LargeRange splitAndAllocate(LargeRange&, size_t alignment, size_t); void concurrentScavenge(); - void scavengeSmallPages(std::unique_lock&, std::chrono::milliseconds); - void scavengeLargeObjects(std::unique_lock&, std::chrono::milliseconds); + void scavengeSmallPages(std::unique_lock&, ScavengeMode); + void scavengeLargeObjects(std::unique_lock&, ScavengeMode); size_t m_vmPageSizePhysical; Vector m_smallLineMetadata; @@ -118,7 +117,9 @@ Map m_objectTypes; - bool m_isAllocatingPages; + std::array m_isAllocatingPages; + bool m_isAllocatingLargePages; + AsyncTask m_scavenger; Environment m_environment; diff -Nru webkit2gtk-2.16.1/Source/bmalloc/bmalloc/VMHeap.h webkit2gtk-2.16.2/Source/bmalloc/bmalloc/VMHeap.h --- webkit2gtk-2.16.1/Source/bmalloc/bmalloc/VMHeap.h 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/bmalloc/bmalloc/VMHeap.h 2017-05-08 12:35:15.000000000 +0000 @@ -41,10 +41,12 @@ class EndTag; class Heap; +typedef enum { Sync, Async } ScavengeMode; + class VMHeap { public: SmallPage* allocateSmallPage(std::lock_guard&, size_t); - void deallocateSmallPage(std::unique_lock&, size_t, SmallPage*); + void deallocateSmallPage(std::unique_lock&, size_t, SmallPage*, ScavengeMode); LargeRange tryAllocateLargeChunk(std::lock_guard&, size_t alignment, size_t); @@ -68,11 +70,13 @@ return page; } -inline void VMHeap::deallocateSmallPage(std::unique_lock& lock, size_t pageClass, SmallPage* page) +inline void VMHeap::deallocateSmallPage(std::unique_lock& lock, size_t pageClass, SmallPage* page, ScavengeMode scavengeMode) { - lock.unlock(); + if (scavengeMode == Async) + lock.unlock(); vmDeallocatePhysicalPagesSloppy(page->begin()->begin(), pageSize(pageClass)); - lock.lock(); + if (scavengeMode == Async) + lock.lock(); m_smallPages[pageClass].push(page); } diff -Nru webkit2gtk-2.16.1/Source/cmake/OptionsCommon.cmake webkit2gtk-2.16.2/Source/cmake/OptionsCommon.cmake --- webkit2gtk-2.16.1/Source/cmake/OptionsCommon.cmake 2017-02-27 07:11:15.000000000 +0000 +++ webkit2gtk-2.16.2/Source/cmake/OptionsCommon.cmake 2017-05-06 08:48:27.000000000 +0000 @@ -215,7 +215,10 @@ if (NOT APPLE) # If using Ninja with cmake >= 3.6.0 and icecream, then the build is broken # if enable the response files. See https://bugs.webkit.org/show_bug.cgi?id=168770 - if (NOT ((${CMAKE_CXX_COMPILER} MATCHES ".*icecc.*") AND (CMAKE_GENERATOR STREQUAL "Ninja") AND (${CMAKE_VERSION} VERSION_GREATER 3.5))) + if (NOT ((((${CMAKE_CXX_COMPILER} MATCHES ".*ccache.*") AND ($ENV{CCACHE_PREFIX} MATCHES ".*icecc.*")) + OR (${CMAKE_CXX_COMPILER} MATCHES ".*icecc.*") + OR (${AR_VERSION} MATCHES "^BSD ar [^ ]* - libarchive")) + AND (CMAKE_GENERATOR STREQUAL "Ninja") AND (${CMAKE_VERSION} VERSION_GREATER 3.5))) set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1) endif () endif () diff -Nru webkit2gtk-2.16.1/Source/cmake/OptionsGTK.cmake webkit2gtk-2.16.2/Source/cmake/OptionsGTK.cmake --- webkit2gtk-2.16.1/Source/cmake/OptionsGTK.cmake 2017-04-04 07:31:58.000000000 +0000 +++ webkit2gtk-2.16.2/Source/cmake/OptionsGTK.cmake 2017-05-09 07:47:09.000000000 +0000 @@ -2,7 +2,7 @@ set(PROJECT_VERSION_MAJOR 2) set(PROJECT_VERSION_MINOR 16) -set(PROJECT_VERSION_MICRO 1) +set(PROJECT_VERSION_MICRO 2) set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_MICRO}) set(WEBKITGTK_API_VERSION 4.0) @@ -14,8 +14,8 @@ # Libtool library version, not to be confused with API version. # See http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html -CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT2 56 4 19) -CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(JAVASCRIPTCORE 23 8 5) +CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT2 56 5 19) +CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(JAVASCRIPTCORE 23 9 5) # These are shared variables, but we special case their definition so that we can use the # CMAKE_INSTALL_* variables that are populated by the GNUInstallDirs macro. @@ -106,7 +106,6 @@ WEBKIT_OPTION_DEPEND(ENABLE_3D_TRANSFORMS ENABLE_OPENGL) WEBKIT_OPTION_DEPEND(ENABLE_ACCELERATED_2D_CANVAS ENABLE_OPENGL) WEBKIT_OPTION_DEPEND(ENABLE_GLES2 ENABLE_OPENGL) -WEBKIT_OPTION_DEPEND(ENABLE_NETSCAPE_PLUGIN_API ENABLE_X11_TARGET) WEBKIT_OPTION_DEPEND(ENABLE_PLUGIN_PROCESS_GTK2 ENABLE_X11_TARGET) WEBKIT_OPTION_DEPEND(ENABLE_THREADED_COMPOSITOR ENABLE_OPENGL) WEBKIT_OPTION_DEPEND(ENABLE_WEBGL ENABLE_OPENGL) @@ -190,14 +189,12 @@ # only their definedness is. They should only be defined in the true case. if (${ENABLE_X11_TARGET}) SET_AND_EXPOSE_TO_BUILD(MOZ_X11 1) -endif () -if (${WTF_OS_UNIX}) SET_AND_EXPOSE_TO_BUILD(XP_UNIX 1) endif () set(ENABLE_WEBKIT OFF) set(ENABLE_WEBKIT2 ON) -set(ENABLE_PLUGIN_PROCESS ${ENABLE_X11_TARGET}) +set(ENABLE_PLUGIN_PROCESS ${ENABLE_NETSCAPE_PLUGIN_API}) add_definitions(-DBUILDING_GTK__=1) add_definitions(-DGETTEXT_PACKAGE="WebKit2GTK-${WEBKITGTK_API_VERSION}") diff -Nru webkit2gtk-2.16.1/Source/cmake/WebKitMacros.cmake webkit2gtk-2.16.2/Source/cmake/WebKitMacros.cmake --- webkit2gtk-2.16.1/Source/cmake/WebKitMacros.cmake 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/cmake/WebKitMacros.cmake 2017-05-08 17:05:06.000000000 +0000 @@ -283,6 +283,7 @@ ${${_target}_SOURCES} ) target_include_directories(${_target} PUBLIC "$") + target_include_directories(${_target} PRIVATE "$") target_link_libraries(${_target} ${${_target}_LIBRARIES}) set_target_properties(${_target} PROPERTIES COMPILE_DEFINITIONS "BUILDING_${_target}") diff -Nru webkit2gtk-2.16.1/Source/JavaScriptCore/API/JSStringRef.cpp webkit2gtk-2.16.2/Source/JavaScriptCore/API/JSStringRef.cpp --- webkit2gtk-2.16.1/Source/JavaScriptCore/API/JSStringRef.cpp 2017-02-20 16:20:08.000000000 +0000 +++ webkit2gtk-2.16.2/Source/JavaScriptCore/API/JSStringRef.cpp 2017-05-08 13:38:20.000000000 +0000 @@ -37,7 +37,7 @@ JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars) { initializeThreading(); - return &OpaqueJSString::create(chars, numChars).leakRef(); + return &OpaqueJSString::create(reinterpret_cast(chars), numChars).leakRef(); } JSStringRef JSStringCreateWithUTF8CString(const char* string) @@ -62,7 +62,7 @@ JSStringRef JSStringCreateWithCharactersNoCopy(const JSChar* chars, size_t numChars) { initializeThreading(); - return OpaqueJSString::create(StringImpl::createWithoutCopying(chars, numChars)).leakRef(); + return OpaqueJSString::create(StringImpl::createWithoutCopying(reinterpret_cast(chars), numChars)).leakRef(); } JSStringRef JSStringRetain(JSStringRef string) @@ -87,7 +87,7 @@ { if (!string) return nullptr; - return string->characters(); + return reinterpret_cast(string->characters()); } size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string) diff -Nru webkit2gtk-2.16.1/Source/JavaScriptCore/heap/MachineStackMarker.cpp webkit2gtk-2.16.2/Source/JavaScriptCore/heap/MachineStackMarker.cpp --- webkit2gtk-2.16.1/Source/JavaScriptCore/heap/MachineStackMarker.cpp 2017-04-03 14:00:46.000000000 +0000 +++ webkit2gtk-2.16.2/Source/JavaScriptCore/heap/MachineStackMarker.cpp 2017-04-04 15:34:55.000000000 +0000 @@ -33,6 +33,7 @@ #include #include #include +#include #include #if OS(DARWIN) @@ -69,14 +70,14 @@ // We use SIGUSR2 to suspend and resume machine threads in JavaScriptCore. static const int SigThreadSuspendResume = SIGUSR2; static StaticLock globalSignalLock; -thread_local static std::atomic threadLocalCurrentThread; +thread_local static std::atomic threadLocalCurrentThread { nullptr }; static void pthreadSignalHandlerSuspendResume(int, siginfo_t*, void* ucontext) { // Touching thread local atomic types from signal handlers is allowed. - JSC::MachineThreads::Thread* thread = threadLocalCurrentThread.load(); + JSC::MachineThreads::ThreadData* threadData = threadLocalCurrentThread.load(); - if (thread->suspended.load(std::memory_order_acquire)) { + if (threadData->suspended.load(std::memory_order_acquire)) { // This is signal handler invocation that is intended to be used to resume sigsuspend. // So this handler invocation itself should not process. // @@ -88,9 +89,9 @@ ucontext_t* userContext = static_cast(ucontext); #if CPU(PPC) - thread->suspendedMachineContext = *userContext->uc_mcontext.uc_regs; + threadData->suspendedMachineContext = *userContext->uc_mcontext.uc_regs; #else - thread->suspendedMachineContext = userContext->uc_mcontext; + threadData->suspendedMachineContext = userContext->uc_mcontext; #endif // Allow suspend caller to see that this thread is suspended. @@ -99,7 +100,7 @@ // // And sem_post emits memory barrier that ensures that suspendedMachineContext is correctly saved. // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_11 - sem_post(&thread->semaphoreForSuspendResume); + sem_post(&threadData->semaphoreForSuspendResume); // Reaching here, SigThreadSuspendResume is blocked in this handler (this is configured by sigaction's sa_mask). // So before calling sigsuspend, SigThreadSuspendResume to this thread is deferred. This ensures that the handler is not executed recursively. @@ -109,7 +110,7 @@ sigsuspend(&blockedSignalSet); // Allow resume caller to see that this thread is resumed. - sem_post(&thread->semaphoreForSuspendResume); + sem_post(&threadData->semaphoreForSuspendResume); } #endif // USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN) @@ -215,18 +216,29 @@ } } +static MachineThreads::ThreadData* threadData() +{ + static NeverDestroyed> threadData; + return threadData.get(); +} + +MachineThreads::Thread::Thread(ThreadData* threadData) + : data(threadData) +{ + ASSERT(threadData); +} + Thread* MachineThreads::Thread::createForCurrentThread() { - auto stackBounds = wtfThreadData().stack(); - return new Thread(getCurrentPlatformThread(), stackBounds.origin(), stackBounds.end()); + return new Thread(threadData()); } bool MachineThreads::Thread::operator==(const PlatformThread& other) const { #if OS(DARWIN) || OS(WINDOWS) - return platformThread == other; + return data->platformThread == other; #elif USE(PTHREADS) - return !!pthread_equal(platformThread, other); + return !!pthread_equal(data->platformThread, other); #else #error Need a way to compare threads on this platform #endif @@ -325,11 +337,13 @@ conservativeRoots.add(currentThreadState.stackTop, currentThreadState.stackOrigin, jitStubRoutines, codeBlocks); } -MachineThreads::Thread::Thread(const PlatformThread& platThread, void* base, void* end) - : platformThread(platThread) - , stackBase(base) - , stackEnd(end) +MachineThreads::ThreadData::ThreadData() { + auto stackBounds = wtfThreadData().stack(); + platformThread = getCurrentPlatformThread(); + stackBase = stackBounds.origin(); + stackEnd = stackBounds.end(); + #if OS(WINDOWS) ASSERT(platformThread == GetCurrentThreadId()); bool isSuccessful = @@ -362,7 +376,7 @@ #endif } -MachineThreads::Thread::~Thread() +MachineThreads::ThreadData::~ThreadData() { #if OS(WINDOWS) CloseHandle(platformThreadHandle); @@ -371,7 +385,7 @@ #endif } -bool MachineThreads::Thread::suspend() +bool MachineThreads::ThreadData::suspend() { #if OS(DARWIN) kern_return_t result = thread_suspend(platformThread); @@ -408,7 +422,7 @@ #endif } -void MachineThreads::Thread::resume() +void MachineThreads::ThreadData::resume() { #if OS(DARWIN) thread_resume(platformThread); @@ -439,9 +453,9 @@ #endif } -size_t MachineThreads::Thread::getRegisters(Thread::Registers& registers) +size_t MachineThreads::ThreadData::getRegisters(ThreadData::Registers& registers) { - Thread::Registers::PlatformRegisters& regs = registers.regs; + ThreadData::Registers::PlatformRegisters& regs = registers.regs; #if OS(DARWIN) #if CPU(X86) unsigned user_count = sizeof(regs)/sizeof(int); @@ -496,7 +510,7 @@ #endif } -void* MachineThreads::Thread::Registers::stackPointer() const +void* MachineThreads::ThreadData::Registers::stackPointer() const { #if OS(DARWIN) @@ -601,7 +615,7 @@ } #if ENABLE(SAMPLING_PROFILER) -void* MachineThreads::Thread::Registers::framePointer() const +void* MachineThreads::ThreadData::Registers::framePointer() const { #if OS(DARWIN) @@ -684,7 +698,7 @@ #endif } -void* MachineThreads::Thread::Registers::instructionPointer() const +void* MachineThreads::ThreadData::Registers::instructionPointer() const { #if OS(DARWIN) @@ -765,7 +779,8 @@ #error Need a way to get the instruction pointer for another thread on this platform #endif } -void* MachineThreads::Thread::Registers::llintPC() const + +void* MachineThreads::ThreadData::Registers::llintPC() const { // LLInt uses regT4 as PC. #if OS(DARWIN) @@ -858,9 +873,9 @@ } #endif // ENABLE(SAMPLING_PROFILER) -void MachineThreads::Thread::freeRegisters(Thread::Registers& registers) +void MachineThreads::ThreadData::freeRegisters(ThreadData::Registers& registers) { - Thread::Registers::PlatformRegisters& regs = registers.regs; + ThreadData::Registers::PlatformRegisters& regs = registers.regs; #if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN) pthread_attr_destroy(®s.attribute); #else @@ -883,7 +898,7 @@ return redZoneAdjustment; } -std::pair MachineThreads::Thread::captureStack(void* stackTop) +std::pair MachineThreads::ThreadData::captureStack(void* stackTop) { char* begin = reinterpret_cast_ptr(stackBase); char* end = bitwise_cast(WTF::roundUpToMultipleOf(reinterpret_cast(stackTop))); @@ -971,12 +986,12 @@ } // Re-do the suspension to get the actual failure result for logging. - kern_return_t error = thread_suspend(thread->platformThread); + kern_return_t error = thread_suspend(thread->platformThread()); ASSERT(error != KERN_SUCCESS); WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "JavaScript garbage collection encountered an invalid thread (err 0x%x): Thread [%d/%d: %p] platformThread %p.", - error, index, numberOfThreads, thread, reinterpret_cast(thread->platformThread)); + error, index, numberOfThreads, thread, reinterpret_cast(thread->platformThread())); // Put the invalid thread on the threadsToBeDeleted list. // We can't just delete it here because we have suspended other diff -Nru webkit2gtk-2.16.1/Source/JavaScriptCore/heap/MachineStackMarker.h webkit2gtk-2.16.2/Source/JavaScriptCore/heap/MachineStackMarker.h --- webkit2gtk-2.16.1/Source/JavaScriptCore/heap/MachineStackMarker.h 2017-04-03 14:00:46.000000000 +0000 +++ webkit2gtk-2.16.2/Source/JavaScriptCore/heap/MachineStackMarker.h 2017-04-04 15:23:50.000000000 +0000 @@ -74,14 +74,13 @@ JS_EXPORT_PRIVATE void addCurrentThread(); // Only needs to be called by clients that can use the same heap from multiple threads. - class Thread { + class ThreadData { WTF_MAKE_FAST_ALLOCATED; - Thread(const PlatformThread& platThread, void* base, void* end); - public: - ~Thread(); + ThreadData(); + ~ThreadData(); - static Thread* createForCurrentThread(); + static ThreadData* createForCurrentThread(); struct Registers { void* stackPointer() const; @@ -118,12 +117,9 @@ #else #error Need a thread register struct for this platform #endif - + PlatformRegisters regs; }; - - bool operator==(const PlatformThread& other) const; - bool operator!=(const PlatformThread& other) const { return !(*this == other); } bool suspend(); void resume(); @@ -131,7 +127,6 @@ void freeRegisters(Registers&); std::pair captureStack(void* stackTop); - Thread* next; PlatformThread platformThread; void* stackBase; void* stackEnd; @@ -145,6 +140,32 @@ #endif }; + class Thread { + WTF_MAKE_FAST_ALLOCATED; + Thread(ThreadData*); + + public: + using Registers = ThreadData::Registers; + + static Thread* createForCurrentThread(); + + bool operator==(const PlatformThread& other) const; + bool operator!=(const PlatformThread& other) const { return !(*this == other); } + + bool suspend() { return data->suspend(); } + void resume() { data->resume(); } + size_t getRegisters(Registers& regs) { return data->getRegisters(regs); } + void freeRegisters(Registers& regs) { data->freeRegisters(regs); } + std::pair captureStack(void* stackTop) { return data->captureStack(stackTop); } + + const PlatformThread& platformThread() { return data->platformThread; } + void* stackBase() const { return data->stackBase; } + void* stackEnd() const { return data->stackEnd; } + + Thread* next; + ThreadData* data; + }; + Lock& getLock() { return m_registeredThreadsMutex; } Thread* threadsListHead(const LockHolder&) const { ASSERT(m_registeredThreadsMutex.isLocked()); return m_registeredThreads; } Thread* machineThreadForCurrentThread(); diff -Nru webkit2gtk-2.16.1/Source/JavaScriptCore/offlineasm/arm.rb webkit2gtk-2.16.2/Source/JavaScriptCore/offlineasm/arm.rb --- webkit2gtk-2.16.1/Source/JavaScriptCore/offlineasm/arm.rb 2017-02-20 16:20:12.000000000 +0000 +++ webkit2gtk-2.16.2/Source/JavaScriptCore/offlineasm/arm.rb 2017-05-08 16:57:13.000000000 +0000 @@ -94,6 +94,7 @@ ARM_EXTRA_GPRS = [SpecialRegister.new("r6"), SpecialRegister.new("r10"), SpecialRegister.new("r12")] ARM_EXTRA_FPRS = [SpecialRegister.new("d7")] ARM_SCRATCH_FPR = SpecialRegister.new("d6") +OS_DARWIN = ((RUBY_PLATFORM =~ /darwin/i) != nil) def armMoveImmediate(value, register) # Currently we only handle the simple cases, and fall back to mov/movt for the complex ones. @@ -568,7 +569,11 @@ end when "call" if operands[0].label? - $asm.puts "blx #{operands[0].asmLabel}" + if OS_DARWIN + $asm.puts "blx #{operands[0].asmLabel}" + else + $asm.puts "bl #{operands[0].asmLabel}" + end else $asm.puts "blx #{operands[0].armOperand}" end diff -Nru webkit2gtk-2.16.1/Source/JavaScriptCore/runtime/DateConversion.cpp webkit2gtk-2.16.2/Source/JavaScriptCore/runtime/DateConversion.cpp --- webkit2gtk-2.16.1/Source/JavaScriptCore/runtime/DateConversion.cpp 2017-02-20 16:20:13.000000000 +0000 +++ webkit2gtk-2.16.2/Source/JavaScriptCore/runtime/DateConversion.cpp 2017-05-08 13:38:20.000000000 +0000 @@ -107,7 +107,8 @@ #if OS(WINDOWS) TIME_ZONE_INFORMATION timeZoneInformation; GetTimeZoneInformation(&timeZoneInformation); - const WCHAR* timeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName; + const WCHAR* winTimeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName; + String timeZoneName(reinterpret_cast(winTimeZoneName)); #else struct tm gtm = t; char timeZoneName[70]; @@ -115,11 +116,7 @@ #endif if (timeZoneName[0]) { builder.appendLiteral(" ("); -#if OS(WINDOWS) - builder.append(String(timeZoneName)); -#else builder.append(timeZoneName); -#endif builder.append(')'); } } diff -Nru webkit2gtk-2.16.1/Source/JavaScriptCore/runtime/MathCommon.cpp webkit2gtk-2.16.2/Source/JavaScriptCore/runtime/MathCommon.cpp --- webkit2gtk-2.16.1/Source/JavaScriptCore/runtime/MathCommon.cpp 2017-02-20 16:20:13.000000000 +0000 +++ webkit2gtk-2.16.2/Source/JavaScriptCore/runtime/MathCommon.cpp 2017-05-08 08:07:21.000000000 +0000 @@ -469,67 +469,7 @@ int32_t JIT_OPERATION operationToInt32SensibleSlow(double number) { - // This function is specialized `operationToInt32` for the slow case of - // the sensible double-to-int32 operation. It is available in x86. - // - // In the sensible double-to-int32, first we attempt to truncate the - // double value to int32 by using cvttsd2si_rr. - // According to the Intel's manual, cvttsd2si perform the following truncate - // operation. - // - // If src = NaN, +-Inf, or |(src)rz| > 0x7fffffff and (src)rz != 0x80000000, - // the result becomes 0x80000000. Otherwise, the operation succeeds. - // Note that ()rz is rouding towards zero. - // - // We call this slow case function when the above cvttsd2si fails. We check - // this condition by performing `result == 0x80000000`. So this function only - // accepts the following numbers. - // - // NaN, +-Inf, |(src)rz| > 0x7fffffff. - // - // As a result, the exp of the double is always >= 31. - // This condition simplifies and speeds up the toInt32 implementation. - int64_t bits = WTF::bitwise_cast(number); - int32_t exp = (static_cast(bits >> 52) & 0x7ff) - 0x3ff; - - // If exponent < 0 there will be no bits to the left of the decimal point - // after rounding; if the exponent is > 83 then no bits of precision can be - // left in the low 32-bit range of the result (IEEE-754 doubles have 52 bits - // of fractional precision). - // Note this case handles 0, -0, and all infinite, NaN, & denormal value. - - // If exp < 0, truncate operation succeeds. So this function does not - // encounter that case. If exp > 83, it means exp >= 84. In that case, - // the following operation produces 0 for the result. - ASSERT(exp >= 0); - - // Select the appropriate 32-bits from the floating point mantissa. If the - // exponent is 52 then the bits we need to select are already aligned to the - // lowest bits of the 64-bit integer representation of the number, no need - // to shift. If the exponent is greater than 52 we need to shift the value - // left by (exp - 52), if the value is less than 52 we need to shift right - // accordingly. - int32_t result = (exp > 52) - ? static_cast(bits << (exp - 52)) - : static_cast(bits >> (52 - exp)); - - // IEEE-754 double precision values are stored omitting an implicit 1 before - // the decimal point; we need to reinsert this now. We may also the shifted - // invalid bits into the result that are not a part of the mantissa (the sign - // and exponent bits from the floatingpoint representation); mask these out. - // - // The important observation is that exp is always >= 31. So the above case - // is needed to be cared only when the exp == 31. - ASSERT(exp >= 31); - if (exp == 31) { - int32_t missingOne = 1 << exp; - result &= (missingOne - 1); - result += missingOne; - } - - // If the input value was negative (we could test either 'number' or 'bits', - // but testing 'bits' is likely faster) invert the result appropriately. - return bits < 0 ? -result : result; + return toInt32Internal(number); } #if HAVE(ARM_IDIV_INSTRUCTIONS) diff -Nru webkit2gtk-2.16.1/Source/JavaScriptCore/runtime/MathCommon.h webkit2gtk-2.16.2/Source/JavaScriptCore/runtime/MathCommon.h --- webkit2gtk-2.16.1/Source/JavaScriptCore/runtime/MathCommon.h 2017-02-20 16:20:13.000000000 +0000 +++ webkit2gtk-2.16.2/Source/JavaScriptCore/runtime/MathCommon.h 2017-05-08 08:07:21.000000000 +0000 @@ -73,9 +73,14 @@ // // The operation can be described as round towards zero, then select the 32 least // bits of the resulting value in 2s-complement representation. -ALWAYS_INLINE int32_t toInt32(double number) +enum ToInt32Mode { + Generic, + AfterSensibleConversionAttempt, +}; +template +ALWAYS_INLINE int32_t toInt32Internal(double number) { - int64_t bits = WTF::bitwise_cast(number); + uint64_t bits = WTF::bitwise_cast(number); int32_t exp = (static_cast(bits >> 52) & 0x7ff) - 0x3ff; // If exponent < 0 there will be no bits to the left of the decimal point @@ -83,7 +88,14 @@ // left in the low 32-bit range of the result (IEEE-754 doubles have 52 bits // of fractional precision). // Note this case handles 0, -0, and all infinite, NaN, & denormal value. - if (exp < 0 || exp > 83) + + // We need to check exp > 83 because: + // 1. exp may be used as a left shift value below in (exp - 52), and + // 2. Left shift amounts that exceed 31 results in undefined behavior. See: + // http://en.cppreference.com/w/cpp/language/operator_arithmetic#Bitwise_shift_operators + // + // Using an unsigned comparison here also gives us a exp < 0 check for free. + if (static_cast(exp) > 83u) return 0; // Select the appropriate 32-bits from the floating point mantissa. If the @@ -92,23 +104,61 @@ // to shift. If the exponent is greater than 52 we need to shift the value // left by (exp - 52), if the value is less than 52 we need to shift right // accordingly. - int32_t result = (exp > 52) - ? static_cast(bits << (exp - 52)) - : static_cast(bits >> (52 - exp)); + uint32_t result = (exp > 52) + ? static_cast(bits << (exp - 52)) + : static_cast(bits >> (52 - exp)); // IEEE-754 double precision values are stored omitting an implicit 1 before // the decimal point; we need to reinsert this now. We may also the shifted // invalid bits into the result that are not a part of the mantissa (the sign // and exponent bits from the floatingpoint representation); mask these out. - if (exp < 32) { - int32_t missingOne = 1 << exp; - result &= missingOne - 1; - result += missingOne; + // Note that missingOne should be held as uint32_t since ((1 << 31) - 1) causes + // int32_t overflow. + if (Mode == ToInt32Mode::AfterSensibleConversionAttempt) { + if (exp == 31) { + // This is an optimization for when toInt32() is called in the slow path + // of a JIT operation. Currently, this optimization is only applicable for + // x86 ports. This optimization offers 5% performance improvement in + // kraken-crypto-pbkdf2. + // + // On x86, the fast path does a sensible double-to-int32 conversion, by + // first attempting to truncate the double value to int32 using the + // cvttsd2si_rr instruction. According to Intel's manual, cvttsd2si performs + // the following truncate operation: + // + // If src = NaN, +-Inf, or |(src)rz| > 0x7fffffff and (src)rz != 0x80000000, + // then the result becomes 0x80000000. Otherwise, the operation succeeds. + // + // Note that the ()rz notation means rounding towards zero. + // We'll call the slow case function only when the above cvttsd2si fails. The + // JIT code checks for fast path failure by checking if result == 0x80000000. + // Hence, the slow path will only see the following possible set of numbers: + // + // NaN, +-Inf, or |(src)rz| > 0x7fffffff. + // + // As a result, the exp of the double is always >= 31. We can take advantage + // of this by specifically checking for (exp == 31) and give the compiler a + // chance to constant fold the operations below. + const constexpr uint32_t missingOne = 1U << 31; + result &= missingOne - 1; + result += missingOne; + } + } else { + if (exp < 32) { + const uint32_t missingOne = 1U << exp; + result &= missingOne - 1; + result += missingOne; + } } // If the input value was negative (we could test either 'number' or 'bits', // but testing 'bits' is likely faster) invert the result appropriately. - return bits < 0 ? -result : result; + return static_cast(bits) < 0 ? -static_cast(result) : static_cast(result); +} + +ALWAYS_INLINE int32_t toInt32(double number) +{ + return toInt32Internal(number); } // This implements ToUInt32, defined in ECMA-262 9.6. diff -Nru webkit2gtk-2.16.1/Source/JavaScriptCore/runtime/SamplingProfiler.cpp webkit2gtk-2.16.2/Source/JavaScriptCore/runtime/SamplingProfiler.cpp --- webkit2gtk-2.16.1/Source/JavaScriptCore/runtime/SamplingProfiler.cpp 2017-04-03 13:58:30.000000000 +0000 +++ webkit2gtk-2.16.2/Source/JavaScriptCore/runtime/SamplingProfiler.cpp 2017-04-04 15:23:50.000000000 +0000 @@ -169,8 +169,8 @@ { uint8_t* fpCast = bitwise_cast(exec); for (MachineThreads::Thread* thread = m_vm.heap.machineThreads().threadsListHead(m_machineThreadsLocker); thread; thread = thread->next) { - uint8_t* stackBase = static_cast(thread->stackBase); - uint8_t* stackLimit = static_cast(thread->stackEnd); + uint8_t* stackBase = static_cast(thread->stackBase()); + uint8_t* stackLimit = static_cast(thread->stackEnd()); RELEASE_ASSERT(stackBase); RELEASE_ASSERT(stackLimit); if (fpCast <= stackBase && fpCast >= stackLimit) diff -Nru webkit2gtk-2.16.1/Source/WebCore/accessibility/AccessibilityRenderObject.cpp webkit2gtk-2.16.2/Source/WebCore/accessibility/AccessibilityRenderObject.cpp --- webkit2gtk-2.16.1/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2017-05-08 12:41:22.000000000 +0000 @@ -532,7 +532,9 @@ bool AccessibilityRenderObject::isOffScreen() const { - ASSERT(m_renderer); + if (!m_renderer) + return true; + IntRect contentRect = snappedIntRect(m_renderer->absoluteClippedOverflowRect()); // FIXME: unclear if we need LegacyIOSDocumentVisibleRect. IntRect viewRect = m_renderer->view().frameView().visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect); @@ -1570,12 +1572,18 @@ bool AccessibilityRenderObject::isUnvisited() const { + if (!m_renderer) + return true; + // FIXME: Is it a privacy violation to expose unvisited information to accessibility APIs? return m_renderer->style().isLink() && m_renderer->style().insideLink() == InsideUnvisitedLink; } bool AccessibilityRenderObject::isVisited() const { + if (!m_renderer) + return false; + // FIXME: Is it a privacy violation to expose visited information to accessibility APIs? return m_renderer->style().isLink() && m_renderer->style().insideLink() == InsideVisitedLink; } @@ -2434,6 +2442,9 @@ void AccessibilityRenderObject::handleAriaExpandedChanged() { + // This object might be deleted under the call to the parentObject() method. + auto protectedThis = makeRef(*this); + // Find if a parent of this object should handle aria-expanded changes. AccessibilityObject* containerParent = this->parentObject(); while (containerParent) { diff -Nru webkit2gtk-2.16.1/Source/WebCore/accessibility/AXObjectCache.cpp webkit2gtk-2.16.2/Source/WebCore/accessibility/AXObjectCache.cpp --- webkit2gtk-2.16.1/Source/WebCore/accessibility/AXObjectCache.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/accessibility/AXObjectCache.cpp 2017-05-08 15:45:34.000000000 +0000 @@ -2684,6 +2684,8 @@ void AXObjectCache::recomputeDeferredIsIgnored(RenderBlock& renderer) { + if (renderer.beingDestroyed()) + return; m_deferredIsIgnoredChangeList.add(&renderer); } diff -Nru webkit2gtk-2.16.1/Source/WebCore/bindings/js/JSEventListener.cpp webkit2gtk-2.16.2/Source/WebCore/bindings/js/JSEventListener.cpp --- webkit2gtk-2.16.1/Source/WebCore/bindings/js/JSEventListener.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/bindings/js/JSEventListener.cpp 2017-05-08 08:48:23.000000000 +0000 @@ -1,6 +1,6 @@ /* * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All Rights Reserved. + * Copyright (C) 2003-2017 Apple Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -47,7 +47,7 @@ : EventListener(JSEventListenerType) , m_wrapper(wrapper) , m_isAttribute(isAttribute) - , m_isolatedWorld(&isolatedWorld) + , m_isolatedWorld(isolatedWorld) { if (wrapper) { JSC::Heap::heap(wrapper)->writeBarrier(wrapper, function); @@ -62,7 +62,7 @@ JSObject* JSEventListener::initializeJSFunction(ScriptExecutionContext*) const { - return 0; + return nullptr; } void JSEventListener::visitJSFunction(SlotVisitor& visitor) @@ -101,7 +101,7 @@ if (!jsFunction) return; - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, *m_isolatedWorld); + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, m_isolatedWorld); if (!globalObject) return; @@ -216,31 +216,31 @@ return JSEventListener::create(asObject(listener), &wrapper, true, currentWorld(&state)); } -JSC::JSValue eventHandlerAttribute(EventTarget& target, const AtomicString& eventType) +JSC::JSValue eventHandlerAttribute(EventTarget& target, const AtomicString& eventType, DOMWrapperWorld& isolatedWorld) { - return eventHandlerAttribute(target.attributeEventListener(eventType), *target.scriptExecutionContext()); + return eventHandlerAttribute(target.attributeEventListener(eventType, isolatedWorld), *target.scriptExecutionContext()); } void setEventHandlerAttribute(JSC::ExecState& state, JSC::JSObject& wrapper, EventTarget& target, const AtomicString& eventType, JSC::JSValue value) { - target.setAttributeEventListener(eventType, createEventListenerForEventHandlerAttribute(state, value, wrapper)); + target.setAttributeEventListener(eventType, createEventListenerForEventHandlerAttribute(state, value, wrapper), currentWorld(&state)); } -JSC::JSValue windowEventHandlerAttribute(HTMLElement& element, const AtomicString& eventType) +JSC::JSValue windowEventHandlerAttribute(HTMLElement& element, const AtomicString& eventType, DOMWrapperWorld& isolatedWorld) { auto& document = element.document(); - return eventHandlerAttribute(document.getWindowAttributeEventListener(eventType), document); + return eventHandlerAttribute(document.getWindowAttributeEventListener(eventType, isolatedWorld), document); } void setWindowEventHandlerAttribute(JSC::ExecState& state, JSC::JSObject& wrapper, HTMLElement& element, const AtomicString& eventType, JSC::JSValue value) { ASSERT(wrapper.globalObject()); - element.document().setWindowAttributeEventListener(eventType, createEventListenerForEventHandlerAttribute(state, value, *wrapper.globalObject())); + element.document().setWindowAttributeEventListener(eventType, createEventListenerForEventHandlerAttribute(state, value, *wrapper.globalObject()), currentWorld(&state)); } -JSC::JSValue windowEventHandlerAttribute(DOMWindow& window, const AtomicString& eventType) +JSC::JSValue windowEventHandlerAttribute(DOMWindow& window, const AtomicString& eventType, DOMWrapperWorld& isolatedWorld) { - return eventHandlerAttribute(window, eventType); + return eventHandlerAttribute(window, eventType, isolatedWorld); } void setWindowEventHandlerAttribute(JSC::ExecState& state, JSC::JSObject& wrapper, DOMWindow& window, const AtomicString& eventType, JSC::JSValue value) @@ -248,10 +248,10 @@ setEventHandlerAttribute(state, wrapper, window, eventType, value); } -JSC::JSValue documentEventHandlerAttribute(HTMLElement& element, const AtomicString& eventType) +JSC::JSValue documentEventHandlerAttribute(HTMLElement& element, const AtomicString& eventType, DOMWrapperWorld& isolatedWorld) { auto& document = element.document(); - return eventHandlerAttribute(document.attributeEventListener(eventType), document); + return eventHandlerAttribute(document.attributeEventListener(eventType, isolatedWorld), document); } void setDocumentEventHandlerAttribute(JSC::ExecState& state, JSC::JSObject& wrapper, HTMLElement& element, const AtomicString& eventType, JSC::JSValue value) @@ -260,12 +260,12 @@ auto& document = element.document(); auto* documentWrapper = JSC::jsCast(toJS(&state, JSC::jsCast(wrapper.globalObject()), document)); ASSERT(documentWrapper); - document.setAttributeEventListener(eventType, createEventListenerForEventHandlerAttribute(state, value, *documentWrapper)); + document.setAttributeEventListener(eventType, createEventListenerForEventHandlerAttribute(state, value, *documentWrapper), currentWorld(&state)); } -JSC::JSValue documentEventHandlerAttribute(Document& document, const AtomicString& eventType) +JSC::JSValue documentEventHandlerAttribute(Document& document, const AtomicString& eventType, DOMWrapperWorld& isolatedWorld) { - return eventHandlerAttribute(document, eventType); + return eventHandlerAttribute(document, eventType, isolatedWorld); } void setDocumentEventHandlerAttribute(JSC::ExecState& state, JSC::JSObject& wrapper, Document& document, const AtomicString& eventType, JSC::JSValue value) diff -Nru webkit2gtk-2.16.1/Source/WebCore/bindings/js/JSEventListener.h webkit2gtk-2.16.2/Source/WebCore/bindings/js/JSEventListener.h --- webkit2gtk-2.16.1/Source/WebCore/bindings/js/JSEventListener.h 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/bindings/js/JSEventListener.h 2017-05-08 08:48:20.000000000 +0000 @@ -1,6 +1,6 @@ /* * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2003-2017 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -54,7 +55,7 @@ { return listener->type() == JSEventListenerType ? static_cast(listener) - : 0; + : nullptr; } virtual ~JSEventListener(); @@ -65,7 +66,7 @@ bool isAttribute() const { return m_isAttribute; } JSC::JSObject* jsFunction(ScriptExecutionContext*) const; - DOMWrapperWorld& isolatedWorld() const { return *m_isolatedWorld; } + DOMWrapperWorld& isolatedWorld() const { return m_isolatedWorld; } JSC::JSObject* wrapper() const { return m_wrapper.get(); } void setWrapper(JSC::VM&, JSC::JSObject* wrapper) const { m_wrapper = JSC::Weak(wrapper); } @@ -87,23 +88,23 @@ mutable JSC::Weak m_wrapper; bool m_isAttribute; - RefPtr m_isolatedWorld; + Ref m_isolatedWorld; }; // For "onxxx" attributes that automatically set up JavaScript event listeners. -JSC::JSValue eventHandlerAttribute(EventTarget&, const AtomicString& eventType); +JSC::JSValue eventHandlerAttribute(EventTarget&, const AtomicString& eventType, DOMWrapperWorld&); void setEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, EventTarget&, const AtomicString& eventType, JSC::JSValue); // Like the functions above, but for attributes that forward event handlers to the window object rather than setting them on the target. -JSC::JSValue windowEventHandlerAttribute(HTMLElement&, const AtomicString& eventType); +JSC::JSValue windowEventHandlerAttribute(HTMLElement&, const AtomicString& eventType, DOMWrapperWorld&); void setWindowEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, HTMLElement&, const AtomicString& eventType, JSC::JSValue); -JSC::JSValue windowEventHandlerAttribute(DOMWindow&, const AtomicString& eventType); +JSC::JSValue windowEventHandlerAttribute(DOMWindow&, const AtomicString& eventType, DOMWrapperWorld&); void setWindowEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, DOMWindow&, const AtomicString& eventType, JSC::JSValue); // Like the functions above, but for attributes that forward event handlers to the document rather than setting them on the target. -JSC::JSValue documentEventHandlerAttribute(HTMLElement&, const AtomicString& eventType); +JSC::JSValue documentEventHandlerAttribute(HTMLElement&, const AtomicString& eventType, DOMWrapperWorld&); void setDocumentEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, HTMLElement&, const AtomicString& eventType, JSC::JSValue); -JSC::JSValue documentEventHandlerAttribute(Document&, const AtomicString& eventType); +JSC::JSValue documentEventHandlerAttribute(Document&, const AtomicString& eventType, DOMWrapperWorld&); void setDocumentEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, Document&, const AtomicString& eventType, JSC::JSValue); inline JSC::JSObject* JSEventListener::jsFunction(ScriptExecutionContext* scriptExecutionContext) const @@ -128,7 +129,7 @@ // If m_wrapper is 0, then m_jsFunction is zombied, and should never be accessed. if (!m_wrapper) - return 0; + return nullptr; // Try to verify that m_jsFunction wasn't recycled. (Not exact, since an // event listener can be almost anything, but this makes test-writing easier). @@ -138,3 +139,7 @@ } } // namespace WebCore + +SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::JSEventListener) +static bool isType(const WebCore::EventListener& input) { return input.type() == WebCore::JSEventListener::JSEventListenerType; } +SPECIALIZE_TYPE_TRAITS_END() diff -Nru webkit2gtk-2.16.1/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm webkit2gtk-2.16.2/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm --- webkit2gtk-2.16.1/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2017-03-13 11:14:02.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2017-05-08 08:25:45.000000000 +0000 @@ -3662,7 +3662,7 @@ : $attribute->extendedAttributes->{DocumentEventHandler} ? "documentEventHandlerAttribute" : "eventHandlerAttribute"; my $eventName = EventHandlerAttributeEventName($attribute); - push(@implContent, " return $getter(thisObject.wrapped(), $eventName);\n"); + push(@implContent, " return $getter(thisObject.wrapped(), $eventName, worldForDOMObject(&thisObject));\n"); } elsif ($codeGenerator->IsConstructorType($attribute->type)) { my $constructorType = $attribute->type->name; $constructorType =~ s/Constructor$//; @@ -3834,7 +3834,7 @@ # FIXME: Find a way to do this special case without hardcoding the class and attribute names here. if ((($interfaceName eq "DOMWindow") or ($interfaceName eq "WorkerGlobalScope")) and $name eq "onerror") { $implIncludes{"JSErrorHandler.h"} = 1; - push(@implContent, " thisObject.wrapped().setAttributeEventListener($eventName, createJSErrorHandler(&state, value, &thisObject));\n"); + push(@implContent, " thisObject.wrapped().setAttributeEventListener($eventName, createJSErrorHandler(&state, value, &thisObject), worldForDOMObject(&thisObject));\n"); } else { $implIncludes{"JSEventListener.h"} = 1; my $setter = $attribute->extendedAttributes->{WindowEventHandler} ? "setWindowEventHandlerAttribute" diff -Nru webkit2gtk-2.16.1/Source/WebCore/css/CSSCalculationValue.cpp webkit2gtk-2.16.2/Source/WebCore/css/CSSCalculationValue.cpp --- webkit2gtk-2.16.1/Source/WebCore/css/CSSCalculationValue.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/css/CSSCalculationValue.cpp 2017-05-08 13:39:49.000000000 +0000 @@ -598,7 +598,8 @@ if (unitCategory(type) == CalcOther) return false; - result->value = CSSCalcPrimitiveValue::create(CSSPrimitiveValue::create(token.numericValue(), type), token.numericValueType() == IntegerValueType); + bool isInteger = token.numericValueType() == IntegerValueType || (token.numericValueType() == NumberValueType && token.numericValue() == trunc(token.numericValue())); + result->value = CSSCalcPrimitiveValue::create(CSSPrimitiveValue::create(token.numericValue(), type), isInteger); return true; } diff -Nru webkit2gtk-2.16.1/Source/WebCore/css/CSSComputedStyleDeclaration.cpp webkit2gtk-2.16.2/Source/WebCore/css/CSSComputedStyleDeclaration.cpp --- webkit2gtk-2.16.1/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2017-05-08 13:45:46.000000000 +0000 @@ -1190,11 +1190,18 @@ static Ref createTransitionPropertyValue(const Animation& animation) { - if (animation.animationMode() == Animation::AnimateNone) + switch (animation.animationMode()) { + case Animation::AnimateNone: return CSSValuePool::singleton().createIdentifierValue(CSSValueNone); - if (animation.animationMode() == Animation::AnimateAll) + case Animation::AnimateAll: return CSSValuePool::singleton().createIdentifierValue(CSSValueAll); - return CSSValuePool::singleton().createValue(getPropertyNameString(animation.property()), CSSPrimitiveValue::CSS_STRING); + case Animation::AnimateSingleProperty: + return CSSValuePool::singleton().createValue(getPropertyNameString(animation.property()), CSSPrimitiveValue::CSS_STRING); + case Animation::AnimateUnknownProperty: + return CSSValuePool::singleton().createValue(animation.unknownProperty(), CSSPrimitiveValue::CSS_STRING); + } + ASSERT_NOT_REACHED(); + return CSSValuePool::singleton().createIdentifierValue(CSSValueNone); } static Ref transitionPropertyValue(const AnimationList* animationList) diff -Nru webkit2gtk-2.16.1/Source/WebCore/css/CSSProperties.json webkit2gtk-2.16.2/Source/WebCore/css/CSSProperties.json --- webkit2gtk-2.16.1/Source/WebCore/css/CSSProperties.json 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/css/CSSProperties.json 2017-05-08 07:10:14.000000000 +0000 @@ -2025,7 +2025,8 @@ "end" ], "codegen-properties": { - "converter": "TextAlign" + "converter": "TextAlign", + "custom": "Initial|Value" } }, "text-anchor": { diff -Nru webkit2gtk-2.16.1/Source/WebCore/css/CSSToStyleMap.cpp webkit2gtk-2.16.2/Source/WebCore/css/CSSToStyleMap.cpp --- webkit2gtk-2.16.1/Source/WebCore/css/CSSToStyleMap.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/css/CSSToStyleMap.cpp 2017-05-08 13:45:44.000000000 +0000 @@ -443,13 +443,21 @@ if (primitiveValue.valueID() == CSSValueAll) { animation.setAnimationMode(Animation::AnimateAll); animation.setProperty(CSSPropertyInvalid); - } else if (primitiveValue.valueID() == CSSValueNone) { + return; + } + if (primitiveValue.valueID() == CSSValueNone) { animation.setAnimationMode(Animation::AnimateNone); animation.setProperty(CSSPropertyInvalid); - } else if (primitiveValue.propertyID() != CSSPropertyInvalid) { - animation.setAnimationMode(Animation::AnimateSingleProperty); - animation.setProperty(primitiveValue.propertyID()); + return; + } + if (primitiveValue.propertyID() == CSSPropertyInvalid) { + animation.setAnimationMode(Animation::AnimateUnknownProperty); + animation.setProperty(CSSPropertyInvalid); + animation.setUnknownProperty(primitiveValue.stringValue()); + return; } + animation.setAnimationMode(Animation::AnimateSingleProperty); + animation.setProperty(primitiveValue.propertyID()); } void CSSToStyleMap::mapAnimationTimingFunction(Animation& animation, const CSSValue& value) diff -Nru webkit2gtk-2.16.1/Source/WebCore/css/parser/CSSSelectorParser.cpp webkit2gtk-2.16.2/Source/WebCore/css/parser/CSSSelectorParser.cpp --- webkit2gtk-2.16.1/Source/WebCore/css/parser/CSSSelectorParser.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/css/parser/CSSSelectorParser.cpp 2017-05-08 08:55:40.000000000 +0000 @@ -257,7 +257,6 @@ if (pseudo == CSSSelector::PseudoClassNot) { ASSERT(simpleSelector.selectorList()); ASSERT(simpleSelector.selectorList()->first()); - ASSERT(!simpleSelector.selectorList()->first()->tagHistory()); pseudo = simpleSelector.selectorList()->first()->pseudoClassType(); } return isPseudoClassValidAfterPseudoElement(pseudo, compoundPseudoElement); diff -Nru webkit2gtk-2.16.1/Source/WebCore/css/StyleBuilderCustom.h webkit2gtk-2.16.2/Source/WebCore/css/StyleBuilderCustom.h --- webkit2gtk-2.16.1/Source/WebCore/css/StyleBuilderCustom.h 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/css/StyleBuilderCustom.h 2017-05-08 07:09:11.000000000 +0000 @@ -127,6 +127,8 @@ static void applyValueBaselineShift(StyleResolver&, CSSValue&); static void applyValueDirection(StyleResolver&, CSSValue&); static void applyValueVerticalAlign(StyleResolver&, CSSValue&); + static void applyInitialTextAlign(StyleResolver&); + static void applyValueTextAlign(StyleResolver&, CSSValue&); #if ENABLE(DASHBOARD_SUPPORT) static void applyValueWebkitDashboardRegion(StyleResolver&, CSSValue&); #endif @@ -168,6 +170,18 @@ styleResolver.style()->setHasExplicitlySetDirection(true); } +inline void StyleBuilderCustom::applyInitialTextAlign(StyleResolver& styleResolver) +{ + styleResolver.style()->setTextAlign(RenderStyle::initialTextAlign()); + styleResolver.style()->setHasExplicitlySetTextAlign(true); +} + +inline void StyleBuilderCustom::applyValueTextAlign(StyleResolver& styleResolver, CSSValue& value) +{ + styleResolver.style()->setTextAlign(StyleBuilderConverter::convertTextAlign(styleResolver, value)); + styleResolver.style()->setHasExplicitlySetTextAlign(true); +} + inline void StyleBuilderCustom::resetEffectiveZoom(StyleResolver& styleResolver) { // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect. diff -Nru webkit2gtk-2.16.1/Source/WebCore/css/StyleResolver.cpp webkit2gtk-2.16.2/Source/WebCore/css/StyleResolver.cpp --- webkit2gtk-2.16.1/Source/WebCore/css/StyleResolver.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/css/StyleResolver.cpp 2017-05-08 07:09:11.000000000 +0000 @@ -843,9 +843,11 @@ style.setFloating(NoFloat); } - // FIXME: We shouldn't be overriding start/-webkit-auto like this. Do it in html.css instead. - // Table headers with a text-align of -webkit-auto will change the text-align to center. - if (element->hasTagName(thTag) && style.textAlign() == TASTART) + // User agents are expected to have a rule in their user agent stylesheet that matches th elements that have a parent + // node whose computed value for the 'text-align' property is its initial value, whose declaration block consists of + // just a single declaration that sets the 'text-align' property to the value 'center'. + // https://html.spec.whatwg.org/multipage/rendering.html#rendering + if (element->hasTagName(thTag) && !style.hasExplicitlySetTextAlign() && parentStyle.textAlign() == RenderStyle::initialTextAlign()) style.setTextAlign(CENTER); if (element->hasTagName(legendTag)) diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/Attr.cpp webkit2gtk-2.16.2/Source/WebCore/dom/Attr.cpp --- webkit2gtk-2.16.1/Source/WebCore/dom/Attr.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/Attr.cpp 2017-05-08 10:58:04.000000000 +0000 @@ -26,6 +26,7 @@ #include "AttributeChangeInvalidation.h" #include "Event.h" #include "ExceptionCode.h" +#include "NoEventDispatchAssertion.h" #include "ScopedEventQueue.h" #include "StyleProperties.h" #include "StyledElement.h" @@ -167,8 +168,10 @@ } else m_standaloneValue = newValue; - if (m_element) + if (m_element) { + NoEventDispatchAssertion::DisableAssertionsInScope allowedScope; m_element->attributeChanged(qualifiedName(), oldValue, newValue); + } } CSSStyleDeclaration* Attr::style() diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/CharacterData.cpp webkit2gtk-2.16.2/Source/WebCore/dom/CharacterData.cpp --- webkit2gtk-2.16.1/Source/WebCore/dom/CharacterData.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/CharacterData.cpp 2017-05-04 06:20:52.000000000 +0000 @@ -22,6 +22,7 @@ #include "config.h" #include "CharacterData.h" +#include "Attr.h" #include "ElementTraversal.h" #include "EventNames.h" #include "ExceptionCode.h" @@ -208,7 +209,9 @@ void CharacterData::notifyParentAfterChange(ContainerNode::ChildChangeSource source) { - NoEventDispatchAssertion assertNoEventDispatch; +#if !ASSERT_DISABLED + auto assertNoEventDispatch = std::make_unique(); +#endif document().incDOMTreeVersion(); @@ -221,6 +224,13 @@ ElementTraversal::nextSibling(*this), source }; + +#if !ASSERT_DISABLED + // Attribute CharacterData is expected to fire events. + if (is(*parentNode())) + assertNoEventDispatch = nullptr; +#endif + parentNode()->childrenChanged(change); } diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/ComposedTreeIterator.cpp webkit2gtk-2.16.2/Source/WebCore/dom/ComposedTreeIterator.cpp --- webkit2gtk-2.16.1/Source/WebCore/dom/ComposedTreeIterator.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/ComposedTreeIterator.cpp 2017-05-08 17:37:49.000000000 +0000 @@ -179,10 +179,10 @@ { while (context().iterator == context().end && m_contextStack.size() > 1) { m_contextStack.removeLast(); - if (context().iterator == context().end) - return; if (is(current()) && advanceInSlot(1)) return; + if (context().iterator == context().end) + return; context().iterator.traverseNextSkippingChildren(); } } diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/ContainerNode.cpp webkit2gtk-2.16.2/Source/WebCore/dom/ContainerNode.cpp --- webkit2gtk-2.16.1/Source/WebCore/dom/ContainerNode.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/ContainerNode.cpp 2017-05-08 10:58:04.000000000 +0000 @@ -69,8 +69,9 @@ ChildNodesLazySnapshot* ChildNodesLazySnapshot::latestSnapshot; -#ifndef NDEBUG +#if !ASSERT_DISABLED unsigned NoEventDispatchAssertion::s_count = 0; +unsigned NoEventDispatchAssertion::DisableAssertionsInScope::s_existingCount = 0; NoEventDispatchAssertion::EventAllowedScope* NoEventDispatchAssertion::EventAllowedScope::s_currentScope = nullptr; #endif diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/Document.cpp webkit2gtk-2.16.2/Source/WebCore/dom/Document.cpp --- webkit2gtk-2.16.1/Source/WebCore/dom/Document.cpp 2017-04-03 17:10:47.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/Document.cpp 2017-05-08 12:50:02.000000000 +0000 @@ -683,6 +683,7 @@ m_fullScreenElement = nullptr; m_fullScreenElementStack.clear(); #endif + m_associatedFormControls.clear(); detachParser(); @@ -2683,13 +2684,13 @@ ImageLoader::dispatchPendingErrorEvents(); HTMLLinkElement::dispatchPendingLoadEvents(); HTMLStyleElement::dispatchPendingLoadEvents(); - } - // To align the HTML load event and the SVGLoad event for the outermost element, fire it from - // here, instead of doing it from SVGElement::finishedParsingChildren (if externalResourcesRequired="false", - // which is the default, for ='true' its fired at a later time, once all external resources finished loading). - if (svgExtensions()) - accessSVGExtensions().dispatchSVGLoadEventToOutermostSVGElements(); + // To align the HTML load event and the SVGLoad event for the outermost element, fire it from + // here, instead of doing it from SVGElement::finishedParsingChildren (if externalResourcesRequired="false", + // which is the default, for ='true' its fired at a later time, once all external resources finished loading). + if (svgExtensions()) + accessSVGExtensions().dispatchSVGLoadEventToOutermostSVGElements(); + } dispatchWindowLoadEvent(); dispatchPageshowEvent(PageshowEventNotPersisted); @@ -4050,30 +4051,30 @@ return const_cast(*this); } -void Document::setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& attributeValue) +void Document::setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& attributeValue, DOMWrapperWorld& isolatedWorld) { - setAttributeEventListener(eventType, JSLazyEventListener::create(*this, attributeName, attributeValue)); + setAttributeEventListener(eventType, JSLazyEventListener::create(*this, attributeName, attributeValue), isolatedWorld); } -void Document::setWindowAttributeEventListener(const AtomicString& eventType, RefPtr&& listener) +void Document::setWindowAttributeEventListener(const AtomicString& eventType, RefPtr&& listener, DOMWrapperWorld& isolatedWorld) { if (!m_domWindow) return; - m_domWindow->setAttributeEventListener(eventType, WTFMove(listener)); + m_domWindow->setAttributeEventListener(eventType, WTFMove(listener), isolatedWorld); } -void Document::setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& attributeValue) +void Document::setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& attributeValue, DOMWrapperWorld& isolatedWorld) { if (!m_domWindow) return; - setWindowAttributeEventListener(eventType, JSLazyEventListener::create(*m_domWindow, attributeName, attributeValue)); + setWindowAttributeEventListener(eventType, JSLazyEventListener::create(*m_domWindow, attributeName, attributeValue), isolatedWorld); } -EventListener* Document::getWindowAttributeEventListener(const AtomicString& eventType) +EventListener* Document::getWindowAttributeEventListener(const AtomicString& eventType, DOMWrapperWorld& isolatedWorld) { if (!m_domWindow) return nullptr; - return m_domWindow->attributeEventListener(eventType); + return m_domWindow->attributeEventListener(eventType, isolatedWorld); } void Document::dispatchWindowEvent(Event& event, EventTarget* target) diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/Document.h webkit2gtk-2.16.2/Source/WebCore/dom/Document.h --- webkit2gtk-2.16.1/Source/WebCore/dom/Document.h 2017-04-03 16:25:32.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/Document.h 2017-05-08 08:25:45.000000000 +0000 @@ -757,9 +757,9 @@ void setContextDocument(Document& document) { m_contextDocument = document.createWeakPtr(); } // Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists. - void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value); - void setWindowAttributeEventListener(const AtomicString& eventType, RefPtr&&); - EventListener* getWindowAttributeEventListener(const AtomicString& eventType); + void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value, DOMWrapperWorld&); + void setWindowAttributeEventListener(const AtomicString& eventType, RefPtr&&, DOMWrapperWorld&); + EventListener* getWindowAttributeEventListener(const AtomicString& eventType, DOMWrapperWorld&); WEBCORE_EXPORT void dispatchWindowEvent(Event&, EventTarget* = nullptr); void dispatchWindowLoadEvent(); @@ -1154,6 +1154,9 @@ bool hasTouchEventHandlers() const { return false; } #endif + void setUserDidInteractWithPage(bool userDidInteractWithPage) { ASSERT(&topDocument() == this); m_userDidInteractWithPage = userDidInteractWithPage; } + bool userDidInteractWithPage() const { ASSERT(&topDocument() == this); return m_userDidInteractWithPage; } + // Used for testing. Count handlers in the main document, and one per frame which contains handlers. WEBCORE_EXPORT unsigned wheelEventHandlerCount() const; WEBCORE_EXPORT unsigned touchEventHandlerCount() const; @@ -1272,7 +1275,7 @@ #endif using ContainerNode::setAttributeEventListener; - void setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value); + void setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value, DOMWrapperWorld& isolatedWorld); DOMSelection* getSelection(); @@ -1735,6 +1738,7 @@ RefPtr m_defaultMediaSession; #endif bool m_areDeviceMotionAndOrientationUpdatesSuspended { false }; + bool m_userDidInteractWithPage { false }; #if ENABLE(MEDIA_STREAM) bool m_hasHadActiveMediaStreamTrack { false }; diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/Element.cpp webkit2gtk-2.16.2/Source/WebCore/dom/Element.cpp --- webkit2gtk-2.16.1/Source/WebCore/dom/Element.cpp 2017-04-03 16:55:15.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/Element.cpp 2017-05-08 08:25:45.000000000 +0000 @@ -4,7 +4,7 @@ * (C) 2001 Peter Kelly (pmk@post.com) * (C) 2001 Dirk Mueller (mueller@kde.org) * (C) 2007 David Smith (catfish.man@gmail.com) - * Copyright (C) 2004-2016 Apple Inc. All rights reserved. + * Copyright (C) 2004-2017 Apple Inc. All rights reserved. * (C) 2007 Eric Seidel (eric@webkit.org) * * This library is free software; you can redistribute it and/or @@ -2055,7 +2055,7 @@ void Element::setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& attributeValue) { - setAttributeEventListener(eventType, JSLazyEventListener::create(*this, attributeName, attributeValue)); + setAttributeEventListener(eventType, JSLazyEventListener::create(*this, attributeName, attributeValue), mainThreadNormalWorld()); } void Element::setIsNamedFlowContentElement() diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/EventTarget.cpp webkit2gtk-2.16.2/Source/WebCore/dom/EventTarget.cpp --- webkit2gtk-2.16.1/Source/WebCore/dom/EventTarget.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/EventTarget.cpp 2017-05-08 08:25:43.000000000 +0000 @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2004-2017 Apple Inc. All rights reserved. * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) * (C) 2007, 2008 Nikolas Zimmermann * @@ -32,9 +32,11 @@ #include "config.h" #include "EventTarget.h" +#include "DOMWrapperWorld.h" #include "EventNames.h" #include "ExceptionCode.h" #include "InspectorInstrumentation.h" +#include "JSEventListener.h" #include "NoEventDispatchAssertion.h" #include "ScriptController.h" #include "WebKitAnimationEvent.h" @@ -104,9 +106,9 @@ return data && data->eventListenerMap.remove(eventType, listener, options.capture); } -bool EventTarget::setAttributeEventListener(const AtomicString& eventType, RefPtr&& listener) +bool EventTarget::setAttributeEventListener(const AtomicString& eventType, RefPtr&& listener, DOMWrapperWorld& isolatedWorld) { - auto* existingListener = attributeEventListener(eventType); + auto* existingListener = attributeEventListener(eventType, isolatedWorld); if (!listener) { if (existingListener) removeEventListener(eventType, *existingListener, false); @@ -119,12 +121,18 @@ return addEventListener(eventType, listener.releaseNonNull()); } -EventListener* EventTarget::attributeEventListener(const AtomicString& eventType) +EventListener* EventTarget::attributeEventListener(const AtomicString& eventType, DOMWrapperWorld& isolatedWorld) { for (auto& eventListener : eventListeners(eventType)) { - if (eventListener->callback().isAttribute()) - return &eventListener->callback(); + auto& listener = eventListener->callback(); + if (!listener.isAttribute()) + continue; + + auto& listenerWorld = downcast(listener).isolatedWorld(); + if (&listenerWorld == &isolatedWorld) + return &listener; } + return nullptr; } diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/EventTarget.h webkit2gtk-2.16.2/Source/WebCore/dom/EventTarget.h --- webkit2gtk-2.16.1/Source/WebCore/dom/EventTarget.h 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/EventTarget.h 2017-05-08 08:25:43.000000000 +0000 @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004-2017 Apple Inc. All rights reserved. * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) * (C) 2007, 2008 Nikolas Zimmermann * @@ -41,6 +41,7 @@ namespace WebCore { class DOMWindow; +class DOMWrapperWorld; class Node; struct EventTargetData { @@ -104,8 +105,8 @@ virtual void uncaughtExceptionInEventHandler(); // Used for legacy "onevent" attributes. - bool setAttributeEventListener(const AtomicString& eventType, RefPtr&&); - EventListener* attributeEventListener(const AtomicString& eventType); + bool setAttributeEventListener(const AtomicString& eventType, RefPtr&&, DOMWrapperWorld&); + EventListener* attributeEventListener(const AtomicString& eventType, DOMWrapperWorld&); bool hasEventListeners() const; bool hasEventListeners(const AtomicString& eventType) const; diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/NoEventDispatchAssertion.h webkit2gtk-2.16.2/Source/WebCore/dom/NoEventDispatchAssertion.h --- webkit2gtk-2.16.1/Source/WebCore/dom/NoEventDispatchAssertion.h 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/NoEventDispatchAssertion.h 2017-05-08 10:58:04.000000000 +0000 @@ -108,6 +108,32 @@ #endif #if !ASSERT_DISABLED + class DisableAssertionsInScope { + public: + DisableAssertionsInScope() + { + if (!isMainThread()) + return; + s_existingCount = s_count; + s_count = 0; + } + + ~DisableAssertionsInScope() + { + s_count = s_existingCount; + s_existingCount = 0; + } + private: + WEBCORE_EXPORT static unsigned s_existingCount; + }; +#else + class DisableAssertionsInScope { + public: + DisableAssertionsInScope() { } + }; +#endif + +#if !ASSERT_DISABLED private: WEBCORE_EXPORT static unsigned s_count; #endif diff -Nru webkit2gtk-2.16.1/Source/WebCore/dom/UserGestureIndicator.cpp webkit2gtk-2.16.2/Source/WebCore/dom/UserGestureIndicator.cpp --- webkit2gtk-2.16.1/Source/WebCore/dom/UserGestureIndicator.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/dom/UserGestureIndicator.cpp 2017-05-08 07:44:04.000000000 +0000 @@ -54,8 +54,10 @@ if (state) currentToken() = UserGestureToken::create(state.value()); - if (document && currentToken()->processingUserGesture()) + if (document && currentToken()->processingUserGesture()) { document->topDocument().updateLastHandledUserGestureTimestamp(); + document->topDocument().setUserDidInteractWithPage(true); + } } UserGestureIndicator::UserGestureIndicator(RefPtr token) diff -Nru webkit2gtk-2.16.1/Source/WebCore/editing/MarkupAccumulator.cpp webkit2gtk-2.16.2/Source/WebCore/editing/MarkupAccumulator.cpp --- webkit2gtk-2.16.1/Source/WebCore/editing/MarkupAccumulator.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/editing/MarkupAccumulator.cpp 2017-05-08 10:11:50.000000000 +0000 @@ -214,10 +214,10 @@ result.append(m_markup); } -void MarkupAccumulator::appendAttributeValue(StringBuilder& result, const String& attribute, bool documentIsHTML) +void MarkupAccumulator::appendAttributeValue(StringBuilder& result, const String& attribute, bool isSerializingHTML) { appendCharactersReplacingEntities(result, attribute, 0, attribute.length(), - documentIsHTML ? EntityMaskInHTMLAttributeValue : EntityMaskInAttributeValue); + isSerializingHTML ? EntityMaskInHTMLAttributeValue : EntityMaskInAttributeValue); } void MarkupAccumulator::appendCustomAttributes(StringBuilder&, const Element&, Namespaces*) @@ -489,12 +489,12 @@ void MarkupAccumulator::appendAttribute(StringBuilder& result, const Element& element, const Attribute& attribute, Namespaces* namespaces) { - bool documentIsHTML = element.document().isHTMLDocument(); + bool isSerializingHTML = element.document().isHTMLDocument() && !inXMLFragmentSerialization(); result.append(' '); QualifiedName prefixedName = attribute.name(); - if (documentIsHTML && !attributeIsInSerializedNamespace(attribute)) + if (isSerializingHTML && !attributeIsInSerializedNamespace(attribute)) result.append(attribute.name().localName()); else { if (!attribute.namespaceURI().isEmpty()) { @@ -524,11 +524,11 @@ appendQuotedURLAttributeValue(result, element, attribute); else { result.append('"'); - appendAttributeValue(result, attribute.value(), documentIsHTML); + appendAttributeValue(result, attribute.value(), isSerializingHTML); result.append('"'); } - if ((inXMLFragmentSerialization() || !documentIsHTML) && namespaces && shouldAddNamespaceAttribute(attribute, *namespaces)) + if (!isSerializingHTML && namespaces && shouldAddNamespaceAttribute(attribute, *namespaces)) appendNamespace(result, prefixedName.prefix(), prefixedName.namespaceURI(), *namespaces); } diff -Nru webkit2gtk-2.16.1/Source/WebCore/editing/MarkupAccumulator.h webkit2gtk-2.16.2/Source/WebCore/editing/MarkupAccumulator.h --- webkit2gtk-2.16.1/Source/WebCore/editing/MarkupAccumulator.h 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/editing/MarkupAccumulator.h 2017-05-08 10:11:50.000000000 +0000 @@ -92,7 +92,7 @@ void appendStartMarkup(StringBuilder&, const Node&, Namespaces*); void appendEndMarkup(StringBuilder&, const Element&); - void appendAttributeValue(StringBuilder&, const String&, bool); + void appendAttributeValue(StringBuilder&, const String&, bool isSerializingHTML); void appendNamespace(StringBuilder&, const AtomicString& prefix, const AtomicString& namespaceURI, Namespaces&, bool allowEmptyDefaultNS = false); void appendXMLDeclaration(StringBuilder&, const Document&); void appendDocumentType(StringBuilder&, const DocumentType&); diff -Nru webkit2gtk-2.16.1/Source/WebCore/editing/ReplaceSelectionCommand.cpp webkit2gtk-2.16.2/Source/WebCore/editing/ReplaceSelectionCommand.cpp --- webkit2gtk-2.16.1/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2017-05-08 08:25:45.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2005-2017 Apple Inc. All rights reserved. * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,6 +32,7 @@ #include "BeforeTextInsertedEvent.h" #include "BreakBlockquoteCommand.h" #include "CSSStyleDeclaration.h" +#include "DOMWrapperWorld.h" #include "DataTransfer.h" #include "Document.h" #include "DocumentFragment.h" @@ -167,7 +168,7 @@ Node* shadowAncestorNode = editableRoot->deprecatedShadowAncestorNode(); - if (!editableRoot->attributeEventListener(eventNames().webkitBeforeTextInsertedEvent) + if (!editableRoot->attributeEventListener(eventNames().webkitBeforeTextInsertedEvent, mainThreadNormalWorld()) && !(shadowAncestorNode && shadowAncestorNode->renderer() && shadowAncestorNode->renderer()->isTextControl()) && editableRoot->hasRichlyEditableStyle()) { removeInterchangeNodes(m_fragment.get()); diff -Nru webkit2gtk-2.16.1/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp webkit2gtk-2.16.2/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp --- webkit2gtk-2.16.1/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2017-05-08 09:47:13.000000000 +0000 @@ -2087,8 +2087,10 @@ return; IntRect sourceRect(destRect); sourceRect.move(-destOffset); + sourceRect.intersect(IntRect(0, 0, data.width(), data.height())); - buffer->putByteArray(Unmultiplied, data.data(), IntSize(data.width(), data.height()), sourceRect, IntPoint(destOffset), coordinateSystem); + if (!sourceRect.isEmpty()) + buffer->putByteArray(Unmultiplied, data.data(), IntSize(data.width(), data.height()), sourceRect, IntPoint(destOffset), coordinateSystem); didDraw(destRect, CanvasDidDrawApplyNone); // ignore transform, shadow and clip } diff -Nru webkit2gtk-2.16.1/Source/WebCore/html/HTMLBodyElement.cpp webkit2gtk-2.16.2/Source/WebCore/html/HTMLBodyElement.cpp --- webkit2gtk-2.16.1/Source/WebCore/html/HTMLBodyElement.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/html/HTMLBodyElement.cpp 2017-05-08 08:25:43.000000000 +0000 @@ -3,7 +3,7 @@ * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann (hausmann@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2006-2010, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2004-2017 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -28,6 +28,7 @@ #include "CSSParser.h" #include "CSSValueKeywords.h" #include "DOMWindow.h" +#include "DOMWrapperWorld.h" #include "EventNames.h" #include "Frame.h" #include "FrameView.h" @@ -173,13 +174,13 @@ } if (name == onselectionchangeAttr) { - document().setAttributeEventListener(eventNames().selectionchangeEvent, name, value); + document().setAttributeEventListener(eventNames().selectionchangeEvent, name, value, mainThreadNormalWorld()); return; } auto& eventName = eventNameForWindowEventHandlerAttribute(name); if (!eventName.isNull()) { - document().setWindowAttributeEventListener(eventName, name, value); + document().setWindowAttributeEventListener(eventName, name, value, mainThreadNormalWorld()); return; } diff -Nru webkit2gtk-2.16.1/Source/WebCore/html/HTMLFrameSetElement.cpp webkit2gtk-2.16.2/Source/WebCore/html/HTMLFrameSetElement.cpp --- webkit2gtk-2.16.1/Source/WebCore/html/HTMLFrameSetElement.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/html/HTMLFrameSetElement.cpp 2017-05-08 08:25:45.000000000 +0000 @@ -3,7 +3,7 @@ * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann (hausmann@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2004-2017 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -25,6 +25,7 @@ #include "HTMLFrameSetElement.h" #include "CSSPropertyNames.h" +#include "DOMWrapperWorld.h" #include "Document.h" #include "ElementIterator.h" #include "Event.h" @@ -142,7 +143,7 @@ auto& eventName = HTMLBodyElement::eventNameForWindowEventHandlerAttribute(name); if (!eventName.isNull()) { - document().setWindowAttributeEventListener(eventName, name, value); + document().setWindowAttributeEventListener(eventName, name, value, mainThreadNormalWorld()); return; } diff -Nru webkit2gtk-2.16.1/Source/WebCore/html/SearchInputType.cpp webkit2gtk-2.16.2/Source/WebCore/html/SearchInputType.cpp --- webkit2gtk-2.16.1/Source/WebCore/html/SearchInputType.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/html/SearchInputType.cpp 2017-05-09 06:32:50.000000000 +0000 @@ -55,8 +55,11 @@ void SearchInputType::addSearchResult() { #if !PLATFORM(IOS) - if (auto* renderer = element().renderer()) - downcast(*renderer).addSearchResult(); + // Normally we've got the correct renderer by the time we get here. However when the input type changes + // we don't update the associated renderers until after the next tree update, so we could actually end up here + // with a mismatched renderer (e.g. through form submission). + if (is(element().renderer())) + downcast(*element().renderer()).addSearchResult(); #endif } @@ -158,8 +161,7 @@ unsigned length = element().innerTextValue().length(); if (!length) { - stopSearchEventTimer(); - element().onSearch(); + m_searchEventTimer.startOneShot(0_ms); return; } @@ -185,9 +187,8 @@ void SearchInputType::didSetValueByUserEdit() { - if (m_cancelButton && element().renderer()) + if (m_cancelButton && is(element().renderer())) downcast(*element().renderer()).updateCancelButtonVisibility(); - // If the incremental attribute is set, then dispatch the search event if (searchEventsShouldBeDispatched()) startSearchEventTimer(); diff -Nru webkit2gtk-2.16.1/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp webkit2gtk-2.16.2/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp --- webkit2gtk-2.16.1/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp 2017-05-07 09:24:48.000000000 +0000 @@ -45,6 +45,7 @@ #include "Storage.h" #include "StorageNamespace.h" #include "StorageNamespaceProvider.h" +#include "StorageType.h" #include "VoidCallback.h" #include #include @@ -163,7 +164,7 @@ if (!m_enabled) return; - RefPtr id = storageId(securityOrigin, storageType == LocalStorage); + RefPtr id = storageId(securityOrigin, storageType == StorageType::Local); if (key.isNull()) m_frontendDispatcher->domStorageItemsCleared(id); diff -Nru webkit2gtk-2.16.1/Source/WebCore/inspector/InspectorInstrumentation.h webkit2gtk-2.16.2/Source/WebCore/inspector/InspectorInstrumentation.h --- webkit2gtk-2.16.1/Source/WebCore/inspector/InspectorInstrumentation.h 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/inspector/InspectorInstrumentation.h 2017-05-07 09:24:50.000000000 +0000 @@ -83,6 +83,8 @@ class WebKitNamedFlow; class WorkerInspectorProxy; +enum class StorageType; + struct ReplayPosition; struct WebSocketFrame; diff -Nru webkit2gtk-2.16.1/Source/WebCore/loader/EmptyClients.cpp webkit2gtk-2.16.2/Source/WebCore/loader/EmptyClients.cpp --- webkit2gtk-2.16.1/Source/WebCore/loader/EmptyClients.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/loader/EmptyClients.cpp 2017-05-07 09:25:30.000000000 +0000 @@ -56,6 +56,7 @@ #include "StorageArea.h" #include "StorageNamespace.h" #include "StorageNamespaceProvider.h" +#include "StorageType.h" #include "TextCheckerClient.h" #include "ThreadableWebSocketChannel.h" #include "UserContentProvider.h" @@ -550,7 +551,7 @@ void clear(Frame*) final { } bool contains(const String&) final { return false; } bool canAccessStorage(Frame*) final { return false; } - StorageType storageType() const final { return LocalStorage; } + StorageType storageType() const final { return StorageType::Local; } size_t memoryBytesUsedByCache() final { return 0; } SecurityOriginData securityOrigin() const final { return { }; } }; @@ -562,6 +563,7 @@ RefPtr createSessionStorageNamespace(Page&, unsigned) final; RefPtr createLocalStorageNamespace(unsigned) final; + RefPtr createEphemeralLocalStorageNamespace(Page&, unsigned) final; RefPtr createTransientLocalStorageNamespace(SecurityOrigin&, unsigned) final; }; @@ -675,6 +677,11 @@ { return adoptRef(*new EmptyStorageNamespace); } + +RefPtr EmptyStorageNamespaceProvider::createEphemeralLocalStorageNamespace(Page&, unsigned) +{ + return adoptRef(*new EmptyStorageNamespace); +} RefPtr EmptyStorageNamespaceProvider::createTransientLocalStorageNamespace(SecurityOrigin&, unsigned) { diff -Nru webkit2gtk-2.16.1/Source/WebCore/loader/FrameLoader.cpp webkit2gtk-2.16.2/Source/WebCore/loader/FrameLoader.cpp --- webkit2gtk-2.16.1/Source/WebCore/loader/FrameLoader.cpp 2017-04-03 16:25:32.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/loader/FrameLoader.cpp 2017-05-08 14:05:50.000000000 +0000 @@ -775,6 +775,13 @@ if (m_isComplete) return; + // FIXME: It would be better if resource loads were kicked off after render tree update (or didn't complete synchronously). + // https://bugs.webkit.org/show_bug.cgi?id=171729 + if (m_frame.document()->inRenderTreeUpdate()) { + scheduleCheckCompleted(); + return; + } + // Are we still parsing? if (m_frame.document()->parsing()) return; @@ -1916,20 +1923,20 @@ if (pdl != m_provisionalDocumentLoader) return; - // Nothing else can interupt this commit - set the Provisional->Committed transition in stone if (m_documentLoader) m_documentLoader->stopLoadingSubresources(); if (m_documentLoader) m_documentLoader->stopLoadingPlugIns(); + // Setting our document loader invokes the unload event handler of our child frames. + // Script can do anything. If the script initiates a new load, we need to abandon the + // current load or the two will stomp each other. setDocumentLoader(m_provisionalDocumentLoader.get()); - setProvisionalDocumentLoader(nullptr); - - if (pdl != m_documentLoader) { - ASSERT(m_state == FrameStateComplete); + if (pdl != m_provisionalDocumentLoader) return; - } + setProvisionalDocumentLoader(nullptr); + // Nothing else can interupt this commit - set the Provisional->Committed transition in stone setState(FrameStateCommittedPage); // Handle adding the URL to the back/forward list. @@ -2988,7 +2995,7 @@ static bool shouldAskForNavigationConfirmation(Document& document, const BeforeUnloadEvent& event) { - bool userDidInteractWithPage = document.topDocument().lastHandledUserGestureTimestamp() > 0; + bool userDidInteractWithPage = document.topDocument().userDidInteractWithPage(); // Web pages can request we ask for confirmation before navigating by: // - Cancelling the BeforeUnloadEvent (modern way) // - Setting the returnValue attribute on the BeforeUnloadEvent to a non-empty string. diff -Nru webkit2gtk-2.16.1/Source/WebCore/Modules/indexeddb/IDBRequest.cpp webkit2gtk-2.16.2/Source/WebCore/Modules/indexeddb/IDBRequest.cpp --- webkit2gtk-2.16.1/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2017-05-08 14:04:29.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. + * Copyright (C) 2015-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -370,7 +370,9 @@ // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject. - m_result = Result { JSC::Strong { context->vm(), toJS(*state, *jsCast(state->lexicalGlobalObject()), keyData) } }; + VM& vm = context->vm(); + JSLockHolder lock(vm); + m_result = Result { JSC::Strong { vm, toJS(*state, *jsCast(state->lexicalGlobalObject()), keyData) } }; } void IDBRequest::setResult(const Vector& keyDatas) @@ -387,8 +389,9 @@ // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject. - Locker locker(context->vm().apiLock()); - m_result = Result { JSC::Strong { context->vm(), toJS>(*state, *jsCast(state->lexicalGlobalObject()), keyDatas) } }; + VM& vm = context->vm(); + JSLockHolder lock(vm); + m_result = Result { JSC::Strong { vm, toJS>(*state, *jsCast(state->lexicalGlobalObject()), keyDatas) } }; } void IDBRequest::setResult(const Vector& values) @@ -405,8 +408,9 @@ // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject. - Locker locker(context->vm().apiLock()); - m_result = Result { JSC::Strong { context->vm(), toJS>(*state, *jsCast(state->lexicalGlobalObject()), values) } }; + VM& vm = context->vm(); + JSLockHolder lock(vm); + m_result = Result { JSC::Strong { vm, toJS>(*state, *jsCast(state->lexicalGlobalObject()), values) } }; } void IDBRequest::setResult(uint64_t number) @@ -436,7 +440,9 @@ // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject. - m_result = Result { JSC::Strong { context->vm(), toJS(*state, *jsCast(state->lexicalGlobalObject()), value) } }; + VM& vm = context->vm(); + JSLockHolder lock(vm); + m_result = Result { JSC::Strong { vm, toJS(*state, *jsCast(state->lexicalGlobalObject()), value) } }; } void IDBRequest::setResultToUndefined() diff -Nru webkit2gtk-2.16.1/Source/WebCore/page/animation/AnimationBase.cpp webkit2gtk-2.16.2/Source/WebCore/page/animation/AnimationBase.cpp --- webkit2gtk-2.16.1/Source/WebCore/page/animation/AnimationBase.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/page/animation/AnimationBase.cpp 2017-05-08 06:52:35.000000000 +0000 @@ -163,10 +163,10 @@ m_compositeAnimation->animationController().removeFromAnimationsWaitingForStyle(this); LOG(Animations, "%p AnimationState %s -> New", this, nameForState(m_animationState)); m_animationState = AnimationState::New; - m_startTime = 0; - m_pauseTime = -1; + m_startTime = std::nullopt; + m_pauseTime = std::nullopt; m_requestedStartTime = 0; - m_nextIterationDuration = -1; + m_nextIterationDuration = std::nullopt; endAnimation(); return; } @@ -176,10 +176,10 @@ m_compositeAnimation->animationController().removeFromAnimationsWaitingForStyle(this); LOG(Animations, "%p AnimationState %s -> New", this, nameForState(m_animationState)); m_animationState = AnimationState::New; - m_startTime = 0; - m_pauseTime = -1; + m_startTime = std::nullopt; + m_pauseTime = std::nullopt; m_requestedStartTime = 0; - m_nextIterationDuration = -1; + m_nextIterationDuration = std::nullopt; endAnimation(); if (!paused()) @@ -209,7 +209,7 @@ if (input == AnimationStateInput::ResumeOverride) { if (m_animationState == AnimationState::Looping || m_animationState == AnimationState::Ending) { // Start the animation - startAnimation(beginAnimationUpdateTime() - m_startTime); + startAnimation(beginAnimationUpdateTime() - m_startTime.value_or(0)); } return; } @@ -227,7 +227,7 @@ // We are pausing before we even started. LOG(Animations, "%p AnimationState %s -> AnimationState::PausedNew", this, nameForState(m_animationState)); m_animationState = AnimationState::PausedNew; - m_pauseTime = 0; + m_pauseTime = std::nullopt; } #if ENABLE(CSS_ANIMATIONS_LEVEL_2) @@ -299,11 +299,11 @@ LOG(Animations, "%p AnimationState %s -> StartTimeSet (time is %f)", this, nameForState(m_animationState), param); // We have a start time, set it, unless the startTime is already set - if (m_startTime <= 0) { + if (!m_startTime) { m_startTime = param; // If the value for 'animation-delay' is negative then the animation appears to have started in the past. if (m_animation->delay() < 0) - m_startTime += m_animation->delay(); + m_startTime = m_startTime.value() + m_animation->delay(); } // Now that we know the start time, fire the start event. @@ -319,7 +319,7 @@ // We are pausing while waiting for a start response. Cancel the animation and wait. When // we unpause, we will act as though the start timer just fired m_pauseTime = beginAnimationUpdateTime(); - pauseAnimation(beginAnimationUpdateTime() - m_startTime); + pauseAnimation(beginAnimationUpdateTime() - m_startTime.value_or(0)); LOG(Animations, "%p AnimationState %s -> PausedWaitResponse", this, nameForState(m_animationState)); m_animationState = AnimationState::PausedWaitResponse; } @@ -339,7 +339,7 @@ } else { // We are pausing while running. Cancel the animation and wait m_pauseTime = beginAnimationUpdateTime(); - pauseAnimation(beginAnimationUpdateTime() - m_startTime); + pauseAnimation(beginAnimationUpdateTime() - m_startTime.value_or(0)); LOG(Animations, "%p AnimationState %s -> PausedRun", this, nameForState(m_animationState)); m_animationState = AnimationState::PausedRun; } @@ -371,7 +371,7 @@ } else { // We are pausing while running. Cancel the animation and wait m_pauseTime = beginAnimationUpdateTime(); - pauseAnimation(beginAnimationUpdateTime() - m_startTime); + pauseAnimation(beginAnimationUpdateTime() - m_startTime.value_or(0)); LOG(Animations, "%p AnimationState %s -> PausedRun", this, nameForState(m_animationState)); m_animationState = AnimationState::PausedRun; } @@ -381,8 +381,8 @@ ASSERT(input == AnimationStateInput::PlayStateRunning); ASSERT(paused()); // Update the times - m_startTime += beginAnimationUpdateTime() - m_pauseTime; - m_pauseTime = -1; + m_startTime = m_startTime.value() + beginAnimationUpdateTime() - m_pauseTime.value_or(0); + m_pauseTime = std::nullopt; // we were waiting for the start timer to fire, go back and wait again LOG(Animations, "%p AnimationState %s -> New", this, nameForState(m_animationState)); @@ -406,18 +406,18 @@ // to start, so jump back to the New state and reset. LOG(Animations, "%p AnimationState %s -> AnimationState::New", this, nameForState(m_animationState)); m_animationState = AnimationState::New; - m_pauseTime = -1; + m_pauseTime = std::nullopt; updateStateMachine(input, param); break; } // Update the times if (m_animationState == AnimationState::PausedRun) - m_startTime += beginAnimationUpdateTime() - m_pauseTime; + m_startTime = m_startTime.value() + beginAnimationUpdateTime() - m_pauseTime.value_or(0); else m_startTime = 0; - m_pauseTime = -1; + m_pauseTime = std::nullopt; if (m_animationState == AnimationState::PausedWaitStyleAvailable) { LOG(Animations, "%p AnimationState %s -> StartWaitStyleAvailable", this, nameForState(m_animationState)); @@ -436,7 +436,7 @@ updateStateMachine(AnimationStateInput::StartTimeSet, beginAnimationUpdateTime()); m_isAccelerated = true; } else { - bool started = startAnimation(beginAnimationUpdateTime() - m_startTime); + bool started = startAnimation(beginAnimationUpdateTime() - m_startTime.value_or(0)); m_compositeAnimation->animationController().addToAnimationsWaitingForStartTimeResponse(this, started); m_isAccelerated = started; } @@ -451,9 +451,9 @@ // We ignore the start time and just move into the paused-run state. LOG(Animations, "%p AnimationState %s -> PausedRun (time is %f)", this, nameForState(m_animationState), param); m_animationState = AnimationState::PausedRun; - ASSERT(m_startTime == 0); + ASSERT(!m_startTime); m_startTime = param; - m_pauseTime += m_startTime; + m_pauseTime = m_pauseTime.value_or(0) + param; break; } @@ -506,7 +506,7 @@ return; } - double elapsedDuration = beginAnimationUpdateTime() - m_startTime; + double elapsedDuration = beginAnimationUpdateTime() - m_startTime.value_or(0); #if ENABLE(CSS_ANIMATIONS_LEVEL_2) // If we are a triggered animation that depends on scroll, our elapsed // time is determined by the scroll position. @@ -520,17 +520,17 @@ elapsedDuration = std::max(elapsedDuration, 0.0); // Check for end timeout - if (m_totalDuration >= 0 && elapsedDuration >= m_totalDuration) { + if (m_totalDuration && elapsedDuration >= m_totalDuration.value()) { // We may still be in AnimationState::Looping if we've managed to skip a // whole iteration, in which case we should jump to the end state. LOG(Animations, "%p AnimationState %s -> Ending", this, nameForState(m_animationState)); m_animationState = AnimationState::Ending; // Fire an end event - updateStateMachine(AnimationStateInput::EndTimerFired, m_totalDuration); + updateStateMachine(AnimationStateInput::EndTimerFired, m_totalDuration.value()); } else { // Check for iteration timeout - if (m_nextIterationDuration < 0) { + if (!m_nextIterationDuration) { // Hasn't been set yet, set it double durationLeft = m_animation->duration() - fmod(elapsedDuration, m_animation->duration()); m_nextIterationDuration = elapsedDuration + durationLeft; @@ -538,7 +538,7 @@ if (elapsedDuration >= m_nextIterationDuration) { // Set to the next iteration - double previous = m_nextIterationDuration; + double previous = m_nextIterationDuration.value(); double durationLeft = m_animation->duration() - fmod(elapsedDuration, m_animation->duration()); m_nextIterationDuration = elapsedDuration + durationLeft; @@ -678,16 +678,16 @@ void AnimationBase::getTimeToNextEvent(double& time, bool& isLooping) const { // Decide when the end or loop event needs to fire - const double elapsedDuration = std::max(beginAnimationUpdateTime() - m_startTime, 0.0); + const double elapsedDuration = std::max(beginAnimationUpdateTime() - m_startTime.value_or(0), 0.0); double durationLeft = 0; - double nextIterationTime = m_totalDuration; + double nextIterationTime = m_totalDuration.value_or(0); - if (m_totalDuration < 0 || elapsedDuration < m_totalDuration) { + if (!m_totalDuration || elapsedDuration < m_totalDuration.value()) { durationLeft = m_animation->duration() > 0 ? (m_animation->duration() - fmod(elapsedDuration, m_animation->duration())) : 0; nextIterationTime = elapsedDuration + durationLeft; } - if (m_totalDuration < 0 || nextIterationTime < m_totalDuration) { + if (!m_totalDuration || nextIterationTime < m_totalDuration.value()) { // We are not at the end yet ASSERT(nextIterationTime > 0); isLooping = true; @@ -722,12 +722,12 @@ ASSERT(m_startTime); // If m_startTime is zero, we haven't started yet, so we'll get a bad pause time. if (t <= m_animation->delay()) - m_pauseTime = m_startTime; + m_pauseTime = m_startTime.value_or(0); else - m_pauseTime = m_startTime + t - m_animation->delay(); + m_pauseTime = m_startTime.value_or(0) + t - m_animation->delay(); if (m_object && m_object->isComposited()) - downcast(*m_object).suspendAnimations(m_pauseTime); + downcast(*m_object).suspendAnimations(m_pauseTime.value()); } double AnimationBase::beginAnimationUpdateTime() const @@ -758,16 +758,16 @@ if (paused()) { double delayOffset = (!m_startTime && m_animation->delay() < 0) ? m_animation->delay() : 0; - return m_pauseTime - m_startTime - delayOffset; + return m_pauseTime.value_or(0) - m_startTime.value_or(0) - delayOffset; } - if (m_startTime <= 0) + if (!m_startTime) return 0; if (postActive() || fillingForwards()) - return m_totalDuration; + return m_totalDuration.value_or(0); - return beginAnimationUpdateTime() - m_startTime; + return beginAnimationUpdateTime() - m_startTime.value_or(0); } void AnimationBase::setElapsedTime(double time) diff -Nru webkit2gtk-2.16.1/Source/WebCore/page/animation/AnimationBase.h webkit2gtk-2.16.2/Source/WebCore/page/animation/AnimationBase.h --- webkit2gtk-2.16.1/Source/WebCore/page/animation/AnimationBase.h 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/page/animation/AnimationBase.h 2017-05-08 06:52:35.000000000 +0000 @@ -121,7 +121,7 @@ bool fillingForwards() const { return m_animationState == AnimationState::FillingForwards; } bool active() const { return !postActive() && !preActive(); } bool running() const { return !isNew() && !postActive(); } - bool paused() const { return m_pauseTime >= 0 || m_animationState == AnimationState::PausedNew; } + bool paused() const { return m_pauseTime || m_animationState == AnimationState::PausedNew; } bool inPausedState() const { return m_animationState >= AnimationState::PausedNew && m_animationState <= AnimationState::PausedRun; } bool isNew() const { return m_animationState == AnimationState::New || m_animationState == AnimationState::PausedNew; } bool waitingForStartTime() const { return m_animationState == AnimationState::StartWaitResponse; } @@ -244,11 +244,11 @@ CompositeAnimation* m_compositeAnimation; // Ideally this would be a reference, but it has to be cleared if an animation is destroyed inside an event callback. Ref m_animation; - double m_startTime { 0 }; - double m_pauseTime { -1 }; + std::optional m_startTime; + std::optional m_pauseTime; double m_requestedStartTime { 0 }; - double m_totalDuration { -1 }; - double m_nextIterationDuration { -1 }; + std::optional m_totalDuration; + std::optional m_nextIterationDuration; AnimationState m_animationState { AnimationState::New }; bool m_isAccelerated { false }; diff -Nru webkit2gtk-2.16.1/Source/WebCore/page/animation/CompositeAnimation.cpp webkit2gtk-2.16.2/Source/WebCore/page/animation/CompositeAnimation.cpp --- webkit2gtk-2.16.1/Source/WebCore/page/animation/CompositeAnimation.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/page/animation/CompositeAnimation.cpp 2017-05-08 13:45:46.000000000 +0000 @@ -97,7 +97,7 @@ bool isActiveTransition = !m_suspended && (animation.duration() || animation.delay() > 0); Animation::AnimationMode mode = animation.animationMode(); - if (mode == Animation::AnimateNone) + if (mode == Animation::AnimateNone || mode == Animation::AnimateUnknownProperty) continue; CSSPropertyID prop = animation.property(); diff -Nru webkit2gtk-2.16.1/Source/WebCore/page/Chrome.cpp webkit2gtk-2.16.2/Source/WebCore/page/Chrome.cpp --- webkit2gtk-2.16.1/Source/WebCore/page/Chrome.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/page/Chrome.cpp 2017-05-07 09:25:28.000000000 +0000 @@ -192,8 +192,12 @@ Page* newPage = m_client.createWindow(frame, request, features, action); if (!newPage) return nullptr; + if (auto* oldSessionStorage = m_page.sessionStorage(false)) newPage->setSessionStorage(oldSessionStorage->copy(newPage)); + if (auto* oldEphemeralLocalStorage = m_page.ephemeralLocalStorage(false)) + newPage->setEphemeralLocalStorage(oldEphemeralLocalStorage->copy(newPage)); + return newPage; } diff -Nru webkit2gtk-2.16.1/Source/WebCore/page/DragController.cpp webkit2gtk-2.16.2/Source/WebCore/page/DragController.cpp --- webkit2gtk-2.16.1/Source/WebCore/page/DragController.cpp 2017-02-20 16:20:16.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/page/DragController.cpp 2017-05-08 09:05:57.000000000 +0000 @@ -658,13 +658,11 @@ state.type = DragSourceActionNone; #endif - for (auto* renderer = startElement->renderer(); renderer; renderer = renderer->parent()) { - Element* element = renderer->nonPseudoElement(); - if (!element) { - // Anonymous render blocks don't correspond to actual DOM elements, so we skip over them - // for the purposes of finding a draggable element. + for (auto* element = startElement; element; element = element->parentOrShadowHostElement()) { + auto* renderer = element->renderer(); + if (!renderer) continue; - } + EUserDrag dragMode = renderer->style().userDrag(); if ((m_dragSourceAction & DragSourceActionDHTML) && dragMode == DRAG_ELEMENT) { state.type = static_cast(state.type | DragSourceActionDHTML); diff -Nru webkit2gtk-2.16.1/Source/WebCore/page/EventHandler.cpp webkit2gtk-2.16.2/Source/WebCore/page/EventHandler.cpp --- webkit2gtk-2.16.1/Source/WebCore/page/EventHandler.cpp 2017-03-13 09:59:45.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/page/EventHandler.cpp 2017-05-08 07:38:20.000000000 +0000 @@ -3093,7 +3093,20 @@ } #endif -bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent) +bool EventHandler::keyEvent(const PlatformKeyboardEvent& keyEvent) +{ + Document* topDocument = m_frame.document() ? &m_frame.document()->topDocument() : nullptr; + bool savedUserDidInteractWithPage = topDocument ? topDocument->userDidInteractWithPage() : false; + bool wasHandled = internalKeyEvent(keyEvent); + + // If the key event was not handled, do not treat it as user interaction with the page. + if (topDocument && !wasHandled) + topDocument->setUserDidInteractWithPage(savedUserDidInteractWithPage); + + return wasHandled; +} + +bool EventHandler::internalKeyEvent(const PlatformKeyboardEvent& initialKeyEvent) { Ref
elements) + return (isEmptyRange && segment.start == segment.end) ? segment.start < start : segment.end <= start; }); ASSERT(it != m_segments.end()); - ASSERT_UNUSED(end, end <= it->end); - auto index = it - m_segments.begin(); - m_lastSegmentIndex = index; - return index; + ASSERT(end <= it->end); + m_lastSegmentIndex = it - m_segments.begin(); + return m_lastSegmentIndex; } } diff -Nru webkit2gtk-2.16.1/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h webkit2gtk-2.16.2/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h --- webkit2gtk-2.16.1/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h 2017-05-06 08:09:43.000000000 +0000 @@ -63,7 +63,7 @@ inline const FlowContents::Segment& FlowContents::segmentForRun(unsigned start, unsigned end) const { - ASSERT(start < end); + ASSERT(start <= end); auto& lastSegment = m_segments[m_lastSegmentIndex]; if (lastSegment.start <= start && end <= lastSegment.end) return m_segments[m_lastSegmentIndex]; diff -Nru webkit2gtk-2.16.1/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp webkit2gtk-2.16.2/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp --- webkit2gtk-2.16.1/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp 2017-03-13 12:57:50.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp 2017-05-06 08:45:19.000000000 +0000 @@ -147,20 +147,20 @@ if (style.visibility() != VISIBLE || style.pointerEvents() == PE_NONE) return false; - RenderObject& renderer = *flow.firstChild(); LayoutRect rangeRect = locationInContainer.boundingBox(); rangeRect.moveBy(-accumulatedOffset); - auto resolver = lineResolver(flow, layout); - for (FloatRect lineRect : resolver.rangeForRect(rangeRect)) { + auto range = resolver.rangeForRect(rangeRect); + for (auto it = range.begin(), end = range.end(); it != end; ++it) { + auto lineRect = *it; lineRect.moveBy(accumulatedOffset); + auto& renderer = const_cast(it.renderer()); if (!locationInContainer.intersects(lineRect)) continue; renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset)); if (!result.addNodeToRectBasedTestResult(renderer.node(), request, locationInContainer, lineRect)) return true; } - return false; } diff -Nru webkit2gtk-2.16.1/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp webkit2gtk-2.16.2/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp --- webkit2gtk-2.16.1/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp 2017-02-28 09:12:45.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp 2017-05-06 08:09:45.000000000 +0000 @@ -267,7 +267,7 @@ { } -const FloatRect LineResolver::Iterator::operator*() const +FloatRect LineResolver::Iterator::operator*() const { unsigned currentLine = m_runIterator.lineIndex(); auto it = m_runIterator; @@ -277,6 +277,13 @@ return rect; } +const RenderObject& LineResolver::Iterator::renderer() const +{ + // FIXME: This works as long as we've got only one renderer per line. + auto run = *m_runIterator; + return m_runIterator.resolver().flowContents().segmentForRun(run.start(), run.end()).renderer; +} + LineResolver::LineResolver(const RenderBlockFlow& flow, const Layout& layout) : m_runResolver(flow, layout) { diff -Nru webkit2gtk-2.16.1/Source/WebCore/rendering/SimpleLineLayoutResolver.h webkit2gtk-2.16.2/Source/WebCore/rendering/SimpleLineLayoutResolver.h --- webkit2gtk-2.16.1/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2017-02-28 09:12:45.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2017-05-06 08:09:45.000000000 +0000 @@ -98,6 +98,7 @@ RunResolver(const RenderBlockFlow&, const Layout&); const RenderBlockFlow& flow() const { return m_flowRenderer; } + const FlowContents& flowContents() const { return m_flowContents; } Iterator begin() const; Iterator end() const; @@ -125,8 +126,6 @@ class LineResolver { public: - class Iterator; - class Iterator { public: explicit Iterator(RunResolver::Iterator); @@ -135,11 +134,12 @@ bool operator==(const Iterator&) const; bool operator!=(const Iterator&) const; - const FloatRect operator*() const; + FloatRect operator*() const; + // FIXME: Use a list to support multiple renderers per line. + const RenderObject& renderer() const; private: RunResolver::Iterator m_runIterator; - LayoutRect m_rect; }; LineResolver(const RenderBlockFlow&, const Layout&); diff -Nru webkit2gtk-2.16.1/Source/WebCore/rendering/style/RenderStyle.cpp webkit2gtk-2.16.2/Source/WebCore/rendering/style/RenderStyle.cpp --- webkit2gtk-2.16.1/Source/WebCore/rendering/style/RenderStyle.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/rendering/style/RenderStyle.cpp 2017-05-08 08:53:28.000000000 +0000 @@ -837,8 +837,20 @@ return false; } +static bool requiresPainting(const RenderStyle& style) +{ + if (style.visibility() == HIDDEN) + return false; + if (!style.opacity()) + return false; + return true; +} + bool RenderStyle::changeRequiresRepaint(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const { + if (!requiresPainting(*this) && !requiresPainting(other)) + return false; + if (m_inheritedFlags.visibility != other.m_inheritedFlags.visibility || m_inheritedFlags.printColorAdjust != other.m_inheritedFlags.printColorAdjust || m_inheritedFlags.insideLink != other.m_inheritedFlags.insideLink diff -Nru webkit2gtk-2.16.1/Source/WebCore/rendering/style/RenderStyle.h webkit2gtk-2.16.2/Source/WebCore/rendering/style/RenderStyle.h --- webkit2gtk-2.16.1/Source/WebCore/rendering/style/RenderStyle.h 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/rendering/style/RenderStyle.h 2017-05-08 07:09:11.000000000 +0000 @@ -1370,6 +1370,9 @@ bool hasExplicitlySetWritingMode() const { return m_nonInheritedFlags.hasExplicitlySetWritingMode(); } void setHasExplicitlySetWritingMode(bool v) { m_nonInheritedFlags.setHasExplicitlySetWritingMode(v); } + bool hasExplicitlySetTextAlign() const { return m_nonInheritedFlags.hasExplicitlySetTextAlign(); } + void setHasExplicitlySetTextAlign(bool value) { m_nonInheritedFlags.setHasExplicitlySetTextAlign(value); } + // A unique style is one that has matches something that makes it impossible to share. bool unique() const { return m_nonInheritedFlags.isUnique(); } void setUnique() { m_nonInheritedFlags.setIsUnique(); } @@ -1782,6 +1785,9 @@ bool hasExplicitlySetWritingMode() const { return getBoolean(hasExplicitlySetWritingModeOffset); } void setHasExplicitlySetWritingMode(bool value) { updateBoolean(value, hasExplicitlySetWritingModeOffset); } + bool hasExplicitlySetTextAlign() const { return getBoolean(hasExplicitlySetTextAlignOffset); } + void setHasExplicitlySetTextAlign(bool value) { updateBoolean(value, hasExplicitlySetTextAlignOffset); } + static ptrdiff_t flagsMemoryOffset() { return OBJECT_OFFSETOF(NonInheritedFlags, m_flags); } static uint64_t flagIsaffectedByActive() { return oneBitMask << affectedByActiveOffset; } static uint64_t flagIsaffectedByHover() { return oneBitMask << affectedByHoverOffset; } @@ -1856,11 +1862,13 @@ static const unsigned hasViewportUnitsOffset = pseudoBitsOffset + pseudoBitsBitCount; // Byte 7. + static const unsigned hasExplicitlySetTextAlignBitCount = 1; + static const unsigned hasExplicitlySetTextAlignOffset = hasViewportUnitsOffset + hasViewportUnitsBitCount; static const unsigned styleTypeBitCount = 6; - static const unsigned styleTypePadding = 2; + static const unsigned styleTypePadding = 1; static const unsigned styleTypeAndPaddingBitCount = styleTypeBitCount + styleTypePadding; static const uint64_t styleTypeMask = (oneBitMask << styleTypeAndPaddingBitCount) - 1; - static const unsigned styleTypeOffset = hasViewportUnitsBitCount + hasViewportUnitsOffset; + static const unsigned styleTypeOffset = hasExplicitlySetTextAlignOffset + hasExplicitlySetTextAlignBitCount; // Byte 8. static const unsigned isUniqueOffset = styleTypeOffset + styleTypeAndPaddingBitCount; diff -Nru webkit2gtk-2.16.1/Source/WebCore/storage/StorageArea.h webkit2gtk-2.16.2/Source/WebCore/storage/StorageArea.h --- webkit2gtk-2.16.1/Source/WebCore/storage/StorageArea.h 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/storage/StorageArea.h 2017-05-07 09:24:48.000000000 +0000 @@ -35,7 +35,8 @@ class SecurityOrigin; class StorageSyncManager; -enum StorageType { LocalStorage, SessionStorage }; +enum class StorageType; + struct SecurityOriginData; class StorageArea : public RefCounted { diff -Nru webkit2gtk-2.16.1/Source/WebCore/storage/Storage.cpp webkit2gtk-2.16.2/Source/WebCore/storage/Storage.cpp --- webkit2gtk-2.16.1/Source/WebCore/storage/Storage.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/storage/Storage.cpp 2017-05-07 09:25:28.000000000 +0000 @@ -33,6 +33,7 @@ #include "SchemeRegistry.h" #include "SecurityOrigin.h" #include "StorageArea.h" +#include "StorageType.h" #include namespace WebCore { @@ -62,9 +63,6 @@ if (!m_storageArea->canAccessStorage(m_frame)) return Exception { SECURITY_ERR }; - if (isDisabledByPrivateBrowsing()) - return 0; - return m_storageArea->length(); } @@ -73,9 +71,6 @@ if (!m_storageArea->canAccessStorage(m_frame)) return Exception { SECURITY_ERR }; - if (isDisabledByPrivateBrowsing()) - return String(); - return m_storageArea->key(index); } @@ -84,9 +79,6 @@ if (!m_storageArea->canAccessStorage(m_frame)) return Exception { SECURITY_ERR }; - if (isDisabledByPrivateBrowsing()) - return String(); - return m_storageArea->item(key); } @@ -95,9 +87,6 @@ if (!m_storageArea->canAccessStorage(m_frame)) return Exception { SECURITY_ERR }; - if (isDisabledByPrivateBrowsing()) - return Exception { QUOTA_EXCEEDED_ERR }; - bool quotaException = false; m_storageArea->setItem(m_frame, key, value, quotaException); if (quotaException) @@ -110,9 +99,6 @@ if (!m_storageArea->canAccessStorage(m_frame)) return Exception { SECURITY_ERR }; - if (isDisabledByPrivateBrowsing()) - return { }; - m_storageArea->removeItem(m_frame, key); return { }; } @@ -122,9 +108,6 @@ if (!m_storageArea->canAccessStorage(m_frame)) return Exception { SECURITY_ERR }; - if (isDisabledByPrivateBrowsing()) - return { }; - m_storageArea->clear(m_frame); return { }; } @@ -134,23 +117,7 @@ if (!m_storageArea->canAccessStorage(m_frame)) return Exception { SECURITY_ERR }; - if (isDisabledByPrivateBrowsing()) - return false; - return m_storageArea->contains(key); } -bool Storage::isDisabledByPrivateBrowsing() const -{ - if (!m_frame->page()->usesEphemeralSession()) - return false; - - if (m_storageArea->storageType() == LocalStorage) { - if (SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing(m_frame->document()->securityOrigin().protocol())) - return false; - } - - return true; -} - } // namespace WebCore diff -Nru webkit2gtk-2.16.1/Source/WebCore/storage/StorageEventDispatcher.cpp webkit2gtk-2.16.2/Source/WebCore/storage/StorageEventDispatcher.cpp --- webkit2gtk-2.16.1/Source/WebCore/storage/StorageEventDispatcher.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/storage/StorageEventDispatcher.cpp 2017-05-07 09:24:48.000000000 +0000 @@ -36,6 +36,7 @@ #include "SecurityOrigin.h" #include "SecurityOriginData.h" #include "StorageEvent.h" +#include "StorageType.h" namespace WebCore { @@ -77,7 +78,7 @@ void StorageEventDispatcher::dispatchSessionStorageEventsToFrames(Page& page, const Vector>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOriginData& securityOrigin) { - InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, SessionStorage, securityOrigin.securityOrigin().ptr()); + InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, StorageType::Session, securityOrigin.securityOrigin().ptr()); for (auto& frame : frames) { auto result = frame->document()->domWindow()->sessionStorage(); @@ -89,7 +90,7 @@ void StorageEventDispatcher::dispatchLocalStorageEventsToFrames(PageGroup& pageGroup, const Vector>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOriginData& securityOrigin) { for (auto& page : pageGroup.pages()) - InspectorInstrumentation::didDispatchDOMStorageEvent(*page, key, oldValue, newValue, LocalStorage, securityOrigin.securityOrigin().ptr()); + InspectorInstrumentation::didDispatchDOMStorageEvent(*page, key, oldValue, newValue, StorageType::Local, securityOrigin.securityOrigin().ptr()); for (auto& frame : frames) { auto result = frame->document()->domWindow()->localStorage(); diff -Nru webkit2gtk-2.16.1/Source/WebCore/storage/StorageMap.h webkit2gtk-2.16.2/Source/WebCore/storage/StorageMap.h --- webkit2gtk-2.16.1/Source/WebCore/storage/StorageMap.h 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/storage/StorageMap.h 2017-05-07 09:25:28.000000000 +0000 @@ -51,11 +51,12 @@ unsigned quota() const { return m_quotaSize; } + WEBCORE_EXPORT Ref copy(); + static const constexpr unsigned noQuota = UINT_MAX; private: explicit StorageMap(unsigned quota); - Ref copy(); void invalidateIterator(); void setIteratorToIndex(unsigned); diff -Nru webkit2gtk-2.16.1/Source/WebCore/storage/StorageNamespaceProvider.cpp webkit2gtk-2.16.2/Source/WebCore/storage/StorageNamespaceProvider.cpp --- webkit2gtk-2.16.1/Source/WebCore/storage/StorageNamespaceProvider.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/storage/StorageNamespaceProvider.cpp 2017-05-07 09:25:28.000000000 +0000 @@ -27,6 +27,7 @@ #include "StorageNamespaceProvider.h" #include "Document.h" +#include "Page.h" #include "SecurityOriginData.h" #include "StorageArea.h" #include "StorageNamespace.h" @@ -61,9 +62,23 @@ RefPtr StorageNamespaceProvider::localStorageArea(Document& document) { - auto& storageNamespace = document.securityOrigin().canAccessLocalStorage(&document.topOrigin()) ? localStorageNamespace() : transientLocalStorageNamespace(document.topOrigin()); + // This StorageNamespaceProvider was retrieved from the Document's Page, + // so the Document had better still actually have a Page. + ASSERT(document.page()); + + bool ephemeral = document.page()->usesEphemeralSession(); + bool transient = !document.securityOrigin().canAccessLocalStorage(&document.topOrigin()); + + RefPtr storageNamespace; + + if (transient) + storageNamespace = &transientLocalStorageNamespace(document.topOrigin()); + else if (ephemeral) + storageNamespace = document.page()->ephemeralLocalStorage(); + else + storageNamespace = &localStorageNamespace(); - return storageNamespace.storageArea(SecurityOriginData::fromSecurityOrigin(document.securityOrigin())); + return storageNamespace->storageArea(SecurityOriginData::fromSecurityOrigin(document.securityOrigin())); } StorageNamespace& StorageNamespaceProvider::localStorageNamespace() diff -Nru webkit2gtk-2.16.1/Source/WebCore/storage/StorageNamespaceProvider.h webkit2gtk-2.16.2/Source/WebCore/storage/StorageNamespaceProvider.h --- webkit2gtk-2.16.1/Source/WebCore/storage/StorageNamespaceProvider.h 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/storage/StorageNamespaceProvider.h 2017-05-07 09:25:28.000000000 +0000 @@ -45,6 +45,8 @@ WEBCORE_EXPORT virtual ~StorageNamespaceProvider(); virtual RefPtr createSessionStorageNamespace(Page&, unsigned quota) = 0; + virtual RefPtr createEphemeralLocalStorageNamespace(Page&, unsigned quota) = 0; + RefPtr localStorageArea(Document&); void addPage(Page&); diff -Nru webkit2gtk-2.16.1/Source/WebCore/storage/StorageType.h webkit2gtk-2.16.2/Source/WebCore/storage/StorageType.h --- webkit2gtk-2.16.1/Source/WebCore/storage/StorageType.h 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/storage/StorageType.h 2017-05-07 09:25:28.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2017 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. + */ + +#pragma once + +namespace WebCore { + +enum class StorageType { + Session, + Local, + EphemeralLocal, + TransientLocal, +}; + +inline bool isLocalStorage(StorageType storageType) +{ + return storageType == StorageType::Local || storageType == StorageType::TransientLocal || storageType == StorageType::EphemeralLocal; +} + +inline bool isPersistentLocalStorage(StorageType storageType) +{ + return storageType == StorageType::Local || storageType == StorageType::TransientLocal; +} + +} // namespace WebCore diff -Nru webkit2gtk-2.16.1/Source/WebCore/svg/SVGSVGElement.cpp webkit2gtk-2.16.2/Source/WebCore/svg/SVGSVGElement.cpp --- webkit2gtk-2.16.1/Source/WebCore/svg/SVGSVGElement.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/svg/SVGSVGElement.cpp 2017-05-08 08:25:45.000000000 +0000 @@ -1,7 +1,7 @@ /* * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis - * Copyright (C) 2007, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2007-2017 Apple Inc. All rights reserved. * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -24,6 +24,7 @@ #include "SVGSVGElement.h" #include "CSSHelper.h" +#include "DOMWrapperWorld.h" #include "ElementIterator.h" #include "EventNames.h" #include "FrameSelection.h" @@ -215,19 +216,19 @@ // For these events, the outermost element works like a element does, // setting certain event handlers directly on the window object. if (name == HTMLNames::onunloadAttr) { - document().setWindowAttributeEventListener(eventNames().unloadEvent, name, value); + document().setWindowAttributeEventListener(eventNames().unloadEvent, name, value, mainThreadNormalWorld()); return; } if (name == HTMLNames::onresizeAttr) { - document().setWindowAttributeEventListener(eventNames().resizeEvent, name, value); + document().setWindowAttributeEventListener(eventNames().resizeEvent, name, value, mainThreadNormalWorld()); return; } if (name == HTMLNames::onscrollAttr) { - document().setWindowAttributeEventListener(eventNames().scrollEvent, name, value); + document().setWindowAttributeEventListener(eventNames().scrollEvent, name, value, mainThreadNormalWorld()); return; } if (name == SVGNames::onzoomAttr) { - document().setWindowAttributeEventListener(eventNames().zoomEvent, name, value); + document().setWindowAttributeEventListener(eventNames().zoomEvent, name, value, mainThreadNormalWorld()); return; } } @@ -236,11 +237,11 @@ // setting certain event handlers directly on the window object. // FIXME: Why different from the events above that work only on the outermost element? if (name == HTMLNames::onabortAttr) { - document().setWindowAttributeEventListener(eventNames().abortEvent, name, value); + document().setWindowAttributeEventListener(eventNames().abortEvent, name, value, mainThreadNormalWorld()); return; } if (name == HTMLNames::onerrorAttr) { - document().setWindowAttributeEventListener(eventNames().errorEvent, name, value); + document().setWindowAttributeEventListener(eventNames().errorEvent, name, value, mainThreadNormalWorld()); return; } diff -Nru webkit2gtk-2.16.1/Source/WebCore/workers/WorkerMessagingProxy.cpp webkit2gtk-2.16.2/Source/WebCore/workers/WorkerMessagingProxy.cpp --- webkit2gtk-2.16.1/Source/WebCore/workers/WorkerMessagingProxy.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/workers/WorkerMessagingProxy.cpp 2017-05-08 08:57:36.000000000 +0000 @@ -58,6 +58,9 @@ { ASSERT((is(*m_scriptExecutionContext) && isMainThread()) || (is(*m_scriptExecutionContext) && currentThread() == downcast(*m_scriptExecutionContext).thread().threadID())); + + // Nobody outside this class ref counts this object. The original ref + // is balanced by the deref in workerGlobalScopeDestroyedInternal. } WorkerMessagingProxy::~WorkerMessagingProxy() @@ -162,8 +165,9 @@ void WorkerMessagingProxy::postMessageToPageInspector(const String& message) { - RunLoop::main().dispatch([this, message = message.isolatedCopy()] { - m_inspectorProxy->sendMessageFromWorkerToFrontend(message); + RunLoop::main().dispatch([this, protectedThis = makeRef(*this), message = message.isolatedCopy()] { + if (!m_mayBeDestroyed) + m_inspectorProxy->sendMessageFromWorkerToFrontend(message); }); } @@ -233,8 +237,9 @@ m_inspectorProxy->workerTerminated(); + // This balances the original ref in construction. if (m_mayBeDestroyed) - delete this; + deref(); } void WorkerMessagingProxy::terminateWorkerGlobalScope() diff -Nru webkit2gtk-2.16.1/Source/WebCore/workers/WorkerMessagingProxy.h webkit2gtk-2.16.2/Source/WebCore/workers/WorkerMessagingProxy.h --- webkit2gtk-2.16.1/Source/WebCore/workers/WorkerMessagingProxy.h 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/workers/WorkerMessagingProxy.h 2017-05-08 08:57:36.000000000 +0000 @@ -28,20 +28,20 @@ #include "WorkerGlobalScopeProxy.h" #include "WorkerLoaderProxy.h" #include "WorkerObjectProxy.h" +#include namespace WebCore { class DedicatedWorkerThread; class WorkerInspectorProxy; -class WorkerMessagingProxy final : public WorkerGlobalScopeProxy, public WorkerObjectProxy, public WorkerLoaderProxy { +class WorkerMessagingProxy final : public ThreadSafeRefCounted, public WorkerGlobalScopeProxy, public WorkerObjectProxy, public WorkerLoaderProxy { WTF_MAKE_FAST_ALLOCATED; public: explicit WorkerMessagingProxy(Worker&); - -private: virtual ~WorkerMessagingProxy(); +private: // Implementations of WorkerGlobalScopeProxy. // (Only use these functions in the worker object thread.) void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags) final; diff -Nru webkit2gtk-2.16.1/Source/WebCore/xml/DOMParser.cpp webkit2gtk-2.16.2/Source/WebCore/xml/DOMParser.cpp --- webkit2gtk-2.16.1/Source/WebCore/xml/DOMParser.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/xml/DOMParser.cpp 2017-05-08 12:55:17.000000000 +0000 @@ -21,6 +21,7 @@ #include "DOMImplementation.h" #include "ExceptionCode.h" +#include "SecurityOriginPolicy.h" namespace WebCore { @@ -42,6 +43,10 @@ if (m_contextDocument) document->setContextDocument(*m_contextDocument.get()); document->setContent(string); + if (m_contextDocument) { + document->setURL(m_contextDocument->url()); + document->setSecurityOriginPolicy(m_contextDocument->securityOriginPolicy()); + } return WTFMove(document); } diff -Nru webkit2gtk-2.16.1/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp webkit2gtk-2.16.2/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp --- webkit2gtk-2.16.1/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2017-05-08 08:59:01.000000000 +0000 @@ -511,7 +511,7 @@ parser->_private = userData; // Substitute entities. - xmlCtxtUseOptions(parser, XML_PARSE_NOENT); + xmlCtxtUseOptions(parser, XML_PARSE_NOENT | XML_PARSE_HUGE); switchToUTF16(parser); @@ -540,7 +540,7 @@ // Substitute entities. // FIXME: Why is XML_PARSE_NODICT needed? This is different from what createStringParser does. - xmlCtxtUseOptions(parser, XML_PARSE_NODICT | XML_PARSE_NOENT); + xmlCtxtUseOptions(parser, XML_PARSE_NODICT | XML_PARSE_NOENT | XML_PARSE_HUGE); // Internal initialization parser->sax2 = 1; diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/BreakpointActionAdd.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/BreakpointActionAdd.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/BreakpointActionAdd.svg 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/BreakpointActionAdd.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ - - - - - diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/BreakpointActionRemove.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/BreakpointActionRemove.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/BreakpointActionRemove.svg 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/BreakpointActionRemove.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ - - - - - Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Colors@2x.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Colors@2x.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/ColorsLarge@2x.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/ColorsLarge@2x.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/ColorsLarge.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/ColorsLarge.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Colors.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Colors.png differ diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/FontVariantSmallCaps.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/FontVariantSmallCaps.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/FontVariantSmallCaps.svg 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/FontVariantSmallCaps.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - - - - - - Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Frames@2x.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Frames@2x.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Frames.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Frames.png differ diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/HeapAllocationsInstrument.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/HeapAllocationsInstrument.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/HeapAllocationsInstrument.svg 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/HeapAllocationsInstrument.svg 2017-05-08 11:51:29.000000000 +0000 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/LayoutInstrument.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/LayoutInstrument.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/LayoutInstrument.svg 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/LayoutInstrument.svg 2017-05-08 11:51:29.000000000 +0000 @@ -0,0 +1,10 @@ + + + + + + + + + + diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/MemoryInstrument.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/MemoryInstrument.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/MemoryInstrument.svg 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/MemoryInstrument.svg 2017-05-08 11:51:29.000000000 +0000 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/NavigationItemCurleyBraces.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/NavigationItemCurleyBraces.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/NavigationItemCurleyBraces.svg 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/NavigationItemCurleyBraces.svg 2017-05-08 11:49:43.000000000 +0000 @@ -1,6 +1,6 @@ - - + + diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/NavigationItemTypes.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/NavigationItemTypes.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/NavigationItemTypes.svg 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/NavigationItemTypes.svg 2017-05-08 11:49:09.000000000 +0000 @@ -1,6 +1,6 @@ - - + + Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Network@2x.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Network@2x.png differ diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/NetworkInstrument.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/NetworkInstrument.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/NetworkInstrument.svg 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/NetworkInstrument.svg 2017-05-08 11:51:29.000000000 +0000 @@ -0,0 +1,6 @@ + + + + + + Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/NetworkLarge@2x.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/NetworkLarge@2x.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/NetworkLarge.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/NetworkLarge.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Network.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Network.png differ diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/RenderingFramesInstrument.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/RenderingFramesInstrument.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/RenderingFramesInstrument.svg 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/RenderingFramesInstrument.svg 2017-05-08 11:51:29.000000000 +0000 @@ -0,0 +1,7 @@ + + + + + + + Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Script@2x.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Script@2x.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/ScriptLarge@2x.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/ScriptLarge@2x.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/ScriptLarge.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/ScriptLarge.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Script.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Script.png differ diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/ScriptsInstrument.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/ScriptsInstrument.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/ScriptsInstrument.svg 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/ScriptsInstrument.svg 2017-05-08 11:51:29.000000000 +0000 @@ -0,0 +1,9 @@ + + + + + + + + + Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Stopwatch@2x.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Stopwatch@2x.png differ Binary files /tmp/tmpvQ_4OX/OZ9TMoblAX/webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Stopwatch.png and /tmp/tmpvQ_4OX/T7kyix0iWG/webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Stopwatch.png differ diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Stopwatch.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Stopwatch.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/Stopwatch.svg 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/Stopwatch.svg 2017-05-08 11:55:48.000000000 +0000 @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/UpDownArrows.svg webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/UpDownArrows.svg --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Images/gtk/UpDownArrows.svg 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Images/gtk/UpDownArrows.svg 2017-05-08 11:49:09.000000000 +0000 @@ -1,6 +1,6 @@ - - + + diff -Nru webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css --- webkit2gtk-2.16.1/Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css 2017-05-08 11:55:48.000000000 +0000 @@ -47,52 +47,10 @@ content: url(../Images/RenderingFramesInstrument.svg); } -/* FIXME: [GTK] Web Inspector: Add new GTK+ icons for instrument icons */ -body:not(.mac-platform, .windows-platform) .network-icon .icon { - content: image-set(url(../Images/Network.png) 1x, url(../Images/Network@2x.png) 2x); -} - -body:not(.mac-platform, .windows-platform) .network-icon.large .icon { - content: image-set(url(../Images/NetworkLarge.png) 1x, url(../Images/NetworkLarge@2x.png) 2x); -} - -body:not(.mac-platform, .windows-platform) .layout-icon .icon { - content: image-set(url(../Images/Colors.png) 1x, url(../Images/Colors@2x.png) 2x); -} - -body:not(.mac-platform, .windows-platform) .layout-icon.large .icon { - content: image-set(url(../Images/ColorsLarge.png) 1x, url(../Images/ColorsLarge@2x.png) 2x); -} - -body:not(.mac-platform, .windows-platform) .script-icon .icon { - content: image-set(url(../Images/Script.png) 1x, url(../Images/Script@2x.png) 2x); -} - -body:not(.mac-platform, .windows-platform) .script-icon.large .icon { - content: image-set(url(../Images/ScriptLarge.png) 1x, url(../Images/ScriptLarge@2x.png) 2x); -} - -body:not(.mac-platform, .windows-platform) .rendering-frame-icon .icon { - content: image-set(url(../Images/Frames.png) 1x, url(../Images/Frames@2x.png) 2x); -} - -body:not(.mac-platform, .windows-platform) .memory-icon .icon { - content: image-set(url(../Images/ScriptLarge.png) 1x, url(../Images/ScriptLarge@2x.png) 2x); -} - -body:not(.mac-platform, .windows-platform) .heap-allocations-icon .icon { - content: image-set(url(../Images/ScriptLarge.png) 1x, url(../Images/ScriptLarge@2x.png) 2x); -} - .stopwatch-icon .icon { content: url(../Images/Stopwatch.svg); } -/* FIXME: [GTK] Web Inspector: Add new GTK+ icon for timeline recording stopwatch */ -body:not(.mac-platform, .windows-platform) .stopwatch-icon .icon { - content: image-set(url(../Images/Stopwatch.png) 1x, url(../Images/Stopwatch@2x.png) 2x); -} - .time-icon .icon { content: url(../Images/Timeline.svg); width: 13px; diff -Nru webkit2gtk-2.16.1/Source/WebKit2/NetworkProcess/NetworkProcess.cpp webkit2gtk-2.16.2/Source/WebKit2/NetworkProcess/NetworkProcess.cpp --- webkit2gtk-2.16.1/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2017-04-03 07:10:40.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2017-05-08 10:31:38.000000000 +0000 @@ -511,7 +511,12 @@ downloadProxyConnection()->send(Messages::DownloadProxy::DidReceiveResponse(response), destinationID); downloadManager().willDecidePendingDownloadDestination(networkDataTask, WTFMove(completionHandler)); - String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(networkDataTask.suggestedFilename(), response.mimeType()); + + // As per https://html.spec.whatwg.org/#as-a-download (step 2), the filename from the Content-Disposition header + // should override the suggested filename from the download attribute. + String suggestedFilename = response.isAttachmentWithFilename() ? response.suggestedFilename() : networkDataTask.suggestedFilename(); + suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(suggestedFilename, response.mimeType()); + downloadProxyConnection()->send(Messages::DownloadProxy::DecideDestinationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), suggestedFilename), destinationID); } #endif diff -Nru webkit2gtk-2.16.1/Source/WebKit2/PluginProcess/unix/PluginControllerProxyUnix.cpp webkit2gtk-2.16.2/Source/WebKit2/PluginProcess/unix/PluginControllerProxyUnix.cpp --- webkit2gtk-2.16.1/Source/WebKit2/PluginProcess/unix/PluginControllerProxyUnix.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/PluginProcess/unix/PluginControllerProxyUnix.cpp 2017-05-06 08:29:12.000000000 +0000 @@ -26,7 +26,7 @@ #include "config.h" #include "PluginControllerProxy.h" -#if ENABLE(PLUGIN_PROCESS) +#if ENABLE(NETSCAPE_PLUGIN_API) #include @@ -51,4 +51,4 @@ } // namespace WebKit -#endif // ENABLE(PLUGIN_PROCESS) +#endif // ENABLE(NETSCAPE_PLUGIN_API) diff -Nru webkit2gtk-2.16.1/Source/WebKit2/Shared/API/c/WKString.cpp webkit2gtk-2.16.2/Source/WebKit2/Shared/API/c/WKString.cpp --- webkit2gtk-2.16.1/Source/WebKit2/Shared/API/c/WKString.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/Shared/API/c/WKString.cpp 2017-05-08 13:38:20.000000000 +0000 @@ -61,7 +61,7 @@ unsigned unsignedBufferLength = std::min(bufferLength, std::numeric_limits::max()); auto substring = toImpl(stringRef)->stringView().substring(0, unsignedBufferLength); - substring.getCharactersWithUpconvert(static_cast(buffer)); + substring.getCharactersWithUpconvert(reinterpret_cast(buffer)); return substring.length(); } diff -Nru webkit2gtk-2.16.1/Source/WebKit2/Shared/ChildProcess.cpp webkit2gtk-2.16.2/Source/WebKit2/Shared/ChildProcess.cpp --- webkit2gtk-2.16.1/Source/WebKit2/Shared/ChildProcess.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/Shared/ChildProcess.cpp 2017-05-04 07:35:09.000000000 +0000 @@ -197,8 +197,9 @@ { } -void ChildProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference) +void ChildProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) { + WTFLogAlways("Received invalid message: '%s::%s'", messageReceiverName.toString().data(), messageName.toString().data()); CRASH(); } #endif diff -Nru webkit2gtk-2.16.1/Source/WebKit2/Shared/WebEventConversion.cpp webkit2gtk-2.16.2/Source/WebKit2/Shared/WebEventConversion.cpp --- webkit2gtk-2.16.1/Source/WebKit2/Shared/WebEventConversion.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/Shared/WebEventConversion.cpp 2017-05-08 11:02:42.000000000 +0000 @@ -109,6 +109,15 @@ m_eventNumber = webEvent.eventNumber(); m_menuTypeForEvent = webEvent.menuTypeForEvent(); #endif + m_modifierFlags = 0; + if (webEvent.shiftKey()) + m_modifierFlags |= WebEvent::ShiftKey; + if (webEvent.controlKey()) + m_modifierFlags |= WebEvent::ControlKey; + if (webEvent.altKey()) + m_modifierFlags |= WebEvent::AltKey; + if (webEvent.metaKey()) + m_modifierFlags |= WebEvent::MetaKey; } }; diff -Nru webkit2gtk-2.16.1/Source/WebKit2/UIProcess/API/gtk/WebKitAutocleanups.h webkit2gtk-2.16.2/Source/WebKit2/UIProcess/API/gtk/WebKitAutocleanups.h --- webkit2gtk-2.16.1/Source/WebKit2/UIProcess/API/gtk/WebKitAutocleanups.h 2017-03-20 09:15:39.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/UIProcess/API/gtk/WebKitAutocleanups.h 2017-05-08 08:54:28.000000000 +0000 @@ -80,7 +80,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitSecurityOrigin, webkit_security_origin_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserScript, webkit_user_script_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserStyleSheet, webkit_user_style_sheet_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitWebsiteData, webkit_website_data_unref); +G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitWebsiteData, webkit_website_data_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitWebViewSessionState, webkit_web_view_session_state_unref) #endif // __GI_SCANNER__ diff -Nru webkit2gtk-2.16.1/Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteData.cpp webkit2gtk-2.16.2/Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteData.cpp --- webkit2gtk-2.16.1/Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteData.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteData.cpp 2017-05-06 08:29:12.000000000 +0000 @@ -73,7 +73,9 @@ WebsiteDataType::LocalStorage, WebsiteDataType::WebSQLDatabases, WebsiteDataType::IndexedDBDatabases, +#if ENABLE(NETSCAPE_PLUGIN_API) WebsiteDataType::PlugInData, +#endif WebsiteDataType::Cookies }; return record.types.contains(typesSupported); @@ -96,8 +98,10 @@ returnValue |= WEBKIT_WEBSITE_DATA_WEBSQL_DATABASES; if (types.contains(WebsiteDataType::IndexedDBDatabases)) returnValue |= WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES; +#if ENABLE(NETSCAPE_PLUGIN_API) if (types.contains(WebsiteDataType::PlugInData)) returnValue |= WEBKIT_WEBSITE_DATA_PLUGIN_DATA; +#endif if (types.contains(WebsiteDataType::Cookies)) returnValue |= WEBKIT_WEBSITE_DATA_COOKIES; return static_cast(returnValue); diff -Nru webkit2gtk-2.16.1/Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteDataManager.cpp webkit2gtk-2.16.2/Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteDataManager.cpp --- webkit2gtk-2.16.1/Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteDataManager.cpp 2017-02-28 09:45:57.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteDataManager.cpp 2017-05-06 08:29:14.000000000 +0000 @@ -641,8 +641,10 @@ returnValue |= WebsiteDataType::WebSQLDatabases; if (types & WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES) returnValue |= WebsiteDataType::IndexedDBDatabases; +#if ENABLE(NETSCAPE_PLUGIN_API) if (types & WEBKIT_WEBSITE_DATA_PLUGIN_DATA) returnValue |= WebsiteDataType::PlugInData; +#endif if (types & WEBKIT_WEBSITE_DATA_COOKIES) returnValue |= WebsiteDataType::Cookies; return returnValue; diff -Nru webkit2gtk-2.16.1/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp webkit2gtk-2.16.2/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp --- webkit2gtk-2.16.1/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2017-05-08 10:31:38.000000000 +0000 @@ -154,6 +154,13 @@ if (!m_processPool) return; +#if !USE(NETWORK_SESSION) + // As per https://html.spec.whatwg.org/#as-a-download (step 2), the filename from the Content-Disposition header + // should override the suggested filename from the download attribute. + if (!m_suggestedFilename.isNull() && response.isAttachmentWithFilename()) + m_suggestedFilename = String(); +#endif + m_processPool->downloadClient().didReceiveResponse(m_processPool.get(), this, response); } diff -Nru webkit2gtk-2.16.1/Source/WebKit2/UIProcess/gtk/HardwareAccelerationManager.cpp webkit2gtk-2.16.2/Source/WebKit2/UIProcess/gtk/HardwareAccelerationManager.cpp --- webkit2gtk-2.16.1/Source/WebKit2/UIProcess/gtk/HardwareAccelerationManager.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/UIProcess/gtk/HardwareAccelerationManager.cpp 2017-05-09 07:46:08.000000000 +0000 @@ -70,7 +70,7 @@ } #endif -#if PLATFORM(WAYLAND) +#if PLATFORM(WAYLAND) && USE(EGL) if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) { if (!WaylandCompositor::singleton().isRunning()) { m_canUseHardwareAcceleration = false; diff -Nru webkit2gtk-2.16.1/Source/WebKit2/UIProcess/WebProcessPool.cpp webkit2gtk-2.16.2/Source/WebKit2/UIProcess/WebProcessPool.cpp --- webkit2gtk-2.16.1/Source/WebKit2/UIProcess/WebProcessPool.cpp 2017-04-03 07:10:40.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/UIProcess/WebProcessPool.cpp 2017-05-08 09:04:16.000000000 +0000 @@ -1221,11 +1221,11 @@ static WebProcessProxy* webProcessProxyFromConnection(IPC::Connection& connection, const Vector>& processes) { for (auto& process : processes) { - if (process->connection() == &connection) + if (process->hasConnection(connection)) return process.get(); } - // FIXME: Can this ever return null? + ASSERT_NOT_REACHED(); return nullptr; } diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp webkit2gtk-2.16.2/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp 2017-02-20 16:20:17.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp 2017-05-06 08:05:47.000000000 +0000 @@ -165,7 +165,7 @@ #if ENABLE(MEDIA_CAPTURE) WebCore::JSMainThreadNullState state; WebCore::HTMLInputElement* item = WebKit::core(self); - return item->mediaCaptureType() != MediaCaptureTypeNone; + return item->mediaCaptureType() != WebCore::MediaCaptureTypeNone; #else UNUSED_PARAM(self); WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Capture") diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Plugins/PluginView.cpp webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Plugins/PluginView.cpp --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2017-02-28 09:08:26.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2017-05-08 14:14:02.000000000 +0000 @@ -775,7 +775,7 @@ viewGeometryDidChange(); } -void PluginView::paint(GraphicsContext& context, const IntRect& /*dirtyRect*/) +void PluginView::paint(GraphicsContext& context, const IntRect& /*dirtyRect*/, Widget::SecurityOriginPaintPolicy) { if (!m_plugin || !m_isInitialized || m_pluginElement->displayState() < HTMLPlugInElement::Restarting) return; diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Plugins/PluginView.h webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Plugins/PluginView.h --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Plugins/PluginView.h 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Plugins/PluginView.h 2017-05-08 14:14:02.000000000 +0000 @@ -170,7 +170,7 @@ // WebCore::Widget void setFrameRect(const WebCore::IntRect&) override; - void paint(WebCore::GraphicsContext&, const WebCore::IntRect&) override; + void paint(WebCore::GraphicsContext&, const WebCore::IntRect&, WebCore::Widget::SecurityOriginPaintPolicy) override; void invalidateRect(const WebCore::IntRect&) override; void setFocus(bool) override; void frameRectsChanged() override; diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp 2017-05-07 09:25:28.000000000 +0000 @@ -42,6 +42,7 @@ #include #include #include +#include using namespace WebCore; @@ -70,7 +71,8 @@ , m_hasPendingGetValues(false) { switch (m_storageType) { - case WebCore::LocalStorage: + case StorageType::Local: + case StorageType::TransientLocal: if (SecurityOrigin* topLevelOrigin = storageNamespace->topLevelOrigin()) WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateTransientLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(*topLevelOrigin), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0); else @@ -78,9 +80,13 @@ break; - case WebCore::SessionStorage: + case StorageType::Session: WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateSessionStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0); break; + + case StorageType::EphemeralLocal: + // The UI process is not involved for EphemeralLocal storages. + return; } WebProcess::singleton().addMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID, *this); @@ -88,8 +94,10 @@ StorageAreaMap::~StorageAreaMap() { - WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::DestroyStorageMap(m_storageMapID), 0); - WebProcess::singleton().removeMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID); + if (m_storageType != StorageType::EphemeralLocal) { + WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::DestroyStorageMap(m_storageMapID), 0); + WebProcess::singleton().removeMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID); + } m_storageNamespace->didDestroyStorageAreaMap(*this); } @@ -302,7 +310,7 @@ applyChange(key, newValue); } - if (storageType() == SessionStorage) + if (storageType() == StorageType::Session) dispatchSessionStorageEvent(sourceStorageAreaID, key, oldValue, newValue, urlString); else dispatchLocalStorageEvent(sourceStorageAreaID, key, oldValue, newValue, urlString); @@ -315,7 +323,7 @@ void StorageAreaMap::dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) { - ASSERT(storageType() == SessionStorage); + ASSERT(storageType() == StorageType::Session); // Namespace IDs for session storage namespaces are equivalent to web page IDs // so we can get the right page here. @@ -349,7 +357,7 @@ void StorageAreaMap::dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) { - ASSERT(storageType() == LocalStorage); + ASSERT(isLocalStorage(storageType())); Vector> frames; diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp 2017-05-07 09:25:28.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,9 +31,11 @@ #include "WebPage.h" #include "WebPageGroupProxy.h" #include "WebProcess.h" +#include #include #include #include +#include using namespace WebCore; @@ -41,17 +43,22 @@ RefPtr StorageNamespaceImpl::createSessionStorageNamespace(uint64_t identifier, unsigned quotaInBytes) { - return adoptRef(new StorageNamespaceImpl(SessionStorage, identifier, nullptr, quotaInBytes)); + return adoptRef(new StorageNamespaceImpl(StorageType::Session, identifier, nullptr, quotaInBytes)); +} + +RefPtr StorageNamespaceImpl::createEphemeralLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes) +{ + return adoptRef(new StorageNamespaceImpl(StorageType::EphemeralLocal, identifier, nullptr, quotaInBytes)); } RefPtr StorageNamespaceImpl::createLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes) { - return adoptRef(new StorageNamespaceImpl(LocalStorage, identifier, nullptr, quotaInBytes)); + return adoptRef(new StorageNamespaceImpl(StorageType::Local, identifier, nullptr, quotaInBytes)); } RefPtr StorageNamespaceImpl::createTransientLocalStorageNamespace(uint64_t identifier, WebCore::SecurityOrigin& topLevelOrigin, uint64_t quotaInBytes) { - return adoptRef(new StorageNamespaceImpl(LocalStorage, identifier, &topLevelOrigin, quotaInBytes)); + return adoptRef(new StorageNamespaceImpl(StorageType::TransientLocal, identifier, &topLevelOrigin, quotaInBytes)); } StorageNamespaceImpl::StorageNamespaceImpl(WebCore::StorageType storageType, uint64_t storageNamespaceID, WebCore::SecurityOrigin* topLevelOrigin, unsigned quotaInBytes) @@ -73,6 +80,9 @@ RefPtr StorageNamespaceImpl::storageArea(const SecurityOriginData& securityOrigin) { + if (m_storageType == StorageType::EphemeralLocal) + return ephemeralLocalStorageArea(securityOrigin); + RefPtr map; auto& slot = m_storageAreaMaps.add(securityOrigin, nullptr).iterator->value; @@ -85,11 +95,125 @@ return StorageAreaImpl::create(map.releaseNonNull()); } +class StorageNamespaceImpl::EphemeralStorageArea final : public StorageArea { +public: + static Ref create(const SecurityOriginData& origin, unsigned quotaInBytes) + { + return adoptRef(*new EphemeralStorageArea(origin, quotaInBytes)); + } + + Ref copy() + { + return adoptRef(*new EphemeralStorageArea(*this)); + } + +private: + EphemeralStorageArea(const SecurityOriginData& origin, unsigned quotaInBytes) + : m_securityOriginData(origin) + , m_storageMap(StorageMap::create(quotaInBytes)) + { + } + + EphemeralStorageArea(EphemeralStorageArea& other) + : m_securityOriginData(other.m_securityOriginData) + , m_storageMap(other.m_storageMap) + { + } + + // WebCore::StorageArea. + unsigned length() + { + return m_storageMap->length(); + } + + String key(unsigned index) + { + return m_storageMap->key(index); + } + + String item(const String& key) + { + return m_storageMap->getItem(key); + } + + void setItem(Frame*, const String& key, const String& value, bool& quotaException) + { + String oldValue; + if (auto newMap = m_storageMap->setItem(key, value, oldValue, quotaException)) + m_storageMap = WTFMove(newMap); + } + + void removeItem(Frame*, const String& key) + { + String oldValue; + if (auto newMap = m_storageMap->removeItem(key, oldValue)) + m_storageMap = WTFMove(newMap); + } + + void clear(Frame*) + { + if (!m_storageMap->length()) + return; + + m_storageMap = StorageMap::create(m_storageMap->quota()); + } + + bool contains(const String& key) + { + return m_storageMap->contains(key); + } + + bool canAccessStorage(Frame* frame) + { + return frame && frame->page(); + } + + StorageType storageType() const + { + return StorageType::EphemeralLocal; + } + + size_t memoryBytesUsedByCache() + { + return 0; + } + + void incrementAccessCount() { } + void decrementAccessCount() { } + void closeDatabaseIfIdle() { } + + SecurityOriginData securityOrigin() const + { + return m_securityOriginData; + } + + SecurityOriginData m_securityOriginData; + RefPtr m_storageMap; +}; + +RefPtr StorageNamespaceImpl::ephemeralLocalStorageArea(const SecurityOriginData& securityOrigin) +{ + auto& slot = m_ephemeralLocalStorageAreas.add(securityOrigin, nullptr).iterator->value; + if (!slot) + slot = StorageNamespaceImpl::EphemeralStorageArea::create(securityOrigin, m_quotaInBytes); + + return slot.get(); +} + RefPtr StorageNamespaceImpl::copy(Page* newPage) { ASSERT(m_storageNamespaceID); - return createSessionStorageNamespace(WebPage::fromCorePage(newPage)->pageID(), m_quotaInBytes); + if (m_storageType == StorageType::Session) + return createSessionStorageNamespace(WebPage::fromCorePage(newPage)->pageID(), m_quotaInBytes); + + ASSERT(m_storageType == StorageType::EphemeralLocal); + RefPtr newNamespace = adoptRef(new StorageNamespaceImpl(m_storageType, m_storageNamespaceID, m_topLevelOrigin.get(), m_quotaInBytes)); + + for (auto& iter : m_ephemeralLocalStorageAreas) + newNamespace->m_ephemeralLocalStorageAreas.set(iter.key, iter.value->copy()); + + return newNamespace; } } // namespace WebKit diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.h webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.h --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.h 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.h 2017-05-07 09:25:28.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,7 @@ class StorageNamespaceImpl : public WebCore::StorageNamespace { public: static RefPtr createSessionStorageNamespace(uint64_t identifier, unsigned quotaInBytes); + static RefPtr createEphemeralLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes); static RefPtr createLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes); static RefPtr createTransientLocalStorageNamespace(uint64_t identifier, WebCore::SecurityOrigin& topLevelOrigin, uint64_t quotaInBytes); @@ -57,6 +59,8 @@ RefPtr storageArea(const WebCore::SecurityOriginData&) override; RefPtr copy(WebCore::Page*) override; + RefPtr ephemeralLocalStorageArea(const WebCore::SecurityOriginData&); + const WebCore::StorageType m_storageType; const uint64_t m_storageNamespaceID; @@ -66,6 +70,9 @@ const unsigned m_quotaInBytes; HashMap m_storageAreaMaps; + + class EphemeralStorageArea; + HashMap> m_ephemeralLocalStorageAreas; }; } // namespace WebKit diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.cpp webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.cpp --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.cpp 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.cpp 2017-05-07 09:25:28.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (C) 2014-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -71,6 +71,11 @@ return StorageNamespaceImpl::createSessionStorageNamespace(WebPage::fromCorePage(&page)->pageID(), quota); } +RefPtr WebStorageNamespaceProvider::createEphemeralLocalStorageNamespace(Page& page, unsigned quota) +{ + return StorageNamespaceImpl::createEphemeralLocalStorageNamespace(WebPage::fromCorePage(&page)->pageID(), quota); +} + RefPtr WebStorageNamespaceProvider::createLocalStorageNamespace(unsigned quota) { return StorageNamespaceImpl::createLocalStorageNamespace(m_identifier, quota); diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.h webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.h --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.h 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.h 2017-05-07 09:25:28.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Apple Inc. All rights reserved. + * Copyright (C) 2014-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,6 +39,7 @@ explicit WebStorageNamespaceProvider(uint64_t identifier); RefPtr createSessionStorageNamespace(WebCore::Page&, unsigned quota) override; + RefPtr createEphemeralLocalStorageNamespace(WebCore::Page&, unsigned quota) override; RefPtr createLocalStorageNamespace(unsigned quota) override; RefPtr createTransientLocalStorageNamespace(WebCore::SecurityOrigin&, unsigned quota) override; diff -Nru webkit2gtk-2.16.1/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp webkit2gtk-2.16.2/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp --- webkit2gtk-2.16.1/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2017-02-20 16:20:18.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2017-05-08 10:41:13.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2016 Apple Inc. All rights reserved. + * Copyright (C) 2010-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -424,20 +424,24 @@ webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), provisionalLoader.navigationID(), url, unreachableURL, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } +static constexpr unsigned maxTitleLength = 1000; // Closest power of 10 above the W3C recommendation for Title length. + void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title) { WebPage* webPage = m_frame->page(); if (!webPage) return; + auto truncatedTitle = truncateFromEnd(title, maxTitleLength); + RefPtr userData; // Notify the bundle client. // FIXME: Use direction of title. - webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title.string, m_frame, userData); + webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, truncatedTitle.string, m_frame, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title.string, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); + webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), truncatedTitle.string, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebFrameLoaderClient::dispatchDidCommitLoad(std::optional hasInsecureContent) diff -Nru webkit2gtk-2.16.1/Source/WTF/wtf/CMakeLists.txt webkit2gtk-2.16.2/Source/WTF/wtf/CMakeLists.txt --- webkit2gtk-2.16.1/Source/WTF/wtf/CMakeLists.txt 2017-02-20 16:20:15.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WTF/wtf/CMakeLists.txt 2017-05-08 17:05:06.000000000 +0000 @@ -272,6 +272,12 @@ set(WTF_INCLUDE_DIRECTORIES "${BMALLOC_DIR}" "${WTF_DIR}" + "${CMAKE_BINARY_DIR}" + "${DERIVED_SOURCES_DIR}" + "${THIRDPARTY_DIR}" +) + +set(WTF_PRIVATE_INCLUDE_DIRECTORIES "${WTF_DIR}/wtf" "${WTF_DIR}/wtf/dtoa" "${WTF_DIR}/wtf/persistence" @@ -279,9 +285,6 @@ "${WTF_DIR}/wtf/text/icu" "${WTF_DIR}/wtf/threads" "${WTF_DIR}/wtf/unicode" - "${THIRDPARTY_DIR}" - "${CMAKE_BINARY_DIR}" - "${DERIVED_SOURCES_DIR}" ) set(WTF_LIBRARIES diff -Nru webkit2gtk-2.16.1/Source/WTF/wtf/NumberOfCores.cpp webkit2gtk-2.16.2/Source/WTF/wtf/NumberOfCores.cpp --- webkit2gtk-2.16.1/Source/WTF/wtf/NumberOfCores.cpp 2017-02-27 08:03:42.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WTF/wtf/NumberOfCores.cpp 2017-05-06 08:30:23.000000000 +0000 @@ -26,6 +26,8 @@ #include "config.h" #include "NumberOfCores.h" +#include + #if OS(DARWIN) #include // sys/types.h must come before sys/sysctl.h because the latter uses diff -Nru webkit2gtk-2.16.1/Source/WTF/wtf/Platform.h webkit2gtk-2.16.2/Source/WTF/wtf/Platform.h --- webkit2gtk-2.16.1/Source/WTF/wtf/Platform.h 2017-02-28 08:34:11.000000000 +0000 +++ webkit2gtk-2.16.2/Source/WTF/wtf/Platform.h 2017-05-06 10:26:28.000000000 +0000 @@ -673,7 +673,7 @@ #endif #if !defined(USE_JSVALUE64) && !defined(USE_JSVALUE32_64) -#if (CPU(X86_64) && (OS(UNIX) || OS(WINDOWS))) \ +#if (CPU(X86_64) && !defined(__ILP32__) && (OS(UNIX) || OS(WINDOWS))) \ || (CPU(IA64) && !CPU(IA64_32)) \ || CPU(ALPHA) \ || CPU(ARM64) \ diff -Nru webkit2gtk-2.16.1/Tools/DumpRenderTree/TestRunner.cpp webkit2gtk-2.16.2/Tools/DumpRenderTree/TestRunner.cpp --- webkit2gtk-2.16.1/Tools/DumpRenderTree/TestRunner.cpp 2017-02-20 16:20:19.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/DumpRenderTree/TestRunner.cpp 2017-05-08 14:04:32.000000000 +0000 @@ -347,7 +347,10 @@ return JSValueMakeUndefined(context); // FIXME (123058): Use a JSC API to get buffer contents once such is exposed. - JSC::JSArrayBufferView* jsBufferView = JSC::jsDynamicCast(toJS(context)->vm(), toJS(toJS(context), arguments[0])); + JSC::VM& vm = toJS(context)->vm(); + JSC::JSLockHolder lock(vm); + + JSC::JSArrayBufferView* jsBufferView = JSC::jsDynamicCast(vm, toJS(toJS(context), arguments[0])); ASSERT(jsBufferView); RefPtr bufferView = jsBufferView->unsharedImpl(); const char* buffer = static_cast(bufferView->baseAddress()); diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp webkit2gtk-2.16.2/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp 2017-02-20 16:20:19.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp 2017-05-08 11:02:42.000000000 +0000 @@ -148,7 +148,7 @@ doMouseButtonEvent(viewWidget, GDK_BUTTON_RELEASE, x, y, 3); } -void PlatformWebView::simulateMouseMove(unsigned x, unsigned y) +void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers) { GUniquePtr event(gdk_event_new(GDK_MOTION_NOTIFY)); event->motion.x = x; diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/PlatformWebView.h webkit2gtk-2.16.2/Tools/TestWebKitAPI/PlatformWebView.h --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/PlatformWebView.h 2017-02-20 16:20:19.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/PlatformWebView.h 2017-05-08 11:02:45.000000000 +0000 @@ -72,7 +72,7 @@ void simulateSpacebarKeyPress(); void simulateAltKeyPress(); void simulateRightClick(unsigned x, unsigned y); - void simulateMouseMove(unsigned x, unsigned y); + void simulateMouseMove(unsigned x, unsigned y, WKEventModifiers = 0); #if PLATFORM(MAC) void simulateButtonClick(WKEventMouseButton, unsigned x, unsigned y, WKEventModifiers); #endif diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp 2017-02-28 09:05:27.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp 2017-05-06 08:32:22.000000000 +0000 @@ -355,4 +355,37 @@ EXPECT_NEAR(glyphBuffer.advanceAt(3).height(), 256 - 64, 0.0001); } +TEST_F(ComplexTextControllerTest, TotalWidthWithJustification) +{ + FontCascadeDescription description; + description.setOneFamily("Times"); + description.setComputedSize(80); + FontCascade font(description); + font.update(); + + Vector advances = { FloatSize(1, 0), FloatSize(2, 0), FloatSize(4, 0), FloatSize(8, 0), FloatSize(16, 0) }; +#if USE_LAYOUT_SPECIFIC_ADVANCES + Vector origins = { FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint() }; +#else + Vector origins = { }; +#endif + + FloatSize initialAdvance = FloatSize(); + + UChar characters[] = { 0x644, ' ', 0x644, ' ', 0x644 }; + size_t charactersLength = WTF_ARRAY_LENGTH(characters); + TextRun textRun(StringView(characters, charactersLength), 0, 14, DefaultExpansion, RTL); + auto run = ComplexTextController::ComplexTextRun::create(advances, origins, { 5, 6, 7, 8, 9 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 5, false); + Vector> runs; + runs.append(WTFMove(run)); + ComplexTextController controller(font, textRun, runs); + + EXPECT_NEAR(controller.totalWidth(), 1 + 20 + 7 + 4 + 20 + 7 + 16, 0.0001); + GlyphBuffer glyphBuffer; + EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001); + controller.advance(5, &glyphBuffer); + EXPECT_EQ(glyphBuffer.size(), 5U); + EXPECT_NEAR(glyphBuffer.advanceAt(0).width() + glyphBuffer.advanceAt(1).width() + glyphBuffer.advanceAt(2).width() + glyphBuffer.advanceAt(3).width() + glyphBuffer.advanceAt(4).width(), controller.totalWidth(), 0.0001); +} + } diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2017-03-13 11:39:58.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2017-05-06 08:18:58.000000000 +0000 @@ -1298,6 +1298,7 @@ checkURL(makeString("gopher://host/path?", withUmlauts, "#fragment"), "asdf://example.com/?doesntmatter", iso88591, {"gopher", "", "", "host", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "fragment", "gopher://host/path?%DC%26%231072%3B%26%231105%3B#fragment"}); checkURL(makeString("asdf://host/path?", withUmlauts, "#fragment"), "http://example.com/?doesntmatter", iso88591, {"asdf", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "asdf://host/path?%C3%9C%D0%B0%D1%91#fragment"}); + checkURL("http://host/?query=foo'bar", UTF8Encoding(), {"http", "", "", "host", 0, "/", "query=foo%27bar", "", "http://host/?query=foo%27bar"}); // FIXME: Add more tests with other encodings and things like non-ascii characters, emoji and unmatched surrogate pairs. } diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp 2017-02-20 16:20:19.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp 2017-05-08 13:23:48.000000000 +0000 @@ -87,9 +87,12 @@ uaString = standardUserAgentForURL(URL(ParsedURLString, "http://www.googleblog.com/")); EXPECT_FALSE(uaString.contains("Firefox")); + // Nor should it affect accounts.google.com due to bug #171770. + uaString = standardUserAgentForURL(URL(ParsedURLString, "http://accounts.google.com/")); + EXPECT_FALSE(uaString.contains("Firefox")); + assertUserAgentForURLHasChromeBrowserQuirk("http://typekit.com/"); assertUserAgentForURLHasChromeBrowserQuirk("http://typekit.net/"); - assertUserAgentForURLHasChromeBrowserQuirk("http://www.youtube.com/"); assertUserAgentForURLHasChromeBrowserQuirk("http://www.slack.com/"); assertUserAgentForURLHasFirefoxBrowserQuirk("http://www.google.com/"); diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebKit2/EventModifiers.cpp webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebKit2/EventModifiers.cpp --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebKit2/EventModifiers.cpp 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebKit2/EventModifiers.cpp 2017-05-08 11:02:42.000000000 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2017 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" + +#if WK_HAVE_C_SPI + +#include "JavaScriptTest.h" +#include "PlatformUtilities.h" +#include "PlatformWebView.h" + +namespace TestWebKitAPI { + +static bool didFinishLoad { false }; +static bool mouseMoveCallbackFinished { false }; + +static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*) +{ + didFinishLoad = true; +} + +static void mouseDidMoveOverElement(WKPageRef, WKHitTestResultRef, WKEventModifiers modifiers, WKTypeRef, const void*) +{ + EXPECT_EQ(modifiers, kWKEventModifiersControlKey); + mouseMoveCallbackFinished = true; +} + +static void setClients(WKPageRef page) +{ + WKPageLoaderClientV0 loaderClient; + memset(&loaderClient, 0, sizeof(loaderClient)); + loaderClient.base.version = 0; + loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; + WKPageSetPageLoaderClient(page, &loaderClient.base); + + WKPageUIClientV1 uiClient; + memset(&uiClient, 0, sizeof(uiClient)); + uiClient.base.version = 1; + uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement; + WKPageSetPageUIClient(page, &uiClient.base); +} + +TEST(WebKit2, EventModifiers) +{ + WKRetainPtr context = adoptWK(WKContextCreate()); + + PlatformWebView webView(context.get()); + setClients(webView.page()); + + WKRetainPtr url(AdoptWK, Util::createURLForResource("simple", "html")); + WKPageLoadURL(webView.page(), url.get()); + Util::run(&didFinishLoad); + + webView.simulateMouseMove(10, 10, kWKEventModifiersControlKey); + Util::run(&mouseMoveCallbackFinished); +} + +} // namespace TestWebKitAPI + +#endif diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebKit2/LimitTitleSize.cpp webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebKit2/LimitTitleSize.cpp --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebKit2/LimitTitleSize.cpp 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebKit2/LimitTitleSize.cpp 2017-05-08 10:41:11.000000000 +0000 @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2017 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" + +#if WK_HAVE_C_SPI + +#include "PlatformUtilities.h" +#include "PlatformWebView.h" +#include "Test.h" +#include + +namespace TestWebKitAPI { + +static bool waitUntilLongTitleReceived = false; +static bool didFinishLoad = false; +static size_t maxTitleLength = 4096; + +static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + didFinishLoad = true; +} + +static void didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef, WKTypeRef, const void*) +{ + WKStringRef titleString = (WKStringRef)title; + + if (WKStringIsEqualToUTF8CString(titleString, "Original Short Title")) + return; + + EXPECT_LE(WKStringGetLength(titleString), maxTitleLength); + waitUntilLongTitleReceived = true; +} + +TEST(WebKit2, LimitTitleSize) +{ + WKRetainPtr context(AdoptWK, WKContextCreate()); + PlatformWebView webView(context.get()); + + WKPageLoaderClientV0 loaderClient; + memset(&loaderClient, 0, sizeof(loaderClient)); + + loaderClient.base.version = 0; + loaderClient.didReceiveTitleForFrame = didReceiveTitleForFrame; + loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; + + WKPageSetPageLoaderClient(webView.page(), &loaderClient.base); + + WKRetainPtr url(AdoptWK, Util::createURLForResource("set-long-title", "html")); + + WKPageLoadURL(webView.page(), url.get()); + Util::run(&waitUntilLongTitleReceived); +} + +} // namespace TestWebKitAPI + +#endif diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebKit2/set-long-title.html webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebKit2/set-long-title.html --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebKit2/set-long-title.html 1970-01-01 00:00:00.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebKit2/set-long-title.html 2017-05-08 10:41:11.000000000 +0000 @@ -0,0 +1,10 @@ + + +Original Short Title + + + + + \ No newline at end of file diff -Nru webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp --- webkit2gtk-2.16.1/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp 2017-04-03 13:04:48.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp 2017-05-08 16:41:06.000000000 +0000 @@ -298,11 +298,11 @@ return m_mouseTargetHitTestResult.get(); } - void simulateUserInterqaction() + void simulateUserInteraction() { - mouseMoveTo(1, 1); - keyStroke(GDK_KEY_Down); - keyStroke(GDK_KEY_Up); + runJavaScriptAndWaitUntilFinished("document.getElementById('testInput').focus()", nullptr); + keyStroke(GDK_KEY_a); + keyStroke(GDK_KEY_b); while (gtk_events_pending()) gtk_main_iteration(); } @@ -535,7 +535,7 @@ static const char* jsConfirmFormat = "do { confirmed = confirm('%s'); } while (!confirmed); alert('confirmed');"; static const char* jsPromptFormat = "alert(prompt('%s', 'default'));"; static const char* htmlOnBeforeUnloadFormat = - ""; + ""; test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_ALERT; GUniquePtr alertDialogMessage(g_strdup_printf(jsAlertFormat, kAlertDialogMessage)); @@ -568,7 +568,7 @@ // Reload should trigger onbeforeunload. #if 0 - test->simulateUserInterqaction(); + test->simulateUserInteraction(); // FIXME: reloading HTML data doesn't emit finished load event. // See https://bugs.webkit.org/show_bug.cgi?id=139089. test->m_scriptDialogConfirmed = false; @@ -578,7 +578,7 @@ #endif // Navigation should trigger onbeforeunload. - test->simulateUserInterqaction(); + test->simulateUserInteraction(); test->m_scriptDialogConfirmed = false; test->loadHtml("", nullptr); test->waitUntilLoadFinished(); @@ -588,7 +588,7 @@ test->m_scriptDialogConfirmed = false; test->loadHtml(beforeUnloadDialogHTML.get(), nullptr); test->waitUntilLoadFinished(); - test->simulateUserInterqaction(); + test->simulateUserInteraction(); test->tryCloseAndWaitUntilClosed(); g_assert(test->m_scriptDialogConfirmed); diff -Nru webkit2gtk-2.16.1/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp webkit2gtk-2.16.2/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp --- webkit2gtk-2.16.1/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp 2017-02-20 16:20:19.000000000 +0000 +++ webkit2gtk-2.16.2/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp 2017-05-08 14:03:23.000000000 +0000 @@ -48,7 +48,7 @@ g_source_set_ready_time(static_cast(userData), -1); fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n"); RunLoop::main().stop(); - return G_SOURCE_CONTINUE; + return G_SOURCE_REMOVE; }, source.get(), nullptr); g_source_attach(source.get(), nullptr); }