Hide trailing margin on some formatted texts

Bug: Issue 5422
Change-Id: Ib7431dec9279c90caea998c9198204e290ec729f
diff --git a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.html b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.html
index 14a7260..08e2e21 100644
--- a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.html
+++ b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.html
@@ -62,7 +62,9 @@
                File comment:
              </span>
           </a>
-          <gr-formatted-text class="message"
+          <gr-formatted-text
+              class="message"
+              no-trailing-margin
               content="[[comment.message]]"
               config="[[projectConfig.commentlinks]]"></gr-formatted-text>
         </div>
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.html b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.html
index 11560f1..8855b0a 100644
--- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.html
+++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.html
@@ -29,6 +29,12 @@
       gr-linked-text.pre {
         margin: 0 0 1.4em 0;
       }
+      :host.noTrailingMargin p:last-child,
+      :host.noTrailingMargin ul:last-child,
+      :host.noTrailingMargin blockquote:last-child,
+      :host.noTrailingMargin gr-linked-text.pre:last-child {
+        margin: 0;
+      }
       blockquote {
         border-left: 1px solid #aaa;
         padding: 0 .7em;
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.js b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.js
index 1b129a7..c17e9e4 100644
--- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.js
+++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.js
@@ -22,12 +22,22 @@
     properties: {
       content: String,
       config: Object,
+      noTrailingMargin: {
+        type: Boolean,
+        value: false,
+      },
     },
 
     observers: [
       '_contentOrConfigChanged(content, config)',
     ],
 
+    ready: function() {
+      if (this.noTrailingMargin) {
+        this.classList.add('noTrailingMargin');
+      }
+    },
+
     /**
      * Get the plain text as it appears in the generated DOM.
      *