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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-text-baseline-tiny-fonts.html

Issue 2392033002: Correcting text baseline for tiny fonts (Closed)
Patch Set: Fixing flaky layout tests. Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-text-baseline-tiny-fonts.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-text-baseline-tiny-fonts.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-text-baseline-tiny-fonts.html
new file mode 100644
index 0000000000000000000000000000000000000000..5fe24e78987934bbb001504e399d41373ea797a2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-text-baseline-tiny-fonts.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<canvas id="canvas1" width=200 height=250></canvas>
+<canvas id="canvas2" width=250 height=250></canvas>
+<canvas id="canvas3" width=250 height=250></canvas>
+<canvas id="canvas4" width=250 height=250></canvas>
+
+<script>
+if (window.testRunner)
+ window.testRunner.dumpAsTextWithPixelResults();
+
+function draw() {
+ // The code works fine with 1px font size, however testing that makes
+ // the test flaky due to pixel differences.
+ for(i = 2; i <= 4; i++) {
qyearsley 2016/10/14 17:46:44 Nit: Normally there's a space after `for` and befo
+ var ctx = document.getElementById("canvas" + i).getContext("2d");
+ ctx.scale(25, 25);
+ ctx.lineWidth = 0.1;
+
+ ctx.beginPath();
+ ctx.moveTo(0, 5);
+ ctx.lineTo(20, 5);
+ ctx.stroke();
+
+ ctx.font = i + "px sans-serif"
+ ctx.textBaseline = "top"
+ ctx.strokeText("A", 1, 5);
+ ctx.textBaseline = "middle"
+ ctx.strokeText("B", 3, 5);
+ ctx.textBaseline = "alphabetic"
+ ctx.strokeText("C", 5, 5);
+ ctx.textBaseline = "bottom"
qyearsley 2016/10/14 17:46:44 Nit: could add semicolons at the end of each state
+ ctx.strokeText("D", 7, 5);
+ }
+}
+
+window.onload = draw;
+</script>
+
qyearsley 2016/10/14 17:46:44 Nit: extra newline
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698