Diff
Modified: trunk/Source/WebKit2/ChangeLog (161473 => 161474)
--- trunk/Source/WebKit2/ChangeLog 2014-01-08 01:03:46 UTC (rev 161473)
+++ trunk/Source/WebKit2/ChangeLog 2014-01-08 01:03:48 UTC (rev 161474)
@@ -1,5 +1,29 @@
2014-01-07 Simon Fraser <simon.fra...@apple.com>
+ Make it possible for MessageReceivers to pass messages to their superclass, and use it for RemoteLayerTreeDrawingAreaProxy
+ https://bugs.webkit.org/show_bug.cgi?id=126558
+
+ Reviewed by Anders Carlsson.
+
+ In a message.in file it's now possible to say:
+
+ messages -> Subclass : Superclass { ... } and the generated code will
+ call Superclass::didReceiveMessage().
+
+ Use this to have RemoteLayerTreeDrawingAreaProxy pass messages up to
+ DrawingAreaProxy.
+
+ * Scripts/webkit2/messages.py:
+ (generate_message_handler):
+ * Scripts/webkit2/model.py:
+ (MessageReceiver.__init__):
+ * Scripts/webkit2/parser.py:
+ (parse):
+ * UIProcess/DrawingAreaProxy.h:
+ * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.messages.in:
+
+2014-01-07 Simon Fraser <simon.fra...@apple.com>
+
Add message-generation test for non-legacy message receiver
https://bugs.webkit.org/show_bug.cgi?id=126603
Added: trunk/Source/WebKit2/Scripts/webkit2/MessageReceiverSuperclass-expected.cpp (0 => 161474)
--- trunk/Source/WebKit2/Scripts/webkit2/MessageReceiverSuperclass-expected.cpp (rev 0)
+++ trunk/Source/WebKit2/Scripts/webkit2/MessageReceiverSuperclass-expected.cpp 2014-01-08 01:03:48 UTC (rev 161474)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "WebPage.h"
+
+#include "ArgumentCoders.h"
+#include "HandleMessage.h"
+#include "MessageDecoder.h"
+#include "WebPageMessages.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)
+{
+ if (decoder.messageName() == Messages::WebPage::LoadURL::name()) {
+ IPC::handleMessage<Messages::WebPage::LoadURL>(decoder, this, &WebPage::loadURL);
+ return;
+ }
+ WebPageBase::didReceiveMessage(connection, decoder);
+}
+
+} // namespace WebKit
Property changes on: trunk/Source/WebKit2/Scripts/webkit2/MessageReceiverSuperclass-expected.cpp
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
Added: trunk/Source/WebKit2/Scripts/webkit2/MessagesSuperclass-expected.h (0 => 161474)
--- trunk/Source/WebKit2/Scripts/webkit2/MessagesSuperclass-expected.h (rev 0)
+++ trunk/Source/WebKit2/Scripts/webkit2/MessagesSuperclass-expected.h 2014-01-08 01:03:48 UTC (rev 161474)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPageMessages_h
+#define WebPageMessages_h
+
+#include "Arguments.h"
+#include "MessageEncoder.h"
+#include "StringReference.h"
+
+namespace WTF {
+ class String;
+}
+
+namespace Messages {
+namespace WebPage {
+
+static inline IPC::StringReference messageReceiverName()
+{
+ return IPC::StringReference("WebPage");
+}
+
+class LoadURL {
+public:
+ typedef std::tuple<String> DecodeType;
+
+ static IPC::StringReference receiverName() { return messageReceiverName(); }
+ static IPC::StringReference name() { return IPC::StringReference("LoadURL"); }
+ static const bool isSync = false;
+
+ explicit LoadURL(const String& url)
+ : m_arguments(url)
+ {
+ }
+
+ const std::tuple<const String&> arguments() const
+ {
+ return m_arguments;
+ }
+
+private:
+ std::tuple<const String&> m_arguments;
+};
+
+} // namespace WebPage
+} // namespace Messages
+
+#endif // WebPageMessages_h
Property changes on: trunk/Source/WebKit2/Scripts/webkit2/MessagesSuperclass-expected.h
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
Modified: trunk/Source/WebKit2/Scripts/webkit2/messages.py (161473 => 161474)
--- trunk/Source/WebKit2/Scripts/webkit2/messages.py 2014-01-08 01:03:46 UTC (rev 161473)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages.py 2014-01-08 01:03:48 UTC (rev 161474)
@@ -595,9 +595,12 @@
result.append('{\n')
result += [async_message_statement(receiver, message) for message in async_messages]
- if not receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE):
- result.append(' UNUSED_PARAM(connection);\n')
- result.append(' ASSERT_NOT_REACHED();\n')
+ if (receiver.superclass):
+ result.append(' %s::didReceiveMessage(connection, decoder);\n' % (receiver.superclass))
+ else:
+ if not receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE):
+ result.append(' UNUSED_PARAM(connection);\n')
+ result.append(' ASSERT_NOT_REACHED();\n')
result.append('}\n')
if sync_messages:
Modified: trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py (161473 => 161474)
--- trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py 2014-01-08 01:03:46 UTC (rev 161473)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py 2014-01-08 01:03:48 UTC (rev 161474)
@@ -31,24 +31,35 @@
script_directory = os.path.dirname(os.path.realpath(__file__))
+with open(os.path.join(script_directory, 'test-messages.in')) as file:
+ _messages_file_contents = file.read()
+
with open(os.path.join(script_directory, 'test-legacy-messages.in')) as file:
_legacy_messages_file_contents = file.read()
-with open(os.path.join(script_directory, 'test-messages.in')) as file:
- _messages_file_contents = file.read()
+with open(os.path.join(script_directory, 'test-superclass-messages.in')) as file:
+ _superclass_messages_file_contents = file.read()
-with open(os.path.join(script_directory, 'LegacyMessages-expected.h')) as file:
- _expected_legacy_receiver_header = file.read()
with open(os.path.join(script_directory, 'Messages-expected.h')) as file:
_expected_receiver_header = file.read()
+with open(os.path.join(script_directory, 'LegacyMessages-expected.h')) as file:
+ _expected_legacy_receiver_header = file.read()
+
+with open(os.path.join(script_directory, 'MessagesSuperclass-expected.h')) as file:
+ _expected_superclass_receiver_header = file.read()
+
+
with open(os.path.join(script_directory, 'MessageReceiver-expected.cpp')) as file:
_expected_receiver_implementation = file.read()
with open(os.path.join(script_directory, 'LegacyMessageReceiver-expected.cpp')) as file:
_expected_legacy_receiver_implementation = file.read()
+with open(os.path.join(script_directory, 'MessageReceiverSuperclass-expected.cpp')) as file:
+ _expected_superclass_receiver_implementation = file.read()
+
_expected_results = {
'name': 'WebPage',
'conditions': ('(ENABLE(WEBKIT2) && (NESTED_MASTER_CONDITION || MASTER_OR && MASTER_AND))'),
@@ -223,11 +234,27 @@
),
}
+_expected_superclass_results = {
+ 'name': 'WebPage',
+ 'superclass' : 'WebPageBase',
+ 'conditions': None,
+ 'messages': (
+ {
+ 'name': 'LoadURL',
+ 'parameters': (
+ ('String', 'url'),
+ ),
+ 'conditions': (None),
+ },
+ ),
+}
+
class MessagesTest(unittest.TestCase):
def setUp(self):
self.receiver = parser.parse(StringIO(_messages_file_contents))
self.legacy_receiver = parser.parse(StringIO(_legacy_messages_file_contents))
+ self.superclass_receiver = parser.parse(StringIO(_superclass_messages_file_contents))
class ParsingTest(MessagesTest):
@@ -266,8 +293,14 @@
for index, message in enumerate(self.legacy_receiver.messages):
self.check_message(message, _expected_results['messages'][index])
+ self.assertEquals(self.superclass_receiver.name, _expected_superclass_results['name'])
+ self.assertEquals(self.superclass_receiver.superclass, _expected_superclass_results['superclass'])
+ self.assertEquals(len(self.superclass_receiver.messages), len(_expected_superclass_results['messages']))
+ for index, message in enumerate(self.superclass_receiver.messages):
+ self.check_message(message, _expected_superclass_results['messages'][index])
+
class GeneratedFileContentsTest(unittest.TestCase):
def assertGeneratedFileContentsEqual(self, first, second):
first_list = first.split('\n')
@@ -281,20 +314,26 @@
class HeaderTest(GeneratedFileContentsTest):
def test_header(self):
+ file_contents = messages.generate_messages_header(StringIO(_messages_file_contents))
+ self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_header)
+
legacy_file_contents = messages.generate_messages_header(StringIO(_legacy_messages_file_contents))
self.assertGeneratedFileContentsEqual(legacy_file_contents, _expected_legacy_receiver_header)
- file_contents = messages.generate_messages_header(StringIO(_messages_file_contents))
- self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_header)
+ superclass_file_contents = messages.generate_messages_header(StringIO(_superclass_messages_file_contents))
+ self.assertGeneratedFileContentsEqual(superclass_file_contents, _expected_superclass_receiver_header)
class ReceiverImplementationTest(GeneratedFileContentsTest):
def test_receiver_implementation(self):
+ file_contents = messages.generate_message_handler(StringIO(_messages_file_contents))
+ self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_implementation)
+
legacy_file_contents = messages.generate_message_handler(StringIO(_legacy_messages_file_contents))
self.assertGeneratedFileContentsEqual(legacy_file_contents, _expected_legacy_receiver_implementation)
- file_contents = messages.generate_message_handler(StringIO(_messages_file_contents))
- self.assertGeneratedFileContentsEqual(file_contents, _expected_receiver_implementation)
+ superclass_file_contents = messages.generate_message_handler(StringIO(_superclass_messages_file_contents))
+ self.assertGeneratedFileContentsEqual(superclass_file_contents, _expected_superclass_receiver_implementation)
class UnsupportedPrecompilerDirectiveTest(unittest.TestCase):
Modified: trunk/Source/WebKit2/Scripts/webkit2/model.py (161473 => 161474)
--- trunk/Source/WebKit2/Scripts/webkit2/model.py 2014-01-08 01:03:46 UTC (rev 161473)
+++ trunk/Source/WebKit2/Scripts/webkit2/model.py 2014-01-08 01:03:48 UTC (rev 161474)
@@ -24,8 +24,9 @@
class MessageReceiver(object):
- def __init__(self, name, attributes, messages, condition):
+ def __init__(self, name, superclass, attributes, messages, condition):
self.name = name
+ self.superclass = superclass
self.attributes = frozenset(attributes or [])
self.messages = messages
self.condition = condition
Modified: trunk/Source/WebKit2/Scripts/webkit2/parser.py (161473 => 161474)
--- trunk/Source/WebKit2/Scripts/webkit2/parser.py 2014-01-08 01:03:46 UTC (rev 161473)
+++ trunk/Source/WebKit2/Scripts/webkit2/parser.py 2014-01-08 01:03:48 UTC (rev 161474)
@@ -48,11 +48,13 @@
messages = []
conditions = []
master_condition = None
+ superclass = []
for line in file:
- match = re.search(r'messages -> (?P<destination>[A-Za-z_0-9]+) \s*(?:(?P<attributes>.*?)\s+)?{', line)
+ match = re.search(r'messages -> (?P<destination>[A-Za-z_0-9]+) \s*(?::\s*(?P<superclass>.*?) \s*)?(?:(?P<attributes>.*?)\s+)?{', line)
if match:
receiver_attributes = parse_attributes_string(match.group('attributes'))
-
+ if match.group('superclass'):
+ superclass = match.group('superclass')
if conditions:
master_condition = conditions
conditions = []
@@ -89,7 +91,7 @@
reply_parameters = None
messages.append(model.Message(name, parameters, reply_parameters, attributes, combine_condition(conditions)))
- return model.MessageReceiver(destination, receiver_attributes, messages, combine_condition(master_condition))
+ return model.MessageReceiver(destination, superclass, receiver_attributes, messages, combine_condition(master_condition))
def parse_attributes_string(attributes_string):
Copied: trunk/Source/WebKit2/Scripts/webkit2/test-superclass-messages.in (from rev 161473, trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.messages.in) (0 => 161474)
--- trunk/Source/WebKit2/Scripts/webkit2/test-superclass-messages.in (rev 0)
+++ trunk/Source/WebKit2/Scripts/webkit2/test-superclass-messages.in 2014-01-08 01:03:48 UTC (rev 161474)
@@ -0,0 +1,25 @@
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+messages -> WebPage : WebPageBase {
+ LoadURL(String url)
+}
Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (161473 => 161474)
--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2014-01-08 01:03:46 UTC (rev 161473)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h 2014-01-08 01:03:48 UTC (rev 161474)
@@ -82,12 +82,12 @@
WebCore::IntSize m_layerPosition;
WebCore::IntSize m_scrollOffset;
+ // IPC::MessageReceiver
+ virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) OVERRIDE;
+
private:
virtual void sizeDidChange() = 0;
- // IPC::MessageReceiver
- virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) OVERRIDE;
-
// Message handlers.
// FIXME: These should be pure virtual.
virtual void update(uint64_t /* backingStoreStateID */, const UpdateInfo&) { }
Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.messages.in (161473 => 161474)
--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.messages.in 2014-01-08 01:03:46 UTC (rev 161473)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.messages.in 2014-01-08 01:03:48 UTC (rev 161474)
@@ -20,6 +20,6 @@
# 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.
-messages -> RemoteLayerTreeDrawingAreaProxy {
+messages -> RemoteLayerTreeDrawingAreaProxy : DrawingAreaProxy {
void CommitLayerTree(WebKit::RemoteLayerTreeTransaction layerTreeTransaction, WebKit::RemoteScrollingCoordinatorTransaction scrollingTreeTransaction)
}