mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Improve select-to-comment behavior in Firefox and on unified diffs
Summary: Ref T13513. - Firefox represents multiple selected rows as a discontinuous range. Accommodate this. - Unified diffs don't have a "copy" marker. Do something sort-of-reasonable for them. Test Plan: - Selected multiple lines of content in Firefox, got an option to add a comment. - Selected content in unified mode, got an option to add a comment. Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21249
This commit is contained in:
parent
42378ea393
commit
ebef22ccc1
2 changed files with 59 additions and 35 deletions
|
@ -13,7 +13,7 @@ return array(
|
||||||
'core.pkg.js' => '0efaf0ac',
|
'core.pkg.js' => '0efaf0ac',
|
||||||
'dark-console.pkg.js' => '187792c2',
|
'dark-console.pkg.js' => '187792c2',
|
||||||
'differential.pkg.css' => 'd71d4531',
|
'differential.pkg.css' => 'd71d4531',
|
||||||
'differential.pkg.js' => '06a7949c',
|
'differential.pkg.js' => 'ac6914bb',
|
||||||
'diffusion.pkg.css' => '42c75c37',
|
'diffusion.pkg.css' => '42c75c37',
|
||||||
'diffusion.pkg.js' => 'a98c0bf7',
|
'diffusion.pkg.js' => 'a98c0bf7',
|
||||||
'maniphest.pkg.css' => '35995d6d',
|
'maniphest.pkg.css' => '35995d6d',
|
||||||
|
@ -380,7 +380,7 @@ return array(
|
||||||
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9',
|
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9',
|
||||||
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
|
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
|
||||||
'rsrc/js/application/diff/DiffChangeset.js' => '20715b98',
|
'rsrc/js/application/diff/DiffChangeset.js' => '20715b98',
|
||||||
'rsrc/js/application/diff/DiffChangesetList.js' => '4a3639a1',
|
'rsrc/js/application/diff/DiffChangesetList.js' => '9d5b137e',
|
||||||
'rsrc/js/application/diff/DiffInline.js' => '6227a0e3',
|
'rsrc/js/application/diff/DiffInline.js' => '6227a0e3',
|
||||||
'rsrc/js/application/diff/DiffPathView.js' => '8207abf9',
|
'rsrc/js/application/diff/DiffPathView.js' => '8207abf9',
|
||||||
'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b',
|
'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b',
|
||||||
|
@ -775,7 +775,7 @@ return array(
|
||||||
'phabricator-darkmessage' => '26cd4b73',
|
'phabricator-darkmessage' => '26cd4b73',
|
||||||
'phabricator-dashboard-css' => '5a205b9d',
|
'phabricator-dashboard-css' => '5a205b9d',
|
||||||
'phabricator-diff-changeset' => '20715b98',
|
'phabricator-diff-changeset' => '20715b98',
|
||||||
'phabricator-diff-changeset-list' => '4a3639a1',
|
'phabricator-diff-changeset-list' => '9d5b137e',
|
||||||
'phabricator-diff-inline' => '6227a0e3',
|
'phabricator-diff-inline' => '6227a0e3',
|
||||||
'phabricator-diff-path-view' => '8207abf9',
|
'phabricator-diff-path-view' => '8207abf9',
|
||||||
'phabricator-diff-tree-view' => '5d83623b',
|
'phabricator-diff-tree-view' => '5d83623b',
|
||||||
|
@ -1327,11 +1327,6 @@ return array(
|
||||||
'490e2e2e' => array(
|
'490e2e2e' => array(
|
||||||
'phui-oi-list-view-css',
|
'phui-oi-list-view-css',
|
||||||
),
|
),
|
||||||
'4a3639a1' => array(
|
|
||||||
'javelin-install',
|
|
||||||
'phuix-button-view',
|
|
||||||
'phabricator-diff-tree-view',
|
|
||||||
),
|
|
||||||
'4a7fb02b' => array(
|
'4a7fb02b' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
|
@ -1821,6 +1816,11 @@ return array(
|
||||||
'javelin-uri',
|
'javelin-uri',
|
||||||
'phabricator-textareautils',
|
'phabricator-textareautils',
|
||||||
),
|
),
|
||||||
|
'9d5b137e' => array(
|
||||||
|
'javelin-install',
|
||||||
|
'phuix-button-view',
|
||||||
|
'phabricator-diff-tree-view',
|
||||||
|
),
|
||||||
'9f081f05' => array(
|
'9f081f05' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
|
|
|
@ -2232,34 +2232,36 @@ JX.install('DiffChangesetList', {
|
||||||
_updateSourceSelection: function() {
|
_updateSourceSelection: function() {
|
||||||
var ranges = this._getSelectedRanges();
|
var ranges = this._getSelectedRanges();
|
||||||
|
|
||||||
// If we have zero or more than one range, don't do anything.
|
// In Firefox, selecting multiple rows gives us multiple ranges. In
|
||||||
if (ranges.length === 1) {
|
// Safari and Chrome, we get a single range.
|
||||||
for (var ii = 0; ii < ranges.length; ii++) {
|
if (!ranges.length) {
|
||||||
var range = ranges[ii];
|
this._setSourceSelection(null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var head = range.startContainer;
|
var min = 0;
|
||||||
var last = range.endContainer;
|
var max = ranges.length - 1;
|
||||||
|
|
||||||
|
var head = ranges[min].startContainer;
|
||||||
|
var last = ranges[max].endContainer;
|
||||||
|
|
||||||
var head_loc = this._getFragmentLocation(head);
|
var head_loc = this._getFragmentLocation(head);
|
||||||
var last_loc = this._getFragmentLocation(last);
|
var last_loc = this._getFragmentLocation(last);
|
||||||
|
|
||||||
if (head_loc === null || last_loc === null) {
|
if (head_loc === null || last_loc === null) {
|
||||||
break;
|
this._setSourceSelection(null, null);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (head_loc.changesetID !== last_loc.changesetID) {
|
if (head_loc.changesetID !== last_loc.changesetID) {
|
||||||
break;
|
this._setSourceSelection(null, null);
|
||||||
}
|
|
||||||
|
|
||||||
head_loc.offset += range.startOffset;
|
|
||||||
last_loc.offset += range.endOffset;
|
|
||||||
|
|
||||||
this._setSourceSelection(head_loc, last_loc);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this._setSourceSelection(null, null);
|
head_loc.offset += ranges[min].startOffset;
|
||||||
|
last_loc.offset += ranges[max].endOffset;
|
||||||
|
|
||||||
|
this._setSourceSelection(head_loc, last_loc);
|
||||||
},
|
},
|
||||||
|
|
||||||
_setSourceSelection: function(start, end) {
|
_setSourceSelection: function(start, end) {
|
||||||
|
@ -2382,6 +2384,8 @@ JX.install('DiffChangesetList', {
|
||||||
// Find the line number and display column for the fragment.
|
// Find the line number and display column for the fragment.
|
||||||
var line = null;
|
var line = null;
|
||||||
var column_count = -1;
|
var column_count = -1;
|
||||||
|
var has_new = false;
|
||||||
|
var has_old = false;
|
||||||
var offset = null;
|
var offset = null;
|
||||||
var target_node = null;
|
var target_node = null;
|
||||||
var td;
|
var td;
|
||||||
|
@ -2415,6 +2419,18 @@ JX.install('DiffChangesetList', {
|
||||||
while (cursor) {
|
while (cursor) {
|
||||||
if (cursor.getAttribute('data-copy-mode')) {
|
if (cursor.getAttribute('data-copy-mode')) {
|
||||||
column_count++;
|
column_count++;
|
||||||
|
} else {
|
||||||
|
// In unified mode, the content column isn't currently marked
|
||||||
|
// with an attribute, and we can't count content columns anyway.
|
||||||
|
// Keep track of whether or not we see a "NL" (New Line) column
|
||||||
|
// and/or an "OL" (Old Line) column to try to puzzle out which
|
||||||
|
// side of the display change we're on.
|
||||||
|
|
||||||
|
if (cursor.id.match(/NL/)) {
|
||||||
|
has_new = true;
|
||||||
|
} else if (cursor.id.match(/OL/)) {
|
||||||
|
has_old = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var n = parseInt(cursor.getAttribute('data-n'));
|
var n = parseInt(cursor.getAttribute('data-n'));
|
||||||
|
@ -2434,8 +2450,16 @@ JX.install('DiffChangesetList', {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_count < 0) {
|
if (column_count < 0) {
|
||||||
|
if (has_new || has_old) {
|
||||||
|
if (has_new) {
|
||||||
|
column_count = 1;
|
||||||
|
} else {
|
||||||
|
column_count = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var seen = 0;
|
var seen = 0;
|
||||||
for (var ii = 0; ii < td.childNodes.length; ii++) {
|
for (var ii = 0; ii < td.childNodes.length; ii++) {
|
||||||
|
|
Loading…
Reference in a new issue