Fixed image.src=. Forwarded AttributeChanged notifications from nsPlaceholderFrame to its anchored item. Got rid of redundant calls to AttributeChanged.

This commit is contained in:
vidur%netscape.com 1998-09-28 21:22:31 +00:00
Родитель 12787b5f3f
Коммит 13c5a9aba4
8 изменённых файлов: 86 добавлений и 84 удалений

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

@ -1197,6 +1197,7 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
mContent->StringToAttribute(aAttribute, aValue, val)) {
// string value was mapped to nsHTMLValue, set it that way
result = SetAttribute(aAttribute, val, aNotify);
return result;
}
else {
// set as string value to avoid another string copy

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

@ -71,10 +71,6 @@ public:
nsIFrame** aFrame,
nsIContent** aContent,
PRInt32& aCursor);
NS_IMETHOD ContentChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsISupports* aSubContent);
NS_IMETHOD AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
@ -898,29 +894,36 @@ ImageFrame::GetCursorAndContentAt(nsIPresContext& aPresContext,
}
NS_IMETHODIMP
ImageFrame::ContentChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsISupports* aSubContent)
ImageFrame::AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute)
{
// See if the src attribute changed; if it did then trigger a redraw
// by firing up a new image load request. Otherwise let our base
// class handle the content-changed request.
nsAutoString oldSRC;
mImageLoader.GetURL(oldSRC);
nsresult rv = nsLeafFrame::AttributeChanged(aShell, aPresContext, aChild,
aAttribute);
if (NS_OK != rv) {
return rv;
}
if ((nsHTMLAtoms::width == aAttribute) ||
(nsHTMLAtoms::height == aAttribute)) {
nsHTMLContainerFrame::ApplyStyleChangeToTree(*aPresContext, this);
nsHTMLContainerFrame::StyleChangeReflow(*aPresContext, this);
}
else if (nsHTMLAtoms::src == aAttribute) {
nsAutoString oldSRC;
mImageLoader.GetURL(oldSRC);
nsAutoString newSRC;
// Get src attribute's value and construct a new absolute url from it
nsAutoString newSRC;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", newSRC)) {
aChild->GetAttribute("src", newSRC);
if (!oldSRC.Equals(newSRC)) {
mSizeFrozen = PR_TRUE;
#ifdef NS_DEBUG
char oldcbuf[100], newcbuf[100];
oldSRC.ToCString(oldcbuf, sizeof(oldcbuf));
newSRC.ToCString(newcbuf, sizeof(newcbuf));
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("ImageFrame::ContentChanged: new image source; old='%s' new='%s'",
("ImageFrame::AttributeChanged: new image source; old='%s' new='%s'",
oldcbuf, newcbuf));
#endif
@ -934,8 +937,8 @@ ImageFrame::ContentChanged(nsIPresShell* aShell,
PR_FALSE, loadStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("ImageFrame::ContentChanged: loadImage status=%x",
loadStatus));
("ImageFrame::AttributeChanged: loadImage status=%x",
loadStatus));
// If the image is already ready then we need to trigger a
// redraw because the image loader won't.
@ -954,30 +957,8 @@ ImageFrame::ContentChanged(nsIPresShell* aShell,
vm->UpdateView(view, bounds, 0);
NS_RELEASE(vm);
}
return NS_OK;
}
}
return ImageFrameSuper::ContentChanged(aShell, aPresContext, aChild,
aSubContent);
}
NS_IMETHODIMP
ImageFrame::AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute)
{
nsresult rv = nsLeafFrame::AttributeChanged(aShell, aPresContext, aChild,
aAttribute);
if (NS_OK != rv) {
return rv;
}
if ((nsHTMLAtoms::width == aAttribute) ||
(nsHTMLAtoms::height == aAttribute)) {
nsHTMLContainerFrame::ApplyStyleChangeToTree(*aPresContext, this);
nsHTMLContainerFrame::StyleChangeReflow(*aPresContext, this);
}
return NS_OK;
}

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

@ -154,6 +154,20 @@ NS_IMETHODIMP nsPlaceholderFrame::ContentChanged(nsIPresShell* aShell,
return NS_OK;
}
NS_IMETHODIMP
nsPlaceholderFrame::AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute)
{
// Forward the notification to the floater
if (nsnull != mAnchoredItem) {
return mAnchoredItem->AttributeChanged(aShell, aPresContext, aChild, aAttribute);
}
return NS_OK;
}
NS_IMETHODIMP nsPlaceholderFrame::ListTag(FILE* out) const
{
fputs("*placeholder", out);

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

@ -55,6 +55,11 @@ public:
nsIContent* aChild,
nsISupports* aSubContent);
NS_IMETHOD AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute);
NS_IMETHOD ListTag(FILE* out = stdout) const;
protected:

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

@ -71,10 +71,6 @@ public:
nsIFrame** aFrame,
nsIContent** aContent,
PRInt32& aCursor);
NS_IMETHOD ContentChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsISupports* aSubContent);
NS_IMETHOD AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
@ -898,29 +894,36 @@ ImageFrame::GetCursorAndContentAt(nsIPresContext& aPresContext,
}
NS_IMETHODIMP
ImageFrame::ContentChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsISupports* aSubContent)
ImageFrame::AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute)
{
// See if the src attribute changed; if it did then trigger a redraw
// by firing up a new image load request. Otherwise let our base
// class handle the content-changed request.
nsAutoString oldSRC;
mImageLoader.GetURL(oldSRC);
nsresult rv = nsLeafFrame::AttributeChanged(aShell, aPresContext, aChild,
aAttribute);
if (NS_OK != rv) {
return rv;
}
if ((nsHTMLAtoms::width == aAttribute) ||
(nsHTMLAtoms::height == aAttribute)) {
nsHTMLContainerFrame::ApplyStyleChangeToTree(*aPresContext, this);
nsHTMLContainerFrame::StyleChangeReflow(*aPresContext, this);
}
else if (nsHTMLAtoms::src == aAttribute) {
nsAutoString oldSRC;
mImageLoader.GetURL(oldSRC);
nsAutoString newSRC;
// Get src attribute's value and construct a new absolute url from it
nsAutoString newSRC;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("SRC", newSRC)) {
aChild->GetAttribute("src", newSRC);
if (!oldSRC.Equals(newSRC)) {
mSizeFrozen = PR_TRUE;
#ifdef NS_DEBUG
char oldcbuf[100], newcbuf[100];
oldSRC.ToCString(oldcbuf, sizeof(oldcbuf));
newSRC.ToCString(newcbuf, sizeof(newcbuf));
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("ImageFrame::ContentChanged: new image source; old='%s' new='%s'",
("ImageFrame::AttributeChanged: new image source; old='%s' new='%s'",
oldcbuf, newcbuf));
#endif
@ -934,8 +937,8 @@ ImageFrame::ContentChanged(nsIPresShell* aShell,
PR_FALSE, loadStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("ImageFrame::ContentChanged: loadImage status=%x",
loadStatus));
("ImageFrame::AttributeChanged: loadImage status=%x",
loadStatus));
// If the image is already ready then we need to trigger a
// redraw because the image loader won't.
@ -954,30 +957,8 @@ ImageFrame::ContentChanged(nsIPresShell* aShell,
vm->UpdateView(view, bounds, 0);
NS_RELEASE(vm);
}
return NS_OK;
}
}
return ImageFrameSuper::ContentChanged(aShell, aPresContext, aChild,
aSubContent);
}
NS_IMETHODIMP
ImageFrame::AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute)
{
nsresult rv = nsLeafFrame::AttributeChanged(aShell, aPresContext, aChild,
aAttribute);
if (NS_OK != rv) {
return rv;
}
if ((nsHTMLAtoms::width == aAttribute) ||
(nsHTMLAtoms::height == aAttribute)) {
nsHTMLContainerFrame::ApplyStyleChangeToTree(*aPresContext, this);
nsHTMLContainerFrame::StyleChangeReflow(*aPresContext, this);
}
return NS_OK;
}

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

@ -154,6 +154,20 @@ NS_IMETHODIMP nsPlaceholderFrame::ContentChanged(nsIPresShell* aShell,
return NS_OK;
}
NS_IMETHODIMP
nsPlaceholderFrame::AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute)
{
// Forward the notification to the floater
if (nsnull != mAnchoredItem) {
return mAnchoredItem->AttributeChanged(aShell, aPresContext, aChild, aAttribute);
}
return NS_OK;
}
NS_IMETHODIMP nsPlaceholderFrame::ListTag(FILE* out) const
{
fputs("*placeholder", out);

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

@ -55,6 +55,11 @@ public:
nsIContent* aChild,
nsISupports* aSubContent);
NS_IMETHOD AttributeChanged(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aChild,
nsIAtom* aAttribute);
NS_IMETHOD ListTag(FILE* out = stdout) const;
protected:

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

@ -1197,6 +1197,7 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
mContent->StringToAttribute(aAttribute, aValue, val)) {
// string value was mapped to nsHTMLValue, set it that way
result = SetAttribute(aAttribute, val, aNotify);
return result;
}
else {
// set as string value to avoid another string copy