Bug 7683

Summary: TinyMCE: Implement execCommand(UnLink)
Product: WebKit Reporter: Justin Garcia <justin.garcia>
Component: HTML EditingAssignee: Justin Garcia <justin.garcia>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Bug Depends on:    
Bug Blocks: 6627    
Attachments:
Description Flags
patch
none
patch justin.garcia: review+

Description Justin Garcia 2006-03-09 12:06:08 PST
Implement execCommand(UnLink)
Comment 1 Justin Garcia 2006-03-15 20:41:50 PST
Created attachment 7103 [details]
patch
Comment 2 Justin Garcia 2006-03-16 02:32:25 PST
I noticed that I misspelled would't:
+// and Unlink, would't push the
I think that selectionAroundNode is a misnomer.  The function returns a selection that selects the contents of the passed node.  selectionFromNodeContents is more accurate. 
Comment 3 Justin Garcia 2006-03-16 02:44:52 PST
Comment on attachment 7103 [details]
patch

Eek, I forgot to svn add Unlink.{h,cpp}!  Removing the review flag until I check in a new patch.  Here are some other problems I noticed:

This should be a FIXME
+    // This pushes down anchors even if they are fully selected.  This is 
+    // less efficient, but makes this code much less complicated.

I now use the new form of the ApplyStyleCommand constructor in 3 places:
+    EditCommandPtr cmd(new ApplyStyleCommand(document(), new CSSMutableStyleDeclarationImpl(), static_cast<ElementImpl*>(newAnchorElement.get())));
+    applyCommandToComposite(cmd);
I should put a convenience method in CompositeEditCommand.

I should follow the style guidelines even in JS code:
+    }
+    else {
+        execUnlinkCommand();
+    }
+}

All I really care about in the test case is the result of innerHTML, so I should probably make the test use dumpAsText.
Comment 4 Justin Garcia 2006-03-16 13:47:17 PST
Created attachment 7118 [details]
patch

Implemented Unlink using ApplyStyleCommand in a remove only mode
Added EditActions for CreateLink/Unlink
Added a new constructor for ApplyStyleCommand to be used by CreateLink, Unlink and pushPartiallySelectedAnchorElementsDown, and reverted the other two constructors to deal only with normal style application.
Added code to push partially selected anchor elements down.  It's used by CreateLink because anchors can't be nested. It's used by Unlink because it's necessary to break a partially selected anchor into fully selected pieces so that Unlink can remove them.
Comment 5 Justin Garcia 2006-03-24 19:15:47 PST
Comment on attachment 7118 [details]
patch

dave r+'ed this assuming I made a few changes he suggested.