ClipboardManx.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * This library is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU Lesser General Public
  4. * License as published by the Free Software Foundation; either
  5. * version 2 of the License, or (at your option) any later version.
  6. *
  7. * This library is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. * Lesser General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU Lesser General Public
  13. * License along with this library; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. #include "config.h"
  17. #include "Clipboard.h"
  18. #include "CachedImage.h"
  19. #include "Document.h"
  20. #include "Editor.h"
  21. #include "Element.h"
  22. #include "Frame.h"
  23. #include "Pasteboard.h"
  24. namespace WebCore {
  25. DragImageRef Clipboard::createDragImage(IntPoint& location) const
  26. {
  27. location = m_dragLoc;
  28. if (m_dragImage)
  29. return createDragImageFromImage(m_dragImage->image());
  30. if (m_dragImageElement) {
  31. Document* document = m_dragImageElement->document();
  32. if (Frame* frame = document->frame())
  33. return frame->nodeImage(m_dragImageElement.get());
  34. }
  35. return 0; // We do not have enough information to create a drag image, use the default icon.
  36. }
  37. void Clipboard::declareAndWriteDragImage(Element* element, const KURL& url, const String& label, Frame* frame)
  38. {
  39. m_pasteboard->writeImage(element->toNode(), url, label);
  40. }
  41. }