Changeset 83750 in webkit


Ignore:
Timestamp:
Apr 13, 2011 11:04:30 AM (13 years ago)
Author:
tony@chromium.org
Message:

2011-04-12 Tony Chang <tony@chromium.org>

Reviewed by Adam Roben.

make PrettyPatch.rb aware of checksums in png files
https://bugs.webkit.org/show_bug.cgi?id=58387

  • PrettyPatch/PrettyPatch.rb:
Location:
trunk/Websites/bugs.webkit.org
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Websites/bugs.webkit.org/ChangeLog

    r83616 r83750  
     12011-04-12  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Adam Roben.
     4
     5        make PrettyPatch.rb aware of checksums in png files
     6        https://bugs.webkit.org/show_bug.cgi?id=58387
     7
     8        * PrettyPatch/PrettyPatch.rb:
     9
    1102011-04-12  Adam Barth  <abarth@webkit.org>
    211
  • trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb

    r81180 r83750  
    229229}
    230230
    231 .Line.add {
     231.Line.add, .FileDiff .add {
    232232    background-color: #dfd;
    233233}
     
    238238}
    239239
    240 .Line.remove {
     240.Line.remove, .FileDiff .remove {
    241241    background-color: #fdd;
    242242}
     
    517517            if @image
    518518                @image_url = "data:image/png;base64," + lines_with_contents.join
     519                @image_checksum = FileDiff.read_checksum_from_png(lines_with_contents.join.unpack("m").join)
    519520            elsif @git_image
    520521                begin
     
    531532                    raise "no binary chunks" unless chunks
    532533
    533                     @image_urls = chunks.zip(@git_indexes).collect do |chunk, git_index|
     534                    binary_contents = chunks.zip(@git_indexes).collect do |chunk, git_index|
    534535                        FileDiff.extract_contents_from_git_binary_chunk(chunk, git_index)
    535536                    end
     537
     538                    @image_urls = binary_contents.collect { |content| "data:image/png;base64," + [content].pack("m") }
     539                    @image_checksums = binary_contents.collect { |content| FileDiff.read_checksum_from_png(content) }
    536540                rescue
    537541                    @image_error = "Exception raised during decoding git binary patch:<pre>#{CGI.escapeHTML($!.to_s + "\n" + $!.backtrace.join("\n"))}</pre>"
     
    545549            str += "<h1>#{PrettyPatch.linkifyFilename(@filename)}</h1>\n"
    546550            if @image then
     551                if @image_checksum then
     552                    str += "<p>" + @image_checksum + "</p>"
     553                end
    547554                str += "<img class='image' src='" + @image_url + "' />"
    548555            elsif @git_image then
     
    552559                    for i in (0...2)
    553560                        image_url = @image_urls[i]
     561                        image_checksum = @image_checksums[i]
     562
    554563                        style = ["remove", "add"][i]
    555564                        str += "<p class=\"#{style}\">"
     565
     566                        if image_checksum
     567                            str += image_checksum + "<br>"
     568                        end
    556569                        if image_url
    557570                            str += "<img class='image' src='" + image_url + "' />"
     
    591604        end
    592605
     606        def self.read_checksum_from_png(png_bytes)
     607            match = png_bytes.match(/tEXtchecksum\0([a-fA-F0-9]{32})/)
     608            match ? match[1] : nil
     609        end
     610
    593611        def self.git_new_file_binary_patch(filename, encoded_chunk, git_index)
    594612            return <<END
     
    633651
    634652            return nil if contents.empty?
    635             return "data:image/png;base64," + [contents].pack("m")
     653            return contents
    636654        end
    637655    end
Note: See TracChangeset for help on using the changeset viewer.