allow cssmanager to manage outer_ace

This commit is contained in:
Chia-liang Kao 2013-06-15 01:37:41 +08:00
parent 548f31a46a
commit f31db205da
3 changed files with 110 additions and 89 deletions

View file

@ -313,7 +313,7 @@ window.onload = function () {\n\
// bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly
// (throbs busy while typing)
outerHTML.push('<link rel="stylesheet" type="text/css" href="data:text/css,"/>', scriptTag(outerScript), '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>');
outerHTML.push('<style type="text/css" title="dynamicsyntax"></style>', '<link rel="stylesheet" type="text/css" href="data:text/css,"/>', scriptTag(outerScript), '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>');
var outerFrame = document.createElement("IFRAME");
outerFrame.name = "ace_outer";

View file

@ -167,12 +167,14 @@ function Ace2Inner(){
}
var dynamicCSS = null;
var outerDynamicCSS = null;
var parentDynamicCSS = null;
function initDynamicCSS()
{
dynamicCSS = makeCSSManager("dynamicsyntax");
parentDynamicCSS = makeCSSManager("dynamicsyntax", true);
outerDynamicCSS = makeCSSManager("dynamicsyntax", "outer");
parentDynamicCSS = makeCSSManager("dynamicsyntax", "parent");
}
var changesetTracker = makeChangesetTracker(scheduler, rep.apool, {
@ -218,6 +220,7 @@ function Ace2Inner(){
var authorStyleSet = hooks.callAll('aceSetAuthorStyle', {
dynamicCSS: dynamicCSS,
parentDynamicCSS: parentDynamicCSS,
outerDynamicCSS: outerDynamicCSS,
info: info,
author: author,
authorSelector: authorSelector,

View file

@ -20,13 +20,31 @@
* limitations under the License.
*/
function makeCSSManager(emptyStylesheetTitle, parentCss)
function makeCSSManager(emptyStylesheetTitle, doc)
{
if (doc === true)
{
doc = 'parent';
} else if (!doc) {
doc = 'inner';
}
function getSheetByTitle(title)
{
if (parentCss) var allSheets = window.parent.parent.document.styleSheets;
else var allSheets = document.styleSheets;
if (doc === 'parent')
{
win = window.parent.parent;
}
else if (doc === 'inner') {
win = window;
}
else if (doc === 'outer') {
win = window.parent;
}
else {
throw "Unknown dynamic style container";
}
var allSheets = win.document.styleSheets;
for (var i = 0; i < allSheets.length; i++)
{
@ -39,7 +57,7 @@ function makeCSSManager(emptyStylesheetTitle, parentCss)
return null;
}
var browserSheet = getSheetByTitle(emptyStylesheetTitle, parentCss);
var browserSheet = getSheetByTitle(emptyStylesheetTitle);
function browserRules()
{