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

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodController.cpp

Issue 2668903003: Replace WTF::emptyString{16Bit}() with a static global (Closed)
Patch Set: Replace WTF::emptyString{16Bit}() with a static global Created 3 years, 10 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 if (frame().selection().isNone()) 431 if (frame().selection().isNone())
432 return; 432 return;
433 433
434 clear(); 434 clear();
435 435
436 // TODO(chongz): Figure out which InputType should we use here. 436 // TODO(chongz): Figure out which InputType should we use here.
437 dispatchBeforeInputFromComposition( 437 dispatchBeforeInputFromComposition(
438 document().focusedElement(), 438 document().focusedElement(),
439 InputEvent::InputType::DeleteComposedCharacterBackward, nullAtom, 439 InputEvent::InputType::DeleteComposedCharacterBackward, nullAtom,
440 InputEvent::EventCancelable::NotCancelable); 440 InputEvent::EventCancelable::NotCancelable);
441 dispatchCompositionUpdateEvent(frame(), emptyString()); 441 dispatchCompositionUpdateEvent(frame(), emptyString);
442 insertTextDuringCompositionWithEvents( 442 insertTextDuringCompositionWithEvents(
443 frame(), emptyString(), 0, 443 frame(), emptyString, 0,
444 TypingCommand::TextCompositionType::TextCompositionCancel); 444 TypingCommand::TextCompositionType::TextCompositionCancel);
445 // Event handler might destroy document. 445 // Event handler might destroy document.
446 if (!isAvailable()) 446 if (!isAvailable())
447 return; 447 return;
448 448
449 // An open typing command that disagrees about current selection would cause 449 // An open typing command that disagrees about current selection would cause
450 // issues with typing later on. 450 // issues with typing later on.
451 TypingCommand::closeTyping(m_frame); 451 TypingCommand::closeTyping(m_frame);
452 452
453 // No DOM update after 'compositionend'. 453 // No DOM update after 'compositionend'.
454 dispatchCompositionEndEvent(frame(), emptyString()); 454 dispatchCompositionEndEvent(frame(), emptyString);
455 } 455 }
456 456
457 void InputMethodController::cancelCompositionIfSelectionIsInvalid() { 457 void InputMethodController::cancelCompositionIfSelectionIsInvalid() {
458 if (!hasComposition() || editor().preventRevealSelection()) 458 if (!hasComposition() || editor().preventRevealSelection())
459 return; 459 return;
460 460
461 // Check if selection start and selection end are valid. 461 // Check if selection start and selection end are valid.
462 FrameSelection& selection = frame().selection(); 462 FrameSelection& selection = frame().selection();
463 if (!selection.isNone() && !m_compositionRange->collapsed()) { 463 if (!selection.isNone() && !m_compositionRange->collapsed()) {
464 if (selection.start().compareTo(m_compositionRange->startPosition()) >= 0 && 464 if (selection.start().compareTo(m_compositionRange->startPosition()) >= 0 &&
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // compositionupdate event is dispatched. 535 // compositionupdate event is dispatched.
536 // 2. Updating the existing composition node. 536 // 2. Updating the existing composition node.
537 // Send a compositionupdate event when this function updates the existing 537 // Send a compositionupdate event when this function updates the existing
538 // composition node, i.e. hasComposition() && !text.isEmpty(). 538 // composition node, i.e. hasComposition() && !text.isEmpty().
539 // 3. Canceling the ongoing composition. 539 // 3. Canceling the ongoing composition.
540 // Send a compositionend event when function deletes the existing 540 // Send a compositionend event when function deletes the existing
541 // composition node, i.e. !hasComposition() && test.isEmpty(). 541 // composition node, i.e. !hasComposition() && test.isEmpty().
542 if (text.isEmpty()) { 542 if (text.isEmpty()) {
543 if (hasComposition()) { 543 if (hasComposition()) {
544 Editor::RevealSelectionScope revealSelectionScope(&editor()); 544 Editor::RevealSelectionScope revealSelectionScope(&editor());
545 replaceComposition(emptyString()); 545 replaceComposition(emptyString);
546 } else { 546 } else {
547 // It's weird to call |setComposition()| with empty text outside 547 // It's weird to call |setComposition()| with empty text outside
548 // composition, however some IME (e.g. Japanese IBus-Anthy) did this, so 548 // composition, however some IME (e.g. Japanese IBus-Anthy) did this, so
549 // we simply delete selection without sending extra events. 549 // we simply delete selection without sending extra events.
550 TypingCommand::deleteSelection(document(), 550 TypingCommand::deleteSelection(document(),
551 TypingCommand::PreventSpellChecking); 551 TypingCommand::PreventSpellChecking);
552 } 552 }
553 553
554 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 554 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
555 // needs to be audited. see http://crbug.com/590369 for more details. 555 // needs to be audited. see http://crbug.com/590369 for more details.
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 frame().chromeClient().resetInputMethod(); 1091 frame().chromeClient().resetInputMethod();
1092 } 1092 }
1093 1093
1094 DEFINE_TRACE(InputMethodController) { 1094 DEFINE_TRACE(InputMethodController) {
1095 visitor->trace(m_frame); 1095 visitor->trace(m_frame);
1096 visitor->trace(m_compositionRange); 1096 visitor->trace(m_compositionRange);
1097 SynchronousMutationObserver::trace(visitor); 1097 SynchronousMutationObserver::trace(visitor);
1098 } 1098 }
1099 1099
1100 } // namespace blink 1100 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Text.cpp ('k') | third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698