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 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 char_event.modifiers = 0; | 1382 char_event.modifiers = 0; |
1383 char_event.windowsKeyCode = last_text[i]; | 1383 char_event.windowsKeyCode = last_text[i]; |
1384 char_event.nativeKeyCode = last_text[i]; | 1384 char_event.nativeKeyCode = last_text[i]; |
1385 | 1385 |
1386 const int32_t char_start = i; | 1386 const int32_t char_start = i; |
1387 for (; i < iterator.array_pos(); ++i) { | 1387 for (; i < iterator.array_pos(); ++i) { |
1388 char_event.text[i - char_start] = last_text[i]; | 1388 char_event.text[i - char_start] = last_text[i]; |
1389 char_event.unmodifiedText[i - char_start] = last_text[i]; | 1389 char_event.unmodifiedText[i - char_start] = last_text[i]; |
1390 } | 1390 } |
1391 | 1391 |
1392 if (GetRenderWidget()->webwidget()) | 1392 if (GetRenderWidget()->GetWebWidget()) |
1393 GetRenderWidget()->webwidget()->handleInputEvent(char_event); | 1393 GetRenderWidget()->GetWebWidget()->handleInputEvent(char_event); |
1394 } | 1394 } |
1395 } else { | 1395 } else { |
1396 // Mimics the order of events sent by WebKit. | 1396 // Mimics the order of events sent by WebKit. |
1397 // See WebCore::Editor::setComposition() for the corresponding code. | 1397 // See WebCore::Editor::setComposition() for the corresponding code. |
1398 focused_pepper_plugin_->HandleCompositionEnd(last_text); | 1398 focused_pepper_plugin_->HandleCompositionEnd(last_text); |
1399 focused_pepper_plugin_->HandleTextInput(last_text); | 1399 focused_pepper_plugin_->HandleTextInput(last_text); |
1400 } | 1400 } |
1401 pepper_composition_text_.clear(); | 1401 pepper_composition_text_.clear(); |
1402 } | 1402 } |
1403 #endif // defined(ENABLE_PLUGINS) | 1403 #endif // defined(ENABLE_PLUGINS) |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 // This IPC is dispatched by RenderWidgetHost, so use its routing id. | 1810 // This IPC is dispatched by RenderWidgetHost, so use its routing id. |
1811 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id())); | 1811 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id())); |
1812 | 1812 |
1813 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1813 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
1814 frame_->selectRange(render_view_->ConvertWindowPointToViewport(base), | 1814 frame_->selectRange(render_view_->ConvertWindowPointToViewport(base), |
1815 render_view_->ConvertWindowPointToViewport(extent)); | 1815 render_view_->ConvertWindowPointToViewport(extent)); |
1816 } | 1816 } |
1817 | 1817 |
1818 void RenderFrameImpl::OnAdjustSelectionByCharacterOffset(int start_adjust, | 1818 void RenderFrameImpl::OnAdjustSelectionByCharacterOffset(int start_adjust, |
1819 int end_adjust) { | 1819 int end_adjust) { |
1820 WebRange range = GetRenderWidget()->webwidget()->caretOrSelectionRange(); | 1820 WebRange range = GetRenderWidget()->GetWebWidget()->caretOrSelectionRange(); |
1821 if (range.isNull()) | 1821 if (range.isNull()) |
1822 return; | 1822 return; |
1823 | 1823 |
1824 // Sanity checks to disallow empty and out of range selections. | 1824 // Sanity checks to disallow empty and out of range selections. |
1825 if (start_adjust - end_adjust > range.length() || | 1825 if (start_adjust - end_adjust > range.length() || |
1826 range.startOffset() + start_adjust < 0) | 1826 range.startOffset() + start_adjust < 0) |
1827 return; | 1827 return; |
1828 | 1828 |
1829 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1829 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
1830 | 1830 |
(...skipping 3817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5648 gfx::Range range; | 5648 gfx::Range range; |
5649 #if defined(ENABLE_PLUGINS) | 5649 #if defined(ENABLE_PLUGINS) |
5650 if (focused_pepper_plugin_) { | 5650 if (focused_pepper_plugin_) { |
5651 focused_pepper_plugin_->GetSurroundingText(&text, &range); | 5651 focused_pepper_plugin_->GetSurroundingText(&text, &range); |
5652 offset = 0; // Pepper API does not support offset reporting. | 5652 offset = 0; // Pepper API does not support offset reporting. |
5653 // TODO(kinaba): cut as needed. | 5653 // TODO(kinaba): cut as needed. |
5654 } else | 5654 } else |
5655 #endif | 5655 #endif |
5656 { | 5656 { |
5657 WebRange selection = | 5657 WebRange selection = |
5658 GetRenderWidget()->webwidget()->caretOrSelectionRange(); | 5658 GetRenderWidget()->GetWebWidget()->caretOrSelectionRange(); |
5659 if (selection.isNull()) | 5659 if (selection.isNull()) |
5660 return; | 5660 return; |
5661 | 5661 |
5662 range = gfx::Range(selection.startOffset(), selection.endOffset()); | 5662 range = gfx::Range(selection.startOffset(), selection.endOffset()); |
5663 | 5663 |
5664 if (GetRenderWidget()->webwidget()->textInputType() != | 5664 if (GetRenderWidget()->GetWebWidget()->textInputType() != |
5665 blink::WebTextInputTypeNone) { | 5665 blink::WebTextInputTypeNone) { |
5666 // If current focused element is editable, we will send 100 more chars | 5666 // If current focused element is editable, we will send 100 more chars |
5667 // before and after selection. It is for input method surrounding text | 5667 // before and after selection. It is for input method surrounding text |
5668 // feature. | 5668 // feature. |
5669 if (selection.startOffset() > kExtraCharsBeforeAndAfterSelection) | 5669 if (selection.startOffset() > kExtraCharsBeforeAndAfterSelection) |
5670 offset = selection.startOffset() - kExtraCharsBeforeAndAfterSelection; | 5670 offset = selection.startOffset() - kExtraCharsBeforeAndAfterSelection; |
5671 else | 5671 else |
5672 offset = 0; | 5672 offset = 0; |
5673 size_t length = | 5673 size_t length = |
5674 selection.endOffset() - offset + kExtraCharsBeforeAndAfterSelection; | 5674 selection.endOffset() - offset + kExtraCharsBeforeAndAfterSelection; |
5675 text = frame_->rangeAsText(WebRange(offset, length)); | 5675 text = frame_->rangeAsText(WebRange(offset, length)); |
5676 } else { | 5676 } else { |
5677 offset = selection.startOffset(); | 5677 offset = selection.startOffset(); |
5678 text = frame_->selectionAsText(); | 5678 text = frame_->selectionAsText(); |
5679 // http://crbug.com/101435 | 5679 // http://crbug.com/101435 |
5680 // In some case, frame->selectionAsText() returned text's length is not | 5680 // In some case, frame->selectionAsText() returned text's length is not |
5681 // equal to the length returned from webwidget()->caretOrSelectionRange(). | 5681 // equal to the length returned from |
| 5682 // GetWebWidget()->caretOrSelectionRange(). |
5682 // So we have to set the range according to text.length(). | 5683 // So we have to set the range according to text.length(). |
5683 range.set_end(range.start() + text.length()); | 5684 range.set_end(range.start() + text.length()); |
5684 } | 5685 } |
5685 } | 5686 } |
5686 | 5687 |
5687 // TODO(dglazkov): Investigate if and why this would be happening, | 5688 // TODO(dglazkov): Investigate if and why this would be happening, |
5688 // and resolve this. We shouldn't be carrying selection text here. | 5689 // and resolve this. We shouldn't be carrying selection text here. |
5689 // http://crbug.com/632920. | 5690 // http://crbug.com/632920. |
5690 // Sometimes we get repeated didChangeSelection calls from webkit when | 5691 // Sometimes we get repeated didChangeSelection calls from webkit when |
5691 // the selection hasn't actually changed. We don't want to report these | 5692 // the selection hasn't actually changed. We don't want to report these |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6319 // event target. Potentially a Pepper plugin will receive the event. | 6320 // event target. Potentially a Pepper plugin will receive the event. |
6320 // In order to tell whether a plugin gets the last mouse event and which it | 6321 // In order to tell whether a plugin gets the last mouse event and which it |
6321 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6322 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6322 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6323 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6323 // |pepper_last_mouse_event_target_|. | 6324 // |pepper_last_mouse_event_target_|. |
6324 pepper_last_mouse_event_target_ = nullptr; | 6325 pepper_last_mouse_event_target_ = nullptr; |
6325 #endif | 6326 #endif |
6326 } | 6327 } |
6327 | 6328 |
6328 } // namespace content | 6329 } // namespace content |
OLD | NEW |