Title: [287506] trunk
Revision
287506
Author
[email protected]
Date
2022-01-01 16:09:19 -0800 (Sat, 01 Jan 2022)

Log Message

make SharedBuffer::copy() return a contiguous SharedBuffer
https://bugs.webkit.org/show_bug.cgi?id=234622
rdar://problem/86829527

Reviewed by Darin Adler.

Source/WebCore:

make SharedBuffer::copy() return a contiguous SharedBuffer

API tests added.

* platform/SharedBuffer.cpp:
(WebCore::FragmentedSharedBuffer::copy const):

Tools:

* TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287505 => 287506)


--- trunk/Source/WebCore/ChangeLog	2022-01-01 23:06:26 UTC (rev 287505)
+++ trunk/Source/WebCore/ChangeLog	2022-01-02 00:09:19 UTC (rev 287506)
@@ -1,3 +1,18 @@
+2022-01-01  Jean-Yves Avenard  <[email protected]>
+
+        make SharedBuffer::copy() return a contiguous SharedBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=234622
+        rdar://problem/86829527
+
+        Reviewed by Darin Adler.
+
+        make SharedBuffer::copy() return a contiguous SharedBuffer
+
+        API tests added.
+
+        * platform/SharedBuffer.cpp:
+        (WebCore::FragmentedSharedBuffer::copy const):
+
 2022-01-01  Wenson Hsieh  <[email protected]>
 
         Modal containers are incorrectly detected in navigation elements and fixed document elements

Modified: trunk/Source/WebCore/platform/SharedBuffer.cpp (287505 => 287506)


--- trunk/Source/WebCore/platform/SharedBuffer.cpp	2022-01-01 23:06:26 UTC (rev 287505)
+++ trunk/Source/WebCore/platform/SharedBuffer.cpp	2022-01-02 00:09:19 UTC (rev 287506)
@@ -231,6 +231,8 @@
 
 Ref<FragmentedSharedBuffer> FragmentedSharedBuffer::copy() const
 {
+    if (m_contiguous)
+        return m_segments.size() ? SharedBuffer::create(m_segments[0].segment.copyRef()) : SharedBuffer::create();
     Ref<FragmentedSharedBuffer> clone = adoptRef(*new FragmentedSharedBuffer);
     clone->m_size = m_size;
     clone->m_segments.reserveInitialCapacity(m_segments.size());

Modified: trunk/Tools/ChangeLog (287505 => 287506)


--- trunk/Tools/ChangeLog	2022-01-01 23:06:26 UTC (rev 287505)
+++ trunk/Tools/ChangeLog	2022-01-02 00:09:19 UTC (rev 287506)
@@ -1,3 +1,14 @@
+2022-01-01  Jean-Yves Avenard  <[email protected]>
+
+        make SharedBuffer::copy() return a contiguous SharedBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=234622
+        rdar://problem/86829527
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2022-01-01  Wenson Hsieh  <[email protected]>
 
         Modal containers are incorrectly detected in navigation elements and fixed document elements

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp (287505 => 287506)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp	2022-01-01 23:06:26 UTC (rev 287505)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp	2022-01-02 00:09:19 UTC (rev 287506)
@@ -315,6 +315,15 @@
     EXPECT_GT(original->begin()->segment->size(), 0u);
 }
 
+TEST_F(FragmentedSharedBufferTest, copyIsContiguous)
+{
+    EXPECT_TRUE(SharedBuffer::create()->copy()->isContiguous());
+    EXPECT_FALSE(FragmentedSharedBuffer::create()->copy()->isContiguous());
+    const char* const simpleText = "This is a simple test.";
+    EXPECT_TRUE(SharedBuffer::create(simpleText, strlen(simpleText))->copy()->isContiguous());
+    EXPECT_FALSE(FragmentedSharedBuffer::create(simpleText, strlen(simpleText))->copy()->isContiguous());
+}
+
 #if ENABLE(MHTML)
 // SharedBufferChunkReader unit-tests -------------------------------------
 template< typename T, size_t N >
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to