2011-02-07 Ojan Vafai <ojan@chromium.org>
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2011 06:39:20 +0000 (06:39 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2011 06:39:20 +0000 (06:39 +0000)
        Reviewed by Adam Barth.

        bring back diff context lines into the review tool
        https://bugs.webkit.org/show_bug.cgi?id=53974

        * code-review.js:

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

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/code-review.js

index 3eef3c1..0da5c66 100644 (file)
@@ -1,3 +1,12 @@
+2011-02-07  Ojan Vafai  <ojan@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        bring back diff context lines into the review tool
+        https://bugs.webkit.org/show_bug.cgi?id=53974
+
+        * code-review.js:
+
 2011-02-01  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Adam Roben.
index acbcc48..ed6cb09 100644 (file)
@@ -582,14 +582,12 @@ var CODE_REVIEW_UNITTEST;
 
     // Don't show the links to expand upwards/downwards if the patch starts/ends without context
     // lines, i.e. starts/ends with add/remove lines.
-    var first_line = file_diff.querySelector('.LineContainer');
+    var first_line = file_diff.querySelector('.LineContainer:not(.context)');
 
     // If there is no element with a "Line" class, then this is an image diff.
     if (!first_line)
       return;
 
-    $('.context', file_diff).detach();
-
     var expand_bar_index = 0;
     if (!$(first_line).hasClass('add') && !$(first_line).hasClass('remove'))
       $('h1', file_diff).after(expandBarHtml(BELOW))
@@ -736,7 +734,7 @@ var CODE_REVIEW_UNITTEST;
     var above_line_numbers = $('.expansionLineNumber', above_expansion);
     if (!above_line_numbers[0]) {
       var diff_section = expand_bar.previousElementSibling;
-      above_line_numbers = $('.lineNumber', diff_section);
+      above_line_numbers = $('.Line:not(.context) .lineNumber', diff_section);
     }
 
     var above_last_line_num, above_last_from_line_num;
@@ -751,7 +749,7 @@ var CODE_REVIEW_UNITTEST;
     if (!below_line_numbers[0]) {
       var diff_section = expand_bar.nextElementSibling;
       if (diff_section)
-        below_line_numbers = $('.lineNumber', diff_section);
+        below_line_numbers = $('.Line:not(.context) .lineNumber', diff_section);
     }
 
     var below_first_line_num, below_first_from_line_num;
@@ -786,6 +784,8 @@ var CODE_REVIEW_UNITTEST;
     if (start_line_num == above_last_line_num && end_line_num == below_first_line_num) {
       $('.ExpandLinkContainer', expand_bar).detach();
       below_expansion.insertBefore(lines, below_expansion.firstChild);
+      // Now that we're filling in all the lines, the context line following this expand bar is no longer needed.
+      $('.context', expand_bar.nextElementSibling).detach();
     } else if (direction == ABOVE) {
       above_expansion.appendChild(lines);
     } else {
@@ -927,7 +927,7 @@ var CODE_REVIEW_UNITTEST;
     // Apply diffs in reverse order to avoid needing to keep track of changing line numbers.
     for (var i = diff_sections.length - 1; i >= 0; i--) {
       var section = diff_sections[i];
-      var lines = section.getElementsByClassName('Line');
+      var lines = $('.Line:not(.context)', section);
       var current_line = -1;
       var context = [];
       var hunk_num = i + 1;
@@ -1092,6 +1092,10 @@ var CODE_REVIEW_UNITTEST;
     $(file_diff).attr('data-diffstate', diff_type);
     updateDiffLinkVisibility(file_diff);
 
+    $('.context', file_diff).each(function() {
+      convertLine(diff_type, this);
+    });
+
     $('.shared .Line', file_diff).each(function() {
       convertLine(diff_type, this);
     });