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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2397883002: Convert drag event position to root frame. (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebView.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 3625 matching lines...) Expand 10 before | Expand all | Expand 10 after
3636 3636
3637 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& pointInViewport) 3637 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& pointInViewport)
3638 { 3638 {
3639 DocumentLifecycle::AllowThrottlingScope throttlingScope(mainFrameImpl()->fra me()->document()->lifecycle()); 3639 DocumentLifecycle::AllowThrottlingScope throttlingScope(mainFrameImpl()->fra me()->document()->lifecycle());
3640 FrameView* view = mainFrameImpl()->frameView(); 3640 FrameView* view = mainFrameImpl()->frameView();
3641 IntPoint pointInRootFrame = view->contentsToFrame(view->viewportToContents(p ointInViewport)); 3641 IntPoint pointInRootFrame = view->contentsToFrame(view->viewportToContents(p ointInViewport));
3642 return hitTestResultForRootFramePos(pointInRootFrame); 3642 return hitTestResultForRootFramePos(pointInRootFrame);
3643 } 3643 }
3644 3644
3645 void WebViewImpl::dragSourceEndedAt( 3645 void WebViewImpl::dragSourceEndedAt(
3646 const WebPoint& clientPoint, 3646 const WebPoint& pointInViewport,
3647 const WebPoint& screenPoint, 3647 const WebPoint& screenPoint,
3648 WebDragOperation operation) 3648 WebDragOperation operation)
3649 { 3649 {
3650 PlatformMouseEvent pme(clientPoint, screenPoint, WebPointerProperties::Butto n::Left, PlatformEvent::MouseMoved, 3650 WebPoint pointInRootFrame(page()->frameHost().visualViewport().viewportToRoo tFrame(pointInViewport));
3651 PlatformMouseEvent pme(pointInRootFrame, screenPoint, WebPointerProperties:: Button::Left, PlatformEvent::MouseMoved,
3651 0, PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishab le, WTF::monotonicallyIncreasingTime()); 3652 0, PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishab le, WTF::monotonicallyIncreasingTime());
3652 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme, 3653 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme,
3653 static_cast<DragOperation>(operation)); 3654 static_cast<DragOperation>(operation));
3654 } 3655 }
3655 3656
3656 void WebViewImpl::dragSourceSystemDragEnded() 3657 void WebViewImpl::dragSourceSystemDragEnded()
3657 { 3658 {
3658 // It's possible for us to get this callback while not doing a drag if 3659 // It's possible for us to get this callback while not doing a drag if
3659 // it's from a previous page that got unloaded. 3660 // it's from a previous page that got unloaded.
3660 if (m_doingDragAndDrop) { 3661 if (m_doingDragAndDrop) {
3661 m_page->dragController().dragEnded(); 3662 m_page->dragController().dragEnded();
3662 m_doingDragAndDrop = false; 3663 m_doingDragAndDrop = false;
3663 } 3664 }
3664 } 3665 }
3665 3666
3666 WebDragOperation WebViewImpl::dragTargetDragEnter( 3667 WebDragOperation WebViewImpl::dragTargetDragEnter(
3667 const WebDragData& webDragData, 3668 const WebDragData& webDragData,
3668 const WebPoint& clientPoint, 3669 const WebPoint& pointInViewport,
3669 const WebPoint& screenPoint, 3670 const WebPoint& screenPoint,
3670 WebDragOperationsMask operationsAllowed, 3671 WebDragOperationsMask operationsAllowed,
3671 int modifiers) 3672 int modifiers)
3672 { 3673 {
3673 DCHECK(!m_currentDragData); 3674 DCHECK(!m_currentDragData);
3674 3675
3675 m_currentDragData = DataObject::create(webDragData); 3676 m_currentDragData = DataObject::create(webDragData);
3676 m_operationsAllowed = operationsAllowed; 3677 m_operationsAllowed = operationsAllowed;
3677 3678
3678 return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter, modifi ers); 3679 return dragTargetDragEnterOrOver(pointInViewport, screenPoint, DragEnter, mo difiers);
3679 } 3680 }
3680 3681
3681 WebDragOperation WebViewImpl::dragTargetDragOver( 3682 WebDragOperation WebViewImpl::dragTargetDragOver(
3682 const WebPoint& clientPoint, 3683 const WebPoint& pointInViewport,
3683 const WebPoint& screenPoint, 3684 const WebPoint& screenPoint,
3684 WebDragOperationsMask operationsAllowed, 3685 WebDragOperationsMask operationsAllowed,
3685 int modifiers) 3686 int modifiers)
3686 { 3687 {
3687 m_operationsAllowed = operationsAllowed; 3688 m_operationsAllowed = operationsAllowed;
3688 3689
3689 return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragOver, modifie rs); 3690 return dragTargetDragEnterOrOver(pointInViewport, screenPoint, DragOver, mod ifiers);
3690 } 3691 }
3691 3692
3692 void WebViewImpl::dragTargetDragLeave() 3693 void WebViewImpl::dragTargetDragLeave()
3693 { 3694 {
3694 DCHECK(m_currentDragData); 3695 DCHECK(m_currentDragData);
3695 3696
3696 DragData dragData( 3697 DragData dragData(
3697 m_currentDragData.get(), 3698 m_currentDragData.get(),
3698 IntPoint(), 3699 IntPoint(),
3699 IntPoint(), 3700 IntPoint(),
3700 static_cast<DragOperation>(m_operationsAllowed)); 3701 static_cast<DragOperation>(m_operationsAllowed));
3701 3702
3702 m_page->dragController().dragExited(&dragData); 3703 m_page->dragController().dragExited(&dragData);
3703 3704
3704 // FIXME: why is the drag scroll timer not stopped here? 3705 // FIXME: why is the drag scroll timer not stopped here?
3705 3706
3706 m_dragOperation = WebDragOperationNone; 3707 m_dragOperation = WebDragOperationNone;
3707 m_currentDragData = nullptr; 3708 m_currentDragData = nullptr;
3708 } 3709 }
3709 3710
3710 void WebViewImpl::dragTargetDrop(const WebDragData& webDragData, const WebPoint& clientPoint, 3711 void WebViewImpl::dragTargetDrop(const WebDragData& webDragData, const WebPoint& pointInViewport,
3711 const WebPoint& screenPoint, 3712 const WebPoint& screenPoint,
3712 int modifiers) 3713 int modifiers)
3713 { 3714 {
3715 WebPoint pointInRootFrame(page()->frameHost().visualViewport().viewportToRoo tFrame(pointInViewport));
3716
3714 DCHECK(m_currentDragData); 3717 DCHECK(m_currentDragData);
3715 m_currentDragData = DataObject::create(webDragData); 3718 m_currentDragData = DataObject::create(webDragData);
3716 3719
3717 WebAutofillClient* autofillClient = mainFrameImpl() ? mainFrameImpl()->autof illClient() : 0; 3720 WebAutofillClient* autofillClient = mainFrameImpl() ? mainFrameImpl()->autof illClient() : 0;
3718 UserGestureNotifier notifier(autofillClient, &m_userGestureObserved); 3721 UserGestureNotifier notifier(autofillClient, &m_userGestureObserved);
3719 3722
3720 // If this webview transitions from the "drop accepting" state to the "not 3723 // If this webview transitions from the "drop accepting" state to the "not
3721 // accepting" state, then our IPC message reply indicating that may be in- 3724 // accepting" state, then our IPC message reply indicating that may be in-
3722 // flight, or else delayed by javascript processing in this webview. If a 3725 // flight, or else delayed by javascript processing in this webview. If a
3723 // drop happens before our IPC reply has reached the browser process, then 3726 // drop happens before our IPC reply has reached the browser process, then
3724 // the browser forwards the drop to this webview. So only allow a drop to 3727 // the browser forwards the drop to this webview. So only allow a drop to
3725 // proceed if our webview m_dragOperation state is not DragOperationNone. 3728 // proceed if our webview m_dragOperation state is not DragOperationNone.
3726 3729
3727 if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop. 3730 if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop.
3728 dragTargetDragLeave(); 3731 dragTargetDragLeave();
3729 return; 3732 return;
3730 } 3733 }
3731 3734
3732 m_currentDragData->setModifiers(modifiers); 3735 m_currentDragData->setModifiers(modifiers);
3733 DragData dragData( 3736 DragData dragData(
3734 m_currentDragData.get(), 3737 m_currentDragData.get(),
3735 clientPoint, 3738 pointInRootFrame,
3736 screenPoint, 3739 screenPoint,
3737 static_cast<DragOperation>(m_operationsAllowed)); 3740 static_cast<DragOperation>(m_operationsAllowed));
3738 3741
3739 UserGestureIndicator gesture(DefinitelyProcessingNewUserGesture); 3742 UserGestureIndicator gesture(DefinitelyProcessingNewUserGesture);
3740 m_page->dragController().performDrag(&dragData); 3743 m_page->dragController().performDrag(&dragData);
3741 3744
3742 m_dragOperation = WebDragOperationNone; 3745 m_dragOperation = WebDragOperationNone;
3743 m_currentDragData = nullptr; 3746 m_currentDragData = nullptr;
3744 } 3747 }
3745 3748
(...skipping 14 matching lines...) Expand all
3760 { 3763 {
3761 Vector<String> convertedWords; 3764 Vector<String> convertedWords;
3762 convertedWords.append(words.data(), words.size()); 3765 convertedWords.append(words.data(), words.size());
3763 3766
3764 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) { 3767 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) {
3765 if (frame->isLocalFrame()) 3768 if (frame->isLocalFrame())
3766 toLocalFrame(frame)->removeSpellingMarkersUnderWords(convertedWords) ; 3769 toLocalFrame(frame)->removeSpellingMarkersUnderWords(convertedWords) ;
3767 } 3770 }
3768 } 3771 }
3769 3772
3770 WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPo int, const WebPoint& screenPoint, DragAction dragAction, int modifiers) 3773 WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& pointInV iewport, const WebPoint& screenPoint, DragAction dragAction, int modifiers)
3771 { 3774 {
3772 DCHECK(m_currentDragData); 3775 DCHECK(m_currentDragData);
3776 WebPoint pointInRootFrame(page()->frameHost().visualViewport().viewportToRoo tFrame(pointInViewport));
3773 3777
3774 m_currentDragData->setModifiers(modifiers); 3778 m_currentDragData->setModifiers(modifiers);
3775 DragData dragData( 3779 DragData dragData(
3776 m_currentDragData.get(), 3780 m_currentDragData.get(),
3777 clientPoint, 3781 pointInRootFrame,
3778 screenPoint, 3782 screenPoint,
3779 static_cast<DragOperation>(m_operationsAllowed)); 3783 static_cast<DragOperation>(m_operationsAllowed));
3780 3784
3781 DragSession dragSession; 3785 DragSession dragSession;
3782 if (dragAction == DragEnter) 3786 if (dragAction == DragEnter)
3783 dragSession = m_page->dragController().dragEntered(&dragData); 3787 dragSession = m_page->dragController().dragEntered(&dragData);
3784 else 3788 else
3785 dragSession = m_page->dragController().dragUpdated(&dragData); 3789 dragSession = m_page->dragController().dragUpdated(&dragData);
3786 3790
3787 DragOperation dropEffect = dragSession.operation; 3791 DragOperation dropEffect = dragSession.operation;
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
4602 return nullptr; 4606 return nullptr;
4603 return focusedFrame; 4607 return focusedFrame;
4604 } 4608 }
4605 4609
4606 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const 4610 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const
4607 { 4611 {
4608 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4612 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4609 } 4613 }
4610 4614
4611 } // namespace blink 4615 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698