Closed Bug 524092 Opened 15 years ago Closed 15 years ago

"View Image Info" command is not carried out if "Page Info" window is already opened.

Categories

(Firefox :: Page Info Window, defect)

3.6 Branch
defect
Not set
normal

Tracking

()

VERIFIED FIXED
Firefox 3.7a1
Tracking Status
status1.9.2 --- beta4-fixed

People

(Reporter: alice0775, Assigned: mozilla.bugs)

References

()

Details

Attachments

(3 files, 9 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2b2pre) Gecko/20091022 Firefox/3.5.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.3a1pre) Gecko/20091022 Minefield/3.7a1pre ID:20091022234402

"View Image Info" command is not carried out if "Page Info" window is already opened.

When I carried out multiple "View Image Info",The command after the second is not carried out unless "Page Info" window is closed.

Reproducible: Always

Steps to Reproduce:
1.Start Minefield with new profile
2.Open URL
3.Carry out "View Image Info" command 
4.Carry out "View Image Info" command  for another image
Actual Results:  
The second command is not carried out

Expected Results:  
The second command should be carried out.
The Page Info" window should be updated,OR one more window should open.
Blocks: 517902
Version: unspecified → Trunk
What you need is something like:
http://mxr.mozilla.org/comm-central/source/suite/browser/navigator.js#1726
together with:
http://mxr.mozilla.org/comm-central/source/suite/browser/pageinfo/pageInfo.js#351
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows Vista → All
Hardware: x86 → All
Component: Menus → Page Info
QA Contact: menus → page.info
Comm-central has http://hg.mozilla.org/comm-central/rev/86f9ec8efa43, which is a modified version of the mozilla-central http://hg.mozilla.org/mozilla-central/rev/59b26c8b271f, which cannot take arguments like the former revision.  I think we can easily do this if we use the elements of the comm-central implementation, I just hope we wont break any extensions in the process.

I will assign this to me, but we will wait on Bug 524106, which Dao is fixing that changes some of this core.  Once he has his changes in the repository, I can quickly fix this one.
Assignee: nobody → mozilla.bugs
Status: NEW → ASSIGNED
Depends on: 524106
Attached patch Patch for resetPageInfo to accept arguments (obsolete) (deleted) β€” β€” Splinter Review
I have taken the comm-central code and added support for imageElement.

Also, I would have simply used the showTab function to select the mediaTab but that left a blank tab open after the contents are cleared, so I used the selector code from loadPageInfo instead.
Attachment #409559 - Flags: review?(db48x)
Comment on attachment 409559 [details] [diff] [review]
Patch for resetPageInfo to accept arguments

>--- a/browser/base/content/browser.js
>+++ b/browser/base/content/browser.js

>     	currentWindow.focus();
>-    	return;
>+    	if (inType == "Browser:page-info")
>+    	  currentWindow.resetPageInfo(extraArgument);
>+      return;

Part of the indentation are tabs, please remove them (also before currentWindow.focus()).

>--- a/browser/base/content/pageinfo/pageInfo.js
>+++ b/browser/base/content/pageinfo/pageInfo.js
>@@ -333,17 +333,17 @@ function loadPageInfo()

>+function resetPageInfo(args)

>+  if (args && args.doc) {
>+    gDocument = args.doc;
>+    gWindow = gDocument.defaultView;
>+  }
>+
>+  if (args && args.imageElement)
>+    gImageElement = args.imageElement;
>+
>+  /* Rebuild the data */
>   loadPageInfo();
>+
>+  var initialTab = (args && args.initialTab) || "generalTab";
>+  var radioGroup = document.getElementById("viewGroup");
>+  initialTab = document.getElementById(initialTab) || document.getElementById("generalTab");
>+  radioGroup.selectedItem = initialTab;
>+  radioGroup.selectedItem.doCommand();
>+  radioGroup.focus();
>+  Components.classes["@mozilla.org/observer-service;1"]
>+            .getService(Components.interfaces.nsIObserverService)
>+            .notifyObservers(window, "page-info-dialog-reset", null);

Can that code be moved to a separate function and shared with onLoadPageInfo?
Attached patch Patch v 1.1 (obsolete) (deleted) β€” β€” Splinter Review
I have fixed the tabs issue (I have no idea how those got in there...), and I have created the selectTab function.  However, there is a showtab function already, which uses a different selection method that leaves the media list blank if you use it.  For efficiency's sake we probably should merge the two, but I don't know if that will break anything else, like a number of add-ons if we do that.
Attachment #409559 - Attachment is obsolete: true
Attachment #409812 - Flags: review?(db48x)
Attachment #409559 - Flags: review?(db48x)
It looks like onLoadPageInfo and resetPageInfo could share the code that determines gDocument, gWindow and gImageElement, and the loadPageInfo call.
Attached patch Alternative Patch v 1.1 (obsolete) (deleted) β€” β€” Splinter Review
This uses the idea of combining those extra lines of code.  I believe I prefer this solution, but the other is workable.
Comment on attachment 409850 [details] [diff] [review]
Alternative Patch v 1.1

>+  loadTab((args && args.initialTab) || "generalTab",args);

There's no need for the first argument, since it's part of the second argument.

>+  /* Load the page info */
>+  loadPageInfo()

missing semicolon...
Attached patch Alternative Patch v 1.2 (obsolete) (deleted) β€” β€” Splinter Review
I fixed the stupid mistakes that Dao caught.
Attachment #409850 - Attachment is obsolete: true
Attachment #409812 - Attachment is obsolete: true
Attachment #409812 - Flags: review?(db48x)
Please integrate toOpenDialogByTypeAndUrl into BrowserPageInfo. The former doesn't belong into the browser.js global scope.
Attached patch Patch v 1.3 (obsolete) (deleted) β€” β€” Splinter Review
Changes made.
Attachment #410164 - Attachment is obsolete: true
Comment on attachment 410279 [details] [diff] [review]
Patch v 1.3

>+  while (windows.hasMoreElements()) {
>+    var currentWindow = windows.getNext();
>+    if (currentWindow.document.documentElement.getAttribute("relatedUrl") == documentURL) {
>+      currentWindow.focus();
>+      currentWindow.resetPageInfo(args);
>+      return;

I think this should return currentWindow.

Note that toOpenDialogByTypeAndUrl existed only for BrowserPageInfo, so it can now be removed.
Attached patch Patch v 1.4 (obsolete) (deleted) β€” β€” Splinter Review
Removed the extra function and now it returns the window if it is open.
Attachment #410279 - Attachment is obsolete: true
Comment on attachment 410430 [details] [diff] [review]
Patch v 1.4

>+  var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
>+  var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
>+  var windows = windowManagerInterface.getEnumerator("Browser:page-info");

Use this instead:

var windows = Cc['@mozilla.org/appshell/window-mediator;1']
                .getService(Ci.nsIWindowMediator)
                .getEnumerator("Browser:page-info");

>+  return window.openDialog("chrome://browser/content/pageinfo/pageInfo.xul", "_blank", "chrome,toolbar,dialog=no,resizable", args);

nit: return openDialog(...), without window

>+  Components.classes["@mozilla.org/observer-service;1"]
>+            .getService(Components.interfaces.nsIObserverService)
>+            .notifyObservers(window, "page-info-dialog-reset", null);

Please don't add this notification.

r=me with that
Attachment #410430 - Flags: review+
(In reply to comment #14)
> >+  return window.openDialog("chrome://browser/content/pageinfo/pageInfo.xul", "_blank", "chrome,toolbar,dialog=no,resizable", args);
> 
> nit: return openDialog(...), without window

Oh, and break this up into multiple lines, e.g.:

return openDialog("chrome://browser/content/pageinfo/pageInfo.xul", "",
                  "chrome,toolbar,dialog=no,resizable", args);
Attached patch Final patch (deleted) β€” β€” Splinter Review
Here it is with those last changes.
Attachment #410430 - Attachment is obsolete: true
Keywords: checkin-needed
Attachment #410693 - Flags: approval1.9.2?
http://hg.mozilla.org/mozilla-central/rev/44ff9f905317
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3.7a1
Version: Trunk → 3.6 Branch
Depends on: 525190
V. Fixed Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20091106 Minefield/3.7a1pre
Should this have tests? And can I get a quick compatibility assessment for understanding how this might affect add-ons?
No longer depends on: 525190
Depends on: 525190
Verified from Comment 18.
Status: RESOLVED → VERIFIED
(In reply to comment #19)
> can I get a quick compatibility assessment for
> understanding how this might affect add-ons?

The toOpenDialogByTypeAndUrl function has been removed from browser.js, but add-ons don't use that according to <http://mxr-test.konigsberg.mozilla.org/addons/search?string=toOpenDialogByTypeAndUrl>.
Also the additional arguments added to resetPageInfo shouldn't affect any addons, since no add-ons use that function either.

http://mxr-test.konigsberg.mozilla.org/addons/search?string=resetPageInfo&tree=addons
resetPageInfo was added in bug 388504 to make it possible to reload the content of the Page Info window after setting gWindow and gDocument to different values (typically a subframe).
Setting gWindow and gDocument unconditionally in a function called by resetPageInfo breaks this.

resetPageInfo is used in https://addons.mozilla.org/fr/firefox/addon/7457
I guess it doesn't appear in the result of your query because this addon is still in the sandbox.
> I guess it doesn't appear in the result of your query because this addon is
> still in the sandbox.
No that MXR instance is an old snapshot and isn't up to date.
> Setting gWindow and gDocument unconditionally in a function called by
> resetPageInfo breaks this.

SeaMonkey depends on this to display our Larry information in much the same way you are now using resetPageInfo to display image properties. Fortunately our implementation isn't affected by your changes.
(In reply to comment #23)
> Setting gWindow and gDocument unconditionally in a function called by
> resetPageInfo breaks this.

We could move the code that defines gDocument and gWindow back to onLoadPageInfo() so that resetting doesn't change those values and then we don't break lines 88 and 89 of your viewframes.js in that add-on.  Moving that code shouldn't break this bug's functionality.  I'll quickly test a patch that does that.
Attached patch Fix for regression (obsolete) (deleted) β€” β€” Splinter Review
This is a fix that moves the function that resets the gDocument and gWindow data back to onLoadPageInfo, and it removes the redundant block of code that resets gImageElement from loadTab.
Attachment #410931 - Flags: review?(dao)
Attachment #410931 - Flags: review?(dao) → review-
Comment on attachment 410931 [details] [diff] [review]
Fix for regression

args.doc isn't guaranteed to be the same as gDocument when resetPageInfo is called.
Attached patch Better fix for regression (obsolete) (deleted) β€” β€” Splinter Review
A better fix entirely thanks to Dao.
Attachment #410931 - Attachment is obsolete: true
Attachment #410932 - Flags: review?(dao)
This has all of the changes that Dao requested in #developers.
Attachment #410932 - Attachment is obsolete: true
Attachment #410933 - Flags: review?(dao)
Attachment #410932 - Flags: review?(dao)
Attachment #410933 - Attachment description: Best fix for regression → fix for compatibility with "View Frames" add-on
Attachment #410933 - Flags: review?(dao) → review+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/0d83b7b45431
Keywords: checkin-needed
Attached patch combined 1.9.2 patch (obsolete) (deleted) β€” β€” Splinter Review
contains the fix for bug 525190
Attachment #410955 - Flags: approval1.9.2?
Attachment #410693 - Flags: approval1.9.2?
Sadly, Koeningsburg isn't a great reference as it doesn't index all Add-ons, everywhere. It's a good first approximation, though. I'd like to make sure that we don't break any add-on functionality, even if that means creating a 1.9.2 patch that supports old method interfaces for now.

Any reason to not keep toOpenDialogByTypeAndUrl around?
doesn't hurt to keep it
Attachment #410955 - Attachment is obsolete: true
Attachment #410970 - Flags: approval1.9.2?
Attachment #410955 - Flags: approval1.9.2?
Comment on attachment 410970 [details] [diff] [review]
combined 1.9.2 patch, leaving toOpenDialogByTypeAndUrl untouched

a192=beltzner, thanks for working through this one, all
Attachment #410970 - Flags: approval1.9.2? → approval1.9.2+
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/aacc9573ddbd
Depends on: 582871
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: