Use <td class="n" data-n="3"> instead of <th>3</th> for line numbers
Summary:
Ref T13161. Ref T12822. See PHI870. Long ago, the web was simple. You could leave your doors unlocked, you knew all your neighbors, crime hadn't been invented yet, and `<th>3</th>` was a perfectly fine way to render a line number cell containing the number "3".
But times have changed!
- In PHI870, this isn't good for screenreaders. We can't do much about this, so switch to `<td>`.
- In D19349 / T13105 and elsewhere, this `::after { content: attr(data-n); }` approach seems like the least bad general-purpose approach for preventing line numbers from being copied. Although Differential needs even more magic beyond this in the two-up view, this is likely good enough for the one-up view, and is consistent with other views (paste, harbormaster logs, general source display) where this technique is sufficient on its own.
The chance this breaks //something// is pretty much 100%, but we've got a week to figure out what it breaks. I couldn't find any issues immediately.
Test Plan:
- Created, edited, deleted inlines in 1-up and 2-up views.
- Replied, keyboard-navigated, keyboard-replied, drag-selected, poked and prodded everything.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13161, T12822
Differential Revision: https://secure.phabricator.com/D20188
This commit is contained in:
@@ -70,13 +70,13 @@ JX.install('DiffChangesetList', {
|
||||
var onrangedown = JX.bind(this, this._ifawake, this._onrangedown);
|
||||
JX.Stratcom.listen(
|
||||
'mousedown',
|
||||
['differential-changeset', 'tag:th'],
|
||||
['differential-changeset', 'tag:td'],
|
||||
onrangedown);
|
||||
|
||||
var onrangemove = JX.bind(this, this._ifawake, this._onrangemove);
|
||||
JX.Stratcom.listen(
|
||||
['mouseover', 'mouseout'],
|
||||
['differential-changeset', 'tag:th'],
|
||||
['differential-changeset', 'tag:td'],
|
||||
onrangemove);
|
||||
|
||||
var onrangeup = JX.bind(this, this._ifawake, this._onrangeup);
|
||||
@@ -360,7 +360,7 @@ JX.install('DiffChangesetList', {
|
||||
while (row) {
|
||||
var header = row.firstChild;
|
||||
while (header) {
|
||||
if (JX.DOM.isType(header, 'th')) {
|
||||
if (this.getLineNumberFromHeader(header)) {
|
||||
if (header.className.indexOf('old') !== -1) {
|
||||
old_list.push(header);
|
||||
} else if (header.className.indexOf('new') !== -1) {
|
||||
@@ -1247,11 +1247,7 @@ JX.install('DiffChangesetList', {
|
||||
},
|
||||
|
||||
getLineNumberFromHeader: function(th) {
|
||||
try {
|
||||
return parseInt(th.id.match(/^C\d+[ON]L(\d+)$/)[1], 10);
|
||||
} catch (x) {
|
||||
return null;
|
||||
}
|
||||
return parseInt(th.getAttribute('data-n'));
|
||||
},
|
||||
|
||||
getDisplaySideFromHeader: function(th) {
|
||||
|
||||
Reference in New Issue
Block a user