[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
trey
trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:44:08 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 7909c3186eeeb665f9e1a38fc94dbd1a5cb84de0
Author: trey <trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Jun 5 03:21:30 2004 +0000
WebCore:
DHTML dragging uses the Cocoa NSDragOperation on both the source and dest ends.
In addition, I caught a prime gaffe where I had used "dropAllowed" instead of "effectAllowed"
for that particular WinIE property. That is renamed throughout.
Reviewed by rjw
* khtml/ecma/kjs_events.cpp:
(stringOrUndefined): New little helper.
(Clipboard::getValueProperty): Return Undefined if dropEffect or effectAllowed are not set.
(Clipboard::putValue): Rename.
* khtml/ecma/kjs_events.h:
(KJS::Clipboard::): Rename.
* khtml/ecma/kjs_events.lut.h:
* khtml/xml/dom2_eventsimpl.h: Rename.
* kwq/KWQClipboard.h: Rename, add access to Cocoa drag op.
* kwq/KWQClipboard.mm:
(KWQClipboard::dropEffect): These 4 just moved in the file.
(KWQClipboard::setDropEffect):
(KWQClipboard::effectAllowed):
(KWQClipboard::setEffectAllowed):
(cocoaOpFromIEOp): Convert from an IE operation string to a Cocoa DragOp
(IEOpFromCocoaOp): and vice-versa
(KWQClipboard::sourceOperation): Return effectAllowed, converted to a NSDragOp
(KWQClipboard::destinationOperation): Return dropEffect, converted to a NSDragOp
(KWQClipboard::setSourceOperation): Set effectAllowed, using a Cocoa value
(KWQClipboard::setDestinationOperation): Set dropEffect, using a Cocoa value
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::dispatchDragSrcEvent): Return the drag op specified by the source element.
(KWQKHTMLPart::khtmlMouseMoveEvent): Pass our drag op up to WebKit.
(KWQKHTMLPart::dragSourceMovedTo): Pass NULL for new arg.
(KWQKHTMLPart::dragSourceEndedAt): Ditto
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge dragOperationForDraggingInfo:]): Set the incoming dragOp onto the clipboard
so DHTML can access it. In addition, validate whatever op DHTML returns so we play well
with Cocoa.
WebKit:
DHTML dragging uses the Cocoa NSDragOperation on both the source and dest ends.
Most of the real work is in WebCore.
Reviewed by rjw
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge startDraggingImage:at:operation:event:]): Pass the drag op along.
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView _startDraggingImage:at:operation:event:]): Remember drag op from WC.
(-[WebHTMLView mouseDragged:]): Pass None for the op (alternate code path that will
be going away).
(-[WebHTMLView draggingSourceOperationMaskForLocal:]): Use the WC drag op.
* WebView.subproj/WebHTMLViewInternal.h:
* WebView.subproj/WebHTMLViewPrivate.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 8681242..0a286c5 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,44 @@
+2004-06-03 Trey Matteson <trey at apple.com>
+
+ DHTML dragging uses the Cocoa NSDragOperation on both the source and dest ends.
+
+ In addition, I caught a prime gaffe where I had used "dropAllowed" instead of "effectAllowed"
+ for that particular WinIE property. That is renamed throughout.
+
+ Reviewed by rjw
+
+ * khtml/ecma/kjs_events.cpp:
+ (stringOrUndefined): New little helper.
+ (Clipboard::getValueProperty): Return Undefined if dropEffect or effectAllowed are not set.
+ (Clipboard::putValue): Rename.
+ * khtml/ecma/kjs_events.h:
+ (KJS::Clipboard::): Rename.
+ * khtml/ecma/kjs_events.lut.h:
+ * khtml/xml/dom2_eventsimpl.h: Rename.
+ * kwq/KWQClipboard.h: Rename, add access to Cocoa drag op.
+ * kwq/KWQClipboard.mm:
+ (KWQClipboard::dropEffect): These 4 just moved in the file.
+ (KWQClipboard::setDropEffect):
+ (KWQClipboard::effectAllowed):
+ (KWQClipboard::setEffectAllowed):
+ (cocoaOpFromIEOp): Convert from an IE operation string to a Cocoa DragOp
+ (IEOpFromCocoaOp): and vice-versa
+ (KWQClipboard::sourceOperation): Return effectAllowed, converted to a NSDragOp
+ (KWQClipboard::destinationOperation): Return dropEffect, converted to a NSDragOp
+ (KWQClipboard::setSourceOperation): Set effectAllowed, using a Cocoa value
+ (KWQClipboard::setDestinationOperation): Set dropEffect, using a Cocoa value
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::dispatchDragSrcEvent): Return the drag op specified by the source element.
+ (KWQKHTMLPart::khtmlMouseMoveEvent): Pass our drag op up to WebKit.
+ (KWQKHTMLPart::dragSourceMovedTo): Pass NULL for new arg.
+ (KWQKHTMLPart::dragSourceEndedAt): Ditto
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge dragOperationForDraggingInfo:]): Set the incoming dragOp onto the clipboard
+ so DHTML can access it. In addition, validate whatever op DHTML returns so we play well
+ with Cocoa.
+
2004-06-04 David Hyatt <hyatt at apple.com>
Add support for auto values in flex transitions. Add support for mapping the back end values to
@@ -342,7 +383,6 @@
* khtml/rendering/render_canvasimage.cpp:
(RenderCanvasImage::createDrawingContext):
->>>>>>> 1.2855
2004-06-01 Trey Matteson <trey at apple.com>
First cut at the source side of DHTML dragging. Following IE, new events are added:
diff --git a/WebCore/khtml/ecma/kjs_events.cpp b/WebCore/khtml/ecma/kjs_events.cpp
index d2d744d..1964a0d 100644
--- a/WebCore/khtml/ecma/kjs_events.cpp
+++ b/WebCore/khtml/ecma/kjs_events.cpp
@@ -892,7 +892,7 @@ const ClassInfo Clipboard::info = { "Clipboard", 0, &ClipboardTable, 0 };
/* Source for ClipboardTable. Use "make hashtables" to regenerate.
@begin ClipboardTable 3
dropEffect Clipboard::DropEffect DontDelete
- dropAllowed Clipboard::DropAllowed DontDelete
+ effectAllowed Clipboard::EffectAllowed DontDelete
types Clipboard::Types DontDelete|ReadOnly
@end
@begin ClipboardProtoTable 4
@@ -920,7 +920,16 @@ Clipboard::~Clipboard()
clipboard->deref();
}
-// FIXME lookups of dropEffect and dropAllowed should fail if !clipboard->isForDragging
+static Value stringOrUndefined(const DOM::DOMString &str)
+{
+ if (str.isNull()) {
+ return Undefined();
+ } else {
+ return String(str);
+ }
+}
+
+// FIXME lookups of dropEffect and effectAllowed should fail if !clipboard->isForDragging
Value Clipboard::tryGet(ExecState *exec, const Identifier &propertyName) const
{
@@ -931,9 +940,9 @@ Value Clipboard::getValueProperty(ExecState *exec, int token) const
{
switch (token) {
case DropEffect:
- return String(clipboard->dropEffect());
- case DropAllowed:
- return String(clipboard->dropAllowed());
+ return stringOrUndefined(clipboard->dropEffect());
+ case EffectAllowed:
+ return stringOrUndefined(clipboard->effectAllowed());
case Types:
{
QStringList qTypes = clipboard->types();
@@ -964,8 +973,8 @@ void Clipboard::putValue(ExecState *exec, int token, const Value& value, int /*a
case DropEffect:
clipboard->setDropEffect(value.toString(exec).string());
break;
- case DropAllowed:
- clipboard->setDropAllowed(value.toString(exec).string());
+ case EffectAllowed:
+ clipboard->setEffectAllowed(value.toString(exec).string());
break;
default:
kdWarning() << "Clipboard::putValue unhandled token " << token << endl;
diff --git a/WebCore/khtml/ecma/kjs_events.h b/WebCore/khtml/ecma/kjs_events.h
index 191801e..baa7f72 100644
--- a/WebCore/khtml/ecma/kjs_events.h
+++ b/WebCore/khtml/ecma/kjs_events.h
@@ -200,7 +200,7 @@ namespace KJS {
virtual bool toBoolean(ExecState *) const { return true; }
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
- enum { ClearData, GetData, SetData, Types, SetDragImage, DropEffect, DropAllowed };
+ enum { ClearData, GetData, SetData, Types, SetDragImage, DropEffect, EffectAllowed };
private:
DOM::ClipboardImpl *clipboard;
};
diff --git a/WebCore/khtml/ecma/kjs_events.lut.h b/WebCore/khtml/ecma/kjs_events.lut.h
index 540c28b..829f9f0 100644
--- a/WebCore/khtml/ecma/kjs_events.lut.h
+++ b/WebCore/khtml/ecma/kjs_events.lut.h
@@ -214,10 +214,10 @@ const struct HashTable DOMMutationEventProtoTable = { 2, 1, DOMMutationEventProt
namespace KJS {
const struct HashEntry ClipboardTableEntries[] = {
- { "dropEffect", Clipboard::DropEffect, DontDelete, 0, &ClipboardTableEntries[3] },
- { "types", Clipboard::Types, DontDelete|ReadOnly, 0, 0 },
+ { "dropEffect", Clipboard::DropEffect, DontDelete, 0, 0 },
+ { "effectAllowed", Clipboard::EffectAllowed, DontDelete, 0, &ClipboardTableEntries[3] },
{ 0, 0, 0, 0, 0 },
- { "dropAllowed", Clipboard::DropAllowed, DontDelete, 0, 0 }
+ { "types", Clipboard::Types, DontDelete|ReadOnly, 0, 0 }
};
const struct HashTable ClipboardTable = { 2, 4, ClipboardTableEntries, 3 };
diff --git a/WebCore/khtml/xml/dom2_eventsimpl.h b/WebCore/khtml/xml/dom2_eventsimpl.h
index b2a95c3..be4d543 100644
--- a/WebCore/khtml/xml/dom2_eventsimpl.h
+++ b/WebCore/khtml/xml/dom2_eventsimpl.h
@@ -384,8 +384,8 @@ public:
virtual DOMString dropEffect() const = 0;
virtual void setDropEffect(const DOMString &s) = 0;
- virtual DOMString dropAllowed() const = 0;
- virtual void setDropAllowed(const DOMString &s) = 0;
+ virtual DOMString effectAllowed() const = 0;
+ virtual void setEffectAllowed(const DOMString &s) = 0;
virtual void clearData(const DOMString &type) = 0;
virtual void clearAllData() = 0;
diff --git a/WebCore/kwq/KWQClipboard.h b/WebCore/kwq/KWQClipboard.h
index 3454206..d52f8a5 100644
--- a/WebCore/kwq/KWQClipboard.h
+++ b/WebCore/kwq/KWQClipboard.h
@@ -41,8 +41,8 @@ public:
DOM::DOMString dropEffect() const;
void setDropEffect(const DOM::DOMString &s);
- DOM::DOMString dropAllowed() const;
- void setDropAllowed(const DOM::DOMString &s);
+ DOM::DOMString effectAllowed() const;
+ void setEffectAllowed(const DOM::DOMString &s);
void clearData(const DOM::DOMString &type);
void clearAllData();
@@ -58,13 +58,19 @@ public:
void setDragLocation(const QPoint &);
QPixmap dragImage() const;
void setDragImage(const QPixmap &);
+
+ // Methods for getting info in Cocoa's type system
NSImage *dragNSImage();
+ bool sourceOperation(NSDragOperation *op) const;
+ bool destinationOperation(NSDragOperation *op) const;
+ void setSourceOperation(NSDragOperation op);
+ void setDestinationOperation(NSDragOperation op);
private:
NSPasteboard *m_pasteboard;
bool m_forDragging;
DOM::DOMString m_dropEffect;
- DOM::DOMString m_dropAllowed;
+ DOM::DOMString m_effectAllowed;
QPoint m_dragLoc;
QPixmap m_dragImage;
};
diff --git a/WebCore/kwq/KWQClipboard.mm b/WebCore/kwq/KWQClipboard.mm
index 3247e03..10ebc86 100644
--- a/WebCore/kwq/KWQClipboard.mm
+++ b/WebCore/kwq/KWQClipboard.mm
@@ -43,26 +43,6 @@ bool KWQClipboard::isForDragging() const
return m_forDragging;
}
-DOM::DOMString KWQClipboard::dropEffect() const
-{
- return m_dropEffect;
-}
-
-void KWQClipboard::setDropEffect(const DOM::DOMString &s)
-{
- m_dropEffect = s;
-}
-
-DOM::DOMString KWQClipboard::dropAllowed() const
-{
- return m_dropAllowed;
-}
-
-void KWQClipboard::setDropAllowed(const DOM::DOMString &s)
-{
- m_dropAllowed = s;
-}
-
// FIXME hardwired for now, will use UTI
static NSString *cocoaTypeFromMIMEType(const DOMString &type) {
QString qType = type.string();
@@ -248,3 +228,99 @@ NSImage *KWQClipboard::dragNSImage()
{
return m_dragImage.image();
}
+
+DOM::DOMString KWQClipboard::dropEffect() const
+{
+ return m_dropEffect;
+}
+
+void KWQClipboard::setDropEffect(const DOM::DOMString &s)
+{
+ m_dropEffect = s;
+}
+
+DOM::DOMString KWQClipboard::effectAllowed() const
+{
+ return m_effectAllowed;
+}
+
+void KWQClipboard::setEffectAllowed(const DOM::DOMString &s)
+{
+ m_effectAllowed = s;
+}
+
+static NSDragOperation cocoaOpFromIEOp(const DOMString &op) {
+ // yep, it's really just this fixed set
+ if (op == "none") {
+ return NSDragOperationNone;
+ } else if (op == "copy") {
+ return NSDragOperationCopy;
+ } else if (op == "link") {
+ return NSDragOperationLink;
+ } else if (op == "move") {
+ return NSDragOperationGeneric;
+ } else if (op == "copyLink") {
+ return NSDragOperationCopy | NSDragOperationLink;
+ } else if (op == "copyMove") {
+ return NSDragOperationCopy | NSDragOperationGeneric | NSDragOperationMove;
+ } else if (op == "linkMove") {
+ return NSDragOperationLink | NSDragOperationGeneric | NSDragOperationMove;
+ } else if (op == "all") {
+ return NSDragOperationEvery;
+ } else {
+ return NSDragOperationPrivate; // really a marker for "no conversion"
+ }
+}
+
+static const DOMString IEOpFromCocoaOp(NSDragOperation op) {
+ bool moveSet = ((NSDragOperationGeneric | NSDragOperationMove) & op) != 0;
+
+ if ((moveSet && (op & NSDragOperationCopy) && (op & NSDragOperationLink))
+ || (op == NSDragOperationEvery)) {
+ return "all";
+ } else if (moveSet && (op & NSDragOperationCopy)) {
+ return "copyMove";
+ } else if (moveSet && (op & NSDragOperationLink)) {
+ return "linkMove";
+ } else if ((op & NSDragOperationCopy) && (op & NSDragOperationLink)) {
+ return "copyLink";
+ } else if (moveSet) {
+ return "move";
+ } else if (op & NSDragOperationCopy) {
+ return "copy";
+ } else if (op & NSDragOperationLink) {
+ return "link";
+ } else {
+ return "none";
+ }
+}
+
+bool KWQClipboard::sourceOperation(NSDragOperation *op) const
+{
+ if (m_effectAllowed.isNull()) {
+ return false;
+ } else {
+ *op = cocoaOpFromIEOp(m_effectAllowed);
+ return true;
+ }
+}
+
+bool KWQClipboard::destinationOperation(NSDragOperation *op) const
+{
+ if (m_dropEffect.isNull()) {
+ return false;
+ } else {
+ *op = cocoaOpFromIEOp(m_dropEffect);
+ return true;
+ }
+}
+
+void KWQClipboard::setSourceOperation(NSDragOperation op)
+{
+ m_effectAllowed = IEOpFromCocoaOp(op);
+}
+
+void KWQClipboard::setDestinationOperation(NSDragOperation op)
+{
+ m_dropEffect = IEOpFromCocoaOp(op);
+}
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index 696d350..b0ebebb 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -327,7 +327,7 @@ private:
static NSView *documentViewForNode(DOM::NodeImpl *);
bool dragHysteresisExceeded(float dragLocationX, float dragLocationY) const;
- bool dispatchDragSrcEvent(int eventId, const QPoint &loc, bool declareTypes, NSImage **dragImage, NSPoint *dragLoc) const;
+ bool dispatchDragSrcEvent(int eventId, const QPoint &loc, bool declareTypes, NSImage **dragImage, NSPoint *dragLoc, unsigned *op) const;
WebCoreBridge *_bridge;
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 60fbc43..0bbd128 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -1907,7 +1907,7 @@ bool KWQKHTMLPart::dragHysteresisExceeded(float dragLocationX, float dragLocatio
}
// returns if we should continue "default processing", i.e., whether eventhandler canceled
-bool KWQKHTMLPart::dispatchDragSrcEvent(int eventId, const QPoint &loc, bool declareTypes, NSImage **dragImage, NSPoint *dragLoc) const
+bool KWQKHTMLPart::dispatchDragSrcEvent(int eventId, const QPoint &loc, bool declareTypes, NSImage **dragImage, NSPoint *dragLoc, NSDragOperation *op) const
{
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
if (declareTypes) {
@@ -1933,6 +1933,11 @@ bool KWQKHTMLPart::dispatchDragSrcEvent(int eventId, const QPoint &loc, bool dec
}
}
+ if (op) {
+ // *op unchanged if no source op was set
+ clipboard->sourceOperation(op);
+ }
+
clipboard->deref();
return !DHTMLBailed;
}
@@ -1978,13 +1983,14 @@ void KWQKHTMLPart::khtmlMouseMoveEvent(MouseMoveEvent *event)
if (dragHysteresisExceeded(dragLocation.x, dragLocation.y)) {
NSImage *dragImage = nil;
NSPoint dragLoc = NSZeroPoint;
- if (dispatchDragSrcEvent(EventImpl::DRAGSTART_EVENT, QPoint(dragLocation), true, &dragImage, &dragLoc)) {
- if ([_bridge startDraggingImage:dragImage at:dragLoc event:_currentEvent]) {
+ NSDragOperation srcOp = NSDragOperationNone;
+ if (dispatchDragSrcEvent(EventImpl::DRAGSTART_EVENT, QPoint(dragLocation), true, &dragImage, &dragLoc, &srcOp)) {
+ if ([_bridge startDraggingImage:dragImage at:dragLoc operation:srcOp event:_currentEvent]) {
// Prevent click handling from taking place once we start dragging.
d->m_view->invalidateClick();
} else {
// WebKit canned the drag at the last minute - we owe _dragSrc a DRAGEND event
- dispatchDragSrcEvent(EventImpl::DRAGEND_EVENT, QPoint(dragLocation), false, NULL, NULL);
+ dispatchDragSrcEvent(EventImpl::DRAGEND_EVENT, QPoint(dragLocation), false, NULL, NULL, NULL);
}
} else {
_mouseDownMayStartDrag = false;
@@ -2019,14 +2025,18 @@ void KWQKHTMLPart::khtmlMouseMoveEvent(MouseMoveEvent *event)
void KWQKHTMLPart::dragSourceMovedTo(const QPoint &loc)
{
- // for now we don't care if event handler cancels default behavior, since there is none
- dispatchDragSrcEvent(EventImpl::DRAG_EVENT, loc, false, NULL, NULL);
+ if (!_dragSrc.isNull()) {
+ // for now we don't care if event handler cancels default behavior, since there is none
+ dispatchDragSrcEvent(EventImpl::DRAG_EVENT, loc, false, NULL, NULL, NULL);
+ }
}
void KWQKHTMLPart::dragSourceEndedAt(const QPoint &loc)
{
- // for now we don't care if event handler cancels default behavior, since there is none
- dispatchDragSrcEvent(EventImpl::DRAGEND_EVENT, loc, false, NULL, NULL);
+ if (!_dragSrc.isNull()) {
+ // for now we don't care if event handler cancels default behavior, since there is none
+ dispatchDragSrcEvent(EventImpl::DRAGEND_EVENT, loc, false, NULL, NULL, NULL);
+ }
}
void KWQKHTMLPart::khtmlMouseReleaseEvent(MouseReleaseEvent *event)
@@ -2885,7 +2895,6 @@ QRect KWQKHTMLPart::selectionRect() const
RenderCanvas *root = static_cast<RenderCanvas *>(xmlDocImpl()->renderer());
if (!root) {
return QRect();
-
}
return root->selectionRect();
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 725bd67..9cc8b42 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -428,7 +428,7 @@ typedef enum {
- (NSString *)MIMETypeForPath:(NSString *)path;
-- (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc event:(NSEvent *)event;
+- (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event;
- (void)handleAutoscrollForMouseDragged:(NSEvent *)event;
- (BOOL)mayStartDragWithMouseDragged:(NSEvent *)event;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index ef577cc..8ede873 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -1577,6 +1577,7 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
- (NSDragOperation)dragOperationForDraggingInfo:(id <NSDraggingInfo>)info
{
+ NSDragOperation op = NSDragOperationNone;
if (_part) {
KHTMLView *v = _part->view();
if (v) {
@@ -1585,18 +1586,36 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
KWQClipboard *clipboard = new KWQClipboard(true, [info draggingPasteboard]);
clipboard->ref();
-
- // FIXME - massage result into NSDragOperation
- // consult event.stopped and event.dataTransfer.dropEffect
- // perhaps put that smarts in KWQClipboard
- NSDragOperation op = v->updateDragAndDrop(QPoint([info draggingLocation]), clipboard) ? NSDragOperationCopy : NSDragOperationNone;
-
+ NSDragOperation srcOp = [info draggingSourceOperationMask];
+ clipboard->setSourceOperation(srcOp);
+
+ if (v->updateDragAndDrop(QPoint([info draggingLocation]), clipboard)) {
+ // *op unchanged if no source op was set
+ if (!clipboard->destinationOperation(&op)) {
+ // The element accepted but they didn't pick an operation, so we pick one for them
+ // (as does WinIE).
+ if (srcOp & NSDragOperationCopy) {
+ op = NSDragOperationCopy;
+ } else if (srcOp & NSDragOperationMove || srcOp & NSDragOperationGeneric) {
+ op = NSDragOperationMove;
+ } else if (srcOp & NSDragOperationLink) {
+ op = NSDragOperationLink;
+ } else {
+ op = NSDragOperationGeneric;
+ }
+ } else if (!(op & srcOp)) {
+ // make sure WC picked an op that was offered. Cocoa doesn't seem to enforce this,
+ // but IE does.
+ op = NSDragOperationNone;
+ }
+ }
+
clipboard->deref();
v->deref();
return op;
}
}
- return NSDragOperationNone;
+ return op;
}
- (void)dragExitedWithDraggingInfo:(id <NSDraggingInfo>)info
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index d5b355e..45db53d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,20 @@
+2004-06-03 Trey Matteson <trey at apple.com>
+
+ DHTML dragging uses the Cocoa NSDragOperation on both the source and dest ends.
+ Most of the real work is in WebCore.
+
+ Reviewed by rjw
+
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge startDraggingImage:at:operation:event:]): Pass the drag op along.
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView _startDraggingImage:at:operation:event:]): Remember drag op from WC.
+ (-[WebHTMLView mouseDragged:]): Pass None for the op (alternate code path that will
+ be going away).
+ (-[WebHTMLView draggingSourceOperationMaskForLocal:]): Use the WC drag op.
+ * WebView.subproj/WebHTMLViewInternal.h:
+ * WebView.subproj/WebHTMLViewPrivate.h:
+
=== Safari-143 ===
2004-06-04 Chris Blumenberg <cblu at apple.com>
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 900fffd..9554480 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -987,11 +987,11 @@ static BOOL loggedObjectCacheSize = NO;
return [type length] == 0 ? @"application/octet-stream" : type;
}
-- (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc event:(NSEvent *)event
+- (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event
{
WebHTMLView *docView = (WebHTMLView *)[[_frame frameView] documentView];
ASSERT([docView isKindOfClass:[WebHTMLView class]]);
- return [docView _startDraggingImage:dragImage at:dragLoc event:event];
+ return [docView _startDraggingImage:dragImage at:dragLoc operation:op event:event];
}
- (void)handleAutoscrollForMouseDragged:(NSEvent *)event;
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index b39aee6..7db507d 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -772,7 +772,7 @@ static WebHTMLView *lastHitView = nil;
return dragImage;
}
-- (BOOL)_startDraggingImage:(NSImage *)wcDragImage at:(NSPoint)wcDragLoc event:(NSEvent *)mouseDraggedEvent
+- (BOOL)_startDraggingImage:(NSImage *)wcDragImage at:(NSPoint)wcDragLoc operation:(NSDragOperation)op event:(NSEvent *)mouseDraggedEvent
{
// Once we start a drag session we may not get a mouseup, so clear this out here as well as mouseUp:
_private->firstMouseDownEvent = nil;
@@ -788,6 +788,7 @@ static WebHTMLView *lastHitView = nil;
_private->draggingImageURL = nil;
NSPoint mouseDraggedPoint = [self convertPoint:[mouseDraggedEvent locationInWindow] fromView:nil];
+ _private->webCoreDragOp = op; // will be DragNone if WebCore doesn't care
NSImage *dragImage = nil;
if (imageURL) {
@@ -1727,16 +1728,20 @@ static WebHTMLView *lastHitView = nil;
// Handle the drag directly instead of getting callbacks from WebCore.
// FIXME - how does this play with DHTML dragging?
if ([self _mayStartDragWithMouseDragged:event]) {
- [self _startDraggingImage:nil at:NSZeroPoint event:event];
+ [self _startDraggingImage:nil at:NSZeroPoint operation:NSDragOperationNone event:event];
}
} else if (!_private->ignoringMouseDraggedEvents) {
[[self _bridge] mouseDragged:event];
}
}
-- (unsigned)draggingSourceOperationMaskForLocal:(BOOL)isLocal
+- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
{
- return (NSDragOperationGeneric | NSDragOperationCopy);
+ if (_private->webCoreDragOp == NSDragOperationNone) {
+ return (NSDragOperationGeneric | NSDragOperationCopy);
+ } else {
+ return _private->webCoreDragOp;
+ }
}
- (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenLoc
diff --git a/WebKit/WebView.subproj/WebHTMLViewInternal.h b/WebKit/WebView.subproj/WebHTMLViewInternal.h
index 0212455..669d631 100644
--- a/WebKit/WebView.subproj/WebHTMLViewInternal.h
+++ b/WebKit/WebView.subproj/WebHTMLViewInternal.h
@@ -14,6 +14,7 @@
BOOL initiatedDrag;
// Is WebCore handling drag destination duties (DHTML dragging)?
BOOL webCoreHandlingDrag;
+ NSDragOperation webCoreDragOp;
id savedSubviews;
BOOL subviewsSetAside;
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
index bb38c6f..ae59e51 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -45,7 +45,7 @@
- (void)_frameOrBoundsChanged;
- (NSImage *)_dragImageForLinkElement:(NSDictionary *)element;
-- (BOOL)_startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc event:(NSEvent *)event;
+- (BOOL)_startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event;
- (void)_handleAutoscrollForMouseDragged:(NSEvent *)event;
- (BOOL)_mayStartDragWithMouseDragged:(NSEvent *)event;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list