[webkit-changes] [WebKit/WebKit] 8efbac: [WK2] Use Spans in remaining cases of moving memor...

Žan Doberšek noreply at github.com
Fri Jan 20 00:16:58 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8efbac52b8cdb3d666f71d2f602d350a08c8c0f4
      https://github.com/WebKit/WebKit/commit/8efbac52b8cdb3d666f71d2f602d350a08c8c0f4
  Author: Žan Doberšek <zdobersek at igalia.com>
  Date:   2023-01-20 (Fri, 20 Jan 2023)

  Changed paths:
    M Source/WebCore/Modules/highlight/AppHighlight.h
    M Source/WebCore/Modules/webauthn/AuthenticatorResponseData.h
    M Source/WebCore/bindings/js/BufferSource.h
    M Source/WebCore/bindings/js/SerializedScriptValue.h
    M Source/WebCore/platform/graphics/ByteArrayPixelBuffer.cpp
    M Source/WebCore/platform/graphics/ByteArrayPixelBuffer.h
    M Source/WebCore/platform/graphics/Model.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.cpp

  Log Message:
  -----------
  [WK2] Use Spans in remaining cases of moving memory spans through IPC
https://bugs.webkit.org/show_bug.cgi?id=250761

Reviewed by Kimmo Kinnunen.

Adopt Spans or encodeSpan()-and-decodeSpan() pairings on the remaining uses
of copying memory spans across IPC channels. Spans are mostly adopted to replace
the combination of the length value and the fixed-length data. encodeSpan() and
decodeSpan() are used where only fixed-length data is operated-with.

Especially in decoding this helps reduce the necessary logic, since all the
overflow and buffer size validation is packed inside Decoder::decodeSpan().

An exception to this is ByteArrayPixelBuffer, which now encodes a complete Span
object. Upon decoding, the Span size is validated to match the buffer size
that's computed from the buffer's format and width-and-height size.

Additionally, in AppHighlight and Model classes, direct encoding and decoding
of memory spans is replaced by simply encoding and decoding the SharedBuffer and
FragmentedSharedBuffer objects.

Finally, FragmentedSharedBuffer encoding and decoding now passes the buffer size
as a size_t value, avoiding widening and narrowing the value through uint64_t.

* Source/WebCore/Modules/highlight/AppHighlight.h:
(WebCore::AppHighlight::encode const):
(WebCore::AppHighlight::decode):
* Source/WebCore/Modules/webauthn/AuthenticatorResponseData.h:
(WebCore::encodeArrayBuffer):
(WebCore::decodeArrayBuffer):
* Source/WebCore/bindings/js/BufferSource.h:
(WebCore::BufferSource::encode const):
(WebCore::BufferSource::decode):
* Source/WebCore/bindings/js/SerializedScriptValue.h:
(WebCore::SerializedScriptValue::encode const):
(WebCore::SerializedScriptValue::decode):
* Source/WebCore/platform/graphics/ByteArrayPixelBuffer.cpp:
* Source/WebCore/platform/graphics/ByteArrayPixelBuffer.h:
(WebCore::ByteArrayPixelBuffer::encode const):
(WebCore::ByteArrayPixelBuffer::decode):
* Source/WebCore/platform/graphics/Model.h:
(WebCore::Model::encode const):
(WebCore::Model::decode):
* Source/WebKit/Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<WebCore::FragmentedSharedBuffer>::encode):
(IPC::ArgumentCoder<WebCore::FragmentedSharedBuffer>::decode):

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




More information about the webkit-changes mailing list