Permalink
Browse files

Merge branch 'master' of github.com:firebug/firebug

  • Loading branch information...
2 parents 8e3fdb8 + 0c933c8 commit ccbf42d7d6116a4f6ec8e1e8ce136bacbeca7e22 @janodvarko janodvarko committed May 18, 2012
Showing with 838 additions and 318 deletions.
  1. +7 −8 extension/content/firebug/css/computedPanel.js
  2. +28 −16 extension/content/firebug/css/cssModule.js
  3. +78 −21 extension/content/firebug/css/cssPanel.js
  4. +46 −35 extension/content/firebug/css/stylePanel.js
  5. +67 −33 extension/content/firebug/editor/editor.js
  6. +6 −5 extension/content/firebug/html/htmlPanel.js
  7. +180 −138 extension/content/firebug/lib/css.js
  8. +7 −8 tests/FBTest/content/FBTestFirebug.js
  9. +8 −4 tests/content/chrome/1883/issue1883.js
  10. +1 −0 tests/content/commandLine/2934/issue2934.html
  11. +1 −0 tests/content/commandLine/3363/issue3363.html
  12. +1 −0 tests/content/commandLine/3599/issue3599.html
  13. +1 −0 tests/content/commandLine/3703/issue3703.html
  14. +1 −0 tests/content/commandLine/3709/issue3709.htm
  15. +1 −0 tests/content/commandLine/4209/issue4209.html
  16. +1 −0 tests/content/commandLine/4234/issue4234.html
  17. +1 −0 tests/content/commandLine/4391/issue4391.html
  18. +1 −0 tests/content/commandLine/4453/issue4453.html
  19. +4 −3 tests/content/css/4411/issue4411.js
  20. +2 −1 tests/content/css/5262/issue5262.js
  21. +38 −0 tests/content/css/5430/issue5430.html
  22. +23 −0 tests/content/css/5430/issue5430.js
  23. +41 −0 tests/content/css/5461/issue5461.html
  24. +42 −0 tests/content/css/5461/issue5461.js
  25. +1 −1 tests/content/css/{ → computed}/3207/issue3207.html
  26. +2 −2 tests/content/css/{ → computed}/3207/issue3207.js
  27. BIN tests/content/css/computed/5449/firebug.png
  28. +48 −0 tests/content/css/computed/5449/issue5449.html
  29. +97 −0 tests/content/css/computed/5449/issue5449.js
  30. +33 −0 tests/content/css/computed/5451/issue5451.html
  31. +20 −0 tests/content/css/computed/5451/issue5451.js
  32. +5 −1 tests/content/firebug.html
  33. +46 −42 tests/content/firebug/4553/issue4553.html
@@ -570,19 +570,19 @@ CSSComputedPanel.prototype = Obj.extend(Firebug.Panel,
{
var propInfo = Firebug.getRepObject(target);
- var text = propInfo.value;
+ var prop = propInfo.property, value = propInfo.value;
var cssValue;
- if (propInfo.property == "font" || propInfo.property == "font-family")
+ if (prop == "font" || prop == "font-family")
{
- if (text.charAt(rangeOffset) == ",")
+ if (value.charAt(rangeOffset) == ",")
return;
- cssValue = Firebug.CSSModule.parseCSSFontFamilyValue(text, rangeOffset, true);
+ cssValue = Firebug.CSSModule.parseCSSFontFamilyValue(value, rangeOffset, prop);
}
else
{
- cssValue = Firebug.CSSModule.parseCSSValue(text, rangeOffset);
+ cssValue = Firebug.CSSModule.parseCSSValue(value, rangeOffset);
}
if (!cssValue)
@@ -604,13 +604,12 @@ CSSComputedPanel.prototype = Obj.extend(Firebug.Panel,
return CSSInfoTip.populateColorInfoTip(infoTip, cssValue.value);
case "url":
- if (Css.isImageRule(Xml.getElementSimpleType(Firebug.getRepObject(target)),
- propInfo.property))
+ if (Css.isImageRule(Xml.getElementSimpleType(Firebug.getRepObject(target)), prop))
{
var baseURL = propInfo.href || propInfo.matchedSelectors[0].href;
var relURL = Firebug.CSSModule.parseURLValue(cssValue.value);
var absURL = Url.isDataURL(relURL) ? relURL : Url.absoluteURL(relURL, baseURL);
- var repeat = Firebug.CSSModule.parseRepeatValue(text);
+ var repeat = Firebug.CSSModule.parseRepeatValue(value);
this.infoTipType = "image";
this.infoTipObject = absURL;
@@ -289,24 +289,30 @@ Firebug.CSSModule = Obj.extend(Obj.extend(Firebug.Module, Firebug.EditorSelector
return cssValue;
},
- parseCSSFontFamilyValue: function(value, offset)
+ parseCSSFontFamilyValue: function(value, offset, propName)
{
- const reFontFamilies = new RegExp("(^(.*(\\d+(\\.\\d+)?"+
- "(em|ex|ch|rem|cm|mm|in|pt|pc|px|%)|(x{1,2}-)?(small|large)|medium|larger|smaller) )"+
- "(.*?)|.*?)(\s*!.*)?$");
- var matches = reFontFamilies.exec(value);
-
- // Parse things that aren't font names as regular CSS properties.
- if (!matches ||
- (matches[2] && offset < matches[2].length) ||
- (matches[9] && offset >= matches[0].length - matches[9].length))
+ var skipped = 0;
+ if (propName === "font")
{
- return this.parseCSSValue(value, offset);
+ var rePreFont = new RegExp(
+ "^.*" + // anything, then
+ "(" +
+ "\\d+(\\.\\d+)?([a-z]*|%)|" + // a number (with possible unit)
+ "(x{1,2}-)?(small|large)|medium|larger|smaller" + // or an named size description
+ ") "
+ );
+ var m = rePreFont.exec(value);
+ if (!m || offset < m[0].length)
+ return this.parseCSSValue(value, offset);
+ skipped = m[0].length;
+ value = value.substr(skipped);
+ offset -= skipped;
}
- var fonts = matches[matches[8] ? 8 : 1].split(",");
+ var matches = /^(.*?)(\s*!.*)?$/.exec(value);
+ var fonts = matches[1].split(",");
- var totalLength = matches[2] ? matches[2].length : 0;
+ var totalLength = 0;
for (var i = 0; i < fonts.length; ++i)
{
totalLength += fonts[i].length;
@@ -318,8 +324,8 @@ Firebug.CSSModule = Obj.extend(Obj.extend(Firebug.Module, Firebug.EditorSelector
var start = end - font.length;
return {
value: font,
- start: start,
- end: end,
+ start: start + skipped,
+ end: end + skipped,
type: "fontFamily"
};
}
@@ -329,7 +335,13 @@ Firebug.CSSModule = Obj.extend(Obj.extend(Firebug.Module, Firebug.EditorSelector
}
// Parse !important.
- return this.parseCSSValue(value, offset);
+ var ret = this.parseCSSValue(value, offset);
+ if (ret)
+ {
+ ret.start += skipped;
+ ret.end += skipped;
+ }
+ return ret;
},
parseURLValue: function(value)
@@ -1031,28 +1031,18 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
);
}
- if (this.selection instanceof window.Element)
+ if (!Url.isSystemStyleSheet(this.selection))
{
items.push(
"-",
{
- label: "EditStyle",
- tooltiptext: "style.tip.Edit_Style",
- command: Obj.bindFixed(this.editElementStyle, this)
+ label: "NewRule",
+ tooltiptext: "css.tip.New_Rule",
+ id: "fbNewCSSRule",
+ command: Obj.bindFixed(this.insertRule, this, target)
}
);
}
- else if (!Url.isSystemStyleSheet(this.selection))
- {
- items.push(
- "-",
- {
- label: "NewRule",
- tooltiptext: "css.tip.New_Rule",
- command: Obj.bindFixed(this.insertRule, this, target)
- }
- );
- }
if (Css.hasClass(target, "cssSelector"))
{
@@ -1164,7 +1154,7 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
if (text.charAt(rangeOffset) == ",")
return;
- cssValue = Firebug.CSSModule.parseCSSFontFamilyValue(text, rangeOffset, true);
+ cssValue = Firebug.CSSModule.parseCSSFontFamilyValue(text, rangeOffset, propName);
}
else
{
@@ -1689,12 +1679,12 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
var propRow = Dom.getAncestorByClass(this.target, "cssProp");
var propName = Dom.getChildByClass(propRow, "cssPropName").textContent.toLowerCase();
if (propName == "font" || propName == "font-family")
- return Firebug.CSSModule.parseCSSFontFamilyValue(value, offset);
+ return Firebug.CSSModule.parseCSSFontFamilyValue(value, offset, propName);
else
return Firebug.CSSModule.parseCSSValue(value, offset);
},
- getAutoCompleteList: function(preExpr, expr, postExpr)
+ getAutoCompleteList: function(preExpr, expr, postExpr, range, cycle)
{
if (Dom.getAncestorByClass(this.target, "importRule"))
{
@@ -1717,10 +1707,11 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
var row = Dom.getAncestorByClass(this.target, "cssProp");
var propName = Dom.getChildByClass(row, "cssPropName").textContent;
var nodeType = Xml.getElementSimpleType(Firebug.getRepObject(this.target));
- var keywords = Css.getCSSKeywordsByProperty(nodeType, propName);
- if (propName === "font" || propName === "font-family")
+ var keywords;
+ if (range.type === "fontFamily")
{
+ keywords = Css.cssKeywords["fontFamily"].slice();
if (this.panel && this.panel.context)
{
// Add the fonts used in this context (they might be inaccessible
@@ -1745,10 +1736,66 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
}
}
}
+ else
+ {
+ var lowerProp = propName.toLowerCase(), avoid;
+ if (["background", "border", "font"].indexOf(lowerProp) !== -1)
+ {
+ if (cycle)
+ {
+ // Cycle only within the same category, if possible.
+ var cat = Css.getCSSShorthandCategory(nodeType, lowerProp, expr);
+ if (cat)
+ return (cat in Css.cssKeywords ? Css.cssKeywords[cat] : [cat]);
+ }
+ else
+ {
+ // Avoid repeated properties. We assume the values to be solely
+ // space-separated tokens, within a comma-separated part (like
+ // for CSS3 multiple backgrounds). This is absolutely wrong, but
+ // good enough in practice because non-tokens for which it fails
+ // likely aren't in any category.
+ // "background-position" and "background-repeat" values can occur
+ // twice, so they are special-cased.
+ avoid = [];
+ var preTokens = preExpr.split(",").reverse()[0].split(" ");
+ var postTokens = postExpr.split(",")[0].split(" ");
+ var tokens = preTokens.concat(postTokens);
+ for (var i = 0; i < tokens.length; ++i)
+ {
+ var cat = Css.getCSSShorthandCategory(nodeType, lowerProp, tokens[i]);
+ if (cat && cat !== "position" && cat !== "bgRepeat")
+ avoid.push(cat);
+ }
+ }
+ }
+ keywords = Css.getCSSKeywordsByProperty(nodeType, propName, avoid);
+ }
+
+ // Add the magic inherit property, if it's sufficiently alone.
+ if (!preExpr)
+ keywords = keywords.concat(["inherit"]);
return keywords;
}
},
+ getAutoCompletePropSeparator: function(range, expr, prefixOf)
+ {
+ if (!Css.hasClass(this.target, "cssPropValue"))
+ return null;
+
+ // For non-multi-valued properties, fail (expanding 'background-repeat: repeat'
+ // into 'no-repeat' should work).
+ var row = Dom.getAncestorByClass(this.target, "cssProp");
+ var propName = Dom.getChildByClass(row, "cssPropName").textContent;
+ if (!Css.multiValuedProperties.hasOwnProperty(propName))
+ return null;
+
+ if (range.type === "fontFamily")
+ return ",";
+ return " ";
+ },
+
doIncrementValue: function(value, amt, offset, offsetEnd)
{
var propName = null;
@@ -2107,7 +2154,7 @@ CSSRuleEditor.prototype = domplate(Firebug.InlineEditor.prototype,
return {start: start, end: end};
},
- getAutoCompleteList: function(preExpr, expr, postExpr, context, out)
+ getAutoCompleteList: function(preExpr, expr, postExpr, range, cycle, context, out)
{
if (!Css.hasClass(this.target, "cssSelector"))
return [];
@@ -2265,6 +2312,16 @@ CSSRuleEditor.prototype = domplate(Firebug.InlineEditor.prototype,
return ret.sort();
},
+ getAutoCompletePropSeparator: function(range, expr, prefixOf)
+ {
+ if (!Css.hasClass(this.target, "cssSelector"))
+ return null;
+
+ // For e.g. 'd|span', expand to a descendant selector; otherwise assume
+ // that this is part of the same selector part.
+ return (reSelectorChar.test(prefixOf.charAt(0)) ? " " : "");
+ },
+
advanceToNext: function(target, charCode)
{
if (charCode == 123 /* "{" */)
Oops, something went wrong.

0 comments on commit ccbf42d

Please sign in to comment.