Closed Bug 363516 Opened 18 years ago Closed 18 years ago

inline message regression

Categories

(Core Graveyard :: XForms, defect)

1.8 Branch
x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: aaronr, Assigned: aaronr)

Details

(Keywords: fixed1.8.0.12, fixed1.8.1.4)

Attachments

(2 files, 2 obsolete files)

xf:messages with inline text (instead of binding to a node or using an external resource) no longer work.  The dialog displays, but no message is shown.

I've debugged this down.  Inline xforms messages stopped working on 11/23/06 due to the checkin for bug 47903.  We currently clone the child nodes of the xf:message and append them into the message document.  We can't do that.  We need to import the nodes into the document first.
Attached file testcase
ugh, no time now.  I'll get to it after the holidays.  If someone else wants to whip up a fix, please feel free to assign this bug to yourself.
Attached patch patch1 (obsolete) — Splinter Review
easy fix, just importing the result of nsXFormsMessageElement::CloneNode into the destination document before appending it.
Attachment #252705 - Flags: review?(Olli.Pettay)
Attachment #252705 - Flags: review?(surkov.alexander)
Comment on attachment 252705 [details] [diff] [review]
patch1

>           CloneNode(child, getter_AddRefs(clone));
>-          if (clone)
>-            bodyEl->AppendChild(clone, getter_AddRefs(tmp));
>+          if (clone) {
>+            // since clone is generated from the original document, we need
>+            // to import it into the destination document before appending
>+            // it.
>+            nsCOMPtr<nsIDOMNode> importedNode;
>+            ddoc->ImportNode(clone, PR_TRUE, getter_AddRefs(importedNode));
>+            bodyEl->AppendChild(importedNode, getter_AddRefs(tmp));

I'd prefer to pass document into nsXFormsMessagee::CloneNode() instead of follow up import node.
Comment on attachment 252705 [details] [diff] [review]
patch1


>           CloneNode(child, getter_AddRefs(clone));
>-          if (clone)
>-            bodyEl->AppendChild(clone, getter_AddRefs(tmp));
>+          if (clone) {
>+            // since clone is generated from the original document, we need
>+            // to import it into the destination document before appending
>+            // it.
>+            nsCOMPtr<nsIDOMNode> importedNode;
>+            ddoc->ImportNode(clone, PR_TRUE, getter_AddRefs(importedNode));

This is quite heavy because first CloneNode creates new nodes which are then
again cloned for the new document when ImportNode is called.
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Core-Document-importNode
"Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node."

I guess nsXFormsMessageElement::CloneNode could be modified to use ImportNode, not
CloneNode (and ofc then it should be called nsXFormsMessageElement::ImportNode :))
Attachment #252705 - Flags: review?(Olli.Pettay) → review-
(In reply to comment #5)
> (From update of attachment 252705 [details] [diff] [review])
> 
> >           CloneNode(child, getter_AddRefs(clone));
> >-          if (clone)
> >-            bodyEl->AppendChild(clone, getter_AddRefs(tmp));
> >+          if (clone) {
> >+            // since clone is generated from the original document, we need
> >+            // to import it into the destination document before appending
> >+            // it.
> >+            nsCOMPtr<nsIDOMNode> importedNode;
> >+            ddoc->ImportNode(clone, PR_TRUE, getter_AddRefs(importedNode));
> 
> This is quite heavy because first CloneNode creates new nodes which are then
> again cloned for the new document when ImportNode is called.
> http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Core-Document-importNode
> "Imports a node from another document to this document, without altering or
> removing the source node from the original document; this method creates a new
> copy of the source node."
> 
> I guess nsXFormsMessageElement::CloneNode could be modified to use ImportNode,
> not
> CloneNode (and ofc then it should be called nsXFormsMessageElement::ImportNode
> :))
> 


I agree it is heavy, but it is a convenient, 3 line change.  I guess I'll go the long way around.  *sigh*.  :-)
Attached patch patch2 (obsolete) — Splinter Review
using smaug and surkov's approach
Attachment #252705 - Attachment is obsolete: true
Attachment #252705 - Flags: review?(surkov.alexander)
Attachment #252792 - Flags: review?(Olli.Pettay)
Attachment #252792 - Flags: review?(surkov.alexander)
Comment on attachment 252792 [details] [diff] [review]
patch2


>+++ nsXFormsMessageElement.cpp	25 Jan 2007 18:35:22 -0000
...
>-  void CloneNode(nsIDOMNode* aSrc, nsIDOMNode** aTarget);
>+  void CloneNode(nsIDOMNode* aSrc, nsIDOMDocument* aDestDoc,
>+                 nsIDOMNode** aTarget);

rename this to ImportNode, r=me
Attachment #252792 - Flags: review?(Olli.Pettay) → review+
Attached patch patch3Splinter Review
renamed to ImportNode as per smaug's comment
Attachment #252792 - Attachment is obsolete: true
Attachment #252854 - Flags: review?(surkov.alexander)
Attachment #252792 - Flags: review?(surkov.alexander)
Attachment #252854 - Flags: review?(surkov.alexander) → review+
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Whiteboard: xf-to-branch
checked into trunk by smaug.
checked into 1.8 branch on 2007-04-12
checked into 1.8.0 branch on 2007-04-16
Whiteboard: xf-to-branch
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: