Patchwork [1,of,5,V2] hgweb: code selection without line numbers in file code view

login
register
mail settings
Submitter Alexander Plavin
Date May 31, 2013, 10:51 a.m.
Message ID <88877f36f75166b4bd12.1369997513@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1679/
State Rejected, archived
Headers show

Comments

Alexander Plavin - May 31, 2013, 10:51 a.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1369988709 -14400
#      Fri May 31 12:25:09 2013 +0400
# Node ID 88877f36f75166b4bd12317cf3f986b17ae8cf2c
# Parent  1bef6f99a12d9062e737bb623da627719a3987e6
hgweb: code selection without line numbers in file code view

File code is presented as HTML ordered list, so that line numbers
are not selected with the code itself. Long lines are wrapped for convenience.
Nicholas Riley - June 1, 2013, 2:33 a.m.
In article <88877f36f75166b4bd12.1369997513@debian-alexander.dolgopa>,
 Alexander Plavin <me@aplavin.ru> wrote:

> +li.source div {
> +  -moz-user-select: text;
> +  -khtml-user-select: text;
> +  -webkit-user-select: text;
> +  -ms-user-select: text;
> +  user-select: text;
> +  padding: 1px 5px;
> +  border-left: 1px solid #ccc;
> +  margin: 0 0 0 -7px;
> +  position: relative;
> +  color: #000;
> +  font-size: 111%;
> +}

The vertical padding here causes some artifacts at the left margin 
during selection in WebKit/Blink-based browsers - it also results in 
reduced vertical density when compared with the old view. However, 
without it, the horizontal lines may overlap the top of the text, so 
you'll need to compensate for that somewhere else.
Alexander Plavin - June 1, 2013, 7:50 a.m.
2013/6/1 Nicholas Riley <njriley@illinois.edu>

> In article <88877f36f75166b4bd12.1369997513@debian-alexander.dolgopa>,
>  Alexander Plavin <me@aplavin.ru> wrote:
>
> > +li.source div {
> > +  -moz-user-select: text;
> > +  -khtml-user-select: text;
> > +  -webkit-user-select: text;
> > +  -ms-user-select: text;
> > +  user-select: text;
> > +  padding: 1px 5px;
> > +  border-left: 1px solid #ccc;
> > +  margin: 0 0 0 -7px;
> > +  position: relative;
> > +  color: #000;
> > +  font-size: 111%;
> > +}
>
> The vertical padding here causes some artifacts at the left margin
> during selection in WebKit/Blink-based browsers - it also results in
> reduced vertical density when compared with the old view. However,
> without it, the horizontal lines may overlap the top of the text, so
> you'll need to compensate for that somewhere else.
>

I've compared the visual density with the old view, and it's actually the
same - I mean the same number of lines fits the screen in all my browsers.
And about the artifacts - I'll try to deal with them, thanks for pointing.


> --
> Nicholas Riley <njriley@illinois.edu>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Pierre-Yves David - June 1, 2013, 9:52 a.m.
On 31 mai 2013, at 12:51, Alexander Plavin wrote:

> # HG changeset patch
> # User Alexander Plavin <me@aplavin.ru>
> # Date 1369988709 -14400
> #      Fri May 31 12:25:09 2013 +0400
> # Node ID 88877f36f75166b4bd12317cf3f986b17ae8cf2c
> # Parent  1bef6f99a12d9062e737bb623da627719a3987e6
> hgweb: code selection without line numbers in file code view
> 
> File code is presented as HTML ordered list, so that line numbers
> are not selected with the code itself. Long lines are wrapped for convenience.

This drop the ability to link to a specific line. What's you plan for that ?
Laurens Holst - June 1, 2013, 12:03 p.m.
Op 6/1/13 11:52 AM, Pierre-Yves David schreef:
> On 31 mai 2013, at 12:51, Alexander Plavin wrote:
>
>> # HG changeset patch
>> # User Alexander Plavin <me@aplavin.ru>
>> # Date 1369988709 -14400
>> #      Fri May 31 12:25:09 2013 +0400
>> # Node ID 88877f36f75166b4bd12317cf3f986b17ae8cf2c
>> # Parent  1bef6f99a12d9062e737bb623da627719a3987e6
>> hgweb: code selection without line numbers in file code view
>>
>> File code is presented as HTML ordered list, so that line numbers
>> are not selected with the code itself. Long lines are wrapped for convenience.
> This drop the ability to link to a specific line. What's you plan for that ?

That feature is brought back in patch 3. If you go to the test page, 
you’ll notice that if you click on the line number it will link to that 
line. It does this by adding an event handler with JavaScript.

Doing it like that hurts accessibility a bit, but I don’t think it’s an 
essential feature for the blind, and is offset by the improvement in 
semantics.

~Laurens
Nicholas Riley - June 1, 2013, 5:10 p.m.
In article 
<CAAHOpS_UH7FD-Fi7Uy_BBkC5Ax9VjgJ5TRZYjEqcrLCU1mgRzQ@mail.gmail.com>,
 Ñ@Ñ|ÑuÑ{ÑÉÑpÑ~ÑtÑÇ ÑPÑ|ÑpÑrÑyÑ~ <me@aplavin.ru> wrote:

> I've compared the visual density with the old view, and it's actually the
> same - I mean the same number of lines fits the screen in all my browsers.
> And about the artifacts - I'll try to deal with them, thanks for pointing.

Here's what I'm seeing (happens with Safari and Chrome):

http://sabi.net/temp/hg-density.png
Alexander Plavin - June 1, 2013, 5:25 p.m.
Yes, here it is (I looked it file code view). And here current hgweb
version is inconsistent, I (tried to) use the same empty space (and thus
density) everywhere when a file or part of it appears. It's the same as in
current hgweb file code view.


2013/6/1 Nicholas Riley <njriley@illinois.edu>

> In article
> <CAAHOpS_UH7FD-Fi7Uy_BBkC5Ax9VjgJ5TRZYjEqcrLCU1mgRzQ@mail.gmail.com>,
>  Ñ@Ñ|ÑuÑ{ÑÉÑpÑ~ÑtÑÇ ÑPÑ|ÑpÑrÑyÑ~ <me@aplavin.ru> wrote:
>
> > I've compared the visual density with the old view, and it's actually the
> > same - I mean the same number of lines fits the screen in all my
> browsers.
> > And about the artifacts - I'll try to deal with them, thanks for
> pointing.
>
> Here's what I'm seeing (happens with Safari and Chrome):
>
> http://sabi.net/temp/hg-density.png
> --
> Nicholas Riley <njriley@illinois.edu>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Matt Mackall - June 1, 2013, 9:31 p.m.
On Sat, 2013-06-01 at 12:10 -0500, Nicholas Riley wrote:
> In article 
> <CAAHOpS_UH7FD-Fi7Uy_BBkC5Ax9VjgJ5TRZYjEqcrLCU1mgRzQ@mail.gmail.com>,
>  Ñ@Ñ|ÑuÑ{ÑÉÑpÑ~ÑtÑÇ ÑPÑ|ÑpÑrÑyÑ~ <me@aplavin.ru> wrote:
> 
> > I've compared the visual density with the old view, and it's actually the
> > same - I mean the same number of lines fits the screen in all my browsers.
> > And about the artifacts - I'll try to deal with them, thanks for pointing.
> 
> Here's what I'm seeing (happens with Safari and Chrome):
> 
> http://sabi.net/temp/hg-density.png

I'll also note this quietly changes our diff chunk line numbering
scheme.

Patch

diff -r 1bef6f99a12d -r 88877f36f751 mercurial/templatefilters.py
--- a/mercurial/templatefilters.py	Thu May 23 17:53:38 2013 -0500
+++ b/mercurial/templatefilters.py	Fri May 31 12:25:09 2013 +0400
@@ -299,6 +299,9 @@ 
     """:shortdate: Date. Returns a date like "2006-09-18"."""
     return util.shortdate(text)
 
+def spaceifempty(text):
+    return text or ' '
+
 def stringescape(text):
     return text.encode('string_escape')
 
@@ -381,6 +384,7 @@ 
     "short": short,
     "shortbisect": shortbisect,
     "shortdate": shortdate,
+    "spaceifempty": spaceifempty,
     "stringescape": stringescape,
     "stringify": stringify,
     "strip": strip,
diff -r 1bef6f99a12d -r 88877f36f751 mercurial/templates/paper/filerevision.tmpl
--- a/mercurial/templates/paper/filerevision.tmpl	Thu May 23 17:53:38 2013 -0500
+++ b/mercurial/templates/paper/filerevision.tmpl	Fri May 31 12:25:09 2013 +0400
@@ -67,8 +67,10 @@ 
 </table>
 
 <div class="overflow">
-<div class="sourcefirst"> line source</div>
+<div class="sourcefirst"></div>
+<ol>
 {text%fileline}
+</ol>
 <div class="sourcelast"></div>
 </div>
 </div>
diff -r 1bef6f99a12d -r 88877f36f751 mercurial/templates/paper/map
--- a/mercurial/templates/paper/map	Thu May 23 17:53:38 2013 -0500
+++ b/mercurial/templates/paper/map	Fri May 31 12:25:09 2013 +0400
@@ -72,7 +72,7 @@ 
 filecomparison = filecomparison.tmpl
 filelog = filelog.tmpl
 fileline = '
-  <div class="parity{parity} source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</div>'
+  <li class="parity{parity} source" id="{lineid}"><div>{line|escape|spaceifempty}</div></li>'
 filelogentry = filelogentry.tmpl
 
 annotateline = '
diff -r 1bef6f99a12d -r 88877f36f751 mercurial/templates/static/style-paper.css
--- a/mercurial/templates/static/style-paper.css	Thu May 23 17:53:38 2013 -0500
+++ b/mercurial/templates/static/style-paper.css	Fri May 31 12:25:09 2013 +0400
@@ -198,10 +198,9 @@ 
 .bigtable td.annotate { font-size: smaller; }
 .bigtable td.source { font-size: inherit; }
 
-.source, .sourcefirst, .sourcelast {
+.source {
   font-family: monospace;
-  white-space: pre;
-  padding: 1px 4px;
+  white-space: pre-wrap;
   font-size: 90%;
 }
 .sourcefirst { border-bottom: 1px solid #999; font-weight: bold; }
@@ -209,6 +208,39 @@ 
 .source a { color: #999; font-size: smaller; font-family: monospace;}
 .bottomline { border-bottom: 1px solid #999; }
 
+div.source, td.source { padding: 1px 4px; }
+
+ol {
+  background-color: #eee;
+  font-size: 90%;
+  margin: 0;
+  padding-left: 50px;
+}
+
+li.source {
+  -moz-user-select: -moz-none;
+  -khtml-user-select: none;
+  -webkit-user-select: none;
+  -ms-user-select: none;
+  user-select: none;
+  color: #999;
+  padding: 0 5px;
+}
+
+li.source div {
+  -moz-user-select: text;
+  -khtml-user-select: text;
+  -webkit-user-select: text;
+  -ms-user-select: text;
+  user-select: text;
+  padding: 1px 5px;
+  border-left: 1px solid #ccc;
+  margin: 0 0 0 -7px;
+  position: relative;
+  color: #000;
+  font-size: 111%;
+}
+
 .fileline { font-family: monospace; }
 .fileline img { border: 0; }