Closed Bug 693624 Opened 13 years ago Closed 7 years ago

Auto-resize panels to match content

Categories

(Add-on SDK Graveyard :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: connorhd, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1

Steps to reproduce:

Created a panel with content larger than the panel size.


Actual results:

Scrollbars.


Expected results:

Panel resized to match content size if the screen size allows it (see Chrome popups).

Maybe this could be enabled using a property when creating the panel?
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
I had a quick go at implementing this, I ran into difficulty working out where the panel was in relation to the screen, the normal window.screenX etc properties seemed to refer to the parent window rather than the popup.

Anyway in case its useful this is my code (currently resizes between a minimum and maximum size rather than the screen size).

(before "this._emit('show');" in panel.js around line 326)

      var self = this;
      doc.documentElement.addEventListener("DOMSubtreeModified", function(){
        self.resize(Math.min(Math.max(doc.documentElement.scrollWidth, 320), 500), Math.min(Math.max(doc.documentElement.scrollHeight, 240), 500));
      }, false);
I've been trying to solve this since forever. I've always tried using a callback from the content script to the main code, passing it measurements to resize to. I tried to get the measurements from a dozen different combinations of anything I could find through google: document, documentElement, window, scrollWidth/Height, innerWidth/Height, boundingRectangle, etc. Nothing has ever worked reliably, it always ends up malformed. Opening the same html file in a tab shows the document the way it should be, so shouldn't it be possible to get the measurements of the document's natural layout and adjusting the panel to it?
For clarity: by it being unreliable, I meant that the results even differ between add-ons. One of my add-ons succesfully uses document.documentElement.scrollHeight/Width + 16, but the exact same code doesn't work at all in another add-on's panel.
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.