RESOLVED FIXED Bug 36430
InsertListCommand needs cleanup
https://bugs.webkit.org/show_bug.cgi?id=36430
Summary InsertListCommand needs cleanup
Ryosuke Niwa
Reported 2010-03-21 15:53:34 PDT
Currently, InsertListCommand has three major problems: 1. If the selection contains more than one paragraphs, modifyRange() loops over each paragraph and calls doApply. This is very misleading because doApply() and modifyRange() aren't really mutually recursive functions (doApply() calls modifyRange() at most once when doApply() is called for the first time). 2. doApply() has two parts; the first part removes the child node and the second part adds list. Although there are cases in which we remove a list element and add a different type of list element later, two parts are sufficiently isolated and they should be separate functions. 3. IndentOutdentCommand and InsertListCommand implements very similar features but do not share much code. IndentOutdentCommand adds and removes list just like InsertListCommand, and the only difference is that InsertListCommand sometimes needs to wrap a paragraph with LI whereas IndentOutdentCommand wraps with a blockquote in such cases. Two classes should share more code. Proposal: we first divide doApply into two separate functions/methods. We then move the code inside of modifyRange into doApply. We can then combine code in IndentOutdentCommand and InsertListCommand.
Attachments
first attempt to separate listifying/unlistifying code (16.75 KB, patch)
2010-03-22 19:09 PDT, Ryosuke Niwa
no flags
Isolates code for listifying/unlistifying paragraphs into seperate functions. (17.60 KB, patch)
2010-06-04 09:49 PDT, Ryosuke Niwa
justin.garcia: review+
Ryosuke Niwa
Comment 1 2010-03-22 19:09:16 PDT
Created attachment 51386 [details] first attempt to separate listifying/unlistifying code This is my first attempt to separate two parts of doApply. Maybe it makes sense to file another but just to land this patch first. Svn diff is messy because it contains the changes to 19539 as well.
Tony Chang
Comment 2 2010-03-25 02:20:23 PDT
Seems like a good refactoring to me. The original method was long and the new function names help to clarify what the code is trying to do.
Ryosuke Niwa
Comment 3 2010-06-04 09:49:43 PDT
Created attachment 57889 [details] Isolates code for listifying/unlistifying paragraphs into seperate functions.
Justin Garcia
Comment 4 2010-06-08 10:30:03 PDT
Comment on attachment 57889 [details] Isolates code for listifying/unlistifying paragraphs into seperate functions. r=me
Ryosuke Niwa
Comment 5 2010-06-08 21:00:16 PDT
Note You need to log in before you can comment on or make changes to this bug.