gitweb: Trouble with ref markers being hyperlinks because of illegally nested links
Commit 4afbaef by Giuseppe Bilotta (gitweb: ref markers link to named shortlogs) turned ref markers for tags and heads into links to appropriate views for the ref name.
Unfortunately the code didn't take into account the fact that nesting links (A elements) is illegal in (X)HTML:
12.2.2 Nested links are illegal
Links and anchors defined by the A element must not be nested; an A element must not contain any other A elements.
(from http://www.w3.org/TR/html401/struct/links.html#h-12.2.2), and that some browsers (e.g. Mozilla 1.17.2 I still use) in the very strict conformance mode (application/xhtml+xml mimetype and XML + XHTML DTD) _enforce_ this requirement by moving inner link immediately outside the end of outer link, i.e. for the HTML source looking like the following
<a ...> some text <a ...>v1.5.1</a></a>
rendered HTML (which you can see using "View Selection Source") is instead
<a ...> some text </a><a ...>v1.5.1</a>
And of course SPAN elements which wraps inner link (inner A element) is _not_ moved.
This is quite easy to fix for hyperlinked ref markers in 'shortlog' and 'history' views: just close the "title" hyperlink before printing $extra, i.e. ref markers. I have even made a patch doing that. Then instead of incorrect
_Merge branch into maint_ [] _maint_
where _aaa_ means that 'aaa' is hyperlink, and [xxx] is a fer marker, we will have correct:
_Merge branch into maint_ [_maint_]
See that we have two separate and not nested links...
What is more complicated is the issue of ref marker from git_print_header_div e.g. in 'commit'/'commitdiff' view, and in 'log' view. There link is made into block element using "display: block;" CSS rule (div.title, a.title), so that you can click _anywhere_ on the header block. This breaks layout even worse, making hyperlinked ref marker text appear *below* header div:
-----------------------------------------------------------
|_Merge branch into maint_ [] |
-----------------------------------------------------------
_maint_
To preserve current layout and behavior it would be needed to do some deep HTML + CSS positioning hackery, perhaps with additional link block without any text... But I don't know exactly how to do this; all [few] experiments I did failed.
I see possible the following alternate solutions:
* Ignore this issue (e.g. if it does not affect modern browsers)
* Revert 4afbaef (we lose feature, but how often used is it?)
* Always use quirks mode, or check browser and use quirks mode if it would break layout
* Use extra divs and links and CSS positioning to make layout which looks like current one, and behaves as current one, but is more complicated.
P.S. From what I have checked neither kernel.org nor repo.or.cz have this issue.
Signature · 2 lines
Jakub Narebski Poland
Quoted 25 lines · Jakub Narebski
Commit 4afbaef by Giuseppe Bilotta (gitweb: ref markers link to named shortlogs) turned ref markers for tags and heads into links to appropriate views for the ref name.
Unfortunately the code didn't take into account the fact that nesting links (A elements) is illegal in (X)HTML:
12.2.2 Nested links are illegal
Links and anchors defined by the A element must not be nested; an A element must not contain any other A elements.
(from http://www.w3.org/TR/html401/struct/links.html#h-12.2.2), and that some browsers (e.g. Mozilla 1.17.2 I still use) in the very strict conformance mode (application/xhtml+xml mimetype and XML + XHTML DTD) _enforce_ this requirement by moving inner link immediately outside the end of outer link, i.e. for the HTML source looking like the following
<a ...> some text <a ...>v1.5.1</a></a>
rendered HTML (which you can see using "View Selection Source") is instead
<a ...> some text </a><a ...>v1.5.1</a>
And of course SPAN elements which wraps inner link (inner A element) is _not_ moved.
Quoted 9 lines
This is quite easy to fix for hyperlinked ref markers in 'shortlog' and 'history' views: just close the "title" hyperlink before printing $extra, i.e. ref markers. I have even made a patch doing that. Then instead of incorrect
_Mergebranch intomaint_[] _maint_
where _aaa_ means that 'aaa' is hyperlink, and [xxx] is a fer marker, we will have correct:
_Mergebranch intomaint_[_maint_]
See that we have two separate and not nested links...
I've seen from the list that you already have patches ready to fix at least this problem. I think we might start from having these patches in while we think of the best way to fix the biggest issue:
Quoted 12 lines
What is more complicated is the issue of ref marker from
git_print_header_dive.g. in 'commit'/'commitdiff' view, and in 'log' view. There link is made into block element using "display: block;" CSS rule (div.title, a.title), so that you can click _anywhere_ on the header block. This breaks layout even worse, making hyperlinked ref marker text appear *below* header div:-----------------------------------------------------------
|_Merge branch intomaint_[] |
-----------------------------------------------------------
_maint_
Quoted 7 lines
To preserve current layout and behavior it would be needed to do some deep HTML + CSS positioning hackery, perhaps with additional link block without any text... But I don't know exactly how to do this; all [few] experiments I did failed.
I see possible the following alternate solutions:
* Ignore this issue (e.g. if it does not affect modern browsers)
That would be my current choice until we find a better solution.
Quoted 6 lines
* Revert 4afbaef (we lose feature, but how often used is it?)
* Always use quirks mode, or check browser and use quirks mode if it would break layout
* Use extra divs and links and CSS positioning to make layout which looks like current one, and behaves as current one, but is more complicated.
I'm asking on #html, hopefully I'll get some interesting idea to try for this.
Signature · 1 line
Giuseppe "Oblomov" Bilotta
Quoted 13 lines · Giuseppe Bilotta
Quoted 11 lines · Jakub Narebski
Commit 4afbaef by Giuseppe Bilotta (gitweb: ref markers link to named shortlogs) turned ref markers for tags and heads into links to appropriate views for the ref name.
Unfortunately the code didn't take into account the fact that nesting links (A elements) is illegal in (X)HTML:
12.2.2 Nested links are illegal
Links and anchors defined by the A element must not be nested; an A element must not contain any other A elements.
[...]
Quoted 17 lines
Quoted 17 lines
What is more complicated is the issue of ref marker from
git_print_header_dive.g. in 'commit'/'commitdiff' view, and in 'log' view. There link is made into block element using "display: block;" CSS rule (div.title, a.title), so that you can click _anywhere_ on the header block. This breaks layout even worse, making hyperlinked ref marker text appear *below* header div:-----------------------------------------------------------
|_Merge branch intomaint_[] |
-----------------------------------------------------------
_maint_To preserve current layout and behavior it would be needed to do some deep HTML + CSS positioning hackery, perhaps with additional link block without any text... But I don't know exactly how to do this; all [few] experiments I did failed.
Quoted 4 lines
Quoted 2 lines
I see possible the following alternate solutions:
* Ignore this issue (e.g. if it does not affect modern browsers)That would be my current choice until we find a better solution.
By the way, how common this error is? Could you check if _your_ web browser (Firefox, Internet Explorer, Opera, Konqueror, Safari, Chrome) does show this bug or not, please?
Quoted 8 lines
Quoted 6 lines
* Revert 4afbaef (we lose feature, but how often used is it?)
* Always use quirks mode, or check browser and use quirks mode if it would break layout
* Use extra divs and links and CSS positioning to make layout which looks like current one, and behaves as current one, but is more complicated.I'm asking on #html, hopefully I'll get some interesting idea to try for this.
I have found _a_ solution. Perhaps not the best one, but it works. And IMHO gives / can give even better visual.
Current version (line wrapped for better visibility):
<div class="header">
<a class="title" href="...">GIT 1.6.1
<span class="refs">
<span class="tag indirect" title="tags/v1.6.1">
<a href="...">v1.6.1</a>
</span> </span>
</a>
</div>
Current CSS (relevant part):
a.title {
display: block;
padding: 6px 8px;
}
Current rendering:
-----------------------------------------------------------
|_GIT 1.6.1_ [] |
-----------------------------------------------------------
__v1.6.1__
Proposed code (line wrapped for better visibility, with CSS embedded, which would change in final version of course). Only parts of style related to positioning are shown.
<div class="header">
<a href="..." style="float: left; margin: 6px 1px 6px 8px;">GIT 1.6.1</a> <div style="float: left; margin: 6px 1px;">
<span class="refs">
<span class="tag indirect" title="tags/v1.6.1">
<a href="...">v1.6.1</a>
</span>
</span> </div>
<a href="..." style="display: block; padding: 6px 8px;"> </a> </div>
Rendering with proposed code:
-----------------------------------------------------------
_|_GIT 1.6.1_ [_v1.6.1_] |_
-----------------------------------------------------------
I guess that instead of additional DIV element, we could use DIV for .refs, or use "float: right" style with SPAN element. I have not checked if other variations works: this one does.
What do you think?
Signature · 2 lines
Jakub Narebski Poland
Quoted 11 lines · Jakub Narebski
Quoted 6 lines · Giuseppe Bilotta
Quoted 2 lines · Jakub Narebski
I see possible the following alternate solutions:
* Ignore this issue (e.g. if it does not affect modern browsers)That would be my current choice until we find a better solution.
By the way, how common this error is? Could you check if _your_ web browser (Firefox, Internet Explorer, Opera, Konqueror, Safari, Chrome) does show this bug or not, please?
Opera works fine (no display or functionality anomaly). That makes sense, since I was the one who submitted the patch 8-D. Konqueror 3.5.9 does the ugly thing instead.
Notice that nested links are actually valid *XML*. Indeed, I asked on www-style and they suggested leaving the problem as-is, serving as html+xml which is what we do.
Quoted 56 lines
Quoted 8 lines
Quoted 6 lines
* Revert 4afbaef (we lose feature, but how often used is it?)
* Always use quirks mode, or check browser and use quirks mode if it would break layout
* Use extra divs and links and CSS positioning to make layout which looks like current one, and behaves as current one, but is more complicated.I'm asking on #html, hopefully I'll get some interesting idea to try for this.
I have found _a_ solution. Perhaps not the best one, but it works. And IMHO gives / can give even better visual.
Current version (line wrapped for better visibility):
<div class="header">
<a class="title" href="...">GIT 1.6.1
<span class="refs">
<span class="tag indirect" title="tags/v1.6.1"> <a href="...">v1.6.1</a>
</span>
</span>
</a>
</div>Current CSS (relevant part):
a.title { display: block; padding: 6px 8px;}
Current rendering:
-----------------------------------------------------------
|_GIT 1.6.1_ [] |
-----------------------------------------------------------
__v1.6.1__Proposed code (line wrapped for better visibility, with CSS embedded, which would change in final version of course). Only parts of style related to positioning are shown.
<div class="header">
<a href="..." style="float: left; margin: 6px 1px 6px 8px;">GIT 1.6.1</a> <div style="float: left; margin: 6px 1px;">
<span class="refs"><span class="tag indirect" title="tags/v1.6.1"> <a href="...">v1.6.1</a> </span></span>
</div>
<a href="..." style="display: block; padding: 6px 8px;"> </a> </div>Rendering with proposed code:
-----------------------------------------------------------
_|_GIT 1.6.1_ [_v1.6.1_] |_
-----------------------------------------------------------
Quoted 5 lines
I guess that instead of additional DIV element, we could use DIV for .refs, or use "float: right" style with SPAN element. I have not checked if other variations works: this one does.
What do you think?
The float thing was the second suggestion I was given on www-style. Can you provide a patch I can apply to my tree for testing to see how it comes up?
Signature · 1 line
Giuseppe "Oblomov" Bilotta
[RFC/PATCH] gitweb: Fix nested links problem with ref markers
Quoted 3 lines · Giuseppe Bilotta
Quoted 2 lines · Jakub Narebski
Quoted 1 line · Giuseppe Bilotta
On Sun, Jan 11, 2009 at 8:15 PM, Jakub Narebski <[email protected]> wrote:
[...]
Quoted 3 lines
Notice that nested links are actually valid *XML*. Indeed, I asked on www-style and they suggested leaving the problem as-is, serving as html+xml which is what we do.
But nested links are neither valid HTML nor valid XHTML. This restriction (no nested links) is IMVHO quite sensible, but IIRC it simply cannot be expressed as pure XML restriction (DTD, XML Schema, Relax-NG... perhaps Sablotron can express this restriction).
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
* Revert 4afbaef (we lose feature, but how often used is it?)
* Always use quirks mode, or check browser and use quirks mode if it would break layout
* Use extra divs and links and CSS positioning to make layout which looks like current one, and behaves as current one, but is more complicated.I'm asking on #html, hopefully I'll get some interesting idea to try for this.
I have found _a_ solution. Perhaps not the best one, but it works. And IMHO gives / can give even better visual.
Current version (line wrapped for better visibility):
[...]
Quoted 14 lines
Quoted 14 lines
Proposed code (line wrapped for better visibility, with CSS embedded, which would change in final version of course). Only parts of style related to positioning are shown.
<div class="header">
<a href="..." style="float: left; margin: 6px 1px 6px 8px;">GIT 1.6.1</a> <div style="float: left; margin: 6px 1px;">
<span class="refs"><span class="tag indirect" title="tags/v1.6.1"> <a href="...">v1.6.1</a> </span></span>
</div>
<a href="..." style="display: block; padding: 6px 8px;"> </a> </div>
[...]
Quoted 3 lines
Quoted 1 line
What do you think?
The float thing was the second suggestion I was given on www-style.
What was the first suggestion? And what is www-style?
Quoted 2 lines
Can you provide a patch I can apply to my tree for testing to see how it comes up?
Here it is. Note that CSS could be I think reduced. The size of gitweb.perl changes is affected by changing calling convention for git_print_header_html subroutine.
There is also strange artifact at least in Mozilla 1.17.2: if I hover over ref marker, the subject (title) gets darker background. Curious...
-- >8 --
From: Jakub Narebski <[email protected]>
Date: Wed, 14 Jan 2009 01:07:30 +0100
Subject: [RFC/PATCH] gitweb: Fix nested links problem with ref markers
Now that ref markers are links, they create nested links which are not allowed in HTML, and in strict mode in some browsers it causes layout errors.
It fixes format_subject_html subroutine (used for example in 'shortlog' view) to put $extra (which currently is formatted ref marker) outside "subject" link, as $extra can contain links and in HTML links cannot be nested.
It changes calling convention of git_print_header_div (and accordingly its calling sites) to provide $ref as separate argument, instead of concatenating it and putting it in $title, and provides workaround so links are not nested.
--- gitweb/gitweb.css | 25 +++++++++++++++++++++- gitweb/gitweb.perl | 56 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 23 deletions(-)
gitweb/gitweb.css +23 -2
@@ -76,23 +76,44 @@ div.page_body { font-family: monospace; } -div.title, a.title { +div.title, a.block { display: block; padding: 6px 8px; + text-decoration: none; + background-color: #edece6; +} + +div.title, a.title { font-weight: bold; background-color: #edece6; text-decoration: none; color: #000000; } +div.header div.extra, +div.header a.float { + float: left; + margin: 6px 1px; +} + +div.header a.float { + margin: 6px 1px 6px 8px; +} + div.readme { padding: 8px; } -a.title:hover { +a.block:hover, +div.header:hover a.title { background-color: #d9d8d1; } +div.header a.title:hover { + background-color: #edece6; /* ??? */ + text-decoration: underline; +} + div.title_text { padding: 6px 0px; border: solid #d9d8d1;
gitweb/gitweb.perl +35 -21
160 lines not on this page · raw message
Signature · 1 line
1.6.0.4
Re: [RFC/PATCH] gitweb: Fix nested links problem with ref markers
Quoted 5 lines · Jakub Narebski
Quoted 3 lines · Giuseppe Bilotta
Quoted 2 lines · Jakub Narebski
Quoted 1 line · Giuseppe Bilotta
On Sun, Jan 11, 2009 at 8:15 PM, Jakub Narebski <[email protected]> wrote:
Quoted 7 lines
[...]
Quoted 3 lines
Notice that nested links are actually valid *XML*. Indeed, I asked on www-style and they suggested leaving the problem as-is, serving as html+xml which is what we do.
But nested links are neither valid HTML nor valid XHTML. This restriction (no nested links) is IMVHO quite sensible
Sensible? I think it's idiotic, especially since CSS does not and cannot provide enough expression power to obtain the same layout and functionality as what can be achieved by nesting links, so that to achieve these results one has to resort to horirble trickes, effectively destroying the whole purporse of HTML+CSS which is to separate layout from semantics.
But anyway.
Quoted 3 lines
Quoted 1 line
The float thing was the second suggestion I was given on www-style.
What was the first suggestion? And what is www-style?
The first suggestion was to just leave things as they are. www-style is [email protected], the CSS mailing list of the W3C
Quoted 6 lines
Quoted 2 lines
Can you provide a patch I can apply to my tree for testing to see how it comes up?
Here it is. Note that CSS could be I think reduced. The size of gitweb.perl changes is affected by changing calling convention for
git_print_header_htmlsubroutine.
It's funny, I was working on a very similar patch myself a couple of days ago, but couldn't get the horizontal filler after the link to work properly, which is why I asked on www-style.
I'll test your patch and let you know.
Quoted 2 lines
There is also strange artifact at least in Mozilla 1.17.2: if I hover over ref marker, the subject (title) gets darker background. Curious...
Might be some kind of bug with the capturing vs bubbling phase.
Signature · 1 line
Giuseppe "Oblomov" Bilotta
Re: [RFC/PATCH] gitweb: Fix nested links problem with ref markers
Quoted 2 lines · Giuseppe Bilotta
Quoted 1 line · Jakub Narebski
On Tue, 13 Jan 2009, Giuseppe Bilotta wrote:
[...]
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
The float thing was the second suggestion I was given on www-style.
What was the first suggestion? And what is www-style?
The first suggestion was to just leave things as they are. www-style is [email protected], the CSS mailing list of the W3C
Thanks.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Can you provide a patch I can apply to my tree for testing to see how it comes up?
Here it is. Note that CSS could be I think reduced. The size of gitweb.perl changes is affected by changing calling convention for
git_print_header_htmlsubroutine.
Quoted 5 lines
It's funny, I was working on a very similar patch myself a couple of days ago, but couldn't get the horizontal filler after the link to work properly, which is why I asked on www-style.
I'll test your patch and let you know.
I am checking 'log' view of git repository; it should have enough ref markers to test this issue.
It works also in Konqueror 3.5.3-0.2.fc4...
Quoted 4 lines
Quoted 2 lines
There is also strange artifact at least in Mozilla 1.17.2: if I hover over ref marker, the subject (title) gets darker background. Curious...
Might be some kind of bug with the capturing vs bubbling phase.
...but the same artifact can be seen too. Also I am not entirely pleased with the way things behave on mouseover. It is a pity that you cannot style element using CSS2.1 based on the pseudo-class :hover of descendant element, or/and pseudo-class of sibling element, which nevertheless overlays given element.
Signature · 2 lines
Jakub Narebski Poland
Re: [RFC/PATCH] gitweb: Fix nested links problem with ref markers
Quoted 25 lines · Jakub Narebski
Quoted 10 lines · Giuseppe Bilotta
Quoted 8 lines · Jakub Narebski
Quoted 2 lines · Giuseppe Bilotta
Can you provide a patch I can apply to my tree for testing to see how it comes up?
Here it is. Note that CSS could be I think reduced. The size of gitweb.perl changes is affected by changing calling convention for
git_print_header_htmlsubroutine.Quoted 5 lines
It's funny, I was working on a very similar patch myself a couple of days ago, but couldn't get the horizontal filler after the link to work properly, which is why I asked on www-style.
I'll test your patch and let you know.
I am checking 'log' view of git repository; it should have enough ref markers to test this issue.
It works also in Konqueror 3.5.3-0.2.fc4...
Quoted 3 lines
Quoted 2 lines
There is also strange artifact at least in Mozilla 1.17.2: if I hover over ref marker, the subject (title) gets darker background. Curious...
Quoted 7 lines
Quoted 1 line
Might be some kind of bug with the capturing vs bubbling phase.
...but the same artifact can be seen too. Also I am not entirely pleased with the way things behave on mouseover. It is a pity that you cannot style element using CSS2.1 based on the pseudo-class :hover of descendant element, or/and pseudo-class of sibling element, which nevertheless overlays given element.
I know, I've been needing something like this in other occasion. And that's precisely what I was talking about for the limits of CSS, and why I really wonder if the illegal XHMTL but valid XML shouldn't rather be our option ...
Signature · 1 line
Giuseppe "Oblomov" Bilotta