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 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 return text.isEmpty() || inputMethodController.hasComposition(); | 2363 return text.isEmpty() || inputMethodController.hasComposition(); |
2364 } | 2364 } |
2365 | 2365 |
2366 bool WebViewImpl::confirmComposition() | 2366 bool WebViewImpl::confirmComposition() |
2367 { | 2367 { |
2368 return confirmComposition(DoNotKeepSelection); | 2368 return confirmComposition(DoNotKeepSelection); |
2369 } | 2369 } |
2370 | 2370 |
2371 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio
r) | 2371 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio
r) |
2372 { | 2372 { |
2373 return confirmComposition(WebString(), selectionBehavior); | 2373 return confirmComposition(WebString(), selectionBehavior, 1); |
2374 } | 2374 } |
2375 | 2375 |
2376 bool WebViewImpl::confirmComposition(const WebString& text) | 2376 bool WebViewImpl::confirmComposition(const WebString& text, int relativeCaretPos
ition) |
2377 { | 2377 { |
2378 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 2378 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
2379 return confirmComposition(text, DoNotKeepSelection); | 2379 return confirmComposition(text, DoNotKeepSelection, relativeCaretPosition); |
2380 } | 2380 } |
2381 | 2381 |
2382 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) | 2382 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior, int relativeCaretPosition) |
2383 { | 2383 { |
2384 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 2384 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
2385 if (!focused) | 2385 if (!focused) |
2386 return false; | 2386 return false; |
2387 | 2387 |
2388 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 2388 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
2389 return plugin->confirmComposition(text, selectionBehavior); | 2389 return plugin->confirmComposition(text, selectionBehavior, relativeCaret
Position); |
2390 | 2390 |
2391 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 2391 if (selectionBehavior == KeepSelection) |
| 2392 return focused->inputMethodController().commitComposition(text); |
| 2393 |
| 2394 return focused->inputMethodController().commitCompositionAndMoveCaret(text,
relativeCaretPosition); |
2392 } | 2395 } |
2393 | 2396 |
2394 bool WebViewImpl::compositionRange(size_t* location, size_t* length) | 2397 bool WebViewImpl::compositionRange(size_t* location, size_t* length) |
2395 { | 2398 { |
2396 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 2399 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
2397 if (!focused) | 2400 if (!focused) |
2398 return false; | 2401 return false; |
2399 | 2402 |
2400 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); | 2403 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); |
2401 if (range.isNull()) | 2404 if (range.isNull()) |
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4608 return nullptr; | 4611 return nullptr; |
4609 return focusedFrame; | 4612 return focusedFrame; |
4610 } | 4613 } |
4611 | 4614 |
4612 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const | 4615 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const |
4613 { | 4616 { |
4614 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4617 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
4615 } | 4618 } |
4616 | 4619 |
4617 } // namespace blink | 4620 } // namespace blink |
OLD | NEW |