Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/sub-pixel/sub-pixel-border.html

Issue 2566593002: Change handling of sub-pixel borders to round
Patch Set: Change border images to round edges Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Test rendering of sub-pixel borders</title>
6 <style>
7 .test {
8 box-sizing: content-box;
9 display: inline-block;
10 margin: 5px;
11 width: 80px;
12 height: 80px;
13 border: 1px solid green;
14 background: lightgreen;
15 text-align: center;
16 line-height: 80px;
17 }
18 </style>
19 <script src="../../resources/testharness.js"></script>
20 <script src="../../resources/testharnessreport.js"></script>
21 </head>
22 <body>
23 <div class="test" style="border-width: 0.25px">0.25px</div>
24 <div class="test" style="border-width: 0.5px">0.5px</div>
25 <div class="test" style="border-width: 0.75px">0.75px</div>
26 <div class="test" style="border-width: 1px">1px</div>
27 <div class="test" style="border-width: 1.25px">1.25px</div>
28 <br>
29 <div class="test" style="border-width: 1.5px">1.5px</div>
30 <div class="test" style="border-width: 1.75px">1.75px</div>
31 <div class="test" id="reference-2" style="border-width: 2px">2px</div>
32 <div class="test" style="border-width: 2.25px">2.25px</div>
33 <br>
34 <div class="test" style="border-width: 2.5px">2.5px</div>
35 <div class="test" style="border-width: 2.75px">2.75px</div>
36 <div class="test" id="reference-3" style="border-width: 3px">3px</div>
37 <div class="test" style="border-width: 3.25px">3.25px</div>
38 <p>
39 Border thickness should be rounded, not floored, with the exception of
40 values below 1px where it should always round up.
41 </p>
42 <p>
43 Thus the boxes on each line should have the same effective size and
44 border thickness.
45 </p>
46 <script>
47 var testElements = {};
48 var elements = document.getElementsByClassName('test');
49 for (var element, i = 0; element = elements[i]; i++) {
50 testElements[element.firstChild.nodeValue] = element;
51 }
52
53 function sizeAsString(element) {
54 var rect = element.getBoundingClientRect();
55 return rect.width.toFixed(2) + 'x' + rect.height.toFixed(2);
56 }
57
58 function borderAsString(element) {
59 var style = window.getComputedStyle(element);
60 return style.borderTopWidth + ' ' + style.borderRightWidth + ' ' +
61 style.borderBottomWidth + ' ' + style.borderLeftWidth;
62 }
63
64 test(function() {
65 var referenceSize = sizeAsString(testElements['1px']);
66 assert_equals(sizeAsString(testElements['0.25px']), referenceSize,
67 'Size of 0.25px box should match 1px reference.');
68 assert_equals(sizeAsString(testElements['0.5px']), referenceSize,
69 'Size of 0.5px box should match 1px reference.');
70 assert_equals(sizeAsString(testElements['0.75px']), referenceSize,
71 'Size of 0.75px box should match 1px reference.');
72 assert_equals(sizeAsString(testElements['1.25px']), referenceSize,
73 'Size of 1.25px box should match 1px reference.');
74 }, 'Size of all elements on the first row should match.');
75
76 test(function() {
77 assert_equals(borderAsString(testElements['0.25px']),
78 '1px 1px 1px 1px',
79 'Border thickness of 0.25px box should be 1px.');
80 assert_equals(borderAsString(testElements['0.5px']),
81 '1px 1px 1px 1px',
82 'Border thickness of 0.5px box should be 1px.');
83 assert_equals(borderAsString(testElements['0.75px']),
84 '1px 1px 1px 1px',
85 'Border thickness of 0.75px box should be 1px.');
86 assert_equals(borderAsString(testElements['1px']),
87 '1px 1px 1px 1px',
88 'Border thickness of 1px box should be 1px.');
89 assert_equals(borderAsString(testElements['1.25px']),
90 '1px 1px 1px 1px',
91 'Border thickness of 1.25px box should be 1px.');
92 }, 'All elements on the first row should have a 1px border.');
93
94 test(function() {
95 var referenceSize = sizeAsString(testElements['2px']);
96 assert_equals(sizeAsString(testElements['1.5px']), referenceSize,
97 'Size of 1.5px box should match 2px reference.');
98 assert_equals(sizeAsString(testElements['1.75px']), referenceSize,
99 'Size of 1.75px box should match 2px reference.');
100 assert_equals(sizeAsString(testElements['2.25px']), referenceSize,
101 'Size of 2.25px box should match 2px reference.');
102 }, 'Size of all elements on the second row should match.');
103
104 test(function() {
105 assert_equals(borderAsString(testElements['1.5px']),
106 '2px 2px 2px 2px',
107 'Border thickness of 1.5px box should be 2px.');
108 assert_equals(borderAsString(testElements['1.75px']),
109 '2px 2px 2px 2px',
110 'Border thickness of 1.75px box should be 2px.');
111 assert_equals(borderAsString(testElements['2px']),
112 '2px 2px 2px 2px',
113 'Border thickness of 2px box should be 2px.');
114 assert_equals(borderAsString(testElements['2.25px']),
115 '2px 2px 2px 2px',
116 'Border thickness of 2.25px box should be 2px.');
117 }, 'All elements on the first row should have a 2px border.');
118
119 test(function() {
120 var referenceSize = sizeAsString(testElements['3px']);
121 assert_equals(sizeAsString(testElements['2.5px']), referenceSize,
122 'Size of 2.5px box should match 3px reference.');
123 assert_equals(sizeAsString(testElements['2.75px']), referenceSize,
124 'Size of 2.75px box should match 3px reference.');
125 assert_equals(sizeAsString(testElements['3.25px']), referenceSize,
126 'Size of 3.25px box should match 3px reference.');
127 }, 'Size of all elements on the third row should match.');
128
129 test(function() {
130 assert_equals(borderAsString(testElements['2.5px']),
131 '3px 3px 3px 3px',
132 'Border thickness of 2.5px box should be 3px.');
133 assert_equals(borderAsString(testElements['2.75px']),
134 '3px 3px 3px 3px',
135 'Border thickness of 2.75px box should be 3px.');
136 assert_equals(borderAsString(testElements['3px']),
137 '3px 3px 3px 3px',
138 'Border thickness of 3px box should be 3px.');
139 assert_equals(borderAsString(testElements['3.25px']),
140 '3px 3px 3px 3px',
141 'Border thickness of 3.25px box should be 3px.');
142 }, 'All elements on the third row should have a 3px border.');
143 </script>
144 </body>
145 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698