Changeset 99369 in webkit
- Timestamp:
- Nov 5, 2011 9:27:39 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r99367 r99369 1 2011-11-04 Jon Lee <jonlee@apple.com> 2 3 Dragging a file onto <input type="file"> should give distinct visual feedback 4 https://bugs.webkit.org/show_bug.cgi?id=13897 5 <rdar://problem/5232483> 6 7 Reviewed by Dan Bernstein. 8 9 When hovering over a file input element, we set the button's state to active 10 to differentiate dragging one file over the input element (which populates that 11 element) versus over the document (which would load the file into the view). 12 13 * html/HTMLInputElement.cpp: 14 (WebCore::HTMLInputElement::HTMLInputElement): 15 (WebCore::HTMLInputElement::canReceiveDroppedFiles): 16 (WebCore::HTMLInputElement::setCanReceiveDroppedFiles): If set, the element 17 is updated, which sets the active state on the button control. 18 * html/HTMLInputElement.h: Add a boolean member representing whether the file 19 input can receive dropped files. 20 * page/DragController.cpp: 21 (WebCore::DragController::DragController): Update/set the file input that 22 can receive dropped files. 23 (WebCore::DragController::dragExited): 24 (WebCore::DragController::tryDocumentDrag): 25 (WebCore::DragController::concludeEditDrag): 26 * page/DragController.h: 27 * rendering/RenderFileUploadControl.cpp: 28 (WebCore::RenderFileUploadControl::updateFromElement): Sets the button active 29 state if the input can receive dropped files. 30 1 31 2011-11-05 Darin Adler <darin@apple.com> 2 32 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r98222 r99369 95 95 , m_parsingInProgress(createdByParser) 96 96 , m_wasModifiedByUser(false) 97 , m_canReceiveDroppedFiles(false) 97 98 , m_inputType(InputType::createText(this)) 98 99 { … … 1411 1412 } 1412 1413 1414 bool HTMLInputElement::canReceiveDroppedFiles() const 1415 { 1416 return m_canReceiveDroppedFiles; 1417 } 1418 1419 void HTMLInputElement::setCanReceiveDroppedFiles(bool canReceiveDroppedFiles) 1420 { 1421 if (m_canReceiveDroppedFiles == canReceiveDroppedFiles) 1422 return; 1423 m_canReceiveDroppedFiles = canReceiveDroppedFiles; 1424 renderer()->updateFromElement(); 1425 } 1426 1413 1427 String HTMLInputElement::visibleValue() const 1414 1428 { -
trunk/Source/WebCore/html/HTMLInputElement.h
r98054 r99369 210 210 void receiveDroppedFiles(const Vector<String>&); 211 211 Icon* icon() const; 212 // These functions are used for rendering the input active during a 213 // drag-and-drop operation. 214 bool canReceiveDroppedFiles() const; 215 void setCanReceiveDroppedFiles(bool); 212 216 213 217 void addSearchResult(); … … 352 356 bool m_parsingInProgress : 1; 353 357 bool m_wasModifiedByUser : 1; 358 bool m_canReceiveDroppedFiles : 1; 354 359 OwnPtr<InputType> m_inputType; 355 360 }; -
trunk/Source/WebCore/page/DragController.cpp
r99108 r99369 89 89 , m_documentUnderMouse(0) 90 90 , m_dragInitiator(0) 91 , m_fileInputElementUnderMouse(0) 91 92 , m_dragDestinationAction(DragDestinationActionNone) 92 93 , m_dragSourceAction(DragSourceActionNone) … … 182 183 } 183 184 mouseMovedIntoDocument(0); 185 if (m_fileInputElementUnderMouse) 186 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 187 m_fileInputElementUnderMouse = 0; 184 188 } 185 189 … … 329 333 330 334 HTMLInputElement* elementAsFileInput = asFileInput(element); 331 if (!elementAsFileInput) 335 if (m_fileInputElementUnderMouse != elementAsFileInput) { 336 if (m_fileInputElementUnderMouse) 337 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 338 m_fileInputElementUnderMouse = elementAsFileInput; 339 } 340 341 if (!m_fileInputElementUnderMouse) 332 342 m_page->dragCaretController()->setCaretPosition(m_documentUnderMouse->frame()->visiblePositionForPoint(point)); 333 343 334 344 Frame* innerFrame = element->document()->frame(); 335 345 dragSession.operation = dragIsMove(innerFrame->selection(), dragData) ? DragOperationMove : DragOperationCopy; 336 dragSession.mouseIsOverFileInput = elementAsFileInput;346 dragSession.mouseIsOverFileInput = m_fileInputElementUnderMouse; 337 347 dragSession.numberOfItemsToBeAccepted = 0; 338 348 339 349 unsigned numberOfFiles = dragData->numberOfFiles(); 340 if ( elementAsFileInput) {341 if ( elementAsFileInput->disabled())350 if (m_fileInputElementUnderMouse) { 351 if (m_fileInputElementUnderMouse->disabled()) 342 352 dragSession.numberOfItemsToBeAccepted = 0; 343 else if ( elementAsFileInput->multiple())353 else if (m_fileInputElementUnderMouse->multiple()) 344 354 dragSession.numberOfItemsToBeAccepted = numberOfFiles; 345 355 else … … 348 358 if (!dragSession.numberOfItemsToBeAccepted) 349 359 dragSession.operation = DragOperationNone; 360 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(dragSession.numberOfItemsToBeAccepted); 350 361 } else { 351 362 // We are not over a file input element. The dragged item(s) will only … … 356 367 return true; 357 368 } 358 // If we're not over an editable region, make sure we're clearing any prior drag cursor. 369 370 // We are not over an editable region. Make sure we're clearing any prior drag cursor. 359 371 m_page->dragCaretController()->clear(); 372 if (m_fileInputElementUnderMouse) 373 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 374 m_fileInputElementUnderMouse = 0; 360 375 return false; 361 376 } … … 400 415 ASSERT(dragData); 401 416 ASSERT(!m_isHandlingDrag); 417 418 if (m_fileInputElementUnderMouse) { 419 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 420 m_fileInputElementUnderMouse = 0; 421 } 402 422 403 423 if (!m_documentUnderMouse) -
trunk/Source/WebCore/page/DragController.h
r99108 r99369 43 43 class Frame; 44 44 class FrameSelection; 45 class HTMLInputElement; 45 46 class Image; 46 47 class IntRect; … … 118 119 RefPtr<Document> m_documentUnderMouse; // The document the mouse was last dragged over. 119 120 RefPtr<Document> m_dragInitiator; // The Document (if any) that initiated the drag. 121 RefPtr<HTMLInputElement> m_fileInputElementUnderMouse; 120 122 121 123 DragDestinationAction m_dragDestinationAction; -
trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp
r99083 r99369 72 72 if (button->disabled() != newDisabled) 73 73 button->setDisabled(newDisabled); 74 75 button->setActive(input->canReceiveDroppedFiles()); 74 76 } 75 77
Note: See TracChangeset
for help on using the changeset viewer.