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

Side by Side Diff: components/test_runner/text_input_controller.cc

Issue 2012823003: Move IME related functions from WebFrame to WebLocalFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change for tkent@'s review Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/test_runner/text_input_controller.h" 5 #include "components/test_runner/text_input_controller.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "components/test_runner/web_test_proxy.h" 8 #include "components/test_runner/web_test_proxy.h"
9 #include "gin/arguments.h" 9 #include "gin/arguments.h"
10 #include "gin/handle.h" 10 #include "gin/handle.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 void TextInputController::InsertText(const std::string& text) { 160 void TextInputController::InsertText(const std::string& text) {
161 view()->confirmComposition(blink::WebString::fromUTF8(text)); 161 view()->confirmComposition(blink::WebString::fromUTF8(text));
162 } 162 }
163 163
164 void TextInputController::UnmarkText() { 164 void TextInputController::UnmarkText() {
165 view()->confirmComposition(); 165 view()->confirmComposition();
166 } 166 }
167 167
168 void TextInputController::DoCommand(const std::string& text) { 168 void TextInputController::DoCommand(const std::string& text) {
yabinh 2016/07/08 01:40:58 mainFrame() can be a remote frame because of OOPI,
169 if (view()->mainFrame()) 169 if (view()->mainFrame() && view()->mainFrame()->isWebLocalFrame())
170 view()->mainFrame()->executeCommand(blink::WebString::fromUTF8(text)); 170 view()->mainFrame()->toWebLocalFrame()->executeCommand(
171 blink::WebString::fromUTF8(text));
171 } 172 }
172 173
173 void TextInputController::SetMarkedText(const std::string& text, 174 void TextInputController::SetMarkedText(const std::string& text,
174 int start, 175 int start,
175 int length) { 176 int length) {
176 blink::WebString web_text(blink::WebString::fromUTF8(text)); 177 blink::WebString web_text(blink::WebString::fromUTF8(text));
177 178
178 // Split underline into up to 3 elements (before, selection, and after). 179 // Split underline into up to 3 elements (before, selection, and after).
179 std::vector<blink::WebCompositionUnderline> underlines; 180 std::vector<blink::WebCompositionUnderline> underlines;
180 blink::WebCompositionUnderline underline; 181 blink::WebCompositionUnderline underline;
(...skipping 11 matching lines...) Expand all
192 underline.startOffset = underline.endOffset; 193 underline.startOffset = underline.endOffset;
193 underline.endOffset = web_text.length(); 194 underline.endOffset = web_text.length();
194 underline.thick = false; 195 underline.thick = false;
195 underlines.push_back(underline); 196 underlines.push_back(underline);
196 } 197 }
197 198
198 view()->setComposition(web_text, underlines, start, start + length); 199 view()->setComposition(web_text, underlines, start, start + length);
199 } 200 }
200 201
201 bool TextInputController::HasMarkedText() { 202 bool TextInputController::HasMarkedText() {
202 return view()->mainFrame() && view()->mainFrame()->hasMarkedText(); 203 return view()->mainFrame() && view()->mainFrame()->isWebLocalFrame() &&
204 view()->mainFrame()->toWebLocalFrame()->hasMarkedText();
203 } 205 }
204 206
205 std::vector<int> TextInputController::MarkedRange() { 207 std::vector<int> TextInputController::MarkedRange() {
206 if (!view()->mainFrame()) 208 if (!view()->mainFrame() && !view()->mainFrame()->isWebLocalFrame())
207 return std::vector<int>(); 209 return std::vector<int>();
208 210
209 blink::WebRange range = view()->mainFrame()->markedRange(); 211 blink::WebRange range = view()->mainFrame()->toWebLocalFrame()->markedRange();
210 std::vector<int> int_array(2); 212 std::vector<int> int_array(2);
211 int_array[0] = range.startOffset(); 213 int_array[0] = range.startOffset();
212 int_array[1] = range.endOffset(); 214 int_array[1] = range.endOffset();
213 215
214 return int_array; 216 return int_array;
215 } 217 }
216 218
217 std::vector<int> TextInputController::SelectedRange() { 219 std::vector<int> TextInputController::SelectedRange() {
218 if (!view()->mainFrame()) 220 if (!view()->mainFrame() && !view()->mainFrame()->isWebLocalFrame())
219 return std::vector<int>(); 221 return std::vector<int>();
220 222
221 blink::WebRange range = view()->mainFrame()->selectionRange(); 223 blink::WebRange range =
224 view()->mainFrame()->toWebLocalFrame()->selectionRange();
222 if (range.isNull()) 225 if (range.isNull())
223 return std::vector<int>(); 226 return std::vector<int>();
224 std::vector<int> int_array(2); 227 std::vector<int> int_array(2);
225 int_array[0] = range.startOffset(); 228 int_array[0] = range.startOffset();
226 int_array[1] = range.endOffset(); 229 int_array[1] = range.endOffset();
227 230
228 return int_array; 231 return int_array;
229 } 232 }
230 233
231 std::vector<int> TextInputController::FirstRectForCharacterRange( 234 std::vector<int> TextInputController::FirstRectForCharacterRange(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 blink::WebString::fromUTF8(text), 267 blink::WebString::fromUTF8(text),
265 blink::WebVector<blink::WebCompositionUnderline>(underlines), 268 blink::WebVector<blink::WebCompositionUnderline>(underlines),
266 text.length(), text.length()); 269 text.length(), text.length());
267 } 270 }
268 271
269 blink::WebView* TextInputController::view() { 272 blink::WebView* TextInputController::view() {
270 return web_test_proxy_base_->web_view(); 273 return web_test_proxy_base_->web_view();
271 } 274 }
272 275
273 } // namespace test_runner 276 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698