Bug 1557102 - Work around inline styles being ignored. r=darktrojan
authorDirk Steinmetz <public@rsjtdrjgfuzkfg.com>
Mon, 17 Jun 2019 10:09:57 +0200
changeset 35877 686ff7f6f966a57217bef39351503db397669c36
parent 35876 f72f5ad61b913c02d8eae1c700cfcf5d964cd3eb
child 35878 65c086fce57ed6fa4f8f7865a400036fdd484874
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersdarktrojan
bugs1557102
Bug 1557102 - Work around inline styles being ignored. r=darktrojan For some unknown reason, inline styles in overlays are ignored until something triggers re-evaluation of the element style. This causes inline styles to be invisible whenever an add-on uses inline styles, but does not alter the styled element using code. To work around the issue, this commit forces styles to be evaluated by setting the 'display' style to the already evaluated value. That forces any inline styles to become visible immediately.
common/src/Overlays.jsm
--- a/common/src/Overlays.jsm
+++ b/common/src/Overlays.jsm
@@ -103,16 +103,24 @@ class Overlays {
       }
 
       let commentNodes = doc.evaluate("//comment()", doc, null, 7, null);
       for (let i = 0, len = commentNodes.snapshotLength; i < len; ++i) {
         let node = commentNodes.snapshotItem(i);
         node.remove();
       }
 
+      // Force a re-evaluation of inline styles to work around an issue
+      // causing inline styles to be initially ignored.
+      let styledNodes = doc.evaluate("//*[@style]", doc, null, 7, null);
+      for (let i = 0, len = styledNodes.snapshotLength; i < len; ++i) {
+        let node = styledNodes.snapshotItem(i);
+        node.style.display = node.style.display;
+      }
+
       // Load css styles from the registry
       for (let sheet of this.overlayProvider.style.get(url, false)) {
         unloadedSheets.push(sheet);
       }
 
       // Load css processing instructions from the overlay
       let stylesheets = doc.evaluate("/processing-instruction('xml-stylesheet')", doc, null, 7, null);
       for (let i = 0, len = stylesheets.snapshotLength; i < len; ++i) {