Color entire replace block same background shade

If the delete or insert side of a replace block is smaller than
the other side, we now color the entire smaller side of the block
with the red (or green) background, rather than a mixture of color
and grey.  This is visually more appealing because we don't have
a run of red-grey-white or green-grey-white in rapid succession.

Change-Id: I58cb94208a1fe7aade7cf354da305355f828c50b
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java
index e75b477..48c6791 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java
@@ -33,6 +33,8 @@
 import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
 import com.google.gwtorm.client.KeyUtil;
 
+import org.eclipse.jgit.diff.Edit;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -106,15 +108,19 @@
           if (del) {
             appendLineText(nc, hunk.getCurA(), DELETE, a, hunk.getCurA());
             hunk.incA();
+          } else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {
+            appendLineNone(nc, DELETE);
           } else {
-            appendLineNone(nc);
+            appendLineNone(nc, CONTEXT);
           }
 
           if (ins) {
             appendLineText(nc, hunk.getCurB(), INSERT, b, hunk.getCurB());
             hunk.incB();
+          } else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {
+            appendLineNone(nc, INSERT);
           } else {
-            appendLineNone(nc);
+            appendLineNone(nc, CONTEXT);
           }
 
           closeLine(nc);
@@ -308,14 +314,24 @@
     m.closeTd();
   }
 
-  private void appendLineNone(final SafeHtmlBuilder m) {
+  private void appendLineNone(final SafeHtmlBuilder m, final PatchLine.Type type) {
     m.openTd();
     m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
     m.closeTd();
 
     m.openTd();
     m.addStyleName(Gerrit.RESOURCES.css().fileLine());
-    m.addStyleName(Gerrit.RESOURCES.css().fileLineNone());
+    switch (type != null ? type : PatchLine.Type.CONTEXT) {
+      case DELETE:
+        m.addStyleName(Gerrit.RESOURCES.css().fileLineDELETE());
+        break;
+      case INSERT:
+        m.addStyleName(Gerrit.RESOURCES.css().fileLineINSERT());
+        break;
+      default:
+        m.addStyleName(Gerrit.RESOURCES.css().fileLineNone());
+        break;
+    }
     m.closeTd();
   }