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

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

Issue 1813143002: Remove a bunch of NPAPI quirks and related support code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_windowed_plugins
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/test/test_render_view_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 #endif 631 #endif
632 has_focus_(false), 632 has_focus_(false),
633 has_scrolled_focused_editable_node_into_rect_(false), 633 has_scrolled_focused_editable_node_into_rect_(false),
634 main_render_frame_(nullptr), 634 main_render_frame_(nullptr),
635 frame_widget_(nullptr), 635 frame_widget_(nullptr),
636 speech_recognition_dispatcher_(NULL), 636 speech_recognition_dispatcher_(NULL),
637 mouse_lock_dispatcher_(NULL), 637 mouse_lock_dispatcher_(NULL),
638 #if defined(OS_ANDROID) 638 #if defined(OS_ANDROID)
639 expected_content_intent_id_(0), 639 expected_content_intent_id_(0),
640 #endif 640 #endif
641 #if defined(OS_WIN)
642 focused_plugin_id_(-1),
643 #endif
644 #if defined(ENABLE_PLUGINS) 641 #if defined(ENABLE_PLUGINS)
645 focused_pepper_plugin_(NULL), 642 focused_pepper_plugin_(NULL),
646 pepper_last_mouse_event_target_(NULL), 643 pepper_last_mouse_event_target_(NULL),
647 #endif 644 #endif
648 enumeration_completion_id_(0), 645 enumeration_completion_id_(0),
649 session_storage_namespace_id_(params.session_storage_namespace_id) { 646 session_storage_namespace_id_(params.session_storage_namespace_id) {
650 GetWidget()->set_owner_delegate(this); 647 GetWidget()->set_owner_delegate(this);
651 } 648 }
652 649
653 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, 650 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params,
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 // environments where RenderView isn't hosting them), so we always have to 1200 // environments where RenderView isn't hosting them), so we always have to
1204 // set the initial state. See webplugin_delegate_impl.h for details. 1201 // set the initial state. See webplugin_delegate_impl.h for details.
1205 delegate->SetContentAreaFocus(has_focus()); 1202 delegate->SetContentAreaFocus(has_focus());
1206 } 1203 }
1207 1204
1208 void RenderViewImpl::UnregisterPluginDelegate( 1205 void RenderViewImpl::UnregisterPluginDelegate(
1209 WebPluginDelegateProxy* delegate) { 1206 WebPluginDelegateProxy* delegate) {
1210 plugin_delegates_.erase(delegate); 1207 plugin_delegates_.erase(delegate);
1211 } 1208 }
1212 1209
1213 #if defined(OS_WIN)
1214 void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) {
1215 if (focused)
1216 focused_plugin_id_ = plugin_id;
1217 else
1218 focused_plugin_id_ = -1;
1219 }
1220 #endif
1221
1222 #if defined(OS_MACOSX) 1210 #if defined(OS_MACOSX)
1223 void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { 1211 void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) {
1224 Send(new ViewHostMsg_PluginFocusChanged(GetRoutingID(), focused, plugin_id)); 1212 Send(new ViewHostMsg_PluginFocusChanged(GetRoutingID(), focused, plugin_id));
1225 } 1213 }
1226 1214
1227 void RenderViewImpl::OnGetRenderedText() { 1215 void RenderViewImpl::OnGetRenderedText() {
1228 if (!webview()) 1216 if (!webview())
1229 return; 1217 return;
1230 1218
1231 if (!webview()->mainFrame()->isWebLocalFrame()) 1219 if (!webview()->mainFrame()->isWebLocalFrame())
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 const std::vector<blink::WebCompositionUnderline>& underlines, 2907 const std::vector<blink::WebCompositionUnderline>& underlines,
2920 const gfx::Range& replacement_range, 2908 const gfx::Range& replacement_range,
2921 int selection_start, 2909 int selection_start,
2922 int selection_end) { 2910 int selection_end) {
2923 #if defined(ENABLE_PLUGINS) 2911 #if defined(ENABLE_PLUGINS)
2924 if (focused_pepper_plugin_) { 2912 if (focused_pepper_plugin_) {
2925 focused_pepper_plugin_->render_frame()->OnImeSetComposition( 2913 focused_pepper_plugin_->render_frame()->OnImeSetComposition(
2926 text, underlines, selection_start, selection_end); 2914 text, underlines, selection_start, selection_end);
2927 return; 2915 return;
2928 } 2916 }
2929
2930 #if defined(OS_WIN)
2931 // When a plugin has focus, we create platform-specific IME data used by
2932 // our IME emulator and send it directly to the focused plugin, i.e. we
2933 // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its
2934 // instance ID is the same one as the specified ID.)
2935 if (focused_plugin_id_ >= 0) {
2936 std::vector<int> clauses;
2937 std::vector<int> target;
2938 for (size_t i = 0; i < underlines.size(); ++i) {
2939 clauses.push_back(underlines[i].startOffset);
2940 clauses.push_back(underlines[i].endOffset);
2941 if (underlines[i].thick) {
2942 target.clear();
2943 target.push_back(underlines[i].startOffset);
2944 target.push_back(underlines[i].endOffset);
2945 }
2946 }
2947 std::set<WebPluginDelegateProxy*>::iterator it;
2948 for (it = plugin_delegates_.begin(); it != plugin_delegates_.end(); ++it) {
2949 (*it)->ImeCompositionUpdated(text, clauses, target, selection_end,
2950 focused_plugin_id_);
2951 }
2952 return;
2953 }
2954 #endif // OS_WIN
2955 #endif // ENABLE_PLUGINS 2917 #endif // ENABLE_PLUGINS
2956 if (replacement_range.IsValid() && webview()) { 2918 if (replacement_range.IsValid() && webview()) {
2957 // Select the text in |replacement_range|, it will then be replaced by 2919 // Select the text in |replacement_range|, it will then be replaced by
2958 // text added by the call to RenderWidget::OnImeSetComposition(). 2920 // text added by the call to RenderWidget::OnImeSetComposition().
2959 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { 2921 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) {
2960 WebRange webrange = WebRange::fromDocumentRange( 2922 WebRange webrange = WebRange::fromDocumentRange(
2961 frame, replacement_range.start(), replacement_range.length()); 2923 frame, replacement_range.start(), replacement_range.length());
2962 if (!webrange.isNull()) 2924 if (!webrange.isNull())
2963 frame->selectRange(webrange); 2925 frame->selectRange(webrange);
2964 } 2926 }
2965 } 2927 }
2966 RenderWidget::OnImeSetComposition(text, 2928 RenderWidget::OnImeSetComposition(text,
2967 underlines, 2929 underlines,
2968 replacement_range, 2930 replacement_range,
2969 selection_start, 2931 selection_start,
2970 selection_end); 2932 selection_end);
2971 } 2933 }
2972 2934
2973 void RenderViewImpl::OnImeConfirmComposition( 2935 void RenderViewImpl::OnImeConfirmComposition(
2974 const base::string16& text, 2936 const base::string16& text,
2975 const gfx::Range& replacement_range, 2937 const gfx::Range& replacement_range,
2976 bool keep_selection) { 2938 bool keep_selection) {
2977 #if defined(ENABLE_PLUGINS) 2939 #if defined(ENABLE_PLUGINS)
2978 if (focused_pepper_plugin_) { 2940 if (focused_pepper_plugin_) {
2979 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( 2941 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition(
2980 text, replacement_range, keep_selection); 2942 text, replacement_range, keep_selection);
2981 return; 2943 return;
2982 } 2944 }
2983 #if defined(OS_WIN)
2984 // Same as OnImeSetComposition(), we send the text from IMEs directly to
2985 // plugins. When we send IME text directly to plugins, we should not send
2986 // it to WebKit to prevent WebKit from controlling IMEs.
2987 // TODO(thakis): Honor |replacement_range| for plugins?
2988 if (focused_plugin_id_ >= 0) {
2989 std::set<WebPluginDelegateProxy*>::iterator it;
2990 for (it = plugin_delegates_.begin();
2991 it != plugin_delegates_.end(); ++it) {
2992 (*it)->ImeCompositionCompleted(text, focused_plugin_id_);
2993 }
2994 return;
2995 }
2996 #endif // OS_WIN
2997 #endif // ENABLE_PLUGINS 2945 #endif // ENABLE_PLUGINS
2998 if (replacement_range.IsValid() && webview()) { 2946 if (replacement_range.IsValid() && webview()) {
2999 // Select the text in |replacement_range|, it will then be replaced by 2947 // Select the text in |replacement_range|, it will then be replaced by
3000 // text added by the call to RenderWidget::OnImeConfirmComposition(). 2948 // text added by the call to RenderWidget::OnImeConfirmComposition().
3001 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { 2949 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) {
3002 WebRange webrange = WebRange::fromDocumentRange( 2950 WebRange webrange = WebRange::fromDocumentRange(
3003 frame, replacement_range.start(), replacement_range.length()); 2951 frame, replacement_range.start(), replacement_range.length());
3004 if (!webrange.isNull()) 2952 if (!webrange.isNull())
3005 frame->selectRange(webrange); 2953 frame->selectRange(webrange);
3006 } 2954 }
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
3504 if (IsUseZoomForDSFEnabled()) { 3452 if (IsUseZoomForDSFEnabled()) {
3505 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); 3453 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_);
3506 } else { 3454 } else {
3507 webview()->setDeviceScaleFactor(device_scale_factor_); 3455 webview()->setDeviceScaleFactor(device_scale_factor_);
3508 } 3456 }
3509 webview()->settings()->setPreferCompositingToLCDTextEnabled( 3457 webview()->settings()->setPreferCompositingToLCDTextEnabled(
3510 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); 3458 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
3511 } 3459 }
3512 3460
3513 } // namespace content 3461 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/test/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698