OLD | NEW |
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 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // A keypress event is canceled. If an ongoing composition exists, then the |
2308 // canceled. In that case, cancel any existing composition. | 2308 // keydown event should have arisen from a handled key (e.g., backspace). |
2309 if (text.isEmpty() || m_suppressNextKeypressEvent) { | 2309 // In this case we ignore the cancellation and continue; otherwise (no |
2310 // A browser process sent an IPC message which does not contain a valid | 2310 // ongoing composition) we exit and signal success only for attempts to |
2311 // string, which means an ongoing composition has been canceled. | 2311 // clear the composition. |
2312 // If the ongoing composition has been canceled, replace the ongoing | 2312 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) |
2313 // composition string with an empty string and complete it. | |
2314 String emptyString; | |
2315 Vector<CompositionUnderline> emptyUnderlines; | |
2316 inputMethodController.setComposition(emptyString, emptyUnderlines, 0, 0)
; | |
2317 return text.isEmpty(); | 2313 return text.isEmpty(); |
2318 } | |
2319 | 2314 |
2320 // When the range of composition underlines overlap with the range between | 2315 // When the range of composition underlines overlap with the range between |
2321 // selectionStart and selectionEnd, WebKit somehow won't paint the selection | 2316 // selectionStart and selectionEnd, WebKit somehow won't paint the selection |
2322 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). | 2317 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). |
2323 // But the selection range actually takes effect. | 2318 // But the selection range actually takes effect. |
2324 inputMethodController.setComposition(String(text), | 2319 inputMethodController.setComposition(String(text), |
2325 CompositionUnderlineVectorBuilder(underlines), | 2320 CompositionUnderlineVectorBuilder(underlines), |
2326 selectionStart, selectionEnd); | 2321 selectionStart, selectionEnd); |
2327 | 2322 |
2328 return inputMethodController.hasComposition(); | 2323 return text.isEmpty() || inputMethodController.hasComposition(); |
2329 } | 2324 } |
2330 | 2325 |
2331 bool WebViewImpl::confirmComposition() | 2326 bool WebViewImpl::confirmComposition() |
2332 { | 2327 { |
2333 return confirmComposition(DoNotKeepSelection); | 2328 return confirmComposition(DoNotKeepSelection); |
2334 } | 2329 } |
2335 | 2330 |
2336 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio
r) | 2331 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio
r) |
2337 { | 2332 { |
2338 return confirmComposition(WebString(), selectionBehavior); | 2333 return confirmComposition(WebString(), selectionBehavior); |
(...skipping 2332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4671 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4666 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4672 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4667 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4673 } | 4668 } |
4674 | 4669 |
4675 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4670 void WebViewImpl::forceNextWebGLContextCreationToFail() |
4676 { | 4671 { |
4677 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4672 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
4678 } | 4673 } |
4679 | 4674 |
4680 } // namespace blink | 4675 } // namespace blink |
OLD | NEW |