Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Clone element to just get the fonts used in it and not its descendants

as far as possible (default fonts will still be highlighted even when
they are not directly used inside an element due to the use of
textContent)
  • Loading branch information...
commit 6cef601efa7c13a4f9225f58f849b1cc3433d2de 1 parent 6d9afe3
@SebastianZ SebastianZ authored
View
9 extension/content/firebug/css/cssElementPanel.js
@@ -720,7 +720,14 @@ function getFontPropValueParts(element, value)
fonts = matches[1].split(",");
}
- var usedFonts = Fonts.getFonts(element);
+ // Clone the element to just get the fonts used in it and not its descendants
+ var clonedElement = element.cloneNode(false);
+ clonedElement.textContent = element.textContent;
+ Firebug.setIgnored(clonedElement);
+ element.parentNode.appendChild(clonedElement);
+ var usedFonts = Fonts.getFonts(clonedElement);
+ clonedElement.parentNode.removeChild(clonedElement);
+
var genericFontUsed = false;
for (; i < fonts.length; ++i)
{
View
14 extension/content/firebug/lib/fonts.js
@@ -30,12 +30,24 @@ Fonts.getFonts = function(node)
return [];
var range = node.ownerDocument.createRange();
- range.selectNode(node);
+ try
+ {
+ range.selectNode(node);
+ }
+ catch(err)
+ {
+ if (FBTrace.DBG_FONTS || FBTrace.DBG_ERRORS)
+ FBTrace.sysout("Fonts.getFonts; node couldn't be selected", err);
+ }
+
var fontFaces = Dom.domUtils.getUsedFontFaces(range);
var fonts = [];
for (var i=0; i<fontFaces.length; i++)
fonts.push(fontFaces.item(i));
+ if (FBTrace.DBG_FONTS)
+ FBTrace.sysout("Fonts.getFonts; used fonts", fonts);
+
return fonts;
}
Please sign in to comment.
Something went wrong with that request. Please try again.