[MSVC] Add /experimental:newLambdaProcessor switch for better C++ conformance
https://bugs.webkit.org/show_bug.cgi?id=204443

Reviewed by Alex Christensen.

.:

MSVC has a bug of lambda capture of 'this'. It has caused
compilation errors repeatedly.

* Source/cmake/OptionsMSVC.cmake: Added /experimental:newLambdaProcessor switch.

Source/WebCore:

* dom/DocumentStorageAccess.cpp:
(WebCore::DocumentStorageAccess::requestStorageAccess): Reverted MSVC workaround of r252726.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@253020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/ChangeLog b/ChangeLog
index a8fdeb2..c20d4c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2019-12-02  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [MSVC] Add /experimental:newLambdaProcessor switch for better C++ conformance
+        https://bugs.webkit.org/show_bug.cgi?id=204443
+
+        Reviewed by Alex Christensen.
+
+        MSVC has a bug of lambda capture of 'this'. It has caused
+        compilation errors repeatedly.
+
+        * Source/cmake/OptionsMSVC.cmake: Added /experimental:newLambdaProcessor switch.
+
 2019-11-28  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Remove ENABLE_KEYBOARD_CODE_ATTRIBUTE and ENABLE_KEYBOARD_KEY_ATTRIBUTE macros
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 9485efc..0e40939 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2019-12-02  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [MSVC] Add /experimental:newLambdaProcessor switch for better C++ conformance
+        https://bugs.webkit.org/show_bug.cgi?id=204443
+
+        Reviewed by Alex Christensen.
+
+        * dom/DocumentStorageAccess.cpp:
+        (WebCore::DocumentStorageAccess::requestStorageAccess): Reverted MSVC workaround of r252726.
+
 2019-12-02  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Crash when animating an enum attribute for multiple instances of an SVG element
diff --git a/Source/WebCore/dom/DocumentStorageAccess.cpp b/Source/WebCore/dom/DocumentStorageAccess.cpp
index 0f52d60..be6944d 100644
--- a/Source/WebCore/dom/DocumentStorageAccess.cpp
+++ b/Source/WebCore/dom/DocumentStorageAccess.cpp
@@ -182,7 +182,7 @@
         bool shouldPreserveUserGesture = wasGranted == StorageAccessWasGranted::Yes || promptWasShown == StorageAccessPromptWasShown::No;
 
         if (shouldPreserveUserGesture) {
-            m_document.eventLoop().queueMicrotask([this, weakThis = makeWeakPtr(*weakThis)] {
+            m_document.eventLoop().queueMicrotask([this, weakThis = makeWeakPtr(*this)] {
                 if (weakThis)
                     enableTemporaryTimeUserGesture();
             });
@@ -197,7 +197,7 @@
         }
 
         if (shouldPreserveUserGesture) {
-            m_document.eventLoop().queueMicrotask([this, weakThis = makeWeakPtr(*weakThis)] {
+            m_document.eventLoop().queueMicrotask([this, weakThis = makeWeakPtr(*this)] {
                 if (weakThis)
                     consumeTemporaryTimeUserGesture();
             });
diff --git a/Source/cmake/OptionsMSVC.cmake b/Source/cmake/OptionsMSVC.cmake
index df2ffb4..5f8a9b2 100644
--- a/Source/cmake/OptionsMSVC.cmake
+++ b/Source/cmake/OptionsMSVC.cmake
@@ -29,6 +29,9 @@
 # Specify the source code encoding
 add_compile_options(/utf-8 /validate-charset)
 
+# Enable the new lambda processor for better C++ conformance with /std:c++17
+add_compile_options(/experimental:newLambdaProcessor)
+
 if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:NOREF /OPT:NOICF")
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:NOREF /OPT:NOICF")