Chromium Code Reviews| Index: Source/core/page/DragController.cpp |
| diff --git a/Source/core/page/DragController.cpp b/Source/core/page/DragController.cpp |
| index 3dc03d21ba91ea2e7244b7eee0649b39065a37fd..d062d9f88ccfb0237674452db4bc8296c4aef8ed 100644 |
| --- a/Source/core/page/DragController.cpp |
| +++ b/Source/core/page/DragController.cpp |
| @@ -620,9 +620,12 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) |
| return true; |
| } |
| -Node* DragController::draggableNode(const Frame* src, Node* startNode, const IntPoint& dragOrigin, DragState& state) const |
| +Node* DragController::draggableNode(const Frame* src, Node* startNode, const IntPoint& dragOrigin, SelectionDragPolicy selectionDragPolicy, DragSourceAction& dragType) const |
| { |
| - state.m_dragType = (src->selection().contains(dragOrigin)) ? DragSourceActionSelection : DragSourceActionNone; |
| + if (selectionDragPolicy == AllowSelectionDrag && src->selection().contains(dragOrigin)) { |
| + dragType = DragSourceActionSelection; |
|
tony
2013/11/04 18:23:40
Is it OK that dragType doesn't always get set? It
dcheng
2013/11/12 00:58:17
It can only be uninitialized if dragSrc is set to
|
| + return startNode; |
| + } |
| for (const RenderObject* renderer = startNode->renderer(); renderer; renderer = renderer->parent()) { |
| Node* node = renderer->nonPseudoNode(); |
| @@ -630,11 +633,13 @@ Node* DragController::draggableNode(const Frame* src, Node* startNode, const Int |
| // Anonymous render blocks don't correspond to actual DOM nodes, so we skip over them |
| // for the purposes of finding a draggable node. |
| continue; |
| - if (!(state.m_dragType & DragSourceActionSelection) && node->isTextNode() && node->canStartSelection()) |
| + if (node->isTextNode() && node->canStartSelection()) { |
| + dragType = DragSourceActionNone; |
| // In this case we have a click in the unselected portion of text. If this text is |
| // selectable, we want to start the selection process instead of looking for a parent |
| // to try to drag. |
| return 0; |
| + } |
| if (node->isElementNode()) { |
| EUserDrag dragMode = renderer->style()->userDrag(); |
| if (dragMode == DRAG_NONE) |
| @@ -642,23 +647,23 @@ Node* DragController::draggableNode(const Frame* src, Node* startNode, const Int |
| if (renderer->isImage() |
| && src->settings() |
| && src->settings()->loadsImagesAutomatically()) { |
| - state.m_dragType = static_cast<DragSourceAction>(state.m_dragType | DragSourceActionImage); |
| + dragType = DragSourceActionImage; |
| return node; |
| } |
| if (isHTMLAnchorElement(node) |
| && toHTMLAnchorElement(node)->isLiveLink()) { |
| - state.m_dragType = static_cast<DragSourceAction>(state.m_dragType | DragSourceActionLink); |
| + dragType = DragSourceActionLink; |
| return node; |
| } |
| if (dragMode == DRAG_ELEMENT) { |
| - state.m_dragType = static_cast<DragSourceAction>(state.m_dragType | DragSourceActionDHTML); |
| + dragType = DragSourceActionDHTML; |
| return node; |
| } |
| } |
| } |
| - // We either have nothing to drag or we have a selection and we're not over a draggable element. |
| - return (state.m_dragType & DragSourceActionSelection) ? startNode : 0; |
| + // Nothing under the drag origin is draggable, so just bail out. |
| + return 0; |
| } |
| static ImageResource* getImageResource(Element* element) |
| @@ -699,7 +704,7 @@ bool DragController::populateDragClipboard(Frame* src, const DragState& state, c |
| if (!src->view() || !src->contentRenderer()) |
| return false; |
| - HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active); |
| + HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragOrigin); |
| // FIXME: Can this even happen? I guess it's possible, but should verify |
| // with a layout test. |
| if (!state.m_dragSrc->contains(hitTestResult.innerNode())) { |
| @@ -820,11 +825,12 @@ bool DragController::startDrag(Frame* src, const DragState& state, const Platfor |
| return false; |
| HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragOrigin); |
| - if (!state.m_dragSrc->contains(hitTestResult.innerNode())) |
| + if (!state.m_dragSrc->contains(hitTestResult.innerNode())) { |
| // The original node being dragged isn't under the drag origin anymore... maybe it was |
| // hidden or moved out from under the cursor. Regardless, we don't want to start a drag on |
| // something that's not actually under the drag origin. |
| return false; |
| + } |
| const KURL& linkURL = hitTestResult.absoluteLinkURL(); |
| const KURL& imageURL = hitTestResult.absoluteImageURL(); |