/src/3rdparty/webkit/Source/WebCore/page/DragController.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 130 lines · 84 code · 20 blank · 26 comment · 0 complexity · c4e35f67ac0578cffc434d0a6e7d8300 MD5 · raw file

  1. /*
  2. * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  17. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef DragController_h
  26. #define DragController_h
  27. #include "DragActions.h"
  28. #include "DragImage.h"
  29. #include "IntPoint.h"
  30. #include "KURL.h"
  31. namespace WebCore {
  32. class Clipboard;
  33. class Document;
  34. class DragClient;
  35. class DragData;
  36. class Element;
  37. class Frame;
  38. class Image;
  39. class IntRect;
  40. class Node;
  41. class Page;
  42. class PlatformMouseEvent;
  43. class Range;
  44. class SelectionController;
  45. class DragController {
  46. WTF_MAKE_NONCOPYABLE(DragController); WTF_MAKE_FAST_ALLOCATED;
  47. public:
  48. DragController(Page*, DragClient*);
  49. ~DragController();
  50. DragClient* client() const { return m_client; }
  51. DragOperation dragEntered(DragData*);
  52. void dragExited(DragData*);
  53. DragOperation dragUpdated(DragData*);
  54. bool performDrag(DragData*);
  55. // FIXME: It should be possible to remove a number of these accessors once all
  56. // drag logic is in WebCore.
  57. void setDidInitiateDrag(bool initiated) { m_didInitiateDrag = initiated; }
  58. bool didInitiateDrag() const { return m_didInitiateDrag; }
  59. void setIsHandlingDrag(bool handling) { m_isHandlingDrag = handling; }
  60. bool isHandlingDrag() const { return m_isHandlingDrag; }
  61. DragOperation sourceDragOperation() const { return m_sourceDragOperation; }
  62. const KURL& draggingImageURL() const { return m_draggingImageURL; }
  63. void setDragOffset(const IntPoint& offset) { m_dragOffset = offset; }
  64. const IntPoint& dragOffset() const { return m_dragOffset; }
  65. DragSourceAction dragSourceAction() const { return m_dragSourceAction; }
  66. Document* documentUnderMouse() const { return m_documentUnderMouse.get(); }
  67. DragDestinationAction dragDestinationAction() const { return m_dragDestinationAction; }
  68. DragSourceAction delegateDragSourceAction(const IntPoint& pagePoint);
  69. bool mayStartDragAtEventLocation(const Frame*, const IntPoint& framePos, Node*);
  70. void dragEnded();
  71. void placeDragCaret(const IntPoint&);
  72. bool startDrag(Frame* src, Clipboard*, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin, bool isDHTMLDrag);
  73. static const IntSize& maxDragImageSize();
  74. static const int LinkDragBorderInset;
  75. static const int MaxOriginalImageArea;
  76. static const int DragIconRightInset;
  77. static const int DragIconBottomInset;
  78. static const float DragImageAlpha;
  79. private:
  80. bool dispatchTextInputEventFor(Frame*, DragData*);
  81. bool canProcessDrag(DragData*);
  82. bool concludeEditDrag(DragData*);
  83. DragOperation dragEnteredOrUpdated(DragData*);
  84. DragOperation operationForLoad(DragData*);
  85. bool tryDocumentDrag(DragData*, DragDestinationAction, DragOperation&);
  86. bool tryDHTMLDrag(DragData*, DragOperation&);
  87. DragOperation dragOperation(DragData*);
  88. void cancelDrag();
  89. bool dragIsMove(SelectionController*, DragData*);
  90. bool isCopyKeyDown(DragData*);
  91. void mouseMovedIntoDocument(Document*);
  92. IntRect selectionDraggingRect(Frame*);
  93. bool doDrag(Frame* src, Clipboard* clipboard, DragImageRef dragImage, const KURL& linkURL, const KURL& imageURL, Node* node, IntPoint& dragLoc, IntPoint& dragImageOffset);
  94. void doImageDrag(Element*, const IntPoint&, const IntRect&, Clipboard*, Frame*, IntPoint&);
  95. void doSystemDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool forLink);
  96. void cleanupAfterSystemDrag();
  97. Page* m_page;
  98. DragClient* m_client;
  99. RefPtr<Document> m_documentUnderMouse; // The document the mouse was last dragged over.
  100. RefPtr<Document> m_dragInitiator; // The Document (if any) that initiated the drag.
  101. DragDestinationAction m_dragDestinationAction;
  102. DragSourceAction m_dragSourceAction;
  103. bool m_didInitiateDrag;
  104. bool m_isHandlingDrag;
  105. DragOperation m_sourceDragOperation; // Set in startDrag when a drag starts from a mouse down within WebKit
  106. IntPoint m_dragOffset;
  107. KURL m_draggingImageURL;
  108. };
  109. }
  110. #endif