1 /* 2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #include "config.h" 27 28 #include "NotImplemented.h" 29 30 #include "CharacterData.h" 31 #include "Document.h" 32 #include "EditCommand.h" 33 #include "Editor.h" 34 #include "NodeList.h" 35 #include "EditorClientJava.h" 36 #include "FocusController.h" 37 #include "Frame.h" 38 #include "FrameView.h" 39 #include <wtf/java/JavaEnv.h> 40 #include "KeyboardEvent.h" 41 #include "Page.h" 42 #include "PlatformKeyboardEvent.h" 43 #include "TextIterator.h" 44 #include "Widget.h" 45 //#include "visible_units.h" 46 47 #include <wtf/Assertions.h> 48 49 #include <iostream> 50 51 #include "com_sun_webkit_event_WCKeyEvent.h" 52 53 using namespace std; 54 55 namespace WebCore { 56 57 58 EditorClientJava::EditorClientJava(const JLObject &webPage) 59 : m_webPage(webPage) 60 , m_isInRedo(false) 61 { 62 } 63 64 EditorClientJava::~EditorClientJava() 65 { 66 } 67 68 void dump(int, Node*) 69 { 70 // for (int i=0; i<indent; i++) cout << " "; //XXX: uncomment 71 // cout << node->nodeType() << StringView(node->nodeName()) << endl; 72 // for (int i=0; i<node->childNodes()->length(); i++) { 73 // dump(indent+2, node->childNodes()->item(i)); 74 // } 75 } 76 77 // 78 // The below keyboard event handling code was adapted from 79 // WebKit/chromium/src/EditorClientImpl.cpp and WebKit/win/WebView.cpp 80 // 81 82 static const int VKEY_BACK = com_sun_webkit_event_WCKeyEvent_VK_BACK; 83 static const int VKEY_TAB = com_sun_webkit_event_WCKeyEvent_VK_TAB; 84 static const int VKEY_RETURN = com_sun_webkit_event_WCKeyEvent_VK_RETURN; 85 static const int VKEY_ESCAPE = com_sun_webkit_event_WCKeyEvent_VK_ESCAPE; 86 static const int VKEY_PRIOR = com_sun_webkit_event_WCKeyEvent_VK_PRIOR; 87 static const int VKEY_NEXT = com_sun_webkit_event_WCKeyEvent_VK_NEXT; 88 static const int VKEY_END = com_sun_webkit_event_WCKeyEvent_VK_END; 89 static const int VKEY_HOME = com_sun_webkit_event_WCKeyEvent_VK_HOME; 90 static const int VKEY_LEFT = com_sun_webkit_event_WCKeyEvent_VK_LEFT; 91 static const int VKEY_UP = com_sun_webkit_event_WCKeyEvent_VK_UP; 92 static const int VKEY_RIGHT = com_sun_webkit_event_WCKeyEvent_VK_RIGHT; 93 static const int VKEY_DOWN = com_sun_webkit_event_WCKeyEvent_VK_DOWN; 94 static const int VKEY_INSERT = com_sun_webkit_event_WCKeyEvent_VK_INSERT; 95 static const int VKEY_DELETE = com_sun_webkit_event_WCKeyEvent_VK_DELETE; 96 static const int VKEY_OEM_PERIOD = com_sun_webkit_event_WCKeyEvent_VK_OEM_PERIOD; 97 98 static const unsigned CtrlKey = 1 << 0; 99 static const unsigned AltKey = 1 << 1; 100 static const unsigned ShiftKey = 1 << 2; 101 static const unsigned MetaKey = 1 << 3; 102 #if OS(DARWIN) 103 // Aliases for the generic key defintions to make kbd shortcuts definitions more 104 // readable on OS X. 105 static const unsigned OptionKey = AltKey; 106 107 // Do not use this constant for anything but cursor movement commands. 108 static const unsigned CommandKey = MetaKey; 109 #endif 110 111 struct KeyDownEntry { 112 unsigned virtualKey; 113 unsigned modifiers; 114 const char* name; 115 }; 116 117 struct KeyPressEntry { 118 unsigned charCode; 119 unsigned modifiers; 120 const char* name; 121 }; 122 123 static const KeyDownEntry keyDownEntries[] = { 124 { VKEY_LEFT, 0, "MoveLeft" }, 125 { VKEY_LEFT, ShiftKey, "MoveLeftAndModifySelection" }, 126 #if OS(DARWIN) 127 { VKEY_LEFT, OptionKey, "MoveWordLeft" }, 128 { VKEY_LEFT, OptionKey | ShiftKey, 129 "MoveWordLeftAndModifySelection" }, 130 #else 131 { VKEY_LEFT, CtrlKey, "MoveWordLeft" }, 132 { VKEY_LEFT, CtrlKey | ShiftKey, 133 "MoveWordLeftAndModifySelection" }, 134 #endif 135 { VKEY_RIGHT, 0, "MoveRight" }, 136 { VKEY_RIGHT, ShiftKey, "MoveRightAndModifySelection" }, 137 #if OS(DARWIN) 138 { VKEY_RIGHT, OptionKey, "MoveWordRight" }, 139 { VKEY_RIGHT, OptionKey | ShiftKey, 140 "MoveWordRightAndModifySelection" }, 141 #else 142 { VKEY_RIGHT, CtrlKey, "MoveWordRight" }, 143 { VKEY_RIGHT, CtrlKey | ShiftKey, 144 "MoveWordRightAndModifySelection" }, 145 #endif 146 { VKEY_UP, 0, "MoveUp" }, 147 { VKEY_UP, ShiftKey, "MoveUpAndModifySelection" }, 148 { VKEY_PRIOR, ShiftKey, "MovePageUpAndModifySelection" }, 149 { VKEY_DOWN, 0, "MoveDown" }, 150 { VKEY_DOWN, ShiftKey, "MoveDownAndModifySelection" }, 151 { VKEY_NEXT, ShiftKey, "MovePageDownAndModifySelection" }, 152 #if !OS(DARWIN) 153 { VKEY_PRIOR, 0, "MovePageUp" }, 154 { VKEY_NEXT, 0, "MovePageDown" }, 155 #endif 156 { VKEY_HOME, 0, "MoveToBeginningOfLine" }, 157 { VKEY_HOME, ShiftKey, 158 "MoveToBeginningOfLineAndModifySelection" }, 159 #if OS(DARWIN) 160 { VKEY_LEFT, CommandKey, "MoveToBeginningOfLine" }, 161 { VKEY_LEFT, CommandKey | ShiftKey, 162 "MoveToBeginningOfLineAndModifySelection" }, 163 { VKEY_PRIOR, OptionKey, "MovePageUp" }, 164 { VKEY_NEXT, OptionKey, "MovePageDown" }, 165 #endif 166 #if OS(DARWIN) 167 { VKEY_UP, CommandKey, "MoveToBeginningOfDocument" }, 168 { VKEY_UP, CommandKey | ShiftKey, 169 "MoveToBeginningOfDocumentAndModifySelection" }, 170 #else 171 { VKEY_HOME, CtrlKey, "MoveToBeginningOfDocument" }, 172 { VKEY_HOME, CtrlKey | ShiftKey, 173 "MoveToBeginningOfDocumentAndModifySelection" }, 174 #endif 175 { VKEY_END, 0, "MoveToEndOfLine" }, 176 { VKEY_END, ShiftKey, "MoveToEndOfLineAndModifySelection" }, 177 #if OS(DARWIN) 178 { VKEY_DOWN, CommandKey, "MoveToEndOfDocument" }, 179 { VKEY_DOWN, CommandKey | ShiftKey, 180 "MoveToEndOfDocumentAndModifySelection" }, 181 #else 182 { VKEY_END, CtrlKey, "MoveToEndOfDocument" }, 183 { VKEY_END, CtrlKey | ShiftKey, 184 "MoveToEndOfDocumentAndModifySelection" }, 185 #endif 186 #if OS(DARWIN) 187 { VKEY_RIGHT, CommandKey, "MoveToEndOfLine" }, 188 { VKEY_RIGHT, CommandKey | ShiftKey, 189 "MoveToEndOfLineAndModifySelection" }, 190 #endif 191 { VKEY_BACK, 0, "DeleteBackward" }, 192 { VKEY_BACK, ShiftKey, "DeleteBackward" }, 193 { VKEY_DELETE, 0, "DeleteForward" }, 194 #if OS(DARWIN) 195 { VKEY_BACK, OptionKey, "DeleteWordBackward" }, 196 { VKEY_DELETE, OptionKey, "DeleteWordForward" }, 197 #else 198 { VKEY_BACK, CtrlKey, "DeleteWordBackward" }, 199 { VKEY_DELETE, CtrlKey, "DeleteWordForward" }, 200 #endif 201 { 'B', CtrlKey, "ToggleBold" }, 202 { 'I', CtrlKey, "ToggleItalic" }, 203 { 'U', CtrlKey, "ToggleUnderline" }, 204 { VKEY_ESCAPE, 0, "Cancel" }, 205 { VKEY_OEM_PERIOD, CtrlKey, "Cancel" }, 206 { VKEY_TAB, 0, "InsertTab" }, 207 { VKEY_TAB, ShiftKey, "InsertBacktab" }, 208 { VKEY_RETURN, 0, "InsertNewline" }, 209 { VKEY_RETURN, CtrlKey, "InsertNewline" }, 210 { VKEY_RETURN, AltKey, "InsertNewline" }, 211 { VKEY_RETURN, AltKey | ShiftKey, "InsertNewline" }, 212 { VKEY_RETURN, ShiftKey, "InsertLineBreak" }, 213 { VKEY_INSERT, CtrlKey, "Copy" }, 214 { VKEY_INSERT, ShiftKey, "Paste" }, 215 { VKEY_DELETE, ShiftKey, "Cut" }, 216 #if OS(DARWIN) 217 // We differ from Chromium here in that we implement 218 // the {Meta|Ctrl}-{C|V|X|A|Z|Y} shortcuts for both OS X 219 // and non-OS X platforms here, whereas Chromium has the 220 // OS X handling of these shortcuts implemented elsewhere 221 { 'C', MetaKey, "Copy" }, 222 { 'V', MetaKey, "Paste" }, 223 { 'V', MetaKey | ShiftKey, "PasteAndMatchStyle" }, 224 { 'X', MetaKey, "Cut" }, 225 { 'A', MetaKey, "SelectAll" }, 226 { 'Z', MetaKey, "Undo" }, 227 { 'Z', MetaKey | ShiftKey, "Redo" }, 228 { 'Y', MetaKey, "Redo" }, 229 #else 230 { 'C', CtrlKey, "Copy" }, 231 { 'V', CtrlKey, "Paste" }, 232 { 'V', CtrlKey | ShiftKey, "PasteAndMatchStyle" }, 233 { 'X', CtrlKey, "Cut" }, 234 { 'A', CtrlKey, "SelectAll" }, 235 { 'Z', CtrlKey, "Undo" }, 236 { 'Z', CtrlKey | ShiftKey, "Redo" }, 237 { 'Y', CtrlKey, "Redo" }, 238 #endif 239 }; 240 241 static const KeyPressEntry keyPressEntries[] = { 242 { '\t', 0, "InsertTab" }, 243 { '\t', ShiftKey, "InsertBacktab" }, 244 { '\r', 0, "InsertNewline" }, 245 { '\r', CtrlKey, "InsertNewline" }, 246 { '\r', ShiftKey, "InsertLineBreak" }, 247 { '\r', AltKey, "InsertNewline" }, 248 { '\r', AltKey | ShiftKey, "InsertNewline" }, 249 }; 250 251 const char* EditorClientJava::interpretKeyEvent(const KeyboardEvent* evt) 252 { 253 const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); 254 if (!keyEvent) 255 return ""; 256 257 static HashMap<int, const char*>* keyDownCommandsMap = 0; 258 static HashMap<int, const char*>* keyPressCommandsMap = 0; 259 260 if (!keyDownCommandsMap) { 261 keyDownCommandsMap = new HashMap<int, const char*>; 262 keyPressCommandsMap = new HashMap<int, const char*>; 263 264 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(keyDownEntries); i++) { 265 keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey, 266 keyDownEntries[i].name); 267 } 268 269 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(keyPressEntries); i++) { 270 keyPressCommandsMap->set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].charCode, 271 keyPressEntries[i].name); 272 } 273 } 274 275 unsigned modifiers = 0; 276 if (keyEvent->shiftKey()) 277 modifiers |= ShiftKey; 278 if (keyEvent->altKey()) 279 modifiers |= AltKey; 280 if (keyEvent->ctrlKey()) 281 modifiers |= CtrlKey; 282 if (keyEvent->metaKey()) 283 modifiers |= MetaKey; 284 285 if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) { 286 int mapKey = modifiers << 16 | evt->keyCode(); 287 return mapKey ? keyDownCommandsMap->get(mapKey) : 0; 288 } 289 290 int mapKey = modifiers << 16 | evt->charCode(); 291 return mapKey ? keyPressCommandsMap->get(mapKey) : 0; 292 } 293 294 bool EditorClientJava::handleEditingKeyboardEvent(KeyboardEvent* evt) 295 { 296 const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); 297 if (!keyEvent) 298 return false; 299 300 Frame* frame = downcast<Node>(evt->target())->document().frame(); 301 if (!frame) 302 return false; 303 304 String commandName = interpretKeyEvent(evt); 305 Editor::Command command = frame->editor().command(commandName); 306 307 if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) { 308 // WebKit doesn't have enough information about mode to decide how 309 // commands that just insert text if executed via Editor should be treated, 310 // so we leave it upon WebCore to either handle them immediately 311 // (e.g. Tab that changes focus) or let a keypress event be generated 312 // (e.g. Tab that inserts a Tab character, or Enter). 313 if (command.isTextInsertion() || commandName.isEmpty()) 314 return false; 315 return command.execute(evt); 316 } 317 318 if (command.execute(evt)) { 319 return true; 320 } 321 322 // Here we need to filter key events. 323 // On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>. 324 // In Webkit, EditorClient::handleKeyboardEvent in 325 // WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events. 326 // On Mac, it emits key events with ASCII text and meta on for Command-<x>. 327 // These key events should not emit text insert event. 328 // Alt key would be used to insert alternative character, so we should let 329 // through. Also note that Ctrl-Alt combination equals to AltGr key which is 330 // also used to insert alternative character. 331 // http://code.google.com/p/chromium/issues/detail?id=10846 332 // Windows sets both alt and meta are on when "Alt" key pressed. 333 // http://code.google.com/p/chromium/issues/detail?id=2215 334 // Also, we should not rely on an assumption that keyboards don't 335 // send ASCII characters when pressing a control key on Windows, 336 // which may be configured to do it so by user. 337 // See also http://en.wikipedia.org/wiki/Keyboard_Layout 338 // FIXME(ukai): investigate more detail for various keyboard layout. 339 if (evt->keyEvent()->text().length() == 1) { 340 UChar ch = evt->keyEvent()->text()[0U]; 341 342 // Don't insert null or control characters as they can result in 343 // unexpected behaviour 344 if (ch < ' ') 345 return false; 346 #if !OS(WINDOWS) 347 // Don't insert ASCII character if ctrl w/o alt or meta is on. 348 // On Mac, we should ignore events when meta is on (Command-<x>). 349 if (ch < 0x80) { 350 if (evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey()) 351 return false; 352 #if OS(DARWIN) 353 if (evt->keyEvent()->metaKey()) 354 return false; 355 #endif 356 } 357 #endif 358 } 359 360 if (!frame->editor().canEdit()) 361 return false; 362 363 return frame->editor().insertText(evt->keyEvent()->text(), evt); 364 } 365 366 void EditorClientJava::handleKeyboardEvent(KeyboardEvent* evt) 367 { 368 if (handleEditingKeyboardEvent(evt)) { 369 evt->setDefaultHandled(); 370 } 371 } 372 373 bool EditorClientJava::shouldDeleteRange(Range*) 374 { 375 notImplemented(); 376 return true; 377 } 378 379 #if ENABLE(DELETION_UI) 380 bool EditorClientJava::shouldShowDeleteInterface(HTMLElement*) 381 { 382 return false; 383 } 384 #endif 385 386 bool EditorClientJava::isContinuousSpellCheckingEnabled() 387 { 388 notImplemented(); 389 return false; 390 } 391 392 bool EditorClientJava::isGrammarCheckingEnabled() 393 { 394 notImplemented(); 395 return false; 396 } 397 398 bool EditorClientJava::isSelectTrailingWhitespaceEnabled() const 399 { 400 notImplemented(); 401 return false; 402 } 403 404 int EditorClientJava::spellCheckerDocumentTag() 405 { 406 notImplemented(); 407 return 0; 408 } 409 410 bool EditorClientJava::shouldBeginEditing(WebCore::Range*) 411 { 412 notImplemented(); 413 return true; 414 } 415 416 bool EditorClientJava::shouldEndEditing(WebCore::Range*) 417 { 418 notImplemented(); 419 return true; 420 } 421 422 bool EditorClientJava::shouldInsertText(const String&, Range*, EditorInsertAction) 423 { 424 notImplemented(); 425 return true; 426 } 427 428 bool EditorClientJava::shouldChangeSelectedRange(Range*, Range*, EAffinity, bool) 429 { 430 return true; 431 } 432 433 bool EditorClientJava::shouldApplyStyle(StyleProperties*, Range*) 434 { 435 return true; 436 } 437 438 void EditorClientJava::didApplyStyle() { 439 notImplemented(); 440 } 441 442 void EditorClientJava::didBeginEditing() 443 { 444 notImplemented(); 445 } 446 447 void EditorClientJava::respondToChangedContents() 448 { 449 notImplemented(); 450 } 451 452 void EditorClientJava::respondToChangedSelection(Frame *frame) 453 { 454 if (!frame || !frame->editor().hasComposition() 455 || frame->editor().ignoreSelectionChanges()) { 456 return; 457 } 458 unsigned start, end; 459 if (!frame->editor().getCompositionSelection(start, end)) { 460 // Commit composed text here outside the Java Input Method 461 // Framework. InputContext.endComposition() will be called 462 // later through a setInputMethodState() call. The 463 // endComposition call will generate an InputMethodEvent with 464 // committed text which will be ignored in 465 // JWebPane.processInputMethodEvent(). 466 frame->editor().cancelComposition(); 467 setInputMethodState(false); 468 } 469 } 470 471 void EditorClientJava::updateEditorStateAfterLayoutIfEditabilityChanged() { 472 notImplemented(); 473 } 474 475 void EditorClientJava::didEndEditing() 476 { 477 notImplemented(); 478 } 479 480 void EditorClientJava::didWriteSelectionToPasteboard() 481 { 482 notImplemented(); 483 } 484 485 bool EditorClientJava::canUndo() const 486 { 487 return !m_undoStack.isEmpty(); 488 } 489 490 bool EditorClientJava::canRedo() const 491 { 492 return !m_redoStack.isEmpty(); 493 } 494 495 void EditorClientJava::undo() 496 { 497 if (canUndo()) { 498 Ref<WebCore::UndoStep> step = WTFMove(*(--m_undoStack.end())); 499 m_undoStack.remove(--m_undoStack.end()); 500 // unapply will call us back to push this command onto the redo stack. 501 step->unapply(); 502 } 503 } 504 505 void EditorClientJava::redo() 506 { 507 if (canRedo()) { 508 Ref<WebCore::UndoStep> step = WTFMove(*(--m_redoStack.end())); 509 m_redoStack.remove(--m_redoStack.end()); 510 511 ASSERT(!m_isInRedo); 512 m_isInRedo = true; 513 // reapply will call us back to push this command onto the undo stack. 514 step->reapply(); 515 m_isInRedo = false; 516 } 517 } 518 519 bool EditorClientJava::shouldInsertNode(Node*, Range*, EditorInsertAction) 520 { 521 notImplemented(); 522 return true; 523 } 524 525 bool EditorClientJava::smartInsertDeleteEnabled() 526 { 527 notImplemented(); 528 return false; 529 } 530 531 void EditorClientJava::toggleContinuousSpellChecking() 532 { 533 notImplemented(); 534 } 535 536 void EditorClientJava::toggleGrammarChecking() 537 { 538 notImplemented(); 539 } 540 541 void EditorClientJava::textFieldDidBeginEditing(Element*) 542 { 543 notImplemented(); 544 } 545 546 void EditorClientJava::textFieldDidEndEditing(Element*) 547 { 548 notImplemented(); 549 } 550 551 void EditorClientJava::textDidChangeInTextField(Element*) 552 { 553 notImplemented(); 554 } 555 556 bool EditorClientJava::doTextFieldCommandFromEvent(Element*, KeyboardEvent*) 557 { 558 notImplemented(); 559 return false; 560 } 561 562 void EditorClientJava::textWillBeDeletedInTextField(Element*) 563 { 564 notImplemented(); 565 } 566 567 void EditorClientJava::textDidChangeInTextArea(Element*) 568 { 569 notImplemented(); 570 } 571 572 void EditorClientJava::overflowScrollPositionChanged() { 573 notImplemented(); 574 } 575 576 void EditorClientJava::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) 577 { 578 notImplemented(); 579 } 580 581 void EditorClientJava::updateSpellingUIWithMisspelledWord(const String&) 582 { 583 notImplemented(); 584 } 585 586 void EditorClientJava::showSpellingUI(bool) 587 { 588 notImplemented(); 589 } 590 591 bool EditorClientJava::spellingUIIsShowing() 592 { 593 notImplemented(); 594 return false; 595 } 596 597 598 bool EditorClientJava::shouldMoveRangeAfterDelete(Range*, Range*) 599 { 600 notImplemented(); 601 return true; 602 } 603 604 void EditorClientJava::setInputMethodState(bool enabled) 605 { 606 JNIEnv* env = WebCore_GetJavaEnv(); 607 608 static jmethodID midSetInputMethodState = env->GetMethodID( 609 PG_GetWebPageClass(env), 610 "setInputMethodState", 611 "(Z)V"); 612 ASSERT(midSetInputMethodState); 613 614 env->CallVoidMethod( 615 m_webPage, 616 midSetInputMethodState, 617 bool_to_jbool(enabled)); 618 CheckAndClearException(env); 619 } 620 621 void EditorClientJava::handleInputMethodKeydown(KeyboardEvent*) 622 { 623 notImplemented(); 624 } 625 626 void EditorClientJava::willSetInputMethodState() 627 { 628 notImplemented(); 629 } 630 631 bool EditorClientJava::canCopyCut(Frame*, bool defaultValue) const 632 { 633 return defaultValue; 634 } 635 636 bool EditorClientJava::canPaste(Frame*, bool defaultValue) const 637 { 638 return defaultValue; 639 } 640 641 void EditorClientJava::discardedComposition(Frame*) { 642 notImplemented(); 643 } 644 645 void EditorClientJava::canceledComposition() { 646 notImplemented(); 647 } 648 649 const int gc_maximumm_undoStackDepth = 1000; 650 void EditorClientJava::registerUndoStep(UndoStep& step) 651 { 652 if (m_undoStack.size() == gc_maximumm_undoStackDepth) 653 m_undoStack.removeFirst(); 654 if (!m_isInRedo) 655 m_redoStack.clear(); 656 m_undoStack.append(step); 657 } 658 659 void EditorClientJava::registerRedoStep(UndoStep& step) 660 { 661 m_redoStack.append(step); 662 } 663 664 void EditorClientJava::clearUndoRedoOperations() 665 { 666 m_undoStack.clear(); 667 m_redoStack.clear(); 668 } 669 670 void EditorClientJava::getClientPasteboardDataForRange(Range*, Vector<String>&, Vector<RefPtr<SharedBuffer> >&) 671 { 672 } 673 674 void EditorClientJava::willWriteSelectionToPasteboard(Range*) 675 { 676 } 677 678 // All of the member functions from TextCheckerClient is umimplemented 679 bool EditorClientJava::shouldEraseMarkersAfterChangeSelection(TextCheckingType) const 680 { 681 notImplemented(); 682 return true; 683 } 684 685 void EditorClientJava::ignoreWordInSpellDocument(const String&) 686 { 687 notImplemented(); 688 } 689 690 void EditorClientJava::learnWord(const String&) 691 { 692 notImplemented(); 693 } 694 695 void EditorClientJava::checkSpellingOfString(StringView, int*, int*) 696 { 697 notImplemented(); 698 } 699 700 String EditorClientJava::getAutoCorrectSuggestionForMisspelledWord(const String&) 701 { 702 notImplemented(); 703 return String(); 704 } 705 706 void EditorClientJava::checkGrammarOfString(StringView, Vector<GrammarDetail>&, int*, int*) 707 { 708 notImplemented(); 709 } 710 711 #if USE(UNIFIED_TEXT_CHECKING) 712 Vector<TextCheckingResult> EditorClientJava::checkTextOfParagraph(StringView, TextCheckingTypeMask, const VisibleSelection&) 713 { 714 notImplemented(); 715 return Vector<TextCheckingResult>(); 716 } 717 #endif 718 719 // For spellcheckers that support multiple languages, it's often important to be able to identify the language in order to 720 // provide more accurate correction suggestions. Caller can pass in more text in "context" to aid such spellcheckers on language 721 // identification. Noramlly it's the text surrounding the "word" for which we are getting correction suggestions. 722 void EditorClientJava::getGuessesForWord(const String&, const String&, const VisibleSelection&, Vector<String>&) 723 { 724 notImplemented(); 725 } 726 727 void EditorClientJava::requestCheckingOfString(TextCheckingRequest&, const VisibleSelection&) 728 { 729 notImplemented(); 730 } 731 732 String EditorClientJava::replacementURLForResource(Ref<WebCore::SharedBuffer>&&, const String&) 733 { 734 notImplemented(); 735 return { }; 736 } 737 738 } // namespace WebCore