Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/WebKit/Source/core/page/DragController.cpp

Issue 1479923002: Enumerate the return value of dispatchEvent so it is clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_passive_uma_add
Patch Set: sed -i s/DispatchEventResult/WebInputEventResult/g Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 { 429 {
430 frame->selection().setSelection(dragCaret); 430 frame->selection().setSelection(dragCaret);
431 if (frame->selection().isNone()) { 431 if (frame->selection().isNone()) {
432 dragCaret = VisibleSelection(frame->positionForPoint(point)); 432 dragCaret = VisibleSelection(frame->positionForPoint(point));
433 frame->selection().setSelection(dragCaret); 433 frame->selection().setSelection(dragCaret);
434 range = createRange(dragCaret.toNormalizedEphemeralRange()); 434 range = createRange(dragCaret.toNormalizedEphemeralRange());
435 } 435 }
436 return !frame->selection().isNone() && frame->selection().isContentEditable( ); 436 return !frame->selection().isNone() && frame->selection().isContentEditable( );
437 } 437 }
438 438
439 bool DragController::dispatchTextInputEventFor(LocalFrame* innerFrame, DragData* dragData) 439 WebInputEventResult DragController::dispatchTextInputEventFor(LocalFrame* innerF rame, DragData* dragData)
440 { 440 {
441 ASSERT(m_page->dragCaretController().hasCaret()); 441 ASSERT(m_page->dragCaretController().hasCaret());
442 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText(); 442 String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText();
443 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection( m_page->dragCaretController().caretPosition())); 443 Element* target = innerFrame->editor().findEventTargetFrom(VisibleSelection( m_page->dragCaretController().caretPosition()));
444 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text)); 444 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text));
445 } 445 }
446 446
447 bool DragController::concludeEditDrag(DragData* dragData) 447 bool DragController::concludeEditDrag(DragData* dragData)
448 { 448 {
449 ASSERT(dragData); 449 ASSERT(dragData);
450 450
451 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous e; 451 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous e;
452 if (m_fileInputElementUnderMouse) { 452 if (m_fileInputElementUnderMouse) {
453 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 453 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
454 m_fileInputElementUnderMouse = nullptr; 454 m_fileInputElementUnderMouse = nullptr;
455 } 455 }
456 456
457 if (!m_documentUnderMouse) 457 if (!m_documentUnderMouse)
458 return false; 458 return false;
459 459
460 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData- >clientPosition()); 460 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData- >clientPosition());
461 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); 461 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point);
462 if (!element) 462 if (!element)
463 return false; 463 return false;
464 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame( ); 464 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame( );
465 ASSERT(innerFrame); 465 ASSERT(innerFrame);
466 466
467 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i nnerFrame.get(), dragData)) 467 if (m_page->dragCaretController().hasCaret() && dispatchTextInputEventFor(in nerFrame.get(), dragData) != WebInputEventResult::NotHandled)
468 return true; 468 return true;
469 469
470 if (dragData->containsFiles() && fileInput) { 470 if (dragData->containsFiles() && fileInput) {
471 // fileInput should be the element we hit tested for, unless it was made 471 // fileInput should be the element we hit tested for, unless it was made
472 // display:none in a drop event handler. 472 // display:none in a drop event handler.
473 ASSERT(fileInput == element || !fileInput->layoutObject()); 473 ASSERT(fileInput == element || !fileInput->layoutObject());
474 if (fileInput->isDisabledFormControl()) 474 if (fileInput->isDisabledFormControl())
475 return false; 475 return false;
476 476
477 return fileInput->receiveDroppedFiles(dragData); 477 return fileInput->receiveDroppedFiles(dragData);
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 961
962 DEFINE_TRACE(DragController) 962 DEFINE_TRACE(DragController)
963 { 963 {
964 visitor->trace(m_page); 964 visitor->trace(m_page);
965 visitor->trace(m_documentUnderMouse); 965 visitor->trace(m_documentUnderMouse);
966 visitor->trace(m_dragInitiator); 966 visitor->trace(m_dragInitiator);
967 visitor->trace(m_fileInputElementUnderMouse); 967 visitor->trace(m_fileInputElementUnderMouse);
968 } 968 }
969 969
970 } // namespace blink 970 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698