Chromium Code Reviews| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 if (RefPtr<FrameView> v = mainFrame->view()) { | 204 if (RefPtr<FrameView> v = mainFrame->view()) { |
| 205 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnder Mouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable ; | 205 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnder Mouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable ; |
| 206 RefPtr<Clipboard> clipboard = Clipboard::create(policy, dragData, mainFr ame); | 206 RefPtr<Clipboard> clipboard = Clipboard::create(policy, dragData, mainFr ame); |
| 207 clipboard->setSourceOperation(dragData->draggingSourceOperationMask()); | 207 clipboard->setSourceOperation(dragData->draggingSourceOperationMask()); |
| 208 mainFrame->eventHandler()->cancelDragAndDrop(createMouseEvent(dragData), clipboard.get()); | 208 mainFrame->eventHandler()->cancelDragAndDrop(createMouseEvent(dragData), clipboard.get()); |
| 209 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he re for security | 209 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he re for security |
| 210 } | 210 } |
| 211 mouseMovedIntoDocument(0); | 211 mouseMovedIntoDocument(0); |
| 212 if (m_fileInputElementUnderMouse) | 212 if (m_fileInputElementUnderMouse) |
| 213 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 213 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 214 m_fileInputElementUnderMouse = 0; | 214 m_fileInputElementUnderMouse.clear(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 DragSession DragController::dragUpdated(DragData* dragData) | 217 DragSession DragController::dragUpdated(DragData* dragData) |
| 218 { | 218 { |
| 219 return dragEnteredOrUpdated(dragData); | 219 return dragEnteredOrUpdated(dragData); |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool DragController::performDrag(DragData* dragData) | 222 bool DragController::performDrag(DragData* dragData) |
| 223 { | 223 { |
| 224 ASSERT(dragData); | 224 ASSERT(dragData); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 return DragSession(); | 278 return DragSession(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 DragSession dragSession; | 281 DragSession dragSession; |
| 282 m_documentIsHandlingDrag = tryDocumentDrag(dragData, m_dragDestinationAction , dragSession); | 282 m_documentIsHandlingDrag = tryDocumentDrag(dragData, m_dragDestinationAction , dragSession); |
| 283 if (!m_documentIsHandlingDrag && (m_dragDestinationAction & DragDestinationA ctionLoad)) | 283 if (!m_documentIsHandlingDrag && (m_dragDestinationAction & DragDestinationA ctionLoad)) |
| 284 dragSession.operation = operationForLoad(dragData); | 284 dragSession.operation = operationForLoad(dragData); |
| 285 return dragSession; | 285 return dragSession; |
| 286 } | 286 } |
| 287 | 287 |
| 288 static HTMLInputElement* asFileInput(Node* node) | 288 static Result<HTMLInputElement> asFileInput(Node* node) |
| 289 { | 289 { |
| 290 ASSERT(node); | 290 ASSERT(node); |
| 291 | 291 |
| 292 HTMLInputElement* inputElement = node->toInputElement(); | 292 Handle<HTMLInputElement> inputElement = node->toInputElement(); |
| 293 | 293 |
| 294 // If this is a button inside of the a file input, move up to the file input . | 294 // If this is a button inside of the a file input, move up to the file input . |
| 295 if (inputElement && inputElement->isTextButton() && inputElement->treeScope( )->rootNode()->isShadowRoot()) | 295 if (inputElement && inputElement->isTextButton() && inputElement->treeScope( )->rootNode()->isShadowRoot()) |
| 296 inputElement = toShadowRoot(Handle<Node>(inputElement->treeScope()->root Node()).raw())->host()->toInputElement(); | 296 inputElement = toShadowRoot(Handle<Node>(inputElement->treeScope()->root Node()).raw())->host()->toInputElement(); |
| 297 | 297 |
| 298 return inputElement && inputElement->isFileUpload() ? inputElement : 0; | 298 return inputElement && inputElement->isFileUpload() ? inputElement : nullptr ; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // This can return null if an empty document is loaded. | 301 // This can return null if an empty document is loaded. |
| 302 static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p) | 302 static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p) |
| 303 { | 303 { |
| 304 Frame* frame = documentUnderMouse->frame(); | 304 Frame* frame = documentUnderMouse->frame(); |
| 305 float zoomFactor = frame ? frame->pageZoomFactor() : 1; | 305 float zoomFactor = frame ? frame->pageZoomFactor() : 1; |
| 306 LayoutPoint point = roundedLayoutPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor)); | 306 LayoutPoint point = roundedLayoutPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor)); |
| 307 | 307 |
| 308 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::DisallowShadowContent); | 308 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::DisallowShadowContent); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 if (dragData->containsColor()) { | 355 if (dragData->containsColor()) { |
| 356 dragSession.operation = DragOperationGeneric; | 356 dragSession.operation = DragOperationGeneric; |
| 357 return true; | 357 return true; |
| 358 } | 358 } |
| 359 | 359 |
| 360 IntPoint point = frameView->windowToContents(dragData->clientPosition()) ; | 360 IntPoint point = frameView->windowToContents(dragData->clientPosition()) ; |
| 361 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 361 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 362 if (!element) | 362 if (!element) |
| 363 return false; | 363 return false; |
| 364 | 364 |
| 365 HTMLInputElement* elementAsFileInput = asFileInput(element); | 365 Handle<HTMLInputElement> elementAsFileInput = asFileInput(element); |
| 366 if (m_fileInputElementUnderMouse != elementAsFileInput) { | 366 if (m_fileInputElementUnderMouse != elementAsFileInput) { |
| 367 if (m_fileInputElementUnderMouse) | 367 if (m_fileInputElementUnderMouse) |
| 368 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 368 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 369 m_fileInputElementUnderMouse = elementAsFileInput; | 369 m_fileInputElementUnderMouse = elementAsFileInput; |
| 370 } | 370 } |
| 371 | 371 |
| 372 if (!m_fileInputElementUnderMouse) | 372 if (!m_fileInputElementUnderMouse) |
| 373 m_page->dragCaretController()->setCaretPosition(m_documentUnderMouse ->frame()->visiblePositionForPoint(point)); | 373 m_page->dragCaretController()->setCaretPosition(m_documentUnderMouse ->frame()->visiblePositionForPoint(point)); |
| 374 | 374 |
| 375 Frame* innerFrame = element->document()->frame(); | 375 Frame* innerFrame = element->document()->frame(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 397 dragSession.numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1; | 397 dragSession.numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1; |
| 398 } | 398 } |
| 399 | 399 |
| 400 return true; | 400 return true; |
| 401 } | 401 } |
| 402 | 402 |
| 403 // We are not over an editable region. Make sure we're clearing any prior dr ag cursor. | 403 // We are not over an editable region. Make sure we're clearing any prior dr ag cursor. |
| 404 m_page->dragCaretController()->clear(); | 404 m_page->dragCaretController()->clear(); |
| 405 if (m_fileInputElementUnderMouse) | 405 if (m_fileInputElementUnderMouse) |
| 406 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 406 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 407 m_fileInputElementUnderMouse = 0; | 407 m_fileInputElementUnderMouse.clear(); |
| 408 return false; | 408 return false; |
| 409 } | 409 } |
| 410 | 410 |
| 411 DragSourceAction DragController::delegateDragSourceAction(const IntPoint& rootVi ewPoint) | 411 DragSourceAction DragController::delegateDragSourceAction(const IntPoint& rootVi ewPoint) |
| 412 { | 412 { |
| 413 m_dragSourceAction = m_client->dragSourceActionMaskForPoint(rootViewPoint); | 413 m_dragSourceAction = m_client->dragSourceActionMaskForPoint(rootViewPoint); |
| 414 return m_dragSourceAction; | 414 return m_dragSourceAction; |
| 415 } | 415 } |
| 416 | 416 |
| 417 DragOperation DragController::operationForLoad(DragData* dragData) | 417 DragOperation DragController::operationForLoad(DragData* dragData) |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 440 ASSERT(m_page->dragCaretController()->hasCaret()); | 440 ASSERT(m_page->dragCaretController()->hasCaret()); |
| 441 String text = m_page->dragCaretController()->isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame); | 441 String text = m_page->dragCaretController()->isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame); |
| 442 Node* target = innerFrame->editor()->findEventTargetFrom(m_page->dragCaretCo ntroller()->caretPosition()); | 442 Node* target = innerFrame->editor()->findEventTargetFrom(m_page->dragCaretCo ntroller()->caretPosition()); |
| 443 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->document() ->domWindow(), text), IGNORE_EXCEPTION); | 443 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->document() ->domWindow(), text), IGNORE_EXCEPTION); |
| 444 } | 444 } |
| 445 | 445 |
| 446 bool DragController::concludeEditDrag(DragData* dragData) | 446 bool DragController::concludeEditDrag(DragData* dragData) |
| 447 { | 447 { |
| 448 ASSERT(dragData); | 448 ASSERT(dragData); |
| 449 | 449 |
| 450 RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse; | 450 Handle<HTMLInputElement> fileInput = m_fileInputElementUnderMouse; |
| 451 if (m_fileInputElementUnderMouse) { | 451 if (m_fileInputElementUnderMouse) { |
| 452 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 452 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 453 m_fileInputElementUnderMouse = 0; | 453 m_fileInputElementUnderMouse.clear(); |
|
Vyacheslav Egorov (Google)
2013/07/18 16:50:08
I think we should kill clear() method and just use
haraken
2013/07/19 02:57:09
I'm neutral to this. Sometimes we need to return a
| |
| 454 } | 454 } |
| 455 | 455 |
| 456 if (!m_documentUnderMouse) | 456 if (!m_documentUnderMouse) |
| 457 return false; | 457 return false; |
| 458 | 458 |
| 459 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl ientPosition()); | 459 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl ientPosition()); |
| 460 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 460 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 461 if (!element) | 461 if (!element) |
| 462 return false; | 462 return false; |
| 463 RefPtr<Frame> innerFrame = element->ownerDocument()->frame(); | 463 RefPtr<Frame> innerFrame = element->ownerDocument()->frame(); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 949 #endif | 949 #endif |
| 950 return maxDragImageSize; | 950 return maxDragImageSize; |
| 951 } | 951 } |
| 952 | 952 |
| 953 void DragController::cleanupAfterSystemDrag() | 953 void DragController::cleanupAfterSystemDrag() |
| 954 { | 954 { |
| 955 } | 955 } |
| 956 | 956 |
| 957 } // namespace WebCore | 957 } // namespace WebCore |
| 958 | 958 |
| OLD | NEW |