Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #471 from ochameau/bug/766917-fix-widget-test

Bug 766917: Fix application of panel style to its document. r=@gozala(cherry picked from commit cd13dec)
  • Loading branch information...
commit c64ad82e81db8933cef4246b366f5926d7a8e764 1 parent a443867
ochameau authored June 21, 2012 KWierso committed July 24, 2012

Showing 1 changed file with 35 additions and 18 deletions. Show diff stats Hide diff stats

  1. 53  packages/addon-kit/lib/panel.js
53  packages/addon-kit/lib/panel.js
@@ -270,6 +270,40 @@ const Panel = Symbiont.resolve({
270 270
       this._emit('error', e);
271 271
     }
272 272
   },
  273
+
  274
+  /**
  275
+   * Retrieve computed text color style in order to apply to the iframe
  276
+   * document. As MacOS background is dark gray, we need to use skin's
  277
+   * text color.
  278
+   */
  279
+  _applyStyleToDocument: function _applyStyleToDocument() {
  280
+    try {
  281
+      let win = this._xulPanel.ownerDocument.defaultView;
  282
+      let node = win.document.getAnonymousElementByAttribute(
  283
+        this._xulPanel, "class", "panel-arrowcontent");
  284
+      if (!node) {
  285
+        // Before bug 764755, anonymous content was different:
  286
+        // TODO: Remove this when targeting FF16+
  287
+        node = win.document.getAnonymousElementByAttribute(
  288
+          this._xulPanel, "class", "panel-inner-arrowcontent");
  289
+      }
  290
+      let textColor = win.getComputedStyle(node).getPropertyValue("color");
  291
+      let doc = this._xulPanel.firstChild.contentDocument;
  292
+      let style = doc.createElement("style");
  293
+      style.textContent = "body { color: " + textColor + "; }";
  294
+      let container = doc.head ? doc.head : doc.documentElement;
  295
+
  296
+      if (container.firstChild)
  297
+        container.insertBefore(style, container.firstChild);
  298
+      else
  299
+        container.appendChild(style);
  300
+    }
  301
+    catch(e) {
  302
+      console.error("Unable to apply panel style");
  303
+      console.exception(e);
  304
+    }
  305
+  },
  306
+
273 307
   /**
274 308
    * When the XUL panel becomes shown, we swap frame loaders between panel
275 309
    * frame and hidden frame to preserve state of the content dom.
@@ -280,24 +314,7 @@ const Panel = Symbiont.resolve({
280 314
         this.on('inited', this._onShow.bind(this));
281 315
       } else {
282 316
         this._frameLoadersSwapped = true;
283  
-
284  
-        // Retrieve computed text color style in order to apply to the iframe
285  
-        // document. As MacOS background is dark gray, we need to use skin's
286  
-        // text color.
287  
-        let win = this._xulPanel.ownerDocument.defaultView;
288  
-        let node = win.document.getAnonymousElementByAttribute(this._xulPanel,
289  
-                    "class", "panel-inner-arrowcontent");
290  
-        let textColor = win.getComputedStyle(node).getPropertyValue("color");
291  
-        let doc = this._xulPanel.firstChild.contentDocument;
292  
-        let style = doc.createElement("style");
293  
-        style.textContent = "body { color: " + textColor + "; }";
294  
-        let container = doc.head ? doc.head : doc.documentElement;
295  
-
296  
-        if (container.firstChild)
297  
-          container.insertBefore(style, container.firstChild);
298  
-        else
299  
-          container.appendChild(style);
300  
-
  317
+        this._applyStyleToDocument();
301 318
         this._emit('show');
302 319
       }
303 320
     } catch(e) {

0 notes on commit c64ad82

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