Closed
Bug 232698
Opened 21 years ago
Closed 14 years ago
Allow javascript to create a new HTML document in memory
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 592827
People
(Reporter: doronr, Unassigned)
Details
Attachments
(2 files, 1 obsolete file)
2.36 KB,
patch
|
peterv
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
3.26 KB,
patch
|
Details | Diff | Splinter Review |
Comment 1•21 years ago
|
||
HTMLDOMImplementation? What's that?
Ah, I remember, that's why we decided not to support createHTMLDocument, it got dropped from DOM Level 2. What we should rather do is to allow creation of html-documents by passing an appropriate doctype to createDocument. While we're there we should proably support creating xul, xhtml and svg documents by passing appropriate name/namespaces to createDocument.
Reporter | ||
Comment 3•21 years ago
|
||
Indeed, HTMLDOMImplementation's createHTMLDocument() is no longer in specs, my bad. Renaming the bug. Note that in IE, createDocumentFragment returns a full HTMLDocument, so that is how this got brought up at IBM.
Summary: Implement HTMLDOMImplementation's createHTMLDocument() → Allow javascript to create a new HTML document in memory
Reporter | ||
Comment 5•20 years ago
|
||
So could we make document.implementation.createDocument create html documents by giving it a mimetype?
Comment 6•20 years ago
|
||
createDocument is specified at http://www.w3.org/TR/2004/PR-DOM-Level-3-Core-20040205/core.html#ID-102161490 We could maybe hack together something where using an HTML4 doctype does the right thing?
Comment 7•20 years ago
|
||
Yeah, I think that's a reasonable approach.
Reporter | ||
Comment 8•20 years ago
|
||
Reporter | ||
Comment 9•20 years ago
|
||
Comment on attachment 151944 [details] [diff] [review] first try Thanks for peterv for all the help. Should I return somethign for unknown namespaces perhaps?
Attachment #151944 -
Flags: review?(peterv)
Reporter | ||
Updated•20 years ago
|
Attachment #151944 -
Flags: superreview?(jst)
Comment 10•20 years ago
|
||
Comment on attachment 151944 [details] [diff] [review] first try Looks good. No need to return anything for unknown namespaces. People should be able to create documents in whatever unknown namespace etc. sr=jst
Attachment #151944 -
Flags: superreview?(jst) → superreview+
Comment 11•20 years ago
|
||
Comment on attachment 151944 [details] [diff] [review] first try >+ // check the namespace >+ if (aNamespaceURI.Equals(NS_LITERAL_STRING("http://www.w3.org/1999/xhtml"))) { >+ // xhtml >+ rv = NS_NewHTMLDocument(getter_AddRefs(doc)); >+#ifdef MOZ_SVG >+ } else if (aNamespaceURI.Equals(NS_LITERAL_STRING("http://www.w3.org/2000/svg"))) { Move the else onto its own line. >+ // svg >+ rv = NS_NewSVGDocument(getter_AddRefs(doc)); >+#endif >+ } else { Same here. > if (!doc) > return NS_ERROR_OUT_OF_MEMORY; > > if (NS_FAILED(rv)) { >- delete doc; >- > return rv; > } No need to check both doc and rv, just NS_ENSURE_SUCCESS(rv, rv); >+ rv = domDoc->CreateElementNS(aNamespaceURI, aQualifiedName, > getter_AddRefs(root)); Align getter_AddRefs with the opening parenthesis.
Attachment #151944 -
Flags: review?(peterv) → review+
Comment 12•20 years ago
|
||
Do we want to add support for XUL documents?
Comment 13•20 years ago
|
||
Comment on attachment 151944 [details] [diff] [review] first try >+ if (aNamespaceURI.Equals(NS_LITERAL_STRING("http://www.w3.org/1999/xhtml"))) { if (aNamespaceURI.EqualsLiteral("http://www.w3.org/1999/xhtml")) {
Comment 14•20 years ago
|
||
I understood both comment #6 and the level 3 spec to talk about doctypes as the deciding criteria, the patch seems to use namespaces though. Is that intenional?
Reporter | ||
Comment 15•20 years ago
|
||
If we are to use doctypes which ones would be used to create HTML documents? And XUL doesn't seem to have a doctype.
Reporter | ||
Comment 16•20 years ago
|
||
Regarding XUL - I took the hard way and implemented a NS_NewXULDocument that takes a nsIDocument (the current one needs a nsIXULDocument). Was a good lesson. Should I use this for consistency sake or simply QI my nsIDocument to a nsIXULDocument in my code?
Reporter | ||
Comment 17•20 years ago
|
||
Comment 18•20 years ago
|
||
Comment on attachment 152945 [details] [diff] [review] Fix review comments and add XUL document creation >Index: content/xml/document/src/nsXMLDocument.cpp >=================================================================== >RCS file: /cvsroot/mozilla/content/xml/document/src/nsXMLDocument.cpp,v >retrieving revision 1.214 >diff -u -r1.214 nsXMLDocument.cpp >--- content/xml/document/src/nsXMLDocument.cpp 25 Jun 2004 12:25:59 -0000 1.214 >+++ content/xml/document/src/nsXMLDocument.cpp 12 Jul 2004 14:31:20 -0000 >@@ -91,6 +91,11 @@ > #include "nsIJSContextStack.h" > #include "nsNodeInfoManager.h" > #include "nsContentCreatorFunctions.h" >+#include "nsIXULDocument.h" is this going to break minimo? They don't build XUL, IIRC <...> >+ // check the namespace >+ if (aNamespaceURI.EqualsLiteral("http://www.w3.org/1999/xhtml")) { >+ // xhtml >+ rv = NS_NewHTMLDocument(getter_AddRefs(doc)); >+ } else if (aNamespaceURI.EqualsLiteral("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")) { >+ // xul --- >+ nsCOMPtr<nsIXULDocument> xulDoc = do_QueryInterface(doc); >+ rv = NS_NewXULDocument(getter_AddRefs(xulDoc)); ___ How can this work? It might be that do_QueryInterface checks for null, but I see no way that xulDoc will point to anything related to doc. nsCOMPtr<nsIXULDocument> xulDoc; rv = NS_NewXULDocument(getter_AddRefs(xulDoc)); NS_ENSURE_SUCCESS(rv, rv); doc = do_QueryInterface(xuldoc); sounds more like it. >+#ifdef MOZ_SVG >+ } else if (aNamespaceURI.EqualsLiteral("http://www.w3.org/2000/svg")) { >+ // svg >+ rv = NS_NewSVGDocument(getter_AddRefs(doc)); >+#endif >+ } else { >+ // default to XMLDocument for backwards compat >+ rv = NS_NewXMLDocument(getter_AddRefs(doc)); >+ } <...>
Reporter | ||
Comment 19•20 years ago
|
||
Pike is right, debug build hung with that code. Fixed that.
Reporter | ||
Updated•20 years ago
|
Attachment #152945 -
Attachment is obsolete: true
Updated•14 years ago
|
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•