Title: [206051] branches/safari-602-branch/Source/WebKit2

Diff

Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (206050 => 206051)


--- branches/safari-602-branch/Source/WebKit2/ChangeLog	2016-09-16 21:42:58 UTC (rev 206050)
+++ branches/safari-602-branch/Source/WebKit2/ChangeLog	2016-09-16 21:43:02 UTC (rev 206051)
@@ -1,5 +1,55 @@
 2016-09-16  Babak Shafiei  <bshaf...@apple.com>
 
+        Merge r206000. rdar://problem/27991573
+
+    2016-09-15  Anders Carlsson  <ander...@apple.com>
+
+            Add support for enum class parameters in the message generator
+            https://bugs.webkit.org/show_bug.cgi?id=162036
+
+            Reviewed by Brady Eidson.
+
+            Also, convert the WebPage::SetLayerHostingMode to take an actual enum class.
+
+            * Scripts/webkit/messages.py:
+            (function_parameter_type):
+            Change this to take the parameter kind as well, and use the raw type for enums.
+
+            (arguments_type):
+            (message_to_struct_declaration):
+            Pass the kind to function_parameter_type.
+
+            (forward_declaration):
+            (forward_declarations_for_namespace):
+            Forward declare enums with "enum class".
+
+            (headers_for_type):
+            Add WebKit::LayerHostingMode as a special case.
+
+            (generate_message_handler):
+            Pass the kind to function_parameter_type.
+
+            * Scripts/webkit/parser.py:
+            (parse_parameters_string):
+            Parse 'enum' as well.
+
+            * Shared/LayerTreeContext.h:
+            Add enum traits.
+
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::viewDidEnterWindow):
+            (WebKit::WebPageProxy::layerHostingModeDidChange):
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::reinitializeWebPage):
+            (WebKit::WebPage::setLayerHostingMode):
+            * WebProcess/WebPage/WebPage.h:
+            Change unsigned to LayerHostingMode.
+
+            * WebProcess/WebPage/WebPage.messages.in:
+            Change unsigned to LayerHostingMode.
+
+2016-09-16  Babak Shafiei  <bshaf...@apple.com>
+
         Merge r204916. rdar://problem/27991573
 
     2016-08-23  Anders Carlsson  <ander...@apple.com>

Modified: branches/safari-602-branch/Source/WebKit2/Scripts/webkit/messages.py (206050 => 206051)


--- branches/safari-602-branch/Source/WebKit2/Scripts/webkit/messages.py	2016-09-16 21:42:58 UTC (rev 206050)
+++ branches/safari-602-branch/Source/WebKit2/Scripts/webkit/messages.py	2016-09-16 21:43:02 UTC (rev 206051)
@@ -66,7 +66,7 @@
     return '#if %s\n%s#endif\n' % (condition, string)
 
 
-def function_parameter_type(type):
+def function_parameter_type(type, kind):
     # Don't use references for built-in types.
     builtin_types = frozenset([
         'bool',
@@ -85,6 +85,9 @@
     if type in builtin_types:
         return type
 
+    if kind == 'enum':
+        return type
+
     return 'const %s&' % type
 
 
@@ -93,7 +96,7 @@
 
 
 def arguments_type(message):
-    return 'std::tuple<%s>' % ', '.join(function_parameter_type(parameter.type) for parameter in message.parameters)
+    return 'std::tuple<%s>' % ', '.join(function_parameter_type(parameter.type, parameter.kind) for parameter in message.parameters)
 
 
 def reply_type(message):
@@ -106,7 +109,7 @@
 
 def message_to_struct_declaration(message):
     result = []
-    function_parameters = [(function_parameter_type(x.type), x.name) for x in message.parameters]
+    function_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.parameters]
     result.append('class %s {\n' % message.name)
     result.append('public:\n')
     result.append('    typedef %s DecodeType;\n' % decode_type(message))
@@ -117,7 +120,7 @@
     result.append('\n')
     if message.reply_parameters != None:
         if message.has_attribute(DELAYED_ATTRIBUTE):
-            send_parameters = [(function_parameter_type(x.type), x.name) for x in message.reply_parameters]
+            send_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.reply_parameters]
             result.append('    struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {\n')
             result.append('        DelayedReply(PassRefPtr<IPC::Connection>, std::unique_ptr<IPC::MessageEncoder>);\n')
             result.append('        ~DelayedReply();\n')
@@ -147,20 +150,21 @@
     return surround_in_condition(''.join(result), message.condition)
 
 
-def struct_or_class(namespace, kind_and_type):
+def forward_declaration(namespace, kind_and_type):
     kind, type = kind_and_type
 
     qualified_name = '%s::%s' % (namespace, type)
     if kind == 'struct':
         return 'struct %s' % type
+    elif kind == 'enum':
+        return 'enum class %s' % type
     else:
         return 'class %s' % type
 
-
 def forward_declarations_for_namespace(namespace, kind_and_types):
     result = []
     result.append('namespace %s {\n' % namespace)
-    result += ['    %s;\n' % struct_or_class(namespace, x) for x in kind_and_types]
+    result += ['    %s;\n' % forward_declaration(namespace, x) for x in kind_and_types]
     result.append('}\n')
     return ''.join(result)
 
@@ -381,6 +385,7 @@
         'struct WebKit::WebUserStyleSheetData': ['"WebUserContentControllerDataTypes.h"'],
         'struct WebKit::WebScriptMessageHandlerData': ['"WebUserContentControllerDataTypes.h"'],
         'std::chrono::system_clock::time_point': ['<chrono>'],
+        'WebKit::LayerHostingMode': ['"LayerTreeContext.h"'],
     }
 
     headers = []
@@ -484,7 +489,7 @@
         result.append('namespace Messages {\n\nnamespace %s {\n\n' % receiver.name)
 
         for message in sync_delayed_messages:
-            send_parameters = [(function_parameter_type(x.type), x.name) for x in message.reply_parameters]
+            send_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.reply_parameters]
 
             if message.condition:
                 result.append('#if %s\n\n' % message.condition)

Modified: branches/safari-602-branch/Source/WebKit2/Scripts/webkit/parser.py (206050 => 206051)


--- branches/safari-602-branch/Source/WebKit2/Scripts/webkit/parser.py	2016-09-16 21:42:58 UTC (rev 206050)
+++ branches/safari-602-branch/Source/WebKit2/Scripts/webkit/parser.py	2016-09-16 21:43:02 UTC (rev 206051)
@@ -133,6 +133,9 @@
         if split[0].startswith('struct '):
             parameter_kind = 'struct'
             split[0] = split[0][7:]
+        elif split[0].startswith('enum '):
+            parameter_kind = 'enum'
+            split[0] = split[0][5:]
 
         parameter_type = split[0]
         parameter_name = split[1]

Modified: branches/safari-602-branch/Source/WebKit2/Shared/LayerTreeContext.h (206050 => 206051)


--- branches/safari-602-branch/Source/WebKit2/Shared/LayerTreeContext.h	2016-09-16 21:42:58 UTC (rev 206050)
+++ branches/safari-602-branch/Source/WebKit2/Shared/LayerTreeContext.h	2016-09-16 21:43:02 UTC (rev 206051)
@@ -23,10 +23,10 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef LayerTreeContext_h
-#define LayerTreeContext_h
+#pragma once
 
 #include <stdint.h>
+#include <wtf/EnumTraits.h>
 
 namespace IPC {
 class ArgumentDecoder;
@@ -62,6 +62,16 @@
     return !(a == b);
 }
 
+}
+
+namespace WTF {
+template<> struct EnumTraits<WebKit::LayerHostingMode> {
+    using values = EnumValues<
+        WebKit::LayerHostingMode,
+#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
+        WebKit::LayerHostingMode::OutOfProcess,
+#endif
+        WebKit::LayerHostingMode::InProcess
+    >;
 };
-
-#endif // LayerTreeContext_h
+}

Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (206050 => 206051)


--- branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-09-16 21:42:58 UTC (rev 206050)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-09-16 21:43:02 UTC (rev 206051)
@@ -1499,7 +1499,7 @@
     LayerHostingMode layerHostingMode = m_pageClient.viewLayerHostingMode();
     if (m_layerHostingMode != layerHostingMode) {
         m_layerHostingMode = layerHostingMode;
-        m_process->send(Messages::WebPage::SetLayerHostingMode(static_cast<unsigned>(layerHostingMode)), m_pageID);
+        m_process->send(Messages::WebPage::SetLayerHostingMode(layerHostingMode), m_pageID);
     }
 }
 
@@ -1616,7 +1616,7 @@
         return;
 
     m_layerHostingMode = layerHostingMode;
-    m_process->send(Messages::WebPage::SetLayerHostingMode(static_cast<unsigned>(layerHostingMode)), m_pageID);
+    m_process->send(Messages::WebPage::SetLayerHostingMode(layerHostingMode), m_pageID);
 }
 
 void WebPageProxy::waitForDidUpdateViewState()

Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (206050 => 206051)


--- branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-09-16 21:42:58 UTC (rev 206050)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-09-16 21:43:02 UTC (rev 206051)
@@ -571,7 +571,7 @@
     if (m_viewState != parameters.viewState)
         setViewState(parameters.viewState, false, Vector<uint64_t>());
     if (m_layerHostingMode != parameters.layerHostingMode)
-        setLayerHostingMode(static_cast<unsigned>(parameters.layerHostingMode));
+        setLayerHostingMode(parameters.layerHostingMode);
 }
 
 void WebPage::setPageActivityState(PageActivityState::Flags activityState)
@@ -2593,9 +2593,9 @@
         updateIsInWindow();
 }
 
-void WebPage::setLayerHostingMode(unsigned layerHostingMode)
+void WebPage::setLayerHostingMode(LayerHostingMode layerHostingMode)
 {
-    m_layerHostingMode = static_cast<LayerHostingMode>(layerHostingMode);
+    m_layerHostingMode = layerHostingMode;
 
     m_drawingArea->setLayerHostingMode(m_layerHostingMode);
 

Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (206050 => 206051)


--- branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-09-16 21:42:58 UTC (rev 206050)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-09-16 21:43:02 UTC (rev 206051)
@@ -436,7 +436,7 @@
     bool isVisibleOrOccluded() const { return m_viewState & WebCore::ViewState::IsVisibleOrOccluded; }
 
     LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
-    void setLayerHostingMode(unsigned);
+    void setLayerHostingMode(LayerHostingMode);
 
 #if PLATFORM(COCOA)
     void updatePluginsActiveAndFocusedState();

Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (206050 => 206051)


--- branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2016-09-16 21:42:58 UTC (rev 206050)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2016-09-16 21:43:02 UTC (rev 206051)
@@ -23,7 +23,7 @@
 messages -> WebPage LegacyReceiver {
     SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event, uint64_t callbackID)
     SetViewState(unsigned viewState, bool wantsDidUpdateViewState, Vector<uint64_t> callbackIDs)
-    SetLayerHostingMode(unsigned layerHostingMode)
+    SetLayerHostingMode(enum WebKit::LayerHostingMode layerHostingMode)
 
     SetSessionID(WebCore::SessionID sessionID)
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to