Closed
Bug 324572
Opened 19 years ago
Closed 19 years ago
More nsINode work
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: sicking, Assigned: sicking)
References
Details
Attachments
(2 files, 2 obsolete files)
62.75 KB,
patch
|
Details | Diff | Splinter Review | |
3.27 KB,
patch
|
bzbarsky
:
review+
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
Patch coming up that makes nsIAttribute inherit nsINode and that moves the property methods to nsINode.
I added a proper implementation for the property methods to nsGenericDOMDataNode so that all nsINodes support properties. Almost all code was already there since data nodes already supported user-data.
The childnode of attributes behave sort of badly. First of all the childnode will not claim to have a parent. This is because we can't set an nsIContent parent. Second, if someone places the childnode elsewhere in the tree we won't remove it as a child of the attribute.
However both these problems existed before this patch too. We should fix this, but that's for a different bug.
I also fixed some unefficient code in nsDOMAttribute::GetValue to speed up the child iteration methods.
Assignee | ||
Comment 1•19 years ago
|
||
Assignee: general → bugmail
Status: NEW → ASSIGNED
Attachment #209517 -
Flags: superreview?(bzbarsky)
Attachment #209517 -
Flags: review?
Assignee | ||
Updated•19 years ago
|
Attachment #209517 -
Flags: review? → review?(bzbarsky)
Comment 2•19 years ago
|
||
Comment on attachment 209517 [details] [diff] [review]
Patch to fix
So per IRC discussion, we should consider just implementing the property stuff on nsINode (as virtual methods, but ones with impls) and not having 4 copies of it in the tree. generic elements and generic DOM data nodes will need to override SetProperty to set their bits, but that's it.
>Index: content/base/public/nsIAttribute.h
Worth including nsINode.h here too? Right now it comes in via nsIContent.h, but to be safe?
Also, change the IID.
>Index: content/base/public/nsINode.h
This needs a new IID. So do all interfaces inheriting from this (specifically, nsIContent and nsIDocument).
> #include "nsCOMPtr.h"
>+#include "nsPropertyTable.h"
Hmm.... Should both those includes perhaps be inside the #ifdef MOZILLA_INTERNAL_API? I think they should, since neither is needed if that's not defined.
>+ * Get a property associated with this node.
....
>+ * @return the property.
"null if the property is not set (though a null return value does not imply the property was not set)"?
>+ * Set a property to be associated with this node. Will overwrite existing
"This will overwrite an existing ..."
>+ * value if one exists. The existing value is destroyed using the descrution
s/descrution/destructor/, I would say.
>+ * @param aDtor descrutor function to be used when this property
s/descrutor/destructor/
>+ * Destroys a property associated with this node. The value is destroyed
>+ * using the descrution function given when that value was set.
s/descrution/destruction/
>+ * Unset a property associated with this node. The value will not be
>+ * destroyed but rather returned.
"It is the caller's responsibility to destroy the value after that point" perhaps?
>+ * @return the property
"null if the property is not set (though a null return value does not imply the property was not set)"?
"?
>Index: content/base/src/nsDOMAttribute.cpp
>+nsDOMAttribute::EnsureChild(PRBool aSetText, PRBool &aHasChild) const
This should not bother creating mChild if it's null and the value is empty.
And maybe "EnsureChildState()" is a better name?
The rest looks ok. I'd like to see the updated patch, though.
Attachment #209517 -
Flags: superreview?(bzbarsky)
Attachment #209517 -
Flags: superreview-
Attachment #209517 -
Flags: review?(bzbarsky)
Attachment #209517 -
Flags: review-
Assignee | ||
Comment 3•19 years ago
|
||
> And maybe "EnsureChildState()" is a better name?
I prefer EnsureChild since this doesn't touch any other state.
No longer blocks: 324600
Assignee | ||
Comment 4•19 years ago
|
||
This fixes bzs comments. I did also notice that we're inconsistent in which pointer we use to store/remove stuff in the properties table. Sometimes we use the nsIDOMNode pointer, sometimes the nsIContent pointer, and sometimes just |this|.
The end result is that we can "leak" properties until the document goes away.
So made us always use the nsINode pointer by making the userdata apis on nsIDocument use |nsINode*| rather then |nsISupports*|. Sorry about the extra changes in the new patch :(
Attachment #209517 -
Attachment is obsolete: true
Attachment #209557 -
Flags: superreview?(bzbarsky)
Attachment #209557 -
Flags: review?(bzbarsky)
Comment 5•19 years ago
|
||
> I prefer EnsureChild since this doesn't touch any other state.
But it does more than ensure that mChild exists -- it ensures that the text value in it is correct (in some cases).
Blocks: 324600
Comment 6•19 years ago
|
||
Comment on attachment 209557 [details] [diff] [review]
patch v2
So... where were we using inconsistent pointers for the user data stuff? I agree that it's better to use nsINode, but I'm curious to see where it was wrong before. Note that nsIDOMAttr is the primary nsISupports pointer for nsDOMAttribute.
The userdata stuff is trunk-only, right?
>Index: base/src/nsDOMAttribute.cpp
>+nsDOMAttribute::EnsureChild(PRBool aSetText, PRBool &aHasChild) const
>+ if (aSetText) {
>+ mChild->SetText(value, PR_TRUE);
>+ }
mChild can be null here if value is empty. Need to check.
I still think EnsureChildState is a better name, but either way.
r+sr=bzbarsky with that fixed.
Attachment #209557 -
Flags: superreview?(bzbarsky)
Attachment #209557 -
Flags: superreview+
Attachment #209557 -
Flags: review?(bzbarsky)
Attachment #209557 -
Flags: review+
Assignee | ||
Comment 7•19 years ago
|
||
Turns out we're never using the wrong pointer on trunk as is. The inconsitencies I was seing were all either from the fact that we use different primary nsISupports for different node-types or from the new code.
Ideally we should make propertytable use typed interfaces rather then just void* as key to avoid people from making the same misstake I did. I have an idea to use c++ magic to accomplish that in an extensible manner, but that's for a different bug.
Changed the name to EnsureChildState.
Assignee | ||
Comment 8•19 years ago
|
||
Oh, I removed a the same casts from nsDocument UserData functions that I had removed from the other classes.
Assignee | ||
Comment 9•19 years ago
|
||
This is what i just checked in
Attachment #209557 -
Attachment is obsolete: true
Assignee | ||
Comment 10•19 years ago
|
||
Doh! I didn't remove the property method implementations from nsDOMAttribute.
Attachment #209635 -
Flags: superreview?(bzbarsky)
Attachment #209635 -
Flags: review?(bzbarsky)
Comment 11•19 years ago
|
||
Comment on attachment 209635 [details] [diff] [review]
Remove property methods from nsDOMAttribute
Bring on the code removal!
Attachment #209635 -
Flags: superreview?(bzbarsky)
Attachment #209635 -
Flags: superreview+
Attachment #209635 -
Flags: review?(bzbarsky)
Attachment #209635 -
Flags: review+
Assignee | ||
Comment 12•19 years ago
|
||
Checked in, thanks for the reviews
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•