A major source of latency in creating comments in large diffs stems from
GR-DIFF-SELECTION applying selection-restricting classes to a parent of
the diff. When the diff contains a large number of lines (and thus a
large number of elements) applying a class forces a style recompute for
the substantial subtree.
This change optimizes this in two ways:
* **Initialize to the right side:** The selection-restricting class is
initialized to the right side, before the diff is even completely
built. This eliminates the need for a recomputation preceding the
first comment add on the right side (the most-likely side to be
interacted with).
* **Minimize the number of class modifications:** only add or remove
classes when necessary. This eliminates recomputes for consecutive
mousedown events that occur on the a common diff side.
On an i7 MBP, this eliminates ~120ms for the first comment on the right
and ~40ms for subsequent such comments.
Change-Id: Ibb8a7eca0398a5c7265dc1385967bce3dae5e5ef