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

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

Issue 2012823003: Move IME related functions from WebFrame to WebLocalFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 4 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 } 1619 }
1620 1620
1621 void RenderViewImpl::didCancelCompositionOnSelectionChange() { 1621 void RenderViewImpl::didCancelCompositionOnSelectionChange() {
1622 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); 1622 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID()));
1623 } 1623 }
1624 1624
1625 bool RenderViewImpl::handleCurrentKeyboardEvent() { 1625 bool RenderViewImpl::handleCurrentKeyboardEvent() {
1626 if (edit_commands_.empty()) 1626 if (edit_commands_.empty())
1627 return false; 1627 return false;
1628 1628
1629 WebFrame* frame = webview()->focusedFrame(); 1629 WebLocalFrame* frame = webview()->focusedFrame();
dcheng 2016/06/13 17:29:45 Ditto: why is |frame| null here? I wonder if this
1630 if (!frame) 1630 if (!frame)
1631 return false; 1631 return false;
1632 1632
1633 EditCommands::iterator it = edit_commands_.begin(); 1633 EditCommands::iterator it = edit_commands_.begin();
1634 EditCommands::iterator end = edit_commands_.end(); 1634 EditCommands::iterator end = edit_commands_.end();
1635 1635
1636 bool did_execute_command = false; 1636 bool did_execute_command = false;
1637 for (; it != end; ++it) { 1637 for (; it != end; ++it) {
1638 // In gtk and cocoa, it's possible to bind multiple edit commands to one 1638 // In gtk and cocoa, it's possible to bind multiple edit commands to one
1639 // key (but it's the exception). Once one edit command is not executed, it 1639 // key (but it's the exception). Once one edit command is not executed, it
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); 2705 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin();
2706 if (focused_pepper_plugin) { 2706 if (focused_pepper_plugin) {
2707 focused_pepper_plugin->render_frame()->OnImeSetComposition( 2707 focused_pepper_plugin->render_frame()->OnImeSetComposition(
2708 text, underlines, selection_start, selection_end); 2708 text, underlines, selection_start, selection_end);
2709 return; 2709 return;
2710 } 2710 }
2711 #endif // ENABLE_PLUGINS 2711 #endif // ENABLE_PLUGINS
2712 if (replacement_range.IsValid() && webview()) { 2712 if (replacement_range.IsValid() && webview()) {
2713 // Select the text in |replacement_range|, it will then be replaced by 2713 // Select the text in |replacement_range|, it will then be replaced by
2714 // text added by the call to RenderWidget::OnImeSetComposition(). 2714 // text added by the call to RenderWidget::OnImeSetComposition().
2715 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { 2715 if (WebLocalFrame* frame = webview()->focusedFrame()) {
dcheng 2016/06/13 17:29:45 I'm not sure this can ever be null. toWebLocalFra
2716 WebRange webrange = WebRange::fromDocumentRange( 2716 WebRange webrange = WebRange::fromDocumentRange(
2717 frame, replacement_range.start(), replacement_range.length()); 2717 frame, replacement_range.start(), replacement_range.length());
2718 if (!webrange.isNull()) 2718 if (!webrange.isNull())
2719 frame->selectRange(webrange); 2719 frame->selectRange(webrange);
2720 } 2720 }
2721 } 2721 }
2722 RenderWidget::OnImeSetComposition(text, 2722 RenderWidget::OnImeSetComposition(text,
2723 underlines, 2723 underlines,
2724 replacement_range, 2724 replacement_range,
2725 selection_start, 2725 selection_start,
2726 selection_end); 2726 selection_end);
2727 } 2727 }
2728 2728
2729 void RenderViewImpl::OnImeConfirmComposition( 2729 void RenderViewImpl::OnImeConfirmComposition(
2730 const base::string16& text, 2730 const base::string16& text,
2731 const gfx::Range& replacement_range, 2731 const gfx::Range& replacement_range,
2732 bool keep_selection) { 2732 bool keep_selection) {
2733 #if defined(ENABLE_PLUGINS) 2733 #if defined(ENABLE_PLUGINS)
2734 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); 2734 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin();
2735 if (focused_pepper_plugin) { 2735 if (focused_pepper_plugin) {
2736 focused_pepper_plugin->render_frame()->OnImeConfirmComposition( 2736 focused_pepper_plugin->render_frame()->OnImeConfirmComposition(
2737 text, replacement_range, keep_selection); 2737 text, replacement_range, keep_selection);
2738 return; 2738 return;
2739 } 2739 }
2740 #endif // ENABLE_PLUGINS 2740 #endif // ENABLE_PLUGINS
2741 if (replacement_range.IsValid() && webview()) { 2741 if (replacement_range.IsValid() && webview()) {
2742 // Select the text in |replacement_range|, it will then be replaced by 2742 // Select the text in |replacement_range|, it will then be replaced by
2743 // text added by the call to RenderWidget::OnImeConfirmComposition(). 2743 // text added by the call to RenderWidget::OnImeConfirmComposition().
2744 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { 2744 if (WebLocalFrame* frame = webview()->focusedFrame()) {
dcheng 2016/06/13 17:29:45 Ditto.
2745 WebRange webrange = WebRange::fromDocumentRange( 2745 WebRange webrange = WebRange::fromDocumentRange(
2746 frame, replacement_range.start(), replacement_range.length()); 2746 frame, replacement_range.start(), replacement_range.length());
2747 if (!webrange.isNull()) 2747 if (!webrange.isNull())
2748 frame->selectRange(webrange); 2748 frame->selectRange(webrange);
2749 } 2749 }
2750 } 2750 }
2751 RenderWidget::OnImeConfirmComposition(text, 2751 RenderWidget::OnImeConfirmComposition(text,
2752 replacement_range, 2752 replacement_range,
2753 keep_selection); 2753 keep_selection);
2754 } 2754 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 2807
2808 if (!webview()) 2808 if (!webview())
2809 return; 2809 return;
2810 size_t start_offset = 0; 2810 size_t start_offset = 0;
2811 size_t character_count = 0; 2811 size_t character_count = 0;
2812 if (!webview()->compositionRange(&start_offset, &character_count)) 2812 if (!webview()->compositionRange(&start_offset, &character_count))
2813 return; 2813 return;
2814 if (character_count == 0) 2814 if (character_count == 0)
2815 return; 2815 return;
2816 2816
2817 blink::WebFrame* frame = webview()->focusedFrame(); 2817 blink::WebLocalFrame* frame = webview()->focusedFrame();
2818 if (!frame) 2818 if (!frame)
dcheng 2016/06/13 17:29:45 Similar question: can this actually return null? I
2819 return; 2819 return;
2820 2820
2821 bounds_in_window->reserve(character_count); 2821 bounds_in_window->reserve(character_count);
2822 blink::WebRect webrect; 2822 blink::WebRect webrect;
2823 for (size_t i = 0; i < character_count; ++i) { 2823 for (size_t i = 0; i < character_count; ++i) {
2824 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { 2824 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) {
2825 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; 2825 DLOG(ERROR) << "Could not retrieve character rectangle at " << i;
2826 bounds_in_window->clear(); 2826 bounds_in_window->clear();
2827 return; 2827 return;
2828 } 2828 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 return render_frame->focused_pepper_plugin(); 3229 return render_frame->focused_pepper_plugin();
3230 } 3230 }
3231 frame = frame->traverseNext(false); 3231 frame = frame->traverseNext(false);
3232 } 3232 }
3233 3233
3234 return nullptr; 3234 return nullptr;
3235 } 3235 }
3236 #endif 3236 #endif
3237 3237
3238 } // namespace content 3238 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698