| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 { | 1830 { |
| 1831 bool accept = false; | 1831 bool accept = false; |
| 1832 | 1832 |
| 1833 if (!m_frame->view()) | 1833 if (!m_frame->view()) |
| 1834 return false; | 1834 return false; |
| 1835 | 1835 |
| 1836 HitTestRequest request(HitTestRequest::ReadOnly); | 1836 HitTestRequest request(HitTestRequest::ReadOnly); |
| 1837 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); | 1837 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); |
| 1838 | 1838 |
| 1839 // Drag events should never go to text nodes (following IE, and proper mouse
over/out dispatch) | 1839 // Drag events should never go to text nodes (following IE, and proper mouse
over/out dispatch) |
| 1840 Node* newTarget = targetNode(mev); | 1840 RefPtr<Node> newTarget = targetNode(mev); |
| 1841 if (newTarget && newTarget->isTextNode()) | 1841 if (newTarget && newTarget->isTextNode()) |
| 1842 newTarget = newTarget->parentNode(); | 1842 newTarget = newTarget->parentNode(); |
| 1843 if (newTarget) | 1843 if (newTarget) |
| 1844 newTarget = newTarget->shadowAncestorNode(); | 1844 newTarget = newTarget->shadowAncestorNode(); |
| 1845 | 1845 |
| 1846 if (m_dragTarget != newTarget) { | 1846 if (m_dragTarget != newTarget) { |
| 1847 // FIXME: this ordering was explicitly chosen to match WinIE. However, | 1847 // FIXME: this ordering was explicitly chosen to match WinIE. However, |
| 1848 // it is sometimes incorrect when dragging within subframes, as seen wit
h | 1848 // it is sometimes incorrect when dragging within subframes, as seen wit
h |
| 1849 // LayoutTests/fast/events/drag-in-frames.html. | 1849 // LayoutTests/fast/events/drag-in-frames.html. |
| 1850 // | 1850 // |
| 1851 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec.
<http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. | 1851 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec.
<http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. |
| 1852 Frame* targetFrame; | 1852 Frame* targetFrame; |
| 1853 if (targetIsFrame(newTarget, targetFrame)) { | 1853 if (targetIsFrame(newTarget.get(), targetFrame)) { |
| 1854 if (targetFrame) | 1854 if (targetFrame) |
| 1855 accept = targetFrame->eventHandler()->updateDragAndDrop(event, c
lipboard); | 1855 accept = targetFrame->eventHandler()->updateDragAndDrop(event, c
lipboard); |
| 1856 } else if (newTarget) { | 1856 } else if (newTarget) { |
| 1857 // As per section 7.9.4 of the HTML 5 spec., we must always fire a d
rag event before firing a dragenter, dragleave, or dragover event. | 1857 // As per section 7.9.4 of the HTML 5 spec., we must always fire a d
rag event before firing a dragenter, dragleave, or dragover event. |
| 1858 if (dragState().m_dragSrc && dragState().shouldDispatchEvents()) { | 1858 if (dragState().m_dragSrc && dragState().shouldDispatchEvents()) { |
| 1859 // for now we don't care if event handler cancels default behavi
or, since there is none | 1859 // for now we don't care if event handler cancels default behavi
or, since there is none |
| 1860 dispatchDragSrcEvent(eventNames().dragEvent, event); | 1860 dispatchDragSrcEvent(eventNames().dragEvent, event); |
| 1861 } | 1861 } |
| 1862 accept = dispatchDragEvent(eventNames().dragenterEvent, newTarget, e
vent, clipboard); | 1862 accept = dispatchDragEvent(eventNames().dragenterEvent, newTarget.ge
t(), event, clipboard); |
| 1863 if (!accept) | 1863 if (!accept) |
| 1864 accept = findDropZone(newTarget, clipboard); | 1864 accept = findDropZone(newTarget.get(), clipboard); |
| 1865 } | 1865 } |
| 1866 | 1866 |
| 1867 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { | 1867 if (targetIsFrame(m_dragTarget.get(), targetFrame)) { |
| 1868 if (targetFrame) | 1868 if (targetFrame) |
| 1869 accept = targetFrame->eventHandler()->updateDragAndDrop(event, c
lipboard); | 1869 accept = targetFrame->eventHandler()->updateDragAndDrop(event, c
lipboard); |
| 1870 } else if (m_dragTarget) | 1870 } else if (m_dragTarget) |
| 1871 dispatchDragEvent(eventNames().dragleaveEvent, m_dragTarget.get(), e
vent, clipboard); | 1871 dispatchDragEvent(eventNames().dragleaveEvent, m_dragTarget.get(), e
vent, clipboard); |
| 1872 | 1872 |
| 1873 if (newTarget) { | 1873 if (newTarget) { |
| 1874 // We do not explicitly call dispatchDragEvent here because it could
ultimately result in the appearance that | 1874 // We do not explicitly call dispatchDragEvent here because it could
ultimately result in the appearance that |
| 1875 // two dragover events fired. So, we mark that we should only fire a
dragover event on the next call to this function. | 1875 // two dragover events fired. So, we mark that we should only fire a
dragover event on the next call to this function. |
| 1876 m_shouldOnlyFireDragOverEvent = true; | 1876 m_shouldOnlyFireDragOverEvent = true; |
| 1877 } | 1877 } |
| 1878 } else { | 1878 } else { |
| 1879 Frame* targetFrame; | 1879 Frame* targetFrame; |
| 1880 if (targetIsFrame(newTarget, targetFrame)) { | 1880 if (targetIsFrame(newTarget.get(), targetFrame)) { |
| 1881 if (targetFrame) | 1881 if (targetFrame) |
| 1882 accept = targetFrame->eventHandler()->updateDragAndDrop(event, c
lipboard); | 1882 accept = targetFrame->eventHandler()->updateDragAndDrop(event, c
lipboard); |
| 1883 } else if (newTarget) { | 1883 } else if (newTarget) { |
| 1884 // Note, when dealing with sub-frames, we may need to fire only a dr
agover event as a drag event may have been fired earlier. | 1884 // Note, when dealing with sub-frames, we may need to fire only a dr
agover event as a drag event may have been fired earlier. |
| 1885 if (!m_shouldOnlyFireDragOverEvent && dragState().m_dragSrc && dragS
tate().shouldDispatchEvents()) { | 1885 if (!m_shouldOnlyFireDragOverEvent && dragState().m_dragSrc && dragS
tate().shouldDispatchEvents()) { |
| 1886 // for now we don't care if event handler cancels default behavi
or, since there is none | 1886 // for now we don't care if event handler cancels default behavi
or, since there is none |
| 1887 dispatchDragSrcEvent(eventNames().dragEvent, event); | 1887 dispatchDragSrcEvent(eventNames().dragEvent, event); |
| 1888 } | 1888 } |
| 1889 accept = dispatchDragEvent(eventNames().dragoverEvent, newTarget, ev
ent, clipboard); | 1889 accept = dispatchDragEvent(eventNames().dragoverEvent, newTarget.get
(), event, clipboard); |
| 1890 if (!accept) | 1890 if (!accept) |
| 1891 accept = findDropZone(newTarget, clipboard); | 1891 accept = findDropZone(newTarget.get(), clipboard); |
| 1892 m_shouldOnlyFireDragOverEvent = false; | 1892 m_shouldOnlyFireDragOverEvent = false; |
| 1893 } | 1893 } |
| 1894 } | 1894 } |
| 1895 m_dragTarget = newTarget; | 1895 m_dragTarget = newTarget; |
| 1896 | 1896 |
| 1897 return accept; | 1897 return accept; |
| 1898 } | 1898 } |
| 1899 | 1899 |
| 1900 void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, Clipboard*
clipboard) | 1900 void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, Clipboard*
clipboard) |
| 1901 { | 1901 { |
| (...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3356 } | 3356 } |
| 3357 | 3357 |
| 3358 return defaultPrevented; | 3358 return defaultPrevented; |
| 3359 } | 3359 } |
| 3360 | 3360 |
| 3361 | 3361 |
| 3362 | 3362 |
| 3363 #endif | 3363 #endif |
| 3364 | 3364 |
| 3365 } | 3365 } |
| OLD | NEW |