[Webkit-unassigned] [Bug 7158] WebKit needs generalized Undo mechanism for DOMNode manipulations

bugzilla-daemon at opendarwin.org bugzilla-daemon at opendarwin.org
Thu Feb 9 13:52:26 PST 2006


http://bugzilla.opendarwin.org/show_bug.cgi?id=7158





------- Comment #1 from ttalbot at karelia.com  2006-02-09 13:52 PDT -------
My workaround, at least for this simple case, was to add a class method on
DOMNode that takes the parent node as an argument. This way, the NSInvocation
will automatically retain it.

+ (DOMNode *)node:(DOMNode *)parent replaceChild:(DOMNode *)newChild :(DOMNode
*)oldChild
{
        DOMDocument *doc = [parent ownerDocument];

        NSUndoManager *undoManager = [[[doc webFrame] webView] undoManager];
        [[undoManager prepareWithInvocationTarget:[DOMNode class]] node:parent
replaceChild:oldChild :newChild];

        return [parent replaceChild:newChild :oldChild];
}

called via:

        [[undoManager prepareWithInvocationTarget:[DOMNode class]]
node:[element parentNode] replaceChild:self :element];
        [[DOMNode class] node:[self parentNode] replaceChild:element :self];

This seems reasonable, though it would be nice if this sort of thing were
generalized to WebKit as a whole.


-- 
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list