Closed
Bug 264308
Opened 21 years ago
Closed 20 years ago
Implement DOM Level 3 UserData API
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: peterv, Assigned: peterv)
References
Details
(Keywords: dev-doc-complete)
Attachments
(1 file, 4 obsolete files)
62.23 KB,
patch
|
jst
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
Assignee | ||
Comment 1•21 years ago
|
||
May still crash and leak.
Assignee | ||
Comment 2•21 years ago
|
||
This doesn't leak. Last remaining problem: we call the handler twice on
importNode (because it does a cloneNode internally). Not sure how to fix it
yet.
Attachment #166151 -
Attachment is obsolete: true
Assignee | ||
Comment 3•21 years ago
|
||
Attachment #172568 -
Attachment is obsolete: true
Attachment #173906 -
Flags: review?(bugmail)
I'll try to start looking at this this weekend
Assignee | ||
Comment 5•20 years ago
|
||
Attachment #173906 -
Attachment is obsolete: true
Assignee | ||
Updated•20 years ago
|
Attachment #173906 -
Flags: review?(bugmail)
Assignee | ||
Updated•20 years ago
|
Attachment #195743 -
Flags: superreview?(jst)
Attachment #195743 -
Flags: review?(jst)
Comment 6•20 years ago
|
||
Comment on attachment 195743 [details] [diff] [review]
v2.1
> #define NS_IDOCUMENT_IID \
>@@ -778,6 +780,39 @@ public:
> */
> virtual void NotifyURIVisitednessChanged(nsIURI* aURI) = 0;
>
>+ nsresult SetUserData(const nsISupports *aObject, const nsAString &aKey,
>+ nsIVariant *aData, nsIDOMUserDataHandler *aHandler,
>+ nsIVariant **aResult)
>+ {
>+ nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
>+ if (!key) {
>+ return NS_ERROR_OUT_OF_MEMORY;
>+ }
>+
>+ return SetUserData(aObject, key, aData, aHandler, aResult);
>+ }
>+ virtual nsresult SetUserData(const nsISupports *aObject, nsIAtom *aKey,
>+ nsIVariant *aData,
>+ nsIDOMUserDataHandler *aHandler,
>+ nsIVariant **aResult) = 0;
>+ nsresult GetUserData(nsISupports *aObject, const nsAString &aKey,
>+ nsIVariant **aResult)
>+ {
>+ nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
>+ if (!key) {
>+ return NS_ERROR_OUT_OF_MEMORY;
>+ }
>+
>+ return GetUserData(aObject, key, aResult);
>+ }
>+ virtual nsresult GetUserData(const nsISupports *aObject, nsIAtom *aKey,
>+ nsIVariant **aResult) = 0;
>+ virtual void CallUserDataHandler(PRUint16 aOperation,
>+ const nsISupports *aObject,
>+ nsIDOMNode *aSource, nsIDOMNode *aDest) = 0;
>+ virtual void TransferUserData(const nsISupports *aObject,
>+ nsIDocument *aDestination) = 0;
>+
Could you add some documentation about these methods.
(In reply to comment #6)
> Could you add some documentation about these methods.
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-getUserData
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-setUserData
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#UserDataHandler
Comment 8•20 years ago
|
||
(In reply to comment #7)
> (In reply to comment #6)
>
> > Could you add some documentation about these methods.
>
>
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-getUserData
>
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-setUserData
> http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#UserDataHandler
>
Those links applies to the methods in
http://lxr.mozilla.org/seamonkey/source/dom/public/idl/core/nsIDOM3Node.idl#82
etc. But I'd like to see comments what the methods in nsIDocument are doing
(not nsIDOM3Document, not nsIDOM3Node, but nsIDocument) ;)
Assignee | ||
Comment 9•20 years ago
|
||
Assignee | ||
Updated•20 years ago
|
Attachment #195743 -
Attachment is obsolete: true
Attachment #199167 -
Flags: superreview?(jst)
Attachment #199167 -
Flags: review?(jst)
Assignee | ||
Updated•20 years ago
|
Attachment #195743 -
Flags: superreview?(jst)
Attachment #195743 -
Flags: review?(jst)
Comment 10•20 years ago
|
||
Comment on attachment 199167 [details] [diff] [review]
v2.2
- In CallHandler() (in nsDocument.cpp):
+ nsresult rv = handlerData->mDocument->GetUserData(object, aKey,
+ getter_AddRefs(data));
+ if (NS_SUCCEEDED(rv)) {
+ nsAutoString key;
+ aKey->ToString(key);
+ handler->Handle(handlerData->mOperation, key, data, handlerData->mSource,
+ handlerData->mDest);
Shouldn't the condition for getting in here be if (data), or if (NS_SUCCEEDED(rv) && data)? Seems like GetUserData() always returns NS_OK, even if there is no data (as it IMO should)...
r+sr=jst
Attachment #199167 -
Flags: superreview?(jst)
Attachment #199167 -
Flags: superreview+
Attachment #199167 -
Flags: review?(jst)
Attachment #199167 -
Flags: review+
Assignee | ||
Comment 11•20 years ago
|
||
(In reply to comment #10)
> (From update of attachment 199167 [details] [diff] [review] [edit])
> - In CallHandler() (in nsDocument.cpp):
>
> + nsresult rv = handlerData->mDocument->GetUserData(object, aKey,
> + getter_AddRefs(data));
> + if (NS_SUCCEEDED(rv)) {
> + nsAutoString key;
> + aKey->ToString(key);
> + handler->Handle(handlerData->mOperation, key, data, handlerData->mSource,
> + handlerData->mDest);
>
> Shouldn't the condition for getting in here be if (data), or if
> (NS_SUCCEEDED(rv) && data)? Seems like GetUserData() always returns NS_OK, even
> if there is no data (as it IMO should)...
I made sure that we only set a handler if we've set data, so I added an assertion here instead.
I also changed the IIDs for nsIContent, nsIDocument and nsIDOMUserDataHandler.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Comment 12•20 years ago
|
||
Caused a crash [@ nsPropertyTable::DeleteAllPropertiesFor] in bug 314075?
Depends on: 324871
Comment 13•19 years ago
|
||
I'd like to have tests written for this. Examples of setUserData() and getUserData() are not easy to find, even on codesearch.google.com. A search on lxr shows only glazou's composer code is using it, and he's not setting any UserDataHandler objects in his calls.
Flags: in-testsuite?
Assignee | ||
Comment 14•19 years ago
|
||
There are at least some tests in the W3C DOM testsuite.
Updated•19 years ago
|
Keywords: dev-doc-needed
Comment 15•18 years ago
|
||
I'm not sure how or where to document these; there's very, very little information available about them. Can someone point me in the direction of where to actually find those tests in the testsuite? I don't happen to know where it is.
Assignee | ||
Comment 16•18 years ago
|
||
http://dev.w3.org/cvsweb/2001/DOM-Test-Suite/tests/level3/core/ contains some of the raw tests (look for files that contain userdata). I personally don't have the html versions of the tests anymore and we haven't imported the DOM Level 3 Core tests into our testsuite yet. I'll see if I can generate just the UserData ones.
Some spec links:
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-getUserData
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-setUserData
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#UserDataHandler
Comment 17•18 years ago
|
||
Yeah, I'm looking at that Java code now. I guess I'll sit down and do some HTML/JS code myself for this.
Comment 18•16 years ago
|
||
FWIW:
https://developer.mozilla.org/en/DOM/Node.setUserData
https://developer.mozilla.org/en/DOM/Node.getUserData
Didn't proof-read those pages though.
Comment 19•13 years ago
|
||
The following pages are in a good shape with at least some little examples:
https://developer.mozilla.org/en/DOM/UserDataHandler
https://developer.mozilla.org/en/DOM/DOMUserData
https://developer.mozilla.org/en/DOM/Node.getUserData
https://developer.mozilla.org/en/DOM/Node.setUserData
Marking this as completed finally.
Keywords: dev-doc-needed → dev-doc-complete
Updated•13 years ago
|
Flags: in-testsuite?
You need to log in
before you can comment on or make changes to this bug.
Description
•