The default bug view has changed. See this FAQ.

Implement Node.textContent

RESOLVED FIXED

Status

()

Core
DOM: Core & HTML
RESOLVED FIXED
14 years ago
9 years ago

People

(Reporter: Christopher Aillon (sabbatical, not receiving bugmail), Assigned: Christopher Aillon (sabbatical, not receiving bugmail))

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

So Johnny and I were talking about this earlier, and here's the result.

Also, since DOM Core Level 3 is in last call, I added the remaining stuff in the
spec to nsIDOM3Node.
Created attachment 126338 [details] [diff] [review]
Patch

Patch
Comment on attachment 126338 [details] [diff] [review]
Patch

Pretty straightforward.
Attachment #126338 - Flags: superreview?(jst)
Attachment #126338 - Flags: review?(jst)
Comment on attachment 126338 [details] [diff] [review]
Patch

+[scriptable, uuid(5470deff-03c9-41b7-a824-e3225266b343)]
+interface nsIDOMUserDataHandler

That interface should be marked as a function (see nsIDOMEventListener.idl).

+  void 	      handle(in unsigned short operation, 
+			     in DOMString key, 
+			     in nsISupports data, 
+			     in nsIDOMNode src, 
+			     in nsIDOMNode dst);

I believe |data| should be of type nsIVariant, I think the spec is incorrect in
defining the type of that argument as DOMObject, it should be DOMUserData.
Email sent to the DOM WG.

- In nsDOMAttribute::LookupPrefix():

-  nsresult rv = NS_OK;
+
   nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(mContent));
-  if (node)
-    rv = node->LookupNamespacePrefix(aNamespaceURI, aPrefix);
-  return rv;
+  if (node) {
+    return node->LookupPrefix(aNamespaceURI, aPrefix);
+  }
+
+  return NS_OK;

I *think* the old code is actually less code due to the early return ending up
duplicating nsCOMPtr dtor code in some compilers. Either way is cool with me
tho...

- In nsDocumentFragment::GetTextContent():

+{
+  SetDOMStringToNull(aTextContent);
+
+  return NS_OK;
+}

This isn't per spec, care to make it so? Same for SetTextContent().

Other than that, r+sr=jst
Attachment #126338 - Flags: superreview?(jst)
Attachment #126338 - Flags: superreview+
Attachment #126338 - Flags: review?(jst)
Attachment #126338 - Flags: review+
Created attachment 126392 [details] [diff] [review]
With jst's changes
Attachment #126338 - Attachment is obsolete: true
Comment on attachment 126392 [details] [diff] [review]
With jst's changes

- In nsIDOMUserDataHandler.idl:

+#include "domstubs.idl"
+#include "nsIVariant.h"

That's .idl, not .h :-)

- In nsDocumentFragment::GetTextContent():

+    return nsNode3Tearoff::GetTextContent(mOwnerDocument,
+					   NS_STATIC_CAST(nsIDOMNode*, this),
+					   aTextContent);

No need for a specific cast here, let the compiler cast for you...

+
+nsresult
+nsNode3Tearoff::GetTextContent(nsIDocument *aDocument,
+				nsIDOMNode *aNode,
+				nsAString &aTextContent)

This is a static method, add "// static" above the method declaration.

r+sr=jst
Attachment #126392 - Flags: superreview+
Attachment #126392 - Flags: review+
Created attachment 126400 [details] [diff] [review]
This should probably also be settable :-)

The other patch is landed.  This is an additional patch to make this property
settable.  (I already made it work for attribute nodes, but forgot to implement
the setter for these guys...)
Comment on attachment 126400 [details] [diff] [review]
This should probably also be settable :-)

r+sr=jst
Attachment #126400 - Flags: superreview+
Attachment #126400 - Flags: review+
And with that, FIXED.

See bug 210556 for the only known issue, which is just a serialization problem.
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED

Comment 9

14 years ago
tbox shown codesize increase

  libgklayout.so
  	Total:	      +2208 (+22122/-19914)
  	Code:	      +1888 (+4152/-2264)
  	Data:	       +320 (+17970/-17650)
  	      +1888 (+4152/-2264)	T (CODE)
  		      +1888 (+4152/-2264)	UNDEF:libgklayout.so:T
  			       +772	nsNode3Tearoff::LookupPrefix(nsAString const &, nsAString &)
  			       +404	nsNode3Tearoff::GetTextContent(nsAString &)
  			       +332	nsTextInputSelectionImpl::SetCaretVisibilityDuringSelection(int)
  			       +280	nsNode3Tearoff::GetTextContent(nsIDocument *, nsIDOMNode *,
nsAString &)
  			       +248	nsNode3Tearoff::SetTextContent(nsAString const &)
  			       +200	nsNode3Tearoff::SetTextContent(nsIContent *, nsAString const &)
  			       +188	nsGenericDOMDataNode::LookupPrefix(nsAString const &, nsAString &)
  			       +184	nsDOMAttribute::LookupPrefix(nsAString const &, nsAString &)
  			        +88	nsDocumentFragment::GetTextContent(nsAString &)
  			        +44	nsCommentNode::LookupPrefix(nsAString const &, nsAString &)
  			        +44	nsDOMDocumentType::LookupPrefix(nsAString const &, nsAString &)
  			        +44	nsDocument::GetTextContent(nsAString &)
  			        +44	nsTextNode::LookupPrefix(nsAString const &, nsAString &)
  			        +44	nsXMLCDATASection::LookupPrefix(nsAString const &, nsAString &)
  			        +44	nsXMLProcessingInstruction::LookupPrefix(nsAString const &,
nsAString &)
  			        +40	PresShell::SetCaretVisibilityDuringSelection(int)
  			        +40	nsDocumentFragment::SetTextContent(nsAString const &)
  			        +36	nsContentUtils::GetDynamicScriptContext(JSContext *,
nsIScriptContext **)
  			        +28	nsDocument::LookupPrefix(nsAString const &, nsAString &)
  			        +28	nsDocumentFragment::LookupPrefix(nsAString const &, nsAString &)
  			        +28	virtual function thunk (delta:-32) for
PresShell::SetCaretVisibilityDuringSelection(int)
  			        +28	virtual function thunk (delta:-36) for
nsDocumentFragment::GetFeature(nsAString const &, nsAString const &, nsISupports **)
  			        +28	virtual function thunk (delta:-36) for
nsDocumentFragment::GetTextContent(nsAString &)
  			        +28	virtual function thunk (delta:-36) for
nsDocumentFragment::GetUserData(nsAString const &, nsIVariant **)
  			        +28	virtual function thunk (delta:-36) for
nsDocumentFragment::IsDefaultNamespace(nsAString const &, int *)
  			        +28	virtual function thunk (delta:-36) for
nsDocumentFragment::IsEqualNode(nsIDOMNode *, int *)
  			        +28	virtual function thunk (delta:-36) for
nsDocumentFragment::LookupPrefix(nsAString const &, nsAString &)
  			        +28	virtual function thunk (delta:-36) for
nsDocumentFragment::SetTextContent(nsAString const &)
  			        +28	virtual function thunk (delta:-36) for
nsDocumentFragment::SetUserData(nsAString const &, nsIVariant *,
nsIDOMUserDataHandler *, nsIVariant **)
  			        +28	virtual function thunk (delta:-4) for
nsDOMAttribute::GetFeature(nsAString const &, nsAString const &, nsISupports **)
  			        +28	virtual function thunk (delta:-4) for
nsDOMAttribute::GetTextContent(nsAString &)
  			        +28	virtual function thunk (delta:-4) for
nsDOMAttribute::GetUserData(nsAString const &, nsIVariant **)
  			        +28	virtual function thunk (delta:-4) for
nsDOMAttribute::IsDefaultNamespace(nsAString const &, int *)
  			        +28	virtual function thunk (delta:-4) for
nsDOMAttribute::IsEqualNode(nsIDOMNode *, int *)
  			        +28	virtual function thunk (delta:-4) for
nsDOMAttribute::LookupPrefix(nsAString const &, nsAString &)
  			        +28	virtual function thunk (delta:-4) for
nsDOMAttribute::SetTextContent(nsAString const &)
  			        +28	virtual function thunk (delta:-4) for
nsDOMAttribute::SetUserData(nsAString const &, nsIVariant *,
nsIDOMUserDataHandler *, nsIVariant **)
  			        +28	virtual function thunk (delta:-40) for
nsDocument::GetFeature(nsAString const &, nsAString const &, nsISupports **)
  			        +28	virtual function thunk (delta:-40) for
nsDocument::GetTextContent(nsAString &)
  			        +28	virtual function thunk (delta:-40) for
nsDocument::GetUserData(nsAString const &, nsIVariant **)
  			        +28	virtual function thunk (delta:-40) for
nsDocument::IsDefaultNamespace(nsAString const &, int *)
  			        +28	virtual function thunk (delta:-40) for
nsDocument::IsEqualNode(nsIDOMNode *, int *)
  			        +28	virtual function thunk (delta:-40) for
nsDocument::LookupPrefix(nsAString const &, nsAString &)
  			        +28	virtual function thunk (delta:-40) for
nsDocument::SetTextContent(nsAString const &)
  			        +28	virtual function thunk (delta:-40) for
nsDocument::SetUserData(nsAString const &, nsIVariant *, nsIDOMUserDataHandler
*, nsIVariant **)
  			        +28	virtual function thunk (delta:-8) for
nsTextInputSelectionImpl::SetCaretVisibilityDuringSelection(int)
  			        +20	nsDOMAttribute::GetTextContent(nsAString &)
  			        +20	nsDOMAttribute::SetTextContent(nsAString const &)
  			        +12	nsDOMAttribute::GetFeature(nsAString const &, nsAString const
&, nsISupports **)
  			        +12	nsDOMAttribute::GetUserData(nsAString const &, nsIVariant **)
  			        +12	nsDOMAttribute::IsDefaultNamespace(nsAString const &, int *)
  			        +12	nsDOMAttribute::IsEqualNode(nsIDOMNode *, int *)
  			        +12	nsDOMAttribute::SetUserData(nsAString const &, nsIVariant *,
nsIDOMUserDataHandler *, nsIVariant **)
  			        +12	nsDocument::GetFeature(nsAString const &, nsAString const &,
nsISupports **)
  			        +12	nsDocument::GetUserData(nsAString const &, nsIVariant **)
  			        +12	nsDocument::IsDefaultNamespace(nsAString const &, int *)
  			        +12	nsDocument::IsEqualNode(nsIDOMNode *, int *)
  			        +12	nsDocument::SetTextContent(nsAString const &)
  			        +12	nsDocument::SetUserData(nsAString const &, nsIVariant *,
nsIDOMUserDataHandler *, nsIVariant **)
  			        +12	nsDocumentFragment::GetFeature(nsAString const &, nsAString
const &, nsISupports **)
  			        +12	nsDocumentFragment::GetUserData(nsAString const &, nsIVariant **)
  			        +12	nsDocumentFragment::IsDefaultNamespace(nsAString const &, int *)
  			        +12	nsDocumentFragment::IsEqualNode(nsIDOMNode *, int *)
  			        +12	nsDocumentFragment::SetUserData(nsAString const &, nsIVariant
*, nsIDOMUserDataHandler *, nsIVariant **)
  			        +12	nsNode3Tearoff::GetFeature(nsAString const &, nsAString const
&, nsISupports **)
  			        +12	nsNode3Tearoff::GetUserData(nsAString const &, nsIVariant **)
  			        +12	nsNode3Tearoff::IsDefaultNamespace(nsAString const &, int *)
  			        +12	nsNode3Tearoff::IsEqualNode(nsIDOMNode *, int *)
  			        +12	nsNode3Tearoff::SetUserData(nsAString const &, nsIVariant *,
nsIDOMUserDataHandler *, nsIVariant **)
  			         -4	atexit
  			         -8	nsXULAttribute::~nsXULAttribute(void)
  			        -12	nsXULAttribute::LookupNamespaceURI(nsAString const &, nsAString &)
  			        -12	nsXULAttribute::LookupNamespacePrefix(nsAString const &,
nsAString &)
  			        -12	nsXULAttribute::IsSameNode(nsIDOMNode *, int *)
  			        -12	nsXULAttribute::GetBaseURI(nsAString &)
  			        -12	nsXULAttribute::CompareDocumentPosition(nsIDOMNode *, unsigned
short *)
  			        -20	nsXULAttribute::nsXULAttribute(nsIContent *, nsINodeInfo *,
nsAString const &)
  			        -28	virtual function thunk (delta:-40) for
nsHTMLDocument::LookupNamespaceURI(nsAString const &, nsAString &)
  			        -28	virtual function thunk (delta:-40) for
nsHTMLDocument::LookupNamespacePrefix(nsAString const &, nsAString &)
  			        -28	virtual function thunk (delta:-40) for
nsHTMLDocument::IsSameNode(nsIDOMNode *, int *)
  			        -28	virtual function thunk (delta:-40) for
nsHTMLDocument::CompareDocumentPosition(nsIDOMNode *, unsigned short *)
  			        -28	virtual function thunk (delta:-40) for
nsDocument::LookupNamespacePrefix(nsAString const &, nsAString &)
  			        -28	virtual function thunk (delta:-4) for nsXULAttribute::Release(void)
  			        -28	virtual function thunk (delta:-4) for
nsXULAttribute::QueryInterface(nsID const &, void **)
  			        -28	virtual function thunk (delta:-4) for
nsXULAttribute::LookupNamespaceURI(nsAString const &, nsAString &)
  			        -28	virtual function thunk (delta:-4) for
nsXULAttribute::LookupNamespacePrefix(nsAString const &, nsAString &)
  			        -28	virtual function thunk (delta:-4) for
nsXULAttribute::IsSameNode(nsIDOMNode *, int *)
  			        -28	virtual function thunk (delta:-4) for
nsXULAttribute::GetBaseURI(nsAString &)
  			        -28	virtual function thunk (delta:-4) for
nsXULAttribute::CompareDocumentPosition(nsIDOMNode *, unsigned short *)
  			        -28	virtual function thunk (delta:-4) for nsXULAttribute::AddRef(void)
  			        -28	virtual function thunk (delta:-4) for
nsDOMAttribute::LookupNamespacePrefix(nsAString const &, nsAString &)
  			        -28	virtual function thunk (delta:-36) for
nsDocumentFragment::LookupNamespacePrefix(nsAString const &, nsAString &)
  			        -28	nsDocumentFragment::LookupNamespacePrefix(nsAString const &,
nsAString &)
  			        -28	nsDocument::LookupNamespacePrefix(nsAString const &, nsAString &)
  			        -44	nsXMLProcessingInstruction::LookupNamespacePrefix(nsAString
const &, nsAString &)
  			        -44	nsXMLCDATASection::LookupNamespacePrefix(nsAString const &,
nsAString &)
  			        -44	nsTextNode::LookupNamespacePrefix(nsAString const &, nsAString &)
  			        -44	nsHTMLDocument::LookupNamespaceURI(nsAString const &, nsAString &)
  			        -44	nsHTMLDocument::LookupNamespacePrefix(nsAString const &,
nsAString &)
  			        -44	nsHTMLDocument::IsSameNode(nsIDOMNode *, int *)
  			        -44	nsHTMLDocument::CompareDocumentPosition(nsIDOMNode *, unsigned
short *)
  			        -44	nsDOMDocumentType::LookupNamespacePrefix(nsAString const &,
nsAString &)
  			        -44	nsCommentNode::LookupNamespacePrefix(nsAString const &,
nsAString &)
  			        -68	nsXULAttribute::QueryInterface(nsID const &, void **)
  			       -104	nsContentUtils::GenerateStateKey(nsIContent *,
nsIStatefulFrame::SpecialStateID, nsACString &)
  			       -168	nsDOMAttribute::LookupNamespacePrefix(nsAString const &,
nsAString &)
  			       -188	nsGenericDOMDataNode::LookupNamespacePrefix(nsAString const &,
nsAString &)
  			       -772	nsNode3Tearoff::LookupNamespacePrefix(nsAString const &,
nsAString &)
  	       +256 (+2624/-2368)	D (DATA)
  		       +256 (+2624/-2368)	UNDEF:libgklayout.so:D
  			       +112	attributes.3930
  			       +104	map.3469
  			        +80	attributes.3468
  			        +80	attributes.3474
  			        +80	attributes.3711
  			        +64	classPolicyOps.2472
  			        +64	hash_table_ops.2163
  			        +64	hash_table_ops.2715
  			        +64	hash_table_ops.4375
  			        +64	hash_table_ops.4376
  			        +56	attributes.4125
  			        +48	attributes.3528
  			        +40	attributes.3456
  			        +40	attributes.3495
  			        +40	attributes.3696
  			        +40	kWhitespace.4479
  			        +40	map.3475
  			        +40	map.4126
  			        +36	classPolicyOps.3774
  			        +36	gOps.5148
  			        +36	hash_table_ops.4179
  			        +36	hash_table_ops.4512
  			        +36	hash_table_ops.4569
  			        +32	attributes.2373
  			        +32	attributes.3621
  			        +32	attributes.3685
  			        +32	attributes.4056
  			        +32	attributes.4071
  			        +32	attributes.4546
  			        +32	attributes.4587
  			        +32	kWhitespace.4536
  			        +32	map.2374
  			        +32	map.2430
  			        +32	map.3457
  			        +32	map.3481
  			        +32	map.3622
  			        +32	map.3684
  			        +32	map.3686
  			        +32	map.4057
  			        +32	map.4072
  			        +32	map.4547
  			        +32	map.4588
  			        +32	nsDOMAttribute::nsIDOM3Node virtual table
  			        +32	nsDocument::nsIDOM3Node virtual table
  			        +32	nsDocumentFragment::nsIDOM3Node virtual table
  			        +32	nsHTMLDocument::nsIDOM3Node virtual table
  			        +32	nsIDOM3Node virtual table
  			        +32	nsImageDocument::nsIDOM3Node virtual table
  			        +32	nsNode3Tearoff virtual table
  			        +32	nsPluginDocument::nsIDOM3Node virtual table
  			        +32	nsXMLDocument::nsIDOM3Node virtual table
  			        +32	nsXULDocument::nsIDOM3Node virtual table
  			        +32	whitespace.2838
  			        +28	initializing.5499
  			        +28	list.3256
  			        +28	map.5514
  			        +28	visitorFalse.5365
  			        +24	attributes.4011
  			        +24	map.3496
  			        +24	map.3697
  			        +20	pref.3615
  			        +16	attributes.2394
  			        +16	attributes.3480
  			        +16	formatNames.4509
  			        +16	map.2970
  			        +16	map.3529
  			        +16	map.3712
  			        +16	map.3931
  			         +8	map.2395
  			         +8	map.4012
  			         +6	bulletCharArray.2208
  			         +4	pixelThresholdX.4227
  			         +4	pixelThresholdY.4228
  			         +4	prefChangeRegistered.3285
  			         +4	space.2228
  			         +4	strippedChars.5697
  			         +4	visitorTrue.5364
  			         +2	nbsp.2227
  			         -2	nbsp.2224
  			         -4	visitorTrue.5361
  			         -4	strippedChars.5691
  			         -4	space.2225
  			         -4	prefChangeRegistered.3282
  			         -4	pixelThresholdY.4225
  			         -4	pixelThresholdX.4224
  			         -6	bulletCharArray.2205
  			         -8	map.4009
  			         -8	map.2389
  			        -16	map.3928
  			        -16	map.3709
  			        -16	map.3526
  			        -16	map.2967
  			        -16	formatNames.4506
  			        -16	attributes.3477
  			        -16	attributes.2388
  			        -20	pref.3612
  			        -24	map.3694
  			        -24	map.3493
  			        -24	attributes.4008
  			        -28	visitorFalse.5362
  			        -28	map.5511
  			        -28	list.3253
  			        -28	initializing.5496
  			        -32	whitespace.2835
  			        -32	map.4585
  			        -32	map.4544
  			        -32	map.4069
  			        -32	map.4054
  			        -32	map.3683
  			        -32	map.3681
  			        -32	map.3619
  			        -32	map.3478
  			        -32	map.3454
  			        -32	map.2427
  			        -32	map.2371
  			        -32	kWhitespace.4533
  			        -32	attributes.4584
  			        -32	attributes.4543
  			        -32	attributes.4068
  			        -32	attributes.4053
  			        -32	attributes.3682
  			        -32	attributes.3618
  			        -32	attributes.2370
  			        -36	hash_table_ops.4566
  			        -36	hash_table_ops.4509
  			        -36	hash_table_ops.4176
  			        -36	gOps.5145
  			        -36	classPolicyOps.3759
  			        -40	map.4123
  			        -40	map.3472
  			        -40	kWhitespace.4476
  			        -40	attributes.3693
  			        -40	attributes.3492
  			        -40	attributes.3453
  			        -48	attributes.3525
  			        -56	attributes.4122
  			        -64	nsXULAttribute::nsIDOM3Node virtual table
  			        -64	hash_table_ops.4274
  			        -64	hash_table_ops.4273
  			        -64	hash_table_ops.2712
  			        -64	hash_table_ops.2160
  			        -64	classPolicyOps.2469
  			        -80	attributes.3708
  			        -80	attributes.3471
  			        -80	attributes.3465
  			       -104	map.3466
  			       -112	attributes.3927
  	        +64 (+15346/-15282)	R (DATA)
  		        +64 (+15346/-15282)	UNDEF:libgklayout.so:R
  			      +7100	map.3915
  			      +3224	kCStringBundleServiceCID.5052
  			       +797	ioServCID.2688
  			       +792	kISupportsIID.4458
  			       +784	kNavDTDCID.5992
  			       +560	sComma.2405
  			       +368	combining.2361
  			       +347	kMathMLStyleSheetURI.4755
  			       +344	kCSSType.3693
  			       +151	kJavaScript.2373
  			       +144	xmlns_len.3957
  			       +136	kLegendFrameCID.6154
  			       +136	kXPConnectCID.4014
  			        +90	kXULPrototypeCacheCID.3370
  			        +80	kXULPrototypeCacheCID.3018
  			        +64	kViewCID
  			        +56	kDOMScriptObjectFactoryCID.2115
  			        +37	textCssStr.5683
  			        +28	badChars.5523
  			        +24	kCParserCID.3673
  			        +24	kEventQueueServiceCID.5638
  			        +16	kCChildCID.6132
  			        +16	kEventQueueServiceCID.4813
  			        +16	kISupportsIID.2433
  			         +8	kFudge.2283
  			         +2	sAster.2403
  			         +2	sPercent.2404
  			         -2	sPercent.2401
  			         -2	sAster.2400
  			         -8	kFudge.2280
  			        -16	kISupportsIID.2430
  			        -16	kEventQueueServiceCID.4810
  			        -16	kCChildCID.6129
  			        -24	kEventQueueServiceCID.5635
  			        -24	kCParserCID.3670
  			        -28	badChars.5520
  			        -37	textCssStr.5680
  			        -56	kDOMScriptObjectFactoryCID.2112
  			        -80	kXULPrototypeCacheCID.3015
  			        -90	kXULPrototypeCacheCID.3367
  			       -136	kXPConnectCID.4011
  			       -136	kLegendFrameCID.6151
  			       -144	xmlns_len.3954
  			       -151	kJavaScript.2370
  			       -344	kCSSType.3690
  			       -347	kMathMLStyleSheetURI.4752
  			       -368	combining.2358
  			       -560	sComma.2402
  			       -784	kNavDTDCID.6001
  			       -792	kISupportsIID.4455
  			       -797	ioServCID.2685
  			      -3224	kCStringBundleServiceCID.5049
  			      -7100	map.3912

Updated

9 years ago
Component: DOM: Core → DOM: Core & HTML
QA Contact: desale → general
You need to log in before you can comment on or make changes to this bug.