зеркало из https://github.com/mozilla/pjs.git
nsImageBoxFrame and nsTreeBodyFrame should use nsContentUtils::LoadImage (and
CanLoadImage). Bug 253627, r+sr=dbaron
This commit is contained in:
Родитель
4f3ae435c2
Коммит
8767b8a1c8
|
@ -44,7 +44,6 @@
|
|||
|
||||
#include "jspubtd.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -56,6 +55,7 @@
|
|||
|
||||
class nsIXPConnect;
|
||||
class nsIContent;
|
||||
class nsIDOMNode;
|
||||
class nsIDocument;
|
||||
class nsIDocShell;
|
||||
class nsINameSpaceManager;
|
||||
|
@ -68,9 +68,10 @@ class imgIDecoderObserver;
|
|||
class imgIRequest;
|
||||
class imgILoader;
|
||||
class nsIPrefBranch;
|
||||
class nsIPref;
|
||||
class nsIImage;
|
||||
class nsIImageLoadingContent;
|
||||
class nsIDOMHTMLFormElement;
|
||||
class nsIDOMDocument;
|
||||
|
||||
class nsContentUtils
|
||||
{
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURI.h"
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
#include "nsGUIEvent.h"
|
||||
|
||||
#include "nsFormControlHelper.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
#define ONLOAD_CALLED_TOO_EARLY 1
|
||||
|
||||
|
@ -348,26 +349,22 @@ nsImageBoxFrame::UpdateImage()
|
|||
mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src);
|
||||
mUseSrcAttr = !src.IsEmpty();
|
||||
if (mUseSrcAttr) {
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
if (mContent) {
|
||||
baseURI = mContent->GetBaseURI();
|
||||
nsIDocument* doc = mContent->GetDocument();
|
||||
if (!doc) {
|
||||
// No need to do anything here...
|
||||
return;
|
||||
}
|
||||
// XXX origin charset needed
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), src, nsnull, baseURI);
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
||||
src,
|
||||
doc,
|
||||
baseURI);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (uri && NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = GetLoadGroup();
|
||||
|
||||
// Get the document URI for the referrer...
|
||||
nsIDocument* doc = mContent ? mContent->GetDocument() : nsnull;
|
||||
nsIURI *documentURI = doc ? doc->GetDocumentURI() : nsnull;
|
||||
|
||||
// XXX: initialDocumentURI is NULL!
|
||||
il->LoadImage(uri, nsnull, documentURI, loadGroup, mListener, doc,
|
||||
mLoadFlags, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
if (uri && nsContentUtils::CanLoadImage(uri, mContent, doc)) {
|
||||
nsContentUtils::LoadImage(uri, doc, doc->GetDocumentURI(),
|
||||
mListener, mLoadFlags,
|
||||
getter_AddRefs(mImageRequest));
|
||||
}
|
||||
} else {
|
||||
// Only get the list-style-image if we aren't being drawn
|
||||
|
|
|
@ -59,6 +59,7 @@ REQUIRES = xpcom \
|
|||
xpconnect \
|
||||
js \
|
||||
webshell \
|
||||
pref \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
#include "imgIContainerObserver.h"
|
||||
#include "imgILoader.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiPresUtils.h"
|
||||
|
@ -1683,30 +1684,31 @@ nsTreeBodyFrame::GetImage(PRInt32 aRowIndex, nsTreeColumn* aCol, PRBool aUseCont
|
|||
if (styleRequest) {
|
||||
styleRequest->Clone(imgDecoderObserver, getter_AddRefs(imageRequest));
|
||||
} else {
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
||||
nsIDocument* doc = mContent->GetDocument();
|
||||
if (!doc)
|
||||
// The page is currently being torn down. Why bother.
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
baseURI = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
|
||||
nsCOMPtr<nsIURI> srcURI;
|
||||
// XXX origin charset needed
|
||||
NS_NewURI(getter_AddRefs(srcURI), imageSrc, nsnull, baseURI);
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(srcURI),
|
||||
imageSrc,
|
||||
doc,
|
||||
baseURI);
|
||||
if (!srcURI)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il =
|
||||
do_GetService("@mozilla.org/image/loader;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// XXX: initialDocumentURI is NULL!
|
||||
rv = il->LoadImage(srcURI, nsnull, doc->GetDocumentURI(), nsnull,
|
||||
imgDecoderObserver, doc, nsIRequest::LOAD_NORMAL,
|
||||
nsnull, nsnull, getter_AddRefs(imageRequest));
|
||||
if (nsContentUtils::CanLoadImage(srcURI, mContent, doc)) {
|
||||
nsresult rv = nsContentUtils::LoadImage(srcURI,
|
||||
doc,
|
||||
doc->GetDocumentURI(),
|
||||
imgDecoderObserver,
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
getter_AddRefs(imageRequest));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
}
|
||||
}
|
||||
listener->UnsuppressInvalidation();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче