зеркало из https://github.com/mozilla/pjs.git
Some hackery for image documents
This commit is contained in:
Родитель
46aac29b34
Коммит
b2d5de9aa4
|
@ -141,6 +141,12 @@ public:
|
|||
nsIContentViewer** aDocViewer);
|
||||
|
||||
nsresult InitUAStyleSheet();
|
||||
|
||||
nsresult CreateImageDocument(nsIURL* aURL,
|
||||
const char* aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
nsIContentViewer** aDocViewer);
|
||||
};
|
||||
|
||||
static nsIStyleSheet* gUAStyleSheet;
|
||||
|
@ -157,6 +163,8 @@ NS_IMPL_ISUPPORTS(nsDocFactoryImpl,kIDocumentLoaderFactoryIID);
|
|||
|
||||
static char* gValidTypes[] = {"text/html","text/xml","application/rtf",0};
|
||||
|
||||
static char* gImageTypes[] = {"image/gif", "image/jpeg", 0 };
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocFactoryImpl::CreateInstance(nsIURL* aURL,
|
||||
const char* aContentType,
|
||||
|
@ -175,6 +183,17 @@ nsDocFactoryImpl::CreateInstance(nsIURL* aURL,
|
|||
goto nextstep;
|
||||
}
|
||||
}
|
||||
|
||||
// Try secondary types
|
||||
typeIndex = 0;
|
||||
while(gImageTypes[typeIndex]) {
|
||||
if (0== PL_strcmp(gImageTypes[typeIndex++], aContentType)) {
|
||||
return CreateImageDocument(aURL, aCommand,
|
||||
aContainer,
|
||||
aDocListener,
|
||||
aDocViewer);
|
||||
}
|
||||
}
|
||||
goto done;
|
||||
|
||||
nextstep:
|
||||
|
@ -223,6 +242,62 @@ done:
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocFactoryImpl::CreateImageDocument(nsIURL* aURL,
|
||||
const char* aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
nsIContentViewer** aDocViewer)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIDocument* doc = nsnull;
|
||||
nsIDocumentViewer* docv = nsnull;
|
||||
|
||||
// Load the UA style sheet if we haven't already done that
|
||||
if (nsnull == gUAStyleSheet) {
|
||||
InitUAStyleSheet();
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the image document...
|
||||
*/
|
||||
rv = NS_NewImageDocument(&doc);
|
||||
if (NS_OK != rv) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the image content viewer...
|
||||
*/
|
||||
rv = NS_NewDocumentViewer(docv);
|
||||
if (NS_OK != rv) {
|
||||
goto done;
|
||||
}
|
||||
docv->SetUAStyleSheet(gUAStyleSheet);
|
||||
|
||||
/*
|
||||
* Initialize the document to begin loading the data...
|
||||
*
|
||||
* An nsIStreamListener connected to the parser is returned in
|
||||
* aDocListener.
|
||||
*/
|
||||
rv = doc->StartDocumentLoad(aURL, aContainer, aDocListener);
|
||||
if (NS_OK != rv) {
|
||||
NS_IF_RELEASE(docv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bind the document to the Content Viewer...
|
||||
*/
|
||||
rv = docv->BindToDocument(doc, aCommand);
|
||||
*aDocViewer = docv;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(doc);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define UA_CSS_URL "resource:/res/ua.css"
|
||||
|
||||
nsresult nsDocFactoryImpl::InitUAStyleSheet()
|
||||
|
|
|
@ -141,6 +141,12 @@ public:
|
|||
nsIContentViewer** aDocViewer);
|
||||
|
||||
nsresult InitUAStyleSheet();
|
||||
|
||||
nsresult CreateImageDocument(nsIURL* aURL,
|
||||
const char* aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
nsIContentViewer** aDocViewer);
|
||||
};
|
||||
|
||||
static nsIStyleSheet* gUAStyleSheet;
|
||||
|
@ -157,6 +163,8 @@ NS_IMPL_ISUPPORTS(nsDocFactoryImpl,kIDocumentLoaderFactoryIID);
|
|||
|
||||
static char* gValidTypes[] = {"text/html","text/xml","application/rtf",0};
|
||||
|
||||
static char* gImageTypes[] = {"image/gif", "image/jpeg", 0 };
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocFactoryImpl::CreateInstance(nsIURL* aURL,
|
||||
const char* aContentType,
|
||||
|
@ -175,6 +183,17 @@ nsDocFactoryImpl::CreateInstance(nsIURL* aURL,
|
|||
goto nextstep;
|
||||
}
|
||||
}
|
||||
|
||||
// Try secondary types
|
||||
typeIndex = 0;
|
||||
while(gImageTypes[typeIndex]) {
|
||||
if (0== PL_strcmp(gImageTypes[typeIndex++], aContentType)) {
|
||||
return CreateImageDocument(aURL, aCommand,
|
||||
aContainer,
|
||||
aDocListener,
|
||||
aDocViewer);
|
||||
}
|
||||
}
|
||||
goto done;
|
||||
|
||||
nextstep:
|
||||
|
@ -223,6 +242,62 @@ done:
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocFactoryImpl::CreateImageDocument(nsIURL* aURL,
|
||||
const char* aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
nsIContentViewer** aDocViewer)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIDocument* doc = nsnull;
|
||||
nsIDocumentViewer* docv = nsnull;
|
||||
|
||||
// Load the UA style sheet if we haven't already done that
|
||||
if (nsnull == gUAStyleSheet) {
|
||||
InitUAStyleSheet();
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the image document...
|
||||
*/
|
||||
rv = NS_NewImageDocument(&doc);
|
||||
if (NS_OK != rv) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the image content viewer...
|
||||
*/
|
||||
rv = NS_NewDocumentViewer(docv);
|
||||
if (NS_OK != rv) {
|
||||
goto done;
|
||||
}
|
||||
docv->SetUAStyleSheet(gUAStyleSheet);
|
||||
|
||||
/*
|
||||
* Initialize the document to begin loading the data...
|
||||
*
|
||||
* An nsIStreamListener connected to the parser is returned in
|
||||
* aDocListener.
|
||||
*/
|
||||
rv = doc->StartDocumentLoad(aURL, aContainer, aDocListener);
|
||||
if (NS_OK != rv) {
|
||||
NS_IF_RELEASE(docv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bind the document to the Content Viewer...
|
||||
*/
|
||||
rv = docv->BindToDocument(doc, aCommand);
|
||||
*aDocViewer = docv;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(doc);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define UA_CSS_URL "resource:/res/ua.css"
|
||||
|
||||
nsresult nsDocFactoryImpl::InitUAStyleSheet()
|
||||
|
|
Загрузка…
Ссылка в новой задаче