diff --git a/mozilla/embedding/browser/webBrowser/nsIWebBrowserNav.idl b/mozilla/embedding/browser/webBrowser/nsIWebBrowserNav.idl index 2558c10372b..6229619605c 100644 --- a/mozilla/embedding/browser/webBrowser/nsIWebBrowserNav.idl +++ b/mozilla/embedding/browser/webBrowser/nsIWebBrowserNav.idl @@ -45,12 +45,12 @@ interface nsIWebBrowserNav : nsISupports /* Tells the browser to navigate to the next Back session history item. */ - void GoBack(); + void goBack(); /* Tells the browser to navigate to the next Forward session history item. */ - void GoForward(); + void goForward(); /* Loads a given URI. This will give priority to loading the requested URI @@ -60,7 +60,7 @@ interface nsIWebBrowserNav : nsISupports @param uri - The URI to load. */ - void LoadURI(in wstring uri); + void loadURI(in wstring uri); /* Loads a given URI through the specified adapter. This will give priority @@ -71,19 +71,31 @@ interface nsIWebBrowserNav : nsISupports @param uri - The URI to load. @param adapterBinding - The local IP address of the adapter to bind to. */ - void LoadURIVia(in wstring uri, in unsigned long adapterBinding); + void loadURIVia(in wstring uri, in unsigned long adapterBinding); - void Reload(); //XXX Should take a cache parameter + void reload(); //XXX Should take a cache parameter /* Stops a load of a URI. */ - void Stop(); + void stop(); + /* + Set the document for the current webBrowser. This will simulate the normal + load process of a document being loaded. + + @param document - The document to be set. + @param contentType - This is the content type to try and render the document + as. This may be null. If this is null, the method will try to query + the document to identify the content type of the document. If the query + fails, content type "HTML" will be assumed. + */ + void setDocument(in nsIDOMDocument document, in wstring contentType); + /* Retrieves or sets the current Document for the WebBrowser. When setting this will simulate the normal load process. */ - attribute nsIDOMDocument document; + readonly attribute nsIDOMDocument document; }; \ No newline at end of file diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp index 573d39e6740..1b3bfcc0043 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -24,6 +24,8 @@ #include "nsGfxCIID.h" #include "nsWidgetsCID.h" #include "nsIDeviceContext.h" +#include "nsIDocument.h" +#include "nsIDOMDocument.h" #include "nsWebBrowser.h" @@ -219,14 +221,28 @@ NS_IMETHODIMP nsWebBrowser::Stop() return NS_ERROR_FAILURE; } -NS_IMETHODIMP nsWebBrowser::SetDocument(nsIDOMDocument* document) +NS_IMETHODIMP nsWebBrowser::SetDocument(nsIDOMDocument* aDocument, + const PRUnichar* aContentType) { - //XXX First Check - /* - Retrieves or sets the current Document for the WebBrowser. When setting - this will simulate the normal load process. - */ - return NS_ERROR_FAILURE; + NS_ENSURE_ARG(aDocument); + + nsAutoString contentType(aContentType); + if(contentType.IsEmpty()) + { + nsCOMPtr doc(do_QueryInterface(aDocument)); + if(doc) + doc->GetContentType(contentType); + } + if(contentType.IsEmpty()) + contentType.Assign("HTML"); + + NS_ENSURE_SUCCESS(CreateDocShell(contentType.GetUnicode()), + NS_ERROR_FAILURE); + + NS_ENSURE_SUCCESS(mDocShell->SetDocument(aDocument, nsnull), + NS_ERROR_FAILURE); + + return NS_OK; } NS_IMETHODIMP nsWebBrowser::GetDocument(nsIDOMDocument** document) @@ -582,14 +598,11 @@ NS_IMETHODIMP nsWebBrowser::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx, NS_IMETHODIMP nsWebBrowser::Repaint(PRBool fForce) { - //XXX First Check - /** - * Tell the window to repaint itself - * @param aForce - if true, repaint immediately - * if false, the window may defer repainting as it sees fit. - */ - return NS_ERROR_FAILURE; -} + NS_ENSURE_STATE(mDocShell); + nsCOMPtr docWnd(do_QueryInterface(mDocShell)); + NS_ENSURE_TRUE(docWnd, NS_ERROR_FAILURE); + return docWnd->Repaint(fForce); // Can directly return this as it is the +} // same interface, thus same returns. NS_IMETHODIMP nsWebBrowser::GetParentWidget(nsIWidget** parentWidget) {