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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_base.cc

Issue 2240553003: Track text selection on the browser side (Mac) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing erikchen@'s comments Created 4 years, 4 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/browser/renderer_host/render_widget_host_view_base.h" 5 #include "content/browser/renderer_host/render_widget_host_view_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h" 9 #include "content/browser/accessibility/browser_accessibility_manager.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 10 #include "content/browser/gpu/gpu_data_manager_impl.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling 57 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling
58 // NotifyObserversAboutShutdown() twice, as the observers are required to 58 // NotifyObserversAboutShutdown() twice, as the observers are required to
59 // de-register on the first call, and so the second call does nothing. 59 // de-register on the first call, and so the second call does nothing.
60 NotifyObserversAboutShutdown(); 60 NotifyObserversAboutShutdown();
61 // If we have a live reference to |text_input_manager_|, we should unregister 61 // If we have a live reference to |text_input_manager_|, we should unregister
62 // so that the |text_input_manager_| will free its state. 62 // so that the |text_input_manager_| will free its state.
63 if (text_input_manager_) 63 if (text_input_manager_)
64 text_input_manager_->Unregister(this); 64 text_input_manager_->Unregister(this);
65 } 65 }
66 66
67 // static
68 RenderWidgetHostViewBase* RenderWidgetHostViewBase::GetFocusedSubView(
69 RenderWidgetHostViewBase* view) {
70 RenderWidgetHostImpl* host =
71 RenderWidgetHostImpl::From(view->GetRenderWidgetHost());
72
73 if (!host || !host->delegate())
74 return nullptr;
75
76 RenderWidgetHostImpl* focused_widget =
77 host->delegate()->GetFocusedRenderWidgetHost(host);
78
79 return focused_widget ? focused_widget->GetView() : nullptr;
80 }
81
82 RenderWidgetHost* RenderWidgetHostViewBase::GetRenderWidgetHost() const {
83 return nullptr;
84 }
85
67 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { 86 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() {
68 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the 87 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the
69 // following notification to remove this view from its surface owners map. 88 // following notification to remove this view from its surface owners map.
70 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, 89 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver,
71 observers_, 90 observers_,
72 OnRenderWidgetHostViewBaseDestroyed(this)); 91 OnRenderWidgetHostViewBaseDestroyed(this));
73 // All observers are required to disconnect after they are notified. 92 // All observers are required to disconnect after they are notified.
74 DCHECK(!observers_.might_have_observers()); 93 DCHECK(!observers_.might_have_observers());
75 } 94 }
76 95
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (GetTextInputManager()) 129 if (GetTextInputManager())
111 GetTextInputManager()->SelectionBoundsChanged(this, params); 130 GetTextInputManager()->SelectionBoundsChanged(this, params);
112 } 131 }
113 132
114 void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text, 133 void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text,
115 size_t offset, 134 size_t offset,
116 const gfx::Range& range) { 135 const gfx::Range& range) {
117 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms. 136 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms.
118 // Also, remove the following local variables when that happens 137 // Also, remove the following local variables when that happens
119 // (https://crbug.com/578168 and https://crbug.com/602427). 138 // (https://crbug.com/578168 and https://crbug.com/602427).
120 #if defined(USE_AURA) 139 #if !defined(OS_ANDROID)
121 if (GetTextInputManager()) 140 if (GetTextInputManager())
122 GetTextInputManager()->SelectionChanged(this, text, offset, range); 141 GetTextInputManager()->SelectionChanged(this, text, offset, range);
123 #else 142 #else
124 selection_text_ = text; 143 selection_text_ = text;
125 selection_text_offset_ = offset; 144 selection_text_offset_ = offset;
126 selection_range_.set_start(range.start()); 145 selection_range_.set_start(range.start());
127 selection_range_.set_end(range.end()); 146 selection_range_.set_end(range.end());
128 #endif 147 #endif
129 } 148 }
130 149
(...skipping 12 matching lines...) Expand all
143 162
144 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { 163 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) {
145 DCHECK_NE(showing_context_menu_, showing); 164 DCHECK_NE(showing_context_menu_, showing);
146 showing_context_menu_ = showing; 165 showing_context_menu_ = showing;
147 } 166 }
148 167
149 base::string16 RenderWidgetHostViewBase::GetSelectedText() { 168 base::string16 RenderWidgetHostViewBase::GetSelectedText() {
150 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms. 169 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms.
151 // Also, remove the following local variables when that happens 170 // Also, remove the following local variables when that happens
152 // (https://crbug.com/578168 and https://crbug.com/602427). 171 // (https://crbug.com/578168 and https://crbug.com/602427).
153 #if defined(USE_AURA) 172 #if !defined(OS_ANDROID)
154 if (!GetTextInputManager()) 173 if (!GetTextInputManager())
155 return base::string16(); 174 return base::string16();
156 175
157 const TextInputManager::TextSelection* selection = 176 const TextInputManager::TextSelection* selection =
158 GetTextInputManager()->GetTextSelection(this); 177 GetTextInputManager()->GetTextSelection(this);
159 178
160 if (!selection || !selection->range.IsValid()) 179 if (!selection || !selection->range.IsValid())
161 return base::string16(); 180 return base::string16();
162 181
163 return selection->text.substr(selection->range.GetMin() - selection->offset, 182 return selection->text.substr(selection->range.GetMin() - selection->offset,
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 512
494 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { 513 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const {
495 return false; 514 return false;
496 } 515 }
497 516
498 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { 517 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const {
499 return cc::SurfaceId(); 518 return cc::SurfaceId();
500 } 519 }
501 520
502 } // namespace content 521 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698