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

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

Issue 2401123002: UserGestureIndicator is a mess. Clean it up. (Closed)
Patch Set: Fix tests 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 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 if (m_dragOperation == 3872 if (m_dragOperation ==
3871 WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop. 3873 WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop.
3872 dragTargetDragLeave(); 3874 dragTargetDragLeave();
3873 return; 3875 return;
3874 } 3876 }
3875 3877
3876 m_currentDragData->setModifiers(modifiers); 3878 m_currentDragData->setModifiers(modifiers);
3877 DragData dragData(m_currentDragData.get(), pointInRootFrame, screenPoint, 3879 DragData dragData(m_currentDragData.get(), pointInRootFrame, screenPoint,
3878 static_cast<DragOperation>(m_operationsAllowed)); 3880 static_cast<DragOperation>(m_operationsAllowed));
3879 3881
3880 UserGestureIndicator gesture(DefinitelyProcessingNewUserGesture); 3882 UserGestureIndicator gesture(
3883 UserGestureToken::create(UserGestureToken::NewGesture));
3881 m_page->dragController().performDrag(&dragData); 3884 m_page->dragController().performDrag(&dragData);
3882 3885
3883 m_dragOperation = WebDragOperationNone; 3886 m_dragOperation = WebDragOperationNone;
3884 m_currentDragData = nullptr; 3887 m_currentDragData = nullptr;
3885 } 3888 }
3886 3889
3887 void WebViewImpl::spellingMarkers(WebVector<uint32_t>* markers) { 3890 void WebViewImpl::spellingMarkers(WebVector<uint32_t>* markers) {
3888 Vector<uint32_t> result; 3891 Vector<uint32_t> result;
3889 for (Frame* frame = m_page->mainFrame(); frame; 3892 for (Frame* frame = m_page->mainFrame(); frame;
3890 frame = frame->tree().traverseNext()) { 3893 frame = frame->tree().traverseNext()) {
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
4666 if (m_layerTreeView) 4669 if (m_layerTreeView)
4667 m_layerTreeView->setVisible(isVisible); 4670 m_layerTreeView->setVisible(isVisible);
4668 } 4671 }
4669 4672
4670 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) { 4673 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) {
4671 std::unique_ptr<UserGestureIndicator> gestureIndicator; 4674 std::unique_ptr<UserGestureIndicator> gestureIndicator;
4672 AtomicString eventType; 4675 AtomicString eventType;
4673 switch (event.type) { 4676 switch (event.type) {
4674 case WebInputEvent::MouseDown: 4677 case WebInputEvent::MouseDown:
4675 eventType = EventTypeNames::mousedown; 4678 eventType = EventTypeNames::mousedown;
4676 gestureIndicator = wrapUnique( 4679 gestureIndicator = wrapUnique(new UserGestureIndicator(
4677 new UserGestureIndicator(DefinitelyProcessingNewUserGesture)); 4680 UserGestureToken::create(UserGestureToken::NewGesture)));
4678 m_pointerLockGestureToken = gestureIndicator->currentToken(); 4681 m_pointerLockGestureToken = gestureIndicator->currentToken();
4679 break; 4682 break;
4680 case WebInputEvent::MouseUp: 4683 case WebInputEvent::MouseUp:
4681 eventType = EventTypeNames::mouseup; 4684 eventType = EventTypeNames::mouseup;
4682 gestureIndicator = wrapUnique( 4685 gestureIndicator = wrapUnique(
4683 new UserGestureIndicator(m_pointerLockGestureToken.release())); 4686 new UserGestureIndicator(m_pointerLockGestureToken.release()));
4684 break; 4687 break;
4685 case WebInputEvent::MouseMove: 4688 case WebInputEvent::MouseMove:
4686 eventType = EventTypeNames::mousemove; 4689 eventType = EventTypeNames::mousemove;
4687 break; 4690 break;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4743 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4746 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4744 return nullptr; 4747 return nullptr;
4745 return focusedFrame; 4748 return focusedFrame;
4746 } 4749 }
4747 4750
4748 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4751 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4749 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4752 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4750 } 4753 }
4751 4754
4752 } // namespace blink 4755 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698