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 bool WebViewImpl::setComposition( | 2313 bool WebViewImpl::setComposition( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 // selectionStart and selectionEnd, WebKit somehow won't paint the selection | 2356 // selectionStart and selectionEnd, WebKit somehow won't paint the selection |
2357 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). | 2357 // at all (see InlineTextBox::paint() function in InlineTextBox.cpp). |
2358 // But the selection range actually takes effect. | 2358 // But the selection range actually takes effect. |
2359 inputMethodController.setComposition(String(text), | 2359 inputMethodController.setComposition(String(text), |
2360 CompositionUnderlineVectorBuilder(underlines), | 2360 CompositionUnderlineVectorBuilder(underlines), |
2361 selectionStart, selectionEnd); | 2361 selectionStart, selectionEnd); |
2362 | 2362 |
2363 return text.isEmpty() || inputMethodController.hasComposition(); | 2363 return text.isEmpty() || inputMethodController.hasComposition(); |
2364 } | 2364 } |
2365 | 2365 |
2366 bool WebViewImpl::confirmComposition() | 2366 bool WebViewImpl::finishComposingText(ConfirmCompositionBehavior selectionBehavi
or) |
2367 { | |
2368 return confirmComposition(DoNotKeepSelection); | |
2369 } | |
2370 | |
2371 bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavio
r) | |
2372 { | |
2373 return confirmComposition(WebString(), selectionBehavior); | |
2374 } | |
2375 | |
2376 bool WebViewImpl::confirmComposition(const WebString& text) | |
2377 { | |
2378 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | |
2379 return confirmComposition(text, DoNotKeepSelection); | |
2380 } | |
2381 | |
2382 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) | |
2383 { | 2367 { |
2384 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 2368 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
2385 if (!focused) | 2369 if (!focused) |
2386 return false; | 2370 return false; |
2387 | 2371 |
2388 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 2372 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
2389 return plugin->confirmComposition(text, selectionBehavior); | 2373 return plugin->finishComposingText(selectionBehavior); |
| 2374 |
| 2375 return focused->inputMethodController().finishComposingText(selectionBehavio
r == KeepSelection ? InputMethodController::KeepSelection : InputMethodControlle
r::DoNotKeepSelection); |
| 2376 } |
| 2377 |
| 2378 bool WebViewImpl::commitText(const WebString& text, int relativeCaretPosition) |
| 2379 { |
| 2380 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 2381 |
| 2382 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 2383 if (!focused) |
| 2384 return false; |
| 2385 |
| 2386 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 2387 return plugin->commitText(text, relativeCaretPosition); |
2390 | 2388 |
2391 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 2389 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
2392 // needs to be audited. See http://crbug.com/590369 for more details. | 2390 // needs to be audited. See http://crbug.com/590369 for more details. |
2393 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 2391 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
2394 | 2392 |
2395 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 2393 return focused->inputMethodController().commitText(text, relativeCaretPositi
on); |
2396 } | 2394 } |
2397 | 2395 |
2398 WebRange WebViewImpl::compositionRange() | 2396 WebRange WebViewImpl::compositionRange() |
2399 { | 2397 { |
2400 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 2398 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
2401 if (!focused) | 2399 if (!focused) |
2402 return WebRange(); | 2400 return WebRange(); |
2403 | 2401 |
2404 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); | 2402 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); |
2405 if (range.isNull()) | 2403 if (range.isNull()) |
(...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4602 return nullptr; | 4600 return nullptr; |
4603 return focusedFrame; | 4601 return focusedFrame; |
4604 } | 4602 } |
4605 | 4603 |
4606 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const | 4604 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const |
4607 { | 4605 { |
4608 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4606 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
4609 } | 4607 } |
4610 | 4608 |
4611 } // namespace blink | 4609 } // namespace blink |
OLD | NEW |