Add a cloneNode hook for XTF (bug 280072). r+sr=jst

git-svn-id: svn://10.0.0.236/trunk@168431 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bryner%brianryner.com 2005-01-28 03:49:44 +00:00
parent 319465f6e9
commit e363246a53
4 changed files with 27 additions and 4 deletions

View File

@ -43,7 +43,7 @@ interface nsIDOMElement;
interface nsIDOMNode;
interface nsIDOMEvent;
[scriptable, uuid(e29224e9-429e-4bcc-98de-ee7fc10e5866)]
[scriptable, uuid(61077434-18c8-4d2d-956c-7c389a7e9bba)]
interface nsIXTFElement : nsISupports
{
// called when the wrapper object is being destroyed.
@ -153,5 +153,10 @@ interface nsIXTFElement : nsISupports
// If the return value is true, the event is marked as handled and
// other default handlers won't be able to handle it again.
boolean handleDefault(in nsIDOMEvent aEvent);
// Set this element to be equivalent to |aElement|. This does not need
// to worry about copying attributes or child nodes, but should copy any
// other needed state.
void cloneState(in nsIDOMElement aElement);
};

View File

@ -395,13 +395,15 @@ nsXTFElementWrapper::CloneNode(PRBool aDeep, nsIDOMNode **aResult)
mAttributeHandler->GetAttributeNameAt(i, getter_AddRefs(attrName));
if (attrName) {
nsAutoString value;
if (NS_SUCCEEDED(mAttributeHandler->GetAttribute(attrName, value)));
if (NS_SUCCEEDED(mAttributeHandler->GetAttribute(attrName, value)))
it->SetAttr(kNameSpaceID_None, attrName, value, PR_TRUE);
}
}
}
kungFuDeathGrip.swap(*aResult);
}
wrapper->CloneState(this);
return rv;
}

View File

@ -43,8 +43,7 @@
#include "nsIXTFElementWrapperPrivate.h"
#include "nsXMLElement.h"
#include "nsIXTFAttributeHandler.h"
class nsIXTFElement;
#include "nsIXTFElement.h"
typedef nsXMLElement nsXTFElementWrapperBase;
@ -119,6 +118,11 @@ public:
PRUint32 aFlags,
nsEventStatus* aEventStatus);
nsresult CloneState(nsIDOMElement *aElement)
{
return GetXTFElement()->CloneState(aElement);
}
protected:
// to be implemented by subclasses:
virtual nsIXTFElement *GetXTFElement() const = 0;

View File

@ -191,6 +191,12 @@ nsXFormsStubElement::OnCreated(nsIXTFGenericElementWrapper *aWrapper)
return NS_OK;
}
NS_IMETHODIMP
nsXFormsStubElement::CloneState(nsIDOMElement *aElement)
{
return NS_OK;
}
nsresult
NS_NewXFormsStubElement(nsIXTFElement **aResult)
{
@ -373,6 +379,12 @@ nsXFormsXMLVisualStub::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
return NS_OK;
}
NS_IMETHODIMP
nsXFormsXMLVisualStub::CloneState(nsIDOMElement *aElement)
{
return NS_OK;
}
nsresult
NS_NewXFormsXMLVisualStub(nsIXTFElement **aResult)
{