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

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

Issue 2401123002: UserGestureIndicator is a mess. Clean it up. (Closed)
Patch Set: Callback cleanup, comments 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
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 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 AtomicString eventType; 2287 AtomicString eventType;
2288 switch (inputEvent.type) { 2288 switch (inputEvent.type) {
2289 case WebInputEvent::MouseMove: 2289 case WebInputEvent::MouseMove:
2290 eventType = EventTypeNames::mousemove; 2290 eventType = EventTypeNames::mousemove;
2291 break; 2291 break;
2292 case WebInputEvent::MouseLeave: 2292 case WebInputEvent::MouseLeave:
2293 eventType = EventTypeNames::mouseout; 2293 eventType = EventTypeNames::mouseout;
2294 break; 2294 break;
2295 case WebInputEvent::MouseDown: 2295 case WebInputEvent::MouseDown:
2296 eventType = EventTypeNames::mousedown; 2296 eventType = EventTypeNames::mousedown;
2297 gestureIndicator = wrapUnique( 2297 gestureIndicator = wrapUnique(new UserGestureIndicator(
2298 new UserGestureIndicator(DefinitelyProcessingNewUserGesture)); 2298 UserGestureToken::create(UserGestureToken::NewGesture)));
2299 m_mouseCaptureGestureToken = gestureIndicator->currentToken(); 2299 m_mouseCaptureGestureToken = gestureIndicator->currentToken();
2300 break; 2300 break;
2301 case WebInputEvent::MouseUp: 2301 case WebInputEvent::MouseUp:
2302 eventType = EventTypeNames::mouseup; 2302 eventType = EventTypeNames::mouseup;
2303 gestureIndicator = wrapUnique( 2303 gestureIndicator = wrapUnique(
2304 new UserGestureIndicator(m_mouseCaptureGestureToken.release())); 2304 new UserGestureIndicator(m_mouseCaptureGestureToken.release()));
2305 break; 2305 break;
2306 default: 2306 default:
2307 NOTREACHED(); 2307 NOTREACHED();
2308 } 2308 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 } 2461 }
2462 2462
2463 // A keypress event is canceled. If an ongoing composition exists, then the 2463 // A keypress event is canceled. If an ongoing composition exists, then the
2464 // keydown event should have arisen from a handled key (e.g., backspace). 2464 // keydown event should have arisen from a handled key (e.g., backspace).
2465 // In this case we ignore the cancellation and continue; otherwise (no 2465 // In this case we ignore the cancellation and continue; otherwise (no
2466 // ongoing composition) we exit and signal success only for attempts to 2466 // ongoing composition) we exit and signal success only for attempts to
2467 // clear the composition. 2467 // clear the composition.
2468 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) 2468 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition())
2469 return text.isEmpty(); 2469 return text.isEmpty();
2470 2470
2471 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 2471 UserGestureIndicator gestureIndicator(
2472 UserGestureToken::create(UserGestureToken::NewGesture));
2472 2473
2473 // When the range of composition underlines overlap with the range between 2474 // When the range of composition underlines overlap with the range between
2474 // selectionStart and selectionEnd, WebKit somehow won't paint the selection 2475 // selectionStart and selectionEnd, WebKit somehow won't paint the selection
2475 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). 2476 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp).
2476 // But the selection range actually takes effect. 2477 // But the selection range actually takes effect.
2477 inputMethodController.setComposition( 2478 inputMethodController.setComposition(
2478 String(text), CompositionUnderlineVectorBuilder(underlines), 2479 String(text), CompositionUnderlineVectorBuilder(underlines),
2479 selectionStart, selectionEnd); 2480 selectionStart, selectionEnd);
2480 2481
2481 return text.isEmpty() || inputMethodController.hasComposition(); 2482 return text.isEmpty() || inputMethodController.hasComposition();
(...skipping 10 matching lines...) Expand all
2492 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 2493 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
2493 return plugin->finishComposingText(selectionBehavior); 2494 return plugin->finishComposingText(selectionBehavior);
2494 2495
2495 return focused->inputMethodController().finishComposingText( 2496 return focused->inputMethodController().finishComposingText(
2496 selectionBehavior == KeepSelection 2497 selectionBehavior == KeepSelection
2497 ? InputMethodController::KeepSelection 2498 ? InputMethodController::KeepSelection
2498 : InputMethodController::DoNotKeepSelection); 2499 : InputMethodController::DoNotKeepSelection);
2499 } 2500 }
2500 2501
2501 bool WebViewImpl::commitText(const WebString& text, int relativeCaretPosition) { 2502 bool WebViewImpl::commitText(const WebString& text, int relativeCaretPosition) {
2502 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 2503 UserGestureIndicator gestureIndicator(
2504 UserGestureToken::create(UserGestureToken::NewGesture));
2503 2505
2504 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 2506 LocalFrame* focused = focusedLocalFrameAvailableForIme();
2505 if (!focused) 2507 if (!focused)
2506 return false; 2508 return false;
2507 2509
2508 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 2510 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
2509 return plugin->commitText(text, relativeCaretPosition); 2511 return plugin->commitText(text, relativeCaretPosition);
2510 2512
2511 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 2513 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
2512 // needs to be audited. See http://crbug.com/590369 for more details. 2514 // needs to be audited. See http://crbug.com/590369 for more details.
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3866 if (m_dragOperation == 3868 if (m_dragOperation ==
3867 WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop. 3869 WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop.
3868 dragTargetDragLeave(); 3870 dragTargetDragLeave();
3869 return; 3871 return;
3870 } 3872 }
3871 3873
3872 m_currentDragData->setModifiers(modifiers); 3874 m_currentDragData->setModifiers(modifiers);
3873 DragData dragData(m_currentDragData.get(), pointInRootFrame, screenPoint, 3875 DragData dragData(m_currentDragData.get(), pointInRootFrame, screenPoint,
3874 static_cast<DragOperation>(m_operationsAllowed)); 3876 static_cast<DragOperation>(m_operationsAllowed));
3875 3877
3876 UserGestureIndicator gesture(DefinitelyProcessingNewUserGesture); 3878 UserGestureIndicator gesture(
3879 UserGestureToken::create(UserGestureToken::NewGesture));
3877 m_page->dragController().performDrag(&dragData); 3880 m_page->dragController().performDrag(&dragData);
3878 3881
3879 m_dragOperation = WebDragOperationNone; 3882 m_dragOperation = WebDragOperationNone;
3880 m_currentDragData = nullptr; 3883 m_currentDragData = nullptr;
3881 } 3884 }
3882 3885
3883 void WebViewImpl::spellingMarkers(WebVector<uint32_t>* markers) { 3886 void WebViewImpl::spellingMarkers(WebVector<uint32_t>* markers) {
3884 Vector<uint32_t> result; 3887 Vector<uint32_t> result;
3885 for (Frame* frame = m_page->mainFrame(); frame; 3888 for (Frame* frame = m_page->mainFrame(); frame;
3886 frame = frame->tree().traverseNext()) { 3889 frame = frame->tree().traverseNext()) {
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
4662 if (m_layerTreeView) 4665 if (m_layerTreeView)
4663 m_layerTreeView->setVisible(isVisible); 4666 m_layerTreeView->setVisible(isVisible);
4664 } 4667 }
4665 4668
4666 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) { 4669 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) {
4667 std::unique_ptr<UserGestureIndicator> gestureIndicator; 4670 std::unique_ptr<UserGestureIndicator> gestureIndicator;
4668 AtomicString eventType; 4671 AtomicString eventType;
4669 switch (event.type) { 4672 switch (event.type) {
4670 case WebInputEvent::MouseDown: 4673 case WebInputEvent::MouseDown:
4671 eventType = EventTypeNames::mousedown; 4674 eventType = EventTypeNames::mousedown;
4672 gestureIndicator = wrapUnique( 4675 gestureIndicator = wrapUnique(new UserGestureIndicator(
4673 new UserGestureIndicator(DefinitelyProcessingNewUserGesture)); 4676 UserGestureToken::create(UserGestureToken::NewGesture)));
4674 m_pointerLockGestureToken = gestureIndicator->currentToken(); 4677 m_pointerLockGestureToken = gestureIndicator->currentToken();
4675 break; 4678 break;
4676 case WebInputEvent::MouseUp: 4679 case WebInputEvent::MouseUp:
4677 eventType = EventTypeNames::mouseup; 4680 eventType = EventTypeNames::mouseup;
4678 gestureIndicator = wrapUnique( 4681 gestureIndicator = wrapUnique(
4679 new UserGestureIndicator(m_pointerLockGestureToken.release())); 4682 new UserGestureIndicator(m_pointerLockGestureToken.release()));
4680 break; 4683 break;
4681 case WebInputEvent::MouseMove: 4684 case WebInputEvent::MouseMove:
4682 eventType = EventTypeNames::mousemove; 4685 eventType = EventTypeNames::mousemove;
4683 break; 4686 break;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4739 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4742 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4740 return nullptr; 4743 return nullptr;
4741 return focusedFrame; 4744 return focusedFrame;
4742 } 4745 }
4743 4746
4744 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4747 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4745 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4748 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4746 } 4749 }
4747 4750
4748 } // namespace blink 4751 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebUserGestureToken.cpp ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698