"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/cssInspector.jsm" between
bluegriffon-3.0.1.tar.gz and bluegriffon-3.1.tar.gz

About: BlueGriffon is a Wysiwyg Web editor (based on the rendering engine of Firefox).

cssInspector.jsm  (bluegriffon-3.0.1):cssInspector.jsm  (bluegriffon-3.1)
skipping to change at line 169 skipping to change at line 169
return null; return null;
}, },
serializeFileStyleSheet: function(aSheet, aHref) serializeFileStyleSheet: function(aSheet, aHref)
{ {
var cssRules = aSheet.cssRules; var cssRules = aSheet.cssRules;
var str = ""; var str = "";
for (var i = 0; i < cssRules.length; i++) for (var i = 0; i < cssRules.length; i++)
{ {
var rule = cssRules[i]; var rule = cssRules[i];
switch (rule.type) str += (i ? "\n" : "") + rule.cssText + "\n";
{
case Components.interfaces.nsIDOMCSSRule.STYLE_RULE:
{
str += (i ? "\n" : "") + rule.selectorText + " {\n " +
rule.style.cssText.replace( /;/g , ";\n");
str += "}\n";
}
break;
default:
str += (i ? "\n" : "") + rule.cssText;
break;
}
} }
var cssParser = new CSSParser(str); var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var cssParser = new CSSParser(str, (prefs.getCharPref("bluegriffon.css.seria
lization") != "shorthands"));
if (str) { if (str) {
var parsedSheet = cssParser.parse(str, false, false); var parsedSheet = cssParser.parse(str, false, false);
str = parsedSheet.cssText(); str = parsedSheet.cssText();
} }
const classes = Components.classes; const classes = Components.classes;
const interfaces = Components.interfaces; const interfaces = Components.interfaces;
const nsILocalFile = interfaces.nsILocalFile; const nsILocalFile = interfaces.nsILocalFile;
const nsIFileOutputStream = interfaces.nsIFileOutputStream; const nsIFileOutputStream = interfaces.nsIFileOutputStream;
const FILEOUT_CTRID = '@mozilla.org/network/file-output-stream;1'; const FILEOUT_CTRID = '@mozilla.org/network/file-output-stream;1';
skipping to change at line 2267 skipping to change at line 2257
this.pushback(); this.pushback();
} }
if (c == "/" && this.peek() == "*") if (c == "/" && this.peek() == "*")
return this.parseComment(c); return this.parseComment(c);
return new jscsspToken(jscsspToken.SYMBOL_TYPE, c); return new jscsspToken(jscsspToken.SYMBOL_TYPE, c);
} }
}; };
function CSSParser(aString) function CSSParser(aString, aExpandShorthands)
{ {
this.mToken = null; this.mToken = null;
this.mLookAhead = null; this.mLookAhead = null;
this.mScanner = new CSSScanner(aString); this.mScanner = new CSSScanner(aString);
this.expandShorthands = aExpandShorthands ? true : false;
this.mPreserveWS = true; this.mPreserveWS = true;
this.mPreserveComments = true; this.mPreserveComments = true;
this.mPreservedTokens = []; this.mPreservedTokens = [];
this.mError = null; this.mError = null;
} }
CSSParser.prototype = { CSSParser.prototype = {
skipping to change at line 2998 skipping to change at line 2990
// expecting block start // expecting block start
if (token.isSymbol("{")) { if (token.isSymbol("{")) {
s += " " + token.value; s += " " + token.value;
var token = this.getToken(true, false); var token = this.getToken(true, false);
while (true) { while (true) {
if (token.isSymbol("}")) { if (token.isSymbol("}")) {
s += "}"; s += "}";
valid = true; valid = true;
break; break;
} else { } else {
var d = this.parseDeclaration(token, declarations, true, true, aShee t); var d = this.parseDeclaration(token, declarations, true, this.expand Shorthands, aSheet);
s += ((d && declarations.length) ? " " : "") + d; s += ((d && declarations.length) ? " " : "") + d;
} }
token = this.getToken(true, false); token = this.getToken(true, false);
} }
} }
} }
if (valid) { if (valid) {
this.forgetState(); this.forgetState();
var rule = new jscsspPageRule(); var rule = new jscsspPageRule();
rule.currentLine = currentLine; rule.currentLine = currentLine;
skipping to change at line 4430 skipping to change at line 4422
while (true) { while (true) {
if (!token.isNotNull()) { if (!token.isNotNull()) {
valid = true; valid = true;
break; break;
} }
if (token.isSymbol("}")) { if (token.isSymbol("}")) {
s += "}"; s += "}";
valid = true; valid = true;
break; break;
} else { } else {
var d = this.parseDeclaration(token, declarations, true, true, aOwne r); var d = this.parseDeclaration(token, declarations, true, this.expand Shorthands, aOwner);
s += ((d && declarations.length) ? " " : "") + d; s += ((d && declarations.length) ? " " : "") + d;
} }
token = this.getToken(true, false); token = this.getToken(true, false);
} }
} }
} }
else { else {
// key is invalid so the whole rule is invalid with it // key is invalid so the whole rule is invalid with it
} }
skipping to change at line 4465 skipping to change at line 4457
}, },
parseMediaRule: function(aToken, aSheet) { parseMediaRule: function(aToken, aSheet) {
var currentLine = CountLF(this.mScanner.getAlreadyScanned()); var currentLine = CountLF(this.mScanner.getAlreadyScanned());
var s = aToken.value; var s = aToken.value;
var valid = false; var valid = false;
var mediaRule = new jscsspMediaRule(); var mediaRule = new jscsspMediaRule();
mediaRule.currentLine = currentLine; mediaRule.currentLine = currentLine;
this.preserveState(); this.preserveState();
var token = this.getToken(true, true); var token = this.getToken(true, true);
var foundMedia = false;
// parse media list
var mediaText = "";
while (token.isNotNull()) { while (token.isNotNull()) {
if (token.isIdent()) { s += " " + token.value;
foundMedia = true; mediaText += (mediaText ? " " : "") + token.value;
s += " " + token.value; token = this.getToken(true, true);
mediaRule.media.push(token.value);
token = this.getToken(true, true); if (token.isSymbol(",")) {
if (token.isSymbol(",")) { mediaRule.media.push(mediaText);
s += ","; mediaText = "";
} else { s += ",";
if (token.isSymbol("{"))
this.ungetToken();
else {
// error...
token.type = jscsspToken.NULL_TYPE;
break;
}
}
} }
else if (token.isSymbol("{")) else if (token.isSymbol("{")) {
break; mediaRule.media.push(mediaText);
else if (foundMedia) {
token.type = jscsspToken.NULL_TYPE;
// not a media list
break; break;
} }
token = this.getToken(true, true);
} }
if (token.isSymbol("{") && mediaRule.media.length) { if (token.isSymbol("{") && mediaRule.media.length) {
// ok let's parse style rules now... // ok let's parse style rules now...
s += " { "; s += " { ";
token = this.getToken(true, false); token = this.getToken(true, false);
while (token.isNotNull()) { while (token.isNotNull()) {
if (token.isComment()) { if (token.isComment()) {
if (this.mPreserveComments) { if (this.mPreserveComments) {
s += " " + token.value; s += " " + token.value;
var comment = new jscsspComment(); var comment = new jscsspComment();
comment.parsedCssText = token.value; comment.parsedCssText = token.value;
skipping to change at line 4562 skipping to change at line 4545
while (true) { while (true) {
if (!token.isNotNull()) { if (!token.isNotNull()) {
valid = true; valid = true;
break; break;
} }
if (token.isSymbol("}")) { if (token.isSymbol("}")) {
s += "}"; s += "}";
valid = true; valid = true;
break; break;
} else { } else {
var d = this.parseDeclaration(token, declarations, true, true, aOwne r); var d = this.parseDeclaration(token, declarations, true, this.expand Shorthands, aOwner);
s += ((d && declarations.length) ? " " : "") + d; s += ((d && declarations.length) ? " " : "") + d;
} }
token = this.getToken(true, false); token = this.getToken(true, false);
} }
} }
} }
else { else {
// selector is invalid so the whole rule is invalid with it // selector is invalid so the whole rule is invalid with it
} }
 End of changes. 12 change blocks. 
41 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)