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

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: remove most of the null checks except the one in spellcheck_provider.cc 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 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 } 1666 }
1667 1667
1668 void RenderViewImpl::didCancelCompositionOnSelectionChange() { 1668 void RenderViewImpl::didCancelCompositionOnSelectionChange() {
1669 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); 1669 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID()));
1670 } 1670 }
1671 1671
1672 bool RenderViewImpl::handleCurrentKeyboardEvent() { 1672 bool RenderViewImpl::handleCurrentKeyboardEvent() {
1673 if (edit_commands_.empty()) 1673 if (edit_commands_.empty())
1674 return false; 1674 return false;
1675 1675
1676 WebFrame* frame = webview()->focusedFrame(); 1676 WebLocalFrame* frame = webview()->focusedFrame();
1677 if (!frame)
1678 return false;
1679 1677
1680 EditCommands::iterator it = edit_commands_.begin(); 1678 EditCommands::iterator it = edit_commands_.begin();
1681 EditCommands::iterator end = edit_commands_.end(); 1679 EditCommands::iterator end = edit_commands_.end();
1682 1680
1683 bool did_execute_command = false; 1681 bool did_execute_command = false;
1684 for (; it != end; ++it) { 1682 for (; it != end; ++it) {
1685 // In gtk and cocoa, it's possible to bind multiple edit commands to one 1683 // In gtk and cocoa, it's possible to bind multiple edit commands to one
1686 // key (but it's the exception). Once one edit command is not executed, it 1684 // key (but it's the exception). Once one edit command is not executed, it
1687 // seems safest to not execute the rest. 1685 // seems safest to not execute the rest.
1688 if (!frame->executeCommand(WebString::fromUTF8(it->name), 1686 if (!frame->executeCommand(WebString::fromUTF8(it->name),
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); 2755 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin();
2758 if (focused_pepper_plugin) { 2756 if (focused_pepper_plugin) {
2759 focused_pepper_plugin->render_frame()->OnImeSetComposition( 2757 focused_pepper_plugin->render_frame()->OnImeSetComposition(
2760 text, underlines, selection_start, selection_end); 2758 text, underlines, selection_start, selection_end);
2761 return; 2759 return;
2762 } 2760 }
2763 #endif // ENABLE_PLUGINS 2761 #endif // ENABLE_PLUGINS
2764 if (replacement_range.IsValid() && webview()) { 2762 if (replacement_range.IsValid() && webview()) {
2765 // Select the text in |replacement_range|, it will then be replaced by 2763 // Select the text in |replacement_range|, it will then be replaced by
2766 // text added by the call to RenderWidget::OnImeSetComposition(). 2764 // text added by the call to RenderWidget::OnImeSetComposition().
2767 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { 2765 WebLocalFrame* frame = webview()->focusedFrame();
2768 WebRange webrange = WebRange::fromDocumentRange( 2766 WebRange webrange = WebRange::fromDocumentRange(
2769 frame, replacement_range.start(), replacement_range.length()); 2767 frame, replacement_range.start(), replacement_range.length());
2770 if (!webrange.isNull()) 2768 if (!webrange.isNull())
2771 frame->selectRange(webrange); 2769 frame->selectRange(webrange);
2772 }
2773 } 2770 }
2774 RenderWidget::OnImeSetComposition(text, 2771 RenderWidget::OnImeSetComposition(text,
2775 underlines, 2772 underlines,
2776 replacement_range, 2773 replacement_range,
2777 selection_start, 2774 selection_start,
2778 selection_end); 2775 selection_end);
2779 } 2776 }
2780 2777
2781 void RenderViewImpl::OnImeConfirmComposition( 2778 void RenderViewImpl::OnImeConfirmComposition(
2782 const base::string16& text, 2779 const base::string16& text,
2783 const gfx::Range& replacement_range, 2780 const gfx::Range& replacement_range,
2784 bool keep_selection) { 2781 bool keep_selection) {
2785 #if defined(ENABLE_PLUGINS) 2782 #if defined(ENABLE_PLUGINS)
2786 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); 2783 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin();
2787 if (focused_pepper_plugin) { 2784 if (focused_pepper_plugin) {
2788 focused_pepper_plugin->render_frame()->OnImeConfirmComposition( 2785 focused_pepper_plugin->render_frame()->OnImeConfirmComposition(
2789 text, replacement_range, keep_selection); 2786 text, replacement_range, keep_selection);
2790 return; 2787 return;
2791 } 2788 }
2792 #endif // ENABLE_PLUGINS 2789 #endif // ENABLE_PLUGINS
2793 if (replacement_range.IsValid() && webview()) { 2790 if (replacement_range.IsValid() && webview()) {
2794 // Select the text in |replacement_range|, it will then be replaced by 2791 // Select the text in |replacement_range|, it will then be replaced by
2795 // text added by the call to RenderWidget::OnImeConfirmComposition(). 2792 // text added by the call to RenderWidget::OnImeConfirmComposition().
2796 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { 2793 WebLocalFrame* frame = webview()->focusedFrame();
2797 WebRange webrange = WebRange::fromDocumentRange( 2794 WebRange webrange = WebRange::fromDocumentRange(
2798 frame, replacement_range.start(), replacement_range.length()); 2795 frame, replacement_range.start(), replacement_range.length());
2799 if (!webrange.isNull()) 2796 if (!webrange.isNull())
2800 frame->selectRange(webrange); 2797 frame->selectRange(webrange);
2801 }
2802 } 2798 }
2803 RenderWidget::OnImeConfirmComposition(text, 2799 RenderWidget::OnImeConfirmComposition(text,
2804 replacement_range, 2800 replacement_range,
2805 keep_selection); 2801 keep_selection);
2806 } 2802 }
2807 2803
2808 void RenderViewImpl::RenderWidgetDidSetColorProfile( 2804 void RenderViewImpl::RenderWidgetDidSetColorProfile(
2809 const std::vector<char>& profile) { 2805 const std::vector<char>& profile) {
2810 if (webview()) { 2806 if (webview()) {
2811 bool was_reset = (profile.size() == 1 && profile[0] == '0'); 2807 bool was_reset = (profile.size() == 1 && profile[0] == '0');
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 2855
2860 if (!webview()) 2856 if (!webview())
2861 return; 2857 return;
2862 size_t start_offset = 0; 2858 size_t start_offset = 0;
2863 size_t character_count = 0; 2859 size_t character_count = 0;
2864 if (!webview()->compositionRange(&start_offset, &character_count)) 2860 if (!webview()->compositionRange(&start_offset, &character_count))
2865 return; 2861 return;
2866 if (character_count == 0) 2862 if (character_count == 0)
2867 return; 2863 return;
2868 2864
2869 blink::WebFrame* frame = webview()->focusedFrame(); 2865 blink::WebLocalFrame* frame = webview()->focusedFrame();
2870 if (!frame)
2871 return;
2872 2866
2873 bounds_in_window->reserve(character_count); 2867 bounds_in_window->reserve(character_count);
2874 blink::WebRect webrect; 2868 blink::WebRect webrect;
2875 for (size_t i = 0; i < character_count; ++i) { 2869 for (size_t i = 0; i < character_count; ++i) {
2876 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { 2870 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) {
2877 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; 2871 DLOG(ERROR) << "Could not retrieve character rectangle at " << i;
2878 bounds_in_window->clear(); 2872 bounds_in_window->clear();
2879 return; 2873 return;
2880 } 2874 }
2881 ConvertViewportToWindowViaWidget(&webrect); 2875 ConvertViewportToWindowViaWidget(&webrect);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3281 return render_frame->focused_pepper_plugin(); 3275 return render_frame->focused_pepper_plugin();
3282 } 3276 }
3283 frame = frame->traverseNext(false); 3277 frame = frame->traverseNext(false);
3284 } 3278 }
3285 3279
3286 return nullptr; 3280 return nullptr;
3287 } 3281 }
3288 #endif 3282 #endif
3289 3283
3290 } // namespace content 3284 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698