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

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

Issue 956133002: [IME] Differentiate s_suppressNextKeypressEvent in WebViewImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing test, reducing non-essential deltas. Created 5 years, 9 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
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 , m_doubleTapZoomPageScaleFactor(0) 382 , m_doubleTapZoomPageScaleFactor(0)
383 , m_doubleTapZoomPending(false) 383 , m_doubleTapZoomPending(false)
384 , m_enableFakePageScaleAnimationForTesting(false) 384 , m_enableFakePageScaleAnimationForTesting(false)
385 , m_fakePageScaleAnimationPageScaleFactor(0) 385 , m_fakePageScaleAnimationPageScaleFactor(0)
386 , m_fakePageScaleAnimationUseAnchor(false) 386 , m_fakePageScaleAnimationUseAnchor(false)
387 , m_contextMenuAllowed(false) 387 , m_contextMenuAllowed(false)
388 , m_doingDragAndDrop(false) 388 , m_doingDragAndDrop(false)
389 , m_ignoreInputEvents(false) 389 , m_ignoreInputEvents(false)
390 , m_compositorDeviceScaleFactorOverride(0) 390 , m_compositorDeviceScaleFactorOverride(0)
391 , m_rootLayerScale(1) 391 , m_rootLayerScale(1)
392 , m_suppressNextKeypressEvent(false) 392 , m_suppressNextKeypressEvent(Suppress_None)
393 , m_imeAcceptEvents(true) 393 , m_imeAcceptEvents(true)
394 , m_operationsAllowed(WebDragOperationNone) 394 , m_operationsAllowed(WebDragOperationNone)
395 , m_dragOperation(WebDragOperationNone) 395 , m_dragOperation(WebDragOperationNone)
396 , m_isTransparent(false) 396 , m_isTransparent(false)
397 , m_tabsToLinks(false) 397 , m_tabsToLinks(false)
398 , m_layerTreeView(0) 398 , m_layerTreeView(0)
399 , m_rootLayer(0) 399 , m_rootLayer(0)
400 , m_rootGraphicsLayer(0) 400 , m_rootGraphicsLayer(0)
401 , m_rootTransformLayer(0) 401 , m_rootTransformLayer(0)
402 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this))) 402 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this)))
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 || (event.type == WebInputEvent::KeyDown) 986 || (event.type == WebInputEvent::KeyDown)
987 || (event.type == WebInputEvent::KeyUp)); 987 || (event.type == WebInputEvent::KeyUp));
988 988
989 // Halt an in-progress fling on a key event. 989 // Halt an in-progress fling on a key event.
990 endActiveFlingAnimation(); 990 endActiveFlingAnimation();
991 991
992 // Please refer to the comments explaining the m_suppressNextKeypressEvent 992 // Please refer to the comments explaining the m_suppressNextKeypressEvent
993 // member. 993 // member.
994 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by 994 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by
995 // Webkit. A keyDown event is typically associated with a keyPress(char) 995 // Webkit. A keyDown event is typically associated with a keyPress(char)
996 // event and a keyUp event. We reset this flag here as this is a new keyDown 996 // event and a keyUp event. We reset this state here as this is a new keyDow n
997 // event. 997 // event.
998 m_suppressNextKeypressEvent = false; 998 m_suppressNextKeypressEvent = Suppress_None;
999 999
1000 // If there is a select popup, it should be the one processing the event, 1000 // If there is a select popup, it should be the one processing the event,
1001 // not the page. 1001 // not the page.
1002 if (m_selectPopup) 1002 if (m_selectPopup)
1003 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 1003 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
1004 if (m_pagePopup) { 1004 if (m_pagePopup) {
1005 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 1005 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
1006 // We need to ignore the next Char event after this otherwise pressing 1006 // We need to ignore the next Char event after this otherwise pressing
1007 // enter when selecting an item in the popup will go to the page. 1007 // enter when selecting an item in the popup will go to the page.
1008 if (WebInputEvent::RawKeyDown == event.type) 1008 if (WebInputEvent::RawKeyDown == event.type)
1009 m_suppressNextKeypressEvent = true; 1009 m_suppressNextKeypressEvent = Suppress_KeyEventCanceled;
James Su 2015/02/27 01:46:18 Why it's Canceled rather than Handled?
1010 return true; 1010 return true;
1011 } 1011 }
1012 1012
1013 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); 1013 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame();
1014 if (focusedFrame && focusedFrame->isRemoteFrame()) { 1014 if (focusedFrame && focusedFrame->isRemoteFrame()) {
1015 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr ame(focusedFrame.get())); 1015 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr ame(focusedFrame.get()));
1016 webFrame->client()->forwardInputEvent(&event); 1016 webFrame->client()->forwardInputEvent(&event);
1017 return true; 1017 return true;
1018 } 1018 }
1019 1019
1020 if (!focusedFrame || !focusedFrame->isLocalFrame()) 1020 if (!focusedFrame || !focusedFrame->isLocalFrame())
1021 return false; 1021 return false;
1022 1022
1023 LocalFrame* frame = toLocalFrame(focusedFrame.get()); 1023 LocalFrame* frame = toLocalFrame(focusedFrame.get());
1024 1024
1025 PlatformKeyboardEventBuilder evt(event); 1025 PlatformKeyboardEventBuilder evt(event);
1026 1026
1027 if (frame->eventHandler().keyEvent(evt)) { 1027 if (frame->eventHandler().keyEvent(evt)) {
1028 if (WebInputEvent::RawKeyDown == event.type) { 1028 if (WebInputEvent::RawKeyDown == event.type) {
1029 // Suppress the next keypress event unless the focused node is a plu g-in node. 1029 // Suppress the next keypress event unless the focused node is a plu g-in node.
1030 // (Flash needs these keypress events to handle non-US keyboards.) 1030 // (Flash needs these keypress events to handle non-US keyboards.)
1031 Element* element = focusedElement(); 1031 Element* element = focusedElement();
1032 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) 1032 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject())
1033 m_suppressNextKeypressEvent = true; 1033 m_suppressNextKeypressEvent = Suppress_KeyEventHandled;
James Su 2015/02/27 01:46:18 Why it's Handled? eventHandler().keyEvent(evt) re
1034 } 1034 }
1035 return true; 1035 return true;
1036 } 1036 }
1037 1037
1038 #if !OS(MACOSX) 1038 #if !OS(MACOSX)
1039 const WebInputEvent::Type contextMenuTriggeringEventType = 1039 const WebInputEvent::Type contextMenuTriggeringEventType =
1040 #if OS(WIN) 1040 #if OS(WIN)
1041 WebInputEvent::KeyUp; 1041 WebInputEvent::KeyUp;
1042 #else 1042 #else
1043 WebInputEvent::RawKeyDown; 1043 WebInputEvent::RawKeyDown;
(...skipping 12 matching lines...) Expand all
1056 1056
1057 bool WebViewImpl::handleCharEvent(const WebKeyboardEvent& event) 1057 bool WebViewImpl::handleCharEvent(const WebKeyboardEvent& event)
1058 { 1058 {
1059 ASSERT(event.type == WebInputEvent::Char); 1059 ASSERT(event.type == WebInputEvent::Char);
1060 1060
1061 // Please refer to the comments explaining the m_suppressNextKeypressEvent 1061 // Please refer to the comments explaining the m_suppressNextKeypressEvent
1062 // member. The m_suppressNextKeypressEvent is set if the KeyDown is 1062 // member. The m_suppressNextKeypressEvent is set if the KeyDown is
1063 // handled by Webkit. A keyDown event is typically associated with a 1063 // handled by Webkit. A keyDown event is typically associated with a
1064 // keyPress(char) event and a keyUp event. We reset this flag here as it 1064 // keyPress(char) event and a keyUp event. We reset this flag here as it
1065 // only applies to the current keyPress event. 1065 // only applies to the current keyPress event.
1066 bool suppress = m_suppressNextKeypressEvent; 1066 bool suppress = (m_suppressNextKeypressEvent != Suppress_None);
1067 m_suppressNextKeypressEvent = false; 1067 m_suppressNextKeypressEvent = Suppress_None;
1068 1068
1069 // If there is a select popup, it should be the one processing the event, 1069 // If there is a select popup, it should be the one processing the event,
1070 // not the page. 1070 // not the page.
1071 if (m_selectPopup) 1071 if (m_selectPopup)
1072 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 1072 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
1073 if (m_pagePopup) 1073 if (m_pagePopup)
1074 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 1074 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
1075 1075
1076 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); 1076 LocalFrame* frame = toLocalFrame(focusedCoreFrame());
1077 if (!frame) 1077 if (!frame)
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 // editable because JavaScript may delete a parent node of the composition 2261 // editable because JavaScript may delete a parent node of the composition
2262 // node. In this case, WebKit crashes while deleting texts from the parent 2262 // node. In this case, WebKit crashes while deleting texts from the parent
2263 // node, which doesn't exist any longer. 2263 // node, which doesn't exist any longer.
2264 RefPtrWillBeRawPtr<Range> range = inputMethodController.compositionRange(); 2264 RefPtrWillBeRawPtr<Range> range = inputMethodController.compositionRange();
2265 if (range) { 2265 if (range) {
2266 Node* node = range->startContainer(); 2266 Node* node = range->startContainer();
2267 if (!node || !node->isContentEditable()) 2267 if (!node || !node->isContentEditable())
2268 return false; 2268 return false;
2269 } 2269 }
2270 2270
2271 // If we're not going to fire a keypress event, then the keydown event was 2271 // The keydown event was canceled, so cancel any existing composition.
2272 // canceled. In that case, cancel any existing composition. 2272 if (text.isEmpty() || m_suppressNextKeypressEvent == Suppress_KeyEventCancel ed) {
James Su 2015/02/27 01:46:18 Based on this change, the composition events will
huangs 2015/02/27 03:43:58 Could you create your own CL and offer it as an al
2273 if (text.isEmpty() || m_suppressNextKeypressEvent) {
2274 // A browser process sent an IPC message which does not contain a valid 2273 // A browser process sent an IPC message which does not contain a valid
2275 // string, which means an ongoing composition has been canceled. 2274 // string, which means an ongoing composition has been canceled.
2276 // If the ongoing composition has been canceled, replace the ongoing 2275 // If the ongoing composition has been canceled, replace the ongoing
2277 // composition string with an empty string and complete it. 2276 // composition string with an empty string and complete it.
2278 String emptyString; 2277 String emptyString;
2279 Vector<CompositionUnderline> emptyUnderlines; 2278 Vector<CompositionUnderline> emptyUnderlines;
2280 inputMethodController.setComposition(emptyString, emptyUnderlines, 0, 0) ; 2279 inputMethodController.setComposition(emptyString, emptyUnderlines, 0, 0) ;
2281 return text.isEmpty(); 2280 return text.isEmpty();
2282 } 2281 }
2283 2282
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
4635 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4634 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4636 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4635 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4637 } 4636 }
4638 4637
4639 void WebViewImpl::forceNextWebGLContextCreationToFail() 4638 void WebViewImpl::forceNextWebGLContextCreationToFail()
4640 { 4639 {
4641 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4640 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4642 } 4641 }
4643 4642
4644 } // namespace blink 4643 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698