Closed
Bug 73847
Opened 24 years ago
Closed 23 years ago
Need a way of determining the MIME type of the current document from chrome JS
Categories
(SeaMonkey :: UI Design, defect)
SeaMonkey
UI Design
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(2 files, 2 obsolete files)
10.29 KB,
patch
|
jst
:
superreview+
|
Details | Diff | Splinter Review |
9.77 KB,
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
Some context menu things could be improved if we had a way of telling when we
are viewing an image URL. The best way to do this is to look at the
content-type. Also, page info could use being able to tell what the
content-type of the current document is (since we will be trying to show it,
like NS 4.x). The MIME service just looks at the extension of the URL, and so
is unreliable.
This could possibly be done by making the nsIDocument or nsIHTMLDocument
interfaces scriptable and then calling the GetContentType methods of those
interfaces... but if there is a better way of doing it, I'm all for it.
Assignee | ||
Updated•24 years ago
|
Comment 1•24 years ago
|
||
The way it's done in the new page info stuff reports whatever the server returns
in the HTTP headers, and doesn't base if off of the file name. As an example,
grab a copy of my latest work from db48x.hypermart.net/pageinfo/, and check out
something from lxr, it does weird stuff to the mime type :).
db48x
Assignee | ||
Comment 2•24 years ago
|
||
Daniel,
Unless I am completely missing something, you use nsIMIMEService to get the mime
type... this just looks at the extension.
Assignee | ||
Comment 4•24 years ago
|
||
Only in that 46655 also uses the MIME service...
Comment 5•23 years ago
|
||
mscott: any idea when you might get to this? It's blocking several bugs for bits
of UI that need to know what sort of content we are viewing.
Gerv
Assignee | ||
Comment 6•23 years ago
|
||
Assignee | ||
Comment 7•23 years ago
|
||
ccing jst for comments (he seems to be fairly well represented in the code I'm
touching). Not sure who should be doing r= for this....
The fact that nsIDocument declares GetContentType as |const| sucks. Otherwise I
could implement all this in nsDocument.cpp....
Assignee: mscott → bzbarsky
Assignee | ||
Comment 8•23 years ago
|
||
um. really ccing jst for review. :)
Assignee | ||
Comment 9•23 years ago
|
||
ccing vidur and peterl as well. Comments?
Comment 10•23 years ago
|
||
This bothers me a bit since this will block global variables named 'contentType'
in scripts on the web from bing accessed from event handlers within the
document. I'm not sure that this will cause enough problems for us to worry
about, and I don't have a better suggestion for the name of this property, so
I'm leaning towards letting this in.
As for the patch:
- You will have merge conflicts when you update, I changed nsIDOMNSDocument.idl
today and it looks like we'll conflict, so look out for that.
- Make add mContentType to nsDocument in stead of adding it to both
nsHTMLDocument and nsXMLDocument, and make it an nsString, not an nsString*.
This will let you move GetContentType() into nsDocument too.
- Why add nsIHTMLDocument::SetContentType()? I don't see that called anywhere
other than from within classes that inherit nsIHTMLDocument, which will inherit
nsHTMLDocument which means they can just set mContentType (which is trivial once
you make it a nsString and not a nsString*).
- Use FindCharInReadable() to find the ';' you're looking for in a few places:
+ nsString::const_iterator start, end;
+ contentType.BeginReading(start);
+ contentType.EndReading(end);
+
+ if(FindCharInReadable(';', start, end)) {
+ SetContentType(Substring(start, iter));
+ } else {
+ SetContentType(contentType);
+ }
Fix that and I'll have one more look.
Comment 11•23 years ago
|
||
Er, make that:
+ SetContentType(Substring(start, iter));
Comment 12•23 years ago
|
||
No, I meant:
+ SetContentType(Substring(start, end));
Assignee | ||
Comment 13•23 years ago
|
||
Assignee | ||
Updated•23 years ago
|
Attachment #50159 -
Attachment is obsolete: true
Assignee | ||
Comment 14•23 years ago
|
||
Assignee | ||
Updated•23 years ago
|
Attachment #50287 -
Attachment is obsolete: true
Comment 15•23 years ago
|
||
- In nsRange.cpp, there's no need for the if (document) check,
do_QueryInterface() is null safe. Take out the if check and remove one of the
text/html assignments...
- In nsRootAccessible.cpp, same as above, no need for the if (mDocument) before
do_QueryInterface().
- Why add #include "nsIDOMNSDocument.h" to nsRootAccessible.h and not
nsRootAccessible.cpp, it's not needed in the header file, right?
Fix those when checking in, sr=jst
Updated•23 years ago
|
Attachment #50329 -
Flags: superreview+
Assignee | ||
Comment 16•23 years ago
|
||
vidur? peterl? Would you care to r=?
Assignee | ||
Comment 17•23 years ago
|
||
Comment 18•23 years ago
|
||
Comment on attachment 50433 [details] [diff] [review]
Updated patch. jst's changes and fix my mistyping of CopyASCIItoUCS2
r=peterv
Attachment #50433 -
Flags: review+
Assignee | ||
Comment 19•23 years ago
|
||
checked in
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Comment 20•23 years ago
|
||
rs vrfy --unless there are particular places you'd like me to test with!
Status: RESOLVED → VERIFIED
Updated•20 years ago
|
Product: Core → Mozilla Application Suite
You need to log in
before you can comment on or make changes to this bug.
Description
•