Closed
Bug 683852
Opened 14 years ago
Closed 14 years ago
Implement Node.contains(node)
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla9
People
(Reporter: mounir, Assigned: smaug)
References
()
Details
(Keywords: dev-doc-complete)
Attachments
(2 files, 1 obsolete file)
11.25 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
11.16 KB,
patch
|
Details | Diff | Splinter Review |
No description provided.
Comment 1•14 years ago
|
||
This is the kind of bug I could do pretty quickly. Would we want anonymous content to show up as true? What about native anonymous content (a la the video element's controls)?
Assignee | ||
Comment 2•14 years ago
|
||
Per spec anonymous content shows up as true only within the same anonymous content (since the spec
relies on parent-to-child chain, not child-to-parent chain).
Assignee | ||
Comment 3•14 years ago
|
||
Sorry Alex. I was in the train and started to write patch for this...
Taking.
Assignee: nobody → Olli.Pettay
Assignee | ||
Comment 4•14 years ago
|
||
Trying to avoid virtual calls, but GetBindingParent is there, and in
some cases IsNodeOfType.
Attachment #557890 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 5•14 years ago
|
||
Comment on attachment 557890 [details] [diff] [review]
patch
>+nsINode::Contains(const nsINode* aOther) const
>+{
>+ if (!aOther ||
>+ aOther == this ||
>+ !(aOther->IsElement() ||
>+ aOther->IsNodeOfType(nsINode::eCONTENT)) ||
>+ !GetFirstChild()) {
This is missing still one thing
.. ||
GetOwnerDoc != aOther->GetOwnerDoc()
Assignee | ||
Comment 6•14 years ago
|
||
Er, GetCurrentDoc != aOther->GetCurrentDoc()
Assignee | ||
Comment 7•14 years ago
|
||
Actually both.
Assignee | ||
Comment 8•14 years ago
|
||
Bah, new patch coming.
![]() |
||
Comment 9•14 years ago
|
||
Does that mean you don't want review on that one?
Assignee | ||
Comment 10•14 years ago
|
||
Attachment #557890 -
Attachment is obsolete: true
Attachment #557890 -
Flags: review?(bzbarsky)
Attachment #557912 -
Flags: review?(bzbarsky)
![]() |
||
Comment 11•14 years ago
|
||
Comment on attachment 557912 [details] [diff] [review]
patch
Once you do the document check, is there a reason to not just use a combination of ContentIsDescendantOf and nsContentUtils::IsInSameAnonymousTree?
Certainly reimplementing ContentIsDescendantOf here is not something we want, I think.
Other than that, looks good.
r=me with the above issue addressed.
Attachment #557912 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 12•14 years ago
|
||
Ah, I could reuse nsContentUtils::ContentIsDescendantOf, but
nsContentUtils::IsInSameAnonymousTree would be bit slower.
![]() |
||
Comment 13•14 years ago
|
||
Yeah, ok. Let's just reuse nsContentUtils::ContentIsDescendantOf.
And maybe we should add more booleans like IsElement() on nsINode...
Assignee | ||
Comment 14•14 years ago
|
||
Updated•14 years ago
|
Keywords: dev-doc-needed
Assignee | ||
Comment 15•14 years ago
|
||
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Comment 16•14 years ago
|
||
FYI, I landed a followup fix [on comm-central] to break bustage for Thunderbird and SeaMonkey.
(Admitedly the comm-* code that depends on this stuff is very very ugly) http://hg.mozilla.org/comm-central/rev/a5f596801e38
Reporter | ||
Comment 17•14 years ago
|
||
Comment on attachment 557929 [details] [diff] [review]
patch
Review of attachment 557929 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/base/src/nsGenericElement.cpp
@@ +5544,5 @@
> + return PR_FALSE;
> + }
> +
> + const nsIContent* other = static_cast<const nsIContent*>(aOther);
> + if (this == GetOwnerDoc()) {
This is *very* confusing I think. If I understand it correctly, we want to check if |this| is a document. right? Isn't there more explicit way to do so?
Assignee | ||
Comment 18•14 years ago
|
||
IsNodeOfType(nsINode::eDOCUMENT) but that is virtual call.
Comment 19•14 years ago
|
||
I guess NodeType() == nsIDOMNode::DOCUMENT_NODE is fast now.
![]() |
||
Comment 20•14 years ago
|
||
We should consider adding IsDocument() on nsINode and backing it with either a boolean flag (we have a bunch of free ones) or the NodeType() check Ms2ger suggests.
Comment 22•14 years ago
|
||
Not fixed,
Pleasre REOPEN, because:
http://host0001.webd.pl/bugs/firefox/contains.html?
theSameElem.contains(theSameElem) should returns TRUE
IE 9, Opera 11.5, Konqueror 4.5, Chrome 13, Safari 5.1 return TRUE
FF 9a1 returns FALSE
Comment 24•14 years ago
|
||
Docs updated:
https://developer.mozilla.org/en/DOM/Node.contains
Mentioned on Firefox 9 for developers.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•