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

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

Issue 2694543002: [refactor] Cleanup IME State in RenderWidgetHostViewMac which is already tracked by TextInputManager (Closed)
Patch Set: Fixed another compile error for Android test Created 3 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
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_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 1330
1331 bool RenderWidgetHostViewAura::GetTextRange(gfx::Range* range) const { 1331 bool RenderWidgetHostViewAura::GetTextRange(gfx::Range* range) const {
1332 if (!text_input_manager_ || !GetFocusedWidget()) 1332 if (!text_input_manager_ || !GetFocusedWidget())
1333 return false; 1333 return false;
1334 1334
1335 const TextInputManager::TextSelection* selection = 1335 const TextInputManager::TextSelection* selection =
1336 text_input_manager_->GetTextSelection(GetFocusedWidget()->GetView()); 1336 text_input_manager_->GetTextSelection(GetFocusedWidget()->GetView());
1337 if (!selection) 1337 if (!selection)
1338 return false; 1338 return false;
1339 1339
1340 range->set_start(selection->offset); 1340 range->set_start(selection->offset());
1341 range->set_end(selection->offset + selection->text.length()); 1341 range->set_end(selection->offset() + selection->text().length());
1342 return true; 1342 return true;
1343 } 1343 }
1344 1344
1345 bool RenderWidgetHostViewAura::GetCompositionTextRange( 1345 bool RenderWidgetHostViewAura::GetCompositionTextRange(
1346 gfx::Range* range) const { 1346 gfx::Range* range) const {
1347 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. 1347 // TODO(suzhe): implement this method when fixing http://crbug.com/55130.
1348 NOTIMPLEMENTED(); 1348 NOTIMPLEMENTED();
1349 return false; 1349 return false;
1350 } 1350 }
1351 1351
1352 bool RenderWidgetHostViewAura::GetSelectionRange(gfx::Range* range) const { 1352 bool RenderWidgetHostViewAura::GetSelectionRange(gfx::Range* range) const {
1353 if (!text_input_manager_ || !GetFocusedWidget()) 1353 if (!text_input_manager_ || !GetFocusedWidget())
1354 return false; 1354 return false;
1355 1355
1356 const TextInputManager::TextSelection* selection = 1356 const TextInputManager::TextSelection* selection =
1357 text_input_manager_->GetTextSelection(GetFocusedWidget()->GetView()); 1357 text_input_manager_->GetTextSelection(GetFocusedWidget()->GetView());
1358 if (!selection) 1358 if (!selection)
1359 return false; 1359 return false;
1360 1360
1361 range->set_start(selection->range.start()); 1361 range->set_start(selection->range().start());
1362 range->set_end(selection->range.end()); 1362 range->set_end(selection->range().end());
1363 return true; 1363 return true;
1364 } 1364 }
1365 1365
1366 bool RenderWidgetHostViewAura::SetSelectionRange(const gfx::Range& range) { 1366 bool RenderWidgetHostViewAura::SetSelectionRange(const gfx::Range& range) {
1367 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. 1367 // TODO(suzhe): implement this method when fixing http://crbug.com/55130.
1368 NOTIMPLEMENTED(); 1368 NOTIMPLEMENTED();
1369 return false; 1369 return false;
1370 } 1370 }
1371 1371
1372 bool RenderWidgetHostViewAura::DeleteRange(const gfx::Range& range) { 1372 bool RenderWidgetHostViewAura::DeleteRange(const gfx::Range& range) {
1373 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. 1373 // TODO(suzhe): implement this method when fixing http://crbug.com/55130.
1374 NOTIMPLEMENTED(); 1374 NOTIMPLEMENTED();
1375 return false; 1375 return false;
1376 } 1376 }
1377 1377
1378 bool RenderWidgetHostViewAura::GetTextFromRange( 1378 bool RenderWidgetHostViewAura::GetTextFromRange(
1379 const gfx::Range& range, 1379 const gfx::Range& range,
1380 base::string16* text) const { 1380 base::string16* text) const {
1381 if (!text_input_manager_ || !GetFocusedWidget()) 1381 if (!text_input_manager_ || !GetFocusedWidget())
1382 return false; 1382 return false;
1383 1383
1384 const TextInputManager::TextSelection* selection = 1384 const TextInputManager::TextSelection* selection =
1385 text_input_manager_->GetTextSelection(GetFocusedWidget()->GetView()); 1385 text_input_manager_->GetTextSelection(GetFocusedWidget()->GetView());
1386 if (!selection) 1386 if (!selection)
1387 return false; 1387 return false;
1388 1388
1389 gfx::Range selection_text_range(selection->offset, 1389 gfx::Range selection_text_range(
1390 selection->offset + selection->text.length()); 1390 selection->offset(), selection->offset() + selection->text().length());
1391 1391
1392 if (!selection_text_range.Contains(range)) { 1392 if (!selection_text_range.Contains(range)) {
1393 text->clear(); 1393 text->clear();
1394 return false; 1394 return false;
1395 } 1395 }
1396 if (selection_text_range.EqualsIgnoringDirection(range)) { 1396 if (selection_text_range.EqualsIgnoringDirection(range)) {
1397 // Avoid calling substr whose performance is low. 1397 // Avoid calling substr whose performance is low.
1398 *text = selection->text; 1398 *text = selection->text();
1399 } else { 1399 } else {
1400 *text = selection->text.substr(range.GetMin() - selection->offset, 1400 *text = selection->text().substr(range.GetMin() - selection->offset(),
1401 range.length()); 1401 range.length());
1402 } 1402 }
1403 return true; 1403 return true;
1404 } 1404 }
1405 1405
1406 void RenderWidgetHostViewAura::OnInputMethodChanged() { 1406 void RenderWidgetHostViewAura::OnInputMethodChanged() {
1407 // TODO(wjmaclean): can host_ ever be null? 1407 // TODO(wjmaclean): can host_ ever be null?
1408 if (!host_) 1408 if (!host_)
1409 return; 1409 return;
1410 1410
1411 // TODO(suzhe): implement the newly added “locale” property of HTML DOM 1411 // TODO(suzhe): implement the newly added “locale” property of HTML DOM
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 // this case we should use TextSelection for |this| since RWHV for guest 2349 // this case we should use TextSelection for |this| since RWHV for guest
2350 // forwards text selection information to its platform view. 2350 // forwards text selection information to its platform view.
2351 RenderWidgetHostViewBase* focused_view = 2351 RenderWidgetHostViewBase* focused_view =
2352 is_guest_view_hack_ ? this : GetFocusedWidget() 2352 is_guest_view_hack_ ? this : GetFocusedWidget()
2353 ? GetFocusedWidget()->GetView() 2353 ? GetFocusedWidget()->GetView()
2354 : nullptr; 2354 : nullptr;
2355 2355
2356 if (!focused_view) 2356 if (!focused_view)
2357 return; 2357 return;
2358 2358
2359 base::string16 selected_text; 2359 const TextInputManager::TextSelection* selection =
2360 if (GetTextInputManager() 2360 GetTextInputManager()->GetTextSelection(focused_view);
2361 ->GetTextSelection(focused_view) 2361 if (selection->selected_text().length()) {
2362 ->GetSelectedText(&selected_text) &&
2363 selected_text.length()) {
2364 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 2362 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
2365 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 2363 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
2366 clipboard_writer.WriteText(selected_text); 2364 clipboard_writer.WriteText(selection->selected_text());
2367 } 2365 }
2368 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 2366 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
2369 } 2367 }
2370 2368
2371 void RenderWidgetHostViewAura::SetPopupChild( 2369 void RenderWidgetHostViewAura::SetPopupChild(
2372 RenderWidgetHostViewAura* popup_child_host_view) { 2370 RenderWidgetHostViewAura* popup_child_host_view) {
2373 popup_child_host_view_ = popup_child_host_view; 2371 popup_child_host_view_ = popup_child_host_view;
2374 event_handler_->SetPopupChild( 2372 event_handler_->SetPopupChild(
2375 popup_child_host_view, 2373 popup_child_host_view,
2376 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); 2374 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr);
2377 } 2375 }
2378 2376
2379 } // namespace content 2377 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698