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 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 2388 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
2389 return plugin->confirmComposition(text, selectionBehavior); | 2389 return plugin->confirmComposition(text, selectionBehavior); |
2390 | 2390 |
2391 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 2391 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
2392 // needs to be audited. See http://crbug.com/590369 for more details. | 2392 // needs to be audited. See http://crbug.com/590369 for more details. |
2393 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 2393 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
2394 | 2394 |
2395 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 2395 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); |
2396 } | 2396 } |
2397 | 2397 |
| 2398 bool WebViewImpl::setEditableSelectionOffsets(int start, int end) |
| 2399 { |
| 2400 TRACE_EVENT0("blink", "WebViewImpl::setEditableSelectionOffsets"); |
| 2401 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 2402 if (!focused) |
| 2403 return false; |
| 2404 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 2405 // needs to be audited. See http://crbug.com/590369 for more details. |
| 2406 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 2407 |
| 2408 return focused->inputMethodController().setEditableSelectionOffsets(PlainTex
tRange(start, end)); |
| 2409 } |
| 2410 |
| 2411 bool WebViewImpl::setCompositionFromExistingText(int compositionStart, int compo
sitionEnd, const WebVector<WebCompositionUnderline>& underlines) |
| 2412 { |
| 2413 TRACE_EVENT0("blink", "WebViewImpl::setCompositionFromExistingText"); |
| 2414 |
| 2415 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 2416 if (!focused) |
| 2417 return false; |
| 2418 if (!focused->editor().canEdit()) |
| 2419 return false; |
| 2420 InputMethodController& inputMethodController = focused->inputMethodControlle
r(); |
| 2421 inputMethodController.cancelComposition(); |
| 2422 |
| 2423 if (compositionStart == compositionEnd) |
| 2424 return true; |
| 2425 |
| 2426 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 2427 // needs to be audited. See http://crbug.com/590369 for more details. |
| 2428 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 2429 |
| 2430 inputMethodController.setCompositionFromExistingText(CompositionUnderlineVec
torBuilder(underlines), compositionStart, compositionEnd); |
| 2431 |
| 2432 return true; |
| 2433 } |
| 2434 |
| 2435 void WebViewImpl::extendSelectionAndDelete(int before, int after) |
| 2436 { |
| 2437 TRACE_EVENT0("blink", "WebViewImpl::extendSelectionAndDelete"); |
| 2438 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
| 2439 if (!focused) |
| 2440 return; |
| 2441 |
| 2442 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) { |
| 2443 plugin->extendSelectionAndDelete(before, after); |
| 2444 return; |
| 2445 } |
| 2446 |
| 2447 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 2448 // needs to be audited. See http://crbug.com/590369 for more details. |
| 2449 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 2450 |
| 2451 focused->inputMethodController().extendSelectionAndDelete(before, after); |
| 2452 } |
| 2453 |
2398 WebRange WebViewImpl::compositionRange() | 2454 WebRange WebViewImpl::compositionRange() |
2399 { | 2455 { |
2400 LocalFrame* focused = focusedLocalFrameAvailableForIme(); | 2456 LocalFrame* focused = focusedLocalFrameAvailableForIme(); |
2401 if (!focused) | 2457 if (!focused) |
2402 return WebRange(); | 2458 return WebRange(); |
2403 | 2459 |
2404 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); | 2460 const EphemeralRange range = focused->inputMethodController().compositionEph
emeralRange(); |
2405 if (range.isNull()) | 2461 if (range.isNull()) |
2406 return WebRange(); | 2462 return WebRange(); |
2407 | 2463 |
(...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4591 return nullptr; | 4647 return nullptr; |
4592 return focusedFrame; | 4648 return focusedFrame; |
4593 } | 4649 } |
4594 | 4650 |
4595 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const | 4651 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const |
4596 { | 4652 { |
4597 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4653 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
4598 } | 4654 } |
4599 | 4655 |
4600 } // namespace blink | 4656 } // namespace blink |
OLD | NEW |