Closed Bug 117805 Opened 23 years ago Closed 23 years ago

Context menus don't work in XML documents

Categories

(Core :: XML, defect)

defect
Not set
major

Tracking

()

VERIFIED FIXED
mozilla0.9.8

People

(Reporter: caillon, Assigned: caillon)

References

Details

(Keywords: regression)

Attachments

(3 files, 1 obsolete file)

Linux 2002010206 - 

Right clicking on a document served with an XML mime type will not allow for any
context menus to appear.  The same page served with a text/html mime type will
allow for context menus.  Testcases coming up.
Context menu appears in HTML mode
Context menu will not appear in XML mode
Severity: normal → major
confirmed on w2k with win32 build 2001123008 trunk
Keywords: regression
OS: Linux → All
Samir, your checkin to fix bug 15176 broke this. XML document does not have
getSelection() method, it is a method of the interface nsIDOMNSHTMLDocument. Is
there any other way to achieve what you want?

Hardware: PC → All
The reason we changed from _content.getSelection() to
ownerDocument.getSelection() is that the former would not give us the selection
when in documents within a frameset.  If there is some other way to get the
selection with and without frames we should switch over.  
Right clicking brings up these 11 warnings and 3 errors in the JS console:

(11 times)
Warning: reference to undefined property this.target.ownerDocument.getSelection
Source File: chrome://communicator/content/nsContextMenu.js
Line: 636
---------------
Error: this.target.ownerDocument.getSelection is not a function
Source File: chrome://communicator/content/nsContextMenu.js
Line: 636
Error: gContextMenu has no properties
Source File: chrome://messenger/content/mailNavigatorOverlay.xul
Line: 62
Error: gContextMenu has no properties
Source File: chrome://editor/content/editorApplicationOverlay.js
Line: 64
Keywords: mozilla0.9.8
Taking if you don't mind, Heikki.

The attached patch checks to see if |this.target.ownerDocument.getSelection()|
is a function for the current document.  If it is, we'll use it and if not we
use the older |_content.getSelection()|

Seeking r=/sr=
Assignee: heikki → caillon
Keywords: patch, review
Target Milestone: --- → mozilla0.9.8
Status: NEW → ASSIGNED
Christopher, that is not a full solution. Think about XHTML frameset documents...
Comment on attachment 64297 [details] [diff] [review]
Proposed fix v1.0

r=heikki

I am in favor of checking this in on the trunk, because the fix to bug 116523
will fix this for real later.
Attachment #64297 - Flags: review+
Comment on attachment 64297 [details] [diff] [review]
Proposed fix v1.0

>Index: resources/content/nsContextMenu.js
>===================================================================
>RCS file: /cvsroot/mozilla/xpfe/communicator/resources/content/nsContextMenu.js,v
>retrieving revision 1.48
>diff -u -r1.48 nsContextMenu.js
>--- resources/content/nsContextMenu.js	2001/12/21 00:43:53	1.48
>+++ resources/content/nsContextMenu.js	2002/01/10 17:19:26
>@@ -633,7 +633,11 @@
>     },
>     
>     searchSelected : function() {
>-        var searchStr = this.target.ownerDocument.getSelection();
>+        var searchStr;
>+        if (typeof this.target.ownerDocument.getSelection == "function")

A better way of doing this would be:
  if ("getSelection" in this.target.ownerDocument)

Could you add a comment pointing to bug 117805 and bug 116523, and add
a comment to the latter bug mentioning this change can be undone once
that is fixed?
Attachment #64297 - Flags: needs-work+
Comment on attachment 64975 [details] [diff] [review]
Patch v.2 with jag's changes

sr=jag

Carrying over Heikki's r=, which I'm sure still stands.
Attachment #64975 - Flags: superreview+
Attachment #64975 - Flags: review+
isn't getSelection deprecated?
Henrik, yes that is bug 116523 which this bug depends on -- this is just a
workaround to get context menus back in XML.

attachment 64975 [details] [diff] [review] has been checked in by bbaetz.  Heikki should we leave this
open for the real fix?  Or just check back after Samir fixes 116523?
Let's mark this fixed and keep eye on Samir when he fixes bug 116523, it will
HAVE to work on XML as well... 
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 121133 has been marked as a duplicate of this bug. ***
Marking verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: