Commit a485c2f2 authored by oliver's avatar oliver

liver Hunt  <oliver@apple.com>

        Reviewed by Adam.
WebCore:
        Migrate more drag and drop logic to WebCore, start preparing
        to move EventHandler::handleDrag from EventHandlerMac to EventHandler 

        * WebCore.exp:   
          updating methods
                    
        * dom/Clipboard.cpp:
        * dom/Clipboard.h:
        (WebCore::Clipboard::Clipboard):
        (WebCore::Clipboard::setDragHasStarted):
        (WebCore::Clipboard::dragStarted): 
          Moving from ClipboardMac to Clipboard 

        * dom/EventTargetNode.cpp:
        (WebCore::EventTargetNode::dispatchMouseEvent):
          PlatformMouseEvent no longer lies about button state, however 
          DOM Events don't allow NoButton, so we need to convert NoButton 
          to LeftButton when we create a DOM Event from PlatformMouseEvent

        * page/DragClient.h:
          Tidying comment 

        * page/DragController.cpp:
        (WebCore::createMouseEvent):
          Updated for new PlatformMouseEvent constructors
        (WebCore::DragController::mayStartDragAtEventLocation):
          Migrated from WebKit

        * page/DragController.h:
          Added above function declarations

        * page/EventHandler.cpp:
        (WebCore::EventHandler::dragState): 
        (WebCore::EventHandler::dragHysteresisExceeded):
        (WebCore::EventHandler::freeClipboard):
        (WebCore::EventHandler::shouldDragAutoNode):
          Moved from EventHandlerMac
        (WebCore::EventHandler::handleMouseMoveEvent):
        (WebCore::EventHandler::eventMayStartDrag):
        (WebCore::EventHandler::handleMousePressEvent):
          Use DragController     

        * page/EventHandler.h:
          Added DragState struct definition to EventHandler

        * page/mac/EventHandlerMac.mm:
        (WebCore::EventHandler::eventActivatedView):
        (WebCore::EventHandler::handleDrag):
        (WebCore::EventHandler::handleMouseUp):
        (WebCore::EventHandler::mouseDown):
          Update to use DragController and PlatformMouseEvent

        * page/mac/WebCoreFrameBridge.h:
        * page/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge dragSourceMovedTo:]):
        (-[WebCoreFrameBridge dragSourceEndedAt:operation:]):
          Use DragController for state               

WebKit:
        Migrating methods to WebCore

        * WebCoreSupport/WebFrameBridge.mm:
        * WebView/WebHTMLView.mm:
        * WebView/WebHTMLViewPrivate.h:
                                         


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a820830e
2007-01-31 Oliver Hunt <oliver@apple.com>
Reviewed by Adam.
Migrate more drag and drop logic to WebCore, start preparing
to move EventHandler::handleDrag from EventHandlerMac to EventHandler
* WebCore.exp:
updating methods
* dom/Clipboard.cpp:
* dom/Clipboard.h:
(WebCore::Clipboard::Clipboard):
(WebCore::Clipboard::setDragHasStarted):
(WebCore::Clipboard::dragStarted):
Moving from ClipboardMac to Clipboard
* dom/EventTargetNode.cpp:
(WebCore::EventTargetNode::dispatchMouseEvent):
PlatformMouseEvent no longer lies about button state, however
DOM Events don't allow NoButton, so we need to convert NoButton
to LeftButton when we create a DOM Event from PlatformMouseEvent
* page/DragClient.h:
Tidying comment
* page/DragController.cpp:
(WebCore::createMouseEvent):
Updated for new PlatformMouseEvent constructors
(WebCore::DragController::mayStartDragAtEventLocation):
Migrated from WebKit
* page/DragController.h:
Added above function declarations
* page/EventHandler.cpp:
(WebCore::EventHandler::dragState):
(WebCore::EventHandler::dragHysteresisExceeded):
(WebCore::EventHandler::freeClipboard):
(WebCore::EventHandler::shouldDragAutoNode):
Moved from EventHandlerMac
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::eventMayStartDrag):
(WebCore::EventHandler::handleMousePressEvent):
Use DragController
* page/EventHandler.h:
Added DragState struct definition to EventHandler
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::eventActivatedView):
(WebCore::EventHandler::handleDrag):
(WebCore::EventHandler::handleMouseUp):
(WebCore::EventHandler::mouseDown):
Update to use DragController and PlatformMouseEvent
* page/mac/WebCoreFrameBridge.h:
* page/mac/WebCoreFrameBridge.mm:
(-[WebCoreFrameBridge dragSourceMovedTo:]):
(-[WebCoreFrameBridge dragSourceEndedAt:operation:]):
Use DragController for state
* platform/PlatformMouseEvent.h:
(WebCore::):
(WebCore::PlatformMouseEvent::PlatformMouseEvent):
(WebCore::PlatformMouseEvent::eventType):
(WebCore::PlatformMouseEvent::timestamp):
(WebCore::PlatformMouseEvent::eventNumber):
(WebCore::PlatformMouseEvent::setClickCount):
Exposing necessary data for Drag logic
* platform/mac/ClipboardMac.h:
* platform/mac/ClipboardMac.mm:
(WebCore::ClipboardMac::ClipboardMac):
(WebCore::ClipboardMac::setDragImage):
Have moved a number of fields from ClipboardMac to Clipboard
so need to use accessors in a few places now
* platform/mac/PlatformMouseEventMac.mm:
(WebCore::mouseButtonForEvent):
(WebCore::mouseEventForNSEvent):
(WebCore::PlatformMouseEvent::PlatformMouseEvent):
Determine MouseEventType, and provide event time info
2007-01-31 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
......
......@@ -473,7 +473,7 @@ __ZNK7WebCore11HistoryItem8childrenEv
__ZNK7WebCore11HistoryItem9urlStringEv
__ZNK7WebCore11HistoryItem9viewStateEv
__ZNK7WebCore12AtomicString16deprecatedStringEv
__ZNK7WebCore12EventHandler17eventMayStartDragEP7NSEvent
__ZNK7WebCore12EventHandler17eventMayStartDragERKNS_18PlatformMouseEventE
__ZNK7WebCore12EventHandler20currentKeyboardEventEv
__ZNK7WebCore12RenderObject25backslashAsCurrencySymbolEv
__ZNK7WebCore13HitTestResult10isLiveLinkEv
......
......@@ -28,7 +28,6 @@
namespace WebCore {
void Clipboard::setAccessPolicy(ClipboardAccessPolicy policy)
{
// once you go numb, can never go back
......
......@@ -41,7 +41,7 @@ namespace WebCore {
// State available during IE's events for drag and drop and copy/paste
class Clipboard : public Shared<Clipboard> {
public:
Clipboard(ClipboardAccessPolicy policy) : m_policy(policy) { }
Clipboard(ClipboardAccessPolicy policy) : m_policy(policy), m_dragStarted(false) { }
virtual ~Clipboard() { }
// Is this operation a drag-drop or a copy-paste?
......@@ -73,13 +73,15 @@ namespace WebCore {
void setSourceOperation(DragOperation);
void setDestinationOperation(DragOperation);
void setDragHasStarted() { m_dragStarted = true; }
protected:
ClipboardAccessPolicy policy() const { return m_policy; }
bool dragStarted() const { return m_dragStarted; }
private:
ClipboardAccessPolicy m_policy;
String m_dropEffect;
String m_effectAllowed;
bool m_dragStarted;
};
} // namespace WebCore
......
......@@ -375,8 +375,12 @@ bool EventTargetNode::dispatchMouseEvent(const PlatformMouseEvent& event, const
IntPoint contentsPos;
if (FrameView* view = document()->view())
contentsPos = view->windowToContents(event.pos());
short button = event.button();
ASSERT(event.eventType() == MouseEventMoved || button != NoButton);
return dispatchMouseEvent(eventType, event.button(), detail,
return dispatchMouseEvent(eventType, button == NoButton ? 0 : button , detail,
contentsPos.x(), contentsPos.y(), event.globalX(), event.globalY(),
event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(),
false, relatedTarget);
......
......@@ -40,9 +40,9 @@ namespace WebCore {
virtual DragDestinationAction actionMaskForDrag(DragData*) = 0;
virtual void dragControllerDestroyed() = 0;
//The UI delegate takes the point in view coordinates, however it is easier to pass
//window coordinates here
//We work in window rather than view coordinates here
virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& windowPoint) = 0;
virtual ~DragClient() {};
};
......
......@@ -49,6 +49,8 @@
#include "ReplaceSelectionCommand.h"
#include "ResourceRequest.h"
#include "SelectionController.h"
#include "Settings.h"
#include "SystemTime.h"
#include "Text.h"
#include "wtf/RefPtr.h"
......@@ -58,7 +60,7 @@ static PlatformMouseEvent createMouseEvent(DragData* dragData)
{
// FIXME: We should fake modifier keys here.
return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPosition(),
LeftButton, 0, false, false, false, false);
LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime());
}
......@@ -417,4 +419,34 @@ DragOperation DragController::tryDHTMLDrag(DragData* dragData)
return op;
}
bool DragController::mayStartDragAtEventLocation(const Frame* frame, const IntPoint& framePos)
{
ASSERT(frame);
if (!frame->view() || !frame->renderer())
return false;
HitTestResult mouseDownTarget = HitTestResult(framePos);
mouseDownTarget = frame->eventHandler()->hitTestResultAtPoint(framePos, true);
if (mouseDownTarget.image()
&& !mouseDownTarget.absoluteImageURL().isEmpty()
&& frame->settings()->loadsImagesAutomatically()
&& m_dragSourceAction & DragSourceActionImage)
return true;
if (!mouseDownTarget.absoluteLinkURL().isEmpty()
&& m_dragSourceAction & DragSourceActionLink
&& mouseDownTarget.isLiveLink())
return true;
if (mouseDownTarget.isSelected()
&& m_dragSourceAction & DragSourceActionSelection)
return true;
return false;
}
}
......@@ -36,8 +36,9 @@ namespace WebCore {
class Document;
class DragClient;
class DragData;
class SelectionController;
class Frame;
class Page;
class SelectionController;
class DragController {
public:
......@@ -70,6 +71,7 @@ namespace WebCore {
DragDestinationAction dragDestinationAction() const { return m_dragDestinationAction; }
DragSourceAction delegateDragSourceAction(const IntPoint& pagePoint);
bool mayStartDragAtEventLocation(const Frame*, const IntPoint& framePos);
void dragEnded() { m_dragInitiator = 0; m_didInitiateDrag = false; }
private:
......
......@@ -69,10 +69,10 @@ using namespace HTMLNames;
// The link drag hysteresis is much larger than the others because there
// needs to be enough space to cancel the link press without starting a link drag,
// and because dragging links is rare.
const float LinkDragHysteresis = 40.0;
const float ImageDragHysteresis = 5.0;
const float TextDragHysteresis = 3.0;
const float GeneralDragHysteresis = 3.0;
const int LinkDragHysteresis = 40;
const int ImageDragHysteresis = 5;
const int TextDragHysteresis = 3;
const int GeneralDragHysteresis = 3;
const double TextDragDelay = 0.15;
#ifdef SVG_SUPPORT
......@@ -109,7 +109,13 @@ EventHandler::EventHandler(Frame* frame)
EventHandler::~EventHandler()
{
}
EventHandler::EventHandlerDragState& EventHandler::dragState()
{
static EventHandlerDragState state;
return state;
}
void EventHandler::clear()
{
m_hoverTimer.stop();
......@@ -301,7 +307,7 @@ bool EventHandler::handleMouseMoveEvent(const MouseEventWithHitTestResults& even
Node* innerNode = event.targetNode();
if (event.event().button() != 0 || !innerNode || !innerNode->renderer())
if (event.event().button() != LeftButton || !innerNode || !innerNode->renderer())
return false;
#if PLATFORM(MAC) // FIXME: Why does this assertion fire on other platforms?
......@@ -339,6 +345,29 @@ bool EventHandler::handleMouseMoveEvent(const MouseEventWithHitTestResults& even
return true;
}
bool EventHandler::eventMayStartDrag(const PlatformMouseEvent& event) const
{
// This is a pre-flight check of whether the event might lead to a drag being started. Be careful
// that its logic needs to stay in sync with handleMouseMoveEvent() and the way we setMouseDownMayStartDrag
// in handleMousePressEvent
if (!m_frame->renderer() || !m_frame->renderer()->layer()
|| event.button() != LeftButton || event.clickCount() != 1)
return false;
bool DHTMLFlag;
bool UAFlag;
allowDHTMLDrag(DHTMLFlag, UAFlag);
if (!DHTMLFlag && !UAFlag)
return false;
HitTestRequest request(true, false);
HitTestResult result(event.pos());
m_frame->renderer()->layer()->hitTest(request, result);
bool srcIsDHTML;
return result.innerNode() && result.innerNode()->renderer()->draggableNode(DHTMLFlag, UAFlag, event.x(), event.y(), srcIsDHTML);
}
void EventHandler::updateSelectionForMouseDragOverPosition(const VisiblePosition& pos)
{
......@@ -713,6 +742,11 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
m_mousePressed = true;
m_currentMousePosition = mouseEvent.pos();
m_mouseDownTimestamp = mouseEvent.timestamp();
m_mouseDownMayStartDrag = false;
m_mouseDownMayStartSelect = false;
m_mouseDownMayStartAutoscroll = false;
m_mouseDownPos = m_frame->view()->windowToContents(mouseEvent.pos());
m_mouseDownWasInSubframe = false;
MouseEventWithHitTestResults mev = prepareMouseEvent(HitTestRequest(false, true), mouseEvent);
......@@ -1244,5 +1278,41 @@ void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event)
m_frame->editor()->handleKeyPress(event);
}
}
bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLocation) const
{
IntPoint dragViewportLocation((int)floatDragViewportLocation.x(), (int)floatDragViewportLocation.y());
return dragHysteresisExceeded(dragViewportLocation);
}
bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation) const
{
IntPoint dragLocation = m_frame->view()->windowToContents(dragViewportLocation);
IntSize delta = dragLocation - m_mouseDownPos;
int threshold = GeneralDragHysteresis;
if (dragState().m_dragSrcIsImage)
threshold = ImageDragHysteresis;
else if (dragState().m_dragSrcIsLink)
threshold = LinkDragHysteresis;
else if (dragState().m_dragSrcInSelection)
threshold = TextDragHysteresis;
return abs(delta.width()) >= threshold || abs(delta.height()) >= threshold;
}
void EventHandler::freeClipboard()
{
if (dragState().m_dragClipboard)
dragState().m_dragClipboard->setAccessPolicy(ClipboardNumb);
}
bool EventHandler::shouldDragAutoNode(Node* node, const IntPoint& point) const
{
ASSERT(node);
if (node->hasChildNodes() || !m_frame->view())
return false;
return m_frame->page() && m_frame->page()->dragController()->mayStartDragAtEventLocation(m_frame, point);
}
}
......@@ -67,13 +67,24 @@ class Widget;
struct HitTestRequest;
extern const float LinkDragHysteresis;
extern const float ImageDragHysteresis;
extern const float TextDragHysteresis;
extern const float GeneralDragHysteresis;
extern const int LinkDragHysteresis;
extern const int ImageDragHysteresis;
extern const int TextDragHysteresis;
extern const int GeneralDragHysteresis;
extern const double TextDragDelay;
class EventHandler : Noncopyable {
struct EventHandlerDragState {
RefPtr<Node> m_dragSrc; // element that may be a drag source, for the current mouse gesture
bool m_dragSrcIsLink;
bool m_dragSrcIsImage;
bool m_dragSrcInSelection;
bool m_dragSrcMayBeDHTML;
bool m_dragSrcMayBeUA; // Are DHTML and/or the UserAgent allowed to drag out?
bool m_dragSrcIsDHTML;
RefPtr<Clipboard> m_dragClipboard; // used on only the source side of dragging
};
static EventHandlerDragState& dragState();
public:
EventHandler(Frame*);
~EventHandler();
......@@ -129,6 +140,8 @@ public:
bool keyEvent(const PlatformKeyboardEvent&);
void defaultKeyboardEventHandler(KeyboardEvent*);
bool eventMayStartDrag(const PlatformMouseEvent&) const;
#if PLATFORM(MAC)
PassRefPtr<KeyboardEvent> currentKeyboardEvent() const;
......@@ -140,7 +153,6 @@ public:
bool keyEvent(NSEvent*);
bool wheelEvent(NSEvent*);
bool eventMayStartDrag(NSEvent*) const;
void sendFakeEventsAfterWidgetTracking(NSEvent* initiatingEvent);
......@@ -153,6 +165,7 @@ public:
#endif
private:
bool eventActivatedView(const PlatformMouseEvent&) const;
void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults& event);
bool handleMouseDoubleClickEvent(const PlatformMouseEvent&);
......
......@@ -55,22 +55,6 @@ namespace WebCore {
using namespace EventNames;
struct EventHandlerDragState {
RefPtr<Node> m_dragSrc; // element that may be a drag source, for the current mouse gesture
bool m_dragSrcIsLink;
bool m_dragSrcIsImage;
bool m_dragSrcInSelection;
bool m_dragSrcMayBeDHTML;
bool m_dragSrcMayBeUA; // Are DHTML and/or the UserAgent allowed to drag out?
bool m_dragSrcIsDHTML;
RefPtr<ClipboardMac> m_dragClipboard; // used on only the source side of dragging
};
static EventHandlerDragState& dragState()
{
static EventHandlerDragState state;
return state;
}
static NSEvent *currentEvent;
......@@ -143,12 +127,6 @@ bool EventHandler::tabsToAllControls(KeyboardEvent* event) const
return handlingOptionTab;
}
void EventHandler::freeClipboard()
{
if (dragState().m_dragClipboard)
dragState().m_dragClipboard->setAccessPolicy(ClipboardNumb);
}
bool EventHandler::keyEvent(NSEvent *event)
{
bool result;
......@@ -340,53 +318,15 @@ NSView *EventHandler::mouseDownViewIfStillGood()
return mouseDownView;
}
bool EventHandler::eventMayStartDrag(NSEvent *event) const
bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const
{
// This is a pre-flight check of whether the event might lead to a drag being started. Be careful
// that its logic needs to stay in sync with handleMouseMoveEvent() and the way we setMouseDownMayStartDrag
// in handleMousePressEvent
if ([event type] != NSLeftMouseDown || [event clickCount] != 1) {
return false;
}
bool DHTMLFlag, UAFlag;
allowDHTMLDrag(DHTMLFlag, UAFlag);
if (!DHTMLFlag && !UAFlag) {
return false;
}
NSPoint loc = [event locationInWindow];
HitTestRequest request(true, false);
IntPoint mouseDownPos = m_frame->view()->windowToContents(IntPoint(loc));
HitTestResult result(mouseDownPos);
m_frame->renderer()->layer()->hitTest(request, result);
bool srcIsDHTML;
return result.innerNode() && result.innerNode()->renderer()->draggableNode(DHTMLFlag, UAFlag, mouseDownPos.x(), mouseDownPos.y(), srcIsDHTML);
return m_activationEventNumber == event.eventNumber();
}
bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLocation) const
{
IntPoint dragViewportLocation((int)floatDragViewportLocation.x(), (int)floatDragViewportLocation.y());
IntPoint dragLocation = m_frame->view()->windowToContents(dragViewportLocation);
IntSize delta = dragLocation - m_mouseDownPos;
float threshold = GeneralDragHysteresis;
if (dragState().m_dragSrcIsImage)
threshold = ImageDragHysteresis;
else if (dragState().m_dragSrcIsLink)
threshold = LinkDragHysteresis;
else if (dragState().m_dragSrcInSelection)
threshold = TextDragHysteresis;
return fabsf(delta.width()) >= threshold || fabsf(delta.height()) >= threshold;
}
bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
if ([currentEvent type] == NSLeftMouseDragged) {
if (event.event().button() == LeftButton && event.event().eventType() == MouseEventMoved) {
NSView *view = mouseDownViewIfStillGood();
if (view) {
......@@ -435,10 +375,10 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)
// For drags starting in the selection, the user must wait between the mousedown and mousedrag,
// or else we bail on the dragging stuff and allow selection to occur
if (m_mouseDownMayStartDrag && dragState().m_dragSrcInSelection && [currentEvent timestamp] - m_mouseDownTimestamp < TextDragDelay) {
if (m_mouseDownMayStartDrag && dragState().m_dragSrcInSelection && event.event().timestamp() - m_mouseDownTimestamp < TextDragDelay) {
m_mouseDownMayStartDrag = false;
// ...but if this was the first click in the window, we don't even want to start selection
if (m_activationEventNumber == [currentEvent eventNumber])
if (eventActivatedView(event.event()))
m_mouseDownMayStartSelect = false;
}
......@@ -446,7 +386,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)
// We are starting a text/image/url drag, so the cursor should be an arrow
m_frame->view()->setCursor(pointerCursor());
if (dragHysteresisExceeded([currentEvent locationInWindow])) {
if (dragHysteresisExceeded(event.event().pos())) {
// Once we're past the hysteresis point, we don't want to treat this gesture as a click
invalidateClick();
......@@ -489,7 +429,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)
wcWrotePasteboard = types && [types count] > 0;
if (dragState().m_dragSrcMayBeDHTML)
dragImage = dragState().m_dragClipboard->dragNSImage(dragLoc);
dragImage = static_cast<ClipboardMac*>(dragState().m_dragClipboard.get())->dragNSImage(dragLoc);
// Yuck, dragSourceMovedTo() can be called as a result of kicking off the drag with
// dragImage! Because of that dumb reentrancy, we may think we've not started the
......@@ -554,7 +494,7 @@ bool EventHandler::handleMouseUp(const MouseEventWithHitTestResults& event)
// the mouse down and drag events to see if we might start a drag. For other first clicks
// in a window, we just don't acceptFirstMouse, and the whole down-drag-up sequence gets
// ignored upstream of this layer.
if (m_activationEventNumber == [currentEvent eventNumber])
if (eventActivatedView(event.event()))
return true;
return false;
......@@ -656,13 +596,6 @@ void EventHandler::mouseDown(NSEvent *event)
NSEvent *oldCurrentEvent = currentEvent;
currentEvent = HardRetain(event);
m_mouseDown = PlatformMouseEvent(event);
NSPoint loc = [event locationInWindow];
m_mouseDownPos = m_frame->view()->windowToContents(IntPoint(loc));
m_mouseDownTimestamp = [event timestamp];
m_mouseDownMayStartDrag = false;
m_mouseDownMayStartSelect = false;
m_mouseDownMayStartAutoscroll = false;
handleMousePressEvent(event);
......@@ -807,18 +740,6 @@ void EventHandler::mouseMoved(NSEvent *event)
END_BLOCK_OBJC_EXCEPTIONS;
}
// Called as we walk up the element chain for nodes with CSS property -webkit-user-drag == auto
bool EventHandler::shouldDragAutoNode(Node* node, const IntPoint& point) const
{
// We assume that WebKit only cares about dragging things that can be leaf nodes (text, images, urls).
// This saves a bunch of expensive calls (creating WC and WK element dicts) as we walk farther up
// the node hierarchy, and we also don't have to cook up a way to ask WK about non-leaf nodes
// (since right now WK just hit-tests using a cached lastMouseDown).
if (node->hasChildNodes() || !m_frame->view())
return false;
return [Mac(m_frame)->bridge() mayStartDragAtEventLocation:m_frame->view()->contentsToWindow(point)];
}
KeyboardUIMode EventHandler::keyboardUIMode() const
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
......
......@@ -301,7 +301,6 @@ typedef enum ObjectElementType {
- (NSString *)MIMETypeForPath:(NSString *)path;
- (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event sourceIsDHTML:(BOOL)flag DHTMLWroteData:(BOOL)dhtmlWroteData;
- (BOOL)mayStartDragAtEventLocation:(NSPoint)location;
- (void)textFieldDidBeginEditing:(DOMHTMLInputElement *)element;
- (void)textFieldDidEndEditing:(DOMHTMLInputElement *)element;
......
......@@ -71,6 +71,7 @@
#import "RetainPtr.h"
#import "Screen.h"
#import "SelectionController.h"
#import "SystemTime.h"
#import "TextEncoding.h"
#import "TextIterator.h"
#import "TypingCommand.h"
......@@ -1324,7 +1325,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
if (m_frame) {
// FIXME: Fake modifier keys here.
PlatformMouseEvent event(IntPoint(windowLoc), globalPoint(windowLoc, [self window]),
LeftButton, 0, false, false, false, false);
LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime());
m_frame->eventHandler()->dragSourceMovedTo(event);
}
}
......@@ -1334,7 +1335,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
if (m_frame) {
// FIXME: Fake modifier keys here.
PlatformMouseEvent event(IntPoint(windowLoc), globalPoint(windowLoc, [self window]),
LeftButton, 0, false, false, false, false);
LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime());
m_frame->eventHandler()->dragSourceEndedAt(event, operation);
}
}
......
......@@ -57,34 +57,39 @@ class QMouseEvent;
#endif
namespace WebCore {
// These button numbers match the ones used in the DOM API, 0 through 2, except for NoButton which isn't specified.
enum MouseButton { NoButton = -1, LeftButton, MiddleButton, RightButton };
enum MouseEventType { MouseEventMoved, MouseEventPressed, MouseEventReleased, MouseEventScroll };
class PlatformMouseEvent {
public:
static const struct CurrentEventTag {} currentEvent;
PlatformMouseEvent()
: m_button(LeftButton)
: m_button(NoButton)
, m_eventType(MouseEventMoved)
, m_clickCount(0)
, m_shiftKey(false)
, m_ctrlKey(false)
, m_altKey(false)
, m_metaKey(false)
, m_timestamp(0)
{
}
PlatformMouseEvent(const CurrentEventTag&);
PlatformMouseEvent(const IntPoint& pos, const IntPoint& globalPos, MouseButton button,
int clickCount, bool shift, bool ctrl, bool alt, bool meta)
PlatformMouseEvent(const IntPoint& pos, const IntPoint& globalPos, MouseButton button, MouseEventType eventType,
int clickCount, bool shift, bool ctrl, bool alt, bool meta, double timestamp)
: m_position(pos), m_globalPosition(globalPos), m_button(button)
, m_eventType(eventType)
, m_clickCount(clickCount)
, m_shiftKey(shift)
, m_ctrlKey(ctrl)
, m_altKey(alt)
, m_metaKey(meta)
, m_timestamp(timestamp)
{
}
......@@ -94,19 +99,23 @@ namespace WebCore {
int globalX() const { return m_globalPosition.x(); }
int globalY() const { return m_globalPosition.y(); }
MouseButton button() const { return m_button; }
MouseEventType eventType() const { return m_eventType; }
int clickCount() const { return m_clickCount; }
bool shiftKey() const { return m_shiftKey; }
bool ctrlKey() const { return m_ctrlKey; }
bool altKey() const { return m_altKey; }
bool metaKey() const { return m_metaKey; }
//time in seconds
double timestamp() const { return m_timestamp; }
#if PLATFORM(MAC)
PlatformMouseEvent(NSEvent*);
int eventNumber() const { return m_eventNumber; }
#endif
#if PLATFORM(WIN)
PlatformMouseEvent(HWND, UINT, WPARAM, LPARAM, bool activatedWebView = false);
void setClickCount(int count) { m_clickCount = count; }
double timestamp() const { return m_timestamp; }
bool activatedWebView() const { return m_activatedWebView; }
#endif