Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

205 lines
6.4 KiB
HTML
Raw Normal View History

<!--
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;
}
Improves visible tabs rendering This change reverts visible tabs to use the » character. A few different approaches have been used for rendering these tab indicators: I: Before the Annotation Pipeline, tab indicators were configured by a class that was optionally applied to tab elements by the diff builder. The class was guarded by the show_tabs preference and a CSS rule created a `::before` pseudo element to insert the character. (Thus also preventing the » from being copyable text.) II: When the Annotation Pipeline was implemented, the ordering of layers called for intraline difference elements being rendered *inside* tab indicators. As a result, the » indicator would sometimes have a different background than the intraline difference, looking sloppy. To solve this, the pseudo element was positioned using absolute, allowing the pseudo element to consume no horizontal space and and the intraline background to extend across the entire tab. III:When performance tuning, it was discovered that the absolute-positioned tab indicators were positioned incorrectly when GPU acceleration was hinted for the diff, so the containing tab elements were made relative. IV: Continuing performance tuning, the tab indicators seemed to slow scrolling on very large diffs with tabs. It was mistakenly assumed (by me) that this was related to the pseudo-elements when it was actually caused by the thousands of positioning contexts they created using relative and absolute. Instead they were modified to use strike-through instead of a pseudo element, which was more-performant, but less-usable (it looked bad). With this change, we roll-back the clock a little and solve a core problem: namely that tab indicators were not annotated inside the intraline differences. Fixing that, positioning tricks are no-longer needed to make the background look right. To do this, we decouple the tab elements (which control tab width) from the tab indicators (which optionally make tabs visible). This is done using an annotation layer that inserts tab indicator elements wherever a tab character is used in the source content, and it does so after intraline differences have been applied. Bug: Issue 4441 Change-Id: I4fea2a3a20a7039bfeb746bd1e1c1004e43c4801
2016-08-25 11:31:42 -07:00
.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>