Title: [206030] trunk/Source/WebKit2
Revision
206030
Author
ander...@apple.com
Date
2016-09-16 10:35:32 -0700 (Fri, 16 Sep 2016)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (206029 => 206030)


--- trunk/Source/WebKit2/ChangeLog	2016-09-16 17:08:09 UTC (rev 206029)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-16 17:35:32 UTC (rev 206030)
@@ -1,3 +1,49 @@
+2016-09-16  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  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r206000.

Modified: trunk/Source/WebKit2/Scripts/webkit/messages.py (206029 => 206030)


--- trunk/Source/WebKit2/Scripts/webkit/messages.py	2016-09-16 17:08:09 UTC (rev 206029)
+++ trunk/Source/WebKit2/Scripts/webkit/messages.py	2016-09-16 17:35:32 UTC (rev 206030)
@@ -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):
@@ -102,7 +105,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 Arguments;\n' % arguments_type(message))
@@ -113,7 +116,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::Encoder>);\n')
             result.append('        ~DelayedReply();\n')
@@ -143,20 +146,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)
 
@@ -372,6 +376,7 @@
         'struct WebKit::WebUserStyleSheetData': ['"WebUserContentControllerDataTypes.h"'],
         'struct WebKit::WebScriptMessageHandlerData': ['"WebUserContentControllerDataTypes.h"'],
         'std::chrono::system_clock::time_point': ['<chrono>'],
+        'WebKit::LayerHostingMode': ['"LayerTreeContext.h"'],
     }
 
     headers = []
@@ -475,7 +480,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: trunk/Source/WebKit2/Scripts/webkit/parser.py (206029 => 206030)


--- trunk/Source/WebKit2/Scripts/webkit/parser.py	2016-09-16 17:08:09 UTC (rev 206029)
+++ trunk/Source/WebKit2/Scripts/webkit/parser.py	2016-09-16 17:35:32 UTC (rev 206030)
@@ -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: trunk/Source/WebKit2/Shared/LayerTreeContext.h (206029 => 206030)


--- trunk/Source/WebKit2/Shared/LayerTreeContext.h	2016-09-16 17:08:09 UTC (rev 206029)
+++ trunk/Source/WebKit2/Shared/LayerTreeContext.h	2016-09-16 17:35:32 UTC (rev 206030)
@@ -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 Decoder;
@@ -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: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (206029 => 206030)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-09-16 17:08:09 UTC (rev 206029)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-09-16 17:35:32 UTC (rev 206030)
@@ -1503,7 +1503,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);
     }
 }
 
@@ -1620,7 +1620,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: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (206029 => 206030)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-09-16 17:08:09 UTC (rev 206029)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-09-16 17:35:32 UTC (rev 206030)
@@ -577,7 +577,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)
@@ -2608,9 +2608,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: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (206029 => 206030)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-09-16 17:08:09 UTC (rev 206029)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-09-16 17:35:32 UTC (rev 206030)
@@ -439,7 +439,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: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (206029 => 206030)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2016-09-16 17:08:09 UTC (rev 206029)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2016-09-16 17:35:32 UTC (rev 206030)
@@ -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