Bug 964504 - Add Editor.setFontSize/getFontSize. r=msucan

This commit is contained in:
Anton Kovalyov 2014-01-28 13:48:09 -08:00
parent 5ec39de586
commit 98bf536309
2 changed files with 25 additions and 1 deletions

View File

@ -750,6 +750,25 @@ Editor.prototype = {
{ line: end.line + 1, ch: end.ch });
},
/**
* Returns current font size for the editor area, in pixels.
*/
getFontSize: function () {
let cm = editors.get(this);
let el = cm.getWrapperElement();
let win = el.ownerDocument.defaultView;
return parseInt(win.getComputedStyle(el).getPropertyValue("font-size"), 10);
},
/**
* Sets font size for the editor area.
*/
setFontSize: function (size) {
let cm = editors.get(this);
cm.getWrapperElement().style.fontSize = parseInt(size, 10) + "px";
},
/**
* Extends an instance of the Editor object with additional
* functions. Each function will be called with context as

View File

@ -51,6 +51,11 @@ function test() {
ed.removeLineClass(0, "test");
ok(!ed.hasLineClass(0, "test"), "test line class is gone");
// Font size
is(ed.getFontSize(), 11, "default font size is 11");
ed.setFontSize(ed.getFontSize() + 1);
is(ed.getFontSize(), 12, "new font size is 12");
teardown(ed, win);
});
}
}