Closed
Bug 292607
Opened 19 years ago
Closed 17 years ago
Dragging <pre>-formatted text collapses whitespace
Categories
(Core :: DOM: Copy & Paste and Drag & Drop, defect)
Core
DOM: Copy & Paste and Drag & Drop
Tracking
()
VERIFIED
FIXED
People
(Reporter: englabenny, Assigned: rich)
References
()
Details
(Keywords: helpwanted, Whiteboard: [good first bug])
Attachments
(3 files, 1 obsolete file)
440 bytes,
text/html
|
Details | |
2.25 KB,
patch
|
bzbarsky
:
review+
bzbarsky
:
superreview+
pavlov
:
approval1.9+
|
Details | Diff | Splinter Review |
6.57 KB,
patch
|
neil
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b2) Gecko/20050328 Camino/0.8+ Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b2) Gecko/20050328 Camino/0.8+ That cococadev page has an example of text enclosed in <pre> </pre> tags. Copying and dragging such text is inconsistent; copying preserves whitespace, while dragging collapses the whitespace to spaces. The problem depends on <pre> tags, regardless of any other tags like <blockquote> and <code>. Similar to Bug 116083; https://bugzilla.mozilla.org/show_bug.cgi?id=116083 but not the same. Reproducible: Always Steps to Reproduce: 1.Select text enclosed in <pre>-tags that contains tabs, linebreaks and multiple spaces 2. Drag the text to a text editor Actual Results: No whitespace preserved; tabs, linebreaks are converted to spaces. Expected Results: The drag operation should perform identically to Edit->copy, i.e. preserving whitespace. Using Mac OS X 10.3.8
Comment 1•19 years ago
|
||
not camino specific.
Assignee: pinkerton → nobody
Status: UNCONFIRMED → NEW
Component: Drag & Drop → Drag and Drop
Ever confirmed: true
Product: Camino → Core
Version: unspecified → Trunk
Comment 2•19 years ago
|
||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050419 Firefox/1.0.4 not mac osx specific
OS: MacOS X → All
Hardware: Macintosh → All
Updated•19 years ago
|
Keywords: helpwanted
Reporter | ||
Comment 3•19 years ago
|
||
A small testcase for the bug. Note: Selecting and dragging results in collapse of whitespace. _However_: if you use Select All, and then drag, whitespace is preserved.
Comment 4•17 years ago
|
||
Probably because the range passed to the serializer doesn't contain the <pre> start tag, so the serializer doesn't realize that it's dealing with preformatted text? Chances are, looking at what copy/paste does would help...
Whiteboard: [good first bug]
Assignee | ||
Comment 5•17 years ago
|
||
> Chances are, looking at what copy/paste does would help...
Yes it did - thanks! The code in nsCopySupport::HTMLCopy set the nsIDocumentEncoder::OutputPreformatted when generating the text flavor. Changing the drag'n'drop code so also sets this flag seems to fix the problem.
Attachment #275290 -
Flags: review?(bzbarsky)
Comment 6•17 years ago
|
||
Comment on attachment 275290 [details] [diff] [review] Patch v1 Looks reasonable. Thanks for doing this!
Attachment #275290 -
Flags: superreview?(neil)
Attachment #275290 -
Flags: review?(bzbarsky)
Attachment #275290 -
Flags: review+
Comment 7•17 years ago
|
||
Comment on attachment 275290 [details] [diff] [review] Patch v1 With this patch, all drags drag the source of the text, which is incorrect for non-preformatted text. I don't think this is how the copy support creates the plain text copy (except when copying from a textarea) but I don't have a debugger handy right now to check.
Attachment #275290 -
Flags: superreview?(neil) → superreview-
Comment 8•17 years ago
|
||
I, um, copied, what nsCopySupport::HTMLCopy does.
Comment 9•17 years ago
|
||
HTMLCopy uses the nsIDocumentEncoder::OutputPreformatted serialization as input to the format converter. Shouldn't this do the same?
Comment 10•17 years ago
|
||
(In reply to comment #9) > HTMLCopy uses the nsIDocumentEncoder::OutputPreformatted serialization as input > to the format converter. Shouldn't this do the same? HTMLCopy is weird, because it's called for plaintext copies in certain cases (textareas and plaintext message compose). In these cases the HTMLCopyEncoder automagically turns itself back into a plaintext encoder, so just in case, we pass the OutputPreformatted flag. The flag has no effect on an HTML copy. Plaintext drag'n'drop doesn't seem to hit this codepath.
Comment 11•17 years ago
|
||
Comment on attachment 275959 [details] [diff] [review] Copy Copy OK, sounds good.
Attachment #275959 -
Flags: superreview+
Attachment #275959 -
Flags: review?(bzbarsky)
Attachment #275959 -
Flags: review+
Comment 12•17 years ago
|
||
Comment on attachment 275959 [details] [diff] [review] Copy Copy This fixes a problem dragging a section of preformatted text (such as most of the text in Bugzilla) where currently all of the text is trimmed onto a single line and loses all of its preformatting.
Attachment #275959 -
Flags: approval1.9?
Assignee | ||
Comment 13•17 years ago
|
||
Thanks Neil. After your review, I did go back and realise that using an HTMLConverter was probably required to get things working right. However I was still reading about XPCOM, etc before making the change, to check I got everything right. :-) Just one comment on your patch... I think that SerializeNodeOrSelection() is now only ever called with an inMode of serializeAsHTML. Do you think it would be worth getting rid of the inMode parameter, the serializationMode enum and removing the unused code paths from the SerializeNodeOrSelection() function? (I'm happy to do this if you'd like.)
Comment 14•17 years ago
|
||
(In reply to comment #13) >I think that SerializeNodeOrSelection() is now only ever called with an inMode >of serializeAsHTML. Do you think it would be worth getting rid of the inMode >parameter, the serializationMode enum and removing the unused code paths from >the SerializeNodeOrSelection() function? Be my guest :-)
Assignee: neil → rich
Status: ASSIGNED → NEW
Assignee | ||
Comment 15•17 years ago
|
||
Thanks Neil. Here's a version of your patch with unused code removed.
Attachment #275290 -
Attachment is obsolete: true
Attachment #276094 -
Flags: review?(neil)
Updated•17 years ago
|
Attachment #276094 -
Flags: review?(neil) → review+
Updated•17 years ago
|
Attachment #275959 -
Flags: approval1.9? → approval1.9+
Comment 16•17 years ago
|
||
Fix checked in.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Updated•17 years ago
|
Updated•16 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•