ie6: Correct rendering of commit messages

IE6 won't honor an LF inside of a div formatted with "white-space: pre".
Instead, create <br> and <p> tags ourselves to replace these LFs, such
that the HTML renderer would lay out the lines according to the break
tags.

Unfortunately we have to use <p> rather than <br><br> to insert what
should be a double LF, as IE6 collapses the double <br> tags into one,
trying to outsmart the author of the page.

Unfortunately the <p> margins collapse entirely under IE6, so we have
to use padding on the <p> box to get them back the way we expected to
see, but that messes with Firefox (which keeps the margins correctly)
so we have to make the margin 0px to prevent getting double margins
between paragraphs.

Bug: GERRIT-85
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-03-30 13:33:01 -07:00
parent 7a1ee1dc81
commit 4380fcd2ed
2 changed files with 11 additions and 2 deletions

View File

@@ -455,6 +455,10 @@
font-family: monospace;
font-size: small;
}
.gerrit-ChangeScreen-Description p {
margin-top: 0px;
padding-top: 0.5em;
}
.gerrit-ChangeScreen .gerrit-ChangeMessages .header {
width: 35em;

View File

@@ -46,8 +46,13 @@ public class ChangeDescriptionBlock extends Composite {
public void display(final Change chg, final PatchSetInfo info,
final AccountInfoCache acc) {
infoBlock.display(chg, acc);
SafeHtml.set(description, new SafeHtmlBuilder().append(info.getMessage())
.linkify());
SafeHtml msg = new SafeHtmlBuilder().append(info.getMessage());
msg = msg.linkify();
msg = msg.replaceAll("\n\n", "<p />");
msg = msg.replaceAll("\n", "<br />");
SafeHtml.set(description, msg);
descriptionPanel.setOpen(true);
}
}