Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2288313002: Return the WebViewFrameWidget in RenderWidget::webwidget() if there (Closed)
Patch Set: make webview methods private Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 3853 matching lines...) Expand 10 before | Expand all | Expand 10 after
5684 gfx::Range range; 5684 gfx::Range range;
5685 #if defined(ENABLE_PLUGINS) 5685 #if defined(ENABLE_PLUGINS)
5686 if (focused_pepper_plugin_) { 5686 if (focused_pepper_plugin_) {
5687 focused_pepper_plugin_->GetSurroundingText(&text, &range); 5687 focused_pepper_plugin_->GetSurroundingText(&text, &range);
5688 offset = 0; // Pepper API does not support offset reporting. 5688 offset = 0; // Pepper API does not support offset reporting.
5689 // TODO(kinaba): cut as needed. 5689 // TODO(kinaba): cut as needed.
5690 } else 5690 } else
5691 #endif 5691 #endif
5692 { 5692 {
5693 WebRange selection = 5693 WebRange selection =
5694 GetRenderWidget()->webwidget()->caretOrSelectionRange(); 5694 GetRenderWidget()->GetWebWidget()->caretOrSelectionRange();
5695 if (selection.isNull()) 5695 if (selection.isNull())
5696 return; 5696 return;
5697 5697
5698 range = gfx::Range(selection.startOffset(), selection.endOffset()); 5698 range = gfx::Range(selection.startOffset(), selection.endOffset());
5699 5699
5700 if (GetRenderWidget()->webwidget()->textInputType() != 5700 if (GetRenderWidget()->GetWebWidget()->textInputType() !=
5701 blink::WebTextInputTypeNone) { 5701 blink::WebTextInputTypeNone) {
5702 // If current focused element is editable, we will send 100 more chars 5702 // If current focused element is editable, we will send 100 more chars
5703 // before and after selection. It is for input method surrounding text 5703 // before and after selection. It is for input method surrounding text
5704 // feature. 5704 // feature.
5705 if (selection.startOffset() > kExtraCharsBeforeAndAfterSelection) 5705 if (selection.startOffset() > kExtraCharsBeforeAndAfterSelection)
5706 offset = selection.startOffset() - kExtraCharsBeforeAndAfterSelection; 5706 offset = selection.startOffset() - kExtraCharsBeforeAndAfterSelection;
5707 else 5707 else
5708 offset = 0; 5708 offset = 0;
5709 size_t length = 5709 size_t length =
5710 selection.endOffset() - offset + kExtraCharsBeforeAndAfterSelection; 5710 selection.endOffset() - offset + kExtraCharsBeforeAndAfterSelection;
5711 text = frame_->rangeAsText(WebRange(offset, length)); 5711 text = frame_->rangeAsText(WebRange(offset, length));
5712 } else { 5712 } else {
5713 offset = selection.startOffset(); 5713 offset = selection.startOffset();
5714 text = frame_->selectionAsText(); 5714 text = frame_->selectionAsText();
5715 // http://crbug.com/101435 5715 // http://crbug.com/101435
5716 // In some case, frame->selectionAsText() returned text's length is not 5716 // In some case, frame->selectionAsText() returned text's length is not
5717 // equal to the length returned from webwidget()->caretOrSelectionRange(). 5717 // equal to the length returned from
5718 // GetWebWidget()->caretOrSelectionRange().
5718 // So we have to set the range according to text.length(). 5719 // So we have to set the range according to text.length().
5719 range.set_end(range.start() + text.length()); 5720 range.set_end(range.start() + text.length());
5720 } 5721 }
5721 } 5722 }
5722 5723
5723 // TODO(dglazkov): Investigate if and why this would be happening, 5724 // TODO(dglazkov): Investigate if and why this would be happening,
5724 // and resolve this. We shouldn't be carrying selection text here. 5725 // and resolve this. We shouldn't be carrying selection text here.
5725 // http://crbug.com/632920. 5726 // http://crbug.com/632920.
5726 // Sometimes we get repeated didChangeSelection calls from webkit when 5727 // Sometimes we get repeated didChangeSelection calls from webkit when
5727 // the selection hasn't actually changed. We don't want to report these 5728 // 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
6350 // event target. Potentially a Pepper plugin will receive the event. 6351 // event target. Potentially a Pepper plugin will receive the event.
6351 // In order to tell whether a plugin gets the last mouse event and which it 6352 // In order to tell whether a plugin gets the last mouse event and which it
6352 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6353 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6353 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6354 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6354 // |pepper_last_mouse_event_target_|. 6355 // |pepper_last_mouse_event_target_|.
6355 pepper_last_mouse_event_target_ = nullptr; 6356 pepper_last_mouse_event_target_ = nullptr;
6356 #endif 6357 #endif
6357 } 6358 }
6358 6359
6359 } // namespace content 6360 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698