[webkit-changes] [WebKit/WebKit] c16b84: [WK2] Apply method signature validation to all typ...

Žan Doberšek noreply at github.com
Tue Dec 13 23:56:33 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c16b84bd344f2188fa548498b29c2b42a8448345
      https://github.com/WebKit/WebKit/commit/c16b84bd344f2188fa548498b29c2b42a8448345
  Author: Žan Doberšek <zdobersek at igalia.com>
  Date:   2022-12-13 (Tue, 13 Dec 2022)

  Changed paths:
    M Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp
    M Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h
    M Source/WebKit/NetworkProcess/NetworkProcess.cpp
    M Source/WebKit/NetworkProcess/NetworkProcess.h
    M Source/WebKit/Platform/IPC/HandleMessage.h
    M Source/WebKit/Platform/IPC/JSIPCBinding.h
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithIfMessageMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithStreamBatchedMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithStreamBufferMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithStreamMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessages.h
    M Source/WebKit/Shared/IPCTester.cpp
    M Source/WebKit/Shared/IPCTester.h
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/UIProcess/WebPasteboardProxy.messages.in
    M Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
    M Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h
    M Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in
    M Source/WebKit/WebProcess/GPU/media/RemoteAudioHardwareListener.messages.in
    M Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.messages.in
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  [WK2] Apply method signature validation to all types of IPC message handling
https://bugs.webkit.org/show_bug.cgi?id=248975

Reviewed by Kimmo Kinnunen.

Validation of CompletionHandler argument types in IPC's message-handling
code is reworked and also applied to the messages' argument types.

The MethodSignatureValidation template takes a message-handling method's
function type and works through the argument types, deducing the
argument types specified by the method as well as any CompletionHandler
object that's used in messages that require a reply. When done, the
template instantiation will provide a std::tuple<> alias of those
argument types as well as a std::tuple<> alias of argument types of any
CompletionHandler object.

The different IPC::handleMessage() variants now use those instantiations
to perform compile-time asserts, ensuring the desired message-handling
method works with the same types as those specified by the IPC message.
In case of messages with a reply, the CompletionHandler's argument types
are similarly compared to the IPC message's reply argument types.

This enables some simplifications in the messages.py generator. Some IPC
messages and message-handling methods also need to be adjusted, either
adopting argument types that perfectly match the current code, or in
some cases using a sized integer type.

WebPage::loadRequestWaitingForProcessLaunch() was so far using the
NO_RETURN macro to apply the noreturn attribute through the C-style
__attribute__ specifier. This caused some trouble with certain compilers
since that attribute is then ingrained into the function type, which
was then causing trouble in the MethodSignatureValidation template
specializations. To avoid that but also apply the necessary no-return
semantics to the method, the C++11-style [[noreturn]] attribute is used.

* Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp:
(WebKit::RemoteDisplayListRecorder::drawSystemImage):
* Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h:
* Source/WebKit/NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::mergeStatisticForTesting):
(WebKit::NetworkProcess::insertExpiredStatisticForTesting):
* Source/WebKit/NetworkProcess/NetworkProcess.h:
* Source/WebKit/Platform/IPC/HandleMessage.h:
(IPC::MethodSignatureValidation<R):
(IPC::handleMessage):
(IPC::handleMessageWantsConnection):
(IPC::handleMessageSynchronous):
(IPC::handleMessageSynchronousWantsConnection):
(IPC::handleMessageAsync):
(IPC::handleMessageAsyncWantsConnection):
(IPC::CompletionHandlerValidation<CompletionHandler<void): Deleted.
* Source/WebKit/Platform/IPC/JSIPCBinding.h:
(IPC::jsValueForDecodedArguments):
* Source/WebKit/Scripts/webkit/messages.py:
(function_parameter_type):
(message_to_struct_declaration):
(arguments_type): Deleted.
(reply_arguments_type): Deleted.
* Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessages.h:
(Messages::TestWithCVPixelBuffer::SendCVPixelBuffer::arguments const):
(Messages::TestWithCVPixelBuffer::ReceiveCVPixelBuffer::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithIfMessageMessages.h:
(Messages::TestWithIfMessage::LoadURL::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessages.h:
(Messages::TestWithImageData::SendImageData::arguments const):
(Messages::TestWithImageData::ReceiveImageData::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessages.h:
(Messages::TestWithLegacyReceiver::LoadURL::arguments const):
(Messages::TestWithLegacyReceiver::LoadSomething::arguments const):
(Messages::TestWithLegacyReceiver::TouchEvent::arguments const):
(Messages::TestWithLegacyReceiver::AddEvent::arguments const):
(Messages::TestWithLegacyReceiver::LoadSomethingElse::arguments const):
(Messages::TestWithLegacyReceiver::DidReceivePolicyDecision::arguments const):
(Messages::TestWithLegacyReceiver::Close::arguments const):
(Messages::TestWithLegacyReceiver::PreferencesDidChange::arguments const):
(Messages::TestWithLegacyReceiver::SendDoubleAndFloat::arguments const):
(Messages::TestWithLegacyReceiver::SendInts::arguments const):
(Messages::TestWithLegacyReceiver::CreatePlugin::arguments const):
(Messages::TestWithLegacyReceiver::RunJavaScriptAlert::arguments const):
(Messages::TestWithLegacyReceiver::GetPlugins::arguments const):
(Messages::TestWithLegacyReceiver::GetPluginProcessConnection::arguments const):
(Messages::TestWithLegacyReceiver::TestMultipleAttributes::arguments const):
(Messages::TestWithLegacyReceiver::TestParameterAttributes::arguments const):
(Messages::TestWithLegacyReceiver::TemplateTest::arguments const):
(Messages::TestWithLegacyReceiver::SetVideoLayerID::arguments const):
(Messages::TestWithLegacyReceiver::DidCreateWebProcessConnection::arguments const):
(Messages::TestWithLegacyReceiver::InterpretKeyEvent::arguments const):
(Messages::TestWithLegacyReceiver::DeprecatedOperation::arguments const):
(Messages::TestWithLegacyReceiver::ExperimentalOperation::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessages.h:
(Messages::TestWithSemaphore::SendSemaphore::arguments const):
(Messages::TestWithSemaphore::ReceiveSemaphore::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithStreamBatchedMessages.h:
(Messages::TestWithStreamBatched::SendString::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithStreamBufferMessages.h:
(Messages::TestWithStreamBuffer::SendStreamBuffer::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithStreamMessages.h:
(Messages::TestWithStream::SendString::arguments const):
(Messages::TestWithStream::SendStringSync::arguments const):
(Messages::TestWithStream::SendMachSendRight::arguments const):
(Messages::TestWithStream::ReceiveMachSendRight::arguments const):
(Messages::TestWithStream::SendAndReceiveMachSendRight::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessages.h:
(Messages::TestWithSuperclass::LoadURL::arguments const):
(Messages::TestWithSuperclass::TestAsyncMessage::arguments const):
(Messages::TestWithSuperclass::TestAsyncMessageWithNoArguments::arguments const):
(Messages::TestWithSuperclass::TestAsyncMessageWithMultipleArguments::arguments const):
(Messages::TestWithSuperclass::TestAsyncMessageWithConnection::arguments const):
(Messages::TestWithSuperclass::TestSyncMessage::arguments const):
(Messages::TestWithSuperclass::TestSynchronousMessage::arguments const):
* Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessages.h:
(Messages::TestWithoutAttributes::LoadURL::arguments const):
(Messages::TestWithoutAttributes::LoadSomething::arguments const):
(Messages::TestWithoutAttributes::TouchEvent::arguments const):
(Messages::TestWithoutAttributes::AddEvent::arguments const):
(Messages::TestWithoutAttributes::LoadSomethingElse::arguments const):
(Messages::TestWithoutAttributes::DidReceivePolicyDecision::arguments const):
(Messages::TestWithoutAttributes::Close::arguments const):
(Messages::TestWithoutAttributes::PreferencesDidChange::arguments const):
(Messages::TestWithoutAttributes::SendDoubleAndFloat::arguments const):
(Messages::TestWithoutAttributes::SendInts::arguments const):
(Messages::TestWithoutAttributes::CreatePlugin::arguments const):
(Messages::TestWithoutAttributes::RunJavaScriptAlert::arguments const):
(Messages::TestWithoutAttributes::GetPlugins::arguments const):
(Messages::TestWithoutAttributes::GetPluginProcessConnection::arguments const):
(Messages::TestWithoutAttributes::TestMultipleAttributes::arguments const):
(Messages::TestWithoutAttributes::TestParameterAttributes::arguments const):
(Messages::TestWithoutAttributes::TemplateTest::arguments const):
(Messages::TestWithoutAttributes::SetVideoLayerID::arguments const):
(Messages::TestWithoutAttributes::DidCreateWebProcessConnection::arguments const):
(Messages::TestWithoutAttributes::InterpretKeyEvent::arguments const):
(Messages::TestWithoutAttributes::DeprecatedOperation::arguments const):
(Messages::TestWithoutAttributes::ExperimentalOperation::arguments const):
* Source/WebKit/Shared/IPCTester.cpp:
(WebKit::IPCTester::stopMessageTesting):
* Source/WebKit/Shared/IPCTester.h:
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/WebPasteboardProxy.messages.in:
* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::engineFailedToLoad):
* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in:
* Source/WebKit/WebProcess/GPU/media/RemoteAudioHardwareListener.messages.in:
* Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVFManager.messages.in:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::loadRequestWaitingForProcessLaunch):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

Canonical link: https://commits.webkit.org/257836@main




More information about the webkit-changes mailing list