Bug 1413314 - Change precise increment to Ctrl instead of Alt for Linux compat; r=jryans

MozReview-Commit-ID: ErTw1XnmWV5

--HG--
extra : rebase_source : 536e23ebbe54a4d5649c26d703b8b7f86a956af9
This commit is contained in:
abhinav 2018-01-26 23:36:21 +05:30
Родитель cd13369f51
Коммит f60bc551a5
2 изменённых файлов: 37 добавлений и 12 удалений

Просмотреть файл

@ -10,6 +10,8 @@
// Bug 1275446 - This test happen to hit the default timeout on linux32
requestLongerTimeout(2);
loader.lazyRequireGetter(this, "system", "devtools/shared/system");
const TEST_URI = `
<style>
#test {
@ -50,10 +52,11 @@ function* testMarginIncrements(view) {
let marginPropEditor = idRuleEditor.rule.textProps[0].editor;
yield runIncrementTest(marginPropEditor, view, {
1: {alt: true, start: "0px", end: "0.1px", selectAll: true},
1: { ...getSmallIncrementKey(), start: "0px", end: "0.1px", selectAll: true},
2: {start: "0px", end: "1px", selectAll: true},
3: {shift: true, start: "0px", end: "10px", selectAll: true},
4: {down: true, alt: true, start: "0.1px", end: "0px", selectAll: true},
4: {down: true, ...getSmallIncrementKey(), start: "0.1px",
end: "0px", selectAll: true},
5: {down: true, start: "0px", end: "-1px", selectAll: true},
6: {down: true, shift: true, start: "0px", end: "-10px", selectAll: true},
7: {pageUp: true, shift: true, start: "0px", end: "100px", selectAll: true},
@ -157,7 +160,7 @@ function* testShorthandIncrements(view) {
end: "-10px 0px 0px 0px", selectAll: true},
7: {up: true, start: "0.1em .1em 0em 0em", end: "0.1em 1.1em 0em 0em",
selection: [6, 9]},
8: {up: true, alt: true, start: "0.1em .9em 0em 0em",
8: {up: true, ...getSmallIncrementKey(), start: "0.1em .9em 0em 0em",
end: "0.1em 1em 0em 0em", selection: [6, 9]},
9: {up: true, shift: true, start: "0.2em .2em 0em 0em",
end: "0.2em 10.2em 0em 0em", selection: [6, 9]}
@ -172,7 +175,7 @@ function* testOddCases(view) {
yield runIncrementTest(marginPropEditor, view, {
1: {start: "98.7%", end: "99.7%", selection: [3, 3]},
2: {alt: true, start: "98.7%", end: "98.8%", selection: [3, 3]},
2: {...getSmallIncrementKey(), start: "98.7%", end: "98.8%", selection: [3, 3]},
3: {start: "0", end: "1px"},
4: {down: true, start: "0", end: "-1px"},
5: {start: "'a=-1'", end: "'a=0'", selection: [4, 4]},
@ -187,10 +190,10 @@ function* testOddCases(view) {
selection: [9, 11]},
12: {start: "url('test1.1.png')", end: "url('test1.2.png')",
selection: [11, 12]},
13: {down: true, alt: true, start: "url('test-0.png')",
13: {down: true, ...getSmallIncrementKey(), start: "url('test-0.png')",
end: "url('test--0.1.png')", selection: [10, 11]},
14: {alt: true, start: "url('test--0.1.png')", end: "url('test-0.png')",
selection: [10, 14]}
14: {...getSmallIncrementKey(), start: "url('test--0.1.png')",
end: "url('test-0.png')", selection: [10, 14]}
});
}
@ -236,10 +239,11 @@ function* testOpacityIncrements(view) {
let opacityPropEditor = idRuleEditor.rule.textProps[7].editor;
yield runIncrementTest(opacityPropEditor, view, {
1: {alt: true, start: "0.5", end: "0.51", selectAll: true},
1: {...getSmallIncrementKey(), start: "0.5", end: "0.51", selectAll: true},
2: {start: "0", end: "0.1", selectAll: true},
3: {shift: true, start: "0", end: "1", selectAll: true},
4: {down: true, alt: true, start: "0.1", end: "0.09", selectAll: true},
4: {down: true, ...getSmallIncrementKey(), start: "0.1",
end: "0.09", selectAll: true},
5: {down: true, start: "0", end: "-0.1", selectAll: true},
6: {down: true, shift: true, start: "0", end: "-1", selectAll: true},
7: {pageUp: true, shift: true, start: "0", end: "10", selectAll: true},
@ -289,7 +293,12 @@ function* testIncrement(editor, options, view) {
key = "VK_PAGE_UP";
}
EventUtils.synthesizeKey(key, {altKey: options.alt, shiftKey: options.shift},
let smallIncrementKey = {ctrlKey: options.ctrl};
if (system.constants.platform === "macosx") {
smallIncrementKey = {altKey: options.alt};
}
EventUtils.synthesizeKey(key, {...smallIncrementKey, shiftKey: options.shift},
view.styleWindow);
yield onKeyUp;
@ -302,3 +311,10 @@ function* testIncrement(editor, options, view) {
is(input.value, options.end, "Value changed to " + options.end);
}
function getSmallIncrementKey() {
if (system.constants.platform === "macosx") {
return { alt: true };
}
return { ctrl: true };
}

Просмотреть файл

@ -27,6 +27,8 @@ const Services = require("Services");
const focusManager = Services.focus;
const {KeyCodes} = require("devtools/client/shared/keycodes");
loader.lazyRequireGetter(this, "system", "devtools/shared/system");
const HTML_NS = "http://www.w3.org/1999/xhtml";
const CONTENT_TYPES = {
PLAIN_TEXT: 0,
@ -1206,6 +1208,13 @@ InplaceEditor.prototype = {
* Get the increment/decrement step to use for the provided key event.
*/
_getIncrement: function (event) {
const getSmallIncrementKey = (evt) => {
if (system.constants.platform === "macosx") {
return evt.altKey;
}
return evt.ctrlKey;
};
const largeIncrement = 100;
const mediumIncrement = 10;
const smallIncrement = 0.1;
@ -1219,13 +1228,13 @@ InplaceEditor.prototype = {
increment = -1 * this.defaultIncrement;
}
if (event.shiftKey && !event.altKey) {
if (event.shiftKey && !getSmallIncrementKey(event)) {
if (isKeyIn(key, "PAGE_UP", "PAGE_DOWN")) {
increment *= largeIncrement;
} else {
increment *= mediumIncrement;
}
} else if (event.altKey && !event.shiftKey) {
} else if (getSmallIncrementKey(event) && !event.shiftKey) {
increment *= smallIncrement;
}