Changeset 45064 in webkit


Ignore:
Timestamp:
Jun 24, 2009 12:07:46 AM (15 years ago)
Author:
eric@webkit.org
Message:

2009-06-05 Eric Seidel <eric@webkit.org>

Reviewed by Oliver Hunt.

https://bugs.webkit.org/show_bug.cgi?id=25922
Fix dropEffect = "none" to work as expected.

  • fast/events/drag-to-navigate-expected.txt: Copied from LayoutTests/editing/selection/doubleclick-whitespace-img-crash-expected.txt.
  • fast/events/drag-to-navigate.html: Added.
  • fast/events/prevent-drag-to-navigate-expected.txt: Copied from LayoutTests/editing/selection/doubleclick-whitespace-img-crash-expected.txt.
  • fast/events/prevent-drag-to-navigate.html: Added.
  • fast/events/resources/file-for-drag-to-navigate.html: Added.
  • fast/events/resources/file-for-prevent-drag-to-navigate.html: Added.

2009-06-05 Eric Seidel <eric@webkit.org>

Reviewed by Oliver Hunt.

https://bugs.webkit.org/show_bug.cgi?id=25922
JS setting dropEffect = "none" causes tryDHTMLDrag
to return DragOperationNone. Which is also the value
tryDHTMLDrag previously used to indicate JS did not
want to handle the drag.

Make it possible for the DragController::try* methods
to return a bool to indicate if javascript accepted
or rejected the drag event, separate from the DragOperation.

Tests:

  • fast/events/drag-to-navigate.html
  • fast/events/prevent-drag-to-navigate.html
  • page/DragController.cpp: (WebCore::DragController::dragEnteredOrUpdated): (WebCore::DragController::tryDocumentDrag): (WebCore::defaultOperationForDrag): (WebCore::DragController::tryDHTMLDrag):
  • page/DragController.h:
Location:
trunk
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r45063 r45064  
     12009-06-05  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=25922
     6        Fix dropEffect = "none" to work as expected.
     7
     8        * fast/events/drag-to-navigate-expected.txt: Copied from LayoutTests/editing/selection/doubleclick-whitespace-img-crash-expected.txt.
     9        * fast/events/drag-to-navigate.html: Added.
     10        * fast/events/prevent-drag-to-navigate-expected.txt: Copied from LayoutTests/editing/selection/doubleclick-whitespace-img-crash-expected.txt.
     11        * fast/events/prevent-drag-to-navigate.html: Added.
     12        * fast/events/resources/file-for-drag-to-navigate.html: Added.
     13        * fast/events/resources/file-for-prevent-drag-to-navigate.html: Added.
     14
    1152009-06-23  Oliver Hunt  <oliver@apple.com>
    216
  • trunk/WebCore/ChangeLog

    r45060 r45064  
     12009-06-05  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=25922
     6        JS setting dropEffect = "none" causes tryDHTMLDrag
     7        to return DragOperationNone.  Which is also the value
     8        tryDHTMLDrag previously used to indicate JS did not
     9        want to handle the drag.
     10
     11        Make it possible for the DragController::try* methods
     12        to return a bool to indicate if javascript accepted
     13        or rejected the drag event, separate from the DragOperation.
     14
     15        Tests:
     16        - fast/events/drag-to-navigate.html
     17        - fast/events/prevent-drag-to-navigate.html
     18
     19        * page/DragController.cpp:
     20        (WebCore::DragController::dragEnteredOrUpdated):
     21        (WebCore::DragController::tryDocumentDrag):
     22        (WebCore::defaultOperationForDrag):
     23        (WebCore::DragController::tryDHTMLDrag):
     24        * page/DragController.h:
     25
    1262009-06-23  Oliver Hunt  <oliver@apple.com> and Eric Carlson  <eric.carlson@apple.com>
    227
  • trunk/WebCore/page/DragController.cpp

    r44659 r45064  
    223223
    224224    m_dragDestinationAction = m_client->actionMaskForDrag(dragData);
    225    
     225    if (m_dragDestinationAction == DragDestinationActionNone) {
     226        cancelDrag(); // FIXME: Why not call mouseMovedIntoDocument(0)?
     227        return DragOperationNone;
     228    }
     229
    226230    DragOperation operation = DragOperationNone;
    227    
    228     if (m_dragDestinationAction == DragDestinationActionNone)
    229         cancelDrag(); // FIXME: Why not call mouseMovedIntoDocument(0)?
    230     else {
    231         operation = tryDocumentDrag(dragData, m_dragDestinationAction);
    232         if (operation == DragOperationNone && (m_dragDestinationAction & DragDestinationActionLoad))
    233             return operationForLoad(dragData);
    234     }
    235    
     231    bool handledByDocument = tryDocumentDrag(dragData, m_dragDestinationAction, operation);
     232    if (!handledByDocument && (m_dragDestinationAction & DragDestinationActionLoad))
     233        return operationForLoad(dragData);
    236234    return operation;
    237235}
     
    257255}
    258256   
    259 DragOperation DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction actionMask)
     257bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction actionMask, DragOperation& operation)
    260258{
    261259    ASSERT(dragData);
    262260   
    263261    if (!m_documentUnderMouse)
    264         return DragOperationNone;
     262        return false;
    265263   
    266264    DragOperation operation = DragOperationNone;
     
    273271        // dragExited.
    274272        if (!m_documentUnderMouse)
    275             return DragOperationNone;
     273            return false;
    276274    }
    277275    m_isHandlingDrag = operation != DragOperationNone;
    278276
     277    // It's unclear why this check is after tryDHTMLDrag.
     278    // We send drag events in tryDHTMLDrag and that may be the reason.
    279279    RefPtr<FrameView> frameView = m_documentUnderMouse->view();
    280280    if (!frameView)
    281         return operation;
    282    
     281        return false;
     282
     283    if (m_isHandlingDrag) {
     284        m_page->dragCaretController()->clear();
     285        return true;
     286    }
     287
    283288    if ((actionMask & DragDestinationActionEdit) && !m_isHandlingDrag && canProcessDrag(dragData)) {
    284         if (dragData->containsColor())
    285             return DragOperationGeneric;
     289        if (dragData->containsColor()) {
     290            operation = DragOperationGeneric;
     291            return true;
     292        }
    286293       
    287294        IntPoint dragPos = dragData->clientPosition();
     
    295302
    296303        Frame* innerFrame = element->document()->frame();
    297         return dragIsMove(innerFrame->selection()) ? DragOperationMove : DragOperationCopy;
    298     }
    299    
    300     m_page->dragCaretController()->clear();
    301     return operation;
     304        operation = dragIsMove(innerFrame->selection()) ? DragOperationMove : DragOperationCopy;
     305        return true;
     306    }
     307    return false;
    302308}
    303309
     
    462468}
    463469
    464 DragOperation DragController::tryDHTMLDrag(DragData* dragData)
     470static DragOperation defaultOperationForDrag(DragOperation srcOpMask)
     471{
     472    // This is designed to match IE's operation fallback for the case where
     473    // the page calls preventDefault() in a drag event but doesn't set dropEffect.
     474    if (srcOpMask & DragOperationCopy)
     475         return DragOperationCopy;
     476    if (srcOpMask & DragOperationMove || srcOpMask & DragOperationGeneric)
     477        return DragOperationMove;
     478    if (srcOpMask & DragOperationLink)
     479        return DragOperationLink;
     480
     481    // FIXME: Does IE really return "generic" even if no operations were allowed by the source?
     482    return DragOperationGeneric;
     483}
     484
     485bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
    465486{   
    466487    ASSERT(dragData);
    467488    ASSERT(m_documentUnderMouse);
    468     DragOperation op = DragOperationNone;
    469489    RefPtr<Frame> mainFrame = m_page->mainFrame();
    470490    RefPtr<FrameView> viewProtector = mainFrame->view();
    471491    if (!viewProtector)
    472         return DragOperationNone;
    473    
     492        return false;
     493
    474494    ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLocal() ? ClipboardReadable : ClipboardTypesReadable;
    475495    RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
    476     DragOperation srcOp = dragData->draggingSourceOperationMask();
    477     clipboard->setSourceOperation(srcOp);
    478    
     496    DragOperation srcOpMask = dragData->draggingSourceOperationMask();
     497    clipboard->setSourceOperation(srcOpMask);
     498
    479499    PlatformMouseEvent event = createMouseEvent(dragData);
    480     if (mainFrame->eventHandler()->updateDragAndDrop(event, clipboard.get())) {
    481         // *op unchanged if no source op was set
    482         if (!clipboard->destinationOperation(op)) {
    483             // The element accepted but they didn't pick an operation, so we pick one for them
    484             // (as does WinIE).
    485             if (srcOp & DragOperationCopy)
    486                 op = DragOperationCopy;
    487             else if (srcOp & DragOperationMove || srcOp & DragOperationGeneric)
    488                 op = DragOperationMove;
    489             else if (srcOp & DragOperationLink)
    490                 op = DragOperationLink;
    491             else
    492                 op = DragOperationGeneric;
    493         } else if (!(op & srcOp)) {
    494             op = DragOperationNone;
    495         }
    496 
     500    if (!mainFrame->eventHandler()->updateDragAndDrop(event, clipboard.get())) {
    497501        clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
    498         return op;
    499     }
    500     return op;
     502        return false;
     503    }
     504
     505    if (!clipboard->destinationOperation(operation)) {
     506        // The element accepted but they didn't pick an operation, so we pick one (to match IE).
     507        operation = defaultOperationForDrag(srcOpMask);
     508    } else if (!(srcOpMask & operation)) {
     509        // The element picked an operation which is not supported by the source
     510        operation = DragOperationNone;
     511    }
     512
     513    clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
     514    return true;
    501515}
    502516
  • trunk/WebCore/page/DragController.h

    r43968 r45064  
    9797        DragOperation dragEnteredOrUpdated(DragData*);
    9898        DragOperation operationForLoad(DragData*);
    99         DragOperation tryDocumentDrag(DragData*, DragDestinationAction);
    100         DragOperation tryDHTMLDrag(DragData*);
     99        bool tryDocumentDrag(DragData*, DragDestinationAction, DragOperation&);
     100        bool tryDHTMLDrag(DragData*, DragOperation&);
    101101        DragOperation dragOperation(DragData*);
    102102        void cancelDrag();
Note: See TracChangeset for help on using the changeset viewer.