Bug 68939

Summary: Simplify ReplaceSelectionCommand::positionAtStartOfInsertedContent
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: HTML EditingAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, enrica, eric, morrita, ojan, tkent, tony
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 68874    
Attachments:
Description Flags
Simplified the function with additional fixes and refactoring
none
new patch
none
Addressed comments darin: review+

Ryosuke Niwa
Reported 2011-09-27 14:37:25 PDT
I don't think we should be calling nextCandidate in positionAtStartOfInsertedContent. We need to simplify this function in order to resolve the bug 68874.
Attachments
Simplified the function with additional fixes and refactoring (12.54 KB, patch)
2011-09-27 15:36 PDT, Ryosuke Niwa
no flags
new patch (14.41 KB, patch)
2011-09-27 16:24 PDT, Ryosuke Niwa
no flags
Addressed comments (14.48 KB, patch)
2011-09-27 17:38 PDT, Ryosuke Niwa
darin: review+
Ryosuke Niwa
Comment 1 2011-09-27 15:36:46 PDT
Created attachment 108916 [details] Simplified the function with additional fixes and refactoring
Ryosuke Niwa
Comment 2 2011-09-27 16:07:19 PDT
Comment on attachment 108916 [details] Simplified the function with additional fixes and refactoring View in context: https://bugs.webkit.org/attachment.cgi?id=108916&action=review > Source/WebCore/rendering/RenderText.cpp:1606 > -unsigned RenderText::caretMaxRenderedOffset() const > +unsigned RenderText::renderedTextLength() const Come to think of it, caretMaxOffset should call this function. Will do in a minute.
Ryosuke Niwa
Comment 3 2011-09-27 16:19:31 PDT
(In reply to comment #2) > (From update of attachment 108916 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=108916&action=review > > > Source/WebCore/rendering/RenderText.cpp:1606 > > -unsigned RenderText::caretMaxRenderedOffset() const > > +unsigned RenderText::renderedTextLength() const > > Come to think of it, caretMaxOffset should call this function. Will do in a minute. Ugh... not really. That won't work.
Ryosuke Niwa
Comment 4 2011-09-27 16:24:26 PDT
Created attachment 108926 [details] new patch
Darin Adler
Comment 5 2011-09-27 17:15:40 PDT
Comment on attachment 108926 [details] new patch View in context: https://bugs.webkit.org/attachment.cgi?id=108926&action=review > Source/WebCore/ChangeLog:12 > + This change revealed a bug in removeUnrenderedTextNodesAtEnds that text nodes without any visible > + text at ends are not removed when it has a render object. Fixed the bug by checking the length of > + the rendered text. Since you fixed a bug we need to add a test case to show that bug in action, or call out which test cases shows us the bug. > Source/WebCore/editing/ReplaceSelectionCommand.cpp:559 > + return node->renderer() && node->renderer()->isText() && toRenderText(node->renderer())->renderedTextLength() > 0; I think that text nodes are guaranteed to have RenderText renderers or no renderer at all, so I don’t think the isText check is needed. If it is needed, we should check in a test case that exercises that code path.
Ryosuke Niwa
Comment 6 2011-09-27 17:22:23 PDT
Comment on attachment 108926 [details] new patch View in context: https://bugs.webkit.org/attachment.cgi?id=108926&action=review >> Source/WebCore/ChangeLog:12 >> + the rendered text. > > Since you fixed a bug we need to add a test case to show that bug in action, or call out which test cases shows us the bug. It's editing/pasteboard/pasting-word-in-div-extra-line.html. >> Source/WebCore/editing/ReplaceSelectionCommand.cpp:559 >> + return node->renderer() && node->renderer()->isText() && toRenderText(node->renderer())->renderedTextLength() > 0; > > I think that text nodes are guaranteed to have RenderText renderers or no renderer at all, so I don’t think the isText check is needed. If it is needed, we should check in a test case that exercises that code path. On the other hand, I didn't want to make this function hard to use. I don't want someone to start calling this function without checking that node is a text node. I guess I can change the argument type to Text*?
Ryosuke Niwa
Comment 7 2011-09-27 17:38:42 PDT
Created attachment 108943 [details] Addressed comments
Ryosuke Niwa
Comment 8 2011-09-27 18:12:23 PDT
Thanks for reviewing these patches!
Ryosuke Niwa
Comment 9 2011-09-27 22:03:17 PDT
Note You need to log in before you can comment on or make changes to this bug.