Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #418 from Gozala/bug/multi-head

ace modules can't be shared across windows - Issue #417
  • Loading branch information...
commit bf638def802213136572b5944505ea294daacc24 2 parents c912a36 + 190ed05
@fjakobs fjakobs authored
View
7 lib/ace/layer/text.js
@@ -23,6 +23,7 @@
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian DOT viereck AT gmail DOT com>
* Mihai Sucan <mihai.sucan@gmail.com>
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -121,8 +122,8 @@ var Text = function(parentEl) {
// Note: characterWidth can be a float!
measureNode.innerHTML = lang.stringRepeat("Xy", n);
- if (document.body) {
- document.body.appendChild(measureNode);
+ if (this.element.ownerDocument.body) {
+ this.element.ownerDocument.body.appendChild(measureNode);
} else {
var container = this.element.parentNode;
while (!dom.hasCssClass(container, "ace_editor"))
@@ -257,7 +258,7 @@ var Text = function(parentEl) {
};
this.$renderLinesFragment = function(config, firstRow, lastRow) {
- var fragment = document.createDocumentFragment(),
+ var fragment = this.element.ownerDocument.createDocumentFragment(),
row = firstRow,
fold = this.session.getNextFold(row),
foldStart = fold ?fold.start.row :Infinity;
View
40 lib/ace/renderloop.js
@@ -20,6 +20,7 @@
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -39,10 +40,11 @@ define(function(require, exports, module) {
var event = require("pilot/event");
-var RenderLoop = function(onRender) {
+var RenderLoop = function(onRender, window) {
this.onRender = onRender;
this.pending = false;
this.changes = 0;
+ this.setTimeoutZero = this.setTimeoutZero.bind(window);
};
(function() {
@@ -70,31 +72,31 @@ var RenderLoop = function(onRender) {
window.msRequestAnimationFrame;
if (this.setTimeoutZero) {
-
- this.setTimeoutZero = this.setTimeoutZero.bind(window)
+ this.setTimeoutZero = this.setTimeoutZero;
} else if (window.postMessage) {
- this.messageName = "zero-timeout-message";
+ this.setTimeoutZero = (function(messageName, attached, listener) {
+ return function setTimeoutZero(callback) {
+ // Set up listener if not listening already.
+ if (!attached) {
+ event.addListener(this, "message", function(e) {
+ if (listener && e.data == messageName) {
+ event.stopPropagation(e);
+ listener();
+ }
+ });
+ attached = true;
+ }
- this.setTimeoutZero = function(callback) {
- if (!this.attached) {
- var _self = this;
- event.addListener(window, "message", function(e) {
- if (_self.callback && e.data == _self.messageName) {
- event.stopPropagation(e);
- _self.callback();
- }
- });
- this.attached = true;
- }
- this.callback = callback;
- window.postMessage(this.messageName, "*");
- }
+ listener = callback;
+ this.postMessage(messageName, "*");
+ };
+ })("zero-timeout-message", false, null);
} else {
this.setTimeoutZero = function(callback) {
- setTimeout(callback, 0);
+ this.setTimeout(callback, 0);
}
}
View
3  lib/ace/scrollbar.js
@@ -20,6 +20,7 @@
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -56,7 +57,7 @@ var ScrollBar = function(parent) {
// of 0px
// in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
// make element a little bit wider to retain scrollbar when page is zoomed
- this.width = dom.scrollbarWidth();
+ this.width = dom.scrollbarWidth(parent.ownerDocument);
this.element.style.width = (this.width || 15) + 5 + "px";
event.addListener(this.element, "scroll", this.onScroll.bind(this));
View
11 lib/ace/theme/clouds.js
@@ -37,9 +37,8 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-clouds .ace_editor {\
+exports.cssClass = "ace-clouds";
+exports.cssText = ".ace-clouds .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -252,8 +251,4 @@ define(function(require, exports, module) {
\
}";
- // import CSS once
- dom.importCssString(cssText);
-
- exports.cssClass = "ace-clouds";
-});
+});
View
11 lib/ace/theme/clouds_midnight.js
@@ -37,9 +37,8 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-clouds-midnight .ace_editor {\
+exports.cssClass = "ace-clouds-midnight";
+exports.cssText = ".ace-clouds-midnight .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -253,8 +252,4 @@ background-color:#E92E2E;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
-
- exports.cssClass = "ace-clouds-midnight";
-});
+});
View
11 lib/ace/theme/cobalt.js
@@ -37,9 +37,8 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-cobalt .ace_editor {\
+exports.cssClass = "ace-cobalt";
+exports.cssText = ".ace-cobalt .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -255,8 +254,4 @@ background-color:#001221;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
-
- exports.cssClass = "ace-cobalt";
-});
+});
View
8 lib/ace/theme/crimson_editor.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-crimson-editor .ace_editor {\
+exports.cssText = ".ace-crimson-editor .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -195,8 +193,6 @@ define(function(require, exports, module) {
color: rgb(192, 0, 192);\
}";
- // Import CSS once.
- dom.importCssString(cssText);
+exports.cssClass = "ace-crimson-editor";
- exports.cssClass = "ace-crimson-editor";
});
View
10 lib/ace/theme/dawn.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-dawn .ace_editor {\
+exports.cssText = ".ace-dawn .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -258,8 +256,6 @@ color:#5A525F;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-dawn";
- exports.cssClass = "ace-dawn";
-});
+});
View
8 lib/ace/theme/eclipse.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-eclipse .ace_editor {\
+exports.cssText = ".ace-eclipse .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -143,8 +141,6 @@ define(function(require, exports, module) {
background: rgb(232, 242, 254);\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-eclipse";
- exports.cssClass = "ace-eclipse";
});
View
10 lib/ace/theme/idle_fingers.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-idle-fingers .ace_editor {\
+exports.cssText = ".ace-idle-fingers .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -255,8 +253,6 @@ color:#BC9458;\
background-color:#FFF980; \
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-idle-fingers";
- exports.cssClass = "ace-idle-fingers";
-});
+});
View
10 lib/ace/theme/kr_theme.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-kr-theme .ace_editor {\
+exports.cssText = ".ace-kr-theme .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -254,8 +252,6 @@ color:#706D5B;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-kr-theme";
- exports.cssClass = "ace-kr-theme";
-});
+});
View
10 lib/ace/theme/merbivore.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-merbivore .ace_editor {\
+exports.cssText = ".ace-merbivore .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -246,8 +244,6 @@ background-color:#990000;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-merbivore";
- exports.cssClass = "ace-merbivore";
-});
+});
View
10 lib/ace/theme/merbivore_soft.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-merbivore-soft .ace_editor {\
+exports.cssText = ".ace-merbivore-soft .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -246,8 +244,6 @@ background-color:#FE3838;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-merbivore-soft";
- exports.cssClass = "ace-merbivore-soft";
-});
+});
View
10 lib/ace/theme/mono_industrial.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-mono-industrial .ace_editor {\
+exports.cssText = ".ace-mono-industrial .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -254,8 +252,6 @@ background-color:#151C19;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-mono-industrial";
- exports.cssClass = "ace-mono-industrial";
-});
+});
View
10 lib/ace/theme/monokai.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-monokai .ace_editor {\
+exports.cssText = ".ace-monokai .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -254,8 +252,6 @@ background-color:#AE81FF;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-monokai";
- exports.cssClass = "ace-monokai";
-});
+});
View
8 lib/ace/theme/pastel_on_dark.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-pastel-on-dark .ace_editor {\
+exports.cssText = ".ace-pastel-on-dark .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -195,8 +193,6 @@ color:#D2A8A1;\
color:#494949;\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-pastel-on-dark";
- exports.cssClass = "ace-pastel-on-dark";
});
View
10 lib/ace/theme/solarized_dark.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-solarized-dark .ace_editor {\
+exports.cssText = ".ace-solarized-dark .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -253,8 +251,6 @@ color:#657B83;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-solarized-dark";
- exports.cssClass = "ace-solarized-dark";
-});
+});
View
10 lib/ace/theme/solarized_light.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-solarized-light .ace_editor {\
+exports.cssText = ".ace-solarized-light .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -252,8 +250,6 @@ define(function(require, exports, module) {
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-solarized-light";
- exports.cssClass = "ace-solarized-light";
-});
+});
View
8 lib/ace/theme/textmate.js
@@ -37,9 +37,9 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
- var cssText = ".ace-tm .ace_editor {\
+exports.cssClass = "ace-tm";
+exports.cssText = ".ace-tm .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -206,8 +206,4 @@ define(function(require, exports, module) {
color: rgb(255, 0, 0)\
}";
- // import CSS once
- dom.importCssString(cssText);
-
- exports.cssClass = "ace-tm";
});
View
11 lib/ace/theme/twilight.js
@@ -37,9 +37,8 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-twilight .ace_editor {\
+exports.cssClass = "ace-twilight";
+exports.cssText = ".ace-twilight .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -256,8 +255,4 @@ color:#5F5A60;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
-
- exports.cssClass = "ace-twilight";
-});
+});
View
10 lib/ace/theme/vibrant_ink.js
@@ -37,9 +37,7 @@
define(function(require, exports, module) {
- var dom = require("pilot/dom");
-
- var cssText = ".ace-vibrant-ink .ace_editor {\
+exports.cssText = ".ace-vibrant-ink .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -255,8 +253,6 @@ color:#99CC99;\
\
}";
- // import CSS once
- dom.importCssString(cssText);
+exports.cssClass = "ace-vibrant-ink";
- exports.cssClass = "ace-vibrant-ink";
-});
+});
View
17 lib/ace/virtual_renderer.js
@@ -53,11 +53,11 @@ var RenderLoop = require("ace/renderloop").RenderLoop;
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var editorCss = require("ace/requirejs/text!ace/css/editor.css");
-// import CSS once
-dom.importCssString(editorCss);
-
var VirtualRenderer = function(container, theme) {
this.container = container;
+
+ // Imports CSS once per DOM document ('ace_editor' serves as an identifier).
+ dom.importCssString(editorCss, "ace_editor", container.ownerDocument);
dom.addCssClass(this.container, "ace_editor");
this.setTheme(theme);
@@ -135,7 +135,10 @@ var VirtualRenderer = function(container, theme) {
height : 1
};
- this.$loop = new RenderLoop(this.$renderChanges.bind(this));
+ this.$loop = new RenderLoop(
+ this.$renderChanges.bind(this),
+ this.container.ownerDocument.defaultView
+ );
this.$loop.schedule(this.CHANGE_FULL);
this.setPadding(4);
@@ -800,6 +803,12 @@ var VirtualRenderer = function(container, theme) {
}
function afterLoad(theme) {
+ dom.importCssString(
+ theme.cssText,
+ theme.cssClass,
+ _self.container.ownerDocument
+ );
+
if (_self.$theme)
dom.removeCssClass(_self.container, _self.$theme);
Please sign in to comment.
Something went wrong with that request. Please try again.