RESOLVED FIXED 64423
Line-breaks are disappeared from textarea.value if user pastes a text into a no-wrap-ed textarea.
https://bugs.webkit.org/show_bug.cgi?id=64423
Summary Line-breaks are disappeared from textarea.value if user pastes a text into a ...
Hajime Morrita
Reported 2011-07-12 19:22:16 PDT
Originally reported at http://crbug.com/88736. A fix will come shortly.
Attachments
Patch (7.26 KB, patch)
2011-07-12 19:24 PDT, Hajime Morrita
no flags
Patch (7.10 KB, patch)
2011-07-27 04:27 PDT, Hajime Morrita
no flags
Hajime Morrita
Comment 1 2011-07-12 19:24:57 PDT
Kent Tamura
Comment 2 2011-07-13 18:48:51 PDT
(In reply to comment #1) > Created an attachment (id=100608) [details] > Patch I think your patch will fix the problem. But can we avoid to insert <div> or something into the inner text of <textarea> and <input>?
Ryosuke Niwa
Comment 3 2011-07-13 19:07:37 PDT
Comment on attachment 100608 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=100608&action=review > LayoutTests/editing/pasteboard/paste-textarea-wrap.html:36 > +description("This tests if pasted text preserves original line-breaks regardless their destination styles."); Nit: regardless *of* their destination styles.
Ryosuke Niwa
Comment 4 2011-07-13 19:08:14 PDT
(In reply to comment #2) > (In reply to comment #1) > > Created an attachment (id=100608) [details] [details] > > Patch > > I think your patch will fix the problem. But can we avoid to insert <div> or something into the inner text of <textarea> and <input>? Yeah, we specifically avoid inserting div into the shadow DOM in various places. We should figure out where this div is coming from and replace them with br's.
Hajime Morrita
Comment 5 2011-07-13 22:21:10 PDT
> > I think your patch will fix the problem. But can we avoid to insert <div> or something into the inner text of <textarea> and <input>? > > Yeah, we specifically avoid inserting div into the shadow DOM in various places. We should figure out where this div is coming from and replace them with br's. Kent-san, Ryosuke, thanks for taking a look! I'm not sure what should happen there. So I'll investigate how text insertion works at first.
Hajime Morrita
Comment 6 2011-07-27 04:27:09 PDT
Hajime Morrita
Comment 7 2011-07-27 04:28:35 PDT
> > I think your patch will fix the problem. But can we avoid to insert <div> or something into the inner text of <textarea> and <input>? > > Yeah, we specifically avoid inserting div into the shadow DOM in various places. We should figure out where this div is coming from and replace them with br's. I updated the patch to use <br>. Niwa-san, could you take a look?
Ryosuke Niwa
Comment 8 2011-07-31 14:06:07 PDT
Comment on attachment 102122 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=102122&action=review > Source/WebCore/editing/markup.cpp:772 > + element = createHTMLElement(document, spanTag); > + fillContainerFromString(element.get(), s); > + fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION); > + element = createBreakElement(document); > + fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION); This seems like a wrong layer to fix this. I'd suspect where we need to fix is ReplaceSelectionCommand.
Hajime Morrita
Comment 9 2011-08-01 02:11:32 PDT
Comment on attachment 102122 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=102122&action=review >> Source/WebCore/editing/markup.cpp:772 >> + fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION); > > This seems like a wrong layer to fix this. I'd suspect where we need to fix is ReplaceSelectionCommand. I don't think so. ReplaceSelectionCommand just emits a textInput event, And Editor handles it, then calls this method. Actually this createFragmentFromText() has similar trick at the beginning of the function for preserveNewLine(). Hopefully we have FragmentBuilder to make these code more organized, like MarkupAccumulator does. But that's another story.
Hajime Morrita
Comment 10 2011-08-23 02:20:41 PDT
Comment on attachment 102122 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=102122&action=review >>> Source/WebCore/editing/markup.cpp:772 >>> + fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION); >> >> This seems like a wrong layer to fix this. I'd suspect where we need to fix is ReplaceSelectionCommand. > > I don't think so. > ReplaceSelectionCommand just emits a textInput event, > And Editor handles it, then calls this method. > Actually this createFragmentFromText() has similar trick at the beginning of the function for preserveNewLine(). > > Hopefully we have FragmentBuilder to make these code more organized, like MarkupAccumulator does. > But that's another story. Actually, the fragment is build _before_ ReplaceSelectionCommand_ is instantiated, The created fragment is passed to ReplaceSelectionCommand constructor instead. So there is nothing to do for ReplaceSelectionCommand.
Ryosuke Niwa
Comment 11 2011-08-23 10:16:57 PDT
Comment on attachment 102122 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=102122&action=review >>>> Source/WebCore/editing/markup.cpp:772 >>>> + fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION); >>> >>> This seems like a wrong layer to fix this. I'd suspect where we need to fix is ReplaceSelectionCommand. >> >> I don't think so. >> ReplaceSelectionCommand just emits a textInput event, >> And Editor handles it, then calls this method. >> Actually this createFragmentFromText() has similar trick at the beginning of the function for preserveNewLine(). >> >> Hopefully we have FragmentBuilder to make these code more organized, like MarkupAccumulator does. >> But that's another story. > > Actually, the fragment is build _before_ ReplaceSelectionCommand_ is instantiated, > The created fragment is passed to ReplaceSelectionCommand constructor instead. > So there is nothing to do for ReplaceSelectionCommand. What I'm saying that createFragment changing behavior depending on whether we're inside a shadow DOM or not seems wrong.
Ryosuke Niwa
Comment 12 2011-08-23 10:18:05 PDT
For example, are you sure that this bug doesn't reproduce in a contenteditable area that has the exactly same CSS style as the one in the shadow DOM of textarea?
Hajime Morrita
Comment 13 2011-12-11 21:28:29 PST
Comment on attachment 102122 [details] Patch Clearing r? for now.
Ryosuke Niwa
Comment 14 2011-12-11 21:33:57 PST
Oops, I had totally forgot about this bug and made a very similar change in http://trac.webkit.org/changeset/102392. Sorry about that :(
Note You need to log in before you can comment on or make changes to this bug.