2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved.
3 * Copyright (C) 2010 Google, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "EditorClientImpl.h"
31 #include "EditCommand.h"
33 #include "EventHandler.h"
34 #include "EventNames.h"
36 #include "HTMLInputElement.h"
37 #include "HTMLNames.h"
38 #include "KeyboardCodes.h"
39 #include "KeyboardEvent.h"
40 #include "PlatformKeyboardEvent.h"
41 #include "PlatformString.h"
42 #include "RenderObject.h"
43 #include "SpellChecker.h"
45 #include "DOMUtilitiesPrivate.h"
46 #include "WebAutofillClient.h"
47 #include "WebEditingAction.h"
48 #include "WebElement.h"
49 #include "WebFrameClient.h"
50 #include "WebFrameImpl.h"
52 #include "WebInputElement.h"
53 #include "WebInputEventConversion.h"
55 #include "WebPermissionClient.h"
57 #include "WebSpellCheckClient.h"
58 #include "WebTextAffinity.h"
59 #include "WebTextCheckingCompletionImpl.h"
60 #include "WebViewClient.h"
61 #include "WebViewImpl.h"
63 using namespace WebCore;
67 // Arbitrary depth limit for the undo stack, to keep it from using
68 // unbounded memory. This is the maximum number of distinct undoable
69 // actions -- unbroken stretches of typed characters are coalesced
70 // into a single action.
71 static const size_t maximumUndoStackDepth = 1000;
73 EditorClientImpl::EditorClientImpl(WebViewImpl* webview)
76 , m_spellCheckThisFieldStatus(SpellCheckAutomatic)
80 EditorClientImpl::~EditorClientImpl()
84 void EditorClientImpl::pageDestroyed()
86 // Our lifetime is bound to the WebViewImpl.
89 bool EditorClientImpl::shouldShowDeleteInterface(HTMLElement* elem)
91 // Normally, we don't care to show WebCore's deletion UI, so we only enable
92 // it if in testing mode and the test specifically requests it by using this
94 return layoutTestMode()
95 && elem->getAttribute(HTMLNames::classAttr) == "needsDeletionUI";
98 bool EditorClientImpl::smartInsertDeleteEnabled()
100 if (m_webView->client())
101 return m_webView->client()->isSmartInsertDeleteEnabled();
105 bool EditorClientImpl::isSelectTrailingWhitespaceEnabled()
107 if (m_webView->client())
108 return m_webView->client()->isSelectTrailingWhitespaceEnabled();
116 bool EditorClientImpl::shouldSpellcheckByDefault()
118 // Spellcheck should be enabled for all editable areas (such as textareas,
119 // contentEditable regions, and designMode docs), except text inputs.
120 const Frame* frame = m_webView->focusedWebCoreFrame();
123 const Editor* editor = frame->editor();
126 if (editor->isSpellCheckingEnabledInFocusedNode())
128 const Document* document = frame->document();
131 const Node* node = document->focusedNode();
132 // If |node| is null, we default to allowing spellchecking. This is done in
133 // order to mitigate the issue when the user clicks outside the textbox, as a
134 // result of which |node| becomes null, resulting in all the spell check
135 // markers being deleted. Also, the Frame will decide not to do spellchecking
136 // if the user can't edit - so returning true here will not cause any problems
137 // to the Frame's behavior.
140 const RenderObject* renderer = node->renderer();
144 return !renderer->isTextField();
147 bool EditorClientImpl::isContinuousSpellCheckingEnabled()
149 if (m_spellCheckThisFieldStatus == SpellCheckForcedOff)
151 if (m_spellCheckThisFieldStatus == SpellCheckForcedOn)
153 return shouldSpellcheckByDefault();
156 void EditorClientImpl::toggleContinuousSpellChecking()
158 if (isContinuousSpellCheckingEnabled())
159 m_spellCheckThisFieldStatus = SpellCheckForcedOff;
161 m_spellCheckThisFieldStatus = SpellCheckForcedOn;
164 bool EditorClientImpl::isGrammarCheckingEnabled()
169 void EditorClientImpl::toggleGrammarChecking()
174 int EditorClientImpl::spellCheckerDocumentTag()
176 ASSERT_NOT_REACHED();
180 bool EditorClientImpl::shouldBeginEditing(Range* range)
182 if (m_webView->client())
183 return m_webView->client()->shouldBeginEditing(WebRange(range));
187 bool EditorClientImpl::shouldEndEditing(Range* range)
189 if (m_webView->client())
190 return m_webView->client()->shouldEndEditing(WebRange(range));
194 bool EditorClientImpl::shouldInsertNode(Node* node,
196 EditorInsertAction action)
198 if (m_webView->client()) {
199 return m_webView->client()->shouldInsertNode(WebNode(node),
201 static_cast<WebEditingAction>(action));
206 bool EditorClientImpl::shouldInsertText(const String& text,
208 EditorInsertAction action)
210 if (m_webView->client()) {
211 return m_webView->client()->shouldInsertText(WebString(text),
213 static_cast<WebEditingAction>(action));
219 bool EditorClientImpl::shouldDeleteRange(Range* range)
221 if (m_webView->client())
222 return m_webView->client()->shouldDeleteRange(WebRange(range));
226 bool EditorClientImpl::shouldChangeSelectedRange(Range* fromRange,
231 if (m_webView->client()) {
232 return m_webView->client()->shouldChangeSelectedRange(WebRange(fromRange),
234 static_cast<WebTextAffinity>(affinity),
240 bool EditorClientImpl::shouldApplyStyle(CSSStyleDeclaration* style,
243 if (m_webView->client()) {
244 // FIXME: Pass a reference to the CSSStyleDeclaration somehow.
245 return m_webView->client()->shouldApplyStyle(WebString(),
251 bool EditorClientImpl::shouldMoveRangeAfterDelete(Range* range,
252 Range* rangeToBeReplaced)
257 void EditorClientImpl::didBeginEditing()
259 if (m_webView->client())
260 m_webView->client()->didBeginEditing();
263 void EditorClientImpl::respondToChangedSelection()
265 if (m_webView->client()) {
266 Frame* frame = m_webView->focusedWebCoreFrame();
268 m_webView->client()->didChangeSelection(!frame->selection()->isRange());
272 void EditorClientImpl::respondToChangedContents()
274 if (m_webView->client())
275 m_webView->client()->didChangeContents();
278 void EditorClientImpl::didEndEditing()
280 if (m_webView->client())
281 m_webView->client()->didEndEditing();
284 void EditorClientImpl::didWriteSelectionToPasteboard()
288 void EditorClientImpl::didSetSelectionTypesForPasteboard()
292 void EditorClientImpl::registerCommandForUndo(PassRefPtr<EditCommand> command)
294 if (m_undoStack.size() == maximumUndoStackDepth)
295 m_undoStack.removeFirst(); // drop oldest item off the far end
298 m_undoStack.append(command);
301 void EditorClientImpl::registerCommandForRedo(PassRefPtr<EditCommand> command)
303 m_redoStack.append(command);
306 void EditorClientImpl::clearUndoRedoOperations()
312 bool EditorClientImpl::canCopyCut(Frame* frame, bool defaultValue) const
314 if (!m_webView->permissionClient())
316 return m_webView->permissionClient()->allowWriteToClipboard(WebFrameImpl::fromFrame(frame), defaultValue);
319 bool EditorClientImpl::canPaste(Frame* frame, bool defaultValue) const
321 if (!m_webView->permissionClient())
323 return m_webView->permissionClient()->allowReadFromClipboard(WebFrameImpl::fromFrame(frame), defaultValue);
326 bool EditorClientImpl::canUndo() const
328 return !m_undoStack.isEmpty();
331 bool EditorClientImpl::canRedo() const
333 return !m_redoStack.isEmpty();
336 void EditorClientImpl::undo()
339 EditCommandStack::iterator back = --m_undoStack.end();
340 RefPtr<EditCommand> command(*back);
341 m_undoStack.remove(back);
343 // unapply will call us back to push this command onto the redo stack.
347 void EditorClientImpl::redo()
350 EditCommandStack::iterator back = --m_redoStack.end();
351 RefPtr<EditCommand> command(*back);
352 m_redoStack.remove(back);
357 // reapply will call us back to push this command onto the undo stack.
363 // The below code was adapted from the WebKit file webview.cpp
366 static const unsigned CtrlKey = 1 << 0;
367 static const unsigned AltKey = 1 << 1;
368 static const unsigned ShiftKey = 1 << 2;
369 static const unsigned MetaKey = 1 << 3;
371 // Aliases for the generic key defintions to make kbd shortcuts definitions more
373 static const unsigned OptionKey = AltKey;
375 // Do not use this constant for anything but cursor movement commands. Keys
376 // with cmd set have their |isSystemKey| bit set, so chances are the shortcut
377 // will not be executed. Another, less important, reason is that shortcuts
378 // defined in the renderer do not blink the menu item that they triggered. See
379 // http://crbug.com/25856 and the bugs linked from there for details.
380 static const unsigned CommandKey = MetaKey;
383 // Keys with special meaning. These will be delegated to the editor using
384 // the execCommand() method
385 struct KeyDownEntry {
391 struct KeyPressEntry {
397 static const KeyDownEntry keyDownEntries[] = {
398 { VKEY_LEFT, 0, "MoveLeft" },
399 { VKEY_LEFT, ShiftKey, "MoveLeftAndModifySelection" },
401 { VKEY_LEFT, OptionKey, "MoveWordLeft" },
402 { VKEY_LEFT, OptionKey | ShiftKey,
403 "MoveWordLeftAndModifySelection" },
405 { VKEY_LEFT, CtrlKey, "MoveWordLeft" },
406 { VKEY_LEFT, CtrlKey | ShiftKey,
407 "MoveWordLeftAndModifySelection" },
409 { VKEY_RIGHT, 0, "MoveRight" },
410 { VKEY_RIGHT, ShiftKey, "MoveRightAndModifySelection" },
412 { VKEY_RIGHT, OptionKey, "MoveWordRight" },
413 { VKEY_RIGHT, OptionKey | ShiftKey,
414 "MoveWordRightAndModifySelection" },
416 { VKEY_RIGHT, CtrlKey, "MoveWordRight" },
417 { VKEY_RIGHT, CtrlKey | ShiftKey,
418 "MoveWordRightAndModifySelection" },
420 { VKEY_UP, 0, "MoveUp" },
421 { VKEY_UP, ShiftKey, "MoveUpAndModifySelection" },
422 { VKEY_PRIOR, ShiftKey, "MovePageUpAndModifySelection" },
423 { VKEY_DOWN, 0, "MoveDown" },
424 { VKEY_DOWN, ShiftKey, "MoveDownAndModifySelection" },
425 { VKEY_NEXT, ShiftKey, "MovePageDownAndModifySelection" },
427 { VKEY_PRIOR, 0, "MovePageUp" },
428 { VKEY_NEXT, 0, "MovePageDown" },
430 { VKEY_HOME, 0, "MoveToBeginningOfLine" },
431 { VKEY_HOME, ShiftKey,
432 "MoveToBeginningOfLineAndModifySelection" },
434 { VKEY_LEFT, CommandKey, "MoveToBeginningOfLine" },
435 { VKEY_LEFT, CommandKey | ShiftKey,
436 "MoveToBeginningOfLineAndModifySelection" },
437 { VKEY_PRIOR, OptionKey, "MovePageUp" },
438 { VKEY_NEXT, OptionKey, "MovePageDown" },
441 { VKEY_UP, CommandKey, "MoveToBeginningOfDocument" },
442 { VKEY_UP, CommandKey | ShiftKey,
443 "MoveToBeginningOfDocumentAndModifySelection" },
445 { VKEY_HOME, CtrlKey, "MoveToBeginningOfDocument" },
446 { VKEY_HOME, CtrlKey | ShiftKey,
447 "MoveToBeginningOfDocumentAndModifySelection" },
449 { VKEY_END, 0, "MoveToEndOfLine" },
450 { VKEY_END, ShiftKey, "MoveToEndOfLineAndModifySelection" },
452 { VKEY_DOWN, CommandKey, "MoveToEndOfDocument" },
453 { VKEY_DOWN, CommandKey | ShiftKey,
454 "MoveToEndOfDocumentAndModifySelection" },
456 { VKEY_END, CtrlKey, "MoveToEndOfDocument" },
457 { VKEY_END, CtrlKey | ShiftKey,
458 "MoveToEndOfDocumentAndModifySelection" },
461 { VKEY_RIGHT, CommandKey, "MoveToEndOfLine" },
462 { VKEY_RIGHT, CommandKey | ShiftKey,
463 "MoveToEndOfLineAndModifySelection" },
465 { VKEY_BACK, 0, "DeleteBackward" },
466 { VKEY_BACK, ShiftKey, "DeleteBackward" },
467 { VKEY_DELETE, 0, "DeleteForward" },
469 { VKEY_BACK, OptionKey, "DeleteWordBackward" },
470 { VKEY_DELETE, OptionKey, "DeleteWordForward" },
472 { VKEY_BACK, CtrlKey, "DeleteWordBackward" },
473 { VKEY_DELETE, CtrlKey, "DeleteWordForward" },
475 { 'B', CtrlKey, "ToggleBold" },
476 { 'I', CtrlKey, "ToggleItalic" },
477 { 'U', CtrlKey, "ToggleUnderline" },
478 { VKEY_ESCAPE, 0, "Cancel" },
479 { VKEY_OEM_PERIOD, CtrlKey, "Cancel" },
480 { VKEY_TAB, 0, "InsertTab" },
481 { VKEY_TAB, ShiftKey, "InsertBacktab" },
482 { VKEY_RETURN, 0, "InsertNewline" },
483 { VKEY_RETURN, CtrlKey, "InsertNewline" },
484 { VKEY_RETURN, AltKey, "InsertNewline" },
485 { VKEY_RETURN, AltKey | ShiftKey, "InsertNewline" },
486 { VKEY_RETURN, ShiftKey, "InsertLineBreak" },
487 { VKEY_INSERT, CtrlKey, "Copy" },
488 { VKEY_INSERT, ShiftKey, "Paste" },
489 { VKEY_DELETE, ShiftKey, "Cut" },
491 // On OS X, we pipe these back to the browser, so that it can do menu item
493 { 'C', CtrlKey, "Copy" },
494 { 'V', CtrlKey, "Paste" },
495 { 'V', CtrlKey | ShiftKey, "PasteAndMatchStyle" },
496 { 'X', CtrlKey, "Cut" },
497 { 'A', CtrlKey, "SelectAll" },
498 { 'Z', CtrlKey, "Undo" },
499 { 'Z', CtrlKey | ShiftKey, "Redo" },
500 { 'Y', CtrlKey, "Redo" },
504 static const KeyPressEntry keyPressEntries[] = {
505 { '\t', 0, "InsertTab" },
506 { '\t', ShiftKey, "InsertBacktab" },
507 { '\r', 0, "InsertNewline" },
508 { '\r', CtrlKey, "InsertNewline" },
509 { '\r', ShiftKey, "InsertLineBreak" },
510 { '\r', AltKey, "InsertNewline" },
511 { '\r', AltKey | ShiftKey, "InsertNewline" },
514 const char* EditorClientImpl::interpretKeyEvent(const KeyboardEvent* evt)
516 const PlatformKeyboardEvent* keyEvent = evt->keyEvent();
520 static HashMap<int, const char*>* keyDownCommandsMap = 0;
521 static HashMap<int, const char*>* keyPressCommandsMap = 0;
523 if (!keyDownCommandsMap) {
524 keyDownCommandsMap = new HashMap<int, const char*>;
525 keyPressCommandsMap = new HashMap<int, const char*>;
527 for (unsigned i = 0; i < arraysize(keyDownEntries); i++) {
528 keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey,
529 keyDownEntries[i].name);
532 for (unsigned i = 0; i < arraysize(keyPressEntries); i++) {
533 keyPressCommandsMap->set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].charCode,
534 keyPressEntries[i].name);
538 unsigned modifiers = 0;
539 if (keyEvent->shiftKey())
540 modifiers |= ShiftKey;
541 if (keyEvent->altKey())
543 if (keyEvent->ctrlKey())
544 modifiers |= CtrlKey;
545 if (keyEvent->metaKey())
546 modifiers |= MetaKey;
548 if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
549 int mapKey = modifiers << 16 | evt->keyCode();
550 return mapKey ? keyDownCommandsMap->get(mapKey) : 0;
553 int mapKey = modifiers << 16 | evt->charCode();
554 return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
557 bool EditorClientImpl::handleEditingKeyboardEvent(KeyboardEvent* evt)
559 const PlatformKeyboardEvent* keyEvent = evt->keyEvent();
560 // do not treat this as text input if it's a system key event
561 if (!keyEvent || keyEvent->isSystemKey())
564 Frame* frame = evt->target()->toNode()->document()->frame();
568 String commandName = interpretKeyEvent(evt);
569 Editor::Command command = frame->editor()->command(commandName);
571 if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
572 // WebKit doesn't have enough information about mode to decide how
573 // commands that just insert text if executed via Editor should be treated,
574 // so we leave it upon WebCore to either handle them immediately
575 // (e.g. Tab that changes focus) or let a keypress event be generated
576 // (e.g. Tab that inserts a Tab character, or Enter).
577 if (command.isTextInsertion() || commandName.isEmpty())
579 if (command.execute(evt)) {
580 if (m_webView->client())
581 m_webView->client()->didExecuteCommand(WebString(commandName));
587 if (command.execute(evt)) {
588 if (m_webView->client())
589 m_webView->client()->didExecuteCommand(WebString(commandName));
593 // Here we need to filter key events.
594 // On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>.
595 // In Webkit, EditorClient::handleKeyboardEvent in
596 // WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events.
597 // On Mac, it emits key events with ASCII text and meta on for Command-<x>.
598 // These key events should not emit text insert event.
599 // Alt key would be used to insert alternative character, so we should let
600 // through. Also note that Ctrl-Alt combination equals to AltGr key which is
601 // also used to insert alternative character.
602 // http://code.google.com/p/chromium/issues/detail?id=10846
603 // Windows sets both alt and meta are on when "Alt" key pressed.
604 // http://code.google.com/p/chromium/issues/detail?id=2215
605 // Also, we should not rely on an assumption that keyboards don't
606 // send ASCII characters when pressing a control key on Windows,
607 // which may be configured to do it so by user.
608 // See also http://en.wikipedia.org/wiki/Keyboard_Layout
609 // FIXME(ukai): investigate more detail for various keyboard layout.
610 if (evt->keyEvent()->text().length() == 1) {
611 UChar ch = evt->keyEvent()->text()[0U];
613 // Don't insert null or control characters as they can result in
614 // unexpected behaviour
618 // Don't insert ASCII character if ctrl w/o alt or meta is on.
619 // On Mac, we should ignore events when meta is on (Command-<x>).
621 if (evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey())
624 if (evt->keyEvent()->metaKey())
631 if (!frame->editor()->canEdit())
634 return frame->editor()->insertText(evt->keyEvent()->text(), evt);
637 void EditorClientImpl::handleKeyboardEvent(KeyboardEvent* evt)
639 // Give the embedder a chance to handle the keyboard event.
640 if ((m_webView->client()
641 && m_webView->client()->handleCurrentKeyboardEvent())
642 || handleEditingKeyboardEvent(evt))
643 evt->setDefaultHandled();
646 void EditorClientImpl::handleInputMethodKeydown(KeyboardEvent* keyEvent)
648 // We handle IME within chrome.
651 void EditorClientImpl::textFieldDidBeginEditing(Element* element)
655 void EditorClientImpl::textFieldDidEndEditing(Element* element)
657 HTMLInputElement* inputElement = toHTMLInputElement(element);
658 if (m_webView->autofillClient() && inputElement)
659 m_webView->autofillClient()->textFieldDidEndEditing(WebInputElement(inputElement));
661 // Notification that focus was lost. Be careful with this, it's also sent
662 // when the page is being closed.
664 // Hide any showing popup.
665 m_webView->hideAutofillPopup();
668 void EditorClientImpl::textDidChangeInTextField(Element* element)
670 ASSERT(element->hasLocalName(HTMLNames::inputTag));
671 HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
672 if (m_webView->autofillClient())
673 m_webView->autofillClient()->textFieldDidChange(WebInputElement(inputElement));
676 bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element,
677 KeyboardEvent* event)
679 HTMLInputElement* inputElement = toHTMLInputElement(element);
680 if (m_webView->autofillClient() && inputElement) {
681 m_webView->autofillClient()->textFieldDidReceiveKeyDown(WebInputElement(inputElement),
682 WebKeyboardEventBuilder(*event));
685 // The Mac code appears to use this method as a hook to implement special
686 // keyboard commands specific to Safari's auto-fill implementation. We
687 // just return false to allow the default action.
691 void EditorClientImpl::textWillBeDeletedInTextField(Element*)
695 void EditorClientImpl::textDidChangeInTextArea(Element*)
699 void EditorClientImpl::ignoreWordInSpellDocument(const String&)
704 void EditorClientImpl::learnWord(const String&)
709 void EditorClientImpl::checkSpellingOfString(const UChar* text, int length,
710 int* misspellingLocation,
711 int* misspellingLength)
713 // SpellCheckWord will write (0, 0) into the output vars, which is what our
714 // caller expects if the word is spelled correctly.
715 int spellLocation = -1;
718 // Check to see if the provided text is spelled correctly.
719 if (isContinuousSpellCheckingEnabled() && m_webView->spellCheckClient())
720 m_webView->spellCheckClient()->spellCheck(WebString(text, length), spellLocation, spellLength, 0);
726 // Note: the Mac code checks if the pointers are null before writing to them,
728 if (misspellingLocation)
729 *misspellingLocation = spellLocation;
730 if (misspellingLength)
731 *misspellingLength = spellLength;
734 void EditorClientImpl::requestCheckingOfString(SpellChecker* sender, int identifier, TextCheckingTypeMask, const String& text)
736 if (m_webView->spellCheckClient())
737 m_webView->spellCheckClient()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(identifier, sender));
740 String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord)
742 if (!(isContinuousSpellCheckingEnabled() && m_webView->client()))
745 // Do not autocorrect words with capital letters in it except the
746 // first letter. This will remove cases changing "IMB" to "IBM".
747 for (size_t i = 1; i < misspelledWord.length(); i++) {
748 if (u_isupper(static_cast<UChar32>(misspelledWord[i])))
752 if (m_webView->spellCheckClient())
753 return m_webView->spellCheckClient()->autoCorrectWord(WebString(misspelledWord));
757 void EditorClientImpl::checkGrammarOfString(const UChar*, int length,
758 WTF::Vector<GrammarDetail>&,
759 int* badGrammarLocation,
760 int* badGrammarLength)
763 if (badGrammarLocation)
764 *badGrammarLocation = 0;
765 if (badGrammarLength)
766 *badGrammarLength = 0;
769 void EditorClientImpl::updateSpellingUIWithGrammarString(const String&,
770 const GrammarDetail& detail)
775 void EditorClientImpl::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
777 if (m_webView->spellCheckClient())
778 m_webView->spellCheckClient()->updateSpellingUIWithMisspelledWord(WebString(misspelledWord));
781 void EditorClientImpl::showSpellingUI(bool show)
783 if (m_webView->spellCheckClient())
784 m_webView->spellCheckClient()->showSpellingUI(show);
787 bool EditorClientImpl::spellingUIIsShowing()
789 if (m_webView->spellCheckClient())
790 return m_webView->spellCheckClient()->isShowingSpellingUI();
794 void EditorClientImpl::getGuessesForWord(const String& word,
795 const String& context,
796 WTF::Vector<String>& guesses)
801 void EditorClientImpl::willSetInputMethodState()
803 if (m_webView->client())
804 m_webView->client()->resetInputMethod();
807 void EditorClientImpl::setInputMethodState(bool)