2 * Copyright (C) 2012 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
28 #if ENABLE(TIZEN_DRAG_SUPPORT)
31 #include "EwkViewImpl.h"
33 #include <WebCore/DragActions.h>
34 #include <WebCore/DragData.h>
35 #include <WebCore/DragSession.h>
36 #include <wtf/text/CString.h>
38 using namespace WebCore;
42 Drag::Drag(EwkViewImpl* viewImpl)
43 : m_viewImpl(viewImpl)
45 , m_dragStorageName("Drag")
50 m_Handle = new DragHandle(viewImpl->view(), EDJE_DIR"/Drag.edj", "drag_support", this);
58 WebFrameProxy* Drag::focusedOrMainFrame()
60 WebFrameProxy* frame = m_viewImpl->page()->focusedFrame();
62 frame = m_viewImpl->page()->mainFrame();
67 void Drag::setDragMode(bool isDragMode)
72 m_isDragMode = isDragMode;
75 void Drag::setDragData(WebCore::DragData* dragdata, PassRefPtr<ShareableBitmap> dragImage)
77 m_dragData = dragdata;
78 m_dragImage = dragImage;
83 IntPoint viewPoint = m_viewImpl->transformFromScene().mapPoint(m_Handle->position());
85 DragData* dragData = new DragData(m_dragData->platformData(), viewPoint,
86 viewPoint, m_dragData->draggingSourceOperationMask(), m_dragData->flags());
88 m_viewImpl->page()->dragExited(dragData ,m_dragStorageName);
90 m_viewImpl->page()->dragEnded(viewPoint, viewPoint, m_dragData->draggingSourceOperationMask());
96 m_Handle->move(m_savePoint);
100 void Drag::handleMouseDown(DragHandle* handle)
102 m_Handle->move(handle->position());
105 void Drag::handleMouseMove(DragHandle* handle)
107 IntPoint viewPoint = m_viewImpl->transformFromScene().mapPoint(handle->position());
109 DragData* dragData = new DragData(m_dragData->platformData(), viewPoint,
110 viewPoint, m_dragData->draggingSourceOperationMask(), m_dragData->flags());
112 m_viewImpl->page()->dragUpdated(dragData ,m_dragStorageName);
114 DragSession dragSession = m_viewImpl->page()->dragSession();
115 if (dragSession.operation != DragSourceActionNone)
116 handle->updateHandleIcon(true);
118 handle->updateHandleIcon(false);
120 m_Handle->move(handle->position());
124 void Drag::handleMouseUp(DragHandle* handle)
126 IntPoint viewPoint = m_viewImpl->transformFromScene().mapPoint(handle->position());
128 DragData* dragData = new DragData(m_dragData->platformData(), viewPoint,
129 viewPoint, m_dragData->draggingSourceOperationMask(), m_dragData->flags());
131 m_viewImpl->page()->dragUpdated(dragData ,m_dragStorageName);
133 DragSession dragSession = m_viewImpl->page()->dragSession();
134 if (dragSession.operation != DragSourceActionNone) {
135 m_viewImpl->page()->performDrag(dragData, m_dragStorageName);
137 m_viewImpl->page()->dragEnded(viewPoint, viewPoint, m_dragData->draggingSourceOperationMask());
141 } // namespace WebKit
143 #endif // TIZEN_DRAG_SUPPORT