| 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 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2293 if (focusedFrame->inputMethodController().hasComposition()) { | 2293 if (focusedFrame->inputMethodController().hasComposition()) { |
| 2294 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame
(focusedFrame)->autofillClient(); | 2294 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame
(focusedFrame)->autofillClient(); |
| 2295 | 2295 |
| 2296 if (autofillClient) | 2296 if (autofillClient) |
| 2297 autofillClient->setIgnoreTextChanges(true); | 2297 autofillClient->setIgnoreTextChanges(true); |
| 2298 | 2298 |
| 2299 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendin
gStylesheets | 2299 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendin
gStylesheets |
| 2300 // needs to be audited. See http://crbug.com/590369 for more de
tails. | 2300 // needs to be audited. See http://crbug.com/590369 for more de
tails. |
| 2301 focusedFrame->document()->updateStyleAndLayoutIgnorePendingStyle
sheets(); | 2301 focusedFrame->document()->updateStyleAndLayoutIgnorePendingStyle
sheets(); |
| 2302 | 2302 |
| 2303 focusedFrame->inputMethodController().confirmComposition(); | 2303 focusedFrame->inputMethodController().finishComposingText(InputM
ethodController::KeepSelection); |
| 2304 | 2304 |
| 2305 if (autofillClient) | 2305 if (autofillClient) |
| 2306 autofillClient->setIgnoreTextChanges(false); | 2306 autofillClient->setIgnoreTextChanges(false); |
| 2307 } | 2307 } |
| 2308 m_imeAcceptEvents = false; | 2308 m_imeAcceptEvents = false; |
| 2309 } | 2309 } |
| 2310 } | 2310 } |
| 2311 } | 2311 } |
| 2312 | 2312 |
| 2313 | 2313 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 // But the selection range actually takes effect. | 2361 // But the selection range actually takes effect. |
| 2362 inputMethodController.setComposition(String(text), | 2362 inputMethodController.setComposition(String(text), |
| 2363 CompositionUnderlineVectorBuilder(underlines), | 2363 CompositionUnderlineVectorBuilder(underlines), |
| 2364 selectionStart, selectionEnd); | 2364 selectionStart, selectionEnd); |
| 2365 | 2365 |
| 2366 return text.isEmpty() || inputMethodController.hasComposition(); | 2366 return text.isEmpty() || inputMethodController.hasComposition(); |
| 2367 } | 2367 } |
| 2368 | 2368 |
| 2369 // TODO(ekaramad):These methods are almost duplicated in WebFrameWidgetImpl as | 2369 // TODO(ekaramad):These methods are almost duplicated in WebFrameWidgetImpl as |
| 2370 // well. This code needs to be refactored (http://crbug.com/629721). | 2370 // well. This code needs to be refactored (http://crbug.com/629721). |
| 2371 bool WebViewImpl::confirmComposition() | 2371 bool WebViewImpl::finishComposingText(ConfirmCompositionBehavior selectionBehavi
or) |
| 2372 { | |
| 2373 return confirmComposition(DoNotKeepSelection); | |
| 2374 } | |
| 2375 | |
| 2376 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio
r) | |
| 2377 { | |
| 2378 return confirmComposition(WebString(), selectionBehavior); | |
| 2379 } | |
| 2380 | |
| 2381 bool WebViewImpl::confirmComposition(const WebString& text) | |
| 2382 { | |
| 2383 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | |
| 2384 return confirmComposition(text, DoNotKeepSelection); | |
| 2385 } | |
| 2386 | |
| 2387 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) | |
| 2388 { | 2372 { |
| 2389 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 2373 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 2390 if (!focused) | 2374 if (!focused) |
| 2391 return false; | 2375 return false; |
| 2392 | 2376 |
| 2393 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 2377 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 2394 return plugin->confirmComposition(text, selectionBehavior); | 2378 return plugin->finishComposingText(selectionBehavior); |
| 2379 |
| 2380 return focused->inputMethodController().finishComposingText(selectionBehavio
r == KeepSelection ? InputMethodController::KeepSelection : InputMethodControlle
r::DoNotKeepSelection); |
| 2381 } |
| 2382 |
| 2383 bool WebViewImpl::commitText(const WebString& text, int relativeCaretPosition) |
| 2384 { |
| 2385 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 2386 |
| 2387 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 2388 if (!focused) |
| 2389 return false; |
| 2390 |
| 2391 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 2392 return plugin->commitText(text, relativeCaretPosition); |
| 2395 | 2393 |
| 2396 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 2394 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 2397 // needs to be audited. See http://crbug.com/590369 for more details. | 2395 // needs to be audited. See http://crbug.com/590369 for more details. |
| 2398 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 2396 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 2399 | 2397 |
| 2400 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 2398 return focused->inputMethodController().commitText(text, relativeCaretPositi
on); |
| 2401 } | 2399 } |
| 2402 | 2400 |
| 2403 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as | 2401 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as |
| 2404 // well. This code needs to be refactored (http://crbug.com/629721). | 2402 // well. This code needs to be refactored (http://crbug.com/629721). |
| 2405 WebRange WebViewImpl::compositionRange() | 2403 WebRange WebViewImpl::compositionRange() |
| 2406 { | 2404 { |
| 2407 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 2405 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 2408 if (!focused) | 2406 if (!focused) |
| 2409 return WebRange(); | 2407 return WebRange(); |
| 2410 | 2408 |
| (...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4607 return nullptr; | 4605 return nullptr; |
| 4608 return focusedFrame; | 4606 return focusedFrame; |
| 4609 } | 4607 } |
| 4610 | 4608 |
| 4611 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const | 4609 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const |
| 4612 { | 4610 { |
| 4613 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4611 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
| 4614 } | 4612 } |
| 4615 | 4613 |
| 4616 } // namespace blink | 4614 } // namespace blink |
| OLD | NEW |