Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/ui/progressBar.js

Issue 8329305: Fixed issue reporter`s progress labels for right-to-left languages (Closed)
Patch Set: Created Sept. 18, 2012, 12:54 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/progressBar.js
===================================================================
--- a/chrome/content/ui/progressBar.js
+++ b/chrome/content/ui/progressBar.js
@@ -1,17 +1,17 @@
/*
* This Source Code is subject to the terms of the Mozilla Public License
* version 2.0 (the "License"). You can obtain a copy of the License at
* http://mozilla.org/MPL/2.0/.
*/
(function()
{
- let progressBar, canvas, headers;
+ let progressBar, canvas, headers, isRTL;
function onLoad()
{
window.removeEventListener("load", onLoad, false);
// Init global variables
progressBar = document.getElementById("progressBar");
canvas = document.getElementById("progressBarCanvas");
@@ -21,16 +21,18 @@
canvas.parentNode.appendChild(headers[i]);
// Expose properties
progressBar.__defineGetter__("activeItem", getActiveItem);
progressBar.__defineSetter__("activeItem", setActiveItem);
progressBar.__defineGetter__("activeItemComplete", getActiveItemComplete);
progressBar.__defineSetter__("activeItemComplete", setActiveItemComplete);
+ isRTL = (window.getComputedStyle(document.documentElement).direction == "rtl");
+
// Run actual drawing delayed, once the sizes are fixed
window.setTimeout(init, 0);
};
window.addEventListener("load", onLoad, false);
function init()
{
const gapWidth = 5;
@@ -38,16 +40,21 @@
let width = canvas.width = canvas.offsetWidth;
let height = canvas.height = canvas.offsetHeight;
let context = canvas.getContext("2d");
context.fillStyle = window.getComputedStyle(progressBar, "").color;
context.strokeStyle = window.getComputedStyle(progressBar, "").color;
context.lineWidth = 1;
+ if (isRTL)
+ {
+ context.translate(width, 0);
+ context.scale(-1, 1);
+ }
let panelCount = headers.length;
let panelWidth = (width - gapWidth * (panelCount - 1) - 1) / panelCount;
for (let i = 0; i < panelCount; i++)
{
context.save();
context.translate(Math.round(i * (panelWidth + gapWidth)) + 0.5, 0.5);
context.beginPath();
@@ -64,24 +71,25 @@
context.lineTo(0, (height - 1) / 2);
context.lineTo(-arrowheadWidth, 0);
}
else
{
context.lineTo(0, height - 1);
context.lineTo(0, 0);
}
+
context.stroke();
context.restore();
let childLeft = Math.round(i * (panelWidth + gapWidth) + 1);
let childWidth = panelWidth - arrowheadWidth - 2;
let child = headers[i];
- child.style.marginLeft = childLeft + "px";
- child.style.marginRight = (width - childLeft - childWidth) + "px";
+ child.style.MozMarginStart = childLeft + "px";
+ child.style.MozMarginEnd = (width - childLeft - childWidth) + "px";
child.style.width = childWidth + "px";
}
// Resize after initialization should be ignored
canvas.parentNode.removeAttribute("flex");
}
function getActiveItem()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld