mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Set width/height of ImageBitmap when deserializing or receiving
This commit is contained in:
parent
3ca4ff6037
commit
498e59f71d
|
|
@ -84,7 +84,7 @@ WebIDL::ExceptionOr<void> ImageBitmap::serialization_steps(HTML::TransferDataEnc
|
|||
WebIDL::ExceptionOr<void> ImageBitmap::deserialization_steps(HTML::TransferDataDecoder& serialized, HTML::DeserializationMemory&)
|
||||
{
|
||||
// 1. Set value's bitmap data to serialized.[[BitmapData]].
|
||||
m_bitmap = TRY(deserialize_bitmap(this->realm(), serialized));
|
||||
set_bitmap(TRY(deserialize_bitmap(this->realm(), serialized)));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ WebIDL::ExceptionOr<void> ImageBitmap::transfer_steps(HTML::TransferDataEncoder&
|
|||
WebIDL::ExceptionOr<void> ImageBitmap::transfer_receiving_steps(HTML::TransferDataDecoder& data_holder)
|
||||
{
|
||||
// 1. Set value's bitmap data to dataHolder.[[BitmapData]].
|
||||
m_bitmap = TRY(deserialize_bitmap(this->realm(), data_holder));
|
||||
set_bitmap(TRY(deserialize_bitmap(this->realm(), data_holder)));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
before cloning:
|
||||
original imageBitmap width: 120
|
||||
original imageBitmap height: 120
|
||||
after cloning, before transferring:
|
||||
original imageBitmap width: 120
|
||||
original imageBitmap height: 120
|
||||
cloned imageBitmap width: 120
|
||||
cloned imageBitmap height: 120
|
||||
after cloning, after transferring:
|
||||
original imageBitmap width: 0
|
||||
original imageBitmap height: 0
|
||||
cloned imageBitmap width: 120
|
||||
cloned imageBitmap height: 120
|
||||
transferred imageBitmap width: 120
|
||||
transferred imageBitmap height: 120
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest((done) => {
|
||||
const image = document.createElement("img");
|
||||
|
||||
image.onload = async () => {
|
||||
const printDimensions = (name, imageBitmapToPrint) => {
|
||||
println(`${name} imageBitmap width: ${imageBitmapToPrint.width}`);
|
||||
println(`${name} imageBitmap height: ${imageBitmapToPrint.height}`);
|
||||
};
|
||||
|
||||
const imageBitmap = await createImageBitmap(image);
|
||||
println("before cloning:");
|
||||
printDimensions("original", imageBitmap);
|
||||
|
||||
println("after cloning, before transferring:");
|
||||
const clonedImageBitmap = structuredClone(imageBitmap);
|
||||
printDimensions("original", imageBitmap);
|
||||
printDimensions("cloned", clonedImageBitmap);
|
||||
|
||||
println("after cloning, after transferring:");
|
||||
const transferredImageBitmap = structuredClone(imageBitmap, { transfer: [imageBitmap] });
|
||||
printDimensions("original", imageBitmap);
|
||||
printDimensions("cloned", clonedImageBitmap);
|
||||
printDimensions("transferred", transferredImageBitmap);
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
image.src = "../../../Assets/120.png";
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user