Differential D8686 Diff 20608 src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
<?php | <?php | ||||
final class DifferentialChangesetTwoUpRenderer | final class DifferentialChangesetTwoUpRenderer | ||||
extends DifferentialChangesetHTMLRenderer { | extends DifferentialChangesetHTMLRenderer { | ||||
public function isOneUpRenderer() { | public function isOneUpRenderer() { | ||||
return false; | return false; | ||||
} | } | ||||
private function renderColgroup() { | |||||
return phutil_tag('colgroup', array(), array( | |||||
phutil_tag('col', array('class' => 'num')), | |||||
phutil_tag('col', array('class' => 'left')), | |||||
phutil_tag('col', array('class' => 'num')), | |||||
phutil_tag('col', array('class' => 'copy')), | |||||
phutil_tag('col', array('class' => 'right')), | |||||
phutil_tag('col', array('class' => 'cov')), | |||||
)); | |||||
} | |||||
public function renderTextChange( | public function renderTextChange( | ||||
$range_start, | $range_start, | ||||
$range_len, | $range_len, | ||||
$rows) { | $rows) { | ||||
$hunk_starts = $this->getHunkStartLines(); | $hunk_starts = $this->getHunkStartLines(); | ||||
$context_not_available = null; | $context_not_available = null; | ||||
if ($hunk_starts) { | if ($hunk_starts) { | ||||
$context_not_available = javelin_tag( | $context_not_available = javelin_tag( | ||||
'tr', | 'tr', | ||||
array( | array( | ||||
'sigil' => 'context-target', | 'sigil' => 'context-target', | ||||
), | ), | ||||
phutil_tag( | phutil_tag( | ||||
'td', | 'td', | ||||
array( | array( | ||||
'colspan' => 6, | 'colspan' => 6, | ||||
'class' => 'show-more' | 'class' => 'show-more' | ||||
), | ), | ||||
pht('Context not available.'))); | pht('Context not available.'))); | ||||
} | } | ||||
$html = array(); | $html = array(); | ||||
$html[] = $this->renderColgroup(); | |||||
$old_lines = $this->getOldLines(); | $old_lines = $this->getOldLines(); | ||||
$new_lines = $this->getNewLines(); | $new_lines = $this->getNewLines(); | ||||
$gaps = $this->getGaps(); | $gaps = $this->getGaps(); | ||||
$reference = $this->getRenderingReference(); | $reference = $this->getRenderingReference(); | ||||
$left_id = $this->getOldChangesetID(); | $left_id = $this->getOldChangesetID(); | ||||
$right_id = $this->getNewChangesetID(); | $right_id = $this->getNewChangesetID(); | ||||
// "N" stands for 'new' and means the comment should attach to the new file | // "N" stands for 'new' and means the comment should attach to the new file | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) { | ||||
$html[] = $container; | $html[] = $container; | ||||
$ii += ($len - 1); | $ii += ($len - 1); | ||||
continue; | continue; | ||||
} | } | ||||
$o_num = null; | $o_num = null; | ||||
$o_classes = 'left'; | $o_classes = ''; | ||||
$o_text = null; | $o_text = null; | ||||
if (isset($old_lines[$ii])) { | if (isset($old_lines[$ii])) { | ||||
$o_num = $old_lines[$ii]['line']; | $o_num = $old_lines[$ii]['line']; | ||||
$o_text = isset($old_render[$ii]) ? $old_render[$ii] : null; | $o_text = isset($old_render[$ii]) ? $old_render[$ii] : null; | ||||
if ($old_lines[$ii]['type']) { | if ($old_lines[$ii]['type']) { | ||||
if ($old_lines[$ii]['type'] == '\\') { | if ($old_lines[$ii]['type'] == '\\') { | ||||
$o_text = $old_lines[$ii]['text']; | $o_text = $old_lines[$ii]['text']; | ||||
$o_classes .= ' comment'; | $o_class = 'comment'; | ||||
} else if ($original_left && !isset($highlight_old[$o_num])) { | } else if ($original_left && !isset($highlight_old[$o_num])) { | ||||
$o_classes .= ' old-rebase'; | $o_class = 'old-rebase'; | ||||
} else if (empty($new_lines[$ii])) { | } else if (empty($new_lines[$ii])) { | ||||
$o_classes .= ' old old-full'; | $o_class = 'old old-full'; | ||||
} else { | } else { | ||||
$o_classes .= ' old'; | $o_class = 'old'; | ||||
} | } | ||||
$o_classes = $o_class; | |||||
} | } | ||||
} | } | ||||
$n_copy = hsprintf('<td class="copy" />'); | $n_copy = hsprintf('<td class="copy" />'); | ||||
$n_cov = null; | $n_cov = null; | ||||
$n_colspan = 2; | $n_colspan = 2; | ||||
$n_classes = ''; | $n_classes = ''; | ||||
$n_num = null; | $n_num = null; | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) { | ||||
'msg' => $title, | 'msg' => $title, | ||||
), | ), | ||||
'class' => 'copy '.$class, | 'class' => 'copy '.$class, | ||||
), | ), | ||||
''); | ''); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$n_classes .= ' right'.$n_colspan; | |||||
if (isset($hunk_starts[$o_num])) { | if (isset($hunk_starts[$o_num])) { | ||||
$html[] = $context_not_available; | $html[] = $context_not_available; | ||||
} | } | ||||
if ($o_num && $left_id) { | if ($o_num && $left_id) { | ||||
$o_id = 'C'.$left_id.$left_char.'L'.$o_num; | $o_id = 'C'.$left_id.$left_char.'L'.$o_num; | ||||
} else { | } else { | ||||
$o_id = null; | $o_id = null; | ||||
} | } | ||||
if ($n_num && $right_id) { | if ($n_num && $right_id) { | ||||
$n_id = 'C'.$right_id.$right_char.'L'.$n_num; | $n_id = 'C'.$right_id.$right_char.'L'.$n_num; | ||||
} else { | } else { | ||||
$n_id = null; | $n_id = null; | ||||
} | } | ||||
// NOTE: This is a unicode zero-width space, which we use as a hint | // NOTE: This is a unicode 'word joiner' (essentially a non-breaking | ||||
// when intercepting 'copy' events to make sure sensible text ends | // zero-width space), which we use as a hint when intercepting 'copy' | ||||
// up on the clipboard. See the 'phabricator-oncopy' behavior. | // events to make sure sensible text ends up on the clipboard. | ||||
$zero_space = "\xE2\x80\x8B"; | // See the 'phabricator-oncopy' behavior. | ||||
$zero_space = "\xE2\x81\xA0"; | |||||
// NOTE: The Javascript is sensitive to whitespace changes in this | // NOTE: The Javascript is sensitive to whitespace changes in this | ||||
// block! | // block! | ||||
$html[] = phutil_tag('tr', array(), array( | $html[] = phutil_tag('tr', array(), array( | ||||
phutil_tag('th', array('id' => $o_id), $o_num), | phutil_tag('th', array('id' => $o_id), $o_num), | ||||
phutil_tag('td', array('class' => $o_classes), $o_text), | phutil_tag('td', array('class' => $o_classes), $o_text), | ||||
phutil_tag('th', array('id' => $n_id), $n_num), | phutil_tag('th', array('id' => $n_id), $n_num), | ||||
Show All 23 Lines | for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) { | ||||
$new = $this->renderInlineComment($new_comment, | $new = $this->renderInlineComment($new_comment, | ||||
$on_right = true); | $on_right = true); | ||||
unset($new_comments[$n_num][$key]); | unset($new_comments[$n_num][$key]); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$html[] = phutil_tag('tr', array('class' => 'inline'), array( | $html[] = phutil_tag('tr', array('class' => 'inline'), array( | ||||
phutil_tag('th', array()), | phutil_tag('th', array()), | ||||
phutil_tag('td', array('class' => 'left'), $comment_html), | phutil_tag('td', array(), $comment_html), | ||||
phutil_tag('th', array()), | phutil_tag('th', array()), | ||||
phutil_tag('td', array('colspan' => 3, 'class' => 'right3'), $new), | phutil_tag('td', array('colspan' => 3), $new), | ||||
)); | )); | ||||
} | } | ||||
} | } | ||||
if ($n_num && isset($new_comments[$n_num])) { | if ($n_num && isset($new_comments[$n_num])) { | ||||
foreach ($new_comments[$n_num] as $comment) { | foreach ($new_comments[$n_num] as $comment) { | ||||
$comment_html = $this->renderInlineComment($comment, | $comment_html = $this->renderInlineComment($comment, | ||||
$on_right = true); | $on_right = true); | ||||
$html[] = phutil_tag('tr', array('class' => 'inline'), array( | $html[] = phutil_tag('tr', array('class' => 'inline'), array( | ||||
phutil_tag('th', array()), | phutil_tag('th', array()), | ||||
phutil_tag('td', array('class' => 'left')), | phutil_tag('td', array()), | ||||
phutil_tag('th', array()), | phutil_tag('th', array()), | ||||
phutil_tag( | phutil_tag( | ||||
'td', | 'td', | ||||
array('colspan' => 3, 'class' => 'right3'), | array('colspan' => 3), | ||||
epriestley: Can we safely remove any of these column classes now? | |||||
Not Done Inline ActionsYes! I meant to and forgot. sophiebits: Yes! I meant to and forgot. | |||||
$comment_html), | $comment_html), | ||||
)); | )); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return $this->wrapChangeInTable(phutil_implode_html('', $html)); | return $this->wrapChangeInTable(phutil_implode_html('', $html)); | ||||
} | } | ||||
Show All 32 Lines | public function renderFileChange($old_file = null, | ||||
$html_old = array(); | $html_old = array(); | ||||
$html_new = array(); | $html_new = array(); | ||||
foreach ($this->getOldComments() as $on_line => $comment_group) { | foreach ($this->getOldComments() as $on_line => $comment_group) { | ||||
foreach ($comment_group as $comment) { | foreach ($comment_group as $comment) { | ||||
$comment_html = $this->renderInlineComment($comment, $on_right = false); | $comment_html = $this->renderInlineComment($comment, $on_right = false); | ||||
$html_old[] = phutil_tag('tr', array('class' => 'inline'), array( | $html_old[] = phutil_tag('tr', array('class' => 'inline'), array( | ||||
phutil_tag('th', array()), | phutil_tag('th', array()), | ||||
phutil_tag('td', array('class' => 'left'), $comment_html), | phutil_tag('td', array(), $comment_html), | ||||
phutil_tag('th', array()), | phutil_tag('th', array()), | ||||
phutil_tag('td', array('colspan' => 3, 'class' => 'right3')), | phutil_tag('td', array('colspan' => 3)), | ||||
)); | )); | ||||
} | } | ||||
} | } | ||||
foreach ($this->getNewComments() as $lin_line => $comment_group) { | foreach ($this->getNewComments() as $lin_line => $comment_group) { | ||||
foreach ($comment_group as $comment) { | foreach ($comment_group as $comment) { | ||||
$comment_html = $this->renderInlineComment($comment, $on_right = true); | $comment_html = $this->renderInlineComment($comment, $on_right = true); | ||||
$html_new[] = phutil_tag('tr', array('class' => 'inline'), array( | $html_new[] = phutil_tag('tr', array('class' => 'inline'), array( | ||||
phutil_tag('th', array()), | phutil_tag('th', array()), | ||||
phutil_tag('td', array('class' => 'left')), | phutil_tag('td', array()), | ||||
phutil_tag('th', array()), | phutil_tag('th', array()), | ||||
phutil_tag( | phutil_tag( | ||||
'td', | 'td', | ||||
array('colspan' => 3, 'class' => 'right3'), | array('colspan' => 3), | ||||
$comment_html), | $comment_html), | ||||
)); | )); | ||||
} | } | ||||
} | } | ||||
if (!$old) { | if (!$old) { | ||||
$th_old = phutil_tag('th', array()); | $th_old = phutil_tag('th', array()); | ||||
} else { | } else { | ||||
$th_old = phutil_tag('th', array('id' => "C{$vs}OL1"), 1); | $th_old = phutil_tag('th', array('id' => "C{$vs}OL1"), 1); | ||||
} | } | ||||
if (!$new) { | if (!$new) { | ||||
$th_new = phutil_tag('th', array()); | $th_new = phutil_tag('th', array()); | ||||
} else { | } else { | ||||
$th_new = phutil_tag('th', array('id' => "C{$id}OL1"), 1); | $th_new = phutil_tag('th', array('id' => "C{$id}OL1"), 1); | ||||
} | } | ||||
$output = hsprintf( | $output = array(); | ||||
$output[] = $this->renderColgroup(); | |||||
$output[] = hsprintf( | |||||
Not Done Inline ActionsDo images still display OK? epriestley: Do images still display OK? | |||||
Not Done Inline ActionsOops, they're a little funky. I'll fix. sophiebits: Oops, they're a little funky. I'll fix. | |||||
'<tr class="differential-image-diff">'. | '<tr class="differential-image-diff">'. | ||||
'%s'. | '%s'. | ||||
'<td class="left differential-old-image">%s</td>'. | '<td class="differential-old-image">%s</td>'. | ||||
'%s'. | '%s'. | ||||
'<td class="right3 differential-new-image" colspan="3">%s</td>'. | '<td class="differential-new-image" colspan="3">%s</td>'. | ||||
'</tr>'. | '</tr>'. | ||||
'%s'. | '%s'. | ||||
'%s', | '%s', | ||||
$th_old, | $th_old, | ||||
$old, | $old, | ||||
$th_new, | $th_new, | ||||
$new, | $new, | ||||
phutil_implode_html('', $html_old), | phutil_implode_html('', $html_old), | ||||
phutil_implode_html('', $html_new)); | phutil_implode_html('', $html_new)); | ||||
$output = $this->wrapChangeInTable($output); | $output = $this->wrapChangeInTable($output); | ||||
return $this->renderChangesetTable($output); | return $this->renderChangesetTable($output); | ||||
} | } | ||||
} | } |
Can we safely remove any of these column classes now?