15 Commits

Author SHA1 Message Date
Wyatt Allen
d0dd392794 Establish annotation pipeline
Apply diff annotations (intraline differences and comment ranges) by
executing the annotation layers in order to each line. The diff builder
maintains an ordered array of annotation layers which are communicated
to GrDiffBuilder subclass instances. The builder also listens to each
layer for notifications that annotations have changed for some line
range and re-renders (i.e. re-applies the pipeline on DIV.contentText
elements) accordingly.

Change-Id: Iea0599d4869cafaadc0974158153a91d927913e8
2016-07-20 12:25:40 -07:00
Viktar Donich
60d8bce771 Release range comments
Remove beta diff setting and enable range comments for all.

Change-Id: I0cee7e1717574ab54317cdce9e2332c8cda7a0cb
2016-07-14 14:45:15 -07:00
Viktar Donich
056fa71f5d Range comments tabs fixes
- Allow range comments to start at a tab.
- Preserve tabs within selected comment range.

Bug: Issue 4253
Change-Id: Ia1ebdcc2e22a1fdad9619cf9ded5db3c80ebe648
2016-07-14 12:39:33 -07:00
Logan Hanks
70509965e0 Fix a couple of lint errors
Change-Id: Id532e4dc808167cf60c7e4f16ff26af87b425150
2016-07-12 18:44:09 +00:00
Wyatt Allen
32e3e23449 Creates gr-annotation library housing DOM-splitting and annotation tools
The gr-diff-highlight library contained a number of generic DOM
manipulation methods that are of use elsewhere, including the variants
of `_splitNode` and `_wrapInHighlight`. This change moves these
functions into their own library called gr-annotation.js.

Change-Id: I0daf3193ef460b76e9348d6286d50a824b6a5986
2016-07-12 10:46:54 -07:00
Wyatt Allen
025e65d7d5 Reorganized DOM for diff content in PolyGerrit
Formerly, diff content elements mixed text with comment threads. For
example, a diff content node with an intraline highlight, a ranged
comment, and a gr-diff-comment-thread may have been organized as below:

    TD.content
      ╠ #text
      ╠ HL (intraline difference)
      ║ ╚ #text
      ╠ #text
      ╠ HL.range (ranged comment highlight)
      ║ ╚ #text
      ╠ #text
      ╚ GR-DIFF-COMMENT-THREAD
        ╠ GR-DIFF-COMMENT
        ╚ ...

Note that the comment thread was inserted at the same level as the text
of the diff line.

With this change, the text is separated from the comment thread by
introducing a DIV to contain the text with class `contentText` as
sibling to comment threads.

    TD.content
      ╠ DIV.contentText
      ║ ╠ #text
      ║ ╠ HL
      ║ ║ ╚ #text
      ║ ╠ #text
      ║ ╠ HL.range
      ║ ║ ╚ #text
      ║ ╚ #text
      ╚ GR-DIFF-COMMENT-THREAD
        ╠ GR-DIFF-COMMENT
        ╚ ...

Modifies the `getContentByLine` method of gr-diff-builder to return the
`DIV.contentText` element rather than the `TD.content` element which is
its parent. In most uses of this function, the text is what is needed
rather than the TD or comment thread, but in other cases, they can be
easily DOM traversed.

Change-Id: I0eded34afd3d22963252efc7eabfee290ae21a9c
2016-07-11 11:20:09 -07:00
Urs Wolfer
13a702372b gr-diff-highlight: Cleanups
- remove duplicated method declarations
- remove unused vars
- fix docs

Change-Id: If796e368e025a526946179cb418d06919707439d
2016-07-02 16:51:53 +02:00
Wyatt Allen
1678d988ae Addresses a gr-diff-highlight edge case
It was possible to cause a JS error when creating a ranged comment that
started at the very end of the first line (selecting no content on that
line). The relevant null-guard needed an additional set of parens to
avoid evaluating the second OR operand with a bad argument in this case.

Addresses the null-guard boolean expressions in `_normalizeStart` and
`_normalizeEnd` and reduces the number of calls to  `_getLength` from
thrice to once per iteration. Adds a relevant unit test.

Change-Id: I98848f9f6089fd3240bda175765770c9f9c5ba30
2016-07-01 13:25:41 -07:00
Viktar Donich
e88b612e29 Handle tabs for range comments
Changes:
- wrapping in HL now adds cssClass instead of discarding previous ones.
- getLength accounts for tab tags correctly.
- generic splitNode, potentially should be moved into util.
- more tests.

Feature: Issue 3915
Change-Id: Id8a646a5de4fd702aa112678c039df9ff8dd8c0b
2016-06-28 15:31:14 -07:00
Viktar Donich
b74a83162f Range comments select-to-create
Creates action box, that creates range comment on mouse down and hotkey
over selected text in diff. Makes best effort in guessing correct start
and end points for the selection.

Known issues listed as TODO items in test and code.

Feature: Issue 3915
Change-Id: I0a3e41d062e559c8cdb4b847829429f65622eb72
2016-06-27 10:21:27 -07:00
Viktar Donich
ea19586d19 Show comment ranges on render and context expand
Feature: Issue 3910
Change-Id: I9590d03b70e845b4f5ebe2f951f080ba3c9dc8db
2016-06-23 09:55:06 -07:00
Viktar Donich
3d6f8d695b Comment events wiring for ranged comments
Listen and update diff on comment events:
- call appropriate methods to apply comment ranges on comment creation
- re-render diff on and thread comment discard
- apply highlight on comment mouse over
- remove highlight on comment mouse out
- tests for all above

Feature: Issue 3910
Change-Id: I501ddcd063407777355b9c887118fcae53dcb5f1
2016-06-23 09:54:48 -07:00
Viktar Donich
d9b1f53a6a Apply range comments and highlights
Utility methods for applying comment range highlights to diff, with
tests including some of the corner cases.

Feature: Issue 3910
Change-Id: Id7de2dd4ff027ce96479a2d596e9414a0cadd6bf
2016-06-23 09:49:54 -07:00
Logan Hanks
d2497fbd09 Clean up lint under polygerrit-ui
This change cleans up all lint errors reported by gjslint,
with the exception of third-party code in the gr-linked-text
element and everything under bower_components:

$ gjslint --custom_jsdoc_tags event --check_html \
    -e bower_components,gr-linked-text -r app
Skipping 577 file(s).
181 files checked, no errors found.

Change-Id: I080d58bdd33b2d4b8dd22a717f06eebd7bbfb63d
2016-06-15 14:27:30 -07:00
Viktar Donich
ab1b211d80 Ranged highlights: initial commit
- Initial commit: structure, 'enabled' property controls sample
mouseDown handler.
- Minimal integration: isRangeSelected
- Minimal test.

Change-Id: I963ac7b158d57a1c24ee302d99eb6af26b0aeeeb
2016-06-13 14:38:08 -07:00