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

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: Sync. 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 , m_doubleTapZoomPageScaleFactor(0) 405 , m_doubleTapZoomPageScaleFactor(0)
406 , m_doubleTapZoomPending(false) 406 , m_doubleTapZoomPending(false)
407 , m_enableFakePageScaleAnimationForTesting(false) 407 , m_enableFakePageScaleAnimationForTesting(false)
408 , m_fakePageScaleAnimationPageScaleFactor(0) 408 , m_fakePageScaleAnimationPageScaleFactor(0)
409 , m_fakePageScaleAnimationUseAnchor(false) 409 , m_fakePageScaleAnimationUseAnchor(false)
410 , m_contextMenuAllowed(false) 410 , m_contextMenuAllowed(false)
411 , m_doingDragAndDrop(false) 411 , m_doingDragAndDrop(false)
412 , m_ignoreInputEvents(false) 412 , m_ignoreInputEvents(false)
413 , m_compositorDeviceScaleFactorOverride(0) 413 , m_compositorDeviceScaleFactorOverride(0)
414 , m_rootLayerScale(1) 414 , m_rootLayerScale(1)
415 , m_suppressNextKeypressEvent(false) 415 , m_suppressNextKeypressEvent(Suppress_None)
416 , m_imeAcceptEvents(true) 416 , m_imeAcceptEvents(true)
417 , m_operationsAllowed(WebDragOperationNone) 417 , m_operationsAllowed(WebDragOperationNone)
418 , m_dragOperation(WebDragOperationNone) 418 , m_dragOperation(WebDragOperationNone)
419 , m_isTransparent(false) 419 , m_isTransparent(false)
420 , m_tabsToLinks(false) 420 , m_tabsToLinks(false)
421 , m_layerTreeView(0) 421 , m_layerTreeView(0)
422 , m_rootLayer(0) 422 , m_rootLayer(0)
423 , m_rootGraphicsLayer(0) 423 , m_rootGraphicsLayer(0)
424 , m_rootTransformLayer(0) 424 , m_rootTransformLayer(0)
425 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this))) 425 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this)))
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 || (event.type == WebInputEvent::KeyDown) 1009 || (event.type == WebInputEvent::KeyDown)
1010 || (event.type == WebInputEvent::KeyUp)); 1010 || (event.type == WebInputEvent::KeyUp));
1011 1011
1012 // Halt an in-progress fling on a key event. 1012 // Halt an in-progress fling on a key event.
1013 endActiveFlingAnimation(); 1013 endActiveFlingAnimation();
1014 1014
1015 // Please refer to the comments explaining the m_suppressNextKeypressEvent 1015 // Please refer to the comments explaining the m_suppressNextKeypressEvent
1016 // member. 1016 // member.
1017 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by 1017 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by
1018 // Webkit. A keyDown event is typically associated with a keyPress(char) 1018 // Webkit. A keyDown event is typically associated with a keyPress(char)
1019 // event and a keyUp event. We reset this flag here as this is a new keyDown 1019 // event and a keyUp event. We reset this state here as this is a new keyDow n
1020 // event. 1020 // event.
1021 m_suppressNextKeypressEvent = false; 1021 m_suppressNextKeypressEvent = Suppress_None;
1022 1022
1023 // If there is a select popup, it should be the one processing the event, 1023 // If there is a select popup, it should be the one processing the event,
1024 // not the page. 1024 // not the page.
1025 if (m_selectPopup) 1025 if (m_selectPopup)
1026 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 1026 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
1027 if (m_pagePopup) { 1027 if (m_pagePopup) {
1028 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 1028 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
1029 // We need to ignore the next Char event after this otherwise pressing 1029 // We need to ignore the next Char event after this otherwise pressing
1030 // enter when selecting an item in the popup will go to the page. 1030 // enter when selecting an item in the popup will go to the page.
1031 if (WebInputEvent::RawKeyDown == event.type) 1031 if (WebInputEvent::RawKeyDown == event.type)
1032 m_suppressNextKeypressEvent = true; 1032 m_suppressNextKeypressEvent = Suppress_KeyEventCanceled;
1033 return true; 1033 return true;
1034 } 1034 }
1035 1035
1036 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); 1036 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame();
1037 if (focusedFrame && focusedFrame->isRemoteFrame()) { 1037 if (focusedFrame && focusedFrame->isRemoteFrame()) {
1038 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr ame(focusedFrame.get())); 1038 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr ame(focusedFrame.get()));
1039 webFrame->client()->forwardInputEvent(&event); 1039 webFrame->client()->forwardInputEvent(&event);
1040 return true; 1040 return true;
1041 } 1041 }
1042 1042
1043 if (!focusedFrame || !focusedFrame->isLocalFrame()) 1043 if (!focusedFrame || !focusedFrame->isLocalFrame())
1044 return false; 1044 return false;
1045 1045
1046 LocalFrame* frame = toLocalFrame(focusedFrame.get()); 1046 LocalFrame* frame = toLocalFrame(focusedFrame.get());
1047 1047
1048 PlatformKeyboardEventBuilder evt(event); 1048 PlatformKeyboardEventBuilder evt(event);
1049 1049
1050 if (frame->eventHandler().keyEvent(evt)) { 1050 if (frame->eventHandler().keyEvent(evt)) {
1051 if (WebInputEvent::RawKeyDown == event.type) { 1051 if (WebInputEvent::RawKeyDown == event.type) {
1052 // Suppress the next keypress event unless the focused node is a plu g-in node. 1052 // Suppress the next keypress event unless the focused node is a plu g-in node.
1053 // (Flash needs these keypress events to handle non-US keyboards.) 1053 // (Flash needs these keypress events to handle non-US keyboards.)
1054 Element* element = focusedElement(); 1054 Element* element = focusedElement();
1055 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) 1055 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject())
1056 m_suppressNextKeypressEvent = true; 1056 m_suppressNextKeypressEvent = Suppress_KeyEventHandled;
1057 } 1057 }
1058 return true; 1058 return true;
1059 } 1059 }
1060 1060
1061 #if !OS(MACOSX) 1061 #if !OS(MACOSX)
1062 const WebInputEvent::Type contextMenuTriggeringEventType = 1062 const WebInputEvent::Type contextMenuTriggeringEventType =
1063 #if OS(WIN) 1063 #if OS(WIN)
1064 WebInputEvent::KeyUp; 1064 WebInputEvent::KeyUp;
1065 #else 1065 #else
1066 WebInputEvent::RawKeyDown; 1066 WebInputEvent::RawKeyDown;
(...skipping 12 matching lines...) Expand all
1079 1079
1080 bool WebViewImpl::handleCharEvent(const WebKeyboardEvent& event) 1080 bool WebViewImpl::handleCharEvent(const WebKeyboardEvent& event)
1081 { 1081 {
1082 ASSERT(event.type == WebInputEvent::Char); 1082 ASSERT(event.type == WebInputEvent::Char);
1083 1083
1084 // Please refer to the comments explaining the m_suppressNextKeypressEvent 1084 // Please refer to the comments explaining the m_suppressNextKeypressEvent
1085 // member. The m_suppressNextKeypressEvent is set if the KeyDown is 1085 // member. The m_suppressNextKeypressEvent is set if the KeyDown is
1086 // handled by Webkit. A keyDown event is typically associated with a 1086 // handled by Webkit. A keyDown event is typically associated with a
1087 // keyPress(char) event and a keyUp event. We reset this flag here as it 1087 // keyPress(char) event and a keyUp event. We reset this flag here as it
1088 // only applies to the current keyPress event. 1088 // only applies to the current keyPress event.
1089 bool suppress = m_suppressNextKeypressEvent; 1089 bool suppress = (m_suppressNextKeypressEvent != Suppress_None);
1090 m_suppressNextKeypressEvent = false; 1090 m_suppressNextKeypressEvent = Suppress_None;
1091 1091
1092 // If there is a select popup, it should be the one processing the event, 1092 // If there is a select popup, it should be the one processing the event,
1093 // not the page. 1093 // not the page.
1094 if (m_selectPopup) 1094 if (m_selectPopup)
1095 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 1095 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
1096 if (m_pagePopup) 1096 if (m_pagePopup)
1097 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 1097 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
1098 1098
1099 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); 1099 LocalFrame* frame = toLocalFrame(focusedCoreFrame());
1100 if (!frame) 1100 if (!frame)
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 // editable because JavaScript may delete a parent node of the composition 2297 // editable because JavaScript may delete a parent node of the composition
2298 // node. In this case, WebKit crashes while deleting texts from the parent 2298 // node. In this case, WebKit crashes while deleting texts from the parent
2299 // node, which doesn't exist any longer. 2299 // node, which doesn't exist any longer.
2300 RefPtrWillBeRawPtr<Range> range = inputMethodController.compositionRange(); 2300 RefPtrWillBeRawPtr<Range> range = inputMethodController.compositionRange();
2301 if (range) { 2301 if (range) {
2302 Node* node = range->startContainer(); 2302 Node* node = range->startContainer();
2303 if (!node || !node->isContentEditable()) 2303 if (!node || !node->isContentEditable())
2304 return false; 2304 return false;
2305 } 2305 }
2306 2306
2307 // If we're not going to fire a keypress event, then the keydown event was 2307 // The keydown event was canceled, so cancel any existing composition.
2308 // canceled. In that case, cancel any existing composition. 2308 if (text.isEmpty() || m_suppressNextKeypressEvent == Suppress_KeyEventCancel ed) {
2309 if (text.isEmpty() || m_suppressNextKeypressEvent) {
2310 // A browser process sent an IPC message which does not contain a valid 2309 // A browser process sent an IPC message which does not contain a valid
2311 // string, which means an ongoing composition has been canceled. 2310 // string, which means an ongoing composition has been canceled.
2312 // If the ongoing composition has been canceled, replace the ongoing 2311 // If the ongoing composition has been canceled, replace the ongoing
2313 // composition string with an empty string and complete it. 2312 // composition string with an empty string and complete it.
2314 String emptyString; 2313 String emptyString;
2315 Vector<CompositionUnderline> emptyUnderlines; 2314 Vector<CompositionUnderline> emptyUnderlines;
2316 inputMethodController.setComposition(emptyString, emptyUnderlines, 0, 0) ; 2315 inputMethodController.setComposition(emptyString, emptyUnderlines, 0, 0) ;
2317 return text.isEmpty(); 2316 return text.isEmpty();
2318 } 2317 }
2319 2318
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
4671 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4670 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4672 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4671 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4673 } 4672 }
4674 4673
4675 void WebViewImpl::forceNextWebGLContextCreationToFail() 4674 void WebViewImpl::forceNextWebGLContextCreationToFail()
4676 { 4675 {
4677 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4676 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4678 } 4677 }
4679 4678
4680 } // namespace blink 4679 } // 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