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

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

Issue 2408333004: Move persistent gesture state to Document, add DocumentUserGestureToken (Closed)
Patch Set: a 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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "web/WebFrameWidgetImpl.h" 31 #include "web/WebFrameWidgetImpl.h"
32 32
33 #include "core/InputTypeNames.h" 33 #include "core/InputTypeNames.h"
34 #include "core/dom/DocumentUserGestureToken.h"
34 #include "core/editing/EditingUtilities.h" 35 #include "core/editing/EditingUtilities.h"
35 #include "core/editing/Editor.h" 36 #include "core/editing/Editor.h"
36 #include "core/editing/FrameSelection.h" 37 #include "core/editing/FrameSelection.h"
37 #include "core/editing/InputMethodController.h" 38 #include "core/editing/InputMethodController.h"
38 #include "core/editing/PlainTextRange.h" 39 #include "core/editing/PlainTextRange.h"
39 #include "core/frame/FrameHost.h" 40 #include "core/frame/FrameHost.h"
40 #include "core/frame/FrameView.h" 41 #include "core/frame/FrameView.h"
41 #include "core/frame/RemoteFrame.h" 42 #include "core/frame/RemoteFrame.h"
42 #include "core/frame/Settings.h" 43 #include "core/frame/Settings.h"
43 #include "core/frame/VisualViewport.h" 44 #include "core/frame/VisualViewport.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 AtomicString eventType; 345 AtomicString eventType;
345 switch (inputEvent.type) { 346 switch (inputEvent.type) {
346 case WebInputEvent::MouseMove: 347 case WebInputEvent::MouseMove:
347 eventType = EventTypeNames::mousemove; 348 eventType = EventTypeNames::mousemove;
348 break; 349 break;
349 case WebInputEvent::MouseLeave: 350 case WebInputEvent::MouseLeave:
350 eventType = EventTypeNames::mouseout; 351 eventType = EventTypeNames::mouseout;
351 break; 352 break;
352 case WebInputEvent::MouseDown: 353 case WebInputEvent::MouseDown:
353 eventType = EventTypeNames::mousedown; 354 eventType = EventTypeNames::mousedown;
354 gestureIndicator = wrapUnique(new UserGestureIndicator( 355 gestureIndicator = wrapUnique(
355 UserGestureToken::create(UserGestureToken::NewGesture))); 356 new UserGestureIndicator(DocumentUserGestureToken::create(
357 &node->document(), UserGestureToken::NewGesture)));
356 m_mouseCaptureGestureToken = gestureIndicator->currentToken(); 358 m_mouseCaptureGestureToken = gestureIndicator->currentToken();
357 break; 359 break;
358 case WebInputEvent::MouseUp: 360 case WebInputEvent::MouseUp:
359 eventType = EventTypeNames::mouseup; 361 eventType = EventTypeNames::mouseup;
360 gestureIndicator = wrapUnique( 362 gestureIndicator = wrapUnique(
361 new UserGestureIndicator(m_mouseCaptureGestureToken.release())); 363 new UserGestureIndicator(m_mouseCaptureGestureToken.release()));
362 break; 364 break;
363 default: 365 default:
364 NOTREACHED(); 366 NOTREACHED();
365 } 367 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 520 }
519 521
520 // A keypress event is canceled. If an ongoing composition exists, then the 522 // A keypress event is canceled. If an ongoing composition exists, then the
521 // keydown event should have arisen from a handled key (e.g., backspace). 523 // keydown event should have arisen from a handled key (e.g., backspace).
522 // In this case we ignore the cancellation and continue; otherwise (no 524 // In this case we ignore the cancellation and continue; otherwise (no
523 // ongoing composition) we exit and signal success only for attempts to 525 // ongoing composition) we exit and signal success only for attempts to
524 // clear the composition. 526 // clear the composition.
525 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) 527 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition())
526 return text.isEmpty(); 528 return text.isEmpty();
527 529
528 UserGestureIndicator gestureIndicator( 530 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
529 UserGestureToken::create(UserGestureToken::NewGesture)); 531 focused->document(), UserGestureToken::NewGesture));
530 532
531 // When the range of composition underlines overlap with the range between 533 // When the range of composition underlines overlap with the range between
532 // selectionStart and selectionEnd, WebKit somehow won't paint the selection 534 // selectionStart and selectionEnd, WebKit somehow won't paint the selection
533 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). 535 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp).
534 // But the selection range actually takes effect. 536 // But the selection range actually takes effect.
535 inputMethodController.setComposition( 537 inputMethodController.setComposition(
536 String(text), CompositionUnderlineVectorBuilder(underlines), 538 String(text), CompositionUnderlineVectorBuilder(underlines),
537 selectionStart, selectionEnd); 539 selectionStart, selectionEnd);
538 540
539 return text.isEmpty() || inputMethodController.hasComposition(); 541 return text.isEmpty() || inputMethodController.hasComposition();
540 } 542 }
541 543
542 // TODO(ekaramad):These methods are almost duplicated in WebViewImpl as well. 544 // TODO(ekaramad):These methods are almost duplicated in WebViewImpl as well.
543 // This code needs to be refactored (http://crbug.com/629721). 545 // This code needs to be refactored (http://crbug.com/629721).
544 bool WebFrameWidgetImpl::commitText(const WebString& text, 546 bool WebFrameWidgetImpl::commitText(const WebString& text,
545 int relativeCaretPosition) { 547 int relativeCaretPosition) {
546 UserGestureIndicator gestureIndicator(
547 UserGestureToken::create(UserGestureToken::NewGesture));
548 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 548 LocalFrame* focused = focusedLocalFrameAvailableForIme();
549 if (!focused) 549 if (!focused)
550 return false; 550 return false;
551 551
552 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
553 focused->document(), UserGestureToken::NewGesture));
554
552 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 555 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
553 return plugin->commitText(text, relativeCaretPosition); 556 return plugin->commitText(text, relativeCaretPosition);
554 557
555 return focused->inputMethodController().commitText(text, 558 return focused->inputMethodController().commitText(text,
556 relativeCaretPosition); 559 relativeCaretPosition);
557 } 560 }
558 561
559 bool WebFrameWidgetImpl::finishComposingText( 562 bool WebFrameWidgetImpl::finishComposingText(
560 ConfirmCompositionBehavior selectionBehavior) { 563 ConfirmCompositionBehavior selectionBehavior) {
561 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 564 LocalFrame* focused = focusedLocalFrameAvailableForIme();
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 return flags; 1521 return flags;
1519 } 1522 }
1520 1523
1521 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { 1524 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const {
1522 if (!m_imeAcceptEvents) 1525 if (!m_imeAcceptEvents)
1523 return nullptr; 1526 return nullptr;
1524 return focusedLocalFrameInWidget(); 1527 return focusedLocalFrameInWidget();
1525 } 1528 }
1526 1529
1527 } // namespace blink 1530 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698