LayoutTests:
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 May 2007 17:14:10 +0000 (17:14 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 May 2007 17:14:10 +0000 (17:14 +0000)
        Reviewed by Darin.

        - pixel test for http://bugs.webkit.org/show_bug.cgi?id=13767
          REGRESSION: Multipart image documents are garbled

        * http/tests/multipart/invalid-image-data-standalone-expected.checksum: Added.
        * http/tests/multipart/invalid-image-data-standalone-expected.png: Added.
        * http/tests/multipart/invalid-image-data-standalone-expected.txt: Added.
        * http/tests/multipart/invalid-image-data-standalone.html: Added.
        * http/tests/multipart/resources/green-100x100.png: Added.

WebCore:

        Reviewed by Darin.

        - fix http://bugs.webkit.org/show_bug.cgi?id=13767
          REGRESSION: Multipart image documents are garbled

        Test: http/tests/multipart/invalid-image-data-standalone.html

        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::isLoadingMultipartContent): Added.
        * loader/DocumentLoader.h:
        * loader/ImageDocument.cpp:
        (WebCore::ImageTokenizer::finish): If the image is multipart, make a copy
        of the current part instead of using the resource data, which is going to be
        overwritten by the next part.
        * loader/MainResourceLoader.h:
        (WebCore::MainResourceLoader::isLoadingMultipartContent): Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@21760 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.checksum [new file with mode: 0644]
LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.png [new file with mode: 0644]
LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/multipart/invalid-image-data-standalone.html [new file with mode: 0644]
LayoutTests/http/tests/multipart/resources/green-100x100.png [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/DocumentLoader.cpp
WebCore/loader/DocumentLoader.h
WebCore/loader/ImageDocument.cpp
WebCore/loader/MainResourceLoader.h

index 0f216c2..b2c6e7d 100644 (file)
@@ -1,3 +1,16 @@
+2007-05-25  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Darin.
+
+        - pixel test for http://bugs.webkit.org/show_bug.cgi?id=13767
+          REGRESSION: Multipart image documents are garbled
+
+        * http/tests/multipart/invalid-image-data-standalone-expected.checksum: Added.
+        * http/tests/multipart/invalid-image-data-standalone-expected.png: Added.
+        * http/tests/multipart/invalid-image-data-standalone-expected.txt: Added.
+        * http/tests/multipart/invalid-image-data-standalone.html: Added.
+        * http/tests/multipart/resources/green-100x100.png: Added.
+
 2007-05-24  Rob Buis  <buis@kde.org>
 
         Reviewed by Hyatt.
diff --git a/LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.checksum b/LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.checksum
new file mode 100644 (file)
index 0000000..9912dde
--- /dev/null
@@ -0,0 +1 @@
+737e54145915c8a0bb8881adbfa42134
\ No newline at end of file
diff --git a/LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.png b/LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.png
new file mode 100644 (file)
index 0000000..ef655c3
Binary files /dev/null and b/LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.png differ
diff --git a/LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.txt b/LayoutTests/http/tests/multipart/invalid-image-data-standalone-expected.txt
new file mode 100644 (file)
index 0000000..8892c15
--- /dev/null
@@ -0,0 +1,32 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 53x18
+          text run at (0,0) width 53: "Test for "
+        RenderInline {I} at (0,0) size 776x36
+          RenderInline {A} at (0,0) size 301x18 [color=#0000EE]
+            RenderText {#text} at (53,0) size 301x18
+              text run at (53,0) width 301: "http://bugs.webkit.org/show_bug.cgi?id=13759"
+          RenderText {#text} at (354,0) size 776x36
+            text run at (354,0) width 4: " "
+            text run at (358,0) width 418: "REGRESSION (r20182-r20184): Incorrect rendering of multipart"
+            text run at (0,18) width 45: "images"
+        RenderText {#text} at (45,18) size 4x18
+          text run at (45,18) width 4: "."
+      RenderBlock {P} at (0,52) size 784x18
+        RenderText {#text} at (0,0) size 244x18
+          text run at (0,0) width 244: "There should be a green square below."
+      RenderBlock (anonymous) at (0,86) size 784x124
+        RenderPartObject {IFRAME} at (0,0) size 124x124 [border: (2px inset #000000)]
+          layer at (0,0) size 120x120
+            RenderView at (0,0) size 120x120
+          layer at (0,0) size 120x120
+            RenderBlock {HTML} at (0,0) size 120x120
+              RenderBody {BODY} at (0,0) size 120x120
+                RenderImage {IMG} at (0,0) size 100x100
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/http/tests/multipart/invalid-image-data-standalone.html b/LayoutTests/http/tests/multipart/invalid-image-data-standalone.html
new file mode 100644 (file)
index 0000000..0ed88fb
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+    <script>
+        if (window.layoutTestController)
+            layoutTestController.waitUntilDone();
+
+        function loadedFirstPart()
+        {
+            if (window.layoutTestController)
+                setTimeout("stop(); layoutTestController.notifyDone()", 200);
+        }
+    </script>
+</head>
+<body>
+    <p>
+        Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=13759">http://bugs.webkit.org/show_bug.cgi?id=13759</a>
+        REGRESSION (r20182-r20184): Incorrect rendering of multipart images</i>.
+    </p>
+    <p>
+        There should be a green square below.
+    </p>
+    <iframe width="120" height="120" src="resources/multipart.php?interval=0&img1=green-100x100.png&img2=abe.png&wait=100" onload="loadedFirstPart()"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/multipart/resources/green-100x100.png b/LayoutTests/http/tests/multipart/resources/green-100x100.png
new file mode 100644 (file)
index 0000000..790e37d
Binary files /dev/null and b/LayoutTests/http/tests/multipart/resources/green-100x100.png differ
index a49f02c..310d831 100644 (file)
@@ -1,3 +1,22 @@
+2007-05-25  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Darin.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=13767
+          REGRESSION: Multipart image documents are garbled
+
+        Test: http/tests/multipart/invalid-image-data-standalone.html
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::isLoadingMultipartContent): Added.
+        * loader/DocumentLoader.h:
+        * loader/ImageDocument.cpp:
+        (WebCore::ImageTokenizer::finish): If the image is multipart, make a copy
+        of the current part instead of using the resource data, which is going to be
+        overwritten by the next part.
+        * loader/MainResourceLoader.h:
+        (WebCore::MainResourceLoader::isLoadingMultipartContent): Added.
+
 2007-05-25  Anders Carlsson  <andersca@apple.com>
 
         Fix no-svg build.
index 8534983..7dc3a1e 100644 (file)
@@ -666,6 +666,12 @@ bool DocumentLoader::isLoadingPlugIns() const
     return !m_plugInStreamLoaders.isEmpty();
 }
 
+bool DocumentLoader::isLoadingMultipartContent() const
+{
+    ASSERT(m_mainResourceLoader);
+    return m_mainResourceLoader->isLoadingMultipartContent();
+}
+
 bool DocumentLoader::startLoadingMainResource(unsigned long identifier)
 {
     ASSERT(!m_mainResourceLoader);
index f52bfeb..619d418 100644 (file)
@@ -138,6 +138,7 @@ namespace WebCore {
         bool isLoadingMainResource() const;
         bool isLoadingSubresources() const;
         bool isLoadingPlugIns() const;
+        bool isLoadingMultipartContent() const;
 
         void stopLoadingPlugIns();
         void stopLoadingSubresources();
index 2695f71..0dbef62 100644 (file)
@@ -96,7 +96,14 @@ void ImageTokenizer::finish()
 {
     if (!m_parserStopped && m_doc->imageElement()) {
         CachedImage* cachedImage = m_doc->cachedImage();
-        cachedImage->data(m_doc->frame()->loader()->documentLoader()->mainResourceData(), true);
+        RefPtr<SharedBuffer> data = m_doc->frame()->loader()->documentLoader()->mainResourceData();
+
+        // If this is a multipart image, make a copy of the current part, since the resource data
+        // will be overwritten by the next part.
+        if (m_doc->frame()->loader()->documentLoader()->isLoadingMultipartContent())
+            data = new SharedBuffer(data->data(), data->size());
+
+        cachedImage->data(data.release(), true);
         cachedImage->finish();
 
         cachedImage->setResponse(m_doc->frame()->loader()->documentLoader()->response());
index f07331b..94a4170 100644 (file)
@@ -55,6 +55,8 @@ namespace WebCore {
 
         void handleDataLoadNow(Timer<MainResourceLoader>*);
 
+        bool isLoadingMultipartContent() const { return m_loadingMultipartContent; }
+
     private:
         MainResourceLoader(Frame*);