Changeset 19327 in webkit
- Timestamp:
- Jan 31, 2007, 10:02:09 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r19324 r19327 1 2007-01-31 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Adam. 4 5 Migrate more drag and drop logic to WebCore, start preparing 6 to move EventHandler::handleDrag from EventHandlerMac to EventHandler 7 8 * WebCore.exp: 9 updating methods 10 11 * dom/Clipboard.cpp: 12 * dom/Clipboard.h: 13 (WebCore::Clipboard::Clipboard): 14 (WebCore::Clipboard::setDragHasStarted): 15 (WebCore::Clipboard::dragStarted): 16 Moving from ClipboardMac to Clipboard 17 18 * dom/EventTargetNode.cpp: 19 (WebCore::EventTargetNode::dispatchMouseEvent): 20 PlatformMouseEvent no longer lies about button state, however 21 DOM Events don't allow NoButton, so we need to convert NoButton 22 to LeftButton when we create a DOM Event from PlatformMouseEvent 23 24 * page/DragClient.h: 25 Tidying comment 26 27 * page/DragController.cpp: 28 (WebCore::createMouseEvent): 29 Updated for new PlatformMouseEvent constructors 30 (WebCore::DragController::mayStartDragAtEventLocation): 31 Migrated from WebKit 32 33 * page/DragController.h: 34 Added above function declarations 35 36 * page/EventHandler.cpp: 37 (WebCore::EventHandler::dragState): 38 (WebCore::EventHandler::dragHysteresisExceeded): 39 (WebCore::EventHandler::freeClipboard): 40 (WebCore::EventHandler::shouldDragAutoNode): 41 Moved from EventHandlerMac 42 (WebCore::EventHandler::handleMouseMoveEvent): 43 (WebCore::EventHandler::eventMayStartDrag): 44 (WebCore::EventHandler::handleMousePressEvent): 45 Use DragController 46 47 * page/EventHandler.h: 48 Added DragState struct definition to EventHandler 49 50 * page/mac/EventHandlerMac.mm: 51 (WebCore::EventHandler::eventActivatedView): 52 (WebCore::EventHandler::handleDrag): 53 (WebCore::EventHandler::handleMouseUp): 54 (WebCore::EventHandler::mouseDown): 55 Update to use DragController and PlatformMouseEvent 56 57 * page/mac/WebCoreFrameBridge.h: 58 * page/mac/WebCoreFrameBridge.mm: 59 (-[WebCoreFrameBridge dragSourceMovedTo:]): 60 (-[WebCoreFrameBridge dragSourceEndedAt:operation:]): 61 Use DragController for state 62 63 * platform/PlatformMouseEvent.h: 64 (WebCore::): 65 (WebCore::PlatformMouseEvent::PlatformMouseEvent): 66 (WebCore::PlatformMouseEvent::eventType): 67 (WebCore::PlatformMouseEvent::timestamp): 68 (WebCore::PlatformMouseEvent::eventNumber): 69 (WebCore::PlatformMouseEvent::setClickCount): 70 Exposing necessary data for Drag logic 71 72 * platform/mac/ClipboardMac.h: 73 * platform/mac/ClipboardMac.mm: 74 (WebCore::ClipboardMac::ClipboardMac): 75 (WebCore::ClipboardMac::setDragImage): 76 Have moved a number of fields from ClipboardMac to Clipboard 77 so need to use accessors in a few places now 78 79 * platform/mac/PlatformMouseEventMac.mm: 80 (WebCore::mouseButtonForEvent): 81 (WebCore::mouseEventForNSEvent): 82 (WebCore::PlatformMouseEvent::PlatformMouseEvent): 83 Determine MouseEventType, and provide event time info 84 1 85 2007-01-31 Alexey Proskuryakov <ap@webkit.org> 2 86 -
trunk/WebCore/WebCore.exp
r19322 r19327 474 474 __ZNK7WebCore11HistoryItem9viewStateEv 475 475 __ZNK7WebCore12AtomicString16deprecatedStringEv 476 __ZNK7WebCore12EventHandler17eventMayStartDragE P7NSEvent476 __ZNK7WebCore12EventHandler17eventMayStartDragERKNS_18PlatformMouseEventE 477 477 __ZNK7WebCore12EventHandler20currentKeyboardEventEv 478 478 __ZNK7WebCore12RenderObject25backslashAsCurrencySymbolEv -
trunk/WebCore/dom/Clipboard.cpp
r19039 r19327 28 28 29 29 namespace WebCore { 30 31 30 32 31 void Clipboard::setAccessPolicy(ClipboardAccessPolicy policy) -
trunk/WebCore/dom/Clipboard.h
r19039 r19327 42 42 class Clipboard : public Shared<Clipboard> { 43 43 public: 44 Clipboard(ClipboardAccessPolicy policy) : m_policy(policy) { }44 Clipboard(ClipboardAccessPolicy policy) : m_policy(policy), m_dragStarted(false) { } 45 45 virtual ~Clipboard() { } 46 46 … … 74 74 void setDestinationOperation(DragOperation); 75 75 76 void setDragHasStarted() { m_dragStarted = true; } 76 77 protected: 77 78 ClipboardAccessPolicy policy() const { return m_policy; } 78 79 bool dragStarted() const { return m_dragStarted; } 79 80 private: 80 81 ClipboardAccessPolicy m_policy; 81 82 String m_dropEffect; 82 83 String m_effectAllowed; 84 bool m_dragStarted; 83 85 }; 84 86 -
trunk/WebCore/dom/EventTargetNode.cpp
r19237 r19327 376 376 if (FrameView* view = document()->view()) 377 377 contentsPos = view->windowToContents(event.pos()); 378 379 return dispatchMouseEvent(eventType, event.button(), detail, 378 379 short button = event.button(); 380 381 ASSERT(event.eventType() == MouseEventMoved || button != NoButton); 382 383 return dispatchMouseEvent(eventType, button == NoButton ? 0 : button , detail, 380 384 contentsPos.x(), contentsPos.y(), event.globalX(), event.globalY(), 381 385 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), -
trunk/WebCore/page/DragClient.h
r19230 r19327 41 41 virtual void dragControllerDestroyed() = 0; 42 42 43 //The UI delegate takes the point in view coordinates, however it is easier to pass 44 //window coordinates here 43 //We work in window rather than view coordinates here 45 44 virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& windowPoint) = 0; 45 46 46 virtual ~DragClient() {}; 47 47 }; -
trunk/WebCore/page/DragController.cpp
r19231 r19327 50 50 #include "ResourceRequest.h" 51 51 #include "SelectionController.h" 52 #include "Settings.h" 53 #include "SystemTime.h" 52 54 #include "Text.h" 53 55 #include "wtf/RefPtr.h" … … 59 61 // FIXME: We should fake modifier keys here. 60 62 return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPosition(), 61 LeftButton, 0, false, false, false, false);63 LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime()); 62 64 63 65 } … … 418 420 } 419 421 420 } 422 bool DragController::mayStartDragAtEventLocation(const Frame* frame, const IntPoint& framePos) 423 { 424 ASSERT(frame); 425 426 if (!frame->view() || !frame->renderer()) 427 return false; 428 429 HitTestResult mouseDownTarget = HitTestResult(framePos); 430 431 mouseDownTarget = frame->eventHandler()->hitTestResultAtPoint(framePos, true); 432 433 if (mouseDownTarget.image() 434 && !mouseDownTarget.absoluteImageURL().isEmpty() 435 && frame->settings()->loadsImagesAutomatically() 436 && m_dragSourceAction & DragSourceActionImage) 437 return true; 438 439 if (!mouseDownTarget.absoluteLinkURL().isEmpty() 440 && m_dragSourceAction & DragSourceActionLink 441 && mouseDownTarget.isLiveLink()) 442 return true; 443 444 if (mouseDownTarget.isSelected() 445 && m_dragSourceAction & DragSourceActionSelection) 446 return true; 447 448 return false; 449 450 } 451 452 } -
trunk/WebCore/page/DragController.h
r19230 r19327 37 37 class DragClient; 38 38 class DragData; 39 class Frame; 40 class Page; 39 41 class SelectionController; 40 class Page;41 42 42 43 class DragController { … … 71 72 DragSourceAction delegateDragSourceAction(const IntPoint& pagePoint); 72 73 74 bool mayStartDragAtEventLocation(const Frame*, const IntPoint& framePos); 73 75 void dragEnded() { m_dragInitiator = 0; m_didInitiateDrag = false; } 74 76 -
trunk/WebCore/page/EventHandler.cpp
r19237 r19327 70 70 // needs to be enough space to cancel the link press without starting a link drag, 71 71 // and because dragging links is rare. 72 const float LinkDragHysteresis = 40.0;73 const float ImageDragHysteresis = 5.0;74 const float TextDragHysteresis = 3.0;75 const float GeneralDragHysteresis = 3.0;72 const int LinkDragHysteresis = 40; 73 const int ImageDragHysteresis = 5; 74 const int TextDragHysteresis = 3; 75 const int GeneralDragHysteresis = 3; 76 76 const double TextDragDelay = 0.15; 77 77 … … 110 110 { 111 111 } 112 112 113 EventHandler::EventHandlerDragState& EventHandler::dragState() 114 { 115 static EventHandlerDragState state; 116 return state; 117 } 118 113 119 void EventHandler::clear() 114 120 { … … 302 308 Node* innerNode = event.targetNode(); 303 309 304 if (event.event().button() != 0|| !innerNode || !innerNode->renderer())310 if (event.event().button() != LeftButton || !innerNode || !innerNode->renderer()) 305 311 return false; 306 312 … … 339 345 340 346 return true; 347 } 348 349 bool EventHandler::eventMayStartDrag(const PlatformMouseEvent& event) const 350 { 351 // This is a pre-flight check of whether the event might lead to a drag being started. Be careful 352 // that its logic needs to stay in sync with handleMouseMoveEvent() and the way we setMouseDownMayStartDrag 353 // in handleMousePressEvent 354 355 if (!m_frame->renderer() || !m_frame->renderer()->layer() 356 || event.button() != LeftButton || event.clickCount() != 1) 357 return false; 358 359 bool DHTMLFlag; 360 bool UAFlag; 361 allowDHTMLDrag(DHTMLFlag, UAFlag); 362 if (!DHTMLFlag && !UAFlag) 363 return false; 364 365 HitTestRequest request(true, false); 366 HitTestResult result(event.pos()); 367 m_frame->renderer()->layer()->hitTest(request, result); 368 bool srcIsDHTML; 369 return result.innerNode() && result.innerNode()->renderer()->draggableNode(DHTMLFlag, UAFlag, event.x(), event.y(), srcIsDHTML); 341 370 } 342 371 … … 714 743 m_mousePressed = true; 715 744 m_currentMousePosition = mouseEvent.pos(); 745 m_mouseDownTimestamp = mouseEvent.timestamp(); 746 m_mouseDownMayStartDrag = false; 747 m_mouseDownMayStartSelect = false; 748 m_mouseDownMayStartAutoscroll = false; 749 m_mouseDownPos = m_frame->view()->windowToContents(mouseEvent.pos()); 716 750 m_mouseDownWasInSubframe = false; 717 751 … … 1245 1279 } 1246 1280 } 1247 1248 } 1281 1282 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLocation) const 1283 { 1284 IntPoint dragViewportLocation((int)floatDragViewportLocation.x(), (int)floatDragViewportLocation.y()); 1285 return dragHysteresisExceeded(dragViewportLocation); 1286 } 1287 1288 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation) const 1289 { 1290 IntPoint dragLocation = m_frame->view()->windowToContents(dragViewportLocation); 1291 IntSize delta = dragLocation - m_mouseDownPos; 1292 1293 int threshold = GeneralDragHysteresis; 1294 if (dragState().m_dragSrcIsImage) 1295 threshold = ImageDragHysteresis; 1296 else if (dragState().m_dragSrcIsLink) 1297 threshold = LinkDragHysteresis; 1298 else if (dragState().m_dragSrcInSelection) 1299 threshold = TextDragHysteresis; 1300 1301 return abs(delta.width()) >= threshold || abs(delta.height()) >= threshold; 1302 } 1303 1304 void EventHandler::freeClipboard() 1305 { 1306 if (dragState().m_dragClipboard) 1307 dragState().m_dragClipboard->setAccessPolicy(ClipboardNumb); 1308 } 1309 1310 bool EventHandler::shouldDragAutoNode(Node* node, const IntPoint& point) const 1311 { 1312 ASSERT(node); 1313 if (node->hasChildNodes() || !m_frame->view()) 1314 return false; 1315 return m_frame->page() && m_frame->page()->dragController()->mayStartDragAtEventLocation(m_frame, point); 1316 } 1317 1318 } -
trunk/WebCore/page/EventHandler.h
r19237 r19327 68 68 struct HitTestRequest; 69 69 70 extern const float LinkDragHysteresis;71 extern const float ImageDragHysteresis;72 extern const float TextDragHysteresis;73 extern const float GeneralDragHysteresis;70 extern const int LinkDragHysteresis; 71 extern const int ImageDragHysteresis; 72 extern const int TextDragHysteresis; 73 extern const int GeneralDragHysteresis; 74 74 extern const double TextDragDelay; 75 75 76 76 class EventHandler : Noncopyable { 77 struct EventHandlerDragState { 78 RefPtr<Node> m_dragSrc; // element that may be a drag source, for the current mouse gesture 79 bool m_dragSrcIsLink; 80 bool m_dragSrcIsImage; 81 bool m_dragSrcInSelection; 82 bool m_dragSrcMayBeDHTML; 83 bool m_dragSrcMayBeUA; // Are DHTML and/or the UserAgent allowed to drag out? 84 bool m_dragSrcIsDHTML; 85 RefPtr<Clipboard> m_dragClipboard; // used on only the source side of dragging 86 }; 87 static EventHandlerDragState& dragState(); 77 88 public: 78 89 EventHandler(Frame*); … … 130 141 131 142 void defaultKeyboardEventHandler(KeyboardEvent*); 143 144 bool eventMayStartDrag(const PlatformMouseEvent&) const; 132 145 133 146 #if PLATFORM(MAC) … … 141 154 bool wheelEvent(NSEvent*); 142 155 143 bool eventMayStartDrag(NSEvent*) const;144 156 145 157 void sendFakeEventsAfterWidgetTracking(NSEvent* initiatingEvent); … … 154 166 155 167 private: 168 bool eventActivatedView(const PlatformMouseEvent&) const; 156 169 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults& event); 157 170 -
trunk/WebCore/page/mac/EventHandlerMac.mm
r19230 r19327 56 56 using namespace EventNames; 57 57 58 struct EventHandlerDragState {59 RefPtr<Node> m_dragSrc; // element that may be a drag source, for the current mouse gesture60 bool m_dragSrcIsLink;61 bool m_dragSrcIsImage;62 bool m_dragSrcInSelection;63 bool m_dragSrcMayBeDHTML;64 bool m_dragSrcMayBeUA; // Are DHTML and/or the UserAgent allowed to drag out?65 bool m_dragSrcIsDHTML;66 RefPtr<ClipboardMac> m_dragClipboard; // used on only the source side of dragging67 };68 69 static EventHandlerDragState& dragState()70 {71 static EventHandlerDragState state;72 return state;73 }74 58 75 59 static NSEvent *currentEvent; … … 142 126 143 127 return handlingOptionTab; 144 }145 146 void EventHandler::freeClipboard()147 {148 if (dragState().m_dragClipboard)149 dragState().m_dragClipboard->setAccessPolicy(ClipboardNumb);150 128 } 151 129 … … 341 319 } 342 320 343 bool EventHandler::eventMayStartDrag(NSEvent *event) const 344 { 345 // This is a pre-flight check of whether the event might lead to a drag being started. Be careful 346 // that its logic needs to stay in sync with handleMouseMoveEvent() and the way we setMouseDownMayStartDrag 347 // in handleMousePressEvent 348 349 if ([event type] != NSLeftMouseDown || [event clickCount] != 1) { 350 return false; 351 } 352 353 bool DHTMLFlag, UAFlag; 354 allowDHTMLDrag(DHTMLFlag, UAFlag); 355 if (!DHTMLFlag && !UAFlag) { 356 return false; 357 } 358 359 NSPoint loc = [event locationInWindow]; 360 HitTestRequest request(true, false); 361 IntPoint mouseDownPos = m_frame->view()->windowToContents(IntPoint(loc)); 362 HitTestResult result(mouseDownPos); 363 m_frame->renderer()->layer()->hitTest(request, result); 364 bool srcIsDHTML; 365 return result.innerNode() && result.innerNode()->renderer()->draggableNode(DHTMLFlag, UAFlag, mouseDownPos.x(), mouseDownPos.y(), srcIsDHTML); 366 } 367 368 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLocation) const 369 { 370 IntPoint dragViewportLocation((int)floatDragViewportLocation.x(), (int)floatDragViewportLocation.y()); 371 IntPoint dragLocation = m_frame->view()->windowToContents(dragViewportLocation); 372 IntSize delta = dragLocation - m_mouseDownPos; 373 374 float threshold = GeneralDragHysteresis; 375 if (dragState().m_dragSrcIsImage) 376 threshold = ImageDragHysteresis; 377 else if (dragState().m_dragSrcIsLink) 378 threshold = LinkDragHysteresis; 379 else if (dragState().m_dragSrcInSelection) 380 threshold = TextDragHysteresis; 381 382 return fabsf(delta.width()) >= threshold || fabsf(delta.height()) >= threshold; 383 } 384 321 bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const 322 { 323 return m_activationEventNumber == event.eventNumber(); 324 } 325 385 326 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) 386 327 { 387 328 BEGIN_BLOCK_OBJC_EXCEPTIONS; 388 389 if ([currentEvent type] == NSLeftMouseDragged) { 329 if (event.event().button() == LeftButton && event.event().eventType() == MouseEventMoved) { 390 330 NSView *view = mouseDownViewIfStillGood(); 391 331 … … 436 376 // For drags starting in the selection, the user must wait between the mousedown and mousedrag, 437 377 // or else we bail on the dragging stuff and allow selection to occur 438 if (m_mouseDownMayStartDrag && dragState().m_dragSrcInSelection && [currentEvent timestamp]- m_mouseDownTimestamp < TextDragDelay) {378 if (m_mouseDownMayStartDrag && dragState().m_dragSrcInSelection && event.event().timestamp() - m_mouseDownTimestamp < TextDragDelay) { 439 379 m_mouseDownMayStartDrag = false; 440 380 // ...but if this was the first click in the window, we don't even want to start selection 441 if ( m_activationEventNumber == [currentEvent eventNumber])381 if (eventActivatedView(event.event())) 442 382 m_mouseDownMayStartSelect = false; 443 383 } … … 447 387 m_frame->view()->setCursor(pointerCursor()); 448 388 449 if (dragHysteresisExceeded( [currentEvent locationInWindow])) {389 if (dragHysteresisExceeded(event.event().pos())) { 450 390 451 391 // Once we're past the hysteresis point, we don't want to treat this gesture as a click … … 490 430 491 431 if (dragState().m_dragSrcMayBeDHTML) 492 dragImage = dragState().m_dragClipboard->dragNSImage(dragLoc);432 dragImage = static_cast<ClipboardMac*>(dragState().m_dragClipboard.get())->dragNSImage(dragLoc); 493 433 494 434 // Yuck, dragSourceMovedTo() can be called as a result of kicking off the drag with … … 555 495 // in a window, we just don't acceptFirstMouse, and the whole down-drag-up sequence gets 556 496 // ignored upstream of this layer. 557 if ( m_activationEventNumber == [currentEvent eventNumber])497 if (eventActivatedView(event.event())) 558 498 return true; 559 499 … … 657 597 currentEvent = HardRetain(event); 658 598 m_mouseDown = PlatformMouseEvent(event); 659 NSPoint loc = [event locationInWindow];660 m_mouseDownPos = m_frame->view()->windowToContents(IntPoint(loc));661 m_mouseDownTimestamp = [event timestamp];662 663 m_mouseDownMayStartDrag = false;664 m_mouseDownMayStartSelect = false;665 m_mouseDownMayStartAutoscroll = false;666 599 667 600 handleMousePressEvent(event); … … 808 741 } 809 742 810 // Called as we walk up the element chain for nodes with CSS property -webkit-user-drag == auto811 bool EventHandler::shouldDragAutoNode(Node* node, const IntPoint& point) const812 {813 // We assume that WebKit only cares about dragging things that can be leaf nodes (text, images, urls).814 // This saves a bunch of expensive calls (creating WC and WK element dicts) as we walk farther up815 // the node hierarchy, and we also don't have to cook up a way to ask WK about non-leaf nodes816 // (since right now WK just hit-tests using a cached lastMouseDown).817 if (node->hasChildNodes() || !m_frame->view())818 return false;819 return [Mac(m_frame)->bridge() mayStartDragAtEventLocation:m_frame->view()->contentsToWindow(point)];820 }821 822 743 KeyboardUIMode EventHandler::keyboardUIMode() const 823 744 { -
trunk/WebCore/page/mac/WebCoreFrameBridge.h
r19237 r19327 302 302 303 303 - (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event sourceIsDHTML:(BOOL)flag DHTMLWroteData:(BOOL)dhtmlWroteData; 304 - (BOOL)mayStartDragAtEventLocation:(NSPoint)location;305 304 306 305 - (void)textFieldDidBeginEditing:(DOMHTMLInputElement *)element; -
trunk/WebCore/page/mac/WebCoreFrameBridge.mm
r19237 r19327 72 72 #import "Screen.h" 73 73 #import "SelectionController.h" 74 #import "SystemTime.h" 74 75 #import "TextEncoding.h" 75 76 #import "TextIterator.h" … … 1325 1326 // FIXME: Fake modifier keys here. 1326 1327 PlatformMouseEvent event(IntPoint(windowLoc), globalPoint(windowLoc, [self window]), 1327 LeftButton, 0, false, false, false, false);1328 LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime()); 1328 1329 m_frame->eventHandler()->dragSourceMovedTo(event); 1329 1330 } … … 1335 1336 // FIXME: Fake modifier keys here. 1336 1337 PlatformMouseEvent event(IntPoint(windowLoc), globalPoint(windowLoc, [self window]), 1337 LeftButton, 0, false, false, false, false);1338 LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime()); 1338 1339 m_frame->eventHandler()->dragSourceEndedAt(event, operation); 1339 1340 } -
trunk/WebCore/platform/PlatformMouseEvent.h
r18165 r19327 58 58 59 59 namespace WebCore { 60 60 61 61 // These button numbers match the ones used in the DOM API, 0 through 2, except for NoButton which isn't specified. 62 62 enum MouseButton { NoButton = -1, LeftButton, MiddleButton, RightButton }; 63 63 enum MouseEventType { MouseEventMoved, MouseEventPressed, MouseEventReleased, MouseEventScroll }; 64 64 65 class PlatformMouseEvent { 65 66 public: … … 67 68 68 69 PlatformMouseEvent() 69 : m_button(LeftButton) 70 : m_button(NoButton) 71 , m_eventType(MouseEventMoved) 70 72 , m_clickCount(0) 71 73 , m_shiftKey(false) … … 73 75 , m_altKey(false) 74 76 , m_metaKey(false) 77 , m_timestamp(0) 75 78 { 76 79 } … … 78 81 PlatformMouseEvent(const CurrentEventTag&); 79 82 80 PlatformMouseEvent(const IntPoint& pos, const IntPoint& globalPos, MouseButton button, 81 int clickCount, bool shift, bool ctrl, bool alt, bool meta )83 PlatformMouseEvent(const IntPoint& pos, const IntPoint& globalPos, MouseButton button, MouseEventType eventType, 84 int clickCount, bool shift, bool ctrl, bool alt, bool meta, double timestamp) 82 85 : m_position(pos), m_globalPosition(globalPos), m_button(button) 86 , m_eventType(eventType) 83 87 , m_clickCount(clickCount) 84 88 , m_shiftKey(shift) … … 86 90 , m_altKey(alt) 87 91 , m_metaKey(meta) 92 , m_timestamp(timestamp) 88 93 { 89 94 } … … 95 100 int globalY() const { return m_globalPosition.y(); } 96 101 MouseButton button() const { return m_button; } 102 MouseEventType eventType() const { return m_eventType; } 97 103 int clickCount() const { return m_clickCount; } 98 104 bool shiftKey() const { return m_shiftKey; } … … 100 106 bool altKey() const { return m_altKey; } 101 107 bool metaKey() const { return m_metaKey; } 108 109 //time in seconds 110 double timestamp() const { return m_timestamp; } 102 111 103 112 #if PLATFORM(MAC) 104 113 PlatformMouseEvent(NSEvent*); 114 int eventNumber() const { return m_eventNumber; } 105 115 #endif 106 116 #if PLATFORM(WIN) 107 117 PlatformMouseEvent(HWND, UINT, WPARAM, LPARAM, bool activatedWebView = false); 108 118 void setClickCount(int count) { m_clickCount = count; } 109 double timestamp() const { return m_timestamp; }110 119 bool activatedWebView() const { return m_activatedWebView; } 111 120 #endif … … 121 130 IntPoint m_globalPosition; 122 131 MouseButton m_button; 132 MouseEventType m_eventType; 123 133 int m_clickCount; 124 134 bool m_shiftKey; … … 126 136 bool m_altKey; 127 137 bool m_metaKey; 128 138 double m_timestamp; // unit: seconds 139 #if PLATFORM(MAC) 140 int m_eventNumber; 141 #endif 129 142 #if PLATFORM(WIN) 130 double m_timestamp; // unit: seconds131 143 bool m_activatedWebView; 132 144 #endif -
trunk/WebCore/platform/mac/ClipboardMac.h
r19039 r19327 71 71 // Methods for getting info in Cocoa's type system 72 72 NSImage *dragNSImage(NSPoint&); // loc converted from dragLoc, based on whole image size 73 74 void setDragHasStarted() { m_dragStarted = true; }75 73 76 74 private: … … 83 81 RefPtr<Node> m_dragImageElement; 84 82 int m_changeCount; 85 bool m_dragStarted;86 83 FrameMac* m_frame; // used on the source side to generate dragging images 87 84 }; -
trunk/WebCore/platform/mac/ClipboardMac.mm
r19039 r19327 42 42 , m_forDragging(forDragging) 43 43 , m_dragImage(0) 44 , m_dragStarted(false)45 44 , m_frame(frame) 46 45 { … … 298 297 m_dragImageElement = node; 299 298 300 if ( m_dragStarted&& m_changeCount == [m_pasteboard.get() changeCount]) {299 if (dragStarted() && m_changeCount == [m_pasteboard.get() changeCount]) { 301 300 NSPoint cocoaLoc; 302 301 NSImage* cocoaImage = dragNSImage(cocoaLoc); -
trunk/WebCore/platform/mac/PlatformMouseEventMac.mm
r17663 r19327 39 39 case NSLeftMouseUp: 40 40 case NSLeftMouseDragged: 41 default:42 41 return LeftButton; 43 42 case NSRightMouseDown: … … 49 48 case NSOtherMouseDragged: 50 49 return MiddleButton; 50 default: 51 return NoButton; 51 52 } 52 53 } … … 117 118 } 118 119 } 120 121 static MouseEventType mouseEventForNSEvent(NSEvent* event) 122 { 123 switch ([event type]) { 124 case NSScrollWheel: 125 return MouseEventScroll; 126 case NSLeftMouseDragged: 127 case NSRightMouseDragged: 128 case NSOtherMouseDragged: 129 case NSMouseMoved: 130 return MouseEventMoved; 131 case NSLeftMouseDown: 132 case NSRightMouseDown: 133 case NSOtherMouseDown: 134 return MouseEventPressed; 135 case NSLeftMouseUp: 136 case NSRightMouseUp: 137 case NSOtherMouseUp: 138 return MouseEventReleased; 139 default: 140 return MouseEventMoved; 141 } 142 } 119 143 120 144 PlatformMouseEvent::PlatformMouseEvent(NSEvent* event) … … 122 146 , m_globalPosition(globalPointForEvent(event)) 123 147 , m_button(mouseButtonForEvent(event)) 148 , m_eventType(mouseEventForNSEvent(event)) 124 149 , m_clickCount(clickCountForEvent(event)) 125 150 , m_shiftKey([event modifierFlags] & NSShiftKeyMask) … … 127 152 , m_altKey([event modifierFlags] & NSAlternateKeyMask) 128 153 , m_metaKey([event modifierFlags] & NSCommandKeyMask) 154 , m_timestamp([event timestamp]) 155 , m_eventNumber([event eventNumber]) 129 156 { 130 157 } 131 158 132 159 PlatformMouseEvent::PlatformMouseEvent(const CurrentEventTag&) 133 160 : m_button(LeftButton), m_clickCount(0), m_shiftKey(false), m_ctrlKey(false), m_altKey(false), m_metaKey(false) … … 138 165 m_globalPosition = globalPointForEvent(event); 139 166 m_button = mouseButtonForEvent(event); 167 m_eventType = mouseEventForNSEvent(event); 140 168 m_clickCount = clickCountForEvent(event); 141 169 m_shiftKey = [event modifierFlags] & NSShiftKeyMask; … … 143 171 m_altKey = [event modifierFlags] & NSAlternateKeyMask; 144 172 m_metaKey = [event modifierFlags] & NSCommandKeyMask; 173 m_timestamp = [event timestamp]; 174 m_eventNumber = [event eventNumber]; 145 175 } 146 176 } -
trunk/WebKit/ChangeLog
r19322 r19327 1 2007-01-31 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Adam. 4 5 Migrating methods to WebCore 6 7 * WebCoreSupport/WebFrameBridge.mm: 8 * WebView/WebHTMLView.mm: 9 * WebView/WebHTMLViewPrivate.h: 10 1 11 2007-01-31 Anders Carlsson <acarlsson@apple.com> 2 12 -
trunk/WebKit/WebCoreSupport/WebFrameBridge.mm
r19230 r19327 738 738 } 739 739 740 - (BOOL)mayStartDragAtEventLocation:(NSPoint)location741 {742 WebHTMLView *docView = (WebHTMLView *)[[_frame frameView] documentView];743 ASSERT([docView isKindOfClass:[WebHTMLView class]]);744 return [docView _mayStartDragAtEventLocation:location];745 }746 747 740 static id <WebFormDelegate> formDelegate(WebFrameBridge *self) 748 741 { -
trunk/WebKit/WebView/WebHTMLView.mm
r19295 r19327 1498 1498 } 1499 1499 1500 - (BOOL)_mayStartDragAtEventLocation:(NSPoint)location1501 {1502 WebHTMLView *topHTMLView = [self _topHTMLView];1503 if (self != topHTMLView)1504 return [topHTMLView _mayStartDragAtEventLocation:location];1505 1506 NSPoint mouseDownPoint = [self convertPoint:location fromView:nil];1507 NSDictionary *mouseDownElement = [self elementAtPoint:mouseDownPoint allowShadowContent:YES];1508 1509 ASSERT([self _webView]);1510 1511 Page* page = core([self _webView]);1512 if (!page)1513 return NO;1514 1515 DragController* dragController = page->dragController();1516 if (!dragController)1517 return NO;1518 1519 if ([mouseDownElement objectForKey:WebElementImageKey]1520 && [mouseDownElement objectForKey:WebElementImageURLKey]1521 && [[[self _webView] preferences] loadsImagesAutomatically]1522 && (dragController->dragSourceAction() & WebDragSourceActionImage))1523 return YES;1524 1525 if ([mouseDownElement objectForKey:WebElementLinkURLKey]1526 && (dragController->dragSourceAction() & WebDragSourceActionLink)1527 && [[mouseDownElement objectForKey:WebElementLinkIsLiveKey] boolValue])1528 return YES;1529 1530 if ([[mouseDownElement objectForKey:WebElementIsSelectedKey] boolValue]1531 && (dragController->dragSourceAction() & WebDragSourceActionSelection))1532 return YES;1533 1534 return NO;1535 }1536 1537 1500 - (WebPluginController *)_pluginController 1538 1501 { -
trunk/WebKit/WebView/WebHTMLViewPrivate.h
r18592 r19327 71 71 - (NSImage *)_dragImageForLinkElement:(NSDictionary *)element; 72 72 - (BOOL)_startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event sourceIsDHTML:(BOOL)flag DHTMLWroteData:(BOOL)dhtmlWroteData; 73 - (void)_handleAutoscrollForMouseDragged:(NSEvent *)event; 74 - (BOOL)_mayStartDragAtEventLocation:(NSPoint)location; 75 73 - (void)_handleAutoscrollForMouseDragged:(NSEvent *)event; 76 74 - (WebPluginController *)_pluginController; 77 75
Note:
See TracChangeset
for help on using the changeset viewer.