| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google, Inc. All rights reserved. | 3 * Copyright (C) 2012 Google, Inc. All rights reserved. |
| 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 10 matching lines...) Expand all Loading... |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "EditorClientImpl.h" | 28 #include "EditorClientImpl.h" |
| 29 | 29 |
| 30 #include "HTMLNames.h" | 30 #include "HTMLNames.h" |
| 31 #include "WebAutofillClient.h" | |
| 32 #include "WebElement.h" | 31 #include "WebElement.h" |
| 33 #include "WebFrameClient.h" | 32 #include "WebFrameClient.h" |
| 34 #include "WebFrameImpl.h" | 33 #include "WebFrameImpl.h" |
| 35 #include "WebInputElement.h" | |
| 36 #include "WebInputEventConversion.h" | |
| 37 #include "WebKit.h" | 34 #include "WebKit.h" |
| 38 #include "WebNode.h" | 35 #include "WebNode.h" |
| 39 #include "WebPermissionClient.h" | 36 #include "WebPermissionClient.h" |
| 40 #include "WebRange.h" | 37 #include "WebRange.h" |
| 41 #include "WebSpellCheckClient.h" | 38 #include "WebSpellCheckClient.h" |
| 42 #include "WebTextAffinity.h" | 39 #include "WebTextAffinity.h" |
| 43 #include "WebTextCheckingCompletionImpl.h" | 40 #include "WebTextCheckingCompletionImpl.h" |
| 44 #include "WebTextCheckingResult.h" | 41 #include "WebTextCheckingResult.h" |
| 45 #include "WebViewClient.h" | 42 #include "WebViewClient.h" |
| 46 #include "WebViewImpl.h" | 43 #include "WebViewImpl.h" |
| 47 #include "core/dom/Document.h" | 44 #include "core/dom/Document.h" |
| 48 #include "core/dom/DocumentMarkerController.h" | 45 #include "core/dom/DocumentMarkerController.h" |
| 49 #include "core/editing/Editor.h" | 46 #include "core/editing/Editor.h" |
| 50 #include "core/editing/SpellChecker.h" | 47 #include "core/editing/SpellChecker.h" |
| 51 #include "core/editing/TextCheckingHelper.h" | 48 #include "core/editing/TextCheckingHelper.h" |
| 52 #include "core/editing/UndoStep.h" | 49 #include "core/editing/UndoStep.h" |
| 53 #include "core/events/KeyboardEvent.h" | 50 #include "core/events/KeyboardEvent.h" |
| 54 #include "core/events/ThreadLocalEventNames.h" | 51 #include "core/events/ThreadLocalEventNames.h" |
| 55 #include "core/frame/Frame.h" | 52 #include "core/frame/Frame.h" |
| 56 #include "core/html/HTMLInputElement.h" | |
| 57 #include "core/page/EventHandler.h" | 53 #include "core/page/EventHandler.h" |
| 58 #include "core/page/Page.h" | 54 #include "core/page/Page.h" |
| 59 #include "core/page/Settings.h" | 55 #include "core/page/Settings.h" |
| 60 #include "core/platform/chromium/KeyboardCodes.h" | 56 #include "core/platform/chromium/KeyboardCodes.h" |
| 61 #include "core/rendering/RenderObject.h" | 57 #include "core/rendering/RenderObject.h" |
| 62 #include "platform/PlatformKeyboardEvent.h" | 58 #include "platform/PlatformKeyboardEvent.h" |
| 63 #include "wtf/text/WTFString.h" | 59 #include "wtf/text/WTFString.h" |
| 64 | 60 |
| 65 using namespace WebCore; | 61 using namespace WebCore; |
| 66 | 62 |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 return frame->editor().insertText(evt->keyEvent()->text(), evt); | 514 return frame->editor().insertText(evt->keyEvent()->text(), evt); |
| 519 } | 515 } |
| 520 | 516 |
| 521 void EditorClientImpl::handleKeyboardEvent(KeyboardEvent* evt) | 517 void EditorClientImpl::handleKeyboardEvent(KeyboardEvent* evt) |
| 522 { | 518 { |
| 523 // Give the embedder a chance to handle the keyboard event. | 519 // Give the embedder a chance to handle the keyboard event. |
| 524 if ((m_webView->client() && m_webView->client()->handleCurrentKeyboardEvent(
)) || handleEditingKeyboardEvent(evt)) | 520 if ((m_webView->client() && m_webView->client()->handleCurrentKeyboardEvent(
)) || handleEditingKeyboardEvent(evt)) |
| 525 evt->setDefaultHandled(); | 521 evt->setDefaultHandled(); |
| 526 } | 522 } |
| 527 | 523 |
| 528 void EditorClientImpl::textFieldDidEndEditing(Element* element) | |
| 529 { | |
| 530 if (m_webView->autofillClient() && element->hasTagName(HTMLNames::inputTag)) | |
| 531 m_webView->autofillClient()->textFieldDidEndEditing(WebInputElement(toHT
MLInputElement(element))); | |
| 532 | |
| 533 // Notification that focus was lost. Be careful with this, it's also sent | |
| 534 // when the page is being closed. | |
| 535 | |
| 536 // Hide any showing popup. | |
| 537 m_webView->hideAutofillPopup(); | |
| 538 } | |
| 539 | |
| 540 void EditorClientImpl::textDidChangeInTextField(Element* element) | |
| 541 { | |
| 542 HTMLInputElement* inputElement = toHTMLInputElement(element); | |
| 543 if (m_webView->autofillClient()) | |
| 544 m_webView->autofillClient()->textFieldDidChange(WebInputElement(inputEle
ment)); | |
| 545 } | |
| 546 | |
| 547 bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element, KeyboardEve
nt* event) | |
| 548 { | |
| 549 if (m_webView->autofillClient() && element->hasTagName(HTMLNames::inputTag)) | |
| 550 m_webView->autofillClient()->textFieldDidReceiveKeyDown(WebInputElement(
toHTMLInputElement(element)), WebKeyboardEventBuilder(*event)); | |
| 551 | |
| 552 // The Mac code appears to use this method as a hook to implement special | |
| 553 // keyboard commands specific to Safari's auto-fill implementation. We | |
| 554 // just return false to allow the default action. | |
| 555 return false; | |
| 556 } | |
| 557 | |
| 558 bool EditorClientImpl::shouldEraseMarkersAfterChangeSelection(TextCheckingType t
ype) const | 524 bool EditorClientImpl::shouldEraseMarkersAfterChangeSelection(TextCheckingType t
ype) const |
| 559 { | 525 { |
| 560 const Frame* frame = m_webView->focusedWebCoreFrame(); | 526 const Frame* frame = m_webView->focusedWebCoreFrame(); |
| 561 return !frame || !frame->settings() || (!frame->settings()->asynchronousSpel
lCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled()); | 527 return !frame || !frame->settings() || (!frame->settings()->asynchronousSpel
lCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled()); |
| 562 } | 528 } |
| 563 | 529 |
| 564 void EditorClientImpl::checkSpellingOfString(const String& text, int* misspellin
gLocation, int* misspellingLength) | 530 void EditorClientImpl::checkSpellingOfString(const String& text, int* misspellin
gLocation, int* misspellingLength) |
| 565 { | 531 { |
| 566 // SpellCheckWord will write (0, 0) into the output vars, which is what our | 532 // SpellCheckWord will write (0, 0) into the output vars, which is what our |
| 567 // caller expects if the word is spelled correctly. | 533 // caller expects if the word is spelled correctly. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 #endif | 640 #endif |
| 675 } | 641 } |
| 676 | 642 |
| 677 void EditorClientImpl::willSetInputMethodState() | 643 void EditorClientImpl::willSetInputMethodState() |
| 678 { | 644 { |
| 679 if (m_webView->client()) | 645 if (m_webView->client()) |
| 680 m_webView->client()->resetInputMethod(); | 646 m_webView->client()->resetInputMethod(); |
| 681 } | 647 } |
| 682 | 648 |
| 683 } // namesace WebKit | 649 } // namesace WebKit |
| OLD | NEW |