In some cases, even though the copy selection was a valid one, the
target is something existing outside the content element. One specific
instance of this is when selecting lines by clicking/dragging along line
numbers.
Bug: Issue 5325
Change-Id: I3496a9d2432201aae6ef43a63ccca601a3bcd309
Previous comment logic relied on the assumption that any element in
a comment with textContent would be childless, which is false. Now, the
method is to fetch all comments within the selection and recursively
extract their text content.
Bug: Issue 5144
Change-Id: I22eac0b9b147fe0f3360d87529661efadb15940a
The addition of formatting in comments broke a variety of things having
to do with the copying logic. This change updates the logic and tests
to reflect the new DOM.
This issue arose because of a lack of integration tests for copying and
selection. That test is coming in a descendant change.
Bug: Issue 4969
Change-Id: I4e1994ab07947506c77b07877a46a9369d666d50
When the text selection exists within one line in diff-view, the
derivation of the selected text from the diff object using substring()
mutated the text and caused some selections to be artificially long.
Swapping the calls so that the end of the string is trimmed off first
fixes this.
This change also includes a regression test for this issue.
Bug: Issue 4794
Change-Id: I19dbab1cddd2e522cc6495011e8ef49f8ffe55b2
Deferring to default copy behavior when copying within diff comment
textareas allows the browser to handle copying. Also includes a
regression test.
Bug: Issue 4624
Change-Id: Ib976dd5055cf0ede89591ab2f483aa8d264a5484
The comment selection process was being performed incorrectly due to
lack of utilization of Polymer.dom. This uncovered a few more issues
with the way the fake copy events in testing were being constructed and
a base case in comment text selection.
Bug: Issue 4674
Change-Id: I7e05b7ebe0bfd60bc9cc8973166685c24e25ab37
This change adds logic that applies a CSS class whenever mouseDown
occurs inside of a comment thread that makes comment messages
highlightable. This replicates the existing functionality of GWTUI. In
addition, logic for copying the messages of multiple comments at once
is included.
Bug: Issue 4494
Change-Id: Id8e49e500c8d48dbba661b885050657dd4cfc0be
At the time that syntax highlighting DOM was introduced, the offsets of
selection ranges had been broken. In change [1] Kasper fixed this for
GR-DIFF-HIGHLIGHT with selection normalization functions. However,
selections for copying code as implemented in GR-DIFF-SELECTION were
still un-normalized.
With this change, the normalization functionality introduced in [1] is
moved to a JS library so that it can be used by both components. Tests
are updated.
[1] I26c61ca706575ea5df6e3b7b18a27225834396e8
Change-Id: I35ab0f71a46b3fc1d7356a314a0cae856f2ef28e
This change uses a new method of generating the clipboard data that
circumvents several strange issues caused by shadow/shady DOM. This
new method is much more legible and abstracts more logic away from the
DOM.
Bug: Issue 4494
Change-Id: I8c186d6cbbe9536548d934f734856b1f9ced1a26
This change fixes two minor issues in Safari.
- In gr-diff-highlight, Safari does not support NodeList.forEach.
- In gr-diff-selection_test, a test that should have been failing (a
selection class was missing) was not being run in Chrome/CI. A prior
commit modified the CSS selectors that enable text selection, and the
test was not changed to reflect this.
SHA of the offending commit: 613b49c
Change-Id: I7ef3b017be9ae731496609430e3856f58e5bd24e
The addition of syntax highlighting silently broke copy/paste
functionality due to the addition of another layer of div nesting.
Related to this bug are some issues with correct text selection in
unified diff view, so this patch addresses them as well.
Bug: Issue 4317
Change-Id: Iac7379de4131ab4e44905a54218d42fcfe67ce62
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