Closed Bug 283004 Opened 20 years ago Closed 20 years ago

Store instance node type as property instead of attribute

Categories

(Core Graveyard :: XForms, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: allan, Assigned: allan)

References

()

Details

Attachments

(2 files, 3 obsolete files)

Right now, we store the type information for instance data nodes directly on the
node as an attribute (nsXFormsModelElement::ProcessBind()). We need to store it
as a property instead.
Attached patch Patch (obsolete) — Splinter Review
Attached patch Correct patch (obsolete) — Splinter Review
Hmmm, something went wrong in the previous patch.

This patch stores the type information as a property instead of as an
attribute.
Attachment #175296 - Attachment is obsolete: true
Attachment #175298 - Flags: review?(doronr)
(In reply to comment #2)
> Created an attachment (id=175298) [edit]

To questions
1) I'm not sure I use SetProperty correct. Will it delete the nsAutoString for me?
2) Should I use nsString instead?
Status: NEW → ASSIGNED
Comment on attachment 175298 [details] [diff] [review]
Correct patch

bryner: could you look at the nsIContent usage and say if its correct/etc?
Attachment #175298 - Flags: superreview?(bryner)
Blocks: 283376
*** Bug 283298 has been marked as a duplicate of this bug. ***
Attached patch Updated patch (obsolete) — Splinter Review
Added a note about bug 283376, and ignored errors for non-content nodes (like
attributes (per bug 283298).
Attachment #175298 - Attachment is obsolete: true
Attachment #175410 - Flags: superreview?(bryner)
Attachment #175410 - Flags: review?(doronr)
(In reply to comment #6)
> Added a note about bug 283376, and ignored errors for non-content nodes (like
> attributes (per bug 283298).

Problem is that the spec states that "However, in contrast to xsi:type, type can
be added to both elements and attributes."
http://www.w3.org/TR/xforms/slice6.html#model-prop-type

and attributes do not implement nsIContent :(
Attachment #175298 - Flags: superreview?(bryner)
Attachment #175298 - Flags: review?(doronr)
would storing it on the nodestate be of any help?  I guess not since we don't
create something on it for the attributes, right?
As Doron found out: Bug 264308 is our friend.
Comment on attachment 175410 [details] [diff] [review]
Updated patch

>+        // Set property
>+        nsAutoString *prop = new nsAutoString(propStrings[j]);

Hm, this is rather unusual (malloc'ing an nsAutoString).  It does work though,
and only mallocs once, instead of twice as it would be if you used an nsString.
 You might ask darin if there's a better way though.

>+        rv = content->SetProperty(sModelPropsList[j],
>+                                  prop,
>+                                  nsnull);

However, you do need a destructor callback, I think.  Otherwise the string
buffer will be leaked.

>--- xforms/nsXFormsUtils.cpp	2005-02-24 08:51:42.000000000 +0100
>+++ xforms.typeproperty/nsXFormsUtils.cpp	2005-02-24 10:27:53.297872008 +0100
>@@ -1015,30 +1016,31 @@ nsXFormsUtils::GetInstanceNodeForData(ns
...
>+  nsAString *typeAttribute = (nsAString*) nodeContent->GetProperty(nsXFormsAtoms::type, &rv);

Cast to nsAutoString (it'll be more efficient to call through).  Also, use
NS_STATIC_CAST.

sr=me with those changes.
Attachment #175410 - Flags: superreview?(bryner) → superreview+
(In reply to comment #10)
> (From update of attachment 175410 [details] [diff] [review] [edit])
> >+        // Set property
> >+        nsAutoString *prop = new nsAutoString(propStrings[j]);
> 
> Hm, this is rather unusual (malloc'ing an nsAutoString).  It does work though,
> and only mallocs once, instead of twice as it would be if you used an nsString.
>  You might ask darin if there's a better way though.

Any comments on this one Darin?
(In reply to comment #7)
> (In reply to comment #6)
> > Added a note about bug 283376, and ignored errors for non-content nodes (like
> > attributes (per bug 283298).
> 
> Problem is that the spec states that "However, in contrast to xsi:type, type can
> be added to both elements and attributes."
> http://www.w3.org/TR/xforms/slice6.html#model-prop-type
> 
> and attributes do not implement nsIContent :(

Looked some more on this. Funnily enough attributes implement nsIAttribute ...
and it's possible to get to the nsIContent through that. Problem is that it is
the nsIContent for the node with the attribute, so that does not help us. I feel
we are heading in the wrong direction here :( Question is then where to store it. 

Should we really store it in the MDG? I've been somewhat reluctant about that,
as I do not feel that type information belongs there. Maybe just a simple
hashmap (nsIDOMnode, nsAString) on the model? What do you say?
A hashmap would work probably.  Is porting what we need from  Bug 264308 too hard?
If you can't seperate out what you need from the other code, then I'd say go
with the hashmap.
Depends on: 285597
In case you haven't seen, I'm working on bug 285597 and bug 235512 to get this
one working.
Attachment #175410 - Flags: review?(doronr) → review+
Attached file Testcase
Let's do a review round again, just to be sure... it's been a while since it
was originally reviewed.
Attachment #175410 - Attachment is obsolete: true
Attachment #185248 - Flags: review?(smaug)
(In reply to comment #17)
> Created an attachment (id=185248) [edit]
> updated to current CVS
> 
I guess I need Bug 285597 with this patch?

(In reply to comment #18)
> (In reply to comment #17)
> > Created an attachment (id=185248) [edit] [edit]
> > updated to current CVS
> > 
> I guess I need Bug 285597 with this patch?

Sure is. I'll check it in quite soon.
Comment on attachment 185248 [details] [diff] [review]
updated to current CVS

r=me

>+  /// @bug We need to check for any type attributes set directly on the node
>+  /// too (XXX)
>+
Is there a bug open for this?
Attachment #185248 - Flags: review?(smaug)
Attachment #185248 - Flags: review?(aaronr)
Attachment #185248 - Flags: review+
Depends on: 293082
(In reply to comment #20)
> (From update of attachment 185248 [details] [diff] [review] [edit])
> r=me
> 
> >+  /// @bug We need to check for any type attributes set directly on the node
> >+  /// too (XXX)
> >+
> Is there a bug open for this?

I think bug 293082 should fix it.
Comment on attachment 185248 [details] [diff] [review]
updated to current CVS

looks good.  r=me
Attachment #185248 - Flags: review?(aaronr) → review+
Checked in
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: