Hello playmobil,
I'd like you to do a code review. Please execute
g4 diff -c 10550638
or point your web browser to
http://mondrian/10550638
to review the following code:
Change 10550638 by nigel...@nigeltao-srcmacgears1 on 2009/03/20 19:33:37
*pending*
For Safari/Mac drag-and-drop, use the dragginSequenceNumber from
the NSDraggingInfo to determine when to reset our cached contents
of the NSDraggingInfo's pasteboard.
This (the sequence number) appears to be more reliable than
resetting on the draggingExited or performDragOperation message,
since neither of those messages are received if, for example,
the web pages calls window.alert during a dragover handler,
since presumably the change of focus inadvertently kills the
drag-and-drop in progress.
PRESUBMIT=passed
R=playmobil
[email protected]
DELTA=16 (13 added, 0 deleted, 3 changed)
OCL=10550638
Affected files ...
...
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm#10
edit
16 delta lines: 13 added, 0 deleted, 3 changed
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [email protected].
Change 10550638 by nigel...@nigeltao-srcmacgears1 on 2009/03/20 19:33:37
*pending*
For Safari/Mac drag-and-drop, use the dragginSequenceNumber from
the NSDraggingInfo to determine when to reset our cached contents
of the NSDraggingInfo's pasteboard.
This (the sequence number) appears to be more reliable than
resetting on the draggingExited or performDragOperation message,
since neither of those messages are received if, for example,
the web pages calls window.alert during a dragover handler,
since presumably the change of focus inadvertently kills the
drag-and-drop in progress.
Affected files ...
...
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm#10
edit
====
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm#10
-
/Users/nigeltao/devel/srcmacgears1/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm
====
# action=edit type=text
--- googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm
2009-03-19 09:48:34.000000000 +1100
+++ googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_sf.mm
2009-03-20 19:26:15.000000000 +1100
@@ -35,6 +35,7 @@
#import "gears/desktop/file_dialog.h"
static FileDragAndDropMetaData *g_file_drag_and_drop_meta_data = NULL;
+static NSInteger g_last_seen_dragging_sequence_number = 0;
static bool g_is_in_a_drag_operation = false;
static bool g_is_in_a_drop_operation = false;
// The next two variables are for when the page's JavaScript explicitly
@@ -111,6 +112,7 @@
}
@interface WebView (GearsSwizzledMethods)
+- (void)updateFromDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
- (NSDragOperation)swizzledDraggingEntered:(id <NSDraggingInfo>)draggingInfo;
- (NSDragOperation)swizzledDraggingUpdated:(id <NSDraggingInfo>)draggingInfo;
- (NSDragOperation)swizzledDraggingExited:(id <NSDraggingInfo>)draggingInfo;
@@ -119,11 +121,16 @@
@implementation WebView (GearsSwizzledMethods)
-- (NSDragOperation)swizzledDraggingEntered:(id <NSDraggingInfo>)draggingInfo {
+- (void)updateFromDraggingInfo:(id <NSDraggingInfo>)draggingInfo {
+ NSInteger seqno = [draggingInfo draggingSequenceNumber];
+ if (g_last_seen_dragging_sequence_number == seqno) {
+ return;
+ }
+ g_last_seen_dragging_sequence_number = seqno;
if (!g_file_drag_and_drop_meta_data) {
g_file_drag_and_drop_meta_data = new FileDragAndDropMetaData;
}
- assert(g_file_drag_and_drop_meta_data->IsEmpty());
+ g_file_drag_and_drop_meta_data->Reset();
// In Safari, arbitrary web pages can put on the pasteboard during an ondrag
// event, simply by calling window.event.dataTransfer.setData('URL',
@@ -156,7 +163,10 @@
}
g_file_drag_and_drop_meta_data->SetFilenames(filenames);
}
-
+}
+
+- (NSDragOperation)swizzledDraggingEntered:(id <NSDraggingInfo>)draggingInfo {
+ [self updateFromDraggingInfo:draggingInfo];
g_is_in_a_drag_operation = true;
g_drag_operation_has_been_set = false;
NSDragOperation result = [self swizzledDraggingEntered:draggingInfo];
@@ -165,6 +175,7 @@
}
- (NSDragOperation)swizzledDraggingUpdated:(id <NSDraggingInfo>)draggingInfo {
+ [self updateFromDraggingInfo:draggingInfo];
g_is_in_a_drag_operation = true;
g_drag_operation_has_been_set = false;
NSDragOperation result = [self swizzledDraggingUpdated:draggingInfo];
@@ -173,6 +184,7 @@
}
- (NSDragOperation)swizzledDraggingExited:(id <NSDraggingInfo>)draggingInfo {
+ [self updateFromDraggingInfo:draggingInfo];
g_is_in_a_drag_operation = true;
g_drag_operation_has_been_set = false;
NSDragOperation result = [self swizzledDraggingExited:draggingInfo];
@@ -182,6 +194,7 @@
}
- (BOOL)swizzledPerformDragOperation:(id <NSDraggingInfo>)draggingInfo {
+ [self updateFromDraggingInfo:draggingInfo];
g_is_in_a_drop_operation = true;
BOOL result = [self swizzledPerformDragOperation:draggingInfo];
g_file_drag_and_drop_meta_data->Reset();