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

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: Add CHECK in TextInputController::HasMarkedText() 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
169 if (view()->mainFrame()) 169 if (view()->mainFrame()) {
170 view()->mainFrame()->executeCommand(blink::WebString::fromUTF8(text)); 170 if (!view()->mainFrame()->toWebLocalFrame()) {
171 CHECK(false) << "This function cannot be called if the main frame is not"
172 "a local frame.";
173 }
174 view()->mainFrame()->toWebLocalFrame()->executeCommand(
175 blink::WebString::fromUTF8(text));
176 }
171 } 177 }
172 178
173 void TextInputController::SetMarkedText(const std::string& text, 179 void TextInputController::SetMarkedText(const std::string& text,
174 int start, 180 int start,
175 int length) { 181 int length) {
176 blink::WebString web_text(blink::WebString::fromUTF8(text)); 182 blink::WebString web_text(blink::WebString::fromUTF8(text));
177 183
178 // Split underline into up to 3 elements (before, selection, and after). 184 // Split underline into up to 3 elements (before, selection, and after).
179 std::vector<blink::WebCompositionUnderline> underlines; 185 std::vector<blink::WebCompositionUnderline> underlines;
180 blink::WebCompositionUnderline underline; 186 blink::WebCompositionUnderline underline;
(...skipping 11 matching lines...) Expand all
192 underline.startOffset = underline.endOffset; 198 underline.startOffset = underline.endOffset;
193 underline.endOffset = web_text.length(); 199 underline.endOffset = web_text.length();
194 underline.thick = false; 200 underline.thick = false;
195 underlines.push_back(underline); 201 underlines.push_back(underline);
196 } 202 }
197 203
198 view()->setComposition(web_text, underlines, start, start + length); 204 view()->setComposition(web_text, underlines, start, start + length);
199 } 205 }
200 206
201 bool TextInputController::HasMarkedText() { 207 bool TextInputController::HasMarkedText() {
202 return view()->mainFrame() && view()->mainFrame()->hasMarkedText(); 208 if (!view()->mainFrame())
209 return false;
210
211 if (!view()->mainFrame()->toWebLocalFrame()) {
212 CHECK(false) << "This function cannot be called if the main frame is not"
213 "a local frame.";
214 }
215
216 return view()->mainFrame()->toWebLocalFrame()->hasMarkedText();
203 } 217 }
204 218
205 std::vector<int> TextInputController::MarkedRange() { 219 std::vector<int> TextInputController::MarkedRange() {
206 if (!view()->mainFrame()) 220 if (!view()->mainFrame())
207 return std::vector<int>(); 221 return std::vector<int>();
208 222
209 blink::WebRange range = view()->mainFrame()->markedRange(); 223 if (!view()->mainFrame()->toWebLocalFrame()) {
224 CHECK(false) << "This function cannot be called if the main frame is not"
225 "a local frame.";
226 }
227
228 blink::WebRange range = view()->mainFrame()->toWebLocalFrame()->markedRange();
210 std::vector<int> int_array(2); 229 std::vector<int> int_array(2);
211 int_array[0] = range.startOffset(); 230 int_array[0] = range.startOffset();
212 int_array[1] = range.endOffset(); 231 int_array[1] = range.endOffset();
213 232
214 return int_array; 233 return int_array;
215 } 234 }
216 235
217 std::vector<int> TextInputController::SelectedRange() { 236 std::vector<int> TextInputController::SelectedRange() {
218 if (!view()->mainFrame()) 237 if (!view()->mainFrame())
219 return std::vector<int>(); 238 return std::vector<int>();
220 239
221 blink::WebRange range = view()->mainFrame()->selectionRange(); 240 if (!view()->mainFrame()->toWebLocalFrame()) {
241 CHECK(false) << "This function cannot be called if the main frame is not"
242 "a local frame.";
243 }
244
245 blink::WebRange range =
246 view()->mainFrame()->toWebLocalFrame()->selectionRange();
222 if (range.isNull()) 247 if (range.isNull())
223 return std::vector<int>(); 248 return std::vector<int>();
224 std::vector<int> int_array(2); 249 std::vector<int> int_array(2);
225 int_array[0] = range.startOffset(); 250 int_array[0] = range.startOffset();
226 int_array[1] = range.endOffset(); 251 int_array[1] = range.endOffset();
227 252
228 return int_array; 253 return int_array;
229 } 254 }
230 255
231 std::vector<int> TextInputController::FirstRectForCharacterRange( 256 std::vector<int> TextInputController::FirstRectForCharacterRange(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 blink::WebString::fromUTF8(text), 289 blink::WebString::fromUTF8(text),
265 blink::WebVector<blink::WebCompositionUnderline>(underlines), 290 blink::WebVector<blink::WebCompositionUnderline>(underlines),
266 text.length(), text.length()); 291 text.length(), text.length());
267 } 292 }
268 293
269 blink::WebView* TextInputController::view() { 294 blink::WebView* TextInputController::view() {
270 return web_test_proxy_base_->web_view(); 295 return web_test_proxy_base_->web_view();
271 } 296 }
272 297
273 } // namespace test_runner 298 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/test_runner_for_specific_view.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698