Closed Bug 78010 Opened 24 years ago Closed 24 years ago

Implement nsIClipboardHelper

Categories

(Core :: XUL, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.1

People

(Reporter: dr, Assigned: dr)

References

Details

Attachments

(2 files)

Clipboard helper routines to copy simple strings, etc. to the clipboard are strewn around the codebase. A clipboard helper (service?), nsIClipboardHelper, would clean this up.
Bug 32358 would like this, but it's going to work around it. nsPresShell.cpp would like this in a few places as well...
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla0.9.1
Depends on: 78824
I have a working patch in my tree now. The interface right now is quite simple. It consists of two methods: |copyString(AString)| and |copyStringToClipboard(AString, long)|. Looking around it looks like we've got a few places in the code right now where we'd like to be using the new interface as it stands: - nsPresShell.cpp: DoCopyLinkLocation, DoCopyImageLocation - extensions/inspector/.../ClipboardUtils.js - msgHeaderViewOverlay.js: CopyEmailAddress Also looks like we should fold nsCopySupport and nsTreeController into this, as well as a couple other functions (just grepping for "nsIClipboard" in lxr)... Patch on the way.
Just remembered, I probably also want to consolidate nsClipboard.js into here sooner or later as well... :)
Any chance of the copyHTML function you mentioned becoming a helper function? And how about reading? nsClipboard.js has functions for that, and it would seem sensible for a clipboard helper to allow you to both read and write :-) (I take it the helper will take care of the Unix Selection Clipboard details.) Gerv
Alright, I'm hoping that's everything. Note that you need the patch attached in 78824, to nsISupportsPrimitives, for this patch to compile. It seems to work just fine for me, but I haven't tested on windows or mac yet. The ugliest part to this seems to have been patching each platform's widget factory -- it might be worth it in the long run to refactor these somehow... (upping severity to major, since this patch touches 25 files :)
Severity: minor → major
Keywords: approval, patch, review
Gerv: Yeah. I'd like to get the interface landed first, before I build on it, though. That way, at least you'll be able to use the basic "copy string to clipboard" functionality right off the bat, without wasting any more time. And yes, the helper hides the details of the unix selection clipboard. I patched the mailnews callsite -- you can see how simple it is to use.
looks ok to me. get pink to look at it too. r=pavlov
several comments: - remove the checks you added for NS_ENSURE_ARG_POINTER in nsWebShell and nsClipboard - the patch to msgHdrViewOverlay.js should call copyStringToClipboard() and pass the gloabl clipboard instead of just calling copyString(), which would wipe the selection clipboard (the old code didn't put it on the selection clip). - placing the data on the selection clip w/in the impl of copyString should probably be ifdef'd unix, though i guess it doesn't have to be. no big deal there. - why only replace the code in msgHdrViewOverlay.js? why not elsewhere (such as contextMenu.js, which that code you replace alludes to have come from)?
> - remove the checks you added for NS_ENSURE_ARG_POINTER in nsWebShell Done. > and nsClipboard Not done. These should properly return failure even in opt builds where the assertion would not be seen. > - the patch to msgHdrViewOverlay.js should call copyStringToClipboard() and > pass the gloabl clipboard instead of just calling copyString(), which would > wipe the selection clipboard (the old code didn't put it on the selection > clip). I'll have to ask. I believe since the old js code here was ripped off from other old js code, there was an error in the ripping-off which nobody caught. I believe they want to be copying to the selection clipboard as well... > - placing the data on the selection clip w/in the impl of copyString should > probably be ifdef'd unix, though i guess it doesn't have to be. no big deal > there. Hm. I must need to comment CopyString a bit more thoroughly. The Right Thing to do to determine whether we support the selection clipboard is not to do #ifdef XP_UNIX (which is what we were doing before), but to ask nsIClipboard::SupportsSelectionClipboard. I do this in CopyStringToClipboard, but don't mention the logic in CopyString. > - why only replace the code in msgHdrViewOverlay.js? why not elsewhere (such > as contextMenu.js, which that code you replace alludes to have come from)? There aren't too many other places that need to simply copy strings. contextMenu.js doesn't even do this anymore -- PresShell does (in DoCopyImageLocation and DoCopyLinkLocation, which is what was moved from contextMenu.js), and I've patched that call. After this interface lands, at some point, I'll fold functionality from nsClipboard.js (and maybe also from PresShell::DoCopy) into the new interface and patch their respective callsites.
Blocks: 79787
I've filed bug 79787 to enhance nsIClipboardHelper with useful methods.
QA Contact: scc → jrgm
inspector changes are kosher. r=hewitt
[s]r=hyatt
Whiteboard: [ready for checkin]
fixed. see widget/public/nsIClipboardHelper for the new api, and bug 79787 for further work.
oops, really fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Component: XP Utilities → XP Toolkit/Widgets
Keywords: approval, patch, reviewverifyme
Whiteboard: [ready for checkin]
mass remove verifyme requests greater than 4 months old
Keywords: verifyme
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: