bug 314453 Rename ImageURIChanged and ObjectURIChanged to LoadImage and

LoadObject, respectively, in order to make it clear what they do rather than
prescribing when they should be called. r+sr=bz
This commit is contained in:
cbiesinger%web.de 2006-01-01 11:25:43 +00:00
Родитель eec5573f68
Коммит e372451268
10 изменённых файлов: 65 добавлений и 65 удалений

Просмотреть файл

@ -419,9 +419,9 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
*/ */
nsresult nsresult
nsImageLoadingContent::ImageURIChanged(const nsAString& aNewURI, nsImageLoadingContent::LoadImage(const nsAString& aNewURI,
PRBool aForce, PRBool aForce,
PRBool aNotify) PRBool aNotify)
{ {
if (!mLoadingEnabled) { if (!mLoadingEnabled) {
FireEvent(NS_LITERAL_STRING("error")); FireEvent(NS_LITERAL_STRING("error"));
@ -440,14 +440,14 @@ nsImageLoadingContent::ImageURIChanged(const nsAString& aNewURI,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// XXXbiesi fire onerror if that failed? // XXXbiesi fire onerror if that failed?
return ImageURIChanged(imageURI, aForce, aNotify, doc); return LoadImage(imageURI, aForce, aNotify, doc);
} }
nsresult nsresult
nsImageLoadingContent::ImageURIChanged(nsIURI* aNewURI, nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
PRBool aForce, PRBool aForce,
PRBool aNotify, PRBool aNotify,
nsIDocument* aDocument) nsIDocument* aDocument)
{ {
if (!mLoadingEnabled) { if (!mLoadingEnabled) {
return NS_OK; return NS_OK;
@ -555,7 +555,7 @@ nsImageLoadingContent::UpdateImageState(PRBool aNotify)
// Ignore this call; we'll update our state when the state changer is // Ignore this call; we'll update our state when the state changer is
// destroyed. Need this to work around the fact that some libpr0n stuff is // destroyed. Need this to work around the fact that some libpr0n stuff is
// actually sync and hence we can get OnStopDecode called while we're still // actually sync and hence we can get OnStopDecode called while we're still
// under ImageURIChanged, and OnStopDecode doesn't know anything about // under LoadImage, and OnStopDecode doesn't know anything about
// aNotify // aNotify
return; return;
} }

Просмотреть файл

@ -68,7 +68,7 @@ public:
protected: protected:
/** /**
* ImageURIChanged is called by subclasses when the appropriate * LoadImage is called by subclasses when the appropriate
* attributes (eg 'src' for <img> tags) change. The string passed * attributes (eg 'src' for <img> tags) change. The string passed
* in is the new uri string; this consolidates the code for getting * in is the new uri string; this consolidates the code for getting
* the charset, constructing URI objects, and any other incidentals * the charset, constructing URI objects, and any other incidentals
@ -80,8 +80,8 @@ protected:
* @param aNotify If true, nsIDocumentObserver state change notifications * @param aNotify If true, nsIDocumentObserver state change notifications
* will be sent as needed. * will be sent as needed.
*/ */
nsresult ImageURIChanged(const nsAString& aNewURI, PRBool aForce, nsresult LoadImage(const nsAString& aNewURI, PRBool aForce,
PRBool aNotify); PRBool aNotify);
/** /**
* ImageState is called by subclasses that are computing their content state. * ImageState is called by subclasses that are computing their content state.
@ -96,7 +96,7 @@ protected:
PRInt32 ImageState() const; PRInt32 ImageState() const;
/** /**
* ImageURIChanged is called by subclasses when the appropriate * LoadImage is called by subclasses when the appropriate
* attributes (eg 'src' for <img> tags) change. If callers have an * attributes (eg 'src' for <img> tags) change. If callers have an
* URI object already available, they should use this method. * URI object already available, they should use this method.
* *
@ -108,8 +108,8 @@ protected:
* @param aDocument Optional parameter giving the document this node is in. * @param aDocument Optional parameter giving the document this node is in.
* This is purely a performance optimization. * This is purely a performance optimization.
*/ */
nsresult ImageURIChanged(nsIURI* aNewURI, PRBool aForce, PRBool aNotify, nsresult LoadImage(nsIURI* aNewURI, PRBool aForce, PRBool aNotify,
nsIDocument* aDocument = nsnull); nsIDocument* aDocument = nsnull);
/** /**
* helper to get the document for this content (from the nodeinfo * helper to get the document for this content (from the nodeinfo
@ -130,7 +130,7 @@ protected:
/** /**
* UseAsPrimaryRequest is called by subclasses when they have an existing * UseAsPrimaryRequest is called by subclasses when they have an existing
* imgIRequest that they want this nsImageLoadingContent to use. This may * imgIRequest that they want this nsImageLoadingContent to use. This may
* effectively be called instead of ImageURIChanged or LoadImageWithChannel. * effectively be called instead of LoadImage or LoadImageWithChannel.
* If aNotify is true, this method will notify on state changes. * If aNotify is true, this method will notify on state changes.
*/ */
nsresult UseAsPrimaryRequest(imgIRequest* aRequest, PRBool aNotify); nsresult UseAsPrimaryRequest(imgIRequest* aRequest, PRBool aNotify);

Просмотреть файл

@ -699,11 +699,11 @@ nsObjectLoadingContent::ObjectState() const
// <protected> // <protected>
nsresult nsresult
nsObjectLoadingContent::ObjectURIChanged(const nsAString& aURI, nsObjectLoadingContent::LoadObject(const nsAString& aURI,
PRBool aNotify, PRBool aNotify,
const nsCString& aTypeHint, const nsCString& aTypeHint,
PRBool aForceType, PRBool aForceType,
PRBool aForceLoad) PRBool aForceLoad)
{ {
LOG(("OBJLC [%p]: Loading object: URI string=<%s> notify=%i type=<%s> forcetype=%i forceload=%i\n", LOG(("OBJLC [%p]: Loading object: URI string=<%s> notify=%i type=<%s> forcetype=%i forceload=%i\n",
this, NS_ConvertUTF16toUTF8(aURI).get(), aNotify, aTypeHint.get(), aForceType, aForceLoad)); this, NS_ConvertUTF16toUTF8(aURI).get(), aNotify, aTypeHint.get(), aForceType, aForceLoad));
@ -730,15 +730,15 @@ nsObjectLoadingContent::ObjectURIChanged(const nsAString& aURI,
return NS_OK; return NS_OK;
} }
return ObjectURIChanged(uri, aNotify, aTypeHint, aForceType, aForceLoad); return LoadObject(uri, aNotify, aTypeHint, aForceType, aForceLoad);
} }
nsresult nsresult
nsObjectLoadingContent::ObjectURIChanged(nsIURI* aURI, nsObjectLoadingContent::LoadObject(nsIURI* aURI,
PRBool aNotify, PRBool aNotify,
const nsCString& aTypeHint, const nsCString& aTypeHint,
PRBool aForceType, PRBool aForceType,
PRBool aForceLoad) PRBool aForceLoad)
{ {
LOG(("OBJLC [%p]: Loading object: URI=<%p> notify=%i type=<%s> forcetype=%i forceload=%i\n", LOG(("OBJLC [%p]: Loading object: URI=<%p> notify=%i type=<%s> forcetype=%i forceload=%i\n",
this, aURI, aNotify, aTypeHint.get(), aForceType, aForceLoad)); this, aURI, aNotify, aTypeHint.get(), aForceType, aForceLoad));
@ -881,7 +881,7 @@ nsObjectLoadingContent::ObjectURIChanged(nsIURI* aURI,
switch (newType) { switch (newType) {
case eType_Image: case eType_Image:
// Don't notify, because we will take care of that ourselves. // Don't notify, because we will take care of that ourselves.
rv = ImageURIChanged(aURI, aForceLoad, PR_FALSE); rv = LoadImage(aURI, aForceLoad, PR_FALSE);
break; break;
case eType_Plugin: case eType_Plugin:
rv = Instantiate(aTypeHint, aURI); rv = Instantiate(aTypeHint, aURI);
@ -1034,7 +1034,7 @@ nsObjectLoadingContent::RemovedFromDocument()
mFrameLoader->Destroy(); mFrameLoader->Destroy();
mFrameLoader = nsnull; mFrameLoader = nsnull;
// Clear the current URI, so that ObjectURIChanged doesn't think that we // Clear the current URI, so that LoadObject doesn't think that we
// have already loaded the content. // have already loaded the content.
mURI = nsnull; mURI = nsnull;
} }

Просмотреть файл

@ -136,11 +136,11 @@ class nsObjectLoadingContent : public nsImageLoadingContent
* @see the URI-taking version of this function for a detailed description * @see the URI-taking version of this function for a detailed description
* of how a plugin will be found. * of how a plugin will be found.
*/ */
nsresult ObjectURIChanged(const nsAString& aURI, nsresult LoadObject(const nsAString& aURI,
PRBool aNotify, PRBool aNotify,
const nsCString& aTypeHint = EmptyCString(), const nsCString& aTypeHint = EmptyCString(),
PRBool aForceType = PR_FALSE, PRBool aForceType = PR_FALSE,
PRBool aForceLoad = PR_FALSE); PRBool aForceLoad = PR_FALSE);
/** /**
* Loads the object from the given URI. * Loads the object from the given URI.
* *
@ -171,11 +171,11 @@ class nsObjectLoadingContent : public nsImageLoadingContent
* @param aForceLoad If true, the object will be refetched even if the URI * @param aForceLoad If true, the object will be refetched even if the URI
* is the same as the currently-loaded object. * is the same as the currently-loaded object.
*/ */
nsresult ObjectURIChanged(nsIURI* aURI, nsresult LoadObject(nsIURI* aURI,
PRBool aNotify, PRBool aNotify,
const nsCString& aTypeHint = EmptyCString(), const nsCString& aTypeHint = EmptyCString(),
PRBool aForceType = PR_FALSE, PRBool aForceType = PR_FALSE,
PRBool aForceLoad = PR_FALSE); PRBool aForceLoad = PR_FALSE);
enum Capabilities { enum Capabilities {
eSupportImages = PR_BIT(0), // Images are supported (imgILoader) eSupportImages = PR_BIT(0), // Images are supported (imgILoader)

Просмотреть файл

@ -108,7 +108,7 @@ public:
virtual PRUint32 GetCapabilities() const; virtual PRUint32 GetCapabilities() const;
protected: protected:
/** /**
* Calls ObjectURIChanged with the correct arguments to start the plugin * Calls LoadObject with the correct arguments to start the plugin
* load. * load.
*/ */
NS_HIDDEN_(void) StartAppletLoad(PRBool aNotify); NS_HIDDEN_(void) StartAppletLoad(PRBool aNotify);
@ -278,15 +278,15 @@ nsHTMLAppletElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue, nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify) PRBool aNotify)
{ {
// If we plan to call ObjectURIChanged, we want to do it first so that the // If we plan to call LoadObject, we want to do it first so that the
// object load kicks off _before_ the reflow triggered by the SetAttr. But if // object load kicks off _before_ the reflow triggered by the SetAttr. But if
// aNotify is false, we are coming from the parser or some such place; we'll // aNotify is false, we are coming from the parser or some such place; we'll
// get bound after all the attributes have been set, so we'll do the // get bound after all the attributes have been set, so we'll do the
// object load from BindToTree/DoneAddingChildren. // object load from BindToTree/DoneAddingChildren.
// Skip the ObjectURIChanged call in that case. // Skip the LoadObject call in that case.
if (aNotify && if (aNotify &&
aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::code) { aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::code) {
ObjectURIChanged(aValue, aNotify, LoadObject(aValue, aNotify,
NS_LITERAL_CSTRING("application/x-java-vm"), NS_LITERAL_CSTRING("application/x-java-vm"),
PR_TRUE, PR_TRUE); PR_TRUE, PR_TRUE);
} }
@ -301,10 +301,10 @@ nsHTMLAppletElement::StartAppletLoad(PRBool aNotify)
{ {
nsAutoString uri; nsAutoString uri;
if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::code, uri)) { if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::code, uri)) {
ObjectURIChanged(uri, aNotify, LoadObject(uri, aNotify,
NS_LITERAL_CSTRING("application/x-java-vm"), PR_TRUE); NS_LITERAL_CSTRING("application/x-java-vm"), PR_TRUE);
} else { } else {
// The constructor set the type to eType_Plugin; but if we have no code // The constructor set the type to eType_Loading; but if we have no code
// attribute, then we aren't really a plugin // attribute, then we aren't really a plugin
Fallback(aNotify); Fallback(aNotify);
} }

Просмотреть файл

@ -550,11 +550,11 @@ nsHTMLImageElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue, nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify) PRBool aNotify)
{ {
// If we plan to call ImageURIChanged, we want to do it first so that the // If we plan to call LoadImage, we want to do it first so that the
// image load kicks off _before_ the reflow triggered by the SetAttr. But if // image load kicks off _before_ the reflow triggered by the SetAttr. But if
// aNotify is false, we are coming from the parser or some such place; we'll // aNotify is false, we are coming from the parser or some such place; we'll
// get bound after all the attributes have been set, so we'll do the // get bound after all the attributes have been set, so we'll do the
// image load from BindToTree. Skip the ImageURIChanged call in that case. // image load from BindToTree. Skip the LoadImage call in that case.
if (aNotify && if (aNotify &&
aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::src) { aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::src) {
@ -569,7 +569,7 @@ nsHTMLImageElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
// Force image loading here, so that we'll try to load the image from // Force image loading here, so that we'll try to load the image from
// network if it's set to be not cacheable... // network if it's set to be not cacheable...
ImageURIChanged(aValue, PR_TRUE, aNotify); LoadImage(aValue, PR_TRUE, aNotify);
if (mCurrentRequest && !mPendingRequest && if (mCurrentRequest && !mPendingRequest &&
oldCurrentRequest != mCurrentRequest) { oldCurrentRequest != mCurrentRequest) {
@ -604,7 +604,7 @@ nsHTMLImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) { if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) {
// Note: no need to notify here; since we're just now being bound // Note: no need to notify here; since we're just now being bound
// we don't have any frames or anything yet. // we don't have any frames or anything yet.
ImageURIChanged(uri, PR_FALSE, PR_FALSE); LoadImage(uri, PR_FALSE, PR_FALSE);
} }
return rv; return rv;

Просмотреть файл

@ -431,7 +431,7 @@ nsHTMLInputElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
} else if (aNotify && aName == nsHTMLAtoms::src && } else if (aNotify && aName == nsHTMLAtoms::src &&
aValue && mType == NS_FORM_INPUT_IMAGE) { aValue && mType == NS_FORM_INPUT_IMAGE) {
// Null value means the attr got unset; don't trigger on that // Null value means the attr got unset; don't trigger on that
ImageURIChanged(*aValue, PR_TRUE, aNotify); LoadImage(*aValue, PR_TRUE, aNotify);
} else if (aNotify && aName == nsHTMLAtoms::disabled) { } else if (aNotify && aName == nsHTMLAtoms::disabled) {
SET_BOOLBIT(mBitField, BF_DISABLED_CHANGED, PR_TRUE); SET_BOOLBIT(mBitField, BF_DISABLED_CHANGED, PR_TRUE);
} }
@ -525,7 +525,7 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
// whether we have an image to load; // whether we have an image to load;
nsAutoString src; nsAutoString src;
if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src)) { if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src)) {
ImageURIChanged(src, PR_FALSE, aNotify); LoadImage(src, PR_FALSE, aNotify);
} }
} }
} }
@ -1685,7 +1685,7 @@ nsHTMLInputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) { if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) {
// Note: no need to notify here; since we're just now being bound // Note: no need to notify here; since we're just now being bound
// we don't have any frames or anything yet. // we don't have any frames or anything yet.
ImageURIChanged(uri, PR_FALSE, PR_FALSE); LoadImage(uri, PR_FALSE, PR_FALSE);
} }
} }

Просмотреть файл

@ -111,7 +111,7 @@ public:
protected: protected:
/** /**
* Calls ObjectURIChanged with the correct arguments to start the plugin * Calls LoadObject with the correct arguments to start the plugin
* load. * load.
*/ */
NS_HIDDEN_(void) StartObjectLoad(PRBool aNotify); NS_HIDDEN_(void) StartObjectLoad(PRBool aNotify);
@ -223,17 +223,17 @@ nsHTMLObjectElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue, nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify) PRBool aNotify)
{ {
// If we plan to call ObjectURIChanged, we want to do it first so that the // If we plan to call LoadObject, we want to do it first so that the
// object load kicks off _before_ the reflow triggered by the SetAttr. But if // object load kicks off _before_ the reflow triggered by the SetAttr. But if
// aNotify is false, we are coming from the parser or some such place; we'll // aNotify is false, we are coming from the parser or some such place; we'll
// get bound after all the attributes have been set, so we'll do the // get bound after all the attributes have been set, so we'll do the
// object load from BindToTree/DoneAddingChildren. // object load from BindToTree/DoneAddingChildren.
// Skip the ObjectURIChanged call in that case. // Skip the LoadObject call in that case.
if (aNotify && if (aNotify &&
aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::data) { aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::data) {
nsAutoString type; nsAutoString type;
GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type); GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type);
ObjectURIChanged(aValue, aNotify, NS_ConvertUTF16toUTF8(type), PR_FALSE, PR_TRUE); LoadObject(aValue, aNotify, NS_ConvertUTF16toUTF8(type), PR_FALSE, PR_TRUE);
} }
@ -426,9 +426,9 @@ nsHTMLObjectElement::StartObjectLoad(PRBool aNotify)
// That handles the case where no URI is specified. An empty string would get // That handles the case where no URI is specified. An empty string would get
// interpreted as the page itself, instead of absence of URI. // interpreted as the page itself, instead of absence of URI.
if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, uri)) { if (!GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, uri)) {
ObjectURIChanged(nsnull, aNotify, ctype); LoadObject(nsnull, aNotify, ctype);
} else { } else {
ObjectURIChanged(uri, aNotify, ctype); LoadObject(uri, aNotify, ctype);
} }
} }

Просмотреть файл

@ -532,11 +532,11 @@ nsHTMLSharedElement::BindToTree(nsIDocument* aDocument,
nsAutoString uri; nsAutoString uri;
if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) { if (GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri)) {
// Don't notify: We aren't in a document yet, so we have no frames // Don't notify: We aren't in a document yet, so we have no frames
ObjectURIChanged(uri, PR_FALSE, NS_ConvertUTF16toUTF8(type), PR_TRUE); LoadObject(uri, PR_FALSE, NS_ConvertUTF16toUTF8(type), PR_TRUE);
} else { } else {
// Sometimes, code uses <embed> with no src attributes, for example using // Sometimes, code uses <embed> with no src attributes, for example using
// code="...". Handle that case. // code="...". Handle that case.
ObjectURIChanged(nsnull, PR_FALSE, NS_ConvertUTF16toUTF8(type), PR_TRUE); LoadObject(nsnull, PR_FALSE, NS_ConvertUTF16toUTF8(type), PR_TRUE);
} }
} }
return rv; return rv;
@ -560,16 +560,16 @@ nsHTMLSharedElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
PRBool aNotify) PRBool aNotify)
{ {
if (mNodeInfo->Equals(nsHTMLAtoms::embed)) { if (mNodeInfo->Equals(nsHTMLAtoms::embed)) {
// If we plan to call ObjectURIChanged, we want to do it first so that the // If we plan to call LoadObject, we want to do it first so that the
// image load kicks off _before_ the reflow triggered by the SetAttr. But if // image load kicks off _before_ the reflow triggered by the SetAttr. But if
// aNotify is false, we are coming from the parser or some such place; we'll // aNotify is false, we are coming from the parser or some such place; we'll
// get bound after all the attributes have been set, so we'll do the // get bound after all the attributes have been set, so we'll do the
// object load from BindToTree. Skip the ObjectURIChanged call in that case. // object load from BindToTree. Skip the LoadObject call in that case.
if (aNotify && if (aNotify &&
aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::src) { aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::src) {
nsAutoString type; nsAutoString type;
GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type); GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type);
ObjectURIChanged(aValue, aNotify, NS_ConvertUTF16toUTF8(type), PR_TRUE, PR_TRUE); LoadObject(aValue, aNotify, NS_ConvertUTF16toUTF8(type), PR_TRUE, PR_TRUE);
} }
} }

Просмотреть файл

@ -387,7 +387,7 @@ nsSVGImageElement::DidModifySVGObservable(nsISVGValue* aObservable,
return NS_OK; return NS_OK;
} }
ImageURIChanged(href, PR_TRUE, PR_TRUE); LoadImage(href, PR_TRUE, PR_TRUE);
} }
return nsSVGImageElementBase::DidModifySVGObservable(aObservable, aModType); return nsSVGImageElementBase::DidModifySVGObservable(aObservable, aModType);