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

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

Issue 2408333004: Move persistent gesture state to Document, add DocumentUserGestureToken (Closed)
Patch Set: Re-add dropped null check Created 4 years, 1 month 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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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/dom/DocumentUserGestureToken.h"
33 #include "core/editing/EditingUtilities.h" 34 #include "core/editing/EditingUtilities.h"
34 #include "core/editing/Editor.h" 35 #include "core/editing/Editor.h"
35 #include "core/editing/FrameSelection.h" 36 #include "core/editing/FrameSelection.h"
36 #include "core/editing/InputMethodController.h" 37 #include "core/editing/InputMethodController.h"
37 #include "core/editing/PlainTextRange.h" 38 #include "core/editing/PlainTextRange.h"
38 #include "core/frame/FrameHost.h" 39 #include "core/frame/FrameHost.h"
39 #include "core/frame/FrameView.h" 40 #include "core/frame/FrameView.h"
40 #include "core/frame/RemoteFrame.h" 41 #include "core/frame/RemoteFrame.h"
41 #include "core/frame/Settings.h" 42 #include "core/frame/Settings.h"
42 #include "core/frame/VisualViewport.h" 43 #include "core/frame/VisualViewport.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 AtomicString eventType; 343 AtomicString eventType;
343 switch (inputEvent.type) { 344 switch (inputEvent.type) {
344 case WebInputEvent::MouseMove: 345 case WebInputEvent::MouseMove:
345 eventType = EventTypeNames::mousemove; 346 eventType = EventTypeNames::mousemove;
346 break; 347 break;
347 case WebInputEvent::MouseLeave: 348 case WebInputEvent::MouseLeave:
348 eventType = EventTypeNames::mouseout; 349 eventType = EventTypeNames::mouseout;
349 break; 350 break;
350 case WebInputEvent::MouseDown: 351 case WebInputEvent::MouseDown:
351 eventType = EventTypeNames::mousedown; 352 eventType = EventTypeNames::mousedown;
352 gestureIndicator = wrapUnique(new UserGestureIndicator( 353 gestureIndicator = wrapUnique(
353 UserGestureToken::create(UserGestureToken::NewGesture))); 354 new UserGestureIndicator(DocumentUserGestureToken::create(
355 &node->document(), UserGestureToken::NewGesture)));
354 m_mouseCaptureGestureToken = gestureIndicator->currentToken(); 356 m_mouseCaptureGestureToken = gestureIndicator->currentToken();
355 break; 357 break;
356 case WebInputEvent::MouseUp: 358 case WebInputEvent::MouseUp:
357 eventType = EventTypeNames::mouseup; 359 eventType = EventTypeNames::mouseup;
358 gestureIndicator = wrapUnique( 360 gestureIndicator = wrapUnique(
359 new UserGestureIndicator(m_mouseCaptureGestureToken.release())); 361 new UserGestureIndicator(m_mouseCaptureGestureToken.release()));
360 break; 362 break;
361 default: 363 default:
362 NOTREACHED(); 364 NOTREACHED();
363 } 365 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 518 }
517 519
518 // A keypress event is canceled. If an ongoing composition exists, then the 520 // A keypress event is canceled. If an ongoing composition exists, then the
519 // keydown event should have arisen from a handled key (e.g., backspace). 521 // keydown event should have arisen from a handled key (e.g., backspace).
520 // In this case we ignore the cancellation and continue; otherwise (no 522 // In this case we ignore the cancellation and continue; otherwise (no
521 // ongoing composition) we exit and signal success only for attempts to 523 // ongoing composition) we exit and signal success only for attempts to
522 // clear the composition. 524 // clear the composition.
523 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) 525 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition())
524 return text.isEmpty(); 526 return text.isEmpty();
525 527
526 UserGestureIndicator gestureIndicator( 528 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
527 UserGestureToken::create(UserGestureToken::NewGesture)); 529 focused->document(), UserGestureToken::NewGesture));
528 530
529 // When the range of composition underlines overlap with the range between 531 // When the range of composition underlines overlap with the range between
530 // selectionStart and selectionEnd, WebKit somehow won't paint the selection 532 // selectionStart and selectionEnd, WebKit somehow won't paint the selection
531 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). 533 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp).
532 // But the selection range actually takes effect. 534 // But the selection range actually takes effect.
533 inputMethodController.setComposition( 535 inputMethodController.setComposition(
534 String(text), CompositionUnderlineVectorBuilder(underlines), 536 String(text), CompositionUnderlineVectorBuilder(underlines),
535 selectionStart, selectionEnd); 537 selectionStart, selectionEnd);
536 538
537 return text.isEmpty() || inputMethodController.hasComposition(); 539 return text.isEmpty() || inputMethodController.hasComposition();
538 } 540 }
539 541
540 // TODO(ekaramad):These methods are almost duplicated in WebViewImpl as well. 542 // TODO(ekaramad):These methods are almost duplicated in WebViewImpl as well.
541 // This code needs to be refactored (http://crbug.com/629721). 543 // This code needs to be refactored (http://crbug.com/629721).
542 bool WebFrameWidgetImpl::commitText(const WebString& text, 544 bool WebFrameWidgetImpl::commitText(const WebString& text,
543 int relativeCaretPosition) { 545 int relativeCaretPosition) {
544 UserGestureIndicator gestureIndicator(
545 UserGestureToken::create(UserGestureToken::NewGesture));
546 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 546 LocalFrame* focused = focusedLocalFrameAvailableForIme();
547 if (!focused) 547 if (!focused)
548 return false; 548 return false;
549 549
550 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
551 focused->document(), UserGestureToken::NewGesture));
552
550 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 553 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
551 return plugin->commitText(text, relativeCaretPosition); 554 return plugin->commitText(text, relativeCaretPosition);
552 555
553 return focused->inputMethodController().commitText(text, 556 return focused->inputMethodController().commitText(text,
554 relativeCaretPosition); 557 relativeCaretPosition);
555 } 558 }
556 559
557 bool WebFrameWidgetImpl::finishComposingText( 560 bool WebFrameWidgetImpl::finishComposingText(
558 ConfirmCompositionBehavior selectionBehavior) { 561 ConfirmCompositionBehavior selectionBehavior) {
559 LocalFrame* focused = focusedLocalFrameAvailableForIme(); 562 LocalFrame* focused = focusedLocalFrameAvailableForIme();
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 return nullptr; 1329 return nullptr;
1327 } 1330 }
1328 1331
1329 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { 1332 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const {
1330 if (!m_imeAcceptEvents) 1333 if (!m_imeAcceptEvents)
1331 return nullptr; 1334 return nullptr;
1332 return focusedLocalFrameInWidget(); 1335 return focusedLocalFrameInWidget();
1333 } 1336 }
1334 1337
1335 } // namespace blink 1338 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698