blob: 1bf62689e2dfc93c15fc3f1679b02ba56cae8d2e [file] [log] [blame]
Andrew Bonventre78792e82016-03-04 17:48:22 -05001<!--
2Copyright (C) 2015 The Android Open Source Project
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15-->
16
17<link rel="import" href="../../../bower_components/polymer/polymer.html">
Andrew Bonventre78792e82016-03-04 17:48:22 -050018<link rel="import" href="../../shared/gr-button/gr-button.html">
Andrew Bonventrecba7d442016-03-05 19:20:09 -050019<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
Viktar Donich0f02cda2016-06-01 11:41:47 -070020<link rel="import" href="../gr-diff-builder/gr-diff-builder.html">
Viktar Doniche1341972016-06-09 16:39:17 -070021<link rel="import" href="../gr-diff-comment-thread/gr-diff-comment-thread.html">
Viktar Donichab1b2112016-06-10 12:47:57 -070022<link rel="import" href="../gr-diff-highlight/gr-diff-highlight.html">
Viktar Doniche1341972016-06-09 16:39:17 -070023<link rel="import" href="../gr-diff-selection/gr-diff-selection.html">
Wyatt Allenec4d6a22016-07-25 22:23:14 -070024<link rel="import" href="../gr-syntax-themes/gr-theme-default.html">
Andrew Bonventre78792e82016-03-04 17:48:22 -050025
26<dom-module id="gr-diff">
27 <template>
28 <style>
Andrew Bonventre2aa22122016-03-25 16:48:13 -040029 :host {
30 --light-remove-highlight-color: #fee;
Wyatt Allen3894bb92016-10-18 18:18:00 -070031 --dark-remove-highlight-color: rgba(255, 0, 0, 0.15);
Andrew Bonventre2aa22122016-03-25 16:48:13 -040032 --light-add-highlight-color: #efe;
Wyatt Allen3894bb92016-10-18 18:18:00 -070033 --dark-add-highlight-color: rgba(0, 255, 0, 0.15);
34
Andrew Bonventre2aa22122016-03-25 16:48:13 -040035 }
Viktar Donichc282d7b2016-08-10 11:53:12 -070036 :host.no-left .sideBySide ::content .left,
Viktar Donich7706e9c2016-08-10 14:55:22 -070037 :host.no-left .sideBySide ::content .left + td,
38 :host.no-left .sideBySide ::content .right:not([data-value]),
39 :host.no-left .sideBySide ::content .right:not([data-value]) + td {
Viktar Donichc282d7b2016-08-10 11:53:12 -070040 display: none;
41 }
Andrew Bonventre78792e82016-03-04 17:48:22 -050042 .diffContainer {
43 border-bottom: 1px solid #eee;
44 border-top: 1px solid #eee;
45 display: flex;
46 font: 12px var(--monospace-font-family);
Viktar Donichbcab1982016-11-02 11:57:23 -070047 overflow-x: auto;
Andrew Bonventre2aa22122016-03-25 16:48:13 -040048 will-change: transform;
Andrew Bonventre78792e82016-03-04 17:48:22 -050049 }
Andrew Bonventre2aa22122016-03-25 16:48:13 -040050 table {
51 border-collapse: collapse;
Andrew Bonventre78792e82016-03-04 17:48:22 -050052 border-right: 1px solid #ddd;
Wyatt Allen32b03fc2016-08-05 15:56:33 -070053 table-layout: fixed;
Viktar Doniche2d1c632016-10-24 20:52:59 +000054
Wyatt Allen4254ca32016-10-21 10:41:24 -070055 /* Hint GPU acceleration */
Wyatt Allen32b03fc2016-08-05 15:56:33 -070056 -webkit-transform: translateZ(0);
57 -moz-transform: translateZ(0);
58 -ms-transform: translateZ(0);
59 -o-transform: translateZ(0);
60 transform: translateZ(0);
Andrew Bonventre78792e82016-03-04 17:48:22 -050061 }
Viktar Doniche1341972016-06-09 16:39:17 -070062 .lineNum {
Andrew Bonventre2aa22122016-03-25 16:48:13 -040063 background-color: #eee;
64 }
Wyatt Allen88678da2016-05-23 17:18:43 -070065 .image-diff .gr-diff {
66 text-align: center;
67 }
68 .image-diff img {
69 max-width: 50em;
70 outline: 1px solid #ccc;
71 }
72 .image-diff label {
73 font-family: var(--font-family);
74 font-style: italic;
75 }
Wyatt Allen72b87fc2016-05-16 14:40:51 -070076 .diff-row.target-row.target-side-left .lineNum.left,
77 .diff-row.target-row.target-side-right .lineNum.right,
78 .diff-row.target-row.unified .lineNum {
Wyatt Allen8eba5942016-05-19 14:50:43 -070079 background-color: #BBDEFB;
80 }
81 .diff-row.target-row.target-side-left .lineNum.left:before,
82 .diff-row.target-row.target-side-right .lineNum.right:before,
83 .diff-row.target-row.unified .lineNum:before {
84 color: #000;
Wyatt Allen72b87fc2016-05-16 14:40:51 -070085 }
Andrew Bonventre2aa22122016-03-25 16:48:13 -040086 .blank,
87 .content {
88 background-color: #fff;
89 }
Becky Siegele7d19a92016-10-31 14:35:35 -070090 .full-width {
91 width: 100%;
92 }
Becky Siegeldc462182016-11-02 17:57:16 -070093 .full-width .contentText {
94 white-space: pre-wrap;
95 word-wrap: break-word;
96 }
Andrew Bonventre2aa22122016-03-25 16:48:13 -040097 .lineNum,
98 .content {
Becky Siegele7d19a92016-10-31 14:35:35 -070099 /* Set font size based the user's diff preference. */
100 font-size: var(--font-size, 12px);
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400101 vertical-align: top;
102 white-space: pre;
103 }
104 .contextLineNum:before,
105 .lineNum:before {
106 display: inline-block;
107 color: #666;
108 content: attr(data-value);
109 padding: 0 .75em;
110 text-align: right;
111 width: 100%;
112 }
113 .canComment .lineNum[data-value] {
114 cursor: pointer;
115 }
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400116 .canComment .lineNum[data-value="FILE"]:before {
117 content: 'File';
118 }
119 .content {
120 overflow: hidden;
Andrew Bonventreac802cd2016-04-02 21:53:35 -0400121 /* Set max and min width since setting width on table cells still
122 allows them to shrink. */
123 max-width: var(--content-width, 80ch);
124 min-width: var(--content-width, 80ch);
Becky Siegele7d19a92016-10-31 14:35:35 -0700125 width: var(--content-width, 80ch);
Becky Siegeld7dbed62016-10-12 10:55:26 -0700126 }
Wyatt Allen650c5292016-06-22 17:18:06 -0700127 .content.add .intraline,
Wyatt Allen1e3cd472016-12-21 12:55:21 -0800128 .delta.total .content.add {
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400129 background-color: var(--dark-add-highlight-color);
130 }
Wyatt Allen1e3cd472016-12-21 12:55:21 -0800131 .content.add {
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400132 background-color: var(--light-add-highlight-color);
133 }
Wyatt Allen650c5292016-06-22 17:18:06 -0700134 .content.remove .intraline,
Wyatt Allen1e3cd472016-12-21 12:55:21 -0800135 .delta.total .content.remove {
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400136 background-color: var(--dark-remove-highlight-color);
137 }
Wyatt Allen1e3cd472016-12-21 12:55:21 -0800138 .content.remove {
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400139 background-color: var(--light-remove-highlight-color);
140 }
Aaron Gabled5d9a132016-12-09 12:30:29 -0800141 .content .contentText:after {
142 /* Newline, to ensure all lines are one line-height tall. */
143 content: '\A';
144 }
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400145 .contextControl {
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400146 background-color: #fef;
Wyatt Allen10979632016-06-01 15:13:33 -0700147 color: #849;
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400148 }
149 .contextControl gr-button {
Wyatt Allen10979632016-06-01 15:13:33 -0700150 display: inline-block;
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400151 font-family: var(--monospace-font-family);
152 text-decoration: none;
153 }
154 .contextControl td:not(.lineNum) {
155 text-align: center;
156 }
Becky Siegel6a7085e2016-11-02 16:25:53 -0700157 .displayLine .diff-row.target-row {
158 border-bottom: 1px solid #bbb;
159 }
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400160 .br:after {
161 /* Line feed */
162 content: '\A';
163 }
164 .tab {
165 display: inline-block;
166 }
Wyatt Allenbe0142c2016-08-25 11:31:42 -0700167 .tab-indicator:before {
168 color: #C62828;
169 /* >> character */
170 content: '\00BB';
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400171 }
Wyatt Allend9705002016-11-17 12:03:51 -0800172 .trailing-whitespace {
173 border-radius: .4em;
174 background-color: #FF9AD2;
175 }
Kasper Nilssonb4893d02017-04-07 15:52:28 -0700176 #diffHeader {
177 background-color: #F9F9F9;
178 color: #2A00FF;
179 font-family: var(--monospace-font-family);
180 font-size: var(--font-size, 12px);
181 padding: 0.5em 0 0.5em 4em;
182 }
Andrew Bonventre78792e82016-03-04 17:48:22 -0500183 </style>
Wyatt Allenec4d6a22016-07-25 22:23:14 -0700184 <style include="gr-theme-default"></style>
Kasper Nilssonb4893d02017-04-07 15:52:28 -0700185 <div id="diffHeader" hidden$="[[_computeDiffHeaderHidden(_diffHeaderItems)]]">
186 <template
187 is="dom-repeat"
188 items="[[_diffHeaderItems]]">
189 <div>[[item]]</div>
190 </template>
191 </div>
Becky Siegel6a7085e2016-11-02 16:25:53 -0700192 <div class$="[[_computeContainerClass(_loggedIn, viewMode, displayLine)]]"
Viktar Doniche1341972016-06-09 16:39:17 -0700193 on-tap="_handleTap">
Wyatt Allen9fcec742016-09-08 14:09:11 -0700194 <gr-diff-selection diff="[[_diff]]">
Viktar Donichab1b2112016-06-10 12:47:57 -0700195 <gr-diff-highlight
196 id="highlights"
197 logged-in="[[_loggedIn]]"
Wyatt Allend0dd3922016-07-14 12:31:09 -0700198 comments="{{_comments}}">
Viktar Donichab1b2112016-06-10 12:47:57 -0700199 <gr-diff-builder
200 id="diffBuilder"
Wyatt Allend0dd3922016-07-14 12:31:09 -0700201 comments="[[_comments]]"
Wyatt Allenea97c5b2016-07-21 22:19:25 -0700202 diff="[[_diff]]"
Viktar Donichab1b2112016-06-10 12:47:57 -0700203 view-mode="[[viewMode]]"
Becky Siegele7d19a92016-10-31 14:35:35 -0700204 line-wrapping="[[lineWrapping]]"
Viktar Donichab1b2112016-06-10 12:47:57 -0700205 is-image-diff="[[isImageDiff]]"
206 base-image="[[_baseImage]]"
207 revision-image="[[_revisionImage]]">
Becky Siegele7d19a92016-10-31 14:35:35 -0700208 <table id="diffTable" class$="[[_diffTableClass]]"></table>
Viktar Donichab1b2112016-06-10 12:47:57 -0700209 </gr-diff-builder>
210 </gr-diff-highlight>
Viktar Doniche1341972016-06-09 16:39:17 -0700211 </gr-diff-selection>
Andrew Bonventre78792e82016-03-04 17:48:22 -0500212 </div>
Andrew Bonventrecba7d442016-03-05 19:20:09 -0500213 <gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
Andrew Bonventre78792e82016-03-04 17:48:22 -0500214 </template>
Andrew Bonventre2aa22122016-03-25 16:48:13 -0400215 <script src="gr-diff-line.js"></script>
216 <script src="gr-diff-group.js"></script>
Andrew Bonventre78792e82016-03-04 17:48:22 -0500217 <script src="gr-diff.js"></script>
218</dom-module>