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

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

Issue 879333002: Support buttons attribute for drag event (blink side). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 STATIC_ASSERT_MATCHING_ENUM(DragOperationCopy); 226 STATIC_ASSERT_MATCHING_ENUM(DragOperationCopy);
227 STATIC_ASSERT_MATCHING_ENUM(DragOperationLink); 227 STATIC_ASSERT_MATCHING_ENUM(DragOperationLink);
228 STATIC_ASSERT_MATCHING_ENUM(DragOperationGeneric); 228 STATIC_ASSERT_MATCHING_ENUM(DragOperationGeneric);
229 STATIC_ASSERT_MATCHING_ENUM(DragOperationPrivate); 229 STATIC_ASSERT_MATCHING_ENUM(DragOperationPrivate);
230 STATIC_ASSERT_MATCHING_ENUM(DragOperationMove); 230 STATIC_ASSERT_MATCHING_ENUM(DragOperationMove);
231 STATIC_ASSERT_MATCHING_ENUM(DragOperationDelete); 231 STATIC_ASSERT_MATCHING_ENUM(DragOperationDelete);
232 STATIC_ASSERT_MATCHING_ENUM(DragOperationEvery); 232 STATIC_ASSERT_MATCHING_ENUM(DragOperationEvery);
233 233
234 static bool shouldUseExternalPopupMenus = false; 234 static bool shouldUseExternalPopupMenus = false;
235 235
236 static int webInputEventKeyStateToPlatformEventKeyState(int webInputEventKeyStat e)
237 {
238 int platformEventKeyState = 0;
239 if (webInputEventKeyState & WebInputEvent::ShiftKey)
240 platformEventKeyState = platformEventKeyState | PlatformEvent::ShiftKey;
241 if (webInputEventKeyState & WebInputEvent::ControlKey)
242 platformEventKeyState = platformEventKeyState | PlatformEvent::CtrlKey;
243 if (webInputEventKeyState & WebInputEvent::AltKey)
244 platformEventKeyState = platformEventKeyState | PlatformEvent::AltKey;
245 if (webInputEventKeyState & WebInputEvent::MetaKey)
246 platformEventKeyState = platformEventKeyState | PlatformEvent::MetaKey;
247 return platformEventKeyState;
248 }
249
250 namespace { 236 namespace {
251 237
252 class UserGestureNotifier { 238 class UserGestureNotifier {
253 public: 239 public:
254 // If a UserGestureIndicator is created for a user gesture since the last 240 // If a UserGestureIndicator is created for a user gesture since the last
255 // page load and *userGestureObserved is false, the UserGestureNotifier 241 // page load and *userGestureObserved is false, the UserGestureNotifier
256 // will notify the client and set *userGestureObserved to true. 242 // will notify the client and set *userGestureObserved to true.
257 UserGestureNotifier(WebAutofillClient*, bool* userGestureObserved); 243 UserGestureNotifier(WebAutofillClient*, bool* userGestureObserved);
258 ~UserGestureNotifier(); 244 ~UserGestureNotifier();
259 245
(...skipping 3315 matching lines...) Expand 10 before | Expand all | Expand 10 after
3575 m_page->dragController().dragEnded(); 3561 m_page->dragController().dragEnded();
3576 m_doingDragAndDrop = false; 3562 m_doingDragAndDrop = false;
3577 } 3563 }
3578 } 3564 }
3579 3565
3580 WebDragOperation WebViewImpl::dragTargetDragEnter( 3566 WebDragOperation WebViewImpl::dragTargetDragEnter(
3581 const WebDragData& webDragData, 3567 const WebDragData& webDragData,
3582 const WebPoint& clientPoint, 3568 const WebPoint& clientPoint,
3583 const WebPoint& screenPoint, 3569 const WebPoint& screenPoint,
3584 WebDragOperationsMask operationsAllowed, 3570 WebDragOperationsMask operationsAllowed,
3585 int keyModifiers) 3571 int modifiers)
3586 { 3572 {
3587 ASSERT(!m_currentDragData); 3573 ASSERT(!m_currentDragData);
3588 3574
3589 m_currentDragData = webDragData.getValue(); 3575 m_currentDragData = webDragData.getValue();
3590 m_operationsAllowed = operationsAllowed; 3576 m_operationsAllowed = operationsAllowed;
3591 3577
3592 return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter, keyMod ifiers); 3578 return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter, modifi ers);
3593 } 3579 }
3594 3580
3595 WebDragOperation WebViewImpl::dragTargetDragOver( 3581 WebDragOperation WebViewImpl::dragTargetDragOver(
3596 const WebPoint& clientPoint, 3582 const WebPoint& clientPoint,
3597 const WebPoint& screenPoint, 3583 const WebPoint& screenPoint,
3598 WebDragOperationsMask operationsAllowed, 3584 WebDragOperationsMask operationsAllowed,
3599 int keyModifiers) 3585 int modifiers)
3600 { 3586 {
3601 m_operationsAllowed = operationsAllowed; 3587 m_operationsAllowed = operationsAllowed;
3602 3588
3603 return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragOver, keyModi fiers); 3589 return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragOver, modifie rs);
3604 } 3590 }
3605 3591
3606 void WebViewImpl::dragTargetDragLeave() 3592 void WebViewImpl::dragTargetDragLeave()
3607 { 3593 {
3608 ASSERT(m_currentDragData); 3594 ASSERT(m_currentDragData);
3609 3595
3610 DragData dragData( 3596 DragData dragData(
3611 m_currentDragData.get(), 3597 m_currentDragData.get(),
3612 IntPoint(), 3598 IntPoint(),
3613 IntPoint(), 3599 IntPoint(),
3614 static_cast<DragOperation>(m_operationsAllowed)); 3600 static_cast<DragOperation>(m_operationsAllowed));
3615 3601
3616 m_page->dragController().dragExited(&dragData); 3602 m_page->dragController().dragExited(&dragData);
3617 3603
3618 // FIXME: why is the drag scroll timer not stopped here? 3604 // FIXME: why is the drag scroll timer not stopped here?
3619 3605
3620 m_dragOperation = WebDragOperationNone; 3606 m_dragOperation = WebDragOperationNone;
3621 m_currentDragData = nullptr; 3607 m_currentDragData = nullptr;
3622 } 3608 }
3623 3609
3624 void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint, 3610 void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
3625 const WebPoint& screenPoint, 3611 const WebPoint& screenPoint,
3626 int keyModifiers) 3612 int modifiers)
3627 { 3613 {
3628 ASSERT(m_currentDragData); 3614 ASSERT(m_currentDragData);
3629 3615
3630 WebAutofillClient* autofillClient = mainFrameImpl() ? mainFrameImpl()->autof illClient() : 0; 3616 WebAutofillClient* autofillClient = mainFrameImpl() ? mainFrameImpl()->autof illClient() : 0;
3631 UserGestureNotifier notifier(autofillClient, &m_userGestureObserved); 3617 UserGestureNotifier notifier(autofillClient, &m_userGestureObserved);
3632 3618
3633 // If this webview transitions from the "drop accepting" state to the "not 3619 // If this webview transitions from the "drop accepting" state to the "not
3634 // accepting" state, then our IPC message reply indicating that may be in- 3620 // accepting" state, then our IPC message reply indicating that may be in-
3635 // flight, or else delayed by javascript processing in this webview. If a 3621 // flight, or else delayed by javascript processing in this webview. If a
3636 // drop happens before our IPC reply has reached the browser process, then 3622 // drop happens before our IPC reply has reached the browser process, then
3637 // the browser forwards the drop to this webview. So only allow a drop to 3623 // the browser forwards the drop to this webview. So only allow a drop to
3638 // proceed if our webview m_dragOperation state is not DragOperationNone. 3624 // proceed if our webview m_dragOperation state is not DragOperationNone.
3639 3625
3640 if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop. 3626 if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop.
3641 dragTargetDragLeave(); 3627 dragTargetDragLeave();
3642 return; 3628 return;
3643 } 3629 }
3644 3630
3645 m_currentDragData->setModifierKeyState(webInputEventKeyStateToPlatformEventK eyState(keyModifiers)); 3631 m_currentDragData->setModifiers(toPlatformMouseEventModifiers(modifiers));
3646 DragData dragData( 3632 DragData dragData(
3647 m_currentDragData.get(), 3633 m_currentDragData.get(),
3648 clientPoint, 3634 clientPoint,
3649 screenPoint, 3635 screenPoint,
3650 static_cast<DragOperation>(m_operationsAllowed)); 3636 static_cast<DragOperation>(m_operationsAllowed));
3651 3637
3652 UserGestureIndicator gesture(DefinitelyProcessingNewUserGesture); 3638 UserGestureIndicator gesture(DefinitelyProcessingNewUserGesture);
3653 m_page->dragController().performDrag(&dragData); 3639 m_page->dragController().performDrag(&dragData);
3654 3640
3655 m_dragOperation = WebDragOperationNone; 3641 m_dragOperation = WebDragOperationNone;
(...skipping 17 matching lines...) Expand all
3673 { 3659 {
3674 Vector<String> convertedWords; 3660 Vector<String> convertedWords;
3675 convertedWords.append(words.data(), words.size()); 3661 convertedWords.append(words.data(), words.size());
3676 3662
3677 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) { 3663 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) {
3678 if (frame->isLocalFrame()) 3664 if (frame->isLocalFrame())
3679 toLocalFrame(frame)->removeSpellingMarkersUnderWords(convertedWords) ; 3665 toLocalFrame(frame)->removeSpellingMarkersUnderWords(convertedWords) ;
3680 } 3666 }
3681 } 3667 }
3682 3668
3683 WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPo int, const WebPoint& screenPoint, DragAction dragAction, int keyModifiers) 3669 WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPo int, const WebPoint& screenPoint, DragAction dragAction, int modifiers)
3684 { 3670 {
3685 ASSERT(m_currentDragData); 3671 ASSERT(m_currentDragData);
3686 3672
3687 m_currentDragData->setModifierKeyState(webInputEventKeyStateToPlatformEventK eyState(keyModifiers)); 3673 m_currentDragData->setModifiers(toPlatformMouseEventModifiers(modifiers));
3688 DragData dragData( 3674 DragData dragData(
3689 m_currentDragData.get(), 3675 m_currentDragData.get(),
3690 clientPoint, 3676 clientPoint,
3691 screenPoint, 3677 screenPoint,
3692 static_cast<DragOperation>(m_operationsAllowed)); 3678 static_cast<DragOperation>(m_operationsAllowed));
3693 3679
3694 DragSession dragSession; 3680 DragSession dragSession;
3695 if (dragAction == DragEnter) 3681 if (dragAction == DragEnter)
3696 dragSession = m_page->dragController().dragEntered(&dragData); 3682 dragSession = m_page->dragController().dragEntered(&dragData);
3697 else 3683 else
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
4606 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4592 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4607 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4593 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4608 } 4594 }
4609 4595
4610 void WebViewImpl::forceNextWebGLContextCreationToFail() 4596 void WebViewImpl::forceNextWebGLContextCreationToFail()
4611 { 4597 {
4612 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4598 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4613 } 4599 }
4614 4600
4615 } // namespace blink 4601 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698