| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Google Inc. | 3 * Copyright (C) 2008 Google Inc. |
| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 378 } |
| 379 | 379 |
| 380 if (!m_fileInputElementUnderMouse) | 380 if (!m_fileInputElementUnderMouse) |
| 381 m_page->dragCaretController().setCaretPosition(m_documentUnderMouse-
>frame()->visiblePositionForPoint(point)); | 381 m_page->dragCaretController().setCaretPosition(m_documentUnderMouse-
>frame()->visiblePositionForPoint(point)); |
| 382 | 382 |
| 383 LocalFrame* innerFrame = element->document().frame(); | 383 LocalFrame* innerFrame = element->document().frame(); |
| 384 dragSession.operation = dragIsMove(innerFrame->selection(), dragData) ?
DragOperationMove : DragOperationCopy; | 384 dragSession.operation = dragIsMove(innerFrame->selection(), dragData) ?
DragOperationMove : DragOperationCopy; |
| 385 dragSession.mouseIsOverFileInput = m_fileInputElementUnderMouse; | 385 dragSession.mouseIsOverFileInput = m_fileInputElementUnderMouse; |
| 386 dragSession.numberOfItemsToBeAccepted = 0; | 386 dragSession.numberOfItemsToBeAccepted = 0; |
| 387 | 387 |
| 388 unsigned numberOfFiles = dragData->numberOfFiles(); | 388 Vector<String> paths; |
| 389 dragData->asFilePaths(paths); |
| 390 const unsigned numberOfFiles = paths.size(); |
| 389 if (m_fileInputElementUnderMouse) { | 391 if (m_fileInputElementUnderMouse) { |
| 390 if (m_fileInputElementUnderMouse->isDisabledFormControl()) | 392 if (m_fileInputElementUnderMouse->isDisabledFormControl()) |
| 391 dragSession.numberOfItemsToBeAccepted = 0; | 393 dragSession.numberOfItemsToBeAccepted = 0; |
| 392 else if (m_fileInputElementUnderMouse->multiple()) | 394 else if (m_fileInputElementUnderMouse->multiple()) |
| 393 dragSession.numberOfItemsToBeAccepted = numberOfFiles; | 395 dragSession.numberOfItemsToBeAccepted = numberOfFiles; |
| 394 else if (numberOfFiles > 1) | 396 else if (numberOfFiles == 1) |
| 397 dragSession.numberOfItemsToBeAccepted = 1; |
| 398 else |
| 395 dragSession.numberOfItemsToBeAccepted = 0; | 399 dragSession.numberOfItemsToBeAccepted = 0; |
| 396 else | |
| 397 dragSession.numberOfItemsToBeAccepted = 1; | |
| 398 | 400 |
| 399 if (!dragSession.numberOfItemsToBeAccepted) | 401 if (!dragSession.numberOfItemsToBeAccepted) |
| 400 dragSession.operation = DragOperationNone; | 402 dragSession.operation = DragOperationNone; |
| 401 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(dragSession.
numberOfItemsToBeAccepted); | 403 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(dragSession.
numberOfItemsToBeAccepted); |
| 402 } else { | 404 } else { |
| 403 // We are not over a file input element. The dragged item(s) will on
ly | 405 // We are not over a file input element. The dragged item(s) will on
ly |
| 404 // be loaded into the view the number of dragged items is 1. | 406 // be loaded into the view the number of dragged items is 1. |
| 405 dragSession.numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1; | 407 dragSession.numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1; |
| 406 } | 408 } |
| 407 | 409 |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 | 986 |
| 985 void DragController::trace(Visitor* visitor) | 987 void DragController::trace(Visitor* visitor) |
| 986 { | 988 { |
| 987 visitor->trace(m_page); | 989 visitor->trace(m_page); |
| 988 visitor->trace(m_documentUnderMouse); | 990 visitor->trace(m_documentUnderMouse); |
| 989 visitor->trace(m_dragInitiator); | 991 visitor->trace(m_dragInitiator); |
| 990 visitor->trace(m_fileInputElementUnderMouse); | 992 visitor->trace(m_fileInputElementUnderMouse); |
| 991 } | 993 } |
| 992 | 994 |
| 993 } // namespace blink | 995 } // namespace blink |
| OLD | NEW |