summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
blob: 54e9c6e1071a5a1698d28636b61de2feba0e99d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!--
Copyright (C) 2015 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../shared/gr-button/gr-button.html">
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../gr-diff-builder/gr-diff-builder.html">
<link rel="import" href="../gr-diff-comment-thread/gr-diff-comment-thread.html">
<link rel="import" href="../gr-diff-highlight/gr-diff-highlight.html">
<link rel="import" href="../gr-diff-selection/gr-diff-selection.html">
<link rel="import" href="../gr-syntax-themes/gr-theme-default.html">

<dom-module id="gr-diff">
  <template>
    <style>
      :host {
        --light-remove-highlight-color: #fee;
        --dark-remove-highlight-color: rgba(255, 0, 0, 0.15);
        --light-add-highlight-color: #efe;
        --dark-add-highlight-color: rgba(0, 255, 0, 0.15);

      }
      :host.no-left .sideBySide ::content .left,
      :host.no-left .sideBySide ::content .left + td,
      :host.no-left .sideBySide ::content .right:not([data-value]),
      :host.no-left .sideBySide ::content .right:not([data-value]) + td {
        display: none;
      }
      .diffContainer {
        border-bottom: 1px solid #eee;
        border-top: 1px solid #eee;
        display: flex;
        font: 12px var(--monospace-font-family);
        overflow-x: auto;
        will-change: transform;
      }
      table {
        border-collapse: collapse;
        border-right: 1px solid #ddd;
        table-layout: fixed;

        /* Hint GPU acceleration */
        -webkit-transform: translateZ(0);
        -moz-transform: translateZ(0);
        -ms-transform: translateZ(0);
        -o-transform: translateZ(0);
        transform: translateZ(0);
      }
      .lineNum {
        background-color: #eee;
      }
      .image-diff .gr-diff {
        text-align: center;
      }
      .image-diff img {
        max-width: 50em;
        outline: 1px solid #ccc;
      }
      .image-diff label {
        font-family: var(--font-family);
        font-style: italic;
      }
      .diff-row.target-row.target-side-left .lineNum.left,
      .diff-row.target-row.target-side-right .lineNum.right,
      .diff-row.target-row.unified .lineNum {
        background-color: #BBDEFB;
      }
      .diff-row.target-row.target-side-left .lineNum.left:before,
      .diff-row.target-row.target-side-right .lineNum.right:before,
      .diff-row.target-row.unified .lineNum:before {
        color: #000;
      }
      .blank,
      .content {
        background-color: #fff;
      }
      .full-width {
        width: 100%;
      }
      .full-width .contentText {
        white-space: pre-wrap;
        word-wrap: break-word;
      }
      .lineNum,
      .content {
        /* Set font size based the user's diff preference. */
        font-size: var(--font-size, 12px);
        vertical-align: top;
        white-space: pre;
      }
      .contextLineNum:before,
      .lineNum:before {
        display: inline-block;
        color: #666;
        content: attr(data-value);
        padding: 0 .75em;
        text-align: right;
        width: 100%;
      }
      .canComment .lineNum[data-value] {
        cursor: pointer;
      }
      .canComment .lineNum[data-value="FILE"]:before {
        content: 'File';
      }
      .content {
        overflow: hidden;
        /* Set max and min width since setting width on table cells still
           allows them to shrink. */
        max-width: var(--content-width, 80ch);
        min-width: var(--content-width, 80ch);
        width: var(--content-width, 80ch);
      }
      .content.add .intraline,
      .delta.total .content.add {
        background-color: var(--dark-add-highlight-color);
      }
      .content.add {
        background-color: var(--light-add-highlight-color);
      }
      .content.remove .intraline,
      .delta.total .content.remove {
        background-color: var(--dark-remove-highlight-color);
      }
      .content.remove {
        background-color: var(--light-remove-highlight-color);
      }
      .content .contentText:after {
        /* Newline, to ensure all lines are one line-height tall. */
        content: '\A';
      }
      .contextControl {
        background-color: #fef;
        color: #849;
      }
      .contextControl gr-button {
        display: inline-block;
        font-family: var(--monospace-font-family);
        text-decoration: none;
      }
      .contextControl td:not(.lineNum) {
        text-align: center;
      }
      .displayLine .diff-row.target-row {
        border-bottom: 1px solid #bbb;
      }
      .br:after {
        /* Line feed */
        content: '\A';
      }
      .tab {
        display: inline-block;
      }
      .tab-indicator:before {
        color: #C62828;
        /* >> character */
        content: '\00BB';
      }
      .trailing-whitespace {
        border-radius: .4em;
        background-color: #FF9AD2;
      }
    </style>
    <style include="gr-theme-default"></style>
    <div class$="[[_computeContainerClass(_loggedIn, viewMode, displayLine)]]"
        on-tap="_handleTap">
      <gr-diff-selection diff="[[_diff]]">
        <gr-diff-highlight
            id="highlights"
            logged-in="[[_loggedIn]]"
            comments="{{_comments}}">
          <gr-diff-builder
              id="diffBuilder"
              comments="[[_comments]]"
              diff="[[_diff]]"
              view-mode="[[viewMode]]"
              line-wrapping="[[lineWrapping]]"
              is-image-diff="[[isImageDiff]]"
              base-image="[[_baseImage]]"
              revision-image="[[_revisionImage]]">
            <table id="diffTable" class$="[[_diffTableClass]]"></table>
          </gr-diff-builder>
        </gr-diff-highlight>
      </gr-diff-selection>
    </div>
    <gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
  </template>
  <script src="gr-diff-line.js"></script>
  <script src="gr-diff-group.js"></script>
  <script src="gr-diff.js"></script>
</dom-module>