Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure ImageData objects are shared when doing structured cloning #14605

Merged
merged 1 commit into from Jun 2, 2023

Conversation

cdumez
Copy link
Contributor

@cdumez cdumez commented Jun 1, 2023

dd1484f

Make sure ImageData objects are shared when doing structured cloning
https://bugs.webkit.org/show_bug.cgi?id=257626

Reviewed by Darin Adler.

Make sure ImageData objects are shared when doing structured cloning so that
if you send the same ImageData object is present multiple times in the
object being serialized, the object identity is preserved after deserializing.

* LayoutTests/imported/w3c/web-platform-tests/webmessaging/without-ports/028-expected.txt:
* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneSerializer::writeImageDataIndex):
(WebCore::CloneDeserializer::readImageDataIndex):
(WebCore::CloneDeserializer::readTerminal):

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

7bf6bc1

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2   πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv ⏳ πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@cdumez cdumez self-assigned this Jun 1, 2023
@cdumez cdumez added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label Jun 1, 2023
@cdumez cdumez marked this pull request as ready for review June 2, 2023 01:11
@@ -437,6 +437,7 @@ static const unsigned CurrentVersion = 13;
static const unsigned TerminatorTag = 0xFFFFFFFF;
static const unsigned StringPoolTag = 0xFFFFFFFE;
static const unsigned NonIndexPropertiesTag = 0xFFFFFFFD;
static const uint32_t ImageDataPoolTag = 0xFFFFFFFE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In new code we want to use constexpr.

@@ -2178,6 +2190,8 @@ class CloneSerializer : CloneBase {
#endif
typedef HashMap<RefPtr<UniquedStringImpl>, uint32_t, IdentifierRepHash> StringConstantPool;
StringConstantPool m_constantPool;
using ImageDataPool = HashMap<RefPtr<ImageData>, uint32_t>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref?

@@ -4072,6 +4091,18 @@ class CloneDeserializer : CloneBase {
uint32_t width;
if (!read(width))
return JSValue();
if (width == ImageDataPoolTag) {
unsigned index = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this would be better using std::optional instead of an out argument.

@cdumez cdumez added the merge-queue Applied to send a pull request to merge-queue label Jun 2, 2023
https://bugs.webkit.org/show_bug.cgi?id=257626

Reviewed by Darin Adler.

Make sure ImageData objects are shared when doing structured cloning so that
if you send the same ImageData object is present multiple times in the
object being serialized, the object identity is preserved after deserializing.

* LayoutTests/imported/w3c/web-platform-tests/webmessaging/without-ports/028-expected.txt:
* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneSerializer::writeImageDataIndex):
(WebCore::CloneDeserializer::readImageDataIndex):
(WebCore::CloneDeserializer::readTerminal):

Canonical link: https://commits.webkit.org/264824@main
@webkit-commit-queue
Copy link
Collaborator

Committed 264824@main (dd1484f): https://commits.webkit.org/264824@main

Reviewed commits have been landed. Closing PR #14605 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit dd1484f into WebKit:main Jun 2, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).
Projects
None yet
4 participants