Bug 212133 take two. Make images load only after they get a parent if they are

coming from the sink.  Hopefully with better perf this time.  r=caillon, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2003-07-11 20:00:31 +00:00
Родитель 0f3a3e3df1
Коммит 462ea831db
1 изменённых файлов: 49 добавлений и 5 удалений

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

@ -140,6 +140,10 @@ public:
// XXXbz What about UnsetAttr? We don't seem to unload images when
// that happens...
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
NS_IMETHOD SetParent(nsIContent* aParent);
protected:
void GetImageFrame(nsIImageFrame** aImageFrame);
nsresult GetXY(PRInt32* aX, PRInt32* aY);
@ -614,9 +618,13 @@ NS_IMETHODIMP
nsHTMLImageElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, PRBool aNotify)
{
// Call ImageURIChanged first so that the image load kicks off
// _before_ the reflow triggered by the SetAttr
if (aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::src) {
// If we plan to call ImageURIChanged, we want to do it first so that the
// 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
// get our parent set after all the attributes have been set, so we'll do the
// image load from SetParent. Skip the ImageURIChanged call in that case.
if (aNotify &&
aNameSpaceID == kNameSpaceID_None && aName == nsHTMLAtoms::src) {
ImageURIChanged(aValue);
}
@ -631,6 +639,42 @@ nsHTMLImageElement::SetAttr(nsINodeInfo* aNodeInfo, const nsAString& aValue,
return nsGenericHTMLLeafElement::SetAttr(aNodeInfo, aValue, aNotify);
}
NS_IMETHODIMP
nsHTMLImageElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers)
{
PRBool documentChanged = aDocument && (aDocument != mDocument);
nsresult rv = nsGenericHTMLLeafElement::SetDocument(aDocument, aDeep,
aCompileEventHandlers);
if (documentChanged && mParent) {
// Our base URI may have changed; claim that our URI changed, and the
// nsImageLoadingContent will decide whether a new image load is warranted.
nsAutoString uri;
nsresult result = GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri);
if (result == NS_CONTENT_ATTR_HAS_VALUE) {
ImageURIChanged(uri);
}
}
return rv;
}
NS_IMETHODIMP
nsHTMLImageElement::SetParent(nsIContent* aParent)
{
nsresult rv = nsGenericHTMLLeafElement::SetParent(aParent);
if (aParent && mDocument) {
// Our base URI may have changed; claim that our URI changed, and the
// nsImageLoadingContent will decide whether a new image load is warranted.
nsAutoString uri;
nsresult result = GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, uri);
if (result == NS_CONTENT_ATTR_HAS_VALUE) {
ImageURIChanged(uri);
}
}
return rv;
}
NS_IMETHODIMP
nsHTMLImageElement::Initialize(JSContext* aContext, JSObject *aObj,
PRUint32 argc, jsval *argv)