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

Side by Side Diff: Source/web/EditorClientImpl.cpp

Issue 72543005: Get rid of explict editor dependency from text field (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-11-18T17:22:32 Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/EditorClientImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
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 "WebAutofillClient.h"
31 #include "WebFrameImpl.h" 30 #include "WebFrameImpl.h"
32 #include "WebInputElement.h"
33 #include "WebInputEventConversion.h"
34 #include "WebPermissionClient.h" 31 #include "WebPermissionClient.h"
35 #include "WebViewClient.h" 32 #include "WebViewClient.h"
36 #include "WebViewImpl.h" 33 #include "WebViewImpl.h"
37 #include "core/editing/Editor.h" 34 #include "core/editing/Editor.h"
38 #include "core/editing/UndoStep.h" 35 #include "core/editing/UndoStep.h"
39 #include "core/events/KeyboardEvent.h" 36 #include "core/events/KeyboardEvent.h"
40 #include "core/frame/Frame.h" 37 #include "core/frame/Frame.h"
41 #include "core/html/HTMLInputElement.h"
42 #include "core/page/EventHandler.h" 38 #include "core/page/EventHandler.h"
43 #include "core/page/Page.h" 39 #include "core/page/Page.h"
44 #include "core/page/Settings.h" 40 #include "core/page/Settings.h"
45 #include "core/platform/chromium/KeyboardCodes.h" 41 #include "core/platform/chromium/KeyboardCodes.h"
46 #include "platform/PlatformKeyboardEvent.h" 42 #include "platform/PlatformKeyboardEvent.h"
47 43
48 using namespace WebCore; 44 using namespace WebCore;
49 45
50 namespace blink { 46 namespace blink {
51 47
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return frame->editor().insertText(evt->keyEvent()->text(), evt); 412 return frame->editor().insertText(evt->keyEvent()->text(), evt);
417 } 413 }
418 414
419 void EditorClientImpl::handleKeyboardEvent(KeyboardEvent* evt) 415 void EditorClientImpl::handleKeyboardEvent(KeyboardEvent* evt)
420 { 416 {
421 // Give the embedder a chance to handle the keyboard event. 417 // Give the embedder a chance to handle the keyboard event.
422 if ((m_webView->client() && m_webView->client()->handleCurrentKeyboardEvent( )) || handleEditingKeyboardEvent(evt)) 418 if ((m_webView->client() && m_webView->client()->handleCurrentKeyboardEvent( )) || handleEditingKeyboardEvent(evt))
423 evt->setDefaultHandled(); 419 evt->setDefaultHandled();
424 } 420 }
425 421
426 void EditorClientImpl::textFieldDidEndEditing(Element* element)
427 {
428 if (m_webView->autofillClient() && element->hasTagName(HTMLNames::inputTag))
429 m_webView->autofillClient()->textFieldDidEndEditing(WebInputElement(toHT MLInputElement(element)));
430
431 // Notification that focus was lost. Be careful with this, it's also sent
432 // when the page is being closed.
433
434 // Hide any showing popup.
435 m_webView->hideAutofillPopup();
436 }
437
438 void EditorClientImpl::textDidChangeInTextField(Element* element)
439 {
440 HTMLInputElement* inputElement = toHTMLInputElement(element);
441 if (m_webView->autofillClient())
442 m_webView->autofillClient()->textFieldDidChange(WebInputElement(inputEle ment));
443 }
444
445 bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element, KeyboardEve nt* event)
446 {
447 if (m_webView->autofillClient() && element->hasTagName(HTMLNames::inputTag))
448 m_webView->autofillClient()->textFieldDidReceiveKeyDown(WebInputElement( toHTMLInputElement(element)), WebKeyboardEventBuilder(*event));
449
450 // The Mac code appears to use this method as a hook to implement special
451 // keyboard commands specific to Safari's auto-fill implementation. We
452 // just return false to allow the default action.
453 return false;
454 }
455
456 } // namesace WebKit 422 } // namesace WebKit
OLDNEW
« no previous file with comments | « Source/web/EditorClientImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698