Changeset 212267 in webkit
- Timestamp:
- Feb 13, 2017 5:44:31 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r212265 r212267 1 2017-02-13 Anders Carlsson <andersca@apple.com> 2 3 Simplify DragController::startDrag 4 https://bugs.webkit.org/show_bug.cgi?id=168240 5 6 Reviewed by Tim Horton. 7 8 Use early returns instead of assigning to a variable that's returned at the end of the function. 9 10 * page/DragController.cpp: 11 (WebCore::DragController::startDrag): 12 1 13 2017-02-13 Said Abou-Hallawa <sabouhallawa@apple.com> 2 14 -
trunk/Source/WebCore/page/DragController.cpp
r212239 r212267 814 814 } 815 815 816 bool startedDrag = true; // optimism - we almost always manage to start the drag817 818 816 ASSERT(state.source); 819 817 Element& element = *state.source; … … 824 822 if (!dataTransfer.pasteboard().hasData()) { 825 823 // FIXME: This entire block is almost identical to the code in Editor::copy, and the code should be shared. 826 827 824 RefPtr<Range> selectionRange = src.selection().toNormalizedRange(); 828 825 ASSERT(selectionRange); … … 862 859 863 860 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, dragImageBounds, dataTransfer, src, false); 864 } else if (!src.document()->securityOrigin().canDisplay(linkURL)) { 861 return true; 862 } 863 864 if (!src.document()->securityOrigin().canDisplay(linkURL)) { 865 865 src.document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, "Not allowed to drag local resource: " + linkURL.stringCenterEllipsizedToLength()); 866 startedDrag = false; 867 } else if (!imageURL.isEmpty() && image && !image->isNull() && (m_dragSourceAction & DragSourceActionImage)) { 866 return false; 867 } 868 869 if (!imageURL.isEmpty() && image && !image->isNull() && (m_dragSourceAction & DragSourceActionImage)) { 868 870 // We shouldn't be starting a drag for an image that can't provide an extension. 869 871 // This is an early detection for problems encountered later upon drop. … … 886 888 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, false); 887 889 } 888 } else if (!linkURL.isEmpty() && (m_dragSourceAction & DragSourceActionLink)) { 890 return true; 891 } 892 893 if (!linkURL.isEmpty() && (m_dragSourceAction & DragSourceActionLink)) { 889 894 if (!dataTransfer.pasteboard().hasData()) { 890 895 // Simplify whitespace so the title put on the dataTransfer resembles what the user sees … … 921 926 } 922 927 doSystemDrag(WTFMove(dragImage), dragLoc, mouseDraggedPoint, { }, dataTransfer, src, true); 928 929 return true; 930 } 931 923 932 #if ENABLE(ATTACHMENT_ELEMENT) 924 } elseif (!attachmentURL.isEmpty() && (m_dragSourceAction & DragSourceActionAttachment)) {933 if (!attachmentURL.isEmpty() && (m_dragSourceAction & DragSourceActionAttachment)) { 925 934 if (!dataTransfer.pasteboard().hasData()) { 926 935 m_draggingAttachmentURL = attachmentURL; … … 937 946 } 938 947 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, false); 939 #endif 940 } else if (state.type == DragSourceActionDHTML) { 941 if (dragImage) { 942 ASSERT(m_dragSourceAction & DragSourceActionDHTML); 943 m_client.willPerformDragSourceAction(DragSourceActionDHTML, dragOrigin, dataTransfer); 944 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, false); 945 } else 946 startedDrag = false; 947 } else { 948 // draggableElement() determined an image or link node was draggable, but it turns out the 949 // image or link had no URL, so there is nothing to drag. 950 startedDrag = false; 951 } 952 953 return startedDrag; 948 return true; 949 } 950 #endif 951 952 if (state.type == DragSourceActionDHTML && dragImage) { 953 ASSERT(m_dragSourceAction & DragSourceActionDHTML); 954 m_client.willPerformDragSourceAction(DragSourceActionDHTML, dragOrigin, dataTransfer); 955 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, false); 956 return true; 957 } 958 959 return false; 954 960 } 955 961
Note: See TracChangeset
for help on using the changeset viewer.