Closed Bug 386225 Opened 17 years ago Closed 17 years ago

clean up clipboard service given drag service rewrite (385116), port fixes

Categories

(Core :: Widget: Cocoa, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jaas, Assigned: jaas)

Details

Attachments

(1 file, 2 obsolete files)

The last-minute patch for bug 385116 undid a lot of the work done by bug 358094. We need to re-do the re-factoring, but this time at a finer grain because of greater differences between the drag and clipboard services.
Flags: blocking1.9+
Attached patch fix v1.0 (obsolete) — Splinter Review
In doing this I ended up rewriting the guts of the clipboard service. I fixed several bugs while optimizing and simplifying a bunch of code. I used a lot of the same lessons learned from rewriting the drag service recently, as well as my realization that the base clipboard service impl caches the transferrable given to it unlike the base drag service impl.

Some more detailed notes:
- This fixes a major ordering problem that could result in pasting the wrong data if somebody does a copy in gecko, a copy in another application, and then pastes into Gecko. Previously we might have used data from a cached transferable when we should have taken data from the clipboard that originated in another application.
- This rewrite doesn't put data on the native clipboard unnecessarily since we can depend on having cached any data that originated in gecko, which won't be of use to anyone else.
Attachment #270658 - Flags: review?(cbarrett)
Attachment #270658 - Flags: review?(cbarrett) → review?(stuart.morgan)
+ void* clipboardDataPtr = (unsigned char*)malloc(dataLength);

This is obviously wrong - I forgot to remove the cast when I changed the data type. Will fix on checkin. Why doesn't gcc warn me about things like that?
Summary: re-factor shared code between cocoa clipboard and drag services → clean up clipboard service given changes in bug 385116, port fixes
Summary: clean up clipboard service given changes in bug 385116, port fixes → clean up clipboard service given drag service rewrite (385116), port fixes
+      // We have never supported this on Mac OS X, we could someday but nobody does this. We want this
+      // test here so that we don't try to get this as a custom type.

Also, this comment is wrong, I forgot to change it.
Comment on attachment 270658 [details] [diff] [review]
fix v1.0

r=me with the comment changes we discussed.
Attachment #270658 - Flags: review?(stuart.morgan) → review+
Attached patch fix v1.1 (obsolete) — Splinter Review
addresses my own comments + smorgan's
Attachment #270658 - Attachment is obsolete: true
Attachment #270683 - Flags: superreview?(pavlov)
Comment on attachment 270683 [details] [diff] [review]
fix v1.1

(sorry these comments are bottom-up)

+      // be nice to Carbon apps, normalize the receiver�s contents using Form C.

it is probably best if we don't use odd charsets for comments?


+    nsXPIDLCString flavorStr;
+    currentFlavor->ToString(getter_Copies(flavorStr)); // i has a flavr
+
+    // printf("looking for clipboard data of type %s\n", flavorStr.get());
+
+    if (strcmp(flavorStr, kUnicodeMime) == 0) {

this isn't safe.  What if flavorStr is shorter than kUnicodeMime?  I think you could do flavorStr.Equals() (not sure about xpidlstrings..)

+private:
+  int changeCount; // this is always set to the native change count after any clipboard modifications
 
do you want to use somethign like mChangeCount?  It is hard to tell that this is a member variable.
Attachment #270683 - Flags: superreview?(pavlov) → superreview-
Attached patch fix v1.2Splinter Review
Fixes pav's comments, plus gets rid of a whole bunch of other strcmp usage.
Attachment #270683 - Attachment is obsolete: true
Attachment #270698 - Flags: superreview?(pavlov)
Attachment #270698 - Attachment is patch: true
Attachment #270698 - Attachment mime type: application/octet-stream → text/plain
Attachment #270698 - Flags: superreview?(pavlov) → superreview+
landed on trunk
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: