OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 char_event.modifiers = 0; | 1383 char_event.modifiers = 0; |
1384 char_event.windowsKeyCode = last_text[i]; | 1384 char_event.windowsKeyCode = last_text[i]; |
1385 char_event.nativeKeyCode = last_text[i]; | 1385 char_event.nativeKeyCode = last_text[i]; |
1386 | 1386 |
1387 const int32_t char_start = i; | 1387 const int32_t char_start = i; |
1388 for (; i < iterator.array_pos(); ++i) { | 1388 for (; i < iterator.array_pos(); ++i) { |
1389 char_event.text[i - char_start] = last_text[i]; | 1389 char_event.text[i - char_start] = last_text[i]; |
1390 char_event.unmodifiedText[i - char_start] = last_text[i]; | 1390 char_event.unmodifiedText[i - char_start] = last_text[i]; |
1391 } | 1391 } |
1392 | 1392 |
1393 if (GetRenderWidget()->webwidget()) | 1393 if (GetRenderWidget()->GetWebWidget()) |
1394 GetRenderWidget()->webwidget()->handleInputEvent(char_event); | 1394 GetRenderWidget()->GetWebWidget()->handleInputEvent(char_event); |
1395 } | 1395 } |
1396 } else { | 1396 } else { |
1397 // Mimics the order of events sent by WebKit. | 1397 // Mimics the order of events sent by WebKit. |
1398 // See WebCore::Editor::setComposition() for the corresponding code. | 1398 // See WebCore::Editor::setComposition() for the corresponding code. |
1399 focused_pepper_plugin_->HandleCompositionEnd(last_text); | 1399 focused_pepper_plugin_->HandleCompositionEnd(last_text); |
1400 focused_pepper_plugin_->HandleTextInput(last_text); | 1400 focused_pepper_plugin_->HandleTextInput(last_text); |
1401 } | 1401 } |
1402 pepper_composition_text_.clear(); | 1402 pepper_composition_text_.clear(); |
1403 } | 1403 } |
1404 #endif // defined(ENABLE_PLUGINS) | 1404 #endif // defined(ENABLE_PLUGINS) |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 // This IPC is dispatched by RenderWidgetHost, so use its routing id. | 1809 // This IPC is dispatched by RenderWidgetHost, so use its routing id. |
1810 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id())); | 1810 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id())); |
1811 | 1811 |
1812 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1812 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
1813 frame_->selectRange(render_view_->ConvertWindowPointToViewport(base), | 1813 frame_->selectRange(render_view_->ConvertWindowPointToViewport(base), |
1814 render_view_->ConvertWindowPointToViewport(extent)); | 1814 render_view_->ConvertWindowPointToViewport(extent)); |
1815 } | 1815 } |
1816 | 1816 |
1817 void RenderFrameImpl::OnAdjustSelectionByCharacterOffset(int start_adjust, | 1817 void RenderFrameImpl::OnAdjustSelectionByCharacterOffset(int start_adjust, |
1818 int end_adjust) { | 1818 int end_adjust) { |
1819 WebRange range = GetRenderWidget()->webwidget()->caretOrSelectionRange(); | 1819 WebRange range = GetRenderWidget()->GetWebWidget()->caretOrSelectionRange(); |
1820 if (range.isNull()) | 1820 if (range.isNull()) |
1821 return; | 1821 return; |
1822 | 1822 |
1823 // Sanity checks to disallow empty and out of range selections. | 1823 // Sanity checks to disallow empty and out of range selections. |
1824 if (start_adjust - end_adjust > range.length() || | 1824 if (start_adjust - end_adjust > range.length() || |
1825 range.startOffset() + start_adjust < 0) | 1825 range.startOffset() + start_adjust < 0) |
1826 return; | 1826 return; |
1827 | 1827 |
1828 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1828 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
1829 | 1829 |
(...skipping 3869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5699 gfx::Range range; | 5699 gfx::Range range; |
5700 #if defined(ENABLE_PLUGINS) | 5700 #if defined(ENABLE_PLUGINS) |
5701 if (focused_pepper_plugin_) { | 5701 if (focused_pepper_plugin_) { |
5702 focused_pepper_plugin_->GetSurroundingText(&text, &range); | 5702 focused_pepper_plugin_->GetSurroundingText(&text, &range); |
5703 offset = 0; // Pepper API does not support offset reporting. | 5703 offset = 0; // Pepper API does not support offset reporting. |
5704 // TODO(kinaba): cut as needed. | 5704 // TODO(kinaba): cut as needed. |
5705 } else | 5705 } else |
5706 #endif | 5706 #endif |
5707 { | 5707 { |
5708 WebRange selection = | 5708 WebRange selection = |
5709 GetRenderWidget()->webwidget()->caretOrSelectionRange(); | 5709 GetRenderWidget()->GetWebWidget()->caretOrSelectionRange(); |
5710 if (selection.isNull()) | 5710 if (selection.isNull()) |
5711 return; | 5711 return; |
5712 | 5712 |
5713 range = gfx::Range(selection.startOffset(), selection.endOffset()); | 5713 range = gfx::Range(selection.startOffset(), selection.endOffset()); |
5714 | 5714 |
5715 if (GetRenderWidget()->webwidget()->textInputType() != | 5715 if (GetRenderWidget()->GetWebWidget()->textInputType() != |
5716 blink::WebTextInputTypeNone) { | 5716 blink::WebTextInputTypeNone) { |
5717 // If current focused element is editable, we will send 100 more chars | 5717 // If current focused element is editable, we will send 100 more chars |
5718 // before and after selection. It is for input method surrounding text | 5718 // before and after selection. It is for input method surrounding text |
5719 // feature. | 5719 // feature. |
5720 if (selection.startOffset() > kExtraCharsBeforeAndAfterSelection) | 5720 if (selection.startOffset() > kExtraCharsBeforeAndAfterSelection) |
5721 offset = selection.startOffset() - kExtraCharsBeforeAndAfterSelection; | 5721 offset = selection.startOffset() - kExtraCharsBeforeAndAfterSelection; |
5722 else | 5722 else |
5723 offset = 0; | 5723 offset = 0; |
5724 size_t length = | 5724 size_t length = |
5725 selection.endOffset() - offset + kExtraCharsBeforeAndAfterSelection; | 5725 selection.endOffset() - offset + kExtraCharsBeforeAndAfterSelection; |
5726 text = frame_->rangeAsText(WebRange(offset, length)); | 5726 text = frame_->rangeAsText(WebRange(offset, length)); |
5727 } else { | 5727 } else { |
5728 offset = selection.startOffset(); | 5728 offset = selection.startOffset(); |
5729 text = frame_->selectionAsText(); | 5729 text = frame_->selectionAsText(); |
5730 // http://crbug.com/101435 | 5730 // http://crbug.com/101435 |
5731 // In some case, frame->selectionAsText() returned text's length is not | 5731 // In some case, frame->selectionAsText() returned text's length is not |
5732 // equal to the length returned from webwidget()->caretOrSelectionRange(). | 5732 // equal to the length returned from |
| 5733 // GetWebWidget()->caretOrSelectionRange(). |
5733 // So we have to set the range according to text.length(). | 5734 // So we have to set the range according to text.length(). |
5734 range.set_end(range.start() + text.length()); | 5735 range.set_end(range.start() + text.length()); |
5735 } | 5736 } |
5736 } | 5737 } |
5737 | 5738 |
5738 // TODO(dglazkov): Investigate if and why this would be happening, | 5739 // TODO(dglazkov): Investigate if and why this would be happening, |
5739 // and resolve this. We shouldn't be carrying selection text here. | 5740 // and resolve this. We shouldn't be carrying selection text here. |
5740 // http://crbug.com/632920. | 5741 // http://crbug.com/632920. |
5741 // Sometimes we get repeated didChangeSelection calls from webkit when | 5742 // Sometimes we get repeated didChangeSelection calls from webkit when |
5742 // the selection hasn't actually changed. We don't want to report these | 5743 // the selection hasn't actually changed. We don't want to report these |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6365 // event target. Potentially a Pepper plugin will receive the event. | 6366 // event target. Potentially a Pepper plugin will receive the event. |
6366 // In order to tell whether a plugin gets the last mouse event and which it | 6367 // In order to tell whether a plugin gets the last mouse event and which it |
6367 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6368 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6368 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6369 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6369 // |pepper_last_mouse_event_target_|. | 6370 // |pepper_last_mouse_event_target_|. |
6370 pepper_last_mouse_event_target_ = nullptr; | 6371 pepper_last_mouse_event_target_ = nullptr; |
6371 #endif | 6372 #endif |
6372 } | 6373 } |
6373 | 6374 |
6374 } // namespace content | 6375 } // namespace content |
OLD | NEW |