Closed Bug 330663 Opened 18 years ago Closed 18 years ago

Content builder doesn't synchronize text nodes correctly.

Categories

(Core :: XUL, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: janv, Assigned: enndeakin)

References

Details

Attachments

(1 file, 1 obsolete file)

 
Attached patch trunk patch (obsolete) — Splinter Review
Attachment #215248 - Flags: review?(enndeakin)
*** Bug 321184 has been marked as a duplicate of this bug. ***
Assignee: nobody → enndeakin
Attachment #215248 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #215284 - Flags: superreview?(bzbarsky)
Attachment #215284 - Flags: review?(bzbarsky)
Attachment #215248 - Flags: review?(enndeakin)
yeah, the same approach is used elsewhere
Comment on attachment 215284 [details] [diff] [review]
This is a better patch

>Index: content/xul/templates/src/nsXULContentBuilder.cpp

This bug could have used a pointer to nsXULContentBuilder::BuildContentFromTemplate.  The patch should certainly have a comment pointing to it and saying that the two should stay in sync....  Possibly also a comment in BuildContentFromTemplate about keeping in sync.

In general, it would have been really nice if this bug had actually described the problem; would have saved me a lot of time.  :(

>+            nsIAtom *tag = tmplKid->Tag();
>+            PRInt32 nameSpaceID = tmplKid->GetNameSpaceID();

Why bother?  Why not just use tmplKid->NodeInfo->Equals(....) ?

>+                if (!attrValue.IsEmpty()) {

If we get into this code after changing the template, this looks wrong.  For example, when going from a nonempty attr to an empty one we won't update the value...

Of course when going from an empty attr to a nonempty one we won't even get the right realKid here, will we?  I mean given the similar test in BuildContentFromTemplate?

Or am I misunderstanding when this code is used?

>+                    nsCOMPtr<nsITextContent> textcontent = do_QueryInterface(realKid);
>+                    if (textcontent)

When would that QI return null?
This bug fixes the <textnode value="?label"> case which creates a text node with that label, but it doesn't update dynamically.

> Or am I misunderstanding when this code is used?

The code is used when the RDF data changes in such a way that only the attributes need to be modified, that is, only changes to existing item, no new or removed items. It doesn't have anything to do with <template> itself changing.

I suppose it's possible someone changed the template DOM in the meantime, but that isn't something that needs to be handled in any particular way. 

> 
> >+                    nsCOMPtr<nsITextContent> textcontent = do_QueryInterface(realKid);
> >+                    if (textcontent)
> 
> When would that QI return null?
> 

If someone manipulated the template generated content it might. 

OK.  So we still have a problem with the proposed patch if the RDF changes to/from an empty string, no?
Not that I can see, no. tmplKid is the node in the template, which doesn't change. The value from the RDF gets filled in inside SubstituteText. If it comes out empty, the text node just gets set to a null string. There's isn't an issue with that is there?
Comment on attachment 215284 [details] [diff] [review]
This is a better patch

Ah, I see.  The empty checks are done on the "?whatever" string...  ok.

r+sr=bzbarsky with the comments added.
Attachment #215284 - Flags: superreview?(bzbarsky)
Attachment #215284 - Flags: superreview+
Attachment #215284 - Flags: review?(bzbarsky)
Attachment #215284 - Flags: review+
added the comments and checked in
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: xptoolkit.xul → xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: