Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Finish up issue 2495 (The rendered font should be highlighted in Styl…

  • Loading branch information...
commit 32baad17c14366ebab1b961ad5fd5afd93042b76 1 parent 1f22471
Sebastian Zartner authored September 23, 2012
41  extension/content/firebug/css/stylePanel.js
@@ -837,7 +837,7 @@ function getFontPropValueParts(element, value, propName)
837 837
         "monospace": 1,
838 838
     };
839 839
 
840  
-    var parts = [];
  840
+    var parts = [], origValue = value;
841 841
 
842 842
     // (Mirroring CSSModule.parseCSSFontFamilyValue)
843 843
     if (propName === "font")
@@ -853,7 +853,7 @@ function getFontPropValueParts(element, value, propName)
853 853
         if (!matches)
854 854
         {
855 855
             // Non-simple font value, like "inherit", "status-bar" or
856  
-            // "-moz-calc(12px) Arial" - just return the whole text.
  856
+            // "calc(12px) Arial" - just return the whole text.
857 857
             return [{type: "otherProps", value: value, lastFont: true}];
858 858
         }
859 859
         var preProps = matches[0].slice(0, -1);
@@ -864,13 +864,36 @@ function getFontPropValueParts(element, value, propName)
864 864
     var matches = /^(.*?)( !important)?$/.exec(value);
865 865
     var fonts = matches[1].split(",");
866 866
 
867  
-    // Clone the element to just get the fonts used in it and not its descendants
868  
-    var clonedElement = element.cloneNode(false);
869  
-    clonedElement.textContent = element.textContent;
870  
-    Firebug.setIgnored(clonedElement);
871  
-    element.parentNode.appendChild(clonedElement);
872  
-    var usedFonts = Fonts.getFonts(clonedElement).slice();
873  
-    clonedElement.parentNode.removeChild(clonedElement);
  867
+    // What we want to know is what the specified "font-family" property means
  868
+    // for the selected element's text, not what the element actually uses (that
  869
+    // depends on font styles of its descendants). Thus, we create a temporary
  870
+    // element for testing. The element still needs to be in the same document,
  871
+    // to support web fonts, but to avoid reflows and effects like issue 5905,
  872
+    // it is positioned absolutely and generally hidden.
  873
+    var testElement = element.ownerDocument
  874
+        .createElementNS("http://www.w3.org/1999/xhtml", "div");
  875
+    Firebug.setIgnored(testElement);
  876
+
  877
+    testElement.textContent = element.textContent;
  878
+    testElement.style.position = "absolute";
  879
+    testElement.style.top = "-100px";
  880
+    testElement.style.width = testElement.style.height = "0";
  881
+    testElement.style.margin = testElement.style.padding =
  882
+        testElement.style.border = "0";
  883
+    testElement.style.overflow = "hidden";
  884
+
  885
+    if (propName === "font-family")
  886
+    {
  887
+        // The font-family property doesn't specify a font on its own - we
  888
+        // also need some additional related text styles.
  889
+        Css.copyTextStyles(element, testElement);
  890
+    }
  891
+    var nonImportant = origValue.replace(/ !important$/, "");
  892
+    testElement.style.setProperty(propName, nonImportant);
  893
+
  894
+    element.parentNode.appendChild(testElement);
  895
+    var usedFonts = Fonts.getFonts(testElement).slice();
  896
+    testElement.parentNode.removeChild(testElement);
874 897
 
875 898
     var genericFontUsed = false;
876 899
     for (var i = 0; i < fonts.length; ++i)
6  extension/content/firebug/html/inspector.js
@@ -124,12 +124,6 @@ Firebug.Inspector = Obj.extend(Firebug.Module,
124 124
                     if (oldContext.window && oldContext.window.document)
125 125
                     {
126 126
                         highlighter.unhighlight(oldContext);
127  
-
128  
-                        if (oldContext.inspectorMouseMove)
129  
-                        {
130  
-                            Events.removeEventListener(oldContext.window.document, "mousemove",
131  
-                                oldContext.inspectorMouseMove, true);
132  
-                        }
133 127
                     }
134 128
                 }, inspectDelay);
135 129
             }

0 notes on commit 32baad1

Please sign in to comment.
Something went wrong with that request. Please try again.