Changeset 76270 in webkit


Ignore:
Timestamp:
Jan 20, 2011 12:30:49 PM (13 years ago)
Author:
ojan@chromium.org
Message:

2011-01-19 Ojan Vafai <ojan@chromium.org>

Reviewed by Adam Barth.

[reviewtool] Add a link for annotated trac page on review page
https://bugs.webkit.org/show_bug.cgi?id=52747

-add line numbers to all trac links to the first line in the file diff
-add annotate/review log links
-make file-diff links other than the file name only show when you mouseover the filediff
-fix white-space to only wrap the .text element and it's childen, any of it's siblings/parents

  • PrettyPatch/PrettyPatch.rb:
  • code-review.js:
Location:
trunk/Websites/bugs.webkit.org
Files:
3 edited

Legend:

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

    r76268 r76270  
     12011-01-19  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        [reviewtool] Add a link for annotated trac page on review page
     6        https://bugs.webkit.org/show_bug.cgi?id=52747
     7
     8        -add line numbers to all trac links to the first line in the file diff
     9        -add annotate/review log links
     10        -make file-diff links other than the file name only show when you mouseover the filediff
     11        -fix white-space to only wrap the .text element and it's childen, any of it's siblings/parents
     12
     13        * PrettyPatch/PrettyPatch.rb:
     14        * code-review.js:
     15
    1162011-01-14  Ojan Vafai  <ojan@chromium.org>
    217
  • trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb

    r76082 r76270  
    139139}
    140140
    141 .DiffLinks a {
    142     border: 0;
    143     font-family: sans-serif;
    144     font-size: small;
    145     font-style: normal;
    146 }
    147 
    148 .FileDiff .DiffLinks {
    149     float: none;
    150     width: 100%;
    151     height: 0;
    152 }
    153 
    154141.FileDiffLinkContainer {
     142    opacity: 0;
    155143    display: table-cell;
    156144    padding-right: 0.5em;
     
    162150    border: solid #ddd;
    163151    border-width: 1px 0px;
     152}
     153
     154.ExpansionLine, .LineContainer {
     155    white-space: nowrap;
    164156}
    165157
     
    328320}
    329321
    330 .ExpandArea, .ExpandLinkContainer {
     322.ExpandLinkContainer {
     323  opacity: 0;
     324  border-top: 1px solid #ddd;
     325  border-bottom: 1px solid #ddd;
     326}
     327
     328.ExpandArea {
    331329  margin: 0;
    332   white-space: pre-wrap;
    333330}
    334331
    335332.ExpandText {
    336333  margin-left: 0.67em;
     334}
     335
     336.LinkContainer {
     337  font-family: sans-serif;
     338  font-size: small;
     339  font-style: normal;
     340  -webkit-transition: opacity 0.5s;
    337341}
    338342
  • trunk/Websites/bugs.webkit.org/code-review.js

    r76268 r76270  
    313313  }
    314314
     315  function firstLine(file_diff) {
     316    var container = $('.LineContainer:not(.context)', file_diff)[0];
     317    var from = fromLineNumber(container);
     318    var to = toLineNumber(container);
     319    return from || to;
     320  }
     321
    315322  function crawlDiff() {
    316323    $('.Line').each(idify).each(hoverify);
    317324    $('.FileDiff').each(function() {
    318       var file_name = $(this).children('h1').text();
     325      var header = $(this).children('h1');
     326      var url_hash = '#L' + firstLine(this);
     327
     328      var file_link = $('a', header)[0];
     329      file_link.target = "_blank";
     330      file_link.href += url_hash;
     331
     332      var file_name = header.text();
    319333      files[file_name] = this;
     334
    320335      addExpandLinks(file_name);
    321       $('h1', this).after('<div class="FileDiffLinkContainer">' + diffLinksHtml() + '</div>');
    322       updateDiffLinkVisibility(this);
    323     });
     336      addFileDiffLinks(file_name, url_hash);
     337    });
     338  }
     339
     340  function addFileDiffLinks(file_name, url_hash) {
     341    var diff_links = $('<div class="FileDiffLinkContainer LinkContainer">' +
     342        diffLinksHtml() +
     343        '</div>');
     344
     345    var trac_links = $('<a target="_blank">annotate</a><a target="_blank">revision log</a>');
     346    trac_links[0].href = 'http://trac.webkit.org/browser/trunk/' + file_name + '?annotate=blame' + url_hash;
     347    trac_links[1].href = 'http://trac.webkit.org/log/trunk/' + file_name;
     348    diff_links.append(trac_links);
     349
     350    $('h1', files[file_name]).after(diff_links);
     351    updateDiffLinkVisibility(files[file_name]);
    324352  }
    325353
     
    529557    }
    530558
     559    var lines = expansionLines(file_name, expansion_area, direction, start_line_num, end_line_num, start_from_line_num);
     560
    531561    var expansion_area;
    532562    // Filling in all the remaining lines. Overwrite the expand links.
    533563    if (start_line_num == above_last_line_num && end_line_num == below_first_line_num) {
    534       expansion_area = expand_bar.querySelector('.ExpandLinkContainer');
    535       expansion_area.innerHTML = '';
     564      $('.ExpandLinkContainer', expand_bar).detach();
     565      below_expansion.insertBefore(lines, below_expansion.firstChild);
     566    } else if (direction == ABOVE) {
     567      above_expansion.appendChild(lines);
    536568    } else {
    537       expansion_area = direction == ABOVE ? above_expansion : below_expansion;
    538     }
    539 
    540     insertLines(file_name, expansion_area, direction, start_line_num, end_line_num, start_from_line_num);
     569      below_expansion.insertBefore(lines, below_expansion.firstChild);
     570    }
    541571  }
    542572
     
    594624  }
    595625
    596   function insertLines(file_name, expansion_area, direction, start_line_num, end_line_num, start_from_line_num) {
     626  function expansionLines(file_name, expansion_area, direction, start_line_num, end_line_num, start_from_line_num) {
    597627    var fragment = document.createDocumentFragment();
    598628    var is_side_by_side = isDiffSideBySide(files[file_name]);
     
    607637    }
    608638
    609     if (direction == BELOW)
    610       expansion_area.insertBefore(fragment, expansion_area.firstChild);
    611     else
    612       expansion_area.appendChild(fragment);
     639    return fragment;
    613640  }
    614641
     
    736763  }
    737764
    738   function diffLinksHtml(opt_containerClassName) {
    739     var containerClassName = opt_containerClassName || '';
    740     return '<div class="DiffLinks ' + containerClassName + '">' +
    741       '<a href="javascript:" class="unify-link">unified</a>' +
    742       '<a href="javascript:" class="side-by-side-link">side-by-side</a>' +
    743     '</div>';
     765  function diffLinksHtml() {
     766    return '<a href="javascript:" class="unify-link">unified</a>' +
     767      '<a href="javascript:" class="side-by-side-link">side-by-side</a>';
    744768  }
    745769
     
    749773    $(document.body).prepend('<div id="message">' +
    750774        '<div class="help">Select line numbers to add a comment.' +
    751           diffLinksHtml('LinkContainer') +
     775          '<div class="DiffLinks LinkContainer">' + diffLinksHtml() + '</div>' +
    752776        '</div>' +
    753777        '<div class="commentStatus"></div>' +
     
    958982  }
    959983
     984  function showFileDiffLinks() {
     985    $('.LinkContainer', this).each(function() { this.style.opacity = 1; });
     986  }
     987
     988  function hideFileDiffLinks() {
     989    $('.LinkContainer', this).each(function() { this.style.opacity = 0; });
     990  }
     991
     992  $('.FileDiff').live('mouseenter', showFileDiffLinks);
     993  $('.FileDiff').live('mouseleave', hideFileDiffLinks);
    960994  $('.side-by-side-link').live('click', handleSideBySideLinkClick);
    961995  $('.unify-link').live('click', handleUnifyLinkClick);
Note: See TracChangeset for help on using the changeset viewer.