mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-24 03:02:23 +00:00
LibWeb: Respect subarrays in TextEncoder::encode_into
This is the method that Figma uses to write strings into Wasm memory, using subarrays to select a particular Wasm memory address to write to.
This commit is contained in:
parent
513231216a
commit
3ab93667f5
Notes:
github-actions[bot]
2025-01-21 20:38:39 +00:00
Author: https://github.com/Lubrsi
Commit: 3ab93667f5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3239
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/kalenikaliaksandr
3 changed files with 10 additions and 10 deletions
|
@ -53,7 +53,7 @@ GC::Ref<JS::Uint8Array> TextEncoder::encode(String const& input) const
|
|||
// https://encoding.spec.whatwg.org/#dom-textencoder-encodeinto
|
||||
TextEncoderEncodeIntoResult TextEncoder::encode_into(String const& source, GC::Root<WebIDL::BufferSource> const& destination) const
|
||||
{
|
||||
auto& data = destination->viewed_array_buffer()->buffer();
|
||||
auto data = destination->viewed_array_buffer()->buffer().bytes().slice(destination->byte_offset(), destination->byte_length());
|
||||
|
||||
// 1. Let read be 0.
|
||||
WebIDL::UnsignedLongLong read = 0;
|
||||
|
@ -79,7 +79,7 @@ TextEncoderEncodeIntoResult TextEncoder::encode_into(String const& source, GC::R
|
|||
|
||||
// 6.4. Otherwise:
|
||||
// 6.4.1. If destination’s byte length − written is greater than or equal to the number of bytes in result, then:
|
||||
if (data.size() - written >= result.size()) {
|
||||
if (destination->byte_length() - written >= result.size()) {
|
||||
// 6.4.1.1. If item is greater than U+FFFF, then increment read by 2.
|
||||
if (item > 0xffff) {
|
||||
read += 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue