Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/diff/PhabricatorDocumentEngineBlocks.php
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | public function newTwoUpLayout() { | ||||
| $changeset = id(new PhabricatorDifferenceEngine()) | $changeset = id(new PhabricatorDifferenceEngine()) | ||||
| ->generateChangesetFromFileContent($old_list, $new_list); | ->generateChangesetFromFileContent($old_list, $new_list); | ||||
| $hunk_parser = id(new DifferentialHunkParser()) | $hunk_parser = id(new DifferentialHunkParser()) | ||||
| ->parseHunksForLineData($changeset->getHunks()) | ->parseHunksForLineData($changeset->getHunks()) | ||||
| ->reparseHunksForSpecialAttributes(); | ->reparseHunksForSpecialAttributes(); | ||||
| $hunk_parser->generateVisibleLinesMask(2); | $hunk_parser->generateVisibleBlocksMask(2); | ||||
| $mask = $hunk_parser->getVisibleLinesMask(); | $mask = $hunk_parser->getVisibleLinesMask(); | ||||
| $old_lines = $hunk_parser->getOldLines(); | $old_lines = $hunk_parser->getOldLines(); | ||||
| $new_lines = $hunk_parser->getNewLines(); | $new_lines = $hunk_parser->getNewLines(); | ||||
| $rows = array(); | $rows = array(); | ||||
| $count = count($old_lines); | $count = count($old_lines); | ||||
| for ($ii = 0; $ii < $count; $ii++) { | for ($ii = 0; $ii < $count; $ii++) { | ||||
| $old_line = idx($old_lines, $ii); | $old_line = idx($old_lines, $ii); | ||||
| $new_line = idx($new_lines, $ii); | $new_line = idx($new_lines, $ii); | ||||
| $is_visible = !empty($mask[$ii + 1]); | $is_visible = !empty($mask[$ii]); | ||||
| // TODO: There's currently a bug where one-line files get incorrectly | |||||
| // masked. This causes images to completely fail to render. Just ignore | |||||
| // the mask if it came back empty. | |||||
| if (!$mask) { | |||||
| $is_visible = true; | |||||
| } | |||||
| if ($old_line) { | if ($old_line) { | ||||
| $old_hash = rtrim($old_line['text'], "\n"); | $old_hash = rtrim($old_line['text'], "\n"); | ||||
| if (!strlen($old_hash)) { | if (!strlen($old_hash)) { | ||||
| // This can happen when one of the sources has no blocks. | // This can happen when one of the sources has no blocks. | ||||
| $old_block = null; | $old_block = null; | ||||
| } else { | } else { | ||||
| $old_block = array_shift($old_map[$old_hash]); | $old_block = array_shift($old_map[$old_hash]); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||