Commit 071be418 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 218618: Show line numbers on patch attachments when viewing them in "diff"…

Bug 218618: Show line numbers on patch attachments when viewing them in "diff" mode - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=justdave a=LpSolit
parent 2bd57ce8
...@@ -23,8 +23,11 @@ ...@@ -23,8 +23,11 @@
# between the elements. This is necessary because DOM parent-child-sibling # between the elements. This is necessary because DOM parent-child-sibling
# relations can change and screw up the javascript for restoring, collapsing # relations can change and screw up the javascript for restoring, collapsing
# and expanding. Do not change without testing all three of those. # and expanding. Do not change without testing all three of those.
# Also, the first empty row is required because 'table-layout: fixed' only
# considers the first row to determine column widths. If a colspan is found,
# it then share the width equally among all columns, which we don't want.
#%] #%]
<table class="file_table"><thead><tr><td class="file_head" colspan="2"><a href="#" onclick="return twisty_click(this)">[% collapsed ? '(+)' : '(-)' %]</a><input type="checkbox" name="[% file.filename FILTER html %]"[% collapsed ? '' : ' checked' %] style="display: none"> <table class="file_table"><thead><tr><td class="num"></td><td></td><td class="num"></td><td></td></tr><tr><td class="file_head" colspan="4"><a href="#" onclick="return twisty_click(this)">[% collapsed ? '(+)' : '(-)' %]</a><input type="checkbox" name="[% file.filename FILTER html %]"[% collapsed ? '' : ' checked' %] style="display: none">
[% IF lxr_prefix && !file.is_add %] [% IF lxr_prefix && !file.is_add %]
<a href="[% lxr_prefix %]">[% file.filename FILTER html %]</a> <a href="[% lxr_prefix %]">[% file.filename FILTER html %]</a>
[% ELSE %] [% ELSE %]
...@@ -49,7 +52,7 @@ incremental_restore() ...@@ -49,7 +52,7 @@ incremental_restore()
[% section_num = 0 %] [% section_num = 0 %]
[% FOREACH section = sections %] [% FOREACH section = sections %]
[% section_num = section_num + 1 %] [% section_num = section_num + 1 %]
<tr><th colspan="2" class="section_head"> <tr><th colspan="4" class="section_head">
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr><th width="95%" align="left"> <tr><th width="95%" align="left">
[% IF file.is_add %] [% IF file.is_add %]
...@@ -79,38 +82,67 @@ incremental_restore() ...@@ -79,38 +82,67 @@ incremental_restore()
<a name="[% file.filename FILTER html %]_sec[% section_num %]" href="#[% file.filename FILTER html %]_sec[% section_num %]">Link&nbsp;Here</a>&nbsp; <a name="[% file.filename FILTER html %]_sec[% section_num %]" href="#[% file.filename FILTER html %]_sec[% section_num %]">Link&nbsp;Here</a>&nbsp;
</th></tr></table> </th></tr></table>
</th></tr> </th></tr>
[% current_line_old = section.old_start %]
[% current_line_new = section.new_start %]
[% FOREACH group = section.groups %] [% FOREACH group = section.groups %]
[% IF group.context %] [% IF group.context %]
[% FOREACH line = group.context %] [% FOREACH line = group.context %]
<tr><td><pre>[% line FILTER html %]</pre></td><td><pre>[% line FILTER html %]</pre></td></tr> <tr>
<td class="num">[% current_line_old %]</td>
<td><pre>[% line FILTER html %]</pre></td>
<td class="num">[% current_line_new %]</td>
<td><pre>[% line FILTER html %]</pre></td>
</tr>
[% current_line_old = current_line_old + 1 %]
[% current_line_new = current_line_new + 1 %]
[% END %] [% END %]
[% END %] [% END %]
[% IF group.plus.size %] [% IF group.plus.size %]
[% IF group.minus.size %] [% IF group.minus.size %]
[% i = 0 %] [% i = 0 %]
[%# We need to store them in external variables. %]
[% curr_new = current_line_new %]
[% curr_old = current_line_old %]
[% WHILE (i < group.plus.size || i < group.minus.size) %] [% WHILE (i < group.plus.size || i < group.minus.size) %]
[% currentloop = 0 %] [% currentloop = 0 %]
[% WHILE currentloop < 500 && (i < group.plus.size || i < group.minus.size) %] [% WHILE currentloop < 500 && (i < group.plus.size || i < group.minus.size) %]
<tr class="changed"> <tr>
<td><pre>[% group.minus.$i FILTER html %]</pre></td> <td class="num">[% curr_old %]</td>
<td><pre>[% group.plus.$i FILTER html %]</pre></td> <td class="changed"><pre>[% group.minus.$i FILTER html %]</pre></td>
<td class="num">[% curr_new %]</td>
<td class="changed"><pre>[% group.plus.$i FILTER html %]</pre></td>
</tr> </tr>
[% currentloop = currentloop + 1 %] [% currentloop = currentloop + 1 %]
[% i = i + 1 %] [% i = i + 1 %]
[% IF i < group.minus.size %]
[% curr_old = curr_old + 1 %]
[% ELSE %]
[% curr_old = "" %]
[% END %]
[% IF i < group.plus.size %]
[% curr_new = curr_new + 1 %]
[% ELSE %]
[% curr_new = "" %]
[% END %]
[% END %] [% END %]
[% END %] [% END %]
[% current_line_old = current_line_old + group.minus.size %]
[% current_line_new = current_line_new + group.plus.size %]
[% ELSE %] [% ELSE %]
[% FOREACH line = group.plus %] [% FOREACH line = group.plus %]
[% IF file.is_add %] [% IF file.is_add %]
<tr> <tr>
<td class="added" colspan="2"><pre>[% line FILTER html %]</pre></td> <td class="num">[% current_line_new %]</td>
<td class="added" colspan="3"><pre>[% line FILTER html %]</pre></td>
</tr> </tr>
[% ELSE %] [% ELSE %]
<tr> <tr>
<td></td> <td class="num"></td><td></td>
<td class="num">[% current_line_new %]</td>
<td class="added"><pre>[% line FILTER html %]</pre></td> <td class="added"><pre>[% line FILTER html %]</pre></td>
</tr> </tr>
[% END %] [% END %]
[% current_line_new = current_line_new + 1 %]
[% END %] [% END %]
[% END %] [% END %]
[% ELSE %] [% ELSE %]
...@@ -118,14 +150,17 @@ incremental_restore() ...@@ -118,14 +150,17 @@ incremental_restore()
[% FOREACH line = group.minus %] [% FOREACH line = group.minus %]
[% IF file.is_remove %] [% IF file.is_remove %]
<tr> <tr>
<td class="removed" colspan="2"><pre>[% line FILTER html %]</pre></td> <td class="num">[% current_line_old %]</td>
<td class="removed" colspan="3"><pre>[% line FILTER html %]</pre></td>
</tr> </tr>
[% ELSE %] [% ELSE %]
<tr> <tr>
<td class="num">[% current_line_old %]</td>
<td class="removed"><pre>[% line FILTER html %]</pre></td> <td class="removed"><pre>[% line FILTER html %]</pre></td>
<td></td> <td class="num"></td><td></td>
</tr> </tr>
[% END %] [% END %]
[% current_line_old = current_line_old + 1 %]
[% END %] [% END %]
[% END %] [% END %]
[% END %] [% END %]
......
...@@ -37,7 +37,6 @@ Interdiff of #[% oldid %] and #[% newid %] for [% terms.bug %] #[% bugid %] ...@@ -37,7 +37,6 @@ Interdiff of #[% oldid %] and #[% newid %] for [% terms.bug %] #[% bugid %]
font-size: 1em; font-size: 1em;
background-color: #c3c3c3; background-color: #c3c3c3;
border: 1px solid black; border: 1px solid black;
width: 100%;
} }
.file_head a { .file_head a {
...@@ -51,7 +50,6 @@ Interdiff of #[% oldid %] and #[% newid %] for [% terms.bug %] #[% bugid %] ...@@ -51,7 +50,6 @@ Interdiff of #[% oldid %] and #[% newid %] for [% terms.bug %] #[% bugid %]
} }
.section_head { .section_head {
width: 100%;
background-color: #f0f0f0; background-color: #f0f0f0;
border: 1px solid black; border: 1px solid black;
text-align: left; text-align: left;
...@@ -70,7 +68,6 @@ table.file_table { ...@@ -70,7 +68,6 @@ table.file_table {
tbody.file td { tbody.file td {
border-left: 1px dashed black; border-left: 1px dashed black;
border-right: 1px dashed black; border-right: 1px dashed black;
width: 50%;
} }
tbody.file pre { tbody.file pre {
...@@ -95,6 +92,13 @@ tbody.file pre:empty { ...@@ -95,6 +92,13 @@ tbody.file pre:empty {
background-color: #FFCC99; background-color: #FFCC99;
} }
.num {
background-color: #ffe9ae;
text-align:right;
padding: 0 0.3em;
width: 3em;
}
.warning { .warning {
color: red color: red
} }
...@@ -196,7 +200,7 @@ tbody.file pre:empty { ...@@ -196,7 +200,7 @@ tbody.file pre:empty {
return twisty.parentNode.parentNode.parentNode.nextSibling; return twisty.parentNode.parentNode.parentNode.nextSibling;
} }
function get_twisty_from_tbody(tbody) { function get_twisty_from_tbody(tbody) {
return tbody.previousSibling.firstChild.firstChild.firstChild; return tbody.previousSibling.firstChild.nextSibling.firstChild.firstChild;
} }
[% END %] [% END %]
......
...@@ -448,7 +448,11 @@ ...@@ -448,7 +448,11 @@
'file.plus_lines', 'file.plus_lines',
'bonsai_prefix', 'bonsai_prefix',
'section.old_start', 'section.old_start',
'section_num' 'section_num',
'current_line_old',
'current_line_new',
'curr_old',
'curr_new'
], ],
'admin/admin.html.tmpl' => [ 'admin/admin.html.tmpl' => [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment