2011-04-19 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Apr 2011 18:08:12 +0000 (18:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Apr 2011 18:08:12 +0000 (18:08 +0000)
        Reviewed by Adam Roben.

        PrettyPatch tries to show images for deleted files
        https://bugs.webkit.org/show_bug.cgi?id=28457

        When the image data is empty, instead of generating an <img> tag, generate
        a text to indicate the image was deleted.

        * PrettyPatch/PrettyPatch.rb:

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

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb

index 1ee7ff2..45d8b55 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-19  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        Reviewed by Adam Roben.
+
+        PrettyPatch tries to show images for deleted files
+        https://bugs.webkit.org/show_bug.cgi?id=28457
+
+        When the image data is empty, instead of generating an <img> tag, generate
+        a text to indicate the image was deleted.
+
+        * PrettyPatch/PrettyPatch.rb:
+
 2011-04-14  Tony Chang  <tony@chromium.org>
 
         Reviewed by Adam Roben.
index a4e3893..e556b1d 100644 (file)
@@ -514,7 +514,7 @@ EOF
             end
             lines_with_contents = lines[startOfSections...lines.length]
             @sections = DiffSection.parse(lines_with_contents) unless @binary
-            if @image
+            if @image and not lines_with_contents.empty?
                 @image_url = "data:image/png;base64," + lines_with_contents.join
                 @image_checksum = FileDiff.read_checksum_from_png(lines_with_contents.join.unpack("m").join)
             elsif @git_image
@@ -544,14 +544,22 @@ EOF
             nil
         end
 
+        def image_to_html
+            if not @image_url then
+                return "<span class='text'>Image file removed</span>"
+            end
+            image_snippet = "<img class='image' src='" + @image_url + "' />"
+            if not @image_checksum then
+                return image_snippet
+            end
+            return "<p>" + @image_checksum + "</p>" + image_snippet
+        end
+
         def to_html
             str = "<div class='FileDiff'>\n"
             str += "<h1>#{PrettyPatch.linkifyFilename(@filename)}</h1>\n"
             if @image then
-                if @image_checksum then
-                    str += "<p>" + @image_checksum + "</p>"
-                end
-                str += "<img class='image' src='" + @image_url + "' />"
+                str += self.image_to_html
             elsif @git_image then
                 if @image_error
                     str += @image_error